@opentiny/next-sdk 0.3.1 → 0.3.3-alpha.1

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.
Files changed (54) hide show
  1. package/WebMcp.ts +6 -0
  2. package/WebMcpClient.ts +16 -21
  3. package/agent/type.ts +93 -69
  4. package/core.ts +1 -0
  5. package/dist/SimulatorMask-BHVXyogh-BFEGpD5S.js +1048 -0
  6. package/dist/SimulatorMask-BHVXyogh-CCYbrb84.js +801 -0
  7. package/dist/WebMcp.d.ts +3 -0
  8. package/dist/WebMcpClient.d.ts +7 -13
  9. package/dist/agent/type.d.ts +10 -0
  10. package/dist/core.d.ts +1 -0
  11. package/dist/core.js +16 -15
  12. package/dist/index.d.ts +3 -2
  13. package/dist/index.es.dev.js +8384 -2700
  14. package/dist/index.es.js +21608 -16893
  15. package/dist/index.js +4033 -1850
  16. package/dist/index.umd.dev.js +9739 -3110
  17. package/dist/index.umd.js +500 -66
  18. package/dist/initialize-builtin-WebMCP-HgObT902.js +6279 -0
  19. package/dist/mcpsdk@1.25.3.dev.js +253 -94
  20. package/dist/mcpsdk@1.25.3.es.dev.js +253 -94
  21. package/dist/mcpsdk@1.25.3.es.js +5689 -5531
  22. package/dist/mcpsdk@1.25.3.js +32 -27
  23. package/dist/page-tools/a11y-tree.d.ts +103 -0
  24. package/dist/page-tools/bridge.d.ts +0 -6
  25. package/dist/page-tools/initialize-builtin-WebMCP.d.ts +1 -0
  26. package/dist/page-tools/page-agent-tool.d.ts +9 -0
  27. package/dist/page-tools/page-state-cache.d.ts +36 -0
  28. package/dist/skills/index.d.ts +7 -12
  29. package/dist/webagent.dev.js +3772 -1919
  30. package/dist/webagent.es.dev.js +3528 -1571
  31. package/dist/webagent.es.js +16380 -14585
  32. package/dist/webagent.js +74 -66
  33. package/dist/webmcp-full.dev.js +7670 -747
  34. package/dist/webmcp-full.es.dev.js +6482 -608
  35. package/dist/webmcp-full.es.js +12180 -7618
  36. package/dist/webmcp-full.js +631 -29
  37. package/dist/webmcp.dev.js +8047 -53
  38. package/dist/webmcp.es.dev.js +6977 -31
  39. package/dist/webmcp.es.js +6187 -860
  40. package/dist/webmcp.js +602 -1
  41. package/index.ts +2 -15
  42. package/package.json +11 -4
  43. package/page-tools/a11y-tree.ts +532 -0
  44. package/page-tools/bridge.ts +48 -14
  45. package/page-tools/initialize-builtin-WebMCP.ts +20 -0
  46. package/page-tools/page-agent-prompt.md +123 -0
  47. package/page-tools/page-agent-tool.ts +223 -0
  48. package/page-tools/page-state-cache.ts +78 -0
  49. package/remoter/createRemoter.ts +2 -1
  50. package/remoter/svgs/logo.svg +45 -0
  51. package/skills/index.ts +50 -31
  52. package/utils/builtinProxy.ts +42 -20
  53. package/vite-env.d.ts +5 -0
  54. package/dist/AgentModelProvider-BnMj6YSC.js +0 -4182
@@ -1,43 +1,48 @@
1
- (function(S,Qt){typeof exports=="object"&&typeof module<"u"?Qt(exports):typeof define=="function"&&define.amd?define(["exports"],Qt):(S=typeof globalThis<"u"?globalThis:S||self,Qt(S.MCPSDK={}))})(this,(function(S){"use strict";function Qt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var tn={exports:{}},Fs={},yt={},Zt={},Hs={},Ws={},Ks={},Ki;function rn(){return Ki||(Ki=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(d){if(super(),!t.IDENTIFIER.test(d))throw new Error("CodeGen: name must be a valid identifier");this.str=d}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(d){super(),this._items=typeof d=="string"?[d]:d}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const d=this._items[0];return d===""||d==='""'}get str(){var d;return(d=this._str)!==null&&d!==void 0?d:this._str=this._items.reduce((m,b)=>`${m}${b}`,"")}get names(){var d;return(d=this._names)!==null&&d!==void 0?d: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(w,...d){const m=[w[0]];let b=0;for(;b<d.length;)o(m,d[b]),m.push(w[++b]);return new n(m)}t._=s;const a=new n("+");function i(w,...d){const m=[_(w[0])];let b=0;for(;b<d.length;)m.push(a),o(m,d[b]),m.push(a,_(w[++b]));return c(m),new n(m)}t.str=i;function o(w,d){d instanceof n?w.push(...d._items):d instanceof r?w.push(d):w.push(h(d))}t.addCodeArg=o;function c(w){let d=1;for(;d<w.length-1;){if(w[d]===a){const m=u(w[d-1],w[d+1]);if(m!==void 0){w.splice(d-1,3,m);continue}w[d++]="+"}d++}}function u(w,d){if(d==='""')return w;if(w==='""')return d;if(typeof w=="string")return d instanceof r||w[w.length-1]!=='"'?void 0:typeof d!="string"?`${w.slice(0,-1)}${d}"`:d[0]==='"'?w.slice(0,-1)+d.slice(1):void 0;if(typeof d=="string"&&d[0]==='"'&&!(w instanceof r))return`"${w}${d.slice(1)}`}function l(w,d){return d.emptyStr()?w:w.emptyStr()?d:i`${w}${d}`}t.strConcat=l;function h(w){return typeof w=="number"||typeof w=="boolean"||w===null?w:_(Array.isArray(w)?w.join(","):w)}function g(w){return new n(_(w))}t.stringify=g;function _(w){return JSON.stringify(w).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=_;function p(w){return typeof w=="string"&&t.IDENTIFIER.test(w)?new n(`.${w}`):s`[${w}]`}t.getProperty=p;function y(w){if(typeof w=="string"&&t.IDENTIFIER.test(w))return new n(`${w}`);throw new Error(`CodeGen: invalid export name: ${w}, use explicit $id name mapping`)}t.getEsmExportName=y;function f(w){return new n(w.toString())}t.regexpCode=f})(Ks)),Ks}var Js={},Ji;function Gi(){return Ji||(Ji=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=rn();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,h;if(!((h=(l=this._parent)===null||l===void 0?void 0:l._prefixes)===null||h===void 0)&&h.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 a extends e.Name{constructor(u,l){super(l),this.prefix=u}setValue(u,{property:l,itemIndex:h}){this.value=u,this.scopePath=(0,e._)`.${new e.Name(l)}[${h}]`}}t.ValueScopeName=a;const i=(0,e._)`\n`;class o 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 a(u,this._newName(u))}value(u,l){var h;if(l.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const g=this.toName(u),{prefix:_}=g,p=(h=l.key)!==null&&h!==void 0?h:l.ref;let y=this._values[_];if(y){const d=y.get(p);if(d)return d}else y=this._values[_]=new Map;y.set(p,g);const f=this._scope[_]||(this._scope[_]=[]),w=f.length;return f[w]=l.ref,g.setValue(l,{property:_,itemIndex:w}),g}getValue(u,l){const h=this._values[u];if(h)return h.get(l)}scopeRefs(u,l=this._values){return this._reduceValues(l,h=>{if(h.scopePath===void 0)throw new Error(`CodeGen: name "${h}" has no value`);return(0,e._)`${u}${h.scopePath}`})}scopeCode(u=this._values,l,h){return this._reduceValues(u,g=>{if(g.value===void 0)throw new Error(`CodeGen: name "${g}" has no value`);return g.value.code},l,h)}_reduceValues(u,l,h={},g){let _=e.nil;for(const p in u){const y=u[p];if(!y)continue;const f=h[p]=h[p]||new Map;y.forEach(w=>{if(f.has(w))return;f.set(w,n.Started);let d=l(w);if(d){const m=this.opts.es5?t.varKinds.var:t.varKinds.const;_=(0,e._)`${_}${m} ${w} = ${d};${this.opts._n}`}else if(d=g?.(w))_=(0,e._)`${_}${d}${this.opts._n}`;else throw new r(w);f.set(w,n.Completed)})}return _}}t.ValueScope=o})(Js)),Js}var Bi;function ae(){return Bi||(Bi=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=rn(),r=Gi();var n=rn();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=Gi();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(k,T){return this}}class i extends a{constructor(k,T,j){super(),this.varKind=k,this.name=T,this.rhs=j}render({es5:k,_n:T}){const j=k?r.varKinds.var:this.varKind,ee=this.rhs===void 0?"":` = ${this.rhs}`;return`${j} ${this.name}${ee};`+T}optimizeNames(k,T){if(k[this.name.str])return this.rhs&&(this.rhs=Y(this.rhs,k,T)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class o extends a{constructor(k,T,j){super(),this.lhs=k,this.rhs=T,this.sideEffects=j}render({_n:k}){return`${this.lhs} = ${this.rhs};`+k}optimizeNames(k,T){if(!(this.lhs instanceof e.Name&&!k[this.lhs.str]&&!this.sideEffects))return this.rhs=Y(this.rhs,k,T),this}get names(){const k=this.lhs instanceof e.Name?{}:{...this.lhs.names};return G(k,this.rhs)}}class c extends o{constructor(k,T,j,ee){super(k,j,ee),this.op=T}render({_n:k}){return`${this.lhs} ${this.op}= ${this.rhs};`+k}}class u extends a{constructor(k){super(),this.label=k,this.names={}}render({_n:k}){return`${this.label}:`+k}}class l extends a{constructor(k){super(),this.label=k,this.names={}}render({_n:k}){return`break${this.label?` ${this.label}`:""};`+k}}class h extends a{constructor(k){super(),this.error=k}render({_n:k}){return`throw ${this.error};`+k}get names(){return this.error.names}}class g extends a{constructor(k){super(),this.code=k}render({_n:k}){return`${this.code};`+k}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(k,T){return this.code=Y(this.code,k,T),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class _ extends a{constructor(k=[]){super(),this.nodes=k}render(k){return this.nodes.reduce((T,j)=>T+j.render(k),"")}optimizeNodes(){const{nodes:k}=this;let T=k.length;for(;T--;){const j=k[T].optimizeNodes();Array.isArray(j)?k.splice(T,1,...j):j?k[T]=j:k.splice(T,1)}return k.length>0?this:void 0}optimizeNames(k,T){const{nodes:j}=this;let ee=j.length;for(;ee--;){const ne=j[ee];ne.optimizeNames(k,T)||(ge(k,ne.names),j.splice(ee,1))}return j.length>0?this:void 0}get names(){return this.nodes.reduce((k,T)=>F(k,T.names),{})}}class p extends _{render(k){return"{"+k._n+super.render(k)+"}"+k._n}}class y extends _{}class f extends p{}f.kind="else";class w extends p{constructor(k,T){super(T),this.condition=k}render(k){let T=`if(${this.condition})`+super.render(k);return this.else&&(T+="else "+this.else.render(k)),T}optimizeNodes(){super.optimizeNodes();const k=this.condition;if(k===!0)return this.nodes;let T=this.else;if(T){const j=T.optimizeNodes();T=this.else=Array.isArray(j)?new f(j):j}if(T)return k===!1?T instanceof w?T:T.nodes:this.nodes.length?this:new w(We(k),T instanceof w?[T]:T.nodes);if(!(k===!1||!this.nodes.length))return this}optimizeNames(k,T){var j;if(this.else=(j=this.else)===null||j===void 0?void 0:j.optimizeNames(k,T),!!(super.optimizeNames(k,T)||this.else))return this.condition=Y(this.condition,k,T),this}get names(){const k=super.names;return G(k,this.condition),this.else&&F(k,this.else.names),k}}w.kind="if";class d extends p{}d.kind="for";class m extends d{constructor(k){super(),this.iteration=k}render(k){return`for(${this.iteration})`+super.render(k)}optimizeNames(k,T){if(super.optimizeNames(k,T))return this.iteration=Y(this.iteration,k,T),this}get names(){return F(super.names,this.iteration.names)}}class b extends d{constructor(k,T,j,ee){super(),this.varKind=k,this.name=T,this.from=j,this.to=ee}render(k){const T=k.es5?r.varKinds.var:this.varKind,{name:j,from:ee,to:ne}=this;return`for(${T} ${j}=${ee}; ${j}<${ne}; ${j}++)`+super.render(k)}get names(){const k=G(super.names,this.from);return G(k,this.to)}}class v extends d{constructor(k,T,j,ee){super(),this.loop=k,this.varKind=T,this.name=j,this.iterable=ee}render(k){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(k)}optimizeNames(k,T){if(super.optimizeNames(k,T))return this.iterable=Y(this.iterable,k,T),this}get names(){return F(super.names,this.iterable.names)}}class $ extends p{constructor(k,T,j){super(),this.name=k,this.args=T,this.async=j}render(k){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(k)}}$.kind="func";class E extends _{render(k){return"return "+super.render(k)}}E.kind="return";class N extends p{render(k){let T="try"+super.render(k);return this.catch&&(T+=this.catch.render(k)),this.finally&&(T+=this.finally.render(k)),T}optimizeNodes(){var k,T;return super.optimizeNodes(),(k=this.catch)===null||k===void 0||k.optimizeNodes(),(T=this.finally)===null||T===void 0||T.optimizeNodes(),this}optimizeNames(k,T){var j,ee;return super.optimizeNames(k,T),(j=this.catch)===null||j===void 0||j.optimizeNames(k,T),(ee=this.finally)===null||ee===void 0||ee.optimizeNames(k,T),this}get names(){const k=super.names;return this.catch&&F(k,this.catch.names),this.finally&&F(k,this.finally.names),k}}class L extends p{constructor(k){super(),this.error=k}render(k){return`catch(${this.error})`+super.render(k)}}L.kind="catch";class K extends p{render(k){return"finally"+super.render(k)}}K.kind="finally";class z{constructor(k,T={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...T,_n:T.lines?`
2
- `:""},this._extScope=k,this._scope=new r.Scope({parent:k}),this._nodes=[new y]}toString(){return this._root.render(this.opts)}name(k){return this._scope.name(k)}scopeName(k){return this._extScope.name(k)}scopeValue(k,T){const j=this._extScope.value(k,T);return(this._values[j.prefix]||(this._values[j.prefix]=new Set)).add(j),j}getScopeValue(k,T){return this._extScope.getValue(k,T)}scopeRefs(k){return this._extScope.scopeRefs(k,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(k,T,j,ee){const ne=this._scope.toName(T);return j!==void 0&&ee&&(this._constants[ne.str]=j),this._leafNode(new i(k,ne,j)),ne}const(k,T,j){return this._def(r.varKinds.const,k,T,j)}let(k,T,j){return this._def(r.varKinds.let,k,T,j)}var(k,T,j){return this._def(r.varKinds.var,k,T,j)}assign(k,T,j){return this._leafNode(new o(k,T,j))}add(k,T){return this._leafNode(new c(k,t.operators.ADD,T))}code(k){return typeof k=="function"?k():k!==e.nil&&this._leafNode(new g(k)),this}object(...k){const T=["{"];for(const[j,ee]of k)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(k,T,j){if(this._blockNode(new w(k)),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(k){return this._elseNode(new w(k))}else(){return this._elseNode(new f)}endIf(){return this._endBlockNode(w,f)}_for(k,T){return this._blockNode(k),T&&this.code(T).endFor(),this}for(k,T){return this._for(new m(k),T)}forRange(k,T,j,ee,ne=this.opts.es5?r.varKinds.var:r.varKinds.let){const me=this._scope.toName(k);return this._for(new b(ne,me,T,j),()=>ee(me))}forOf(k,T,j,ee=r.varKinds.const){const ne=this._scope.toName(k);if(this.opts.es5){const me=T instanceof e.Name?T:this.var("_arr",T);return this.forRange("_i",0,(0,e._)`${me}.length`,le=>{this.var(ne,(0,e._)`${me}[${le}]`),j(ne)})}return this._for(new v("of",ee,ne,T),()=>j(ne))}forIn(k,T,j,ee=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(k,(0,e._)`Object.keys(${T})`,j);const ne=this._scope.toName(k);return this._for(new v("in",ee,ne,T),()=>j(ne))}endFor(){return this._endBlockNode(d)}label(k){return this._leafNode(new u(k))}break(k){return this._leafNode(new l(k))}return(k){const T=new E;if(this._blockNode(T),this.code(k),T.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(E)}try(k,T,j){if(!T&&!j)throw new Error('CodeGen: "try" without "catch" and "finally"');const ee=new N;if(this._blockNode(ee),this.code(k),T){const ne=this.name("e");this._currNode=ee.catch=new L(ne),T(ne)}return j&&(this._currNode=ee.finally=new K,this.code(j)),this._endBlockNode(L,K)}throw(k){return this._leafNode(new h(k))}block(k,T){return this._blockStarts.push(this._nodes.length),k&&this.code(k).endBlock(T),this}endBlock(k){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||k!==void 0&&j!==k)throw new Error(`CodeGen: wrong number of nodes: ${j} vs ${k} expected`);return this._nodes.length=T,this}func(k,T=e.nil,j,ee){return this._blockNode(new $(k,T,j)),ee&&this.code(ee).endFunc(),this}endFunc(){return this._endBlockNode($)}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,T){const j=this._currNode;if(j instanceof k||T&&j instanceof T)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${T?`${k.kind}/${T.kind}`:k.kind}"`)}_elseNode(k){const T=this._currNode;if(!(T instanceof w))throw new Error('CodeGen: "else" without "if"');return this._currNode=T.else=k,this}get _root(){return this._nodes[0]}get _currNode(){const k=this._nodes;return k[k.length-1]}set _currNode(k){const T=this._nodes;T[T.length-1]=k}}t.CodeGen=z;function F(O,k){for(const T in k)O[T]=(O[T]||0)+(k[T]||0);return O}function G(O,k){return k instanceof e._CodeOrName?F(O,k.names):O}function Y(O,k,T){if(O instanceof e.Name)return j(O);if(!ee(O))return O;return new e._Code(O._items.reduce((ne,me)=>(me instanceof e.Name&&(me=j(me)),me instanceof e._Code?ne.push(...me._items):ne.push(me),ne),[]));function j(ne){const me=T[ne.str];return me===void 0||k[ne.str]!==1?ne:(delete k[ne.str],me)}function ee(ne){return ne instanceof e._Code&&ne._items.some(me=>me instanceof e.Name&&k[me.str]===1&&T[me.str]!==void 0)}}function ge(O,k){for(const T in k)O[T]=(O[T]||0)-(k[T]||0)}function We(O){return typeof O=="boolean"||typeof O=="number"||O===null?!O:(0,e._)`!${q(O)}`}t.not=We;const Ke=C(t.operators.AND);function we(...O){return O.reduce(Ke)}t.and=we;const mt=C(t.operators.OR);function D(...O){return O.reduce(mt)}t.or=D;function C(O){return(k,T)=>k===e.nil?T:T===e.nil?k:(0,e._)`${q(k)} ${O} ${q(T)}`}function q(O){return O instanceof e.Name?O:(0,e._)`(${O})`}})(Ws)),Ws}var ie={},Yi;function de(){if(Yi)return ie;Yi=1,Object.defineProperty(ie,"__esModule",{value:!0}),ie.checkStrictMode=ie.getErrorPath=ie.Type=ie.useFunc=ie.setEvaluated=ie.evaluatedPropsToName=ie.mergeEvaluated=ie.eachItem=ie.unescapeJsonPointer=ie.escapeJsonPointer=ie.escapeFragment=ie.unescapeFragment=ie.schemaRefOrVal=ie.schemaHasRulesButRef=ie.schemaHasRules=ie.checkUnknownRules=ie.alwaysValidSchema=ie.toHash=void 0;const t=ae(),e=rn();function r(v){const $={};for(const E of v)$[E]=!0;return $}ie.toHash=r;function n(v,$){return typeof $=="boolean"?$:Object.keys($).length===0?!0:(s(v,$),!a($,v.self.RULES.all))}ie.alwaysValidSchema=n;function s(v,$=v.schema){const{opts:E,self:N}=v;if(!E.strictSchema||typeof $=="boolean")return;const L=N.RULES.keywords;for(const K in $)L[K]||b(v,`unknown keyword: "${K}"`)}ie.checkUnknownRules=s;function a(v,$){if(typeof v=="boolean")return!v;for(const E in v)if($[E])return!0;return!1}ie.schemaHasRules=a;function i(v,$){if(typeof v=="boolean")return!v;for(const E in v)if(E!=="$ref"&&$.all[E])return!0;return!1}ie.schemaHasRulesButRef=i;function o({topSchemaRef:v,schemaPath:$},E,N,L){if(!L){if(typeof E=="number"||typeof E=="boolean")return E;if(typeof E=="string")return(0,t._)`${E}`}return(0,t._)`${v}${$}${(0,t.getProperty)(N)}`}ie.schemaRefOrVal=o;function c(v){return h(decodeURIComponent(v))}ie.unescapeFragment=c;function u(v){return encodeURIComponent(l(v))}ie.escapeFragment=u;function l(v){return typeof v=="number"?`${v}`:v.replace(/~/g,"~0").replace(/\//g,"~1")}ie.escapeJsonPointer=l;function h(v){return v.replace(/~1/g,"/").replace(/~0/g,"~")}ie.unescapeJsonPointer=h;function g(v,$){if(Array.isArray(v))for(const E of v)$(E);else $(v)}ie.eachItem=g;function _({mergeNames:v,mergeToName:$,mergeValues:E,resultToName:N}){return(L,K,z,F)=>{const G=z===void 0?K:z instanceof t.Name?(K instanceof t.Name?v(L,K,z):$(L,K,z),z):K instanceof t.Name?($(L,z,K),K):E(K,z);return F===t.Name&&!(G instanceof t.Name)?N(L,G):G}}ie.mergeEvaluated={props:_({mergeNames:(v,$,E)=>v.if((0,t._)`${E} !== true && ${$} !== undefined`,()=>{v.if((0,t._)`${$} === true`,()=>v.assign(E,!0),()=>v.assign(E,(0,t._)`${E} || {}`).code((0,t._)`Object.assign(${E}, ${$})`))}),mergeToName:(v,$,E)=>v.if((0,t._)`${E} !== true`,()=>{$===!0?v.assign(E,!0):(v.assign(E,(0,t._)`${E} || {}`),y(v,E,$))}),mergeValues:(v,$)=>v===!0?!0:{...v,...$},resultToName:p}),items:_({mergeNames:(v,$,E)=>v.if((0,t._)`${E} !== true && ${$} !== undefined`,()=>v.assign(E,(0,t._)`${$} === true ? true : ${E} > ${$} ? ${E} : ${$}`)),mergeToName:(v,$,E)=>v.if((0,t._)`${E} !== true`,()=>v.assign(E,$===!0?!0:(0,t._)`${E} > ${$} ? ${E} : ${$}`)),mergeValues:(v,$)=>v===!0?!0:Math.max(v,$),resultToName:(v,$)=>v.var("items",$)})};function p(v,$){if($===!0)return v.var("props",!0);const E=v.var("props",(0,t._)`{}`);return $!==void 0&&y(v,E,$),E}ie.evaluatedPropsToName=p;function y(v,$,E){Object.keys(E).forEach(N=>v.assign((0,t._)`${$}${(0,t.getProperty)(N)}`,!0))}ie.setEvaluated=y;const f={};function w(v,$){return v.scopeValue("func",{ref:$,code:f[$.code]||(f[$.code]=new e._Code($.code))})}ie.useFunc=w;var d;(function(v){v[v.Num=0]="Num",v[v.Str=1]="Str"})(d||(ie.Type=d={}));function m(v,$,E){if(v instanceof t.Name){const N=$===d.Num;return E?N?(0,t._)`"[" + ${v} + "]"`:(0,t._)`"['" + ${v} + "']"`:N?(0,t._)`"/" + ${v}`:(0,t._)`"/" + ${v}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return E?(0,t.getProperty)(v).toString():"/"+l(v)}ie.getErrorPath=m;function b(v,$,E=v.opts.strictSchema){if(E){if($=`strict mode: ${$}`,E===!0)throw new Error($);v.self.logger.warn($)}}return ie.checkStrictMode=b,ie}var nn={},Qi;function Et(){if(Qi)return nn;Qi=1,Object.defineProperty(nn,"__esModule",{value:!0});const t=ae(),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 nn.default=e,nn}var Xi;function sn(){return Xi||(Xi=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=ae(),r=de(),n=Et();t.keywordError={message:({keyword:f})=>(0,e.str)`must pass "${f}" keyword validation`},t.keyword$DataError={message:({keyword:f,schemaType:w})=>w?(0,e.str)`"${f}" keyword must be ${w} ($data)`:(0,e.str)`"${f}" keyword is invalid ($data)`};function s(f,w=t.keywordError,d,m){const{it:b}=f,{gen:v,compositeRule:$,allErrors:E}=b,N=h(f,w,d);m??($||E)?c(v,N):u(b,(0,e._)`[${N}]`)}t.reportError=s;function a(f,w=t.keywordError,d){const{it:m}=f,{gen:b,compositeRule:v,allErrors:$}=m,E=h(f,w,d);c(b,E),v||$||u(m,n.default.vErrors)}t.reportExtraError=a;function i(f,w){f.assign(n.default.errors,w),f.if((0,e._)`${n.default.vErrors} !== null`,()=>f.if(w,()=>f.assign((0,e._)`${n.default.vErrors}.length`,w),()=>f.assign(n.default.vErrors,null)))}t.resetErrorsCount=i;function o({gen:f,keyword:w,schemaValue:d,data:m,errsCount:b,it:v}){if(b===void 0)throw new Error("ajv implementation error");const $=f.name("err");f.forRange("i",b,n.default.errors,E=>{f.const($,(0,e._)`${n.default.vErrors}[${E}]`),f.if((0,e._)`${$}.instancePath === undefined`,()=>f.assign((0,e._)`${$}.instancePath`,(0,e.strConcat)(n.default.instancePath,v.errorPath))),f.assign((0,e._)`${$}.schemaPath`,(0,e.str)`${v.errSchemaPath}/${w}`),v.opts.verbose&&(f.assign((0,e._)`${$}.schema`,d),f.assign((0,e._)`${$}.data`,m))})}t.extendErrors=o;function c(f,w){const d=f.const("err",w);f.if((0,e._)`${n.default.vErrors} === null`,()=>f.assign(n.default.vErrors,(0,e._)`[${d}]`),(0,e._)`${n.default.vErrors}.push(${d})`),f.code((0,e._)`${n.default.errors}++`)}function u(f,w){const{gen:d,validateName:m,schemaEnv:b}=f;b.$async?d.throw((0,e._)`new ${f.ValidationError}(${w})`):(d.assign((0,e._)`${m}.errors`,w),d.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 h(f,w,d){const{createErrors:m}=f.it;return m===!1?(0,e._)`{}`:g(f,w,d)}function g(f,w,d={}){const{gen:m,it:b}=f,v=[_(b,d),p(f,d)];return y(f,w,v),m.object(...v)}function _({errorPath:f},{instancePath:w}){const d=w?(0,e.str)`${f}${(0,r.getErrorPath)(w,r.Type.Str)}`:f;return[n.default.instancePath,(0,e.strConcat)(n.default.instancePath,d)]}function p({keyword:f,it:{errSchemaPath:w}},{schemaPath:d,parentSchema:m}){let b=m?w:(0,e.str)`${w}/${f}`;return d&&(b=(0,e.str)`${b}${(0,r.getErrorPath)(d,r.Type.Str)}`),[l.schemaPath,b]}function y(f,{params:w,message:d},m){const{keyword:b,data:v,schemaValue:$,it:E}=f,{opts:N,propertyName:L,topSchemaRef:K,schemaPath:z}=E;m.push([l.keyword,b],[l.params,typeof w=="function"?w(f):w||(0,e._)`{}`]),N.messages&&m.push([l.message,typeof d=="function"?d(f):d]),N.verbose&&m.push([l.schema,$],[l.parentSchema,(0,e._)`${K}${z}`],[n.default.data,v]),L&&m.push([l.propertyName,L])}})(Hs)),Hs}var eo;function Bd(){if(eo)return Zt;eo=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.boolOrEmptySchema=Zt.topBoolOrEmptySchema=void 0;const t=sn(),e=ae(),r=Et(),n={message:"boolean schema is false"};function s(o){const{gen:c,schema:u,validateName:l}=o;u===!1?i(o,!1):typeof u=="object"&&u.$async===!0?c.return(r.default.data):(c.assign((0,e._)`${l}.errors`,null),c.return(!0))}Zt.topBoolOrEmptySchema=s;function a(o,c){const{gen:u,schema:l}=o;l===!1?(u.var(c,!1),i(o)):u.var(c,!0)}Zt.boolOrEmptySchema=a;function i(o,c){const{gen:u,data:l}=o,h={gen:u,keyword:"false schema",data:l,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:o};(0,t.reportError)(h,n,void 0,c)}return Zt}var Ze={},Lt={},to;function ro(){if(to)return Lt;to=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.getRules=Lt.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)}Lt.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 Lt.getRules=n,Lt}var vt={},no;function so(){if(no)return vt;no=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.shouldUseRule=vt.shouldUseGroup=vt.schemaHasRulesForType=void 0;function t({schema:n,self:s},a){const i=s.RULES.types[a];return i&&i!==!0&&e(n,i)}vt.schemaHasRulesForType=t;function e(n,s){return s.rules.some(a=>r(n,a))}vt.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 vt.shouldUseRule=r,vt}var ao;function an(){if(ao)return Ze;ao=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=ro(),e=so(),r=sn(),n=ae(),s=de();var a;(function(d){d[d.Correct=0]="Correct",d[d.Wrong=1]="Wrong"})(a||(Ze.DataType=a={}));function i(d){const m=o(d.type);if(m.includes("null")){if(d.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!m.length&&d.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');d.nullable===!0&&m.push("null")}return m}Ze.getSchemaTypes=i;function o(d){const m=Array.isArray(d)?d:d?[d]:[];if(m.every(t.isJSONType))return m;throw new Error("type must be JSONType or JSONType[]: "+m.join(","))}Ze.getJSONTypes=o;function c(d,m){const{gen:b,data:v,opts:$}=d,E=l(m,$.coerceTypes),N=m.length>0&&!(E.length===0&&m.length===1&&(0,e.schemaHasRulesForType)(d,m[0]));if(N){const L=p(m,v,$.strictNumbers,a.Wrong);b.if(L,()=>{E.length?h(d,m,E):f(d)})}return N}Ze.coerceAndCheckDataType=c;const u=new Set(["string","number","integer","boolean","null"]);function l(d,m){return m?d.filter(b=>u.has(b)||m==="array"&&b==="array"):[]}function h(d,m,b){const{gen:v,data:$,opts:E}=d,N=v.let("dataType",(0,n._)`typeof ${$}`),L=v.let("coerced",(0,n._)`undefined`);E.coerceTypes==="array"&&v.if((0,n._)`${N} == 'object' && Array.isArray(${$}) && ${$}.length == 1`,()=>v.assign($,(0,n._)`${$}[0]`).assign(N,(0,n._)`typeof ${$}`).if(p(m,$,E.strictNumbers),()=>v.assign(L,$))),v.if((0,n._)`${L} !== undefined`);for(const z of b)(u.has(z)||z==="array"&&E.coerceTypes==="array")&&K(z);v.else(),f(d),v.endIf(),v.if((0,n._)`${L} !== undefined`,()=>{v.assign($,L),g(d,L)});function K(z){switch(z){case"string":v.elseIf((0,n._)`${N} == "number" || ${N} == "boolean"`).assign(L,(0,n._)`"" + ${$}`).elseIf((0,n._)`${$} === null`).assign(L,(0,n._)`""`);return;case"number":v.elseIf((0,n._)`${N} == "boolean" || ${$} === null
3
- || (${N} == "string" && ${$} && ${$} == +${$})`).assign(L,(0,n._)`+${$}`);return;case"integer":v.elseIf((0,n._)`${N} === "boolean" || ${$} === null
4
- || (${N} === "string" && ${$} && ${$} == +${$} && !(${$} % 1))`).assign(L,(0,n._)`+${$}`);return;case"boolean":v.elseIf((0,n._)`${$} === "false" || ${$} === 0 || ${$} === null`).assign(L,!1).elseIf((0,n._)`${$} === "true" || ${$} === 1`).assign(L,!0);return;case"null":v.elseIf((0,n._)`${$} === "" || ${$} === 0 || ${$} === false`),v.assign(L,null);return;case"array":v.elseIf((0,n._)`${N} === "string" || ${N} === "number"
5
- || ${N} === "boolean" || ${$} === null`).assign(L,(0,n._)`[${$}]`)}}}function g({gen:d,parentData:m,parentDataProperty:b},v){d.if((0,n._)`${m} !== undefined`,()=>d.assign((0,n._)`${m}[${b}]`,v))}function _(d,m,b,v=a.Correct){const $=v===a.Correct?n.operators.EQ:n.operators.NEQ;let E;switch(d){case"null":return(0,n._)`${m} ${$} null`;case"array":E=(0,n._)`Array.isArray(${m})`;break;case"object":E=(0,n._)`${m} && typeof ${m} == "object" && !Array.isArray(${m})`;break;case"integer":E=N((0,n._)`!(${m} % 1) && !isNaN(${m})`);break;case"number":E=N();break;default:return(0,n._)`typeof ${m} ${$} ${d}`}return v===a.Correct?E:(0,n.not)(E);function N(L=n.nil){return(0,n.and)((0,n._)`typeof ${m} == "number"`,L,b?(0,n._)`isFinite(${m})`:n.nil)}}Ze.checkDataType=_;function p(d,m,b,v){if(d.length===1)return _(d[0],m,b,v);let $;const E=(0,s.toHash)(d);if(E.array&&E.object){const N=(0,n._)`typeof ${m} != "object"`;$=E.null?N:(0,n._)`!${m} || ${N}`,delete E.null,delete E.array,delete E.object}else $=n.nil;E.number&&delete E.integer;for(const N in E)$=(0,n.and)($,_(N,m,b,v));return $}Ze.checkDataTypes=p;const y={message:({schema:d})=>`must be ${d}`,params:({schema:d,schemaValue:m})=>typeof d=="string"?(0,n._)`{type: ${d}}`:(0,n._)`{type: ${m}}`};function f(d){const m=w(d);(0,r.reportError)(m,y)}Ze.reportTypeError=f;function w(d){const{gen:m,data:b,schema:v}=d,$=(0,s.schemaRefOrVal)(d,v,"type");return{gen:m,keyword:"type",data:b,schema:v.type,schemaCode:$,schemaValue:$,parentSchema:v,params:{},it:d}}return Ze}var Sr={},io;function Yd(){if(io)return Sr;io=1,Object.defineProperty(Sr,"__esModule",{value:!0}),Sr.assignDefaults=void 0;const t=ae(),e=de();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,u)=>n(s,u,c.default))}Sr.assignDefaults=r;function n(s,a,i){const{gen:o,compositeRule:c,data:u,opts:l}=s;if(i===void 0)return;const h=(0,t._)`${u}${(0,t.getProperty)(a)}`;if(c){(0,e.checkStrictMode)(s,`default is ignored for: ${h}`);return}let g=(0,t._)`${h} === undefined`;l.useDefaults==="empty"&&(g=(0,t._)`${g} || ${h} === null || ${h} === ""`),o.if(g,(0,t._)`${h} = ${(0,t.stringify)(i)}`)}return Sr}var ct={},ye={},oo;function ut(){if(oo)return ye;oo=1,Object.defineProperty(ye,"__esModule",{value:!0}),ye.validateUnion=ye.validateArray=ye.usePattern=ye.callValidateCode=ye.schemaProperties=ye.allSchemaProperties=ye.noPropertyInData=ye.propertyInData=ye.isOwnProperty=ye.hasPropFunc=ye.reportMissingProp=ye.checkMissingProp=ye.checkReportMissingProp=void 0;const t=ae(),e=de(),r=Et(),n=de();function s(d,m){const{gen:b,data:v,it:$}=d;b.if(l(b,v,m,$.opts.ownProperties),()=>{d.setParams({missingProperty:(0,t._)`${m}`},!0),d.error()})}ye.checkReportMissingProp=s;function a({gen:d,data:m,it:{opts:b}},v,$){return(0,t.or)(...v.map(E=>(0,t.and)(l(d,m,E,b.ownProperties),(0,t._)`${$} = ${E}`)))}ye.checkMissingProp=a;function i(d,m){d.setParams({missingProperty:m},!0),d.error()}ye.reportMissingProp=i;function o(d){return d.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}ye.hasPropFunc=o;function c(d,m,b){return(0,t._)`${o(d)}.call(${m}, ${b})`}ye.isOwnProperty=c;function u(d,m,b,v){const $=(0,t._)`${m}${(0,t.getProperty)(b)} !== undefined`;return v?(0,t._)`${$} && ${c(d,m,b)}`:$}ye.propertyInData=u;function l(d,m,b,v){const $=(0,t._)`${m}${(0,t.getProperty)(b)} === undefined`;return v?(0,t.or)($,(0,t.not)(c(d,m,b))):$}ye.noPropertyInData=l;function h(d){return d?Object.keys(d).filter(m=>m!=="__proto__"):[]}ye.allSchemaProperties=h;function g(d,m){return h(m).filter(b=>!(0,e.alwaysValidSchema)(d,m[b]))}ye.schemaProperties=g;function _({schemaCode:d,data:m,it:{gen:b,topSchemaRef:v,schemaPath:$,errorPath:E},it:N},L,K,z){const F=z?(0,t._)`${d}, ${m}, ${v}${$}`:m,G=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,E)],[r.default.parentData,N.parentData],[r.default.parentDataProperty,N.parentDataProperty],[r.default.rootData,r.default.rootData]];N.opts.dynamicRef&&G.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const Y=(0,t._)`${F}, ${b.object(...G)}`;return K!==t.nil?(0,t._)`${L}.call(${K}, ${Y})`:(0,t._)`${L}(${Y})`}ye.callValidateCode=_;const p=(0,t._)`new RegExp`;function y({gen:d,it:{opts:m}},b){const v=m.unicodeRegExp?"u":"",{regExp:$}=m.code,E=$(b,v);return d.scopeValue("pattern",{key:E.toString(),ref:E,code:(0,t._)`${$.code==="new RegExp"?p:(0,n.useFunc)(d,$)}(${b}, ${v})`})}ye.usePattern=y;function f(d){const{gen:m,data:b,keyword:v,it:$}=d,E=m.name("valid");if($.allErrors){const L=m.let("valid",!0);return N(()=>m.assign(L,!1)),L}return m.var(E,!0),N(()=>m.break()),E;function N(L){const K=m.const("len",(0,t._)`${b}.length`);m.forRange("i",0,K,z=>{d.subschema({keyword:v,dataProp:z,dataPropType:e.Type.Num},E),m.if((0,t.not)(E),L)})}}ye.validateArray=f;function w(d){const{gen:m,schema:b,keyword:v,it:$}=d;if(!Array.isArray(b))throw new Error("ajv implementation error");if(b.some(K=>(0,e.alwaysValidSchema)($,K))&&!$.opts.unevaluated)return;const N=m.let("valid",!1),L=m.name("_valid");m.block(()=>b.forEach((K,z)=>{const F=d.subschema({keyword:v,schemaProp:z,compositeRule:!0},L);m.assign(N,(0,t._)`${N} || ${L}`),d.mergeValidEvaluated(F,L)||m.if((0,t.not)(N))})),d.result(N,()=>d.reset(),()=>d.error(!0))}return ye.validateUnion=w,ye}var co;function Qd(){if(co)return ct;co=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.validateKeywordUsage=ct.validSchemaType=ct.funcKeywordCode=ct.macroKeywordCode=void 0;const t=ae(),e=Et(),r=ut(),n=sn();function s(g,_){const{gen:p,keyword:y,schema:f,parentSchema:w,it:d}=g,m=_.macro.call(d.self,f,w,d),b=u(p,y,m);d.opts.validateSchema!==!1&&d.self.validateSchema(m,!0);const v=p.name("valid");g.subschema({schema:m,schemaPath:t.nil,errSchemaPath:`${d.errSchemaPath}/${y}`,topSchemaRef:b,compositeRule:!0},v),g.pass(v,()=>g.error(!0))}ct.macroKeywordCode=s;function a(g,_){var p;const{gen:y,keyword:f,schema:w,parentSchema:d,$data:m,it:b}=g;c(b,_);const v=!m&&_.compile?_.compile.call(b.self,w,d,b):_.validate,$=u(y,f,v),E=y.let("valid");g.block$data(E,N),g.ok((p=_.valid)!==null&&p!==void 0?p:E);function N(){if(_.errors===!1)z(),_.modifying&&i(g),F(()=>g.error());else{const G=_.async?L():K();_.modifying&&i(g),F(()=>o(g,G))}}function L(){const G=y.let("ruleErrs",null);return y.try(()=>z((0,t._)`await `),Y=>y.assign(E,!1).if((0,t._)`${Y} instanceof ${b.ValidationError}`,()=>y.assign(G,(0,t._)`${Y}.errors`),()=>y.throw(Y))),G}function K(){const G=(0,t._)`${$}.errors`;return y.assign(G,null),z(t.nil),G}function z(G=_.async?(0,t._)`await `:t.nil){const Y=b.opts.passContext?e.default.this:e.default.self,ge=!("compile"in _&&!m||_.schema===!1);y.assign(E,(0,t._)`${G}${(0,r.callValidateCode)(g,$,Y,ge)}`,_.modifying)}function F(G){var Y;y.if((0,t.not)((Y=_.valid)!==null&&Y!==void 0?Y:E),G)}}ct.funcKeywordCode=a;function i(g){const{gen:_,data:p,it:y}=g;_.if(y.parentData,()=>_.assign(p,(0,t._)`${y.parentData}[${y.parentDataProperty}]`))}function o(g,_){const{gen:p}=g;p.if((0,t._)`Array.isArray(${_})`,()=>{p.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)(g)},()=>g.error())}function c({schemaEnv:g},_){if(_.async&&!g.$async)throw new Error("async keyword in sync schema")}function u(g,_,p){if(p===void 0)throw new Error(`keyword "${_}" failed to compile`);return g.scopeValue("keyword",typeof p=="function"?{ref:p}:{ref:p,code:(0,t.stringify)(p)})}function l(g,_,p=!1){return!_.length||_.some(y=>y==="array"?Array.isArray(g):y==="object"?g&&typeof g=="object"&&!Array.isArray(g):typeof g==y||p&&typeof g>"u")}ct.validSchemaType=l;function h({schema:g,opts:_,self:p,errSchemaPath:y},f,w){if(Array.isArray(f.keyword)?!f.keyword.includes(w):f.keyword!==w)throw new Error("ajv implementation error");const d=f.dependencies;if(d?.some(m=>!Object.prototype.hasOwnProperty.call(g,m)))throw new Error(`parent schema must have dependencies of ${w}: ${d.join(",")}`);if(f.validateSchema&&!f.validateSchema(g[w])){const b=`keyword "${w}" value is invalid at path "${y}": `+p.errorsText(f.validateSchema.errors);if(_.validateSchema==="log")p.logger.error(b);else throw new Error(b)}}return ct.validateKeywordUsage=h,ct}var wt={},uo;function Xd(){if(uo)return wt;uo=1,Object.defineProperty(wt,"__esModule",{value:!0}),wt.extendSubschemaMode=wt.extendSubschemaData=wt.getSubschema=void 0;const t=ae(),e=de();function r(a,{keyword:i,schemaProp:o,schema:c,schemaPath:u,errSchemaPath:l,topSchemaRef:h}){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(u===void 0||l===void 0||h===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:u,topSchemaRef:h,errSchemaPath:l}}throw new Error('either "keyword" or "schema" must be passed')}wt.getSubschema=r;function n(a,i,{dataProp:o,dataPropType:c,data:u,dataTypes:l,propertyName:h}){if(u!==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:y,opts:f}=i,w=g.let("data",(0,t._)`${i.data}${(0,t.getProperty)(o)}`,!0);_(w),a.errorPath=(0,t.str)`${p}${(0,e.getErrorPath)(o,c,f.jsPropertySyntax)}`,a.parentDataProperty=(0,t._)`${o}`,a.dataPathArr=[...y,a.parentDataProperty]}if(u!==void 0){const p=u instanceof t.Name?u:g.let("data",u,!0);_(p),h!==void 0&&(a.propertyName=h)}l&&(a.dataTypes=l);function _(p){a.data=p,a.dataLevel=i.dataLevel+1,a.dataTypes=[],i.definedProperties=new Set,a.parentData=i.data,a.dataNames=[...i.dataNames,p]}}wt.extendSubschemaData=n;function s(a,{jtdDiscriminator:i,jtdMetadata:o,compositeRule:c,createErrors:u,allErrors:l}){c!==void 0&&(a.compositeRule=c),u!==void 0&&(a.createErrors=u),l!==void 0&&(a.allErrors=l),a.jtdDiscriminator=i,a.jtdMetadata=o}return wt.extendSubschemaMode=s,wt}var Fe={},Gs,lo;function fo(){return lo||(lo=1,Gs=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}),Gs}var Bs={exports:{}},ho;function ef(){if(ho)return Bs.exports;ho=1;var t=Bs.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,u,l,h,g){if(i&&typeof i=="object"&&!Array.isArray(i)){s(i,o,c,u,l,h,g);for(var _ in i){var p=i[_];if(Array.isArray(p)){if(_ in t.arrayKeywords)for(var y=0;y<p.length;y++)e(n,s,a,p[y],o+"/"+_+"/"+y,c,o,_,i,y)}else if(_ in t.propsKeywords){if(p&&typeof p=="object")for(var f in p)e(n,s,a,p[f],o+"/"+_+"/"+r(f),c,o,_,i,f)}else(_ in t.keywords||n.allKeys&&!(_ in t.skipKeywords))&&e(n,s,a,p,o+"/"+_,c,o,_,i)}a(i,o,c,u,l,h,g)}}function r(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}return Bs.exports}var po;function on(){if(po)return Fe;po=1,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.getSchemaRefs=Fe.resolveUrl=Fe.normalizeId=Fe._getFullPath=Fe.getFullPath=Fe.inlineRef=void 0;const t=de(),e=fo(),r=ef(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function s(y,f=!0){return typeof y=="boolean"?!0:f===!0?!i(y):f?o(y)<=f:!1}Fe.inlineRef=s;const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function i(y){for(const f in y){if(a.has(f))return!0;const w=y[f];if(Array.isArray(w)&&w.some(i)||typeof w=="object"&&i(w))return!0}return!1}function o(y){let f=0;for(const w in y){if(w==="$ref")return 1/0;if(f++,!n.has(w)&&(typeof y[w]=="object"&&(0,t.eachItem)(y[w],d=>f+=o(d)),f===1/0))return 1/0}return f}function c(y,f="",w){w!==!1&&(f=h(f));const d=y.parse(f);return u(y,d)}Fe.getFullPath=c;function u(y,f){return y.serialize(f).split("#")[0]+"#"}Fe._getFullPath=u;const l=/#\/?$/;function h(y){return y?y.replace(l,""):""}Fe.normalizeId=h;function g(y,f,w){return w=h(w),y.resolve(f,w)}Fe.resolveUrl=g;const _=/^[a-z_][-a-z0-9._]*$/i;function p(y,f){if(typeof y=="boolean")return{};const{schemaId:w,uriResolver:d}=this.opts,m=h(y[w]||f),b={"":m},v=c(d,m,!1),$={},E=new Set;return r(y,{allKeys:!0},(K,z,F,G)=>{if(G===void 0)return;const Y=v+z;let ge=b[G];typeof K[w]=="string"&&(ge=We.call(this,K[w])),Ke.call(this,K.$anchor),Ke.call(this,K.$dynamicAnchor),b[z]=ge;function We(we){const mt=this.opts.uriResolver.resolve;if(we=h(ge?mt(ge,we):we),E.has(we))throw L(we);E.add(we);let D=this.refs[we];return typeof D=="string"&&(D=this.refs[D]),typeof D=="object"?N(K,D.schema,we):we!==h(Y)&&(we[0]==="#"?(N(K,$[we],we),$[we]=K):this.refs[we]=Y),we}function Ke(we){if(typeof we=="string"){if(!_.test(we))throw new Error(`invalid anchor "${we}"`);We.call(this,`#${we}`)}}}),$;function N(K,z,F){if(z!==void 0&&!e(K,z))throw L(F)}function L(K){return new Error(`reference "${K}" resolves to more than one schema`)}}return Fe.getSchemaRefs=p,Fe}var mo;function cn(){if(mo)return yt;mo=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.getData=yt.KeywordCxt=yt.validateFunctionCode=void 0;const t=Bd(),e=an(),r=so(),n=an(),s=Yd(),a=Qd(),i=Xd(),o=ae(),c=Et(),u=on(),l=de(),h=sn();function g(P){if(v(P)&&(E(P),b(P))){f(P);return}_(P,()=>(0,t.topBoolOrEmptySchema)(P))}yt.validateFunctionCode=g;function _({gen:P,validateName:I,schema:M,schemaEnv:U,opts:re},ce){re.code.es5?P.func(I,(0,o._)`${c.default.data}, ${c.default.valCxt}`,U.$async,()=>{P.code((0,o._)`"use strict"; ${d(M,re)}`),y(P,re),P.code(ce)}):P.func(I,(0,o._)`${c.default.data}, ${p(re)}`,U.$async,()=>P.code(d(M,re)).code(ce))}function p(P){return(0,o._)`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${P.dynamicRef?(0,o._)`, ${c.default.dynamicAnchors}={}`:o.nil}}={}`}function y(P,I){P.if(c.default.valCxt,()=>{P.var(c.default.instancePath,(0,o._)`${c.default.valCxt}.${c.default.instancePath}`),P.var(c.default.parentData,(0,o._)`${c.default.valCxt}.${c.default.parentData}`),P.var(c.default.parentDataProperty,(0,o._)`${c.default.valCxt}.${c.default.parentDataProperty}`),P.var(c.default.rootData,(0,o._)`${c.default.valCxt}.${c.default.rootData}`),I.dynamicRef&&P.var(c.default.dynamicAnchors,(0,o._)`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{P.var(c.default.instancePath,(0,o._)`""`),P.var(c.default.parentData,(0,o._)`undefined`),P.var(c.default.parentDataProperty,(0,o._)`undefined`),P.var(c.default.rootData,c.default.data),I.dynamicRef&&P.var(c.default.dynamicAnchors,(0,o._)`{}`)})}function f(P){const{schema:I,opts:M,gen:U}=P;_(P,()=>{M.$comment&&I.$comment&&G(P),K(P),U.let(c.default.vErrors,null),U.let(c.default.errors,0),M.unevaluated&&w(P),N(P),Y(P)})}function w(P){const{gen:I,validateName:M}=P;P.evaluated=I.const("evaluated",(0,o._)`${M}.evaluated`),I.if((0,o._)`${P.evaluated}.dynamicProps`,()=>I.assign((0,o._)`${P.evaluated}.props`,(0,o._)`undefined`)),I.if((0,o._)`${P.evaluated}.dynamicItems`,()=>I.assign((0,o._)`${P.evaluated}.items`,(0,o._)`undefined`))}function d(P,I){const M=typeof P=="object"&&P[I.schemaId];return M&&(I.code.source||I.code.process)?(0,o._)`/*# sourceURL=${M} */`:o.nil}function m(P,I){if(v(P)&&(E(P),b(P))){$(P,I);return}(0,t.boolOrEmptySchema)(P,I)}function b({schema:P,self:I}){if(typeof P=="boolean")return!P;for(const M in P)if(I.RULES.all[M])return!0;return!1}function v(P){return typeof P.schema!="boolean"}function $(P,I){const{schema:M,gen:U,opts:re}=P;re.$comment&&M.$comment&&G(P),z(P),F(P);const ce=U.const("_errs",c.default.errors);N(P,ce),U.var(I,(0,o._)`${ce} === ${c.default.errors}`)}function E(P){(0,l.checkUnknownRules)(P),L(P)}function N(P,I){if(P.opts.jtd)return We(P,[],!1,I);const M=(0,e.getSchemaTypes)(P.schema),U=(0,e.coerceAndCheckDataType)(P,M);We(P,M,!U,I)}function L(P){const{schema:I,errSchemaPath:M,opts:U,self:re}=P;I.$ref&&U.ignoreKeywordsWithRef&&(0,l.schemaHasRulesButRef)(I,re.RULES)&&re.logger.warn(`$ref: keywords ignored in schema at path "${M}"`)}function K(P){const{schema:I,opts:M}=P;I.default!==void 0&&M.useDefaults&&M.strictSchema&&(0,l.checkStrictMode)(P,"default is ignored in the schema root")}function z(P){const I=P.schema[P.opts.schemaId];I&&(P.baseId=(0,u.resolveUrl)(P.opts.uriResolver,P.baseId,I))}function F(P){if(P.schema.$async&&!P.schemaEnv.$async)throw new Error("async schema in sync schema")}function G({gen:P,schemaEnv:I,schema:M,errSchemaPath:U,opts:re}){const ce=M.$comment;if(re.$comment===!0)P.code((0,o._)`${c.default.self}.logger.log(${ce})`);else if(typeof re.$comment=="function"){const Ue=(0,o.str)`${U}/$comment`,_t=P.scopeValue("root",{ref:I.root});P.code((0,o._)`${c.default.self}.opts.$comment(${ce}, ${Ue}, ${_t}.schema)`)}}function Y(P){const{gen:I,schemaEnv:M,validateName:U,ValidationError:re,opts:ce}=P;M.$async?I.if((0,o._)`${c.default.errors} === 0`,()=>I.return(c.default.data),()=>I.throw((0,o._)`new ${re}(${c.default.vErrors})`)):(I.assign((0,o._)`${U}.errors`,c.default.vErrors),ce.unevaluated&&ge(P),I.return((0,o._)`${c.default.errors} === 0`))}function ge({gen:P,evaluated:I,props:M,items:U}){M instanceof o.Name&&P.assign((0,o._)`${I}.props`,M),U instanceof o.Name&&P.assign((0,o._)`${I}.items`,U)}function We(P,I,M,U){const{gen:re,schema:ce,data:Ue,allErrors:_t,opts:Ye,self:Qe}=P,{RULES:Ve}=Qe;if(ce.$ref&&(Ye.ignoreKeywordsWithRef||!(0,l.schemaHasRulesButRef)(ce,Ve))){re.block(()=>ee(P,"$ref",Ve.all.$ref.definition));return}Ye.jtd||we(P,I),re.block(()=>{for(const ot of Ve.rules)br(ot);br(Ve.post)});function br(ot){(0,r.shouldUseGroup)(ce,ot)&&(ot.type?(re.if((0,n.checkDataType)(ot.type,Ue,Ye.strictNumbers)),Ke(P,ot),I.length===1&&I[0]===ot.type&&M&&(re.else(),(0,n.reportTypeError)(P)),re.endIf()):Ke(P,ot),_t||re.if((0,o._)`${c.default.errors} === ${U||0}`))}}function Ke(P,I){const{gen:M,schema:U,opts:{useDefaults:re}}=P;re&&(0,s.assignDefaults)(P,I.type),M.block(()=>{for(const ce of I.rules)(0,r.shouldUseRule)(U,ce)&&ee(P,ce.keyword,ce.definition,I.type)})}function we(P,I){P.schemaEnv.meta||!P.opts.strictTypes||(mt(P,I),P.opts.allowUnionTypes||D(P,I),C(P,P.dataTypes))}function mt(P,I){if(I.length){if(!P.dataTypes.length){P.dataTypes=I;return}I.forEach(M=>{O(P.dataTypes,M)||T(P,`type "${M}" not allowed by context "${P.dataTypes.join(",")}"`)}),k(P,I)}}function D(P,I){I.length>1&&!(I.length===2&&I.includes("null"))&&T(P,"use allowUnionTypes to allow union type keyword")}function C(P,I){const M=P.self.RULES.all;for(const U in M){const re=M[U];if(typeof re=="object"&&(0,r.shouldUseRule)(P.schema,re)){const{type:ce}=re.definition;ce.length&&!ce.some(Ue=>q(I,Ue))&&T(P,`missing type "${ce.join(",")}" for keyword "${U}"`)}}}function q(P,I){return P.includes(I)||I==="number"&&P.includes("integer")}function O(P,I){return P.includes(I)||I==="integer"&&P.includes("number")}function k(P,I){const M=[];for(const U of P.dataTypes)O(I,U)?M.push(U):I.includes("integer")&&U==="number"&&M.push("integer");P.dataTypes=M}function T(P,I){const M=P.schemaEnv.baseId+P.errSchemaPath;I+=` at "${M}" (strictTypes)`,(0,l.checkStrictMode)(P,I,P.opts.strictTypes)}class j{constructor(I,M,U){if((0,a.validateKeywordUsage)(I,M,U),this.gen=I.gen,this.allErrors=I.allErrors,this.keyword=U,this.data=I.data,this.schema=I.schema[U],this.$data=M.$data&&I.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,l.schemaRefOrVal)(I,this.schema,U,this.$data),this.schemaType=M.schemaType,this.parentSchema=I.schema,this.params={},this.it=I,this.def=M,this.$data)this.schemaCode=I.gen.const("vSchema",le(this.$data,I));else if(this.schemaCode=this.schemaValue,!(0,a.validSchemaType)(this.schema,M.schemaType,M.allowUndefined))throw new Error(`${U} value must be ${JSON.stringify(M.schemaType)}`);("code"in M?M.trackErrors:M.errors!==!1)&&(this.errsCount=I.gen.const("_errs",c.default.errors))}result(I,M,U){this.failResult((0,o.not)(I),M,U)}failResult(I,M,U){this.gen.if(I),U?U():this.error(),M?(this.gen.else(),M(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(I,M){this.failResult((0,o.not)(I),void 0,M)}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:M}=this;this.fail((0,o._)`${M} !== undefined && (${(0,o.or)(this.invalid$data(),I)})`)}error(I,M,U){if(M){this.setParams(M),this._error(I,U),this.setParams({});return}this._error(I,U)}_error(I,M){(I?h.reportExtraError:h.reportError)(this,this.def.error,M)}$dataError(){(0,h.reportError)(this,this.def.$dataError||h.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,h.resetErrorsCount)(this.gen,this.errsCount)}ok(I){this.allErrors||this.gen.if(I)}setParams(I,M){M?Object.assign(this.params,I):this.params=I}block$data(I,M,U=o.nil){this.gen.block(()=>{this.check$data(I,U),M()})}check$data(I=o.nil,M=o.nil){if(!this.$data)return;const{gen:U,schemaCode:re,schemaType:ce,def:Ue}=this;U.if((0,o.or)((0,o._)`${re} === undefined`,M)),I!==o.nil&&U.assign(I,!0),(ce.length||Ue.validateSchema)&&(U.elseIf(this.invalid$data()),this.$dataError(),I!==o.nil&&U.assign(I,!1)),U.else()}invalid$data(){const{gen:I,schemaCode:M,schemaType:U,def:re,it:ce}=this;return(0,o.or)(Ue(),_t());function Ue(){if(U.length){if(!(M instanceof o.Name))throw new Error("ajv implementation error");const Ye=Array.isArray(U)?U:[U];return(0,o._)`${(0,n.checkDataTypes)(Ye,M,ce.opts.strictNumbers,n.DataType.Wrong)}`}return o.nil}function _t(){if(re.validateSchema){const Ye=I.scopeValue("validate$data",{ref:re.validateSchema});return(0,o._)`!${Ye}(${M})`}return o.nil}}subschema(I,M){const U=(0,i.getSubschema)(this.it,I);(0,i.extendSubschemaData)(U,this.it,I),(0,i.extendSubschemaMode)(U,I);const re={...this.it,...U,items:void 0,props:void 0};return m(re,M),re}mergeEvaluated(I,M){const{it:U,gen:re}=this;U.opts.unevaluated&&(U.props!==!0&&I.props!==void 0&&(U.props=l.mergeEvaluated.props(re,I.props,U.props,M)),U.items!==!0&&I.items!==void 0&&(U.items=l.mergeEvaluated.items(re,I.items,U.items,M)))}mergeValidEvaluated(I,M){const{it:U,gen:re}=this;if(U.opts.unevaluated&&(U.props!==!0||U.items!==!0))return re.if(M,()=>this.mergeEvaluated(I,o.Name)),!0}}yt.KeywordCxt=j;function ee(P,I,M,U){const re=new j(P,M,I);"code"in M?M.code(re,U):re.$data&&M.validate?(0,a.funcKeywordCode)(re,M):"macro"in M?(0,a.macroKeywordCode)(re,M):(M.compile||M.validate)&&(0,a.funcKeywordCode)(re,M)}const ne=/^\/(?:[^~]|~0|~1)*$/,me=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function le(P,{dataLevel:I,dataNames:M,dataPathArr:U}){let re,ce;if(P==="")return c.default.rootData;if(P[0]==="/"){if(!ne.test(P))throw new Error(`Invalid JSON-pointer: ${P}`);re=P,ce=c.default.rootData}else{const Qe=me.exec(P);if(!Qe)throw new Error(`Invalid JSON-pointer: ${P}`);const Ve=+Qe[1];if(re=Qe[2],re==="#"){if(Ve>=I)throw new Error(Ye("property/index",Ve));return U[I-Ve]}if(Ve>I)throw new Error(Ye("data",Ve));if(ce=M[I-Ve],!re)return ce}let Ue=ce;const _t=re.split("/");for(const Qe of _t)Qe&&(ce=(0,o._)`${ce}${(0,o.getProperty)((0,l.unescapeJsonPointer)(Qe))}`,Ue=(0,o._)`${Ue} && ${ce}`);return Ue;function Ye(Qe,Ve){return`Cannot access ${Qe} ${Ve} levels up, current level is ${I}`}}return yt.getData=le,yt}var un={},_o;function Ys(){if(_o)return un;_o=1,Object.defineProperty(un,"__esModule",{value:!0});class t extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return un.default=t,un}var ln={},go;function dn(){if(go)return ln;go=1,Object.defineProperty(ln,"__esModule",{value:!0});const t=on();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 ln.default=e,ln}var Xe={},yo;function Qs(){if(yo)return Xe;yo=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.resolveSchema=Xe.getCompilingSchema=Xe.resolveRef=Xe.compileSchema=Xe.SchemaEnv=void 0;const t=ae(),e=Ys(),r=Et(),n=on(),s=de(),a=cn();class i{constructor(w){var d;this.refs={},this.dynamicAnchors={};let m;typeof w.schema=="object"&&(m=w.schema),this.schema=w.schema,this.schemaId=w.schemaId,this.root=w.root||this,this.baseId=(d=w.baseId)!==null&&d!==void 0?d:(0,n.normalizeId)(m?.[w.schemaId||"$id"]),this.schemaPath=w.schemaPath,this.localRefs=w.localRefs,this.meta=w.meta,this.$async=m?.$async,this.refs={}}}Xe.SchemaEnv=i;function o(f){const w=l.call(this,f);if(w)return w;const d=(0,n.getFullPath)(this.opts.uriResolver,f.root.baseId),{es5:m,lines:b}=this.opts.code,{ownProperties:v}=this.opts,$=new t.CodeGen(this.scope,{es5:m,lines:b,ownProperties:v});let E;f.$async&&(E=$.scopeValue("Error",{ref:e.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));const N=$.scopeName("validate");f.validateName=N;const L={gen:$,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:$.scopeValue("schema",this.opts.code.source===!0?{ref:f.schema,code:(0,t.stringify)(f.schema)}:{ref:f.schema}),validateName:N,ValidationError:E,schema:f.schema,schemaEnv:f,rootId:d,baseId:f.baseId||d,schemaPath:t.nil,errSchemaPath:f.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,t._)`""`,opts:this.opts,self:this};let K;try{this._compilations.add(f),(0,a.validateFunctionCode)(L),$.optimize(this.opts.code.optimize);const z=$.toString();K=`${$.scopeRefs(r.default.scope)}return ${z}`,this.opts.code.process&&(K=this.opts.code.process(K,f));const G=new Function(`${r.default.self}`,`${r.default.scope}`,K)(this,this.scope.get());if(this.scope.value(N,{ref:G}),G.errors=null,G.schema=f.schema,G.schemaEnv=f,f.$async&&(G.$async=!0),this.opts.code.source===!0&&(G.source={validateName:N,validateCode:z,scopeValues:$._values}),this.opts.unevaluated){const{props:Y,items:ge}=L;G.evaluated={props:Y instanceof t.Name?void 0:Y,items:ge instanceof t.Name?void 0:ge,dynamicProps:Y instanceof t.Name,dynamicItems:ge instanceof t.Name},G.source&&(G.source.evaluated=(0,t.stringify)(G.evaluated))}return f.validate=G,f}catch(z){throw delete f.validate,delete f.validateName,K&&this.logger.error("Error compiling schema, function code:",K),z}finally{this._compilations.delete(f)}}Xe.compileSchema=o;function c(f,w,d){var m;d=(0,n.resolveUrl)(this.opts.uriResolver,w,d);const b=f.refs[d];if(b)return b;let v=g.call(this,f,d);if(v===void 0){const $=(m=f.localRefs)===null||m===void 0?void 0:m[d],{schemaId:E}=this.opts;$&&(v=new i({schema:$,schemaId:E,root:f,baseId:w}))}if(v!==void 0)return f.refs[d]=u.call(this,v)}Xe.resolveRef=c;function u(f){return(0,n.inlineRef)(f.schema,this.opts.inlineRefs)?f.schema:f.validate?f:o.call(this,f)}function l(f){for(const w of this._compilations)if(h(w,f))return w}Xe.getCompilingSchema=l;function h(f,w){return f.schema===w.schema&&f.root===w.root&&f.baseId===w.baseId}function g(f,w){let d;for(;typeof(d=this.refs[w])=="string";)w=d;return d||this.schemas[w]||_.call(this,f,w)}function _(f,w){const d=this.opts.uriResolver.parse(w),m=(0,n._getFullPath)(this.opts.uriResolver,d);let b=(0,n.getFullPath)(this.opts.uriResolver,f.baseId,void 0);if(Object.keys(f.schema).length>0&&m===b)return y.call(this,d,f);const v=(0,n.normalizeId)(m),$=this.refs[v]||this.schemas[v];if(typeof $=="string"){const E=_.call(this,f,$);return typeof E?.schema!="object"?void 0:y.call(this,d,E)}if(typeof $?.schema=="object"){if($.validate||o.call(this,$),v===(0,n.normalizeId)(w)){const{schema:E}=$,{schemaId:N}=this.opts,L=E[N];return L&&(b=(0,n.resolveUrl)(this.opts.uriResolver,b,L)),new i({schema:E,schemaId:N,root:f,baseId:b})}return y.call(this,d,$)}}Xe.resolveSchema=_;const p=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function y(f,{baseId:w,schema:d,root:m}){var b;if(((b=f.fragment)===null||b===void 0?void 0:b[0])!=="/")return;for(const E of f.fragment.slice(1).split("/")){if(typeof d=="boolean")return;const N=d[(0,s.unescapeFragment)(E)];if(N===void 0)return;d=N;const L=typeof d=="object"&&d[this.opts.schemaId];!p.has(E)&&L&&(w=(0,n.resolveUrl)(this.opts.uriResolver,w,L))}let v;if(typeof d!="boolean"&&d.$ref&&!(0,s.schemaHasRulesButRef)(d,this.RULES)){const E=(0,n.resolveUrl)(this.opts.uriResolver,w,d.$ref);v=_.call(this,m,E)}const{schemaId:$}=this.opts;if(v=v||new i({schema:d,schemaId:$,root:m,baseId:w}),v.schema!==v.root.schema)return v}return Xe}const tf={$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 fn={},kr={exports:{}},Xs,vo;function wo(){if(vo)return Xs;vo=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 _="",p=0,y=0;for(y=0;y<g.length;y++)if(p=g[y].charCodeAt(0),p!==48){if(!(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102))return"";_+=g[y];break}for(y+=1;y<g.length;y++){if(p=g[y].charCodeAt(0),!(p>=48&&p<=57||p>=65&&p<=70||p>=97&&p<=102))return"";_+=g[y]}return _}const n=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function s(g){return g.length=0,!0}function a(g,_,p){if(g.length){const y=r(g);if(y!=="")_.push(y);else return p.error=!0,!1;g.length=0}return!0}function i(g){let _=0;const p={error:!1,address:"",zone:""},y=[],f=[];let w=!1,d=!1,m=a;for(let b=0;b<g.length;b++){const v=g[b];if(!(v==="["||v==="]"))if(v===":"){if(w===!0&&(d=!0),!m(f,y,p))break;if(++_>7){p.error=!0;break}b>0&&g[b-1]===":"&&(w=!0),y.push(":");continue}else if(v==="%"){if(!m(f,y,p))break;m=s}else{f.push(v);continue}}return f.length&&(m===s?p.zone=f.join(""):d?y.push(f.join("")):y.push(r(f))),p.address=y.join(""),p}function o(g){if(c(g,":")<2)return{host:g,isIPV6:!1};const _=i(g);if(_.error)return{host:g,isIPV6:!1};{let p=_.address,y=_.address;return _.zone&&(p+="%"+_.zone,y+="%25"+_.zone),{host:p,isIPV6:!0,escapedHost:y}}}function c(g,_){let p=0;for(let y=0;y<g.length;y++)g[y]===_&&p++;return p}function u(g){let _=g;const p=[];let y=-1,f=0;for(;f=_.length;){if(f===1){if(_===".")break;if(_==="/"){p.push("/");break}else{p.push(_);break}}else if(f===2){if(_[0]==="."){if(_[1]===".")break;if(_[1]==="/"){_=_.slice(2);continue}}else if(_[0]==="/"&&(_[1]==="."||_[1]==="/")){p.push("/");break}}else if(f===3&&_==="/.."){p.length!==0&&p.pop(),p.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),p.length!==0&&p.pop();continue}}if((y=_.indexOf("/",1))===-1){p.push(_);break}else p.push(_.slice(0,y)),_=_.slice(y)}return p.join("")}function l(g,_){const p=_!==!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 h(g){const _=[];if(g.userinfo!==void 0&&(_.push(g.userinfo),_.push("@")),g.host!==void 0){let p=unescape(g.host);if(!e(p)){const y=o(p);y.isIPV6===!0?p=`[${y.escapedHost}]`:p=g.host}_.push(p)}return(typeof g.port=="number"||typeof g.port=="string")&&(_.push(":"),_.push(String(g.port))),_.length?_.join(""):void 0}return Xs={nonSimpleDomain:n,recomposeAuthority:h,normalizeComponentEncoding:l,removeDotSegments:u,isIPv4:e,isUUID:t,normalizeIPv6:o,stringArrayToHexStripped:r},Xs}var ea,bo;function rf(){if(bo)return ea;bo=1;const{isUUID:t}=wo(),e=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,r=["http","https","ws","wss","urn","urn:uuid"];function n(v){return r.indexOf(v)!==-1}function s(v){return v.secure===!0?!0:v.secure===!1?!1:v.scheme?v.scheme.length===3&&(v.scheme[0]==="w"||v.scheme[0]==="W")&&(v.scheme[1]==="s"||v.scheme[1]==="S")&&(v.scheme[2]==="s"||v.scheme[2]==="S"):!1}function a(v){return v.host||(v.error=v.error||"HTTP URIs must have a host."),v}function i(v){const $=String(v.scheme).toLowerCase()==="https";return(v.port===($?443:80)||v.port==="")&&(v.port=void 0),v.path||(v.path="/"),v}function o(v){return v.secure=s(v),v.resourceName=(v.path||"/")+(v.query?"?"+v.query:""),v.path=void 0,v.query=void 0,v}function c(v){if((v.port===(s(v)?443:80)||v.port==="")&&(v.port=void 0),typeof v.secure=="boolean"&&(v.scheme=v.secure?"wss":"ws",v.secure=void 0),v.resourceName){const[$,E]=v.resourceName.split("?");v.path=$&&$!=="/"?$:void 0,v.query=E,v.resourceName=void 0}return v.fragment=void 0,v}function u(v,$){if(!v.path)return v.error="URN can not be parsed",v;const E=v.path.match(e);if(E){const N=$.scheme||v.scheme||"urn";v.nid=E[1].toLowerCase(),v.nss=E[2];const L=`${N}:${$.nid||v.nid}`,K=b(L);v.path=void 0,K&&(v=K.parse(v,$))}else v.error=v.error||"URN can not be parsed.";return v}function l(v,$){if(v.nid===void 0)throw new Error("URN without nid cannot be serialized");const E=$.scheme||v.scheme||"urn",N=v.nid.toLowerCase(),L=`${E}:${$.nid||N}`,K=b(L);K&&(v=K.serialize(v,$));const z=v,F=v.nss;return z.path=`${N||$.nid}:${F}`,$.skipEscape=!0,z}function h(v,$){const E=v;return E.uuid=E.nss,E.nss=void 0,!$.tolerant&&(!E.uuid||!t(E.uuid))&&(E.error=E.error||"UUID is not valid."),E}function g(v){const $=v;return $.nss=(v.uuid||"").toLowerCase(),$}const _={scheme:"http",domainHost:!0,parse:a,serialize:i},p={scheme:"https",domainHost:_.domainHost,parse:a,serialize:i},y={scheme:"ws",domainHost:!0,parse:o,serialize:c},f={scheme:"wss",domainHost:y.domainHost,parse:y.parse,serialize:y.serialize},m={http:_,https:p,ws:y,wss:f,urn:{scheme:"urn",parse:u,serialize:l,skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:h,serialize:g,skipNormalize:!0}};Object.setPrototypeOf(m,null);function b(v){return v&&(m[v]||m[v.toLowerCase()])||void 0}return ea={wsIsSecure:s,SCHEMES:m,isValidSchemeName:n,getSchemeHandler:b},ea}var So;function nf(){if(So)return kr.exports;So=1;const{normalizeIPv6:t,removeDotSegments:e,recomposeAuthority:r,normalizeComponentEncoding:n,isIPv4:s,nonSimpleDomain:a}=wo(),{SCHEMES:i,getSchemeHandler:o}=rf();function c(f,w){return typeof f=="string"?f=g(p(f,w),w):typeof f=="object"&&(f=p(g(f,w),w)),f}function u(f,w,d){const m=d?Object.assign({scheme:"null"},d):{scheme:"null"},b=l(p(f,m),p(w,m),m,!0);return m.skipEscape=!0,g(b,m)}function l(f,w,d,m){const b={};return m||(f=p(g(f,d),d),w=p(g(w,d),d)),d=d||{},!d.tolerant&&w.scheme?(b.scheme=w.scheme,b.userinfo=w.userinfo,b.host=w.host,b.port=w.port,b.path=e(w.path||""),b.query=w.query):(w.userinfo!==void 0||w.host!==void 0||w.port!==void 0?(b.userinfo=w.userinfo,b.host=w.host,b.port=w.port,b.path=e(w.path||""),b.query=w.query):(w.path?(w.path[0]==="/"?b.path=e(w.path):((f.userinfo!==void 0||f.host!==void 0||f.port!==void 0)&&!f.path?b.path="/"+w.path:f.path?b.path=f.path.slice(0,f.path.lastIndexOf("/")+1)+w.path:b.path=w.path,b.path=e(b.path)),b.query=w.query):(b.path=f.path,w.query!==void 0?b.query=w.query:b.query=f.query),b.userinfo=f.userinfo,b.host=f.host,b.port=f.port),b.scheme=f.scheme),b.fragment=w.fragment,b}function h(f,w,d){return typeof f=="string"?(f=unescape(f),f=g(n(p(f,d),!0),{...d,skipEscape:!0})):typeof f=="object"&&(f=g(n(f,!0),{...d,skipEscape:!0})),typeof w=="string"?(w=unescape(w),w=g(n(p(w,d),!0),{...d,skipEscape:!0})):typeof w=="object"&&(w=g(n(w,!0),{...d,skipEscape:!0})),f.toLowerCase()===w.toLowerCase()}function g(f,w){const d={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:""},m=Object.assign({},w),b=[],v=o(m.scheme||d.scheme);v&&v.serialize&&v.serialize(d,m),d.path!==void 0&&(m.skipEscape?d.path=unescape(d.path):(d.path=escape(d.path),d.scheme!==void 0&&(d.path=d.path.split("%3A").join(":")))),m.reference!=="suffix"&&d.scheme&&b.push(d.scheme,":");const $=r(d);if($!==void 0&&(m.reference!=="suffix"&&b.push("//"),b.push($),d.path&&d.path[0]!=="/"&&b.push("/")),d.path!==void 0){let E=d.path;!m.absolutePath&&(!v||!v.absolutePath)&&(E=e(E)),$===void 0&&E[0]==="/"&&E[1]==="/"&&(E="/%2F"+E.slice(2)),b.push(E)}return d.query!==void 0&&b.push("?",d.query),d.fragment!==void 0&&b.push("#",d.fragment),b.join("")}const _=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function p(f,w){const d=Object.assign({},w),m={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let b=!1;d.reference==="suffix"&&(d.scheme?f=d.scheme+":"+f:f="//"+f);const v=f.match(_);if(v){if(m.scheme=v[1],m.userinfo=v[3],m.host=v[4],m.port=parseInt(v[5],10),m.path=v[6]||"",m.query=v[7],m.fragment=v[8],isNaN(m.port)&&(m.port=v[5]),m.host)if(s(m.host)===!1){const N=t(m.host);m.host=N.host.toLowerCase(),b=N.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",d.reference&&d.reference!=="suffix"&&d.reference!==m.reference&&(m.error=m.error||"URI is not a "+d.reference+" reference.");const $=o(d.scheme||m.scheme);if(!d.unicodeSupport&&(!$||!$.unicodeSupport)&&m.host&&(d.domainHost||$&&$.domainHost)&&b===!1&&a(m.host))try{m.host=URL.domainToASCII(m.host.toLowerCase())}catch(E){m.error=m.error||"Host's domain name can not be converted to ASCII: "+E}(!$||$&&!$.skipNormalize)&&(f.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)))),$&&$.parse&&$.parse(m,d)}else m.error=m.error||"URI can not be parsed.";return m}const y={SCHEMES:i,normalize:c,resolve:u,resolveComponent:l,equal:h,serialize:g,parse:p};return kr.exports=y,kr.exports.default=y,kr.exports.fastUri=y,kr.exports}var ko;function sf(){if(ko)return fn;ko=1,Object.defineProperty(fn,"__esModule",{value:!0});const t=nf();return t.code='require("ajv/dist/runtime/uri").default',fn.default=t,fn}var $o;function af(){return $o||($o=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=cn();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var r=ae();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=Ys(),s=dn(),a=ro(),i=Qs(),o=ae(),c=on(),u=an(),l=de(),h=tf,g=sf(),_=(D,C)=>new RegExp(D,C);_.code="new RegExp";const p=["removeAdditional","useDefaults","coerceTypes"],y=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."},w={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},d=200;function m(D){var C,q,O,k,T,j,ee,ne,me,le,P,I,M,U,re,ce,Ue,_t,Ye,Qe,Ve,br,ot,Fi,Hi;const en=D.strict,Wi=(C=D.code)===null||C===void 0?void 0:C.optimize,Jd=Wi===!0||Wi===void 0?1:Wi||0,Gd=(O=(q=D.code)===null||q===void 0?void 0:q.regExp)!==null&&O!==void 0?O:_,$v=(k=D.uriResolver)!==null&&k!==void 0?k:g.default;return{strictSchema:(j=(T=D.strictSchema)!==null&&T!==void 0?T:en)!==null&&j!==void 0?j:!0,strictNumbers:(ne=(ee=D.strictNumbers)!==null&&ee!==void 0?ee:en)!==null&&ne!==void 0?ne:!0,strictTypes:(le=(me=D.strictTypes)!==null&&me!==void 0?me:en)!==null&&le!==void 0?le:"log",strictTuples:(I=(P=D.strictTuples)!==null&&P!==void 0?P:en)!==null&&I!==void 0?I:"log",strictRequired:(U=(M=D.strictRequired)!==null&&M!==void 0?M:en)!==null&&U!==void 0?U:!1,code:D.code?{...D.code,optimize:Jd,regExp:Gd}:{optimize:Jd,regExp:Gd},loopRequired:(re=D.loopRequired)!==null&&re!==void 0?re:d,loopEnum:(ce=D.loopEnum)!==null&&ce!==void 0?ce:d,meta:(Ue=D.meta)!==null&&Ue!==void 0?Ue:!0,messages:(_t=D.messages)!==null&&_t!==void 0?_t:!0,inlineRefs:(Ye=D.inlineRefs)!==null&&Ye!==void 0?Ye:!0,schemaId:(Qe=D.schemaId)!==null&&Qe!==void 0?Qe:"$id",addUsedSchema:(Ve=D.addUsedSchema)!==null&&Ve!==void 0?Ve:!0,validateSchema:(br=D.validateSchema)!==null&&br!==void 0?br:!0,validateFormats:(ot=D.validateFormats)!==null&&ot!==void 0?ot:!0,unicodeRegExp:(Fi=D.unicodeRegExp)!==null&&Fi!==void 0?Fi:!0,int32range:(Hi=D.int32range)!==null&&Hi!==void 0?Hi:!0,uriResolver:$v}}class b{constructor(C={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,C=this.opts={...C,...m(C)};const{es5:q,lines:O}=this.opts.code;this.scope=new o.ValueScope({scope:{},prefixes:y,es5:q,lines:O}),this.logger=F(C.logger);const k=C.validateFormats;C.validateFormats=!1,this.RULES=(0,a.getRules)(),v.call(this,f,C,"NOT SUPPORTED"),v.call(this,w,C,"DEPRECATED","warn"),this._metaOpts=K.call(this),C.formats&&N.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),C.keywords&&L.call(this,C.keywords),typeof C.meta=="object"&&this.addMetaSchema(C.meta),E.call(this),C.validateFormats=k}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:C,meta:q,schemaId:O}=this.opts;let k=h;O==="id"&&(k={...h},k.id=k.$id,delete k.$id),q&&C&&this.addMetaSchema(k,k[O],!1)}defaultMeta(){const{meta:C,schemaId:q}=this.opts;return this.opts.defaultMeta=typeof C=="object"?C[q]||C:void 0}validate(C,q){let O;if(typeof C=="string"){if(O=this.getSchema(C),!O)throw new Error(`no schema with key or ref "${C}"`)}else O=this.compile(C);const k=O(q);return"$async"in O||(this.errors=O.errors),k}compile(C,q){const O=this._addSchema(C,q);return O.validate||this._compileSchemaEnv(O)}compileAsync(C,q){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:O}=this.opts;return k.call(this,C,q);async function k(le,P){await T.call(this,le.$schema);const I=this._addSchema(le,P);return I.validate||j.call(this,I)}async function T(le){le&&!this.getSchema(le)&&await k.call(this,{$ref:le},!0)}async function j(le){try{return this._compileSchemaEnv(le)}catch(P){if(!(P instanceof s.default))throw P;return ee.call(this,P),await ne.call(this,P.missingSchema),j.call(this,le)}}function ee({missingSchema:le,missingRef:P}){if(this.refs[le])throw new Error(`AnySchema ${le} is loaded but ${P} cannot be resolved`)}async function ne(le){const P=await me.call(this,le);this.refs[le]||await T.call(this,P.$schema),this.refs[le]||this.addSchema(P,le,q)}async function me(le){const P=this._loading[le];if(P)return P;try{return await(this._loading[le]=O(le))}finally{delete this._loading[le]}}}addSchema(C,q,O,k=this.opts.validateSchema){if(Array.isArray(C)){for(const j of C)this.addSchema(j,void 0,O,k);return this}let T;if(typeof C=="object"){const{schemaId:j}=this.opts;if(T=C[j],T!==void 0&&typeof T!="string")throw new Error(`schema ${j} must be string`)}return q=(0,c.normalizeId)(q||T),this._checkUnique(q),this.schemas[q]=this._addSchema(C,O,q,k,!0),this}addMetaSchema(C,q,O=this.opts.validateSchema){return this.addSchema(C,q,!0,O),this}validateSchema(C,q){if(typeof C=="boolean")return!0;let O;if(O=C.$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,C);if(!k&&q){const T="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(T);else throw new Error(T)}return k}getSchema(C){let q;for(;typeof(q=$.call(this,C))=="string";)C=q;if(q===void 0){const{schemaId:O}=this.opts,k=new i.SchemaEnv({schema:{},schemaId:O});if(q=i.resolveSchema.call(this,k,C),!q)return;this.refs[C]=q}return q.validate||this._compileSchemaEnv(q)}removeSchema(C){if(C instanceof RegExp)return this._removeAllSchemas(this.schemas,C),this._removeAllSchemas(this.refs,C),this;switch(typeof C){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const q=$.call(this,C);return typeof q=="object"&&this._cache.delete(q.schema),delete this.schemas[C],delete this.refs[C],this}case"object":{const q=C;this._cache.delete(q);let O=C[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(C){for(const q of C)this.addKeyword(q);return this}addKeyword(C,q){let O;if(typeof C=="string")O=C,typeof q=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),q.keyword=O);else if(typeof C=="object"&&q===void 0){if(q=C,O=q.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,q),!q)return(0,l.eachItem)(O,T=>ge.call(this,T)),this;Ke.call(this,q);const k={...q,type:(0,u.getJSONTypes)(q.type),schemaType:(0,u.getJSONTypes)(q.schemaType)};return(0,l.eachItem)(O,k.type.length===0?T=>ge.call(this,T,k):T=>k.type.forEach(j=>ge.call(this,T,k,j))),this}getKeyword(C){const q=this.RULES.all[C];return typeof q=="object"?q.definition:!!q}removeKeyword(C){const{RULES:q}=this;delete q.keywords[C],delete q.all[C];for(const O of q.rules){const k=O.rules.findIndex(T=>T.keyword===C);k>=0&&O.rules.splice(k,1)}return this}addFormat(C,q){return typeof q=="string"&&(q=new RegExp(q)),this.formats[C]=q,this}errorsText(C=this.errors,{separator:q=", ",dataVar:O="data"}={}){return!C||C.length===0?"No errors":C.map(k=>`${O}${k.instancePath} ${k.message}`).reduce((k,T)=>k+q+T)}$dataMetaSchema(C,q){const O=this.RULES.all;C=JSON.parse(JSON.stringify(C));for(const k of q){const T=k.split("/").slice(1);let j=C;for(const ee of T)j=j[ee];for(const ee in O){const ne=O[ee];if(typeof ne!="object")continue;const{$data:me}=ne.definition,le=j[ee];me&&le&&(j[ee]=mt(le))}}return C}_removeAllSchemas(C,q){for(const O in C){const k=C[O];(!q||q.test(O))&&(typeof k=="string"?delete C[O]:k&&!k.meta&&(this._cache.delete(k.schema),delete C[O]))}}_addSchema(C,q,O,k=this.opts.validateSchema,T=this.opts.addUsedSchema){let j;const{schemaId:ee}=this.opts;if(typeof C=="object")j=C[ee];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof C!="boolean")throw new Error("schema must be object or boolean")}let ne=this._cache.get(C);if(ne!==void 0)return ne;O=(0,c.normalizeId)(j||O);const me=c.getSchemaRefs.call(this,C,O);return ne=new i.SchemaEnv({schema:C,schemaId:ee,meta:q,baseId:O,localRefs:me}),this._cache.set(ne.schema,ne),T&&!O.startsWith("#")&&(O&&this._checkUnique(O),this.refs[O]=ne),k&&this.validateSchema(C,!0),ne}_checkUnique(C){if(this.schemas[C]||this.refs[C])throw new Error(`schema with key or id "${C}" already exists`)}_compileSchemaEnv(C){if(C.meta?this._compileMetaSchema(C):i.compileSchema.call(this,C),!C.validate)throw new Error("ajv implementation error");return C.validate}_compileMetaSchema(C){const q=this.opts;this.opts=this._metaOpts;try{i.compileSchema.call(this,C)}finally{this.opts=q}}}b.ValidationError=n.default,b.MissingRefError=s.default,t.default=b;function v(D,C,q,O="error"){for(const k in D){const T=k;T in C&&this.logger[O](`${q}: option ${k}. ${D[T]}`)}}function $(D){return D=(0,c.normalizeId)(D),this.schemas[D]||this.refs[D]}function E(){const D=this.opts.schemas;if(D)if(Array.isArray(D))this.addSchema(D);else for(const C in D)this.addSchema(D[C],C)}function N(){for(const D in this.opts.formats){const C=this.opts.formats[D];C&&this.addFormat(D,C)}}function L(D){if(Array.isArray(D)){this.addVocabulary(D);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const C in D){const q=D[C];q.keyword||(q.keyword=C),this.addKeyword(q)}}function K(){const D={...this.opts};for(const C of p)delete D[C];return D}const z={log(){},warn(){},error(){}};function F(D){if(D===!1)return z;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 G=/^[a-z_$][a-z0-9_$:-]*$/i;function Y(D,C){const{RULES:q}=this;if((0,l.eachItem)(D,O=>{if(q.keywords[O])throw new Error(`Keyword ${O} is already defined`);if(!G.test(O))throw new Error(`Keyword ${O} has invalid name`)}),!!C&&C.$data&&!("code"in C||"validate"in C))throw new Error('$data keyword must have "code" or "validate" function')}function ge(D,C,q){var O;const k=C?.post;if(q&&k)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:T}=this;let j=k?T.post:T.rules.find(({type:ne})=>ne===q);if(j||(j={type:q,rules:[]},T.rules.push(j)),T.keywords[D]=!0,!C)return;const ee={keyword:D,definition:{...C,type:(0,u.getJSONTypes)(C.type),schemaType:(0,u.getJSONTypes)(C.schemaType)}};C.before?We.call(this,j,ee,C.before):j.rules.push(ee),T.all[D]=ee,(O=C.implements)===null||O===void 0||O.forEach(ne=>this.addKeyword(ne))}function We(D,C,q){const O=D.rules.findIndex(k=>k.keyword===q);O>=0?D.rules.splice(O,0,C):(D.rules.push(C),this.logger.warn(`rule ${q} is not defined`))}function Ke(D){let{metaSchema:C}=D;C!==void 0&&(D.$data&&this.opts.$data&&(C=mt(C)),D.validateSchema=this.compile(C,!0))}const we={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function mt(D){return{anyOf:[D,we]}}})(Fs)),Fs}var hn={},pn={},mn={},Eo;function of(){if(Eo)return mn;Eo=1,Object.defineProperty(mn,"__esModule",{value:!0});const t={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return mn.default=t,mn}var Rt={},Ro;function cf(){if(Ro)return Rt;Ro=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.callRef=Rt.getValidate=void 0;const t=dn(),e=ut(),r=ae(),n=Et(),s=Qs(),a=de(),i={keyword:"$ref",schemaType:"string",code(u){const{gen:l,schema:h,it:g}=u,{baseId:_,schemaEnv:p,validateName:y,opts:f,self:w}=g,{root:d}=p;if((h==="#"||h==="#/")&&_===d.baseId)return b();const m=s.resolveRef.call(w,d,_,h);if(m===void 0)throw new t.default(g.opts.uriResolver,_,h);if(m instanceof s.SchemaEnv)return v(m);return $(m);function b(){if(p===d)return c(u,y,p,p.$async);const E=l.scopeValue("root",{ref:d});return c(u,(0,r._)`${E}.validate`,d,d.$async)}function v(E){const N=o(u,E);c(u,N,E,E.$async)}function $(E){const N=l.scopeValue("schema",f.code.source===!0?{ref:E,code:(0,r.stringify)(E)}:{ref:E}),L=l.name("valid"),K=u.subschema({schema:E,dataTypes:[],schemaPath:r.nil,topSchemaRef:N,errSchemaPath:h},L);u.mergeEvaluated(K),u.ok(L)}}};function o(u,l){const{gen:h}=u;return l.validate?h.scopeValue("validate",{ref:l.validate}):(0,r._)`${h.scopeValue("wrapper",{ref:l})}.validate`}Rt.getValidate=o;function c(u,l,h,g){const{gen:_,it:p}=u,{allErrors:y,schemaEnv:f,opts:w}=p,d=w.passContext?n.default.this:r.nil;g?m():b();function m(){if(!f.$async)throw new Error("async schema referenced by sync schema");const E=_.let("valid");_.try(()=>{_.code((0,r._)`await ${(0,e.callValidateCode)(u,l,d)}`),$(l),y||_.assign(E,!0)},N=>{_.if((0,r._)`!(${N} instanceof ${p.ValidationError})`,()=>_.throw(N)),v(N),y||_.assign(E,!1)}),u.ok(E)}function b(){u.result((0,e.callValidateCode)(u,l,d),()=>$(l),()=>v(l))}function v(E){const N=(0,r._)`${E}.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 $(E){var N;if(!p.opts.unevaluated)return;const L=(N=h?.validate)===null||N===void 0?void 0:N.evaluated;if(p.props!==!0)if(L&&!L.dynamicProps)L.props!==void 0&&(p.props=a.mergeEvaluated.props(_,L.props,p.props));else{const K=_.var("props",(0,r._)`${E}.evaluated.props`);p.props=a.mergeEvaluated.props(_,K,p.props,r.Name)}if(p.items!==!0)if(L&&!L.dynamicItems)L.items!==void 0&&(p.items=a.mergeEvaluated.items(_,L.items,p.items));else{const K=_.var("items",(0,r._)`${E}.evaluated.items`);p.items=a.mergeEvaluated.items(_,K,p.items,r.Name)}}}return Rt.callRef=c,Rt.default=i,Rt}var To;function uf(){if(To)return pn;To=1,Object.defineProperty(pn,"__esModule",{value:!0});const t=of(),e=cf(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",t.default,e.default];return pn.default=r,pn}var _n={},gn={},Po;function lf(){if(Po)return gn;Po=1,Object.defineProperty(gn,"__esModule",{value:!0});const t=ae(),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 gn.default=s,gn}var yn={},Co;function df(){if(Co)return yn;Co=1,Object.defineProperty(yn,"__esModule",{value:!0});const t=ae(),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,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} = ${a}/${i}, ${l}))`)}};return yn.default=r,yn}var vn={},wn={},Io;function ff(){if(Io)return wn;Io=1,Object.defineProperty(wn,"__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 wn.default=t,t.code='require("ajv/dist/runtime/ucs2length").default',wn}var Oo;function hf(){if(Oo)return vn;Oo=1,Object.defineProperty(vn,"__esModule",{value:!0});const t=ae(),e=de(),r=ff(),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:u}=a,l=i==="maxLength"?t.operators.GT:t.operators.LT,h=u.opts.unicode===!1?(0,t._)`${o}.length`:(0,t._)`${(0,e.useFunc)(a.gen,r.default)}(${o})`;a.fail$data((0,t._)`${h} ${l} ${c}`)}};return vn.default=s,vn}var bn={},No;function pf(){if(No)return bn;No=1,Object.defineProperty(bn,"__esModule",{value:!0});const t=ut(),e=de(),r=ae(),s={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:a})=>(0,r.str)`must match pattern "${a}"`,params:({schemaCode:a})=>(0,r._)`{pattern: ${a}}`},code(a){const{gen:i,data:o,$data:c,schema:u,schemaCode:l,it:h}=a,g=h.opts.unicodeRegExp?"u":"";if(c){const{regExp:_}=h.opts.code,p=_.code==="new RegExp"?(0,r._)`new RegExp`:(0,e.useFunc)(i,_),y=i.let("valid");i.try(()=>i.assign(y,(0,r._)`${p}(${l}, ${g}).test(${o})`),()=>i.assign(y,!1)),a.fail$data((0,r._)`!${y}`)}else{const _=(0,t.usePattern)(a,u);a.fail$data((0,r._)`!${_}.test(${o})`)}}};return bn.default=s,bn}var Sn={},Ao;function mf(){if(Ao)return Sn;Ao=1,Object.defineProperty(Sn,"__esModule",{value:!0});const t=ae(),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 Sn.default=r,Sn}var kn={},jo;function _f(){if(jo)return kn;jo=1,Object.defineProperty(kn,"__esModule",{value:!0});const t=ut(),e=ae(),r=de(),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:u,$data:l,it:h}=a,{opts:g}=h;if(!l&&o.length===0)return;const _=o.length>=g.loopRequired;if(h.allErrors?p():y(),g.strictRequired){const d=a.parentSchema.properties,{definedProperties:m}=a.it;for(const b of o)if(d?.[b]===void 0&&!m.has(b)){const v=h.schemaEnv.baseId+h.errSchemaPath,$=`required property "${b}" is not defined at "${v}" (strictRequired)`;(0,r.checkStrictMode)(h,$,h.opts.strictRequired)}}function p(){if(_||l)a.block$data(e.nil,f);else for(const d of o)(0,t.checkReportMissingProp)(a,d)}function y(){const d=i.let("missing");if(_||l){const m=i.let("valid",!0);a.block$data(m,()=>w(d,m)),a.ok(m)}else i.if((0,t.checkMissingProp)(a,o,d)),(0,t.reportMissingProp)(a,d),i.else()}function f(){i.forOf("prop",c,d=>{a.setParams({missingProperty:d}),i.if((0,t.noPropertyInData)(i,u,d,g.ownProperties),()=>a.error())})}function w(d,m){a.setParams({missingProperty:d}),i.forOf(d,c,()=>{i.assign(m,(0,t.propertyInData)(i,u,d,g.ownProperties)),i.if((0,e.not)(m),()=>{a.error(),i.break()})},e.nil)}}};return kn.default=s,kn}var $n={},zo;function gf(){if(zo)return $n;zo=1,Object.defineProperty($n,"__esModule",{value:!0});const t=ae(),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 $n.default=r,$n}var En={},Rn={},Mo;function ta(){if(Mo)return Rn;Mo=1,Object.defineProperty(Rn,"__esModule",{value:!0});const t=fo();return t.code='require("ajv/dist/runtime/equal").default',Rn.default=t,Rn}var qo;function yf(){if(qo)return En;qo=1,Object.defineProperty(En,"__esModule",{value:!0});const t=an(),e=ae(),r=de(),n=ta(),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:u,schema:l,parentSchema:h,schemaCode:g,it:_}=i;if(!u&&!l)return;const p=o.let("valid"),y=h.items?(0,t.getSchemaTypes)(h.items):[];i.block$data(p,f,(0,e._)`${g} === false`),i.ok(p);function f(){const b=o.let("i",(0,e._)`${c}.length`),v=o.let("j");i.setParams({i:b,j:v}),o.assign(p,!0),o.if((0,e._)`${b} > 1`,()=>(w()?d:m)(b,v))}function w(){return y.length>0&&!y.some(b=>b==="object"||b==="array")}function d(b,v){const $=o.name("item"),E=(0,t.checkDataTypes)(y,$,_.opts.strictNumbers,t.DataType.Wrong),N=o.const("indices",(0,e._)`{}`);o.for((0,e._)`;${b}--;`,()=>{o.let($,(0,e._)`${c}[${b}]`),o.if(E,(0,e._)`continue`),y.length>1&&o.if((0,e._)`typeof ${$} == "string"`,(0,e._)`${$} += "_"`),o.if((0,e._)`typeof ${N}[${$}] == "number"`,()=>{o.assign(v,(0,e._)`${N}[${$}]`),i.error(),o.assign(p,!1).break()}).code((0,e._)`${N}[${$}] = ${b}`)})}function m(b,v){const $=(0,r.useFunc)(o,n.default),E=o.name("outer");o.label(E).for((0,e._)`;${b}--;`,()=>o.for((0,e._)`${v} = ${b}; ${v}--;`,()=>o.if((0,e._)`${$}(${c}[${b}], ${c}[${v}])`,()=>{i.error(),o.assign(p,!1).break(E)})))}}};return En.default=a,En}var Tn={},Zo;function vf(){if(Zo)return Tn;Zo=1,Object.defineProperty(Tn,"__esModule",{value:!0});const t=ae(),e=de(),r=ta(),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:u,schema:l}=a;c||l&&typeof l=="object"?a.fail$data((0,t._)`!${(0,e.useFunc)(i,r.default)}(${o}, ${u})`):a.fail((0,t._)`${l} !== ${o}`)}};return Tn.default=s,Tn}var Pn={},Lo;function wf(){if(Lo)return Pn;Lo=1,Object.defineProperty(Pn,"__esModule",{value:!0});const t=ae(),e=de(),r=ta(),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:u,schemaCode:l,it:h}=a;if(!c&&u.length===0)throw new Error("enum must have non-empty array");const g=u.length>=h.opts.loopEnum;let _;const p=()=>_??(_=(0,e.useFunc)(i,r.default));let y;if(g||c)y=i.let("valid"),a.block$data(y,f);else{if(!Array.isArray(u))throw new Error("ajv implementation error");const d=i.const("vSchema",l);y=(0,t.or)(...u.map((m,b)=>w(d,b)))}a.pass(y);function f(){i.assign(y,!1),i.forOf("v",l,d=>i.if((0,t._)`${p()}(${o}, ${d})`,()=>i.assign(y,!0).break()))}function w(d,m){const b=u[m];return typeof b=="object"&&b!==null?(0,t._)`${p()}(${o}, ${d}[${m}])`:(0,t._)`${o} === ${b}`}}};return Pn.default=s,Pn}var xo;function bf(){if(xo)return _n;xo=1,Object.defineProperty(_n,"__esModule",{value:!0});const t=lf(),e=df(),r=hf(),n=pf(),s=mf(),a=_f(),i=gf(),o=yf(),c=vf(),u=wf(),l=[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,u.default];return _n.default=l,_n}var Cn={},Xt={},Do;function Uo(){if(Do)return Xt;Do=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.validateAdditionalItems=void 0;const t=ae(),e=de(),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:u,keyword:l,it:h}=a;h.items=!0;const g=o.const("len",(0,t._)`${u}.length`);if(c===!1)a.setParams({len:i.length}),a.pass((0,t._)`${g} <= ${i.length}`);else if(typeof c=="object"&&!(0,e.alwaysValidSchema)(h,c)){const p=o.var("valid",(0,t._)`${g} <= ${i.length}`);o.if((0,t.not)(p),()=>_(p)),a.ok(p)}function _(p){o.forRange("i",i.length,g,y=>{a.subschema({keyword:l,dataProp:y,dataPropType:e.Type.Num},p),h.allErrors||o.if((0,t.not)(p),()=>o.break())})}}return Xt.validateAdditionalItems=s,Xt.default=n,Xt}var In={},er={},Vo;function Fo(){if(Vo)return er;Vo=1,Object.defineProperty(er,"__esModule",{value:!0}),er.validateTuple=void 0;const t=ae(),e=de(),r=ut(),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:u,data:l,keyword:h,it:g}=a;y(u),g.opts.unevaluated&&o.length&&g.items!==!0&&(g.items=e.mergeEvaluated.items(c,o.length,g.items));const _=c.name("valid"),p=c.const("len",(0,t._)`${l}.length`);o.forEach((f,w)=>{(0,e.alwaysValidSchema)(g,f)||(c.if((0,t._)`${p} > ${w}`,()=>a.subschema({keyword:h,schemaProp:w,dataProp:w},_)),a.ok(_))});function y(f){const{opts:w,errSchemaPath:d}=g,m=o.length,b=m===f.minItems&&(m===f.maxItems||f[i]===!1);if(w.strictTuples&&!b){const v=`"${h}" is ${m}-tuple, but minItems or maxItems/${i} are not specified or different at path "${d}"`;(0,e.checkStrictMode)(g,v,w.strictTuples)}}}return er.validateTuple=s,er.default=n,er}var Ho;function Sf(){if(Ho)return In;Ho=1,Object.defineProperty(In,"__esModule",{value:!0});const t=Fo(),e={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:r=>(0,t.validateTuple)(r,"items")};return In.default=e,In}var On={},Wo;function kf(){if(Wo)return On;Wo=1,Object.defineProperty(On,"__esModule",{value:!0});const t=ae(),e=de(),r=ut(),n=Uo(),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:u}=i,{prefixItems:l}=c;u.items=!0,!(0,e.alwaysValidSchema)(u,o)&&(l?(0,n.validateAdditionalItems)(i,l):i.ok((0,r.validateArray)(i)))}};return On.default=a,On}var Nn={},Ko;function $f(){if(Ko)return Nn;Ko=1,Object.defineProperty(Nn,"__esModule",{value:!0});const t=ae(),e=de(),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:u}=s;let l,h;const{minContains:g,maxContains:_}=o;u.opts.next?(l=g===void 0?1:g,h=_):l=1;const p=a.const("len",(0,t._)`${c}.length`);if(s.setParams({min:l,max:h}),h===void 0&&l===0){(0,e.checkStrictMode)(u,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(h!==void 0&&l>h){(0,e.checkStrictMode)(u,'"minContains" > "maxContains" is always invalid'),s.fail();return}if((0,e.alwaysValidSchema)(u,i)){let m=(0,t._)`${p} >= ${l}`;h!==void 0&&(m=(0,t._)`${m} && ${p} <= ${h}`),s.pass(m);return}u.items=!0;const y=a.name("valid");h===void 0&&l===1?w(y,()=>a.if(y,()=>a.break())):l===0?(a.let(y,!0),h!==void 0&&a.if((0,t._)`${c}.length > 0`,f)):(a.let(y,!1),f()),s.result(y,()=>s.reset());function f(){const m=a.name("_valid"),b=a.let("count",0);w(m,()=>a.if(m,()=>d(b)))}function w(m,b){a.forRange("i",0,p,v=>{s.subschema({keyword:"contains",dataProp:v,dataPropType:e.Type.Num,compositeRule:!0},m),b()})}function d(m){a.code((0,t._)`${m}++`),h===void 0?a.if((0,t._)`${m} >= ${l}`,()=>a.assign(y,!0).break()):(a.if((0,t._)`${m} > ${h}`,()=>a.assign(y,!1).break()),l===1?a.assign(y,!0):a.if((0,t._)`${m} >= ${l}`,()=>a.assign(y,!0)))}}};return Nn.default=n,Nn}var ra={},Jo;function Ef(){return Jo||(Jo=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const e=ae(),r=de(),n=ut();t.error={message:({params:{property:c,depsCount:u,deps:l}})=>{const h=u===1?"property":"properties";return(0,e.str)`must have ${h} ${l} when property ${c} is present`},params:({params:{property:c,depsCount:u,deps:l,missingProperty:h}})=>(0,e._)`{property: ${c},
6
- missingProperty: ${h},
1
+ (function($,Xt){typeof exports=="object"&&typeof module<"u"?Xt(exports):typeof define=="function"&&define.amd?define(["exports"],Xt):($=typeof globalThis<"u"?globalThis:$||self,Xt($.MCPSDK={}))})(this,(function($){"use strict";function Xt(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var rn={exports:{}},Hs={},yt={},Zt={},Ws={},Ks={},Js={},Bi;function nn(){return Bi||(Bi=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(p){if(super(),!t.IDENTIFIER.test(p))throw new Error("CodeGen: name must be a valid identifier");this.str=p}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}t.Name=r;class n extends e{constructor(p){super(),this._items=typeof p=="string"?[p]:p}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const p=this._items[0];return p===""||p==='""'}get str(){var p;return(p=this._str)!==null&&p!==void 0?p:this._str=this._items.reduce((y,R)=>`${y}${R}`,"")}get names(){var p;return(p=this._names)!==null&&p!==void 0?p:this._names=this._items.reduce((y,R)=>(R instanceof r&&(y[R.str]=(y[R.str]||0)+1),y),{})}}t._Code=n,t.nil=new n("");function s(S,...p){const y=[S[0]];let R=0;for(;R<p.length;)o(y,p[R]),y.push(S[++R]);return new n(y)}t._=s;const a=new n("+");function i(S,...p){const y=[v(S[0])];let R=0;for(;R<p.length;)y.push(a),o(y,p[R]),y.push(a,v(S[++R]));return c(y),new n(y)}t.str=i;function o(S,p){p instanceof n?S.push(...p._items):p instanceof r?S.push(p):S.push(f(p))}t.addCodeArg=o;function c(S){let p=1;for(;p<S.length-1;){if(S[p]===a){const y=u(S[p-1],S[p+1]);if(y!==void 0){S.splice(p-1,3,y);continue}S[p++]="+"}p++}}function u(S,p){if(p==='""')return S;if(S==='""')return p;if(typeof S=="string")return p instanceof r||S[S.length-1]!=='"'?void 0:typeof p!="string"?`${S.slice(0,-1)}${p}"`:p[0]==='"'?S.slice(0,-1)+p.slice(1):void 0;if(typeof p=="string"&&p[0]==='"'&&!(S instanceof r))return`"${S}${p.slice(1)}`}function l(S,p){return p.emptyStr()?S:S.emptyStr()?p:i`${S}${p}`}t.strConcat=l;function f(S){return typeof S=="number"||typeof S=="boolean"||S===null?S:v(Array.isArray(S)?S.join(","):S)}function b(S){return new n(v(S))}t.stringify=b;function v(S){return JSON.stringify(S).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}t.safeStringify=v;function g(S){return typeof S=="string"&&t.IDENTIFIER.test(S)?new n(`.${S}`):s`[${S}]`}t.getProperty=g;function w(S){if(typeof S=="string"&&t.IDENTIFIER.test(S))return new n(`${S}`);throw new Error(`CodeGen: invalid export name: ${S}, use explicit $id name mapping`)}t.getEsmExportName=w;function m(S){return new n(S.toString())}t.regexpCode=m})(Js)),Js}var Bs={},Gi;function Yi(){return Gi||(Gi=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.ValueScope=t.ValueScopeName=t.Scope=t.varKinds=t.UsedValueState=void 0;const e=nn();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,f;if(!((f=(l=this._parent)===null||l===void 0?void 0:l._prefixes)===null||f===void 0)&&f.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 a extends e.Name{constructor(u,l){super(l),this.prefix=u}setValue(u,{property:l,itemIndex:f}){this.value=u,this.scopePath=(0,e._)`.${new e.Name(l)}[${f}]`}}t.ValueScopeName=a;const i=(0,e._)`\n`;class o 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 a(u,this._newName(u))}value(u,l){var f;if(l.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const b=this.toName(u),{prefix:v}=b,g=(f=l.key)!==null&&f!==void 0?f:l.ref;let w=this._values[v];if(w){const p=w.get(g);if(p)return p}else w=this._values[v]=new Map;w.set(g,b);const m=this._scope[v]||(this._scope[v]=[]),S=m.length;return m[S]=l.ref,b.setValue(l,{property:v,itemIndex:S}),b}getValue(u,l){const f=this._values[u];if(f)return f.get(l)}scopeRefs(u,l=this._values){return this._reduceValues(l,f=>{if(f.scopePath===void 0)throw new Error(`CodeGen: name "${f}" has no value`);return(0,e._)`${u}${f.scopePath}`})}scopeCode(u=this._values,l,f){return this._reduceValues(u,b=>{if(b.value===void 0)throw new Error(`CodeGen: name "${b}" has no value`);return b.value.code},l,f)}_reduceValues(u,l,f={},b){let v=e.nil;for(const g in u){const w=u[g];if(!w)continue;const m=f[g]=f[g]||new Map;w.forEach(S=>{if(m.has(S))return;m.set(S,n.Started);let p=l(S);if(p){const y=this.opts.es5?t.varKinds.var:t.varKinds.const;v=(0,e._)`${v}${y} ${S} = ${p};${this.opts._n}`}else if(p=b?.(S))v=(0,e._)`${v}${p}${this.opts._n}`;else throw new r(S);m.set(S,n.Completed)})}return v}}t.ValueScope=o})(Bs)),Bs}var Qi;function ie(){return Qi||(Qi=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=nn(),r=Yi();var n=nn();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=Yi();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(k,P){return this}}class i extends a{constructor(k,P,Z){super(),this.varKind=k,this.name=P,this.rhs=Z}render({es5:k,_n:P}){const Z=k?r.varKinds.var:this.varKind,ee=this.rhs===void 0?"":` = ${this.rhs}`;return`${Z} ${this.name}${ee};`+P}optimizeNames(k,P){if(k[this.name.str])return this.rhs&&(this.rhs=D(this.rhs,k,P)),this}get names(){return this.rhs instanceof e._CodeOrName?this.rhs.names:{}}}class o extends a{constructor(k,P,Z){super(),this.lhs=k,this.rhs=P,this.sideEffects=Z}render({_n:k}){return`${this.lhs} = ${this.rhs};`+k}optimizeNames(k,P){if(!(this.lhs instanceof e.Name&&!k[this.lhs.str]&&!this.sideEffects))return this.rhs=D(this.rhs,k,P),this}get names(){const k=this.lhs instanceof e.Name?{}:{...this.lhs.names};return F(k,this.rhs)}}class c extends o{constructor(k,P,Z,ee){super(k,Z,ee),this.op=P}render({_n:k}){return`${this.lhs} ${this.op}= ${this.rhs};`+k}}class u extends a{constructor(k){super(),this.label=k,this.names={}}render({_n:k}){return`${this.label}:`+k}}class l extends a{constructor(k){super(),this.label=k,this.names={}}render({_n:k}){return`break${this.label?` ${this.label}`:""};`+k}}class f extends a{constructor(k){super(),this.error=k}render({_n:k}){return`throw ${this.error};`+k}get names(){return this.error.names}}class b extends a{constructor(k){super(),this.code=k}render({_n:k}){return`${this.code};`+k}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(k,P){return this.code=D(this.code,k,P),this}get names(){return this.code instanceof e._CodeOrName?this.code.names:{}}}class v extends a{constructor(k=[]){super(),this.nodes=k}render(k){return this.nodes.reduce((P,Z)=>P+Z.render(k),"")}optimizeNodes(){const{nodes:k}=this;let P=k.length;for(;P--;){const Z=k[P].optimizeNodes();Array.isArray(Z)?k.splice(P,1,...Z):Z?k[P]=Z:k.splice(P,1)}return k.length>0?this:void 0}optimizeNames(k,P){const{nodes:Z}=this;let ee=Z.length;for(;ee--;){const ne=Z[ee];ne.optimizeNames(k,P)||(ae(k,ne.names),Z.splice(ee,1))}return Z.length>0?this:void 0}get names(){return this.nodes.reduce((k,P)=>M(k,P.names),{})}}class g extends v{render(k){return"{"+k._n+super.render(k)+"}"+k._n}}class w extends v{}class m extends g{}m.kind="else";class S extends g{constructor(k,P){super(P),this.condition=k}render(k){let P=`if(${this.condition})`+super.render(k);return this.else&&(P+="else "+this.else.render(k)),P}optimizeNodes(){super.optimizeNodes();const k=this.condition;if(k===!0)return this.nodes;let P=this.else;if(P){const Z=P.optimizeNodes();P=this.else=Array.isArray(Z)?new m(Z):Z}if(P)return k===!1?P instanceof S?P:P.nodes:this.nodes.length?this:new S($e(k),P instanceof S?[P]:P.nodes);if(!(k===!1||!this.nodes.length))return this}optimizeNames(k,P){var Z;if(this.else=(Z=this.else)===null||Z===void 0?void 0:Z.optimizeNames(k,P),!!(super.optimizeNames(k,P)||this.else))return this.condition=D(this.condition,k,P),this}get names(){const k=super.names;return F(k,this.condition),this.else&&M(k,this.else.names),k}}S.kind="if";class p extends g{}p.kind="for";class y extends p{constructor(k){super(),this.iteration=k}render(k){return`for(${this.iteration})`+super.render(k)}optimizeNames(k,P){if(super.optimizeNames(k,P))return this.iteration=D(this.iteration,k,P),this}get names(){return M(super.names,this.iteration.names)}}class R extends p{constructor(k,P,Z,ee){super(),this.varKind=k,this.name=P,this.from=Z,this.to=ee}render(k){const P=k.es5?r.varKinds.var:this.varKind,{name:Z,from:ee,to:ne}=this;return`for(${P} ${Z}=${ee}; ${Z}<${ne}; ${Z}++)`+super.render(k)}get names(){const k=F(super.names,this.from);return F(k,this.to)}}class d extends p{constructor(k,P,Z,ee){super(),this.loop=k,this.varKind=P,this.name=Z,this.iterable=ee}render(k){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(k)}optimizeNames(k,P){if(super.optimizeNames(k,P))return this.iterable=D(this.iterable,k,P),this}get names(){return M(super.names,this.iterable.names)}}class h extends g{constructor(k,P,Z){super(),this.name=k,this.args=P,this.async=Z}render(k){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(k)}}h.kind="func";class _ extends v{render(k){return"return "+super.render(k)}}_.kind="return";class E extends g{render(k){let P="try"+super.render(k);return this.catch&&(P+=this.catch.render(k)),this.finally&&(P+=this.finally.render(k)),P}optimizeNodes(){var k,P;return super.optimizeNodes(),(k=this.catch)===null||k===void 0||k.optimizeNodes(),(P=this.finally)===null||P===void 0||P.optimizeNodes(),this}optimizeNames(k,P){var Z,ee;return super.optimizeNames(k,P),(Z=this.catch)===null||Z===void 0||Z.optimizeNames(k,P),(ee=this.finally)===null||ee===void 0||ee.optimizeNames(k,P),this}get names(){const k=super.names;return this.catch&&M(k,this.catch.names),this.finally&&M(k,this.finally.names),k}}class I extends g{constructor(k){super(),this.error=k}render(k){return`catch(${this.error})`+super.render(k)}}I.kind="catch";class j extends g{render(k){return"finally"+super.render(k)}}j.kind="finally";class C{constructor(k,P={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...P,_n:P.lines?`
2
+ `:""},this._extScope=k,this._scope=new r.Scope({parent:k}),this._nodes=[new w]}toString(){return this._root.render(this.opts)}name(k){return this._scope.name(k)}scopeName(k){return this._extScope.name(k)}scopeValue(k,P){const Z=this._extScope.value(k,P);return(this._values[Z.prefix]||(this._values[Z.prefix]=new Set)).add(Z),Z}getScopeValue(k,P){return this._extScope.getValue(k,P)}scopeRefs(k){return this._extScope.scopeRefs(k,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(k,P,Z,ee){const ne=this._scope.toName(P);return Z!==void 0&&ee&&(this._constants[ne.str]=Z),this._leafNode(new i(k,ne,Z)),ne}const(k,P,Z){return this._def(r.varKinds.const,k,P,Z)}let(k,P,Z){return this._def(r.varKinds.let,k,P,Z)}var(k,P,Z){return this._def(r.varKinds.var,k,P,Z)}assign(k,P,Z){return this._leafNode(new o(k,P,Z))}add(k,P){return this._leafNode(new c(k,t.operators.ADD,P))}code(k){return typeof k=="function"?k():k!==e.nil&&this._leafNode(new b(k)),this}object(...k){const P=["{"];for(const[Z,ee]of k)P.length>1&&P.push(","),P.push(Z),(Z!==ee||this.opts.es5)&&(P.push(":"),(0,e.addCodeArg)(P,ee));return P.push("}"),new e._Code(P)}if(k,P,Z){if(this._blockNode(new S(k)),P&&Z)this.code(P).else().code(Z).endIf();else if(P)this.code(P).endIf();else if(Z)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(k){return this._elseNode(new S(k))}else(){return this._elseNode(new m)}endIf(){return this._endBlockNode(S,m)}_for(k,P){return this._blockNode(k),P&&this.code(P).endFor(),this}for(k,P){return this._for(new y(k),P)}forRange(k,P,Z,ee,ne=this.opts.es5?r.varKinds.var:r.varKinds.let){const _e=this._scope.toName(k);return this._for(new R(ne,_e,P,Z),()=>ee(_e))}forOf(k,P,Z,ee=r.varKinds.const){const ne=this._scope.toName(k);if(this.opts.es5){const _e=P instanceof e.Name?P:this.var("_arr",P);return this.forRange("_i",0,(0,e._)`${_e}.length`,de=>{this.var(ne,(0,e._)`${_e}[${de}]`),Z(ne)})}return this._for(new d("of",ee,ne,P),()=>Z(ne))}forIn(k,P,Z,ee=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(k,(0,e._)`Object.keys(${P})`,Z);const ne=this._scope.toName(k);return this._for(new d("in",ee,ne,P),()=>Z(ne))}endFor(){return this._endBlockNode(p)}label(k){return this._leafNode(new u(k))}break(k){return this._leafNode(new l(k))}return(k){const P=new _;if(this._blockNode(P),this.code(k),P.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(_)}try(k,P,Z){if(!P&&!Z)throw new Error('CodeGen: "try" without "catch" and "finally"');const ee=new E;if(this._blockNode(ee),this.code(k),P){const ne=this.name("e");this._currNode=ee.catch=new I(ne),P(ne)}return Z&&(this._currNode=ee.finally=new j,this.code(Z)),this._endBlockNode(I,j)}throw(k){return this._leafNode(new f(k))}block(k,P){return this._blockStarts.push(this._nodes.length),k&&this.code(k).endBlock(P),this}endBlock(k){const P=this._blockStarts.pop();if(P===void 0)throw new Error("CodeGen: not in self-balancing block");const Z=this._nodes.length-P;if(Z<0||k!==void 0&&Z!==k)throw new Error(`CodeGen: wrong number of nodes: ${Z} vs ${k} expected`);return this._nodes.length=P,this}func(k,P=e.nil,Z,ee){return this._blockNode(new h(k,P,Z)),ee&&this.code(ee).endFunc(),this}endFunc(){return this._endBlockNode(h)}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,P){const Z=this._currNode;if(Z instanceof k||P&&Z instanceof P)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${P?`${k.kind}/${P.kind}`:k.kind}"`)}_elseNode(k){const P=this._currNode;if(!(P instanceof S))throw new Error('CodeGen: "else" without "if"');return this._currNode=P.else=k,this}get _root(){return this._nodes[0]}get _currNode(){const k=this._nodes;return k[k.length-1]}set _currNode(k){const P=this._nodes;P[P.length-1]=k}}t.CodeGen=C;function M(z,k){for(const P in k)z[P]=(z[P]||0)+(k[P]||0);return z}function F(z,k){return k instanceof e._CodeOrName?M(z,k.names):z}function D(z,k,P){if(z instanceof e.Name)return Z(z);if(!ee(z))return z;return new e._Code(z._items.reduce((ne,_e)=>(_e instanceof e.Name&&(_e=Z(_e)),_e instanceof e._Code?ne.push(..._e._items):ne.push(_e),ne),[]));function Z(ne){const _e=P[ne.str];return _e===void 0||k[ne.str]!==1?ne:(delete k[ne.str],_e)}function ee(ne){return ne instanceof e._Code&&ne._items.some(_e=>_e instanceof e.Name&&k[_e.str]===1&&P[_e.str]!==void 0)}}function ae(z,k){for(const P in k)z[P]=(z[P]||0)-(k[P]||0)}function $e(z){return typeof z=="boolean"||typeof z=="number"||z===null?!z:(0,e._)`!${L(z)}`}t.not=$e;const xe=N(t.operators.AND);function ge(...z){return z.reduce(xe)}t.and=ge;const mt=N(t.operators.OR);function H(...z){return z.reduce(mt)}t.or=H;function N(z){return(k,P)=>k===e.nil?P:P===e.nil?k:(0,e._)`${L(k)} ${z} ${L(P)}`}function L(z){return z instanceof e.Name?z:(0,e._)`(${z})`}})(Ks)),Ks}var oe={},Xi;function fe(){if(Xi)return oe;Xi=1,Object.defineProperty(oe,"__esModule",{value:!0}),oe.checkStrictMode=oe.getErrorPath=oe.Type=oe.useFunc=oe.setEvaluated=oe.evaluatedPropsToName=oe.mergeEvaluated=oe.eachItem=oe.unescapeJsonPointer=oe.escapeJsonPointer=oe.escapeFragment=oe.unescapeFragment=oe.schemaRefOrVal=oe.schemaHasRulesButRef=oe.schemaHasRules=oe.checkUnknownRules=oe.alwaysValidSchema=oe.toHash=void 0;const t=ie(),e=nn();function r(d){const h={};for(const _ of d)h[_]=!0;return h}oe.toHash=r;function n(d,h){return typeof h=="boolean"?h:Object.keys(h).length===0?!0:(s(d,h),!a(h,d.self.RULES.all))}oe.alwaysValidSchema=n;function s(d,h=d.schema){const{opts:_,self:E}=d;if(!_.strictSchema||typeof h=="boolean")return;const I=E.RULES.keywords;for(const j in h)I[j]||R(d,`unknown keyword: "${j}"`)}oe.checkUnknownRules=s;function a(d,h){if(typeof d=="boolean")return!d;for(const _ in d)if(h[_])return!0;return!1}oe.schemaHasRules=a;function i(d,h){if(typeof d=="boolean")return!d;for(const _ in d)if(_!=="$ref"&&h.all[_])return!0;return!1}oe.schemaHasRulesButRef=i;function o({topSchemaRef:d,schemaPath:h},_,E,I){if(!I){if(typeof _=="number"||typeof _=="boolean")return _;if(typeof _=="string")return(0,t._)`${_}`}return(0,t._)`${d}${h}${(0,t.getProperty)(E)}`}oe.schemaRefOrVal=o;function c(d){return f(decodeURIComponent(d))}oe.unescapeFragment=c;function u(d){return encodeURIComponent(l(d))}oe.escapeFragment=u;function l(d){return typeof d=="number"?`${d}`:d.replace(/~/g,"~0").replace(/\//g,"~1")}oe.escapeJsonPointer=l;function f(d){return d.replace(/~1/g,"/").replace(/~0/g,"~")}oe.unescapeJsonPointer=f;function b(d,h){if(Array.isArray(d))for(const _ of d)h(_);else h(d)}oe.eachItem=b;function v({mergeNames:d,mergeToName:h,mergeValues:_,resultToName:E}){return(I,j,C,M)=>{const F=C===void 0?j:C instanceof t.Name?(j instanceof t.Name?d(I,j,C):h(I,j,C),C):j instanceof t.Name?(h(I,C,j),j):_(j,C);return M===t.Name&&!(F instanceof t.Name)?E(I,F):F}}oe.mergeEvaluated={props:v({mergeNames:(d,h,_)=>d.if((0,t._)`${_} !== true && ${h} !== undefined`,()=>{d.if((0,t._)`${h} === true`,()=>d.assign(_,!0),()=>d.assign(_,(0,t._)`${_} || {}`).code((0,t._)`Object.assign(${_}, ${h})`))}),mergeToName:(d,h,_)=>d.if((0,t._)`${_} !== true`,()=>{h===!0?d.assign(_,!0):(d.assign(_,(0,t._)`${_} || {}`),w(d,_,h))}),mergeValues:(d,h)=>d===!0?!0:{...d,...h},resultToName:g}),items:v({mergeNames:(d,h,_)=>d.if((0,t._)`${_} !== true && ${h} !== undefined`,()=>d.assign(_,(0,t._)`${h} === true ? true : ${_} > ${h} ? ${_} : ${h}`)),mergeToName:(d,h,_)=>d.if((0,t._)`${_} !== true`,()=>d.assign(_,h===!0?!0:(0,t._)`${_} > ${h} ? ${_} : ${h}`)),mergeValues:(d,h)=>d===!0?!0:Math.max(d,h),resultToName:(d,h)=>d.var("items",h)})};function g(d,h){if(h===!0)return d.var("props",!0);const _=d.var("props",(0,t._)`{}`);return h!==void 0&&w(d,_,h),_}oe.evaluatedPropsToName=g;function w(d,h,_){Object.keys(_).forEach(E=>d.assign((0,t._)`${h}${(0,t.getProperty)(E)}`,!0))}oe.setEvaluated=w;const m={};function S(d,h){return d.scopeValue("func",{ref:h,code:m[h.code]||(m[h.code]=new e._Code(h.code))})}oe.useFunc=S;var p;(function(d){d[d.Num=0]="Num",d[d.Str=1]="Str"})(p||(oe.Type=p={}));function y(d,h,_){if(d instanceof t.Name){const E=h===p.Num;return _?E?(0,t._)`"[" + ${d} + "]"`:(0,t._)`"['" + ${d} + "']"`:E?(0,t._)`"/" + ${d}`:(0,t._)`"/" + ${d}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return _?(0,t.getProperty)(d).toString():"/"+l(d)}oe.getErrorPath=y;function R(d,h,_=d.opts.strictSchema){if(_){if(h=`strict mode: ${h}`,_===!0)throw new Error(h);d.self.logger.warn(h)}}return oe.checkStrictMode=R,oe}var sn={},eo;function Et(){if(eo)return sn;eo=1,Object.defineProperty(sn,"__esModule",{value:!0});const t=ie(),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 sn.default=e,sn}var to;function an(){return to||(to=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=ie(),r=fe(),n=Et();t.keywordError={message:({keyword:m})=>(0,e.str)`must pass "${m}" keyword validation`},t.keyword$DataError={message:({keyword:m,schemaType:S})=>S?(0,e.str)`"${m}" keyword must be ${S} ($data)`:(0,e.str)`"${m}" keyword is invalid ($data)`};function s(m,S=t.keywordError,p,y){const{it:R}=m,{gen:d,compositeRule:h,allErrors:_}=R,E=f(m,S,p);y??(h||_)?c(d,E):u(R,(0,e._)`[${E}]`)}t.reportError=s;function a(m,S=t.keywordError,p){const{it:y}=m,{gen:R,compositeRule:d,allErrors:h}=y,_=f(m,S,p);c(R,_),d||h||u(y,n.default.vErrors)}t.reportExtraError=a;function i(m,S){m.assign(n.default.errors,S),m.if((0,e._)`${n.default.vErrors} !== null`,()=>m.if(S,()=>m.assign((0,e._)`${n.default.vErrors}.length`,S),()=>m.assign(n.default.vErrors,null)))}t.resetErrorsCount=i;function o({gen:m,keyword:S,schemaValue:p,data:y,errsCount:R,it:d}){if(R===void 0)throw new Error("ajv implementation error");const h=m.name("err");m.forRange("i",R,n.default.errors,_=>{m.const(h,(0,e._)`${n.default.vErrors}[${_}]`),m.if((0,e._)`${h}.instancePath === undefined`,()=>m.assign((0,e._)`${h}.instancePath`,(0,e.strConcat)(n.default.instancePath,d.errorPath))),m.assign((0,e._)`${h}.schemaPath`,(0,e.str)`${d.errSchemaPath}/${S}`),d.opts.verbose&&(m.assign((0,e._)`${h}.schema`,p),m.assign((0,e._)`${h}.data`,y))})}t.extendErrors=o;function c(m,S){const p=m.const("err",S);m.if((0,e._)`${n.default.vErrors} === null`,()=>m.assign(n.default.vErrors,(0,e._)`[${p}]`),(0,e._)`${n.default.vErrors}.push(${p})`),m.code((0,e._)`${n.default.errors}++`)}function u(m,S){const{gen:p,validateName:y,schemaEnv:R}=m;R.$async?p.throw((0,e._)`new ${m.ValidationError}(${S})`):(p.assign((0,e._)`${y}.errors`,S),p.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 f(m,S,p){const{createErrors:y}=m.it;return y===!1?(0,e._)`{}`:b(m,S,p)}function b(m,S,p={}){const{gen:y,it:R}=m,d=[v(R,p),g(m,p)];return w(m,S,d),y.object(...d)}function v({errorPath:m},{instancePath:S}){const p=S?(0,e.str)`${m}${(0,r.getErrorPath)(S,r.Type.Str)}`:m;return[n.default.instancePath,(0,e.strConcat)(n.default.instancePath,p)]}function g({keyword:m,it:{errSchemaPath:S}},{schemaPath:p,parentSchema:y}){let R=y?S:(0,e.str)`${S}/${m}`;return p&&(R=(0,e.str)`${R}${(0,r.getErrorPath)(p,r.Type.Str)}`),[l.schemaPath,R]}function w(m,{params:S,message:p},y){const{keyword:R,data:d,schemaValue:h,it:_}=m,{opts:E,propertyName:I,topSchemaRef:j,schemaPath:C}=_;y.push([l.keyword,R],[l.params,typeof S=="function"?S(m):S||(0,e._)`{}`]),E.messages&&y.push([l.message,typeof p=="function"?p(m):p]),E.verbose&&y.push([l.schema,h],[l.parentSchema,(0,e._)`${j}${C}`],[n.default.data,d]),I&&y.push([l.propertyName,I])}})(Ws)),Ws}var ro;function ef(){if(ro)return Zt;ro=1,Object.defineProperty(Zt,"__esModule",{value:!0}),Zt.boolOrEmptySchema=Zt.topBoolOrEmptySchema=void 0;const t=an(),e=ie(),r=Et(),n={message:"boolean schema is false"};function s(o){const{gen:c,schema:u,validateName:l}=o;u===!1?i(o,!1):typeof u=="object"&&u.$async===!0?c.return(r.default.data):(c.assign((0,e._)`${l}.errors`,null),c.return(!0))}Zt.topBoolOrEmptySchema=s;function a(o,c){const{gen:u,schema:l}=o;l===!1?(u.var(c,!1),i(o)):u.var(c,!0)}Zt.boolOrEmptySchema=a;function i(o,c){const{gen:u,data:l}=o,f={gen:u,keyword:"false schema",data:l,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:o};(0,t.reportError)(f,n,void 0,c)}return Zt}var Le={},xt={},no;function so(){if(no)return xt;no=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 vt={},ao;function io(){if(ao)return vt;ao=1,Object.defineProperty(vt,"__esModule",{value:!0}),vt.shouldUseRule=vt.shouldUseGroup=vt.schemaHasRulesForType=void 0;function t({schema:n,self:s},a){const i=s.RULES.types[a];return i&&i!==!0&&e(n,i)}vt.schemaHasRulesForType=t;function e(n,s){return s.rules.some(a=>r(n,a))}vt.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 vt.shouldUseRule=r,vt}var oo;function on(){if(oo)return Le;oo=1,Object.defineProperty(Le,"__esModule",{value:!0}),Le.reportTypeError=Le.checkDataTypes=Le.checkDataType=Le.coerceAndCheckDataType=Le.getJSONTypes=Le.getSchemaTypes=Le.DataType=void 0;const t=so(),e=io(),r=an(),n=ie(),s=fe();var a;(function(p){p[p.Correct=0]="Correct",p[p.Wrong=1]="Wrong"})(a||(Le.DataType=a={}));function i(p){const y=o(p.type);if(y.includes("null")){if(p.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!y.length&&p.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');p.nullable===!0&&y.push("null")}return y}Le.getSchemaTypes=i;function o(p){const y=Array.isArray(p)?p:p?[p]:[];if(y.every(t.isJSONType))return y;throw new Error("type must be JSONType or JSONType[]: "+y.join(","))}Le.getJSONTypes=o;function c(p,y){const{gen:R,data:d,opts:h}=p,_=l(y,h.coerceTypes),E=y.length>0&&!(_.length===0&&y.length===1&&(0,e.schemaHasRulesForType)(p,y[0]));if(E){const I=g(y,d,h.strictNumbers,a.Wrong);R.if(I,()=>{_.length?f(p,y,_):m(p)})}return E}Le.coerceAndCheckDataType=c;const u=new Set(["string","number","integer","boolean","null"]);function l(p,y){return y?p.filter(R=>u.has(R)||y==="array"&&R==="array"):[]}function f(p,y,R){const{gen:d,data:h,opts:_}=p,E=d.let("dataType",(0,n._)`typeof ${h}`),I=d.let("coerced",(0,n._)`undefined`);_.coerceTypes==="array"&&d.if((0,n._)`${E} == 'object' && Array.isArray(${h}) && ${h}.length == 1`,()=>d.assign(h,(0,n._)`${h}[0]`).assign(E,(0,n._)`typeof ${h}`).if(g(y,h,_.strictNumbers),()=>d.assign(I,h))),d.if((0,n._)`${I} !== undefined`);for(const C of R)(u.has(C)||C==="array"&&_.coerceTypes==="array")&&j(C);d.else(),m(p),d.endIf(),d.if((0,n._)`${I} !== undefined`,()=>{d.assign(h,I),b(p,I)});function j(C){switch(C){case"string":d.elseIf((0,n._)`${E} == "number" || ${E} == "boolean"`).assign(I,(0,n._)`"" + ${h}`).elseIf((0,n._)`${h} === null`).assign(I,(0,n._)`""`);return;case"number":d.elseIf((0,n._)`${E} == "boolean" || ${h} === null
3
+ || (${E} == "string" && ${h} && ${h} == +${h})`).assign(I,(0,n._)`+${h}`);return;case"integer":d.elseIf((0,n._)`${E} === "boolean" || ${h} === null
4
+ || (${E} === "string" && ${h} && ${h} == +${h} && !(${h} % 1))`).assign(I,(0,n._)`+${h}`);return;case"boolean":d.elseIf((0,n._)`${h} === "false" || ${h} === 0 || ${h} === null`).assign(I,!1).elseIf((0,n._)`${h} === "true" || ${h} === 1`).assign(I,!0);return;case"null":d.elseIf((0,n._)`${h} === "" || ${h} === 0 || ${h} === false`),d.assign(I,null);return;case"array":d.elseIf((0,n._)`${E} === "string" || ${E} === "number"
5
+ || ${E} === "boolean" || ${h} === null`).assign(I,(0,n._)`[${h}]`)}}}function b({gen:p,parentData:y,parentDataProperty:R},d){p.if((0,n._)`${y} !== undefined`,()=>p.assign((0,n._)`${y}[${R}]`,d))}function v(p,y,R,d=a.Correct){const h=d===a.Correct?n.operators.EQ:n.operators.NEQ;let _;switch(p){case"null":return(0,n._)`${y} ${h} null`;case"array":_=(0,n._)`Array.isArray(${y})`;break;case"object":_=(0,n._)`${y} && typeof ${y} == "object" && !Array.isArray(${y})`;break;case"integer":_=E((0,n._)`!(${y} % 1) && !isNaN(${y})`);break;case"number":_=E();break;default:return(0,n._)`typeof ${y} ${h} ${p}`}return d===a.Correct?_:(0,n.not)(_);function E(I=n.nil){return(0,n.and)((0,n._)`typeof ${y} == "number"`,I,R?(0,n._)`isFinite(${y})`:n.nil)}}Le.checkDataType=v;function g(p,y,R,d){if(p.length===1)return v(p[0],y,R,d);let h;const _=(0,s.toHash)(p);if(_.array&&_.object){const E=(0,n._)`typeof ${y} != "object"`;h=_.null?E:(0,n._)`!${y} || ${E}`,delete _.null,delete _.array,delete _.object}else h=n.nil;_.number&&delete _.integer;for(const E in _)h=(0,n.and)(h,v(E,y,R,d));return h}Le.checkDataTypes=g;const w={message:({schema:p})=>`must be ${p}`,params:({schema:p,schemaValue:y})=>typeof p=="string"?(0,n._)`{type: ${p}}`:(0,n._)`{type: ${y}}`};function m(p){const y=S(p);(0,r.reportError)(y,w)}Le.reportTypeError=m;function S(p){const{gen:y,data:R,schema:d}=p,h=(0,s.schemaRefOrVal)(p,d,"type");return{gen:y,keyword:"type",data:R,schema:d.type,schemaCode:h,schemaValue:h,parentSchema:d,params:{},it:p}}return Le}var $r={},co;function tf(){if(co)return $r;co=1,Object.defineProperty($r,"__esModule",{value:!0}),$r.assignDefaults=void 0;const t=ie(),e=fe();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,u)=>n(s,u,c.default))}$r.assignDefaults=r;function n(s,a,i){const{gen:o,compositeRule:c,data:u,opts:l}=s;if(i===void 0)return;const f=(0,t._)`${u}${(0,t.getProperty)(a)}`;if(c){(0,e.checkStrictMode)(s,`default is ignored for: ${f}`);return}let b=(0,t._)`${f} === undefined`;l.useDefaults==="empty"&&(b=(0,t._)`${b} || ${f} === null || ${f} === ""`),o.if(b,(0,t._)`${f} = ${(0,t.stringify)(i)}`)}return $r}var ct={},ve={},uo;function ut(){if(uo)return ve;uo=1,Object.defineProperty(ve,"__esModule",{value:!0}),ve.validateUnion=ve.validateArray=ve.usePattern=ve.callValidateCode=ve.schemaProperties=ve.allSchemaProperties=ve.noPropertyInData=ve.propertyInData=ve.isOwnProperty=ve.hasPropFunc=ve.reportMissingProp=ve.checkMissingProp=ve.checkReportMissingProp=void 0;const t=ie(),e=fe(),r=Et(),n=fe();function s(p,y){const{gen:R,data:d,it:h}=p;R.if(l(R,d,y,h.opts.ownProperties),()=>{p.setParams({missingProperty:(0,t._)`${y}`},!0),p.error()})}ve.checkReportMissingProp=s;function a({gen:p,data:y,it:{opts:R}},d,h){return(0,t.or)(...d.map(_=>(0,t.and)(l(p,y,_,R.ownProperties),(0,t._)`${h} = ${_}`)))}ve.checkMissingProp=a;function i(p,y){p.setParams({missingProperty:y},!0),p.error()}ve.reportMissingProp=i;function o(p){return p.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}ve.hasPropFunc=o;function c(p,y,R){return(0,t._)`${o(p)}.call(${y}, ${R})`}ve.isOwnProperty=c;function u(p,y,R,d){const h=(0,t._)`${y}${(0,t.getProperty)(R)} !== undefined`;return d?(0,t._)`${h} && ${c(p,y,R)}`:h}ve.propertyInData=u;function l(p,y,R,d){const h=(0,t._)`${y}${(0,t.getProperty)(R)} === undefined`;return d?(0,t.or)(h,(0,t.not)(c(p,y,R))):h}ve.noPropertyInData=l;function f(p){return p?Object.keys(p).filter(y=>y!=="__proto__"):[]}ve.allSchemaProperties=f;function b(p,y){return f(y).filter(R=>!(0,e.alwaysValidSchema)(p,y[R]))}ve.schemaProperties=b;function v({schemaCode:p,data:y,it:{gen:R,topSchemaRef:d,schemaPath:h,errorPath:_},it:E},I,j,C){const M=C?(0,t._)`${p}, ${y}, ${d}${h}`:y,F=[[r.default.instancePath,(0,t.strConcat)(r.default.instancePath,_)],[r.default.parentData,E.parentData],[r.default.parentDataProperty,E.parentDataProperty],[r.default.rootData,r.default.rootData]];E.opts.dynamicRef&&F.push([r.default.dynamicAnchors,r.default.dynamicAnchors]);const D=(0,t._)`${M}, ${R.object(...F)}`;return j!==t.nil?(0,t._)`${I}.call(${j}, ${D})`:(0,t._)`${I}(${D})`}ve.callValidateCode=v;const g=(0,t._)`new RegExp`;function w({gen:p,it:{opts:y}},R){const d=y.unicodeRegExp?"u":"",{regExp:h}=y.code,_=h(R,d);return p.scopeValue("pattern",{key:_.toString(),ref:_,code:(0,t._)`${h.code==="new RegExp"?g:(0,n.useFunc)(p,h)}(${R}, ${d})`})}ve.usePattern=w;function m(p){const{gen:y,data:R,keyword:d,it:h}=p,_=y.name("valid");if(h.allErrors){const I=y.let("valid",!0);return E(()=>y.assign(I,!1)),I}return y.var(_,!0),E(()=>y.break()),_;function E(I){const j=y.const("len",(0,t._)`${R}.length`);y.forRange("i",0,j,C=>{p.subschema({keyword:d,dataProp:C,dataPropType:e.Type.Num},_),y.if((0,t.not)(_),I)})}}ve.validateArray=m;function S(p){const{gen:y,schema:R,keyword:d,it:h}=p;if(!Array.isArray(R))throw new Error("ajv implementation error");if(R.some(j=>(0,e.alwaysValidSchema)(h,j))&&!h.opts.unevaluated)return;const E=y.let("valid",!1),I=y.name("_valid");y.block(()=>R.forEach((j,C)=>{const M=p.subschema({keyword:d,schemaProp:C,compositeRule:!0},I);y.assign(E,(0,t._)`${E} || ${I}`),p.mergeValidEvaluated(M,I)||y.if((0,t.not)(E))})),p.result(E,()=>p.reset(),()=>p.error(!0))}return ve.validateUnion=S,ve}var lo;function rf(){if(lo)return ct;lo=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.validateKeywordUsage=ct.validSchemaType=ct.funcKeywordCode=ct.macroKeywordCode=void 0;const t=ie(),e=Et(),r=ut(),n=an();function s(b,v){const{gen:g,keyword:w,schema:m,parentSchema:S,it:p}=b,y=v.macro.call(p.self,m,S,p),R=u(g,w,y);p.opts.validateSchema!==!1&&p.self.validateSchema(y,!0);const d=g.name("valid");b.subschema({schema:y,schemaPath:t.nil,errSchemaPath:`${p.errSchemaPath}/${w}`,topSchemaRef:R,compositeRule:!0},d),b.pass(d,()=>b.error(!0))}ct.macroKeywordCode=s;function a(b,v){var g;const{gen:w,keyword:m,schema:S,parentSchema:p,$data:y,it:R}=b;c(R,v);const d=!y&&v.compile?v.compile.call(R.self,S,p,R):v.validate,h=u(w,m,d),_=w.let("valid");b.block$data(_,E),b.ok((g=v.valid)!==null&&g!==void 0?g:_);function E(){if(v.errors===!1)C(),v.modifying&&i(b),M(()=>b.error());else{const F=v.async?I():j();v.modifying&&i(b),M(()=>o(b,F))}}function I(){const F=w.let("ruleErrs",null);return w.try(()=>C((0,t._)`await `),D=>w.assign(_,!1).if((0,t._)`${D} instanceof ${R.ValidationError}`,()=>w.assign(F,(0,t._)`${D}.errors`),()=>w.throw(D))),F}function j(){const F=(0,t._)`${h}.errors`;return w.assign(F,null),C(t.nil),F}function C(F=v.async?(0,t._)`await `:t.nil){const D=R.opts.passContext?e.default.this:e.default.self,ae=!("compile"in v&&!y||v.schema===!1);w.assign(_,(0,t._)`${F}${(0,r.callValidateCode)(b,h,D,ae)}`,v.modifying)}function M(F){var D;w.if((0,t.not)((D=v.valid)!==null&&D!==void 0?D:_),F)}}ct.funcKeywordCode=a;function i(b){const{gen:v,data:g,it:w}=b;v.if(w.parentData,()=>v.assign(g,(0,t._)`${w.parentData}[${w.parentDataProperty}]`))}function o(b,v){const{gen:g}=b;g.if((0,t._)`Array.isArray(${v})`,()=>{g.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)(b)},()=>b.error())}function c({schemaEnv:b},v){if(v.async&&!b.$async)throw new Error("async keyword in sync schema")}function u(b,v,g){if(g===void 0)throw new Error(`keyword "${v}" failed to compile`);return b.scopeValue("keyword",typeof g=="function"?{ref:g}:{ref:g,code:(0,t.stringify)(g)})}function l(b,v,g=!1){return!v.length||v.some(w=>w==="array"?Array.isArray(b):w==="object"?b&&typeof b=="object"&&!Array.isArray(b):typeof b==w||g&&typeof b>"u")}ct.validSchemaType=l;function f({schema:b,opts:v,self:g,errSchemaPath:w},m,S){if(Array.isArray(m.keyword)?!m.keyword.includes(S):m.keyword!==S)throw new Error("ajv implementation error");const p=m.dependencies;if(p?.some(y=>!Object.prototype.hasOwnProperty.call(b,y)))throw new Error(`parent schema must have dependencies of ${S}: ${p.join(",")}`);if(m.validateSchema&&!m.validateSchema(b[S])){const R=`keyword "${S}" value is invalid at path "${w}": `+g.errorsText(m.validateSchema.errors);if(v.validateSchema==="log")g.logger.error(R);else throw new Error(R)}}return ct.validateKeywordUsage=f,ct}var wt={},fo;function nf(){if(fo)return wt;fo=1,Object.defineProperty(wt,"__esModule",{value:!0}),wt.extendSubschemaMode=wt.extendSubschemaData=wt.getSubschema=void 0;const t=ie(),e=fe();function r(a,{keyword:i,schemaProp:o,schema:c,schemaPath:u,errSchemaPath:l,topSchemaRef:f}){if(i!==void 0&&c!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(i!==void 0){const b=a.schema[i];return o===void 0?{schema:b,schemaPath:(0,t._)`${a.schemaPath}${(0,t.getProperty)(i)}`,errSchemaPath:`${a.errSchemaPath}/${i}`}:{schema:b[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(u===void 0||l===void 0||f===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:c,schemaPath:u,topSchemaRef:f,errSchemaPath:l}}throw new Error('either "keyword" or "schema" must be passed')}wt.getSubschema=r;function n(a,i,{dataProp:o,dataPropType:c,data:u,dataTypes:l,propertyName:f}){if(u!==void 0&&o!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');const{gen:b}=i;if(o!==void 0){const{errorPath:g,dataPathArr:w,opts:m}=i,S=b.let("data",(0,t._)`${i.data}${(0,t.getProperty)(o)}`,!0);v(S),a.errorPath=(0,t.str)`${g}${(0,e.getErrorPath)(o,c,m.jsPropertySyntax)}`,a.parentDataProperty=(0,t._)`${o}`,a.dataPathArr=[...w,a.parentDataProperty]}if(u!==void 0){const g=u instanceof t.Name?u:b.let("data",u,!0);v(g),f!==void 0&&(a.propertyName=f)}l&&(a.dataTypes=l);function v(g){a.data=g,a.dataLevel=i.dataLevel+1,a.dataTypes=[],i.definedProperties=new Set,a.parentData=i.data,a.dataNames=[...i.dataNames,g]}}wt.extendSubschemaData=n;function s(a,{jtdDiscriminator:i,jtdMetadata:o,compositeRule:c,createErrors:u,allErrors:l}){c!==void 0&&(a.compositeRule=c),u!==void 0&&(a.createErrors=u),l!==void 0&&(a.allErrors=l),a.jtdDiscriminator=i,a.jtdMetadata=o}return wt.extendSubschemaMode=s,wt}var We={},Gs,ho;function po(){return ho||(ho=1,Gs=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}),Gs}var Ys={exports:{}},mo;function sf(){if(mo)return Ys.exports;mo=1;var t=Ys.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,u,l,f,b){if(i&&typeof i=="object"&&!Array.isArray(i)){s(i,o,c,u,l,f,b);for(var v in i){var g=i[v];if(Array.isArray(g)){if(v in t.arrayKeywords)for(var w=0;w<g.length;w++)e(n,s,a,g[w],o+"/"+v+"/"+w,c,o,v,i,w)}else if(v in t.propsKeywords){if(g&&typeof g=="object")for(var m in g)e(n,s,a,g[m],o+"/"+v+"/"+r(m),c,o,v,i,m)}else(v in t.keywords||n.allKeys&&!(v in t.skipKeywords))&&e(n,s,a,g,o+"/"+v,c,o,v,i)}a(i,o,c,u,l,f,b)}}function r(n){return n.replace(/~/g,"~0").replace(/\//g,"~1")}return Ys.exports}var go;function cn(){if(go)return We;go=1,Object.defineProperty(We,"__esModule",{value:!0}),We.getSchemaRefs=We.resolveUrl=We.normalizeId=We._getFullPath=We.getFullPath=We.inlineRef=void 0;const t=fe(),e=po(),r=sf(),n=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function s(w,m=!0){return typeof w=="boolean"?!0:m===!0?!i(w):m?o(w)<=m:!1}We.inlineRef=s;const a=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function i(w){for(const m in w){if(a.has(m))return!0;const S=w[m];if(Array.isArray(S)&&S.some(i)||typeof S=="object"&&i(S))return!0}return!1}function o(w){let m=0;for(const S in w){if(S==="$ref")return 1/0;if(m++,!n.has(S)&&(typeof w[S]=="object"&&(0,t.eachItem)(w[S],p=>m+=o(p)),m===1/0))return 1/0}return m}function c(w,m="",S){S!==!1&&(m=f(m));const p=w.parse(m);return u(w,p)}We.getFullPath=c;function u(w,m){return w.serialize(m).split("#")[0]+"#"}We._getFullPath=u;const l=/#\/?$/;function f(w){return w?w.replace(l,""):""}We.normalizeId=f;function b(w,m,S){return S=f(S),w.resolve(m,S)}We.resolveUrl=b;const v=/^[a-z_][-a-z0-9._]*$/i;function g(w,m){if(typeof w=="boolean")return{};const{schemaId:S,uriResolver:p}=this.opts,y=f(w[S]||m),R={"":y},d=c(p,y,!1),h={},_=new Set;return r(w,{allKeys:!0},(j,C,M,F)=>{if(F===void 0)return;const D=d+C;let ae=R[F];typeof j[S]=="string"&&(ae=$e.call(this,j[S])),xe.call(this,j.$anchor),xe.call(this,j.$dynamicAnchor),R[C]=ae;function $e(ge){const mt=this.opts.uriResolver.resolve;if(ge=f(ae?mt(ae,ge):ge),_.has(ge))throw I(ge);_.add(ge);let H=this.refs[ge];return typeof H=="string"&&(H=this.refs[H]),typeof H=="object"?E(j,H.schema,ge):ge!==f(D)&&(ge[0]==="#"?(E(j,h[ge],ge),h[ge]=j):this.refs[ge]=D),ge}function xe(ge){if(typeof ge=="string"){if(!v.test(ge))throw new Error(`invalid anchor "${ge}"`);$e.call(this,`#${ge}`)}}}),h;function E(j,C,M){if(C!==void 0&&!e(j,C))throw I(M)}function I(j){return new Error(`reference "${j}" resolves to more than one schema`)}}return We.getSchemaRefs=g,We}var _o;function un(){if(_o)return yt;_o=1,Object.defineProperty(yt,"__esModule",{value:!0}),yt.getData=yt.KeywordCxt=yt.validateFunctionCode=void 0;const t=ef(),e=on(),r=io(),n=on(),s=tf(),a=rf(),i=nf(),o=ie(),c=Et(),u=cn(),l=fe(),f=an();function b(O){if(d(O)&&(_(O),R(O))){m(O);return}v(O,()=>(0,t.topBoolOrEmptySchema)(O))}yt.validateFunctionCode=b;function v({gen:O,validateName:A,schema:x,schemaEnv:W,opts:re},ue){re.code.es5?O.func(A,(0,o._)`${c.default.data}, ${c.default.valCxt}`,W.$async,()=>{O.code((0,o._)`"use strict"; ${p(x,re)}`),w(O,re),O.code(ue)}):O.func(A,(0,o._)`${c.default.data}, ${g(re)}`,W.$async,()=>O.code(p(x,re)).code(ue))}function g(O){return(0,o._)`{${c.default.instancePath}="", ${c.default.parentData}, ${c.default.parentDataProperty}, ${c.default.rootData}=${c.default.data}${O.dynamicRef?(0,o._)`, ${c.default.dynamicAnchors}={}`:o.nil}}={}`}function w(O,A){O.if(c.default.valCxt,()=>{O.var(c.default.instancePath,(0,o._)`${c.default.valCxt}.${c.default.instancePath}`),O.var(c.default.parentData,(0,o._)`${c.default.valCxt}.${c.default.parentData}`),O.var(c.default.parentDataProperty,(0,o._)`${c.default.valCxt}.${c.default.parentDataProperty}`),O.var(c.default.rootData,(0,o._)`${c.default.valCxt}.${c.default.rootData}`),A.dynamicRef&&O.var(c.default.dynamicAnchors,(0,o._)`${c.default.valCxt}.${c.default.dynamicAnchors}`)},()=>{O.var(c.default.instancePath,(0,o._)`""`),O.var(c.default.parentData,(0,o._)`undefined`),O.var(c.default.parentDataProperty,(0,o._)`undefined`),O.var(c.default.rootData,c.default.data),A.dynamicRef&&O.var(c.default.dynamicAnchors,(0,o._)`{}`)})}function m(O){const{schema:A,opts:x,gen:W}=O;v(O,()=>{x.$comment&&A.$comment&&F(O),j(O),W.let(c.default.vErrors,null),W.let(c.default.errors,0),x.unevaluated&&S(O),E(O),D(O)})}function S(O){const{gen:A,validateName:x}=O;O.evaluated=A.const("evaluated",(0,o._)`${x}.evaluated`),A.if((0,o._)`${O.evaluated}.dynamicProps`,()=>A.assign((0,o._)`${O.evaluated}.props`,(0,o._)`undefined`)),A.if((0,o._)`${O.evaluated}.dynamicItems`,()=>A.assign((0,o._)`${O.evaluated}.items`,(0,o._)`undefined`))}function p(O,A){const x=typeof O=="object"&&O[A.schemaId];return x&&(A.code.source||A.code.process)?(0,o._)`/*# sourceURL=${x} */`:o.nil}function y(O,A){if(d(O)&&(_(O),R(O))){h(O,A);return}(0,t.boolOrEmptySchema)(O,A)}function R({schema:O,self:A}){if(typeof O=="boolean")return!O;for(const x in O)if(A.RULES.all[x])return!0;return!1}function d(O){return typeof O.schema!="boolean"}function h(O,A){const{schema:x,gen:W,opts:re}=O;re.$comment&&x.$comment&&F(O),C(O),M(O);const ue=W.const("_errs",c.default.errors);E(O,ue),W.var(A,(0,o._)`${ue} === ${c.default.errors}`)}function _(O){(0,l.checkUnknownRules)(O),I(O)}function E(O,A){if(O.opts.jtd)return $e(O,[],!1,A);const x=(0,e.getSchemaTypes)(O.schema),W=(0,e.coerceAndCheckDataType)(O,x);$e(O,x,!W,A)}function I(O){const{schema:A,errSchemaPath:x,opts:W,self:re}=O;A.$ref&&W.ignoreKeywordsWithRef&&(0,l.schemaHasRulesButRef)(A,re.RULES)&&re.logger.warn(`$ref: keywords ignored in schema at path "${x}"`)}function j(O){const{schema:A,opts:x}=O;A.default!==void 0&&x.useDefaults&&x.strictSchema&&(0,l.checkStrictMode)(O,"default is ignored in the schema root")}function C(O){const A=O.schema[O.opts.schemaId];A&&(O.baseId=(0,u.resolveUrl)(O.opts.uriResolver,O.baseId,A))}function M(O){if(O.schema.$async&&!O.schemaEnv.$async)throw new Error("async schema in sync schema")}function F({gen:O,schemaEnv:A,schema:x,errSchemaPath:W,opts:re}){const ue=x.$comment;if(re.$comment===!0)O.code((0,o._)`${c.default.self}.logger.log(${ue})`);else if(typeof re.$comment=="function"){const Fe=(0,o.str)`${W}/$comment`,gt=O.scopeValue("root",{ref:A.root});O.code((0,o._)`${c.default.self}.opts.$comment(${ue}, ${Fe}, ${gt}.schema)`)}}function D(O){const{gen:A,schemaEnv:x,validateName:W,ValidationError:re,opts:ue}=O;x.$async?A.if((0,o._)`${c.default.errors} === 0`,()=>A.return(c.default.data),()=>A.throw((0,o._)`new ${re}(${c.default.vErrors})`)):(A.assign((0,o._)`${W}.errors`,c.default.vErrors),ue.unevaluated&&ae(O),A.return((0,o._)`${c.default.errors} === 0`))}function ae({gen:O,evaluated:A,props:x,items:W}){x instanceof o.Name&&O.assign((0,o._)`${A}.props`,x),W instanceof o.Name&&O.assign((0,o._)`${A}.items`,W)}function $e(O,A,x,W){const{gen:re,schema:ue,data:Fe,allErrors:gt,opts:Ye,self:Qe}=O,{RULES:He}=Qe;if(ue.$ref&&(Ye.ignoreKeywordsWithRef||!(0,l.schemaHasRulesButRef)(ue,He))){re.block(()=>ee(O,"$ref",He.all.$ref.definition));return}Ye.jtd||ge(O,A),re.block(()=>{for(const ot of He.rules)Sr(ot);Sr(He.post)});function Sr(ot){(0,r.shouldUseGroup)(ue,ot)&&(ot.type?(re.if((0,n.checkDataType)(ot.type,Fe,Ye.strictNumbers)),xe(O,ot),A.length===1&&A[0]===ot.type&&x&&(re.else(),(0,n.reportTypeError)(O)),re.endIf()):xe(O,ot),gt||re.if((0,o._)`${c.default.errors} === ${W||0}`))}}function xe(O,A){const{gen:x,schema:W,opts:{useDefaults:re}}=O;re&&(0,s.assignDefaults)(O,A.type),x.block(()=>{for(const ue of A.rules)(0,r.shouldUseRule)(W,ue)&&ee(O,ue.keyword,ue.definition,A.type)})}function ge(O,A){O.schemaEnv.meta||!O.opts.strictTypes||(mt(O,A),O.opts.allowUnionTypes||H(O,A),N(O,O.dataTypes))}function mt(O,A){if(A.length){if(!O.dataTypes.length){O.dataTypes=A;return}A.forEach(x=>{z(O.dataTypes,x)||P(O,`type "${x}" not allowed by context "${O.dataTypes.join(",")}"`)}),k(O,A)}}function H(O,A){A.length>1&&!(A.length===2&&A.includes("null"))&&P(O,"use allowUnionTypes to allow union type keyword")}function N(O,A){const x=O.self.RULES.all;for(const W in x){const re=x[W];if(typeof re=="object"&&(0,r.shouldUseRule)(O.schema,re)){const{type:ue}=re.definition;ue.length&&!ue.some(Fe=>L(A,Fe))&&P(O,`missing type "${ue.join(",")}" for keyword "${W}"`)}}}function L(O,A){return O.includes(A)||A==="number"&&O.includes("integer")}function z(O,A){return O.includes(A)||A==="integer"&&O.includes("number")}function k(O,A){const x=[];for(const W of O.dataTypes)z(A,W)?x.push(W):A.includes("integer")&&W==="number"&&x.push("integer");O.dataTypes=x}function P(O,A){const x=O.schemaEnv.baseId+O.errSchemaPath;A+=` at "${x}" (strictTypes)`,(0,l.checkStrictMode)(O,A,O.opts.strictTypes)}class Z{constructor(A,x,W){if((0,a.validateKeywordUsage)(A,x,W),this.gen=A.gen,this.allErrors=A.allErrors,this.keyword=W,this.data=A.data,this.schema=A.schema[W],this.$data=x.$data&&A.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,l.schemaRefOrVal)(A,this.schema,W,this.$data),this.schemaType=x.schemaType,this.parentSchema=A.schema,this.params={},this.it=A,this.def=x,this.$data)this.schemaCode=A.gen.const("vSchema",de(this.$data,A));else if(this.schemaCode=this.schemaValue,!(0,a.validSchemaType)(this.schema,x.schemaType,x.allowUndefined))throw new Error(`${W} value must be ${JSON.stringify(x.schemaType)}`);("code"in x?x.trackErrors:x.errors!==!1)&&(this.errsCount=A.gen.const("_errs",c.default.errors))}result(A,x,W){this.failResult((0,o.not)(A),x,W)}failResult(A,x,W){this.gen.if(A),W?W():this.error(),x?(this.gen.else(),x(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(A,x){this.failResult((0,o.not)(A),void 0,x)}fail(A){if(A===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(A),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(A){if(!this.$data)return this.fail(A);const{schemaCode:x}=this;this.fail((0,o._)`${x} !== undefined && (${(0,o.or)(this.invalid$data(),A)})`)}error(A,x,W){if(x){this.setParams(x),this._error(A,W),this.setParams({});return}this._error(A,W)}_error(A,x){(A?f.reportExtraError:f.reportError)(this,this.def.error,x)}$dataError(){(0,f.reportError)(this,this.def.$dataError||f.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,f.resetErrorsCount)(this.gen,this.errsCount)}ok(A){this.allErrors||this.gen.if(A)}setParams(A,x){x?Object.assign(this.params,A):this.params=A}block$data(A,x,W=o.nil){this.gen.block(()=>{this.check$data(A,W),x()})}check$data(A=o.nil,x=o.nil){if(!this.$data)return;const{gen:W,schemaCode:re,schemaType:ue,def:Fe}=this;W.if((0,o.or)((0,o._)`${re} === undefined`,x)),A!==o.nil&&W.assign(A,!0),(ue.length||Fe.validateSchema)&&(W.elseIf(this.invalid$data()),this.$dataError(),A!==o.nil&&W.assign(A,!1)),W.else()}invalid$data(){const{gen:A,schemaCode:x,schemaType:W,def:re,it:ue}=this;return(0,o.or)(Fe(),gt());function Fe(){if(W.length){if(!(x instanceof o.Name))throw new Error("ajv implementation error");const Ye=Array.isArray(W)?W:[W];return(0,o._)`${(0,n.checkDataTypes)(Ye,x,ue.opts.strictNumbers,n.DataType.Wrong)}`}return o.nil}function gt(){if(re.validateSchema){const Ye=A.scopeValue("validate$data",{ref:re.validateSchema});return(0,o._)`!${Ye}(${x})`}return o.nil}}subschema(A,x){const W=(0,i.getSubschema)(this.it,A);(0,i.extendSubschemaData)(W,this.it,A),(0,i.extendSubschemaMode)(W,A);const re={...this.it,...W,items:void 0,props:void 0};return y(re,x),re}mergeEvaluated(A,x){const{it:W,gen:re}=this;W.opts.unevaluated&&(W.props!==!0&&A.props!==void 0&&(W.props=l.mergeEvaluated.props(re,A.props,W.props,x)),W.items!==!0&&A.items!==void 0&&(W.items=l.mergeEvaluated.items(re,A.items,W.items,x)))}mergeValidEvaluated(A,x){const{it:W,gen:re}=this;if(W.opts.unevaluated&&(W.props!==!0||W.items!==!0))return re.if(x,()=>this.mergeEvaluated(A,o.Name)),!0}}yt.KeywordCxt=Z;function ee(O,A,x,W){const re=new Z(O,x,A);"code"in x?x.code(re,W):re.$data&&x.validate?(0,a.funcKeywordCode)(re,x):"macro"in x?(0,a.macroKeywordCode)(re,x):(x.compile||x.validate)&&(0,a.funcKeywordCode)(re,x)}const ne=/^\/(?:[^~]|~0|~1)*$/,_e=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function de(O,{dataLevel:A,dataNames:x,dataPathArr:W}){let re,ue;if(O==="")return c.default.rootData;if(O[0]==="/"){if(!ne.test(O))throw new Error(`Invalid JSON-pointer: ${O}`);re=O,ue=c.default.rootData}else{const Qe=_e.exec(O);if(!Qe)throw new Error(`Invalid JSON-pointer: ${O}`);const He=+Qe[1];if(re=Qe[2],re==="#"){if(He>=A)throw new Error(Ye("property/index",He));return W[A-He]}if(He>A)throw new Error(Ye("data",He));if(ue=x[A-He],!re)return ue}let Fe=ue;const gt=re.split("/");for(const Qe of gt)Qe&&(ue=(0,o._)`${ue}${(0,o.getProperty)((0,l.unescapeJsonPointer)(Qe))}`,Fe=(0,o._)`${Fe} && ${ue}`);return Fe;function Ye(Qe,He){return`Cannot access ${Qe} ${He} levels up, current level is ${A}`}}return yt.getData=de,yt}var ln={},yo;function Qs(){if(yo)return ln;yo=1,Object.defineProperty(ln,"__esModule",{value:!0});class t extends Error{constructor(r){super("validation failed"),this.errors=r,this.ajv=this.validation=!0}}return ln.default=t,ln}var dn={},vo;function fn(){if(vo)return dn;vo=1,Object.defineProperty(dn,"__esModule",{value:!0});const t=cn();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 dn.default=e,dn}var Xe={},wo;function Xs(){if(wo)return Xe;wo=1,Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.resolveSchema=Xe.getCompilingSchema=Xe.resolveRef=Xe.compileSchema=Xe.SchemaEnv=void 0;const t=ie(),e=Qs(),r=Et(),n=cn(),s=fe(),a=un();class i{constructor(S){var p;this.refs={},this.dynamicAnchors={};let y;typeof S.schema=="object"&&(y=S.schema),this.schema=S.schema,this.schemaId=S.schemaId,this.root=S.root||this,this.baseId=(p=S.baseId)!==null&&p!==void 0?p:(0,n.normalizeId)(y?.[S.schemaId||"$id"]),this.schemaPath=S.schemaPath,this.localRefs=S.localRefs,this.meta=S.meta,this.$async=y?.$async,this.refs={}}}Xe.SchemaEnv=i;function o(m){const S=l.call(this,m);if(S)return S;const p=(0,n.getFullPath)(this.opts.uriResolver,m.root.baseId),{es5:y,lines:R}=this.opts.code,{ownProperties:d}=this.opts,h=new t.CodeGen(this.scope,{es5:y,lines:R,ownProperties:d});let _;m.$async&&(_=h.scopeValue("Error",{ref:e.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));const E=h.scopeName("validate");m.validateName=E;const I={gen:h,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:h.scopeValue("schema",this.opts.code.source===!0?{ref:m.schema,code:(0,t.stringify)(m.schema)}:{ref:m.schema}),validateName:E,ValidationError:_,schema:m.schema,schemaEnv:m,rootId:p,baseId:m.baseId||p,schemaPath:t.nil,errSchemaPath:m.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,t._)`""`,opts:this.opts,self:this};let j;try{this._compilations.add(m),(0,a.validateFunctionCode)(I),h.optimize(this.opts.code.optimize);const C=h.toString();j=`${h.scopeRefs(r.default.scope)}return ${C}`,this.opts.code.process&&(j=this.opts.code.process(j,m));const F=new Function(`${r.default.self}`,`${r.default.scope}`,j)(this,this.scope.get());if(this.scope.value(E,{ref:F}),F.errors=null,F.schema=m.schema,F.schemaEnv=m,m.$async&&(F.$async=!0),this.opts.code.source===!0&&(F.source={validateName:E,validateCode:C,scopeValues:h._values}),this.opts.unevaluated){const{props:D,items:ae}=I;F.evaluated={props:D instanceof t.Name?void 0:D,items:ae instanceof t.Name?void 0:ae,dynamicProps:D instanceof t.Name,dynamicItems:ae instanceof t.Name},F.source&&(F.source.evaluated=(0,t.stringify)(F.evaluated))}return m.validate=F,m}catch(C){throw delete m.validate,delete m.validateName,j&&this.logger.error("Error compiling schema, function code:",j),C}finally{this._compilations.delete(m)}}Xe.compileSchema=o;function c(m,S,p){var y;p=(0,n.resolveUrl)(this.opts.uriResolver,S,p);const R=m.refs[p];if(R)return R;let d=b.call(this,m,p);if(d===void 0){const h=(y=m.localRefs)===null||y===void 0?void 0:y[p],{schemaId:_}=this.opts;h&&(d=new i({schema:h,schemaId:_,root:m,baseId:S}))}if(d!==void 0)return m.refs[p]=u.call(this,d)}Xe.resolveRef=c;function u(m){return(0,n.inlineRef)(m.schema,this.opts.inlineRefs)?m.schema:m.validate?m:o.call(this,m)}function l(m){for(const S of this._compilations)if(f(S,m))return S}Xe.getCompilingSchema=l;function f(m,S){return m.schema===S.schema&&m.root===S.root&&m.baseId===S.baseId}function b(m,S){let p;for(;typeof(p=this.refs[S])=="string";)S=p;return p||this.schemas[S]||v.call(this,m,S)}function v(m,S){const p=this.opts.uriResolver.parse(S),y=(0,n._getFullPath)(this.opts.uriResolver,p);let R=(0,n.getFullPath)(this.opts.uriResolver,m.baseId,void 0);if(Object.keys(m.schema).length>0&&y===R)return w.call(this,p,m);const d=(0,n.normalizeId)(y),h=this.refs[d]||this.schemas[d];if(typeof h=="string"){const _=v.call(this,m,h);return typeof _?.schema!="object"?void 0:w.call(this,p,_)}if(typeof h?.schema=="object"){if(h.validate||o.call(this,h),d===(0,n.normalizeId)(S)){const{schema:_}=h,{schemaId:E}=this.opts,I=_[E];return I&&(R=(0,n.resolveUrl)(this.opts.uriResolver,R,I)),new i({schema:_,schemaId:E,root:m,baseId:R})}return w.call(this,p,h)}}Xe.resolveSchema=v;const g=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function w(m,{baseId:S,schema:p,root:y}){var R;if(((R=m.fragment)===null||R===void 0?void 0:R[0])!=="/")return;for(const _ of m.fragment.slice(1).split("/")){if(typeof p=="boolean")return;const E=p[(0,s.unescapeFragment)(_)];if(E===void 0)return;p=E;const I=typeof p=="object"&&p[this.opts.schemaId];!g.has(_)&&I&&(S=(0,n.resolveUrl)(this.opts.uriResolver,S,I))}let d;if(typeof p!="boolean"&&p.$ref&&!(0,s.schemaHasRulesButRef)(p,this.RULES)){const _=(0,n.resolveUrl)(this.opts.uriResolver,S,p.$ref);d=v.call(this,y,_)}const{schemaId:h}=this.opts;if(d=d||new i({schema:p,schemaId:h,root:y,baseId:S}),d.schema!==d.root.schema)return d}return Xe}const af={$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 hn={},kr={exports:{}},ea,bo;function So(){if(bo)return ea;bo=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),r=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),n=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),s=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function a(d){let h="",_=0,E=0;for(E=0;E<d.length;E++)if(_=d[E].charCodeAt(0),_!==48){if(!(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102))return"";h+=d[E];break}for(E+=1;E<d.length;E++){if(_=d[E].charCodeAt(0),!(_>=48&&_<=57||_>=65&&_<=70||_>=97&&_<=102))return"";h+=d[E]}return h}const i=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function o(d){return d.length=0,!0}function c(d,h,_){if(d.length){const E=a(d);if(E!=="")h.push(E);else return _.error=!0,!1;d.length=0}return!0}function u(d){let h=0;const _={error:!1,address:"",zone:""},E=[],I=[];let j=!1,C=!1,M=c;for(let F=0;F<d.length;F++){const D=d[F];if(!(D==="["||D==="]"))if(D===":"){if(j===!0&&(C=!0),!M(I,E,_))break;if(++h>7){_.error=!0;break}F>0&&d[F-1]===":"&&(j=!0),E.push(":");continue}else if(D==="%"){if(!M(I,E,_))break;M=o}else{I.push(D);continue}}return I.length&&(M===o?_.zone=I.join(""):C?E.push(I.join("")):E.push(a(I))),_.address=E.join(""),_}function l(d){if(f(d,":")<2)return{host:d,isIPV6:!1};const h=u(d);if(h.error)return{host:d,isIPV6:!1};{let _=h.address,E=h.address;return h.zone&&(_+="%"+h.zone,E+="%25"+h.zone),{host:_,isIPV6:!0,escapedHost:E}}}function f(d,h){let _=0;for(let E=0;E<d.length;E++)d[E]===h&&_++;return _}function b(d){let h=d;const _=[];let E=-1,I=0;for(;I=h.length;){if(I===1){if(h===".")break;if(h==="/"){_.push("/");break}else{_.push(h);break}}else if(I===2){if(h[0]==="."){if(h[1]===".")break;if(h[1]==="/"){h=h.slice(2);continue}}else if(h[0]==="/"&&(h[1]==="."||h[1]==="/")){_.push("/");break}}else if(I===3&&h==="/.."){_.length!==0&&_.pop(),_.push("/");break}if(h[0]==="."){if(h[1]==="."){if(h[2]==="/"){h=h.slice(3);continue}}else if(h[1]==="/"){h=h.slice(2);continue}}else if(h[0]==="/"&&h[1]==="."){if(h[2]==="/"){h=h.slice(2);continue}else if(h[2]==="."&&h[3]==="/"){h=h.slice(3),_.length!==0&&_.pop();continue}}if((E=h.indexOf("/",1))===-1){_.push(h);break}else _.push(h.slice(0,E)),h=h.slice(E)}return _.join("")}const v={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},g=/[@/?#:]/g,w=/[@/?#]/g;function m(d,h){const _=h?w:g;return _.lastIndex=0,d.replace(_,E=>v[E])}function S(d,h=!1){if(d.indexOf("%")===-1)return d;let _="";for(let E=0;E<d.length;E++){if(d[E]==="%"&&E+2<d.length){const I=d.slice(E+1,E+3);if(r(I)){const j=I.toUpperCase(),C=String.fromCharCode(parseInt(j,16));h&&n(C)?_+=C:_+="%"+j,E+=2;continue}}_+=d[E]}return _}function p(d){let h="";for(let _=0;_<d.length;_++){if(d[_]==="%"&&_+2<d.length){const E=d.slice(_+1,_+3);if(r(E)){const I=E.toUpperCase(),j=String.fromCharCode(parseInt(I,16));j!=="."&&n(j)?h+=j:h+="%"+I,_+=2;continue}}s(d[_])?h+=d[_]:h+=escape(d[_])}return h}function y(d){let h="";for(let _=0;_<d.length;_++){if(d[_]==="%"&&_+2<d.length){const E=d.slice(_+1,_+3);if(r(E)){h+="%"+E.toUpperCase(),_+=2;continue}}h+=escape(d[_])}return h}function R(d){const h=[];if(d.userinfo!==void 0&&(h.push(d.userinfo),h.push("@")),d.host!==void 0){let _=unescape(d.host);if(!e(_)){const E=l(_);E.isIPV6===!0?_=`[${E.escapedHost}]`:_=m(_,!1)}h.push(_)}return(typeof d.port=="number"||typeof d.port=="string")&&(h.push(":"),h.push(String(d.port))),h.length?h.join(""):void 0}return ea={nonSimpleDomain:i,recomposeAuthority:R,reescapeHostDelimiters:m,normalizePercentEncoding:S,normalizePathEncoding:p,escapePreservingEscapes:y,removeDotSegments:b,isIPv4:e,isUUID:t,normalizeIPv6:l,stringArrayToHexStripped:a},ea}var ta,$o;function of(){if($o)return ta;$o=1;const{isUUID:t}=So(),e=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,r=["http","https","ws","wss","urn","urn:uuid"];function n(d){return r.indexOf(d)!==-1}function s(d){return d.secure===!0?!0:d.secure===!1?!1:d.scheme?d.scheme.length===3&&(d.scheme[0]==="w"||d.scheme[0]==="W")&&(d.scheme[1]==="s"||d.scheme[1]==="S")&&(d.scheme[2]==="s"||d.scheme[2]==="S"):!1}function a(d){return d.host||(d.error=d.error||"HTTP URIs must have a host."),d}function i(d){const h=String(d.scheme).toLowerCase()==="https";return(d.port===(h?443:80)||d.port==="")&&(d.port=void 0),d.path||(d.path="/"),d}function o(d){return d.secure=s(d),d.resourceName=(d.path||"/")+(d.query?"?"+d.query:""),d.path=void 0,d.query=void 0,d}function c(d){if((d.port===(s(d)?443:80)||d.port==="")&&(d.port=void 0),typeof d.secure=="boolean"&&(d.scheme=d.secure?"wss":"ws",d.secure=void 0),d.resourceName){const[h,_]=d.resourceName.split("?");d.path=h&&h!=="/"?h:void 0,d.query=_,d.resourceName=void 0}return d.fragment=void 0,d}function u(d,h){if(!d.path)return d.error="URN can not be parsed",d;const _=d.path.match(e);if(_){const E=h.scheme||d.scheme||"urn";d.nid=_[1].toLowerCase(),d.nss=_[2];const I=`${E}:${h.nid||d.nid}`,j=R(I);d.path=void 0,j&&(d=j.parse(d,h))}else d.error=d.error||"URN can not be parsed.";return d}function l(d,h){if(d.nid===void 0)throw new Error("URN without nid cannot be serialized");const _=h.scheme||d.scheme||"urn",E=d.nid.toLowerCase(),I=`${_}:${h.nid||E}`,j=R(I);j&&(d=j.serialize(d,h));const C=d,M=d.nss;return C.path=`${E||h.nid}:${M}`,h.skipEscape=!0,C}function f(d,h){const _=d;return _.uuid=_.nss,_.nss=void 0,!h.tolerant&&(!_.uuid||!t(_.uuid))&&(_.error=_.error||"UUID is not valid."),_}function b(d){const h=d;return h.nss=(d.uuid||"").toLowerCase(),h}const v={scheme:"http",domainHost:!0,parse:a,serialize:i},g={scheme:"https",domainHost:v.domainHost,parse:a,serialize:i},w={scheme:"ws",domainHost:!0,parse:o,serialize:c},m={scheme:"wss",domainHost:w.domainHost,parse:w.parse,serialize:w.serialize},y={http:v,https:g,ws:w,wss:m,urn:{scheme:"urn",parse:u,serialize:l,skipNormalize:!0},"urn:uuid":{scheme:"urn:uuid",parse:f,serialize:b,skipNormalize:!0}};Object.setPrototypeOf(y,null);function R(d){return d&&(y[d]||y[d.toLowerCase()])||void 0}return ta={wsIsSecure:s,SCHEMES:y,isValidSchemeName:n,getSchemeHandler:R},ta}var ko;function cf(){if(ko)return kr.exports;ko=1;const{normalizeIPv6:t,removeDotSegments:e,recomposeAuthority:r,normalizePercentEncoding:n,normalizePathEncoding:s,escapePreservingEscapes:a,reescapeHostDelimiters:i,isIPv4:o,nonSimpleDomain:c}=So(),{SCHEMES:u,getSchemeHandler:l}=of();function f(E,I){return typeof E=="string"?E=R(E,I):typeof E=="object"&&(E=y(w(E,I),I)),E}function b(E,I,j){const C=j?Object.assign({scheme:"null"},j):{scheme:"null"},M=v(y(E,C),y(I,C),C,!0);return C.skipEscape=!0,w(M,C)}function v(E,I,j,C){const M={};return C||(E=y(w(E,j),j),I=y(w(I,j),j)),j=j||{},!j.tolerant&&I.scheme?(M.scheme=I.scheme,M.userinfo=I.userinfo,M.host=I.host,M.port=I.port,M.path=e(I.path||""),M.query=I.query):(I.userinfo!==void 0||I.host!==void 0||I.port!==void 0?(M.userinfo=I.userinfo,M.host=I.host,M.port=I.port,M.path=e(I.path||""),M.query=I.query):(I.path?(I.path[0]==="/"?M.path=e(I.path):((E.userinfo!==void 0||E.host!==void 0||E.port!==void 0)&&!E.path?M.path="/"+I.path:E.path?M.path=E.path.slice(0,E.path.lastIndexOf("/")+1)+I.path:M.path=I.path,M.path=e(M.path)),M.query=I.query):(M.path=E.path,I.query!==void 0?M.query=I.query:M.query=E.query),M.userinfo=E.userinfo,M.host=E.host,M.port=E.port),M.scheme=E.scheme),M.fragment=I.fragment,M}function g(E,I,j){const C=h(E,j),M=h(I,j);return C!==void 0&&M!==void 0&&C.toLowerCase()===M.toLowerCase()}function w(E,I){const j={host:E.host,scheme:E.scheme,userinfo:E.userinfo,port:E.port,path:E.path,query:E.query,nid:E.nid,nss:E.nss,uuid:E.uuid,fragment:E.fragment,reference:E.reference,resourceName:E.resourceName,secure:E.secure,error:""},C=Object.assign({},I),M=[],F=l(C.scheme||j.scheme);F&&F.serialize&&F.serialize(j,C),j.path!==void 0&&(C.skipEscape?j.path=n(j.path):(j.path=a(j.path),j.scheme!==void 0&&(j.path=j.path.split("%3A").join(":")))),C.reference!=="suffix"&&j.scheme&&M.push(j.scheme,":");const D=r(j);if(D!==void 0&&(C.reference!=="suffix"&&M.push("//"),M.push(D),j.path&&j.path[0]!=="/"&&M.push("/")),j.path!==void 0){let ae=j.path;!C.absolutePath&&(!F||!F.absolutePath)&&(ae=e(ae)),D===void 0&&ae[0]==="/"&&ae[1]==="/"&&(ae="/%2F"+ae.slice(2)),M.push(ae)}return j.query!==void 0&&M.push("?",j.query),j.fragment!==void 0&&M.push("#",j.fragment),M.join("")}const m=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function S(E,I){if(I[2]!==void 0&&E.path&&E.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof E.port=="number"&&(E.port<0||E.port>65535))return"URI port is malformed."}function p(E,I){const j=Object.assign({},I),C={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let M=!1,F=!1;j.reference==="suffix"&&(j.scheme?E=j.scheme+":"+E:E="//"+E);const D=E.match(m);if(D){C.scheme=D[1],C.userinfo=D[3],C.host=D[4],C.port=parseInt(D[5],10),C.path=D[6]||"",C.query=D[7],C.fragment=D[8],isNaN(C.port)&&(C.port=D[5]);const ae=S(C,D);if(ae!==void 0&&(C.error=C.error||ae,M=!0),C.host)if(o(C.host)===!1){const ge=t(C.host);C.host=ge.host.toLowerCase(),F=ge.isIPV6}else F=!0;C.scheme===void 0&&C.userinfo===void 0&&C.host===void 0&&C.port===void 0&&C.query===void 0&&!C.path?C.reference="same-document":C.scheme===void 0?C.reference="relative":C.fragment===void 0?C.reference="absolute":C.reference="uri",j.reference&&j.reference!=="suffix"&&j.reference!==C.reference&&(C.error=C.error||"URI is not a "+j.reference+" reference.");const $e=l(j.scheme||C.scheme);if(!j.unicodeSupport&&(!$e||!$e.unicodeSupport)&&C.host&&(j.domainHost||$e&&$e.domainHost)&&F===!1&&c(C.host))try{C.host=new URL("http://"+C.host).hostname}catch(xe){C.error=C.error||"Host's domain name can not be converted to ASCII: "+xe}if((!$e||$e&&!$e.skipNormalize)&&(E.indexOf("%")!==-1&&(C.scheme!==void 0&&(C.scheme=unescape(C.scheme)),C.host!==void 0&&(C.host=i(unescape(C.host),F))),C.path&&(C.path=s(C.path)),C.fragment))try{C.fragment=encodeURI(decodeURIComponent(C.fragment))}catch{C.error=C.error||"URI malformed"}$e&&$e.parse&&$e.parse(C,j)}else C.error=C.error||"URI can not be parsed.";return{parsed:C,malformedAuthorityOrPort:M}}function y(E,I){return p(E,I).parsed}function R(E,I){return d(E,I).normalized}function d(E,I){const{parsed:j,malformedAuthorityOrPort:C}=p(E,I);return{normalized:C?E:w(j,I),malformedAuthorityOrPort:C}}function h(E,I){if(typeof E=="string"){const{normalized:j,malformedAuthorityOrPort:C}=d(E,I);return C?void 0:j}if(typeof E=="object")return w(E,I)}const _={SCHEMES:u,normalize:f,resolve:b,resolveComponent:v,equal:g,serialize:w,parse:y};return kr.exports=_,kr.exports.default=_,kr.exports.fastUri=_,kr.exports}var Eo;function uf(){if(Eo)return hn;Eo=1,Object.defineProperty(hn,"__esModule",{value:!0});const t=cf();return t.code='require("ajv/dist/runtime/uri").default',hn.default=t,hn}var Ro;function lf(){return Ro||(Ro=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=un();Object.defineProperty(t,"KeywordCxt",{enumerable:!0,get:function(){return e.KeywordCxt}});var r=ie();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=Qs(),s=fn(),a=so(),i=Xs(),o=ie(),c=cn(),u=on(),l=fe(),f=af,b=uf(),v=(H,N)=>new RegExp(H,N);v.code="new RegExp";const g=["removeAdditional","useDefaults","coerceTypes"],w=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),m={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."},S={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},p=200;function y(H){var N,L,z,k,P,Z,ee,ne,_e,de,O,A,x,W,re,ue,Fe,gt,Ye,Qe,He,Sr,ot,Wi,Ki;const tn=H.strict,Ji=(N=H.code)===null||N===void 0?void 0:N.optimize,Qd=Ji===!0||Ji===void 0?1:Ji||0,Xd=(z=(L=H.code)===null||L===void 0?void 0:L.regExp)!==null&&z!==void 0?z:v,Pv=(k=H.uriResolver)!==null&&k!==void 0?k:b.default;return{strictSchema:(Z=(P=H.strictSchema)!==null&&P!==void 0?P:tn)!==null&&Z!==void 0?Z:!0,strictNumbers:(ne=(ee=H.strictNumbers)!==null&&ee!==void 0?ee:tn)!==null&&ne!==void 0?ne:!0,strictTypes:(de=(_e=H.strictTypes)!==null&&_e!==void 0?_e:tn)!==null&&de!==void 0?de:"log",strictTuples:(A=(O=H.strictTuples)!==null&&O!==void 0?O:tn)!==null&&A!==void 0?A:"log",strictRequired:(W=(x=H.strictRequired)!==null&&x!==void 0?x:tn)!==null&&W!==void 0?W:!1,code:H.code?{...H.code,optimize:Qd,regExp:Xd}:{optimize:Qd,regExp:Xd},loopRequired:(re=H.loopRequired)!==null&&re!==void 0?re:p,loopEnum:(ue=H.loopEnum)!==null&&ue!==void 0?ue:p,meta:(Fe=H.meta)!==null&&Fe!==void 0?Fe:!0,messages:(gt=H.messages)!==null&&gt!==void 0?gt:!0,inlineRefs:(Ye=H.inlineRefs)!==null&&Ye!==void 0?Ye:!0,schemaId:(Qe=H.schemaId)!==null&&Qe!==void 0?Qe:"$id",addUsedSchema:(He=H.addUsedSchema)!==null&&He!==void 0?He:!0,validateSchema:(Sr=H.validateSchema)!==null&&Sr!==void 0?Sr:!0,validateFormats:(ot=H.validateFormats)!==null&&ot!==void 0?ot:!0,unicodeRegExp:(Wi=H.unicodeRegExp)!==null&&Wi!==void 0?Wi:!0,int32range:(Ki=H.int32range)!==null&&Ki!==void 0?Ki:!0,uriResolver:Pv}}class R{constructor(N={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,N=this.opts={...N,...y(N)};const{es5:L,lines:z}=this.opts.code;this.scope=new o.ValueScope({scope:{},prefixes:w,es5:L,lines:z}),this.logger=M(N.logger);const k=N.validateFormats;N.validateFormats=!1,this.RULES=(0,a.getRules)(),d.call(this,m,N,"NOT SUPPORTED"),d.call(this,S,N,"DEPRECATED","warn"),this._metaOpts=j.call(this),N.formats&&E.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),N.keywords&&I.call(this,N.keywords),typeof N.meta=="object"&&this.addMetaSchema(N.meta),_.call(this),N.validateFormats=k}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:N,meta:L,schemaId:z}=this.opts;let k=f;z==="id"&&(k={...f},k.id=k.$id,delete k.$id),L&&N&&this.addMetaSchema(k,k[z],!1)}defaultMeta(){const{meta:N,schemaId:L}=this.opts;return this.opts.defaultMeta=typeof N=="object"?N[L]||N:void 0}validate(N,L){let z;if(typeof N=="string"){if(z=this.getSchema(N),!z)throw new Error(`no schema with key or ref "${N}"`)}else z=this.compile(N);const k=z(L);return"$async"in z||(this.errors=z.errors),k}compile(N,L){const z=this._addSchema(N,L);return z.validate||this._compileSchemaEnv(z)}compileAsync(N,L){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");const{loadSchema:z}=this.opts;return k.call(this,N,L);async function k(de,O){await P.call(this,de.$schema);const A=this._addSchema(de,O);return A.validate||Z.call(this,A)}async function P(de){de&&!this.getSchema(de)&&await k.call(this,{$ref:de},!0)}async function Z(de){try{return this._compileSchemaEnv(de)}catch(O){if(!(O instanceof s.default))throw O;return ee.call(this,O),await ne.call(this,O.missingSchema),Z.call(this,de)}}function ee({missingSchema:de,missingRef:O}){if(this.refs[de])throw new Error(`AnySchema ${de} is loaded but ${O} cannot be resolved`)}async function ne(de){const O=await _e.call(this,de);this.refs[de]||await P.call(this,O.$schema),this.refs[de]||this.addSchema(O,de,L)}async function _e(de){const O=this._loading[de];if(O)return O;try{return await(this._loading[de]=z(de))}finally{delete this._loading[de]}}}addSchema(N,L,z,k=this.opts.validateSchema){if(Array.isArray(N)){for(const Z of N)this.addSchema(Z,void 0,z,k);return this}let P;if(typeof N=="object"){const{schemaId:Z}=this.opts;if(P=N[Z],P!==void 0&&typeof P!="string")throw new Error(`schema ${Z} must be string`)}return L=(0,c.normalizeId)(L||P),this._checkUnique(L),this.schemas[L]=this._addSchema(N,z,L,k,!0),this}addMetaSchema(N,L,z=this.opts.validateSchema){return this.addSchema(N,L,!0,z),this}validateSchema(N,L){if(typeof N=="boolean")return!0;let z;if(z=N.$schema,z!==void 0&&typeof z!="string")throw new Error("$schema must be a string");if(z=z||this.opts.defaultMeta||this.defaultMeta(),!z)return this.logger.warn("meta-schema not available"),this.errors=null,!0;const k=this.validate(z,N);if(!k&&L){const P="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(P);else throw new Error(P)}return k}getSchema(N){let L;for(;typeof(L=h.call(this,N))=="string";)N=L;if(L===void 0){const{schemaId:z}=this.opts,k=new i.SchemaEnv({schema:{},schemaId:z});if(L=i.resolveSchema.call(this,k,N),!L)return;this.refs[N]=L}return L.validate||this._compileSchemaEnv(L)}removeSchema(N){if(N instanceof RegExp)return this._removeAllSchemas(this.schemas,N),this._removeAllSchemas(this.refs,N),this;switch(typeof N){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{const L=h.call(this,N);return typeof L=="object"&&this._cache.delete(L.schema),delete this.schemas[N],delete this.refs[N],this}case"object":{const L=N;this._cache.delete(L);let z=N[this.opts.schemaId];return z&&(z=(0,c.normalizeId)(z),delete this.schemas[z],delete this.refs[z]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(N){for(const L of N)this.addKeyword(L);return this}addKeyword(N,L){let z;if(typeof N=="string")z=N,typeof L=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),L.keyword=z);else if(typeof N=="object"&&L===void 0){if(L=N,z=L.keyword,Array.isArray(z)&&!z.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(D.call(this,z,L),!L)return(0,l.eachItem)(z,P=>ae.call(this,P)),this;xe.call(this,L);const k={...L,type:(0,u.getJSONTypes)(L.type),schemaType:(0,u.getJSONTypes)(L.schemaType)};return(0,l.eachItem)(z,k.type.length===0?P=>ae.call(this,P,k):P=>k.type.forEach(Z=>ae.call(this,P,k,Z))),this}getKeyword(N){const L=this.RULES.all[N];return typeof L=="object"?L.definition:!!L}removeKeyword(N){const{RULES:L}=this;delete L.keywords[N],delete L.all[N];for(const z of L.rules){const k=z.rules.findIndex(P=>P.keyword===N);k>=0&&z.rules.splice(k,1)}return this}addFormat(N,L){return typeof L=="string"&&(L=new RegExp(L)),this.formats[N]=L,this}errorsText(N=this.errors,{separator:L=", ",dataVar:z="data"}={}){return!N||N.length===0?"No errors":N.map(k=>`${z}${k.instancePath} ${k.message}`).reduce((k,P)=>k+L+P)}$dataMetaSchema(N,L){const z=this.RULES.all;N=JSON.parse(JSON.stringify(N));for(const k of L){const P=k.split("/").slice(1);let Z=N;for(const ee of P)Z=Z[ee];for(const ee in z){const ne=z[ee];if(typeof ne!="object")continue;const{$data:_e}=ne.definition,de=Z[ee];_e&&de&&(Z[ee]=mt(de))}}return N}_removeAllSchemas(N,L){for(const z in N){const k=N[z];(!L||L.test(z))&&(typeof k=="string"?delete N[z]:k&&!k.meta&&(this._cache.delete(k.schema),delete N[z]))}}_addSchema(N,L,z,k=this.opts.validateSchema,P=this.opts.addUsedSchema){let Z;const{schemaId:ee}=this.opts;if(typeof N=="object")Z=N[ee];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof N!="boolean")throw new Error("schema must be object or boolean")}let ne=this._cache.get(N);if(ne!==void 0)return ne;z=(0,c.normalizeId)(Z||z);const _e=c.getSchemaRefs.call(this,N,z);return ne=new i.SchemaEnv({schema:N,schemaId:ee,meta:L,baseId:z,localRefs:_e}),this._cache.set(ne.schema,ne),P&&!z.startsWith("#")&&(z&&this._checkUnique(z),this.refs[z]=ne),k&&this.validateSchema(N,!0),ne}_checkUnique(N){if(this.schemas[N]||this.refs[N])throw new Error(`schema with key or id "${N}" already exists`)}_compileSchemaEnv(N){if(N.meta?this._compileMetaSchema(N):i.compileSchema.call(this,N),!N.validate)throw new Error("ajv implementation error");return N.validate}_compileMetaSchema(N){const L=this.opts;this.opts=this._metaOpts;try{i.compileSchema.call(this,N)}finally{this.opts=L}}}R.ValidationError=n.default,R.MissingRefError=s.default,t.default=R;function d(H,N,L,z="error"){for(const k in H){const P=k;P in N&&this.logger[z](`${L}: option ${k}. ${H[P]}`)}}function h(H){return H=(0,c.normalizeId)(H),this.schemas[H]||this.refs[H]}function _(){const H=this.opts.schemas;if(H)if(Array.isArray(H))this.addSchema(H);else for(const N in H)this.addSchema(H[N],N)}function E(){for(const H in this.opts.formats){const N=this.opts.formats[H];N&&this.addFormat(H,N)}}function I(H){if(Array.isArray(H)){this.addVocabulary(H);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const N in H){const L=H[N];L.keyword||(L.keyword=N),this.addKeyword(L)}}function j(){const H={...this.opts};for(const N of g)delete H[N];return H}const C={log(){},warn(){},error(){}};function M(H){if(H===!1)return C;if(H===void 0)return console;if(H.log&&H.warn&&H.error)return H;throw new Error("logger must implement log, warn and error methods")}const F=/^[a-z_$][a-z0-9_$:-]*$/i;function D(H,N){const{RULES:L}=this;if((0,l.eachItem)(H,z=>{if(L.keywords[z])throw new Error(`Keyword ${z} is already defined`);if(!F.test(z))throw new Error(`Keyword ${z} has invalid name`)}),!!N&&N.$data&&!("code"in N||"validate"in N))throw new Error('$data keyword must have "code" or "validate" function')}function ae(H,N,L){var z;const k=N?.post;if(L&&k)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:P}=this;let Z=k?P.post:P.rules.find(({type:ne})=>ne===L);if(Z||(Z={type:L,rules:[]},P.rules.push(Z)),P.keywords[H]=!0,!N)return;const ee={keyword:H,definition:{...N,type:(0,u.getJSONTypes)(N.type),schemaType:(0,u.getJSONTypes)(N.schemaType)}};N.before?$e.call(this,Z,ee,N.before):Z.rules.push(ee),P.all[H]=ee,(z=N.implements)===null||z===void 0||z.forEach(ne=>this.addKeyword(ne))}function $e(H,N,L){const z=H.rules.findIndex(k=>k.keyword===L);z>=0?H.rules.splice(z,0,N):(H.rules.push(N),this.logger.warn(`rule ${L} is not defined`))}function xe(H){let{metaSchema:N}=H;N!==void 0&&(H.$data&&this.opts.$data&&(N=mt(N)),H.validateSchema=this.compile(N,!0))}const ge={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function mt(H){return{anyOf:[H,ge]}}})(Hs)),Hs}var pn={},mn={},gn={},To;function df(){if(To)return gn;To=1,Object.defineProperty(gn,"__esModule",{value:!0});const t={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};return gn.default=t,gn}var Rt={},Po;function ff(){if(Po)return Rt;Po=1,Object.defineProperty(Rt,"__esModule",{value:!0}),Rt.callRef=Rt.getValidate=void 0;const t=fn(),e=ut(),r=ie(),n=Et(),s=Xs(),a=fe(),i={keyword:"$ref",schemaType:"string",code(u){const{gen:l,schema:f,it:b}=u,{baseId:v,schemaEnv:g,validateName:w,opts:m,self:S}=b,{root:p}=g;if((f==="#"||f==="#/")&&v===p.baseId)return R();const y=s.resolveRef.call(S,p,v,f);if(y===void 0)throw new t.default(b.opts.uriResolver,v,f);if(y instanceof s.SchemaEnv)return d(y);return h(y);function R(){if(g===p)return c(u,w,g,g.$async);const _=l.scopeValue("root",{ref:p});return c(u,(0,r._)`${_}.validate`,p,p.$async)}function d(_){const E=o(u,_);c(u,E,_,_.$async)}function h(_){const E=l.scopeValue("schema",m.code.source===!0?{ref:_,code:(0,r.stringify)(_)}:{ref:_}),I=l.name("valid"),j=u.subschema({schema:_,dataTypes:[],schemaPath:r.nil,topSchemaRef:E,errSchemaPath:f},I);u.mergeEvaluated(j),u.ok(I)}}};function o(u,l){const{gen:f}=u;return l.validate?f.scopeValue("validate",{ref:l.validate}):(0,r._)`${f.scopeValue("wrapper",{ref:l})}.validate`}Rt.getValidate=o;function c(u,l,f,b){const{gen:v,it:g}=u,{allErrors:w,schemaEnv:m,opts:S}=g,p=S.passContext?n.default.this:r.nil;b?y():R();function y(){if(!m.$async)throw new Error("async schema referenced by sync schema");const _=v.let("valid");v.try(()=>{v.code((0,r._)`await ${(0,e.callValidateCode)(u,l,p)}`),h(l),w||v.assign(_,!0)},E=>{v.if((0,r._)`!(${E} instanceof ${g.ValidationError})`,()=>v.throw(E)),d(E),w||v.assign(_,!1)}),u.ok(_)}function R(){u.result((0,e.callValidateCode)(u,l,p),()=>h(l),()=>d(l))}function d(_){const E=(0,r._)`${_}.errors`;v.assign(n.default.vErrors,(0,r._)`${n.default.vErrors} === null ? ${E} : ${n.default.vErrors}.concat(${E})`),v.assign(n.default.errors,(0,r._)`${n.default.vErrors}.length`)}function h(_){var E;if(!g.opts.unevaluated)return;const I=(E=f?.validate)===null||E===void 0?void 0:E.evaluated;if(g.props!==!0)if(I&&!I.dynamicProps)I.props!==void 0&&(g.props=a.mergeEvaluated.props(v,I.props,g.props));else{const j=v.var("props",(0,r._)`${_}.evaluated.props`);g.props=a.mergeEvaluated.props(v,j,g.props,r.Name)}if(g.items!==!0)if(I&&!I.dynamicItems)I.items!==void 0&&(g.items=a.mergeEvaluated.items(v,I.items,g.items));else{const j=v.var("items",(0,r._)`${_}.evaluated.items`);g.items=a.mergeEvaluated.items(v,j,g.items,r.Name)}}}return Rt.callRef=c,Rt.default=i,Rt}var Co;function hf(){if(Co)return mn;Co=1,Object.defineProperty(mn,"__esModule",{value:!0});const t=df(),e=ff(),r=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",t.default,e.default];return mn.default=r,mn}var _n={},yn={},Io;function pf(){if(Io)return yn;Io=1,Object.defineProperty(yn,"__esModule",{value:!0});const t=ie(),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 yn.default=s,yn}var vn={},Oo;function mf(){if(Oo)return vn;Oo=1,Object.defineProperty(vn,"__esModule",{value:!0});const t=ie(),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,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} = ${a}/${i}, ${l}))`)}};return vn.default=r,vn}var wn={},bn={},No;function gf(){if(No)return bn;No=1,Object.defineProperty(bn,"__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 bn.default=t,t.code='require("ajv/dist/runtime/ucs2length").default',bn}var Ao;function _f(){if(Ao)return wn;Ao=1,Object.defineProperty(wn,"__esModule",{value:!0});const t=ie(),e=fe(),r=gf(),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:u}=a,l=i==="maxLength"?t.operators.GT:t.operators.LT,f=u.opts.unicode===!1?(0,t._)`${o}.length`:(0,t._)`${(0,e.useFunc)(a.gen,r.default)}(${o})`;a.fail$data((0,t._)`${f} ${l} ${c}`)}};return wn.default=s,wn}var Sn={},zo;function yf(){if(zo)return Sn;zo=1,Object.defineProperty(Sn,"__esModule",{value:!0});const t=ut(),e=fe(),r=ie(),s={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:{message:({schemaCode:a})=>(0,r.str)`must match pattern "${a}"`,params:({schemaCode:a})=>(0,r._)`{pattern: ${a}}`},code(a){const{gen:i,data:o,$data:c,schema:u,schemaCode:l,it:f}=a,b=f.opts.unicodeRegExp?"u":"";if(c){const{regExp:v}=f.opts.code,g=v.code==="new RegExp"?(0,r._)`new RegExp`:(0,e.useFunc)(i,v),w=i.let("valid");i.try(()=>i.assign(w,(0,r._)`${g}(${l}, ${b}).test(${o})`),()=>i.assign(w,!1)),a.fail$data((0,r._)`!${w}`)}else{const v=(0,t.usePattern)(a,u);a.fail$data((0,r._)`!${v}.test(${o})`)}}};return Sn.default=s,Sn}var $n={},jo;function vf(){if(jo)return $n;jo=1,Object.defineProperty($n,"__esModule",{value:!0});const t=ie(),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 $n.default=r,$n}var kn={},Mo;function wf(){if(Mo)return kn;Mo=1,Object.defineProperty(kn,"__esModule",{value:!0});const t=ut(),e=ie(),r=fe(),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:u,$data:l,it:f}=a,{opts:b}=f;if(!l&&o.length===0)return;const v=o.length>=b.loopRequired;if(f.allErrors?g():w(),b.strictRequired){const p=a.parentSchema.properties,{definedProperties:y}=a.it;for(const R of o)if(p?.[R]===void 0&&!y.has(R)){const d=f.schemaEnv.baseId+f.errSchemaPath,h=`required property "${R}" is not defined at "${d}" (strictRequired)`;(0,r.checkStrictMode)(f,h,f.opts.strictRequired)}}function g(){if(v||l)a.block$data(e.nil,m);else for(const p of o)(0,t.checkReportMissingProp)(a,p)}function w(){const p=i.let("missing");if(v||l){const y=i.let("valid",!0);a.block$data(y,()=>S(p,y)),a.ok(y)}else i.if((0,t.checkMissingProp)(a,o,p)),(0,t.reportMissingProp)(a,p),i.else()}function m(){i.forOf("prop",c,p=>{a.setParams({missingProperty:p}),i.if((0,t.noPropertyInData)(i,u,p,b.ownProperties),()=>a.error())})}function S(p,y){a.setParams({missingProperty:p}),i.forOf(p,c,()=>{i.assign(y,(0,t.propertyInData)(i,u,p,b.ownProperties)),i.if((0,e.not)(y),()=>{a.error(),i.break()})},e.nil)}}};return kn.default=s,kn}var En={},qo;function bf(){if(qo)return En;qo=1,Object.defineProperty(En,"__esModule",{value:!0});const t=ie(),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 En.default=r,En}var Rn={},Tn={},Zo;function ra(){if(Zo)return Tn;Zo=1,Object.defineProperty(Tn,"__esModule",{value:!0});const t=po();return t.code='require("ajv/dist/runtime/equal").default',Tn.default=t,Tn}var xo;function Sf(){if(xo)return Rn;xo=1,Object.defineProperty(Rn,"__esModule",{value:!0});const t=on(),e=ie(),r=fe(),n=ra(),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:u,schema:l,parentSchema:f,schemaCode:b,it:v}=i;if(!u&&!l)return;const g=o.let("valid"),w=f.items?(0,t.getSchemaTypes)(f.items):[];i.block$data(g,m,(0,e._)`${b} === false`),i.ok(g);function m(){const R=o.let("i",(0,e._)`${c}.length`),d=o.let("j");i.setParams({i:R,j:d}),o.assign(g,!0),o.if((0,e._)`${R} > 1`,()=>(S()?p:y)(R,d))}function S(){return w.length>0&&!w.some(R=>R==="object"||R==="array")}function p(R,d){const h=o.name("item"),_=(0,t.checkDataTypes)(w,h,v.opts.strictNumbers,t.DataType.Wrong),E=o.const("indices",(0,e._)`{}`);o.for((0,e._)`;${R}--;`,()=>{o.let(h,(0,e._)`${c}[${R}]`),o.if(_,(0,e._)`continue`),w.length>1&&o.if((0,e._)`typeof ${h} == "string"`,(0,e._)`${h} += "_"`),o.if((0,e._)`typeof ${E}[${h}] == "number"`,()=>{o.assign(d,(0,e._)`${E}[${h}]`),i.error(),o.assign(g,!1).break()}).code((0,e._)`${E}[${h}] = ${R}`)})}function y(R,d){const h=(0,r.useFunc)(o,n.default),_=o.name("outer");o.label(_).for((0,e._)`;${R}--;`,()=>o.for((0,e._)`${d} = ${R}; ${d}--;`,()=>o.if((0,e._)`${h}(${c}[${R}], ${c}[${d}])`,()=>{i.error(),o.assign(g,!1).break(_)})))}}};return Rn.default=a,Rn}var Pn={},Lo;function $f(){if(Lo)return Pn;Lo=1,Object.defineProperty(Pn,"__esModule",{value:!0});const t=ie(),e=fe(),r=ra(),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:u,schema:l}=a;c||l&&typeof l=="object"?a.fail$data((0,t._)`!${(0,e.useFunc)(i,r.default)}(${o}, ${u})`):a.fail((0,t._)`${l} !== ${o}`)}};return Pn.default=s,Pn}var Cn={},Do;function kf(){if(Do)return Cn;Do=1,Object.defineProperty(Cn,"__esModule",{value:!0});const t=ie(),e=fe(),r=ra(),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:u,schemaCode:l,it:f}=a;if(!c&&u.length===0)throw new Error("enum must have non-empty array");const b=u.length>=f.opts.loopEnum;let v;const g=()=>v??(v=(0,e.useFunc)(i,r.default));let w;if(b||c)w=i.let("valid"),a.block$data(w,m);else{if(!Array.isArray(u))throw new Error("ajv implementation error");const p=i.const("vSchema",l);w=(0,t.or)(...u.map((y,R)=>S(p,R)))}a.pass(w);function m(){i.assign(w,!1),i.forOf("v",l,p=>i.if((0,t._)`${g()}(${o}, ${p})`,()=>i.assign(w,!0).break()))}function S(p,y){const R=u[y];return typeof R=="object"&&R!==null?(0,t._)`${g()}(${o}, ${p}[${y}])`:(0,t._)`${o} === ${R}`}}};return Cn.default=s,Cn}var Uo;function Ef(){if(Uo)return _n;Uo=1,Object.defineProperty(_n,"__esModule",{value:!0});const t=pf(),e=mf(),r=_f(),n=yf(),s=vf(),a=wf(),i=bf(),o=Sf(),c=$f(),u=kf(),l=[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,u.default];return _n.default=l,_n}var In={},er={},Vo;function Fo(){if(Vo)return er;Vo=1,Object.defineProperty(er,"__esModule",{value:!0}),er.validateAdditionalItems=void 0;const t=ie(),e=fe(),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:u,keyword:l,it:f}=a;f.items=!0;const b=o.const("len",(0,t._)`${u}.length`);if(c===!1)a.setParams({len:i.length}),a.pass((0,t._)`${b} <= ${i.length}`);else if(typeof c=="object"&&!(0,e.alwaysValidSchema)(f,c)){const g=o.var("valid",(0,t._)`${b} <= ${i.length}`);o.if((0,t.not)(g),()=>v(g)),a.ok(g)}function v(g){o.forRange("i",i.length,b,w=>{a.subschema({keyword:l,dataProp:w,dataPropType:e.Type.Num},g),f.allErrors||o.if((0,t.not)(g),()=>o.break())})}}return er.validateAdditionalItems=s,er.default=n,er}var On={},tr={},Ho;function Wo(){if(Ho)return tr;Ho=1,Object.defineProperty(tr,"__esModule",{value:!0}),tr.validateTuple=void 0;const t=ie(),e=fe(),r=ut(),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:u,data:l,keyword:f,it:b}=a;w(u),b.opts.unevaluated&&o.length&&b.items!==!0&&(b.items=e.mergeEvaluated.items(c,o.length,b.items));const v=c.name("valid"),g=c.const("len",(0,t._)`${l}.length`);o.forEach((m,S)=>{(0,e.alwaysValidSchema)(b,m)||(c.if((0,t._)`${g} > ${S}`,()=>a.subschema({keyword:f,schemaProp:S,dataProp:S},v)),a.ok(v))});function w(m){const{opts:S,errSchemaPath:p}=b,y=o.length,R=y===m.minItems&&(y===m.maxItems||m[i]===!1);if(S.strictTuples&&!R){const d=`"${f}" is ${y}-tuple, but minItems or maxItems/${i} are not specified or different at path "${p}"`;(0,e.checkStrictMode)(b,d,S.strictTuples)}}}return tr.validateTuple=s,tr.default=n,tr}var Ko;function Rf(){if(Ko)return On;Ko=1,Object.defineProperty(On,"__esModule",{value:!0});const t=Wo(),e={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:r=>(0,t.validateTuple)(r,"items")};return On.default=e,On}var Nn={},Jo;function Tf(){if(Jo)return Nn;Jo=1,Object.defineProperty(Nn,"__esModule",{value:!0});const t=ie(),e=fe(),r=ut(),n=Fo(),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:u}=i,{prefixItems:l}=c;u.items=!0,!(0,e.alwaysValidSchema)(u,o)&&(l?(0,n.validateAdditionalItems)(i,l):i.ok((0,r.validateArray)(i)))}};return Nn.default=a,Nn}var An={},Bo;function Pf(){if(Bo)return An;Bo=1,Object.defineProperty(An,"__esModule",{value:!0});const t=ie(),e=fe(),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:u}=s;let l,f;const{minContains:b,maxContains:v}=o;u.opts.next?(l=b===void 0?1:b,f=v):l=1;const g=a.const("len",(0,t._)`${c}.length`);if(s.setParams({min:l,max:f}),f===void 0&&l===0){(0,e.checkStrictMode)(u,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(f!==void 0&&l>f){(0,e.checkStrictMode)(u,'"minContains" > "maxContains" is always invalid'),s.fail();return}if((0,e.alwaysValidSchema)(u,i)){let y=(0,t._)`${g} >= ${l}`;f!==void 0&&(y=(0,t._)`${y} && ${g} <= ${f}`),s.pass(y);return}u.items=!0;const w=a.name("valid");f===void 0&&l===1?S(w,()=>a.if(w,()=>a.break())):l===0?(a.let(w,!0),f!==void 0&&a.if((0,t._)`${c}.length > 0`,m)):(a.let(w,!1),m()),s.result(w,()=>s.reset());function m(){const y=a.name("_valid"),R=a.let("count",0);S(y,()=>a.if(y,()=>p(R)))}function S(y,R){a.forRange("i",0,g,d=>{s.subschema({keyword:"contains",dataProp:d,dataPropType:e.Type.Num,compositeRule:!0},y),R()})}function p(y){a.code((0,t._)`${y}++`),f===void 0?a.if((0,t._)`${y} >= ${l}`,()=>a.assign(w,!0).break()):(a.if((0,t._)`${y} > ${f}`,()=>a.assign(w,!1).break()),l===1?a.assign(w,!0):a.if((0,t._)`${y} >= ${l}`,()=>a.assign(w,!0)))}}};return An.default=n,An}var na={},Go;function Cf(){return Go||(Go=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.validateSchemaDeps=t.validatePropertyDeps=t.error=void 0;const e=ie(),r=fe(),n=ut();t.error={message:({params:{property:c,depsCount:u,deps:l}})=>{const f=u===1?"property":"properties";return(0,e.str)`must have ${f} ${l} when property ${c} is present`},params:({params:{property:c,depsCount:u,deps:l,missingProperty:f}})=>(0,e._)`{property: ${c},
6
+ missingProperty: ${f},
7
7
  depsCount: ${u},
8
- deps: ${l}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(c){const[u,l]=a(c);i(c,u),o(c,l)}};function a({schema:c}){const u={},l={};for(const h in c){if(h==="__proto__")continue;const g=Array.isArray(c[h])?u:l;g[h]=c[h]}return[u,l]}function i(c,u=c.schema){const{gen:l,data:h,it:g}=c;if(Object.keys(u).length===0)return;const _=l.let("missing");for(const p in u){const y=u[p];if(y.length===0)continue;const f=(0,n.propertyInData)(l,h,p,g.opts.ownProperties);c.setParams({property:p,depsCount:y.length,deps:y.join(", ")}),g.allErrors?l.if(f,()=>{for(const w of y)(0,n.checkReportMissingProp)(c,w)}):(l.if((0,e._)`${f} && (${(0,n.checkMissingProp)(c,y,_)})`),(0,n.reportMissingProp)(c,_),l.else())}}t.validatePropertyDeps=i;function o(c,u=c.schema){const{gen:l,data:h,keyword:g,it:_}=c,p=l.name("valid");for(const y in u)(0,r.alwaysValidSchema)(_,u[y])||(l.if((0,n.propertyInData)(l,h,y,_.opts.ownProperties),()=>{const f=c.subschema({keyword:g,schemaProp:y},p);c.mergeValidEvaluated(f,p)},()=>l.var(p,!0)),c.ok(p))}t.validateSchemaDeps=o,t.default=s})(ra)),ra}var An={},Go;function Rf(){if(Go)return An;Go=1,Object.defineProperty(An,"__esModule",{value:!0});const t=ae(),e=de(),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 u=a.name("valid");a.forIn("key",o,l=>{s.setParams({propertyName:l}),s.subschema({keyword:"propertyNames",data:l,dataTypes:["string"],propertyName:l,compositeRule:!0},u),a.if((0,t.not)(u),()=>{s.error(!0),c.allErrors||a.break()})}),s.ok(u)}};return An.default=n,An}var jn={},Bo;function Yo(){if(Bo)return jn;Bo=1,Object.defineProperty(jn,"__esModule",{value:!0});const t=ut(),e=ae(),r=Et(),n=de(),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:u,data:l,errsCount:h,it:g}=i;if(!h)throw new Error("ajv implementation error");const{allErrors:_,opts:p}=g;if(g.props=!0,p.removeAdditional!=="all"&&(0,n.alwaysValidSchema)(g,c))return;const y=(0,t.allSchemaProperties)(u.properties),f=(0,t.allSchemaProperties)(u.patternProperties);w(),i.ok((0,e._)`${h} === ${r.default.errors}`);function w(){o.forIn("key",l,$=>{!y.length&&!f.length?b($):o.if(d($),()=>b($))})}function d($){let E;if(y.length>8){const N=(0,n.schemaRefOrVal)(g,u.properties,"properties");E=(0,t.isOwnProperty)(o,N,$)}else y.length?E=(0,e.or)(...y.map(N=>(0,e._)`${$} === ${N}`)):E=e.nil;return f.length&&(E=(0,e.or)(E,...f.map(N=>(0,e._)`${(0,t.usePattern)(i,N)}.test(${$})`))),(0,e.not)(E)}function m($){o.code((0,e._)`delete ${l}[${$}]`)}function b($){if(p.removeAdditional==="all"||p.removeAdditional&&c===!1){m($);return}if(c===!1){i.setParams({additionalProperty:$}),i.error(),_||o.break();return}if(typeof c=="object"&&!(0,n.alwaysValidSchema)(g,c)){const E=o.name("valid");p.removeAdditional==="failing"?(v($,E,!1),o.if((0,e.not)(E),()=>{i.reset(),m($)})):(v($,E),_||o.if((0,e.not)(E),()=>o.break()))}}function v($,E,N){const L={keyword:"additionalProperties",dataProp:$,dataPropType:n.Type.Str};N===!1&&Object.assign(L,{compositeRule:!0,createErrors:!1,allErrors:!1}),i.subschema(L,E)}}};return jn.default=a,jn}var zn={},Qo;function Tf(){if(Qo)return zn;Qo=1,Object.defineProperty(zn,"__esModule",{value:!0});const t=cn(),e=ut(),r=de(),n=Yo(),s={keyword:"properties",type:"object",schemaType:"object",code(a){const{gen:i,schema:o,parentSchema:c,data:u,it:l}=a;l.opts.removeAdditional==="all"&&c.additionalProperties===void 0&&n.default.code(new t.KeywordCxt(l,n.default,"additionalProperties"));const h=(0,e.allSchemaProperties)(o);for(const f of h)l.definedProperties.add(f);l.opts.unevaluated&&h.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(i,(0,r.toHash)(h),l.props));const g=h.filter(f=>!(0,r.alwaysValidSchema)(l,o[f]));if(g.length===0)return;const _=i.name("valid");for(const f of g)p(f)?y(f):(i.if((0,e.propertyInData)(i,u,f,l.opts.ownProperties)),y(f),l.allErrors||i.else().var(_,!0),i.endIf()),a.it.definedProperties.add(f),a.ok(_);function p(f){return l.opts.useDefaults&&!l.compositeRule&&o[f].default!==void 0}function y(f){a.subschema({keyword:"properties",schemaProp:f,dataProp:f},_)}}};return zn.default=s,zn}var Mn={},Xo;function Pf(){if(Xo)return Mn;Xo=1,Object.defineProperty(Mn,"__esModule",{value:!0});const t=ut(),e=ae(),r=de(),n=de(),s={keyword:"patternProperties",type:"object",schemaType:"object",code(a){const{gen:i,schema:o,data:c,parentSchema:u,it:l}=a,{opts:h}=l,g=(0,t.allSchemaProperties)(o),_=g.filter(b=>(0,r.alwaysValidSchema)(l,o[b]));if(g.length===0||_.length===g.length&&(!l.opts.unevaluated||l.props===!0))return;const p=h.strictSchema&&!h.allowMatchingProperties&&u.properties,y=i.name("valid");l.props!==!0&&!(l.props instanceof e.Name)&&(l.props=(0,n.evaluatedPropsToName)(i,l.props));const{props:f}=l;w();function w(){for(const b of g)p&&d(b),l.allErrors?m(b):(i.var(y,!0),m(b),i.if(y))}function d(b){for(const v in p)new RegExp(b).test(v)&&(0,r.checkStrictMode)(l,`property ${v} matches pattern ${b} (use allowMatchingProperties)`)}function m(b){i.forIn("key",c,v=>{i.if((0,e._)`${(0,t.usePattern)(a,b)}.test(${v})`,()=>{const $=_.includes(b);$||a.subschema({keyword:"patternProperties",schemaProp:b,dataProp:v,dataPropType:n.Type.Str},y),l.opts.unevaluated&&f!==!0?i.assign((0,e._)`${f}[${v}]`,!0):!$&&!l.allErrors&&i.if((0,e.not)(y),()=>i.break())})})}}};return Mn.default=s,Mn}var qn={},ec;function Cf(){if(ec)return qn;ec=1,Object.defineProperty(qn,"__esModule",{value:!0});const t=de(),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 qn.default=e,qn}var Zn={},tc;function If(){if(tc)return Zn;tc=1,Object.defineProperty(Zn,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ut().validateUnion,error:{message:"must match a schema in anyOf"}};return Zn.default=e,Zn}var Ln={},rc;function Of(){if(rc)return Ln;rc=1,Object.defineProperty(Ln,"__esModule",{value:!0});const t=ae(),e=de(),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 u=i,l=a.let("valid",!1),h=a.let("passing",null),g=a.name("_valid");s.setParams({passing:h}),a.block(_),s.result(l,()=>s.reset(),()=>s.error(!0));function _(){u.forEach((p,y)=>{let f;(0,e.alwaysValidSchema)(c,p)?a.var(g,!0):f=s.subschema({keyword:"oneOf",schemaProp:y,compositeRule:!0},g),y>0&&a.if((0,t._)`${g} && ${l}`).assign(l,!1).assign(h,(0,t._)`[${h}, ${y}]`).else(),a.if(g,()=>{a.assign(l,!0),a.assign(h,y),f&&s.mergeEvaluated(f,t.Name)})})}}};return Ln.default=n,Ln}var xn={},nc;function Nf(){if(nc)return xn;nc=1,Object.defineProperty(xn,"__esModule",{value:!0});const t=de(),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 u=r.subschema({keyword:"allOf",schemaProp:c},i);r.ok(i),r.mergeEvaluated(u)})}};return xn.default=e,xn}var Dn={},sc;function Af(){if(sc)return Dn;sc=1,Object.defineProperty(Dn,"__esModule",{value:!0});const t=ae(),e=de(),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 u=s(c,"then"),l=s(c,"else");if(!u&&!l)return;const h=i.let("valid",!0),g=i.name("_valid");if(_(),a.reset(),u&&l){const y=i.let("ifClause");a.setParams({ifClause:y}),i.if(g,p("then",y),p("else",y))}else u?i.if(g,p("then")):i.if((0,t.not)(g),p("else"));a.pass(h,()=>a.error(!0));function _(){const y=a.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},g);a.mergeEvaluated(y)}function p(y,f){return()=>{const w=a.subschema({keyword:y},g);i.assign(h,g),a.mergeValidEvaluated(w,h),f?i.assign(f,(0,t._)`${y}`):a.setParams({ifClause:y})}}}};function s(a,i){const o=a.schema[i];return o!==void 0&&!(0,e.alwaysValidSchema)(a,o)}return Dn.default=n,Dn}var Un={},ac;function jf(){if(ac)return Un;ac=1,Object.defineProperty(Un,"__esModule",{value:!0});const t=de(),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 Un.default=e,Un}var ic;function zf(){if(ic)return Cn;ic=1,Object.defineProperty(Cn,"__esModule",{value:!0});const t=Uo(),e=Sf(),r=Fo(),n=kf(),s=$f(),a=Ef(),i=Rf(),o=Yo(),c=Tf(),u=Pf(),l=Cf(),h=If(),g=Of(),_=Nf(),p=Af(),y=jf();function f(w=!1){const d=[l.default,h.default,g.default,_.default,p.default,y.default,i.default,o.default,a.default,c.default,u.default];return w?d.push(e.default,n.default):d.push(t.default,r.default),d.push(s.default),d}return Cn.default=f,Cn}var Vn={},Fn={},oc;function Mf(){if(oc)return Fn;oc=1,Object.defineProperty(Fn,"__esModule",{value:!0});const t=ae(),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:u,it:l}=n,{opts:h,errSchemaPath:g,schemaEnv:_,self:p}=l;if(!h.validateFormats)return;o?y():f();function y(){const w=a.scopeValue("formats",{ref:p.formats,code:h.code.formats}),d=a.const("fDef",(0,t._)`${w}[${u}]`),m=a.let("fType"),b=a.let("format");a.if((0,t._)`typeof ${d} == "object" && !(${d} instanceof RegExp)`,()=>a.assign(m,(0,t._)`${d}.type || "string"`).assign(b,(0,t._)`${d}.validate`),()=>a.assign(m,(0,t._)`"string"`).assign(b,d)),n.fail$data((0,t.or)(v(),$()));function v(){return h.strictSchema===!1?t.nil:(0,t._)`${u} && !${b}`}function $(){const E=_.$async?(0,t._)`(${d}.async ? await ${b}(${i}) : ${b}(${i}))`:(0,t._)`${b}(${i})`,N=(0,t._)`(typeof ${b} == "function" ? ${E} : ${b}.test(${i}))`;return(0,t._)`${b} && ${b} !== true && ${m} === ${s} && !${N}`}}function f(){const w=p.formats[c];if(!w){v();return}if(w===!0)return;const[d,m,b]=$(w);d===s&&n.pass(E());function v(){if(h.strictSchema===!1){p.logger.warn(N());return}throw new Error(N());function N(){return`unknown format "${c}" ignored in schema at path "${g}"`}}function $(N){const L=N instanceof RegExp?(0,t.regexpCode)(N):h.code.formats?(0,t._)`${h.code.formats}${(0,t.getProperty)(c)}`:void 0,K=a.scopeValue("formats",{key:c,ref:N,code:L});return typeof N=="object"&&!(N instanceof RegExp)?[N.type||"string",N.validate,(0,t._)`${K}.validate`]:["string",N,K]}function E(){if(typeof w=="object"&&!(w instanceof RegExp)&&w.async){if(!_.$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 Fn.default=r,Fn}var cc;function qf(){if(cc)return Vn;cc=1,Object.defineProperty(Vn,"__esModule",{value:!0});const e=[Mf().default];return Vn.default=e,Vn}var xt={},uc;function Zf(){return uc||(uc=1,Object.defineProperty(xt,"__esModule",{value:!0}),xt.contentVocabulary=xt.metadataVocabulary=void 0,xt.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],xt.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),xt}var lc;function Lf(){if(lc)return hn;lc=1,Object.defineProperty(hn,"__esModule",{value:!0});const t=uf(),e=bf(),r=zf(),n=qf(),s=Zf(),a=[t.default,e.default,(0,r.default)(),n.default,s.metadataVocabulary,s.contentVocabulary];return hn.default=a,hn}var Hn={},$r={},dc;function xf(){if(dc)return $r;dc=1,Object.defineProperty($r,"__esModule",{value:!0}),$r.DiscrError=void 0;var t;return(function(e){e.Tag="tag",e.Mapping="mapping"})(t||($r.DiscrError=t={})),$r}var fc;function Df(){if(fc)return Hn;fc=1,Object.defineProperty(Hn,"__esModule",{value:!0});const t=ae(),e=xf(),r=Qs(),n=dn(),s=de(),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:u}})=>(0,t._)`{error: ${o}, tag: ${u}, tagValue: ${c}}`},code(o){const{gen:c,data:u,schema:l,parentSchema:h,it:g}=o,{oneOf:_}=h;if(!g.opts.discriminator)throw new Error("discriminator: requires discriminator option");const p=l.propertyName;if(typeof p!="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 y=c.let("valid",!1),f=c.const("tag",(0,t._)`${u}${(0,t.getProperty)(p)}`);c.if((0,t._)`typeof ${f} == "string"`,()=>w(),()=>o.error(!1,{discrError:e.DiscrError.Tag,tag:f,tagName:p})),o.ok(y);function w(){const b=m();c.if(!1);for(const v in b)c.elseIf((0,t._)`${f} === ${v}`),c.assign(y,d(b[v]));c.else(),o.error(!1,{discrError:e.DiscrError.Mapping,tag:f,tagName:p}),c.endIf()}function d(b){const v=c.name("valid"),$=o.subschema({keyword:"oneOf",schemaProp:b},v);return o.mergeEvaluated($,t.Name),v}function m(){var b;const v={},$=N(h);let E=!0;for(let z=0;z<_.length;z++){let F=_[z];if(F?.$ref&&!(0,s.schemaHasRulesButRef)(F,g.self.RULES)){const Y=F.$ref;if(F=r.resolveRef.call(g.self,g.schemaEnv.root,g.baseId,Y),F instanceof r.SchemaEnv&&(F=F.schema),F===void 0)throw new n.default(g.opts.uriResolver,g.baseId,Y)}const G=(b=F?.properties)===null||b===void 0?void 0:b[p];if(typeof G!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${p}"`);E=E&&($||N(F)),L(G,z)}if(!E)throw new Error(`discriminator: "${p}" must be required`);return v;function N({required:z}){return Array.isArray(z)&&z.includes(p)}function L(z,F){if(z.const)K(z.const,F);else if(z.enum)for(const G of z.enum)K(G,F);else throw new Error(`discriminator: "properties/${p}" must have "const" or "enum"`)}function K(z,F){if(typeof z!="string"||z in v)throw new Error(`discriminator: "${p}" values must be unique strings`);v[z]=F}}}};return Hn.default=i,Hn}const Uf={$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 hc;function pc(){return hc||(hc=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=af(),n=Lf(),s=Df(),a=Uf,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 u=cn();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var l=ae();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 h=Ys();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return h.default}});var g=dn();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return g.default}})})(tn,tn.exports)),tn.exports}var Vf=pc();const mc=Qt(Vf),Ff=Object.freeze({status:"aborted"});function A(t,e,r){function n(o,c){var u;Object.defineProperty(o,"_zod",{value:o._zod??{},enumerable:!1}),(u=o._zod).traits??(u.traits=new Set),o._zod.traits.add(t),e(o,c);for(const l in i.prototype)l in o||Object.defineProperty(o,l,{value:i.prototype[l].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 u=r?.Parent?new a:this;n(u,o),(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:o=>r?.Parent&&o instanceof r.Parent?!0:o?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}class Er extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const _c={};function Tt(t){return _c}function gc(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 Hf(t,e){return typeof e=="bigint"?e.toString():e}function na(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function sa(t){return t==null}function aa(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Wf(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 Se(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 Rr(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Tr(t){return JSON.stringify(t)}const yc=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Wn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const Kf=na(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Kn(t){if(Wn(t)===!1)return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(Wn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const Jf=new Set(["string","number","symbol"]);function Pr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pt(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 Gf(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const Bf={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 Yf(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 Pt(t,{...t._zod.def,shape:r,checks:[]})}function Qf(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 Pt(t,{...t._zod.def,shape:r,checks:[]})}function Xf(t,e){if(!Kn(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 Rr(this,"shape",n),n},checks:[]};return Pt(t,r)}function eh(t,e){return Pt(t,{...t._zod.def,get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Rr(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function th(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 Pt(e,{...e._zod.def,shape:s,checks:[]})}function rh(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 Pt(e,{...e._zod.def,shape:s,checks:[]})}function Cr(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Dt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Jn(t){return typeof t=="string"?t:t?.message}function Ct(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=Jn(t.inst?._zod.def?.error?.(t))??Jn(e?.error?.(t))??Jn(r.customError?.(t))??Jn(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function ia(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Ir(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const vc=(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,Hf,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},wc=A("$ZodError",vc),Gn=A("$ZodError",vc,{Parent:Error});function nh(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 sh(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 u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(r(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(t),n}const bc=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 Er;if(i.issues.length){const o=new(s?.Err??t)(i.issues.map(c=>Ct(c,a,Tt())));throw yc(o,s?.callee),o}return i.value},ah=bc(Gn),Sc=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=>Ct(c,a,Tt())));throw yc(o,s?.callee),o}return i.value},ih=Sc(Gn),kc=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 Er;return a.issues.length?{success:!1,error:new(t??wc)(a.issues.map(i=>Ct(i,s,Tt())))}:{success:!0,data:a.value}},oa=kc(Gn),$c=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=>Ct(i,s,Tt())))}:{success:!0,data:a.value}},ca=$c(Gn),oh=/^[cC][^\s-]{8,}$/,ch=/^[0-9a-z]+$/,uh=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,lh=/^[0-9a-vA-V]{20}$/,dh=/^[A-Za-z0-9]{27}$/,fh=/^[a-zA-Z0-9_-]{21}$/,hh=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ph=/^([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})$/,Ec=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)$/,mh=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,_h="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function gh(){return new RegExp(_h,"u")}const yh=/^(?:(?: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])$/,vh=/^(([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})$/,wh=/^((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])$/,bh=/^(([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])$/,Sh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Rc=/^[A-Za-z0-9_-]*$/,kh=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,$h=/^\+(?:[0-9]){6,14}[0-9]$/,Tc="(?:(?:\\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])))",Eh=new RegExp(`^${Tc}$`);function Pc(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 Rh(t){return new RegExp(`^${Pc(t)}$`)}function Th(t){const e=Pc({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(`^${Tc}T(?:${n})$`)}const Ph=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Ch=/^\d+$/,Ih=/^-?\d+(?:\.\d+)?/i,Oh=/true|false/i,Nh=/null/i,Ah=/^[^A-Z]*$/,jh=/^[^a-z]*$/,Je=A("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Cc={number:"number",bigint:"bigint",object:"date"},Ic=A("$ZodCheckLessThan",(t,e)=>{Je.init(t,e);const r=Cc[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})}}),Oc=A("$ZodCheckGreaterThan",(t,e)=>{Je.init(t,e);const r=Cc[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})}}),zh=A("$ZodCheckMultipleOf",(t,e)=>{Je.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):Wf(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})}}),Mh=A("$ZodCheckNumberFormat",(t,e)=>{Je.init(t,e),e.format=e.format||"float64";const r=e.format?.includes("int"),n=r?"int":"number",[s,a]=Bf[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=Ch)}),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})}}),qh=A("$ZodCheckMaxLength",(t,e)=>{var r;Je.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!sa(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=ia(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Zh=A("$ZodCheckMinLength",(t,e)=>{var r;Je.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!sa(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=ia(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Lh=A("$ZodCheckLengthEquals",(t,e)=>{var r;Je.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!sa(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=ia(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})}}),Bn=A("$ZodCheckStringFormat",(t,e)=>{var r,n;Je.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=()=>{})}),xh=A("$ZodCheckRegex",(t,e)=>{Bn.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})}}),Dh=A("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Ah),Bn.init(t,e)}),Uh=A("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=jh),Bn.init(t,e)}),Vh=A("$ZodCheckIncludes",(t,e)=>{Je.init(t,e);const r=Pr(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})}}),Fh=A("$ZodCheckStartsWith",(t,e)=>{Je.init(t,e);const r=new RegExp(`^${Pr(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})}}),Hh=A("$ZodCheckEndsWith",(t,e)=>{Je.init(t,e);const r=new RegExp(`.*${Pr(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})}}),Wh=A("$ZodCheckOverwrite",(t,e)=>{Je.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class Kh{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(`
8
+ deps: ${l}}`};const s={keyword:"dependencies",type:"object",schemaType:"object",error:t.error,code(c){const[u,l]=a(c);i(c,u),o(c,l)}};function a({schema:c}){const u={},l={};for(const f in c){if(f==="__proto__")continue;const b=Array.isArray(c[f])?u:l;b[f]=c[f]}return[u,l]}function i(c,u=c.schema){const{gen:l,data:f,it:b}=c;if(Object.keys(u).length===0)return;const v=l.let("missing");for(const g in u){const w=u[g];if(w.length===0)continue;const m=(0,n.propertyInData)(l,f,g,b.opts.ownProperties);c.setParams({property:g,depsCount:w.length,deps:w.join(", ")}),b.allErrors?l.if(m,()=>{for(const S of w)(0,n.checkReportMissingProp)(c,S)}):(l.if((0,e._)`${m} && (${(0,n.checkMissingProp)(c,w,v)})`),(0,n.reportMissingProp)(c,v),l.else())}}t.validatePropertyDeps=i;function o(c,u=c.schema){const{gen:l,data:f,keyword:b,it:v}=c,g=l.name("valid");for(const w in u)(0,r.alwaysValidSchema)(v,u[w])||(l.if((0,n.propertyInData)(l,f,w,v.opts.ownProperties),()=>{const m=c.subschema({keyword:b,schemaProp:w},g);c.mergeValidEvaluated(m,g)},()=>l.var(g,!0)),c.ok(g))}t.validateSchemaDeps=o,t.default=s})(na)),na}var zn={},Yo;function If(){if(Yo)return zn;Yo=1,Object.defineProperty(zn,"__esModule",{value:!0});const t=ie(),e=fe(),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 u=a.name("valid");a.forIn("key",o,l=>{s.setParams({propertyName:l}),s.subschema({keyword:"propertyNames",data:l,dataTypes:["string"],propertyName:l,compositeRule:!0},u),a.if((0,t.not)(u),()=>{s.error(!0),c.allErrors||a.break()})}),s.ok(u)}};return zn.default=n,zn}var jn={},Qo;function Xo(){if(Qo)return jn;Qo=1,Object.defineProperty(jn,"__esModule",{value:!0});const t=ut(),e=ie(),r=Et(),n=fe(),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:u,data:l,errsCount:f,it:b}=i;if(!f)throw new Error("ajv implementation error");const{allErrors:v,opts:g}=b;if(b.props=!0,g.removeAdditional!=="all"&&(0,n.alwaysValidSchema)(b,c))return;const w=(0,t.allSchemaProperties)(u.properties),m=(0,t.allSchemaProperties)(u.patternProperties);S(),i.ok((0,e._)`${f} === ${r.default.errors}`);function S(){o.forIn("key",l,h=>{!w.length&&!m.length?R(h):o.if(p(h),()=>R(h))})}function p(h){let _;if(w.length>8){const E=(0,n.schemaRefOrVal)(b,u.properties,"properties");_=(0,t.isOwnProperty)(o,E,h)}else w.length?_=(0,e.or)(...w.map(E=>(0,e._)`${h} === ${E}`)):_=e.nil;return m.length&&(_=(0,e.or)(_,...m.map(E=>(0,e._)`${(0,t.usePattern)(i,E)}.test(${h})`))),(0,e.not)(_)}function y(h){o.code((0,e._)`delete ${l}[${h}]`)}function R(h){if(g.removeAdditional==="all"||g.removeAdditional&&c===!1){y(h);return}if(c===!1){i.setParams({additionalProperty:h}),i.error(),v||o.break();return}if(typeof c=="object"&&!(0,n.alwaysValidSchema)(b,c)){const _=o.name("valid");g.removeAdditional==="failing"?(d(h,_,!1),o.if((0,e.not)(_),()=>{i.reset(),y(h)})):(d(h,_),v||o.if((0,e.not)(_),()=>o.break()))}}function d(h,_,E){const I={keyword:"additionalProperties",dataProp:h,dataPropType:n.Type.Str};E===!1&&Object.assign(I,{compositeRule:!0,createErrors:!1,allErrors:!1}),i.subschema(I,_)}}};return jn.default=a,jn}var Mn={},ec;function Of(){if(ec)return Mn;ec=1,Object.defineProperty(Mn,"__esModule",{value:!0});const t=un(),e=ut(),r=fe(),n=Xo(),s={keyword:"properties",type:"object",schemaType:"object",code(a){const{gen:i,schema:o,parentSchema:c,data:u,it:l}=a;l.opts.removeAdditional==="all"&&c.additionalProperties===void 0&&n.default.code(new t.KeywordCxt(l,n.default,"additionalProperties"));const f=(0,e.allSchemaProperties)(o);for(const m of f)l.definedProperties.add(m);l.opts.unevaluated&&f.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(i,(0,r.toHash)(f),l.props));const b=f.filter(m=>!(0,r.alwaysValidSchema)(l,o[m]));if(b.length===0)return;const v=i.name("valid");for(const m of b)g(m)?w(m):(i.if((0,e.propertyInData)(i,u,m,l.opts.ownProperties)),w(m),l.allErrors||i.else().var(v,!0),i.endIf()),a.it.definedProperties.add(m),a.ok(v);function g(m){return l.opts.useDefaults&&!l.compositeRule&&o[m].default!==void 0}function w(m){a.subschema({keyword:"properties",schemaProp:m,dataProp:m},v)}}};return Mn.default=s,Mn}var qn={},tc;function Nf(){if(tc)return qn;tc=1,Object.defineProperty(qn,"__esModule",{value:!0});const t=ut(),e=ie(),r=fe(),n=fe(),s={keyword:"patternProperties",type:"object",schemaType:"object",code(a){const{gen:i,schema:o,data:c,parentSchema:u,it:l}=a,{opts:f}=l,b=(0,t.allSchemaProperties)(o),v=b.filter(R=>(0,r.alwaysValidSchema)(l,o[R]));if(b.length===0||v.length===b.length&&(!l.opts.unevaluated||l.props===!0))return;const g=f.strictSchema&&!f.allowMatchingProperties&&u.properties,w=i.name("valid");l.props!==!0&&!(l.props instanceof e.Name)&&(l.props=(0,n.evaluatedPropsToName)(i,l.props));const{props:m}=l;S();function S(){for(const R of b)g&&p(R),l.allErrors?y(R):(i.var(w,!0),y(R),i.if(w))}function p(R){for(const d in g)new RegExp(R).test(d)&&(0,r.checkStrictMode)(l,`property ${d} matches pattern ${R} (use allowMatchingProperties)`)}function y(R){i.forIn("key",c,d=>{i.if((0,e._)`${(0,t.usePattern)(a,R)}.test(${d})`,()=>{const h=v.includes(R);h||a.subschema({keyword:"patternProperties",schemaProp:R,dataProp:d,dataPropType:n.Type.Str},w),l.opts.unevaluated&&m!==!0?i.assign((0,e._)`${m}[${d}]`,!0):!h&&!l.allErrors&&i.if((0,e.not)(w),()=>i.break())})})}}};return qn.default=s,qn}var Zn={},rc;function Af(){if(rc)return Zn;rc=1,Object.defineProperty(Zn,"__esModule",{value:!0});const t=fe(),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 Zn.default=e,Zn}var xn={},nc;function zf(){if(nc)return xn;nc=1,Object.defineProperty(xn,"__esModule",{value:!0});const e={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ut().validateUnion,error:{message:"must match a schema in anyOf"}};return xn.default=e,xn}var Ln={},sc;function jf(){if(sc)return Ln;sc=1,Object.defineProperty(Ln,"__esModule",{value:!0});const t=ie(),e=fe(),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 u=i,l=a.let("valid",!1),f=a.let("passing",null),b=a.name("_valid");s.setParams({passing:f}),a.block(v),s.result(l,()=>s.reset(),()=>s.error(!0));function v(){u.forEach((g,w)=>{let m;(0,e.alwaysValidSchema)(c,g)?a.var(b,!0):m=s.subschema({keyword:"oneOf",schemaProp:w,compositeRule:!0},b),w>0&&a.if((0,t._)`${b} && ${l}`).assign(l,!1).assign(f,(0,t._)`[${f}, ${w}]`).else(),a.if(b,()=>{a.assign(l,!0),a.assign(f,w),m&&s.mergeEvaluated(m,t.Name)})})}}};return Ln.default=n,Ln}var Dn={},ac;function Mf(){if(ac)return Dn;ac=1,Object.defineProperty(Dn,"__esModule",{value:!0});const t=fe(),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 u=r.subschema({keyword:"allOf",schemaProp:c},i);r.ok(i),r.mergeEvaluated(u)})}};return Dn.default=e,Dn}var Un={},ic;function qf(){if(ic)return Un;ic=1,Object.defineProperty(Un,"__esModule",{value:!0});const t=ie(),e=fe(),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 u=s(c,"then"),l=s(c,"else");if(!u&&!l)return;const f=i.let("valid",!0),b=i.name("_valid");if(v(),a.reset(),u&&l){const w=i.let("ifClause");a.setParams({ifClause:w}),i.if(b,g("then",w),g("else",w))}else u?i.if(b,g("then")):i.if((0,t.not)(b),g("else"));a.pass(f,()=>a.error(!0));function v(){const w=a.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},b);a.mergeEvaluated(w)}function g(w,m){return()=>{const S=a.subschema({keyword:w},b);i.assign(f,b),a.mergeValidEvaluated(S,f),m?i.assign(m,(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 Un.default=n,Un}var Vn={},oc;function Zf(){if(oc)return Vn;oc=1,Object.defineProperty(Vn,"__esModule",{value:!0});const t=fe(),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 Vn.default=e,Vn}var cc;function xf(){if(cc)return In;cc=1,Object.defineProperty(In,"__esModule",{value:!0});const t=Fo(),e=Rf(),r=Wo(),n=Tf(),s=Pf(),a=Cf(),i=If(),o=Xo(),c=Of(),u=Nf(),l=Af(),f=zf(),b=jf(),v=Mf(),g=qf(),w=Zf();function m(S=!1){const p=[l.default,f.default,b.default,v.default,g.default,w.default,i.default,o.default,a.default,c.default,u.default];return S?p.push(e.default,n.default):p.push(t.default,r.default),p.push(s.default),p}return In.default=m,In}var Fn={},Hn={},uc;function Lf(){if(uc)return Hn;uc=1,Object.defineProperty(Hn,"__esModule",{value:!0});const t=ie(),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:u,it:l}=n,{opts:f,errSchemaPath:b,schemaEnv:v,self:g}=l;if(!f.validateFormats)return;o?w():m();function w(){const S=a.scopeValue("formats",{ref:g.formats,code:f.code.formats}),p=a.const("fDef",(0,t._)`${S}[${u}]`),y=a.let("fType"),R=a.let("format");a.if((0,t._)`typeof ${p} == "object" && !(${p} instanceof RegExp)`,()=>a.assign(y,(0,t._)`${p}.type || "string"`).assign(R,(0,t._)`${p}.validate`),()=>a.assign(y,(0,t._)`"string"`).assign(R,p)),n.fail$data((0,t.or)(d(),h()));function d(){return f.strictSchema===!1?t.nil:(0,t._)`${u} && !${R}`}function h(){const _=v.$async?(0,t._)`(${p}.async ? await ${R}(${i}) : ${R}(${i}))`:(0,t._)`${R}(${i})`,E=(0,t._)`(typeof ${R} == "function" ? ${_} : ${R}.test(${i}))`;return(0,t._)`${R} && ${R} !== true && ${y} === ${s} && !${E}`}}function m(){const S=g.formats[c];if(!S){d();return}if(S===!0)return;const[p,y,R]=h(S);p===s&&n.pass(_());function d(){if(f.strictSchema===!1){g.logger.warn(E());return}throw new Error(E());function E(){return`unknown format "${c}" ignored in schema at path "${b}"`}}function h(E){const I=E instanceof RegExp?(0,t.regexpCode)(E):f.code.formats?(0,t._)`${f.code.formats}${(0,t.getProperty)(c)}`:void 0,j=a.scopeValue("formats",{key:c,ref:E,code:I});return typeof E=="object"&&!(E instanceof RegExp)?[E.type||"string",E.validate,(0,t._)`${j}.validate`]:["string",E,j]}function _(){if(typeof S=="object"&&!(S instanceof RegExp)&&S.async){if(!v.$async)throw new Error("async format in sync schema");return(0,t._)`await ${R}(${i})`}return typeof y=="function"?(0,t._)`${R}(${i})`:(0,t._)`${R}.test(${i})`}}}};return Hn.default=r,Hn}var lc;function Df(){if(lc)return Fn;lc=1,Object.defineProperty(Fn,"__esModule",{value:!0});const e=[Lf().default];return Fn.default=e,Fn}var Lt={},dc;function Uf(){return dc||(dc=1,Object.defineProperty(Lt,"__esModule",{value:!0}),Lt.contentVocabulary=Lt.metadataVocabulary=void 0,Lt.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"],Lt.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]),Lt}var fc;function Vf(){if(fc)return pn;fc=1,Object.defineProperty(pn,"__esModule",{value:!0});const t=hf(),e=Ef(),r=xf(),n=Df(),s=Uf(),a=[t.default,e.default,(0,r.default)(),n.default,s.metadataVocabulary,s.contentVocabulary];return pn.default=a,pn}var Wn={},Er={},hc;function Ff(){if(hc)return Er;hc=1,Object.defineProperty(Er,"__esModule",{value:!0}),Er.DiscrError=void 0;var t;return(function(e){e.Tag="tag",e.Mapping="mapping"})(t||(Er.DiscrError=t={})),Er}var pc;function Hf(){if(pc)return Wn;pc=1,Object.defineProperty(Wn,"__esModule",{value:!0});const t=ie(),e=Ff(),r=Xs(),n=fn(),s=fe(),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:u}})=>(0,t._)`{error: ${o}, tag: ${u}, tagValue: ${c}}`},code(o){const{gen:c,data:u,schema:l,parentSchema:f,it:b}=o,{oneOf:v}=f;if(!b.opts.discriminator)throw new Error("discriminator: requires discriminator option");const g=l.propertyName;if(typeof g!="string")throw new Error("discriminator: requires propertyName");if(l.mapping)throw new Error("discriminator: mapping is not supported");if(!v)throw new Error("discriminator: requires oneOf keyword");const w=c.let("valid",!1),m=c.const("tag",(0,t._)`${u}${(0,t.getProperty)(g)}`);c.if((0,t._)`typeof ${m} == "string"`,()=>S(),()=>o.error(!1,{discrError:e.DiscrError.Tag,tag:m,tagName:g})),o.ok(w);function S(){const R=y();c.if(!1);for(const d in R)c.elseIf((0,t._)`${m} === ${d}`),c.assign(w,p(R[d]));c.else(),o.error(!1,{discrError:e.DiscrError.Mapping,tag:m,tagName:g}),c.endIf()}function p(R){const d=c.name("valid"),h=o.subschema({keyword:"oneOf",schemaProp:R},d);return o.mergeEvaluated(h,t.Name),d}function y(){var R;const d={},h=E(f);let _=!0;for(let C=0;C<v.length;C++){let M=v[C];if(M?.$ref&&!(0,s.schemaHasRulesButRef)(M,b.self.RULES)){const D=M.$ref;if(M=r.resolveRef.call(b.self,b.schemaEnv.root,b.baseId,D),M instanceof r.SchemaEnv&&(M=M.schema),M===void 0)throw new n.default(b.opts.uriResolver,b.baseId,D)}const F=(R=M?.properties)===null||R===void 0?void 0:R[g];if(typeof F!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${g}"`);_=_&&(h||E(M)),I(F,C)}if(!_)throw new Error(`discriminator: "${g}" must be required`);return d;function E({required:C}){return Array.isArray(C)&&C.includes(g)}function I(C,M){if(C.const)j(C.const,M);else if(C.enum)for(const F of C.enum)j(F,M);else throw new Error(`discriminator: "properties/${g}" must have "const" or "enum"`)}function j(C,M){if(typeof C!="string"||C in d)throw new Error(`discriminator: "${g}" values must be unique strings`);d[C]=M}}}};return Wn.default=i,Wn}const Wf={$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 mc;function gc(){return mc||(mc=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=lf(),n=Vf(),s=Hf(),a=Wf,i=["/properties"],o="http://json-schema.org/draft-07/schema";class c extends r.default{_addVocabularies(){super._addVocabularies(),n.default.forEach(g=>this.addVocabulary(g)),this.opts.discriminator&&this.addKeyword(s.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;const g=this.opts.$data?this.$dataMetaSchema(a,i):a;this.addMetaSchema(g,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 u=un();Object.defineProperty(e,"KeywordCxt",{enumerable:!0,get:function(){return u.KeywordCxt}});var l=ie();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 f=Qs();Object.defineProperty(e,"ValidationError",{enumerable:!0,get:function(){return f.default}});var b=fn();Object.defineProperty(e,"MissingRefError",{enumerable:!0,get:function(){return b.default}})})(rn,rn.exports)),rn.exports}var Kf=gc();const _c=Xt(Kf),Jf=Object.freeze({status:"aborted"});function q(t,e,r){function n(o,c){var u;Object.defineProperty(o,"_zod",{value:o._zod??{},enumerable:!1}),(u=o._zod).traits??(u.traits=new Set),o._zod.traits.add(t),e(o,c);for(const l in i.prototype)l in o||Object.defineProperty(o,l,{value:i.prototype[l].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 u=r?.Parent?new a:this;n(u,o),(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:o=>r?.Parent&&o instanceof r.Parent?!0:o?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}class Rr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const yc={};function Tt(t){return yc}function vc(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 Bf(t,e){return typeof e=="bigint"?e.toString():e}function sa(t){return{get value(){{const e=t();return Object.defineProperty(this,"value",{value:e}),e}}}}function aa(t){return t==null}function ia(t){const e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Gf(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 Se(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 Tr(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Pr(t){return JSON.stringify(t)}const wc=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Kn(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}const Yf=sa(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const t=Function;return new t(""),!0}catch{return!1}});function Jn(t){if(Kn(t)===!1)return!1;const e=t.constructor;if(e===void 0)return!0;const r=e.prototype;return!(Kn(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}const Qf=new Set(["string","number","symbol"]);function Cr(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Pt(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 Xf(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}const eh={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 th(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 Pt(t,{...t._zod.def,shape:r,checks:[]})}function rh(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 Pt(t,{...t._zod.def,shape:r,checks:[]})}function nh(t,e){if(!Jn(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 Tr(this,"shape",n),n},checks:[]};return Pt(t,r)}function sh(t,e){return Pt(t,{...t._zod.def,get shape(){const r={...t._zod.def.shape,...e._zod.def.shape};return Tr(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function ah(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 Pt(e,{...e._zod.def,shape:s,checks:[]})}function ih(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 Pt(e,{...e._zod.def,shape:s,checks:[]})}function Ir(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function Dt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Bn(t){return typeof t=="string"?t:t?.message}function Ct(t,e,r){const n={...t,path:t.path??[]};if(!t.message){const s=Bn(t.inst?._zod.def?.error?.(t))??Bn(e?.error?.(t))??Bn(r.customError?.(t))??Bn(r.localeError?.(t))??"Invalid input";n.message=s}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function oa(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Or(...t){const[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}const bc=(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,Bf,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Sc=q("$ZodError",bc),Gn=q("$ZodError",bc,{Parent:Error});function oh(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 ch(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 u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(r(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(t),n}const $c=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 Rr;if(i.issues.length){const o=new(s?.Err??t)(i.issues.map(c=>Ct(c,a,Tt())));throw wc(o,s?.callee),o}return i.value},uh=$c(Gn),kc=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=>Ct(c,a,Tt())));throw wc(o,s?.callee),o}return i.value},lh=kc(Gn),Ec=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 Rr;return a.issues.length?{success:!1,error:new(t??Sc)(a.issues.map(i=>Ct(i,s,Tt())))}:{success:!0,data:a.value}},ca=Ec(Gn),Rc=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=>Ct(i,s,Tt())))}:{success:!0,data:a.value}},ua=Rc(Gn),dh=/^[cC][^\s-]{8,}$/,fh=/^[0-9a-z]+$/,hh=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ph=/^[0-9a-vA-V]{20}$/,mh=/^[A-Za-z0-9]{27}$/,gh=/^[a-zA-Z0-9_-]{21}$/,_h=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,yh=/^([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})$/,Tc=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)$/,vh=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,wh="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function bh(){return new RegExp(wh,"u")}const Sh=/^(?:(?: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])$/,$h=/^(([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})$/,kh=/^((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])$/,Eh=/^(([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])$/,Rh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Pc=/^[A-Za-z0-9_-]*$/,Th=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,Ph=/^\+(?:[0-9]){6,14}[0-9]$/,Cc="(?:(?:\\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])))",Ch=new RegExp(`^${Cc}$`);function Ic(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 Ih(t){return new RegExp(`^${Ic(t)}$`)}function Oh(t){const e=Ic({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(`^${Cc}T(?:${n})$`)}const Nh=t=>{const e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Ah=/^\d+$/,zh=/^-?\d+(?:\.\d+)?/i,jh=/true|false/i,Mh=/null/i,qh=/^[^A-Z]*$/,Zh=/^[^a-z]*$/,Je=q("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Oc={number:"number",bigint:"bigint",object:"date"},Nc=q("$ZodCheckLessThan",(t,e)=>{Je.init(t,e);const r=Oc[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})}}),Ac=q("$ZodCheckGreaterThan",(t,e)=>{Je.init(t,e);const r=Oc[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})}}),xh=q("$ZodCheckMultipleOf",(t,e)=>{Je.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):Gf(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})}}),Lh=q("$ZodCheckNumberFormat",(t,e)=>{Je.init(t,e),e.format=e.format||"float64";const r=e.format?.includes("int"),n=r?"int":"number",[s,a]=eh[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=Ah)}),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})}}),Dh=q("$ZodCheckMaxLength",(t,e)=>{var r;Je.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!aa(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=oa(s);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Uh=q("$ZodCheckMinLength",(t,e)=>{var r;Je.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!aa(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=oa(s);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:s,inst:t,continue:!e.abort})}}),Vh=q("$ZodCheckLengthEquals",(t,e)=>{var r;Je.init(t,e),(r=t._zod.def).when??(r.when=n=>{const s=n.value;return!aa(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=oa(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})}}),Yn=q("$ZodCheckStringFormat",(t,e)=>{var r,n;Je.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=()=>{})}),Fh=q("$ZodCheckRegex",(t,e)=>{Yn.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})}}),Hh=q("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=qh),Yn.init(t,e)}),Wh=q("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Zh),Yn.init(t,e)}),Kh=q("$ZodCheckIncludes",(t,e)=>{Je.init(t,e);const r=Cr(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})}}),Jh=q("$ZodCheckStartsWith",(t,e)=>{Je.init(t,e);const r=new RegExp(`^${Cr(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})}}),Bh=q("$ZodCheckEndsWith",(t,e)=>{Je.init(t,e);const r=new RegExp(`.*${Cr(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})}}),Gh=q("$ZodCheckOverwrite",(t,e)=>{Je.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});class Yh{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
9
  `).filter(i=>i),s=Math.min(...n.map(i=>i.length-i.trimStart().length)),a=n.map(i=>i.slice(s)).map(i=>" ".repeat(this.indent*2)+i);for(const i of a)this.content.push(i)}compile(){const e=Function,r=this?.args,s=[...(this?.content??[""]).map(a=>` ${a}`)];return new e(...r,s.join(`
10
- `))}}const Jh={major:4,minor:0,patch:0},be=A("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Jh;const n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(const s of n)for(const a of s._zod.onattach)a(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const s=(a,i,o)=>{let c=Cr(a),u;for(const l of i){if(l._zod.def.when){if(!l._zod.def.when(a))continue}else if(c)continue;const h=a.issues.length,g=l._zod.check(a);if(g instanceof Promise&&o?.async===!1)throw new Er;if(u||g instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await g,a.issues.length!==h&&(c||(c=Cr(a,h)))});else{if(a.issues.length===h)continue;c||(c=Cr(a,h))}}return u?u.then(()=>a):a};t._zod.run=(a,i)=>{const o=t._zod.parse(a,i);if(o instanceof Promise){if(i.async===!1)throw new Er;return o.then(c=>s(c,n,i))}return s(o,n,i)}}t["~standard"]={validate:s=>{try{const a=oa(t,s);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return ca(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),ua=A("$ZodString",(t,e)=>{be.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Ph(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}}),Ee=A("$ZodStringFormat",(t,e)=>{Bn.init(t,e),ua.init(t,e)}),Gh=A("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=ph),Ee.init(t,e)}),Bh=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=Ec(n))}else e.pattern??(e.pattern=Ec());Ee.init(t,e)}),Yh=A("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=mh),Ee.init(t,e)}),Qh=A("$ZodURL",(t,e)=>{Ee.init(t,e),t._zod.check=r=>{try{const n=r.value,s=new URL(n),a=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:kh.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("/")&&a.endsWith("/")?r.value=a.slice(0,-1):r.value=a;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),Xh=A("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=gh()),Ee.init(t,e)}),ep=A("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=fh),Ee.init(t,e)}),tp=A("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=oh),Ee.init(t,e)}),rp=A("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=ch),Ee.init(t,e)}),np=A("$ZodULID",(t,e)=>{e.pattern??(e.pattern=uh),Ee.init(t,e)}),sp=A("$ZodXID",(t,e)=>{e.pattern??(e.pattern=lh),Ee.init(t,e)}),ap=A("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=dh),Ee.init(t,e)}),ip=A("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Th(e)),Ee.init(t,e)}),op=A("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Eh),Ee.init(t,e)}),cp=A("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Rh(e)),Ee.init(t,e)}),up=A("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=hh),Ee.init(t,e)}),lp=A("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=yh),Ee.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),dp=A("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=vh),Ee.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})}}}),fp=A("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=wh),Ee.init(t,e)}),hp=A("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=bh),Ee.init(t,e),t._zod.check=r=>{const[n,s]=r.value.split("/");try{if(!s)throw new Error;const a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>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 Nc(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const pp=A("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Sh),Ee.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{Nc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function mp(t){if(!Rc.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return Nc(r)}const _p=A("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Rc),Ee.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{mp(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),gp=A("$ZodE164",(t,e)=>{e.pattern??(e.pattern=$h),Ee.init(t,e)});function yp(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 vp=A("$ZodJWT",(t,e)=>{Ee.init(t,e),t._zod.check=r=>{yp(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),Ac=A("$ZodNumber",(t,e)=>{be.init(t,e),t._zod.pattern=t._zod.bag.pattern??Ih,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 a=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,...a?{received:a}:{}}),r}}),wp=A("$ZodNumber",(t,e)=>{Mh.init(t,e),Ac.init(t,e)}),bp=A("$ZodBoolean",(t,e)=>{be.init(t,e),t._zod.pattern=Oh,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}}),Sp=A("$ZodNull",(t,e)=>{be.init(t,e),t._zod.pattern=Nh,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}}),kp=A("$ZodAny",(t,e)=>{be.init(t,e),t._zod.parse=r=>r}),$p=A("$ZodUnknown",(t,e)=>{be.init(t,e),t._zod.parse=r=>r}),Ep=A("$ZodNever",(t,e)=>{be.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function jc(t,e,r){t.issues.length&&e.issues.push(...Dt(r,t.issues)),e.value[r]=t.value}const Rp=A("$ZodArray",(t,e)=>{be.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 a=[];for(let i=0;i<s.length;i++){const o=s[i],c=e.element._zod.run({value:o,issues:[]},n);c instanceof Promise?a.push(c.then(u=>jc(u,r,i))):jc(c,r,i)}return a.length?Promise.all(a).then(()=>r):r}});function Yn(t,e,r){t.issues.length&&e.issues.push(...Dt(r,t.issues)),e.value[r]=t.value}function zc(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(...Dt(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}const Mc=A("$ZodObject",(t,e)=>{be.init(t,e);const r=na(()=>{const h=Object.keys(e.shape);for(const _ of h)if(!(e.shape[_]instanceof be))throw new Error(`Invalid element at key "${_}": expected a Zod schema`);const g=Gf(e.shape);return{shape:e.shape,keys:h,keySet:new Set(h),numKeys:h.length,optionalKeys:new Set(g)}});Se(t._zod,"propValues",()=>{const h=e.shape,g={};for(const _ in h){const p=h[_]._zod;if(p.values){g[_]??(g[_]=new Set);for(const y of p.values)g[_].add(y)}}return g});const n=h=>{const g=new Kh(["shape","payload","ctx"]),_=r.value,p=d=>{const m=Tr(d);return`shape[${m}]._zod.run({ value: input[${m}], issues: [] }, ctx)`};g.write("const input = payload.value;");const y=Object.create(null);let f=0;for(const d of _.keys)y[d]=`key_${f++}`;g.write("const newResult = {}");for(const d of _.keys)if(_.optionalKeys.has(d)){const m=y[d];g.write(`const ${m} = ${p(d)};`);const b=Tr(d);g.write(`
11
- if (${m}.issues.length) {
12
- if (input[${b}] === undefined) {
13
- if (${b} in input) {
14
- newResult[${b}] = undefined;
10
+ `))}}const Qh={major:4,minor:0,patch:0},be=q("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Qh;const n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(const s of n)for(const a of s._zod.onattach)a(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{const s=(a,i,o)=>{let c=Ir(a),u;for(const l of i){if(l._zod.def.when){if(!l._zod.def.when(a))continue}else if(c)continue;const f=a.issues.length,b=l._zod.check(a);if(b instanceof Promise&&o?.async===!1)throw new Rr;if(u||b instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await b,a.issues.length!==f&&(c||(c=Ir(a,f)))});else{if(a.issues.length===f)continue;c||(c=Ir(a,f))}}return u?u.then(()=>a):a};t._zod.run=(a,i)=>{const o=t._zod.parse(a,i);if(o instanceof Promise){if(i.async===!1)throw new Rr;return o.then(c=>s(c,n,i))}return s(o,n,i)}}t["~standard"]={validate:s=>{try{const a=ca(t,s);return a.success?{value:a.data}:{issues:a.error?.issues}}catch{return ua(t,s).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),la=q("$ZodString",(t,e)=>{be.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Nh(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}}),Re=q("$ZodStringFormat",(t,e)=>{Yn.init(t,e),la.init(t,e)}),Xh=q("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=yh),Re.init(t,e)}),ep=q("$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=Tc(n))}else e.pattern??(e.pattern=Tc());Re.init(t,e)}),tp=q("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=vh),Re.init(t,e)}),rp=q("$ZodURL",(t,e)=>{Re.init(t,e),t._zod.check=r=>{try{const n=r.value,s=new URL(n),a=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:Th.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("/")&&a.endsWith("/")?r.value=a.slice(0,-1):r.value=a;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),np=q("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=bh()),Re.init(t,e)}),sp=q("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=gh),Re.init(t,e)}),ap=q("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=dh),Re.init(t,e)}),ip=q("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=fh),Re.init(t,e)}),op=q("$ZodULID",(t,e)=>{e.pattern??(e.pattern=hh),Re.init(t,e)}),cp=q("$ZodXID",(t,e)=>{e.pattern??(e.pattern=ph),Re.init(t,e)}),up=q("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=mh),Re.init(t,e)}),lp=q("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Oh(e)),Re.init(t,e)}),dp=q("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Ch),Re.init(t,e)}),fp=q("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Ih(e)),Re.init(t,e)}),hp=q("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=_h),Re.init(t,e)}),pp=q("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Sh),Re.init(t,e),t._zod.onattach.push(r=>{const n=r._zod.bag;n.format="ipv4"})}),mp=q("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=$h),Re.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})}}}),gp=q("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=kh),Re.init(t,e)}),_p=q("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Eh),Re.init(t,e),t._zod.check=r=>{const[n,s]=r.value.split("/");try{if(!s)throw new Error;const a=Number(s);if(`${a}`!==s)throw new Error;if(a<0||a>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 zc(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}const yp=q("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Rh),Re.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{zc(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function vp(t){if(!Pc.test(t))return!1;const e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return zc(r)}const wp=q("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Pc),Re.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{vp(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),bp=q("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Ph),Re.init(t,e)});function Sp(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 $p=q("$ZodJWT",(t,e)=>{Re.init(t,e),t._zod.check=r=>{Sp(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}}),jc=q("$ZodNumber",(t,e)=>{be.init(t,e),t._zod.pattern=t._zod.bag.pattern??zh,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 a=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,...a?{received:a}:{}}),r}}),kp=q("$ZodNumber",(t,e)=>{Lh.init(t,e),jc.init(t,e)}),Ep=q("$ZodBoolean",(t,e)=>{be.init(t,e),t._zod.pattern=jh,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}}),Rp=q("$ZodNull",(t,e)=>{be.init(t,e),t._zod.pattern=Mh,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}}),Tp=q("$ZodAny",(t,e)=>{be.init(t,e),t._zod.parse=r=>r}),Pp=q("$ZodUnknown",(t,e)=>{be.init(t,e),t._zod.parse=r=>r}),Cp=q("$ZodNever",(t,e)=>{be.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Mc(t,e,r){t.issues.length&&e.issues.push(...Dt(r,t.issues)),e.value[r]=t.value}const Ip=q("$ZodArray",(t,e)=>{be.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 a=[];for(let i=0;i<s.length;i++){const o=s[i],c=e.element._zod.run({value:o,issues:[]},n);c instanceof Promise?a.push(c.then(u=>Mc(u,r,i))):Mc(c,r,i)}return a.length?Promise.all(a).then(()=>r):r}});function Qn(t,e,r){t.issues.length&&e.issues.push(...Dt(r,t.issues)),e.value[r]=t.value}function qc(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(...Dt(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}const Zc=q("$ZodObject",(t,e)=>{be.init(t,e);const r=sa(()=>{const f=Object.keys(e.shape);for(const v of f)if(!(e.shape[v]instanceof be))throw new Error(`Invalid element at key "${v}": expected a Zod schema`);const b=Xf(e.shape);return{shape:e.shape,keys:f,keySet:new Set(f),numKeys:f.length,optionalKeys:new Set(b)}});Se(t._zod,"propValues",()=>{const f=e.shape,b={};for(const v in f){const g=f[v]._zod;if(g.values){b[v]??(b[v]=new Set);for(const w of g.values)b[v].add(w)}}return b});const n=f=>{const b=new Yh(["shape","payload","ctx"]),v=r.value,g=p=>{const y=Pr(p);return`shape[${y}]._zod.run({ value: input[${y}], issues: [] }, ctx)`};b.write("const input = payload.value;");const w=Object.create(null);let m=0;for(const p of v.keys)w[p]=`key_${m++}`;b.write("const newResult = {}");for(const p of v.keys)if(v.optionalKeys.has(p)){const y=w[p];b.write(`const ${y} = ${g(p)};`);const R=Pr(p);b.write(`
11
+ if (${y}.issues.length) {
12
+ if (input[${R}] === undefined) {
13
+ if (${R} in input) {
14
+ newResult[${R}] = undefined;
15
15
  }
16
16
  } else {
17
17
  payload.issues = payload.issues.concat(
18
- ${m}.issues.map((iss) => ({
18
+ ${y}.issues.map((iss) => ({
19
19
  ...iss,
20
- path: iss.path ? [${b}, ...iss.path] : [${b}],
20
+ path: iss.path ? [${R}, ...iss.path] : [${R}],
21
21
  }))
22
22
  );
23
23
  }
24
- } else if (${m}.value === undefined) {
25
- if (${b} in input) newResult[${b}] = undefined;
24
+ } else if (${y}.value === undefined) {
25
+ if (${R} in input) newResult[${R}] = undefined;
26
26
  } else {
27
- newResult[${b}] = ${m}.value;
27
+ newResult[${R}] = ${y}.value;
28
28
  }
29
- `)}else{const m=y[d];g.write(`const ${m} = ${p(d)};`),g.write(`
30
- if (${m}.issues.length) payload.issues = payload.issues.concat(${m}.issues.map(iss => ({
29
+ `)}else{const y=w[p];b.write(`const ${y} = ${g(p)};`),b.write(`
30
+ if (${y}.issues.length) payload.issues = payload.issues.concat(${y}.issues.map(iss => ({
31
31
  ...iss,
32
- path: iss.path ? [${Tr(d)}, ...iss.path] : [${Tr(d)}]
33
- })));`),g.write(`newResult[${Tr(d)}] = ${m}.value`)}g.write("payload.value = newResult;"),g.write("return payload;");const w=g.compile();return(d,m)=>w(h,d,m)};let s;const a=Wn,i=!_c.jitless,c=i&&Kf.value,u=e.catchall;let l;t._zod.parse=(h,g)=>{l??(l=r.value);const _=h.value;if(!a(_))return h.issues.push({expected:"object",code:"invalid_type",input:_,inst:t}),h;const p=[];if(i&&c&&g?.async===!1&&g.jitless!==!0)s||(s=n(e.shape)),h=s(h,g);else{h.value={};const m=l.shape;for(const b of l.keys){const v=m[b],$=v._zod.run({value:_[b],issues:[]},g),E=v._zod.optin==="optional"&&v._zod.optout==="optional";$ instanceof Promise?p.push($.then(N=>E?zc(N,h,b,_):Yn(N,h,b))):E?zc($,h,b,_):Yn($,h,b)}}if(!u)return p.length?Promise.all(p).then(()=>h):h;const y=[],f=l.keySet,w=u._zod,d=w.def.type;for(const m of Object.keys(_)){if(f.has(m))continue;if(d==="never"){y.push(m);continue}const b=w.run({value:_[m],issues:[]},g);b instanceof Promise?p.push(b.then(v=>Yn(v,h,m))):Yn(b,h,m)}return y.length&&h.issues.push({code:"unrecognized_keys",keys:y,input:_,inst:t}),p.length?Promise.all(p).then(()=>h):h}});function qc(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=>Ct(a,n,Tt())))}),e}const Zc=A("$ZodUnion",(t,e)=>{be.init(t,e),Se(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Se(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Se(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),Se(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=>aa(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=>qc(i,r,t,n)):qc(a,r,t,n)}}),Tp=A("$ZodDiscriminatedUnion",(t,e)=>{Zc.init(t,e);const r=t._zod.parse;Se(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 u of c)s[o].add(u)}}return s});const n=na(()=>{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(!Wn(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)}}),Pp=A("$ZodIntersection",(t,e)=>{be.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,u])=>Lc(r,c,u)):Lc(r,a,i)}});function la(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(Kn(t)&&Kn(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=la(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=la(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 Lc(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Cr(t))return t;const n=la(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 Cp=A("$ZodRecord",(t,e)=>{be.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!Kn(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 u=e.valueType._zod.run({value:s[c],issues:[]},n);u instanceof Promise?a.push(u.then(l=>{l.issues.length&&r.issues.push(...Dt(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...Dt(c,u.issues)),r.value[c]=u.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(u=>Ct(u,n,Tt())),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(u=>{u.issues.length&&r.issues.push(...Dt(i,u.issues)),r.value[o.value]=u.value})):(c.issues.length&&r.issues.push(...Dt(i,c.issues)),r.value[o.value]=c.value)}}return a.length?Promise.all(a).then(()=>r):r}}),Ip=A("$ZodEnum",(t,e)=>{be.init(t,e);const r=gc(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>Jf.has(typeof n)).map(n=>typeof n=="string"?Pr(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}}),Op=A("$ZodLiteral",(t,e)=>{be.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Pr(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}}),Np=A("$ZodTransform",(t,e)=>{be.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 Er;return r.value=s,r}}),Ap=A("$ZodOptional",(t,e)=>{be.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Se(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Se(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${aa(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)}),jp=A("$ZodNullable",(t,e)=>{be.init(t,e),Se(t._zod,"optin",()=>e.innerType._zod.optin),Se(t._zod,"optout",()=>e.innerType._zod.optout),Se(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${aa(r.source)}|null)$`):void 0}),Se(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)}),zp=A("$ZodDefault",(t,e)=>{be.init(t,e),t._zod.optin="optional",Se(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=>xc(a,e)):xc(s,e)}});function xc(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const Mp=A("$ZodPrefault",(t,e)=>{be.init(t,e),t._zod.optin="optional",Se(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))}),qp=A("$ZodNonOptional",(t,e)=>{be.init(t,e),Se(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=>Dc(a,t)):Dc(s,t)}});function Dc(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 Zp=A("$ZodCatch",(t,e)=>{be.init(t,e),t._zod.optin="optional",Se(t._zod,"optout",()=>e.innerType._zod.optout),Se(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=>Ct(i,n,Tt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(a=>Ct(a,n,Tt()))},input:r.value}),r.issues=[]),r)}}),Lp=A("$ZodPipe",(t,e)=>{be.init(t,e),Se(t._zod,"values",()=>e.in._zod.values),Se(t._zod,"optin",()=>e.in._zod.optin),Se(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=>Uc(a,e,n)):Uc(s,e,n)}});function Uc(t,e,r){return Cr(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}const xp=A("$ZodReadonly",(t,e)=>{be.init(t,e),Se(t._zod,"propValues",()=>e.innerType._zod.propValues),Se(t._zod,"values",()=>e.innerType._zod.values),Se(t._zod,"optin",()=>e.innerType._zod.optin),Se(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(Vc):Vc(s)}});function Vc(t){return t.value=Object.freeze(t.value),t}const Dp=A("$ZodCustom",(t,e)=>{Je.init(t,e),be.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=>Fc(a,r,n,t));Fc(s,r,n,t)}});function Fc(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(Ir(s))}}class Hc{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 Up(){return new Hc}const Or=Up();function Vp(t,e){return new t({type:"string",...Q(e)})}function Fp(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Q(e)})}function Wc(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Q(e)})}function Hp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Q(e)})}function Wp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Q(e)})}function Kp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Q(e)})}function Jp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Q(e)})}function Kc(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Q(e)})}function Gp(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Q(e)})}function Bp(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Q(e)})}function Yp(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Q(e)})}function Qp(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Q(e)})}function Xp(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Q(e)})}function em(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Q(e)})}function tm(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Q(e)})}function rm(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Q(e)})}function nm(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Q(e)})}function sm(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Q(e)})}function am(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Q(e)})}function im(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Q(e)})}function om(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Q(e)})}function cm(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Q(e)})}function um(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Q(e)})}function lm(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Q(e)})}function dm(t,e){return new t({type:"string",format:"date",check:"string_format",...Q(e)})}function fm(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Q(e)})}function hm(t,e){return new t({type:"string",format:"duration",check:"string_format",...Q(e)})}function pm(t,e){return new t({type:"number",checks:[],...Q(e)})}function mm(t,e){return new t({type:"number",coerce:!0,checks:[],...Q(e)})}function _m(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Q(e)})}function gm(t,e){return new t({type:"boolean",...Q(e)})}function ym(t,e){return new t({type:"null",...Q(e)})}function vm(t){return new t({type:"any"})}function wm(t){return new t({type:"unknown"})}function bm(t,e){return new t({type:"never",...Q(e)})}function Jc(t,e){return new Ic({check:"less_than",...Q(e),value:t,inclusive:!1})}function da(t,e){return new Ic({check:"less_than",...Q(e),value:t,inclusive:!0})}function Gc(t,e){return new Oc({check:"greater_than",...Q(e),value:t,inclusive:!1})}function fa(t,e){return new Oc({check:"greater_than",...Q(e),value:t,inclusive:!0})}function Bc(t,e){return new zh({check:"multiple_of",...Q(e),value:t})}function Yc(t,e){return new qh({check:"max_length",...Q(e),maximum:t})}function Qn(t,e){return new Zh({check:"min_length",...Q(e),minimum:t})}function Qc(t,e){return new Lh({check:"length_equals",...Q(e),length:t})}function Sm(t,e){return new xh({check:"string_format",format:"regex",...Q(e),pattern:t})}function km(t){return new Dh({check:"string_format",format:"lowercase",...Q(t)})}function $m(t){return new Uh({check:"string_format",format:"uppercase",...Q(t)})}function Em(t,e){return new Vh({check:"string_format",format:"includes",...Q(e),includes:t})}function Rm(t,e){return new Fh({check:"string_format",format:"starts_with",...Q(e),prefix:t})}function Tm(t,e){return new Hh({check:"string_format",format:"ends_with",...Q(e),suffix:t})}function Nr(t){return new Wh({check:"overwrite",tx:t})}function Pm(t){return Nr(e=>e.normalize(t))}function Cm(){return Nr(t=>t.trim())}function Im(){return Nr(t=>t.toLowerCase())}function Om(){return Nr(t=>t.toUpperCase())}function Nm(t,e,r){return new t({type:"array",element:e,...Q(r)})}function Am(t,e,r){const n=Q(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function jm(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Q(r)})}class Xc{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Or,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 h={...r,schemaPath:[...r.schemaPath,e],path:r.path},g=e._zod.parent;if(g)o.ref=g,this.process(g,h),this.seen.get(g).isParent=!0;else{const _=o.schema;switch(s.type){case"string":{const p=_;p.type="string";const{minimum:y,maximum:f,format:w,patterns:d,contentEncoding:m}=e._zod.bag;if(typeof y=="number"&&(p.minLength=y),typeof f=="number"&&(p.maxLength=f),w&&(p.format=a[w]??w,p.format===""&&delete p.format),m&&(p.contentEncoding=m),d&&d.size>0){const b=[...d];b.length===1?p.pattern=b[0].source:b.length>1&&(o.schema.allOf=[...b.map(v=>({...this.target==="draft-7"?{type:"string"}:{},pattern:v.source}))])}break}case"number":{const p=_,{minimum:y,maximum:f,format:w,multipleOf:d,exclusiveMaximum:m,exclusiveMinimum:b}=e._zod.bag;typeof w=="string"&&w.includes("int")?p.type="integer":p.type="number",typeof b=="number"&&(p.exclusiveMinimum=b),typeof y=="number"&&(p.minimum=y,typeof b=="number"&&(b>=y?delete p.minimum:delete p.exclusiveMinimum)),typeof m=="number"&&(p.exclusiveMaximum=m),typeof f=="number"&&(p.maximum=f,typeof m=="number"&&(m<=f?delete p.maximum:delete p.exclusiveMaximum)),typeof d=="number"&&(p.multipleOf=d);break}case"boolean":{const p=_;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":{_.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 p=_,{minimum:y,maximum:f}=e._zod.bag;typeof y=="number"&&(p.minItems=y),typeof f=="number"&&(p.maxItems=f),p.type="array",p.items=this.process(s.element,{...h,path:[...h.path,"items"]});break}case"object":{const p=_;p.type="object",p.properties={};const y=s.shape;for(const d in y)p.properties[d]=this.process(y[d],{...h,path:[...h.path,"properties",d]});const f=new Set(Object.keys(y)),w=new Set([...f].filter(d=>{const m=s.shape[d]._zod;return this.io==="input"?m.optin===void 0:m.optout===void 0}));w.size>0&&(p.required=Array.from(w)),s.catchall?._zod.def.type==="never"?p.additionalProperties=!1:s.catchall?s.catchall&&(p.additionalProperties=this.process(s.catchall,{...h,path:[...h.path,"additionalProperties"]})):this.io==="output"&&(p.additionalProperties=!1);break}case"union":{const p=_;p.anyOf=s.options.map((y,f)=>this.process(y,{...h,path:[...h.path,"anyOf",f]}));break}case"intersection":{const p=_,y=this.process(s.left,{...h,path:[...h.path,"allOf",0]}),f=this.process(s.right,{...h,path:[...h.path,"allOf",1]}),w=m=>"allOf"in m&&Object.keys(m).length===1,d=[...w(y)?y.allOf:[y],...w(f)?f.allOf:[f]];p.allOf=d;break}case"tuple":{const p=_;p.type="array";const y=s.items.map((d,m)=>this.process(d,{...h,path:[...h.path,"prefixItems",m]}));if(this.target==="draft-2020-12"?p.prefixItems=y:p.items=y,s.rest){const d=this.process(s.rest,{...h,path:[...h.path,"items"]});this.target==="draft-2020-12"?p.items=d:p.additionalItems=d}s.rest&&(p.items=this.process(s.rest,{...h,path:[...h.path,"items"]}));const{minimum:f,maximum:w}=e._zod.bag;typeof f=="number"&&(p.minItems=f),typeof w=="number"&&(p.maxItems=w);break}case"record":{const p=_;p.type="object",p.propertyNames=this.process(s.keyType,{...h,path:[...h.path,"propertyNames"]}),p.additionalProperties=this.process(s.valueType,{...h,path:[...h.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=_,y=gc(s.entries);y.every(f=>typeof f=="number")&&(p.type="number"),y.every(f=>typeof f=="string")&&(p.type="string"),p.enum=y;break}case"literal":{const p=_,y=[];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");y.push(Number(f))}else y.push(f);if(y.length!==0)if(y.length===1){const f=y[0];p.type=f===null?"null":typeof f,p.const=f}else y.every(f=>typeof f=="number")&&(p.type="number"),y.every(f=>typeof f=="string")&&(p.type="string"),y.every(f=>typeof f=="boolean")&&(p.type="string"),y.every(f=>f===null)&&(p.type="null"),p.enum=y;break}case"file":{const p=_,y={type:"string",format:"binary",contentEncoding:"binary"},{minimum:f,maximum:w,mime:d}=e._zod.bag;f!==void 0&&(y.minLength=f),w!==void 0&&(y.maxLength=w),d?d.length===1?(y.contentMediaType=d[0],Object.assign(p,y)):p.anyOf=d.map(m=>({...y,contentMediaType:m})):Object.assign(p,y);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,h);_.anyOf=[p,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,h),o.ref=s.innerType;break}case"success":{const p=_;p.type="boolean";break}case"default":{this.process(s.innerType,h),o.ref=s.innerType,_.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,h),o.ref=s.innerType,this.io==="input"&&(_._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,h),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")}_.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=_,y=e._zod.pattern;if(!y)throw new Error("Pattern not found in template literal");p.type="string",p.pattern=y.source;break}case"pipe":{const p=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(p,h),o.ref=p;break}case"readonly":{this.process(s.innerType,h),o.ref=s.innerType,_.readOnly=!0;break}case"promise":{this.process(s.innerType,h),o.ref=s.innerType;break}case"optional":{this.process(s.innerType,h),o.ref=s.innerType;break}case"lazy":{const p=e._zod.innerType;this.process(p,h),o.ref=p;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(o.schema,u),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=l=>{const h=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const y=n.external.registry.get(l[0])?.id,f=n.external.uri??(d=>d);if(y)return{ref:f(y)};const w=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=w,{defId:w,ref:`${f("__shared")}#/${h}/${w}`}}if(l[1]===s)return{ref:"#"};const _=`#/${h}/`,p=l[1].schema.id??`__schema${this.counter++}`;return{defId:p,ref:_+p}},i=l=>{if(l[1].schema.$ref)return;const h=l[1],{ref:g,defId:_}=a(l);h.def={...h.schema},_&&(h.defId=_);const p=h.schema;for(const y in p)delete p[y];p.$ref=g};if(n.cycles==="throw")for(const l of this.seen.entries()){const h=l[1];if(h.cycle)throw new Error(`Cycle detected: #/${h.cycle?.join("/")}/<root>
32
+ path: iss.path ? [${Pr(p)}, ...iss.path] : [${Pr(p)}]
33
+ })));`),b.write(`newResult[${Pr(p)}] = ${y}.value`)}b.write("payload.value = newResult;"),b.write("return payload;");const S=b.compile();return(p,y)=>S(f,p,y)};let s;const a=Kn,i=!yc.jitless,c=i&&Yf.value,u=e.catchall;let l;t._zod.parse=(f,b)=>{l??(l=r.value);const v=f.value;if(!a(v))return f.issues.push({expected:"object",code:"invalid_type",input:v,inst:t}),f;const g=[];if(i&&c&&b?.async===!1&&b.jitless!==!0)s||(s=n(e.shape)),f=s(f,b);else{f.value={};const y=l.shape;for(const R of l.keys){const d=y[R],h=d._zod.run({value:v[R],issues:[]},b),_=d._zod.optin==="optional"&&d._zod.optout==="optional";h instanceof Promise?g.push(h.then(E=>_?qc(E,f,R,v):Qn(E,f,R))):_?qc(h,f,R,v):Qn(h,f,R)}}if(!u)return g.length?Promise.all(g).then(()=>f):f;const w=[],m=l.keySet,S=u._zod,p=S.def.type;for(const y of Object.keys(v)){if(m.has(y))continue;if(p==="never"){w.push(y);continue}const R=S.run({value:v[y],issues:[]},b);R instanceof Promise?g.push(R.then(d=>Qn(d,f,y))):Qn(R,f,y)}return w.length&&f.issues.push({code:"unrecognized_keys",keys:w,input:v,inst:t}),g.length?Promise.all(g).then(()=>f):f}});function xc(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=>Ct(a,n,Tt())))}),e}const Lc=q("$ZodUnion",(t,e)=>{be.init(t,e),Se(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),Se(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),Se(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),Se(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=>ia(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=>xc(i,r,t,n)):xc(a,r,t,n)}}),Op=q("$ZodDiscriminatedUnion",(t,e)=>{Lc.init(t,e);const r=t._zod.parse;Se(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 u of c)s[o].add(u)}}return s});const n=sa(()=>{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(!Kn(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)}}),Np=q("$ZodIntersection",(t,e)=>{be.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,u])=>Dc(r,c,u)):Dc(r,a,i)}});function da(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(Jn(t)&&Jn(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=da(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=da(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 Dc(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Ir(t))return t;const n=da(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 Ap=q("$ZodRecord",(t,e)=>{be.init(t,e),t._zod.parse=(r,n)=>{const s=r.value;if(!Jn(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 u=e.valueType._zod.run({value:s[c],issues:[]},n);u instanceof Promise?a.push(u.then(l=>{l.issues.length&&r.issues.push(...Dt(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...Dt(c,u.issues)),r.value[c]=u.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(u=>Ct(u,n,Tt())),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(u=>{u.issues.length&&r.issues.push(...Dt(i,u.issues)),r.value[o.value]=u.value})):(c.issues.length&&r.issues.push(...Dt(i,c.issues)),r.value[o.value]=c.value)}}return a.length?Promise.all(a).then(()=>r):r}}),zp=q("$ZodEnum",(t,e)=>{be.init(t,e);const r=vc(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>Qf.has(typeof n)).map(n=>typeof n=="string"?Cr(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}}),jp=q("$ZodLiteral",(t,e)=>{be.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Cr(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}}),Mp=q("$ZodTransform",(t,e)=>{be.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 Rr;return r.value=s,r}}),qp=q("$ZodOptional",(t,e)=>{be.init(t,e),t._zod.optin="optional",t._zod.optout="optional",Se(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),Se(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${ia(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)}),Zp=q("$ZodNullable",(t,e)=>{be.init(t,e),Se(t._zod,"optin",()=>e.innerType._zod.optin),Se(t._zod,"optout",()=>e.innerType._zod.optout),Se(t._zod,"pattern",()=>{const r=e.innerType._zod.pattern;return r?new RegExp(`^(${ia(r.source)}|null)$`):void 0}),Se(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)}),xp=q("$ZodDefault",(t,e)=>{be.init(t,e),t._zod.optin="optional",Se(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=>Uc(a,e)):Uc(s,e)}});function Uc(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}const Lp=q("$ZodPrefault",(t,e)=>{be.init(t,e),t._zod.optin="optional",Se(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))}),Dp=q("$ZodNonOptional",(t,e)=>{be.init(t,e),Se(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=>Vc(a,t)):Vc(s,t)}});function Vc(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 Up=q("$ZodCatch",(t,e)=>{be.init(t,e),t._zod.optin="optional",Se(t._zod,"optout",()=>e.innerType._zod.optout),Se(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=>Ct(i,n,Tt()))},input:r.value}),r.issues=[]),r)):(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(a=>Ct(a,n,Tt()))},input:r.value}),r.issues=[]),r)}}),Vp=q("$ZodPipe",(t,e)=>{be.init(t,e),Se(t._zod,"values",()=>e.in._zod.values),Se(t._zod,"optin",()=>e.in._zod.optin),Se(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=>Fc(a,e,n)):Fc(s,e,n)}});function Fc(t,e,r){return Ir(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}const Fp=q("$ZodReadonly",(t,e)=>{be.init(t,e),Se(t._zod,"propValues",()=>e.innerType._zod.propValues),Se(t._zod,"values",()=>e.innerType._zod.values),Se(t._zod,"optin",()=>e.innerType._zod.optin),Se(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(Hc):Hc(s)}});function Hc(t){return t.value=Object.freeze(t.value),t}const Hp=q("$ZodCustom",(t,e)=>{Je.init(t,e),be.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=>Wc(a,r,n,t));Wc(s,r,n,t)}});function Wc(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(Or(s))}}class Kc{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 Wp(){return new Kc}const Nr=Wp();function Kp(t,e){return new t({type:"string",...Q(e)})}function Jp(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...Q(e)})}function Jc(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...Q(e)})}function Bp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...Q(e)})}function Gp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...Q(e)})}function Yp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...Q(e)})}function Qp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...Q(e)})}function Bc(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...Q(e)})}function Xp(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...Q(e)})}function em(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...Q(e)})}function tm(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...Q(e)})}function rm(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...Q(e)})}function nm(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...Q(e)})}function sm(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...Q(e)})}function am(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...Q(e)})}function im(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...Q(e)})}function om(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...Q(e)})}function cm(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...Q(e)})}function um(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...Q(e)})}function lm(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...Q(e)})}function dm(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...Q(e)})}function fm(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...Q(e)})}function hm(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...Q(e)})}function pm(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...Q(e)})}function mm(t,e){return new t({type:"string",format:"date",check:"string_format",...Q(e)})}function gm(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...Q(e)})}function _m(t,e){return new t({type:"string",format:"duration",check:"string_format",...Q(e)})}function ym(t,e){return new t({type:"number",checks:[],...Q(e)})}function vm(t,e){return new t({type:"number",coerce:!0,checks:[],...Q(e)})}function wm(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...Q(e)})}function bm(t,e){return new t({type:"boolean",...Q(e)})}function Sm(t,e){return new t({type:"null",...Q(e)})}function $m(t){return new t({type:"any"})}function km(t){return new t({type:"unknown"})}function Em(t,e){return new t({type:"never",...Q(e)})}function Gc(t,e){return new Nc({check:"less_than",...Q(e),value:t,inclusive:!1})}function fa(t,e){return new Nc({check:"less_than",...Q(e),value:t,inclusive:!0})}function Yc(t,e){return new Ac({check:"greater_than",...Q(e),value:t,inclusive:!1})}function ha(t,e){return new Ac({check:"greater_than",...Q(e),value:t,inclusive:!0})}function Qc(t,e){return new xh({check:"multiple_of",...Q(e),value:t})}function Xc(t,e){return new Dh({check:"max_length",...Q(e),maximum:t})}function Xn(t,e){return new Uh({check:"min_length",...Q(e),minimum:t})}function eu(t,e){return new Vh({check:"length_equals",...Q(e),length:t})}function Rm(t,e){return new Fh({check:"string_format",format:"regex",...Q(e),pattern:t})}function Tm(t){return new Hh({check:"string_format",format:"lowercase",...Q(t)})}function Pm(t){return new Wh({check:"string_format",format:"uppercase",...Q(t)})}function Cm(t,e){return new Kh({check:"string_format",format:"includes",...Q(e),includes:t})}function Im(t,e){return new Jh({check:"string_format",format:"starts_with",...Q(e),prefix:t})}function Om(t,e){return new Bh({check:"string_format",format:"ends_with",...Q(e),suffix:t})}function Ar(t){return new Gh({check:"overwrite",tx:t})}function Nm(t){return Ar(e=>e.normalize(t))}function Am(){return Ar(t=>t.trim())}function zm(){return Ar(t=>t.toLowerCase())}function jm(){return Ar(t=>t.toUpperCase())}function Mm(t,e,r){return new t({type:"array",element:e,...Q(r)})}function qm(t,e,r){const n=Q(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Zm(t,e,r){return new t({type:"custom",check:"custom",fn:e,...Q(r)})}class tu{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Nr,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 f={...r,schemaPath:[...r.schemaPath,e],path:r.path},b=e._zod.parent;if(b)o.ref=b,this.process(b,f),this.seen.get(b).isParent=!0;else{const v=o.schema;switch(s.type){case"string":{const g=v;g.type="string";const{minimum:w,maximum:m,format:S,patterns:p,contentEncoding:y}=e._zod.bag;if(typeof w=="number"&&(g.minLength=w),typeof m=="number"&&(g.maxLength=m),S&&(g.format=a[S]??S,g.format===""&&delete g.format),y&&(g.contentEncoding=y),p&&p.size>0){const R=[...p];R.length===1?g.pattern=R[0].source:R.length>1&&(o.schema.allOf=[...R.map(d=>({...this.target==="draft-7"?{type:"string"}:{},pattern:d.source}))])}break}case"number":{const g=v,{minimum:w,maximum:m,format:S,multipleOf:p,exclusiveMaximum:y,exclusiveMinimum:R}=e._zod.bag;typeof S=="string"&&S.includes("int")?g.type="integer":g.type="number",typeof R=="number"&&(g.exclusiveMinimum=R),typeof w=="number"&&(g.minimum=w,typeof R=="number"&&(R>=w?delete g.minimum:delete g.exclusiveMinimum)),typeof y=="number"&&(g.exclusiveMaximum=y),typeof m=="number"&&(g.maximum=m,typeof y=="number"&&(y<=m?delete g.maximum:delete g.exclusiveMaximum)),typeof p=="number"&&(g.multipleOf=p);break}case"boolean":{const g=v;g.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 g=v,{minimum:w,maximum:m}=e._zod.bag;typeof w=="number"&&(g.minItems=w),typeof m=="number"&&(g.maxItems=m),g.type="array",g.items=this.process(s.element,{...f,path:[...f.path,"items"]});break}case"object":{const g=v;g.type="object",g.properties={};const w=s.shape;for(const p in w)g.properties[p]=this.process(w[p],{...f,path:[...f.path,"properties",p]});const m=new Set(Object.keys(w)),S=new Set([...m].filter(p=>{const y=s.shape[p]._zod;return this.io==="input"?y.optin===void 0:y.optout===void 0}));S.size>0&&(g.required=Array.from(S)),s.catchall?._zod.def.type==="never"?g.additionalProperties=!1:s.catchall?s.catchall&&(g.additionalProperties=this.process(s.catchall,{...f,path:[...f.path,"additionalProperties"]})):this.io==="output"&&(g.additionalProperties=!1);break}case"union":{const g=v;g.anyOf=s.options.map((w,m)=>this.process(w,{...f,path:[...f.path,"anyOf",m]}));break}case"intersection":{const g=v,w=this.process(s.left,{...f,path:[...f.path,"allOf",0]}),m=this.process(s.right,{...f,path:[...f.path,"allOf",1]}),S=y=>"allOf"in y&&Object.keys(y).length===1,p=[...S(w)?w.allOf:[w],...S(m)?m.allOf:[m]];g.allOf=p;break}case"tuple":{const g=v;g.type="array";const w=s.items.map((p,y)=>this.process(p,{...f,path:[...f.path,"prefixItems",y]}));if(this.target==="draft-2020-12"?g.prefixItems=w:g.items=w,s.rest){const p=this.process(s.rest,{...f,path:[...f.path,"items"]});this.target==="draft-2020-12"?g.items=p:g.additionalItems=p}s.rest&&(g.items=this.process(s.rest,{...f,path:[...f.path,"items"]}));const{minimum:m,maximum:S}=e._zod.bag;typeof m=="number"&&(g.minItems=m),typeof S=="number"&&(g.maxItems=S);break}case"record":{const g=v;g.type="object",g.propertyNames=this.process(s.keyType,{...f,path:[...f.path,"propertyNames"]}),g.additionalProperties=this.process(s.valueType,{...f,path:[...f.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 g=v,w=vc(s.entries);w.every(m=>typeof m=="number")&&(g.type="number"),w.every(m=>typeof m=="string")&&(g.type="string"),g.enum=w;break}case"literal":{const g=v,w=[];for(const m of s.values)if(m===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof m=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");w.push(Number(m))}else w.push(m);if(w.length!==0)if(w.length===1){const m=w[0];g.type=m===null?"null":typeof m,g.const=m}else w.every(m=>typeof m=="number")&&(g.type="number"),w.every(m=>typeof m=="string")&&(g.type="string"),w.every(m=>typeof m=="boolean")&&(g.type="string"),w.every(m=>m===null)&&(g.type="null"),g.enum=w;break}case"file":{const g=v,w={type:"string",format:"binary",contentEncoding:"binary"},{minimum:m,maximum:S,mime:p}=e._zod.bag;m!==void 0&&(w.minLength=m),S!==void 0&&(w.maxLength=S),p?p.length===1?(w.contentMediaType=p[0],Object.assign(g,w)):g.anyOf=p.map(y=>({...w,contentMediaType:y})):Object.assign(g,w);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{const g=this.process(s.innerType,f);v.anyOf=[g,{type:"null"}];break}case"nonoptional":{this.process(s.innerType,f),o.ref=s.innerType;break}case"success":{const g=v;g.type="boolean";break}case"default":{this.process(s.innerType,f),o.ref=s.innerType,v.default=JSON.parse(JSON.stringify(s.defaultValue));break}case"prefault":{this.process(s.innerType,f),o.ref=s.innerType,this.io==="input"&&(v._prefault=JSON.parse(JSON.stringify(s.defaultValue)));break}case"catch":{this.process(s.innerType,f),o.ref=s.innerType;let g;try{g=s.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}v.default=g;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{const g=v,w=e._zod.pattern;if(!w)throw new Error("Pattern not found in template literal");g.type="string",g.pattern=w.source;break}case"pipe":{const g=this.io==="input"?s.in._zod.def.type==="transform"?s.out:s.in:s.out;this.process(g,f),o.ref=g;break}case"readonly":{this.process(s.innerType,f),o.ref=s.innerType,v.readOnly=!0;break}case"promise":{this.process(s.innerType,f),o.ref=s.innerType;break}case"optional":{this.process(s.innerType,f),o.ref=s.innerType;break}case"lazy":{const g=e._zod.innerType;this.process(g,f),o.ref=g;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(o.schema,u),this.io==="input"&&ze(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=l=>{const f=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){const w=n.external.registry.get(l[0])?.id,m=n.external.uri??(p=>p);if(w)return{ref:m(w)};const S=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=S,{defId:S,ref:`${m("__shared")}#/${f}/${S}`}}if(l[1]===s)return{ref:"#"};const v=`#/${f}/`,g=l[1].schema.id??`__schema${this.counter++}`;return{defId:g,ref:v+g}},i=l=>{if(l[1].schema.$ref)return;const f=l[1],{ref:b,defId:v}=a(l);f.def={...f.schema},v&&(f.defId=v);const g=f.schema;for(const w in g)delete g[w];g.$ref=b};if(n.cycles==="throw")for(const l of this.seen.entries()){const f=l[1];if(f.cycle)throw new Error(`Cycle detected: #/${f.cycle?.join("/")}/<root>
34
34
 
35
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const l of this.seen.entries()){const h=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(h.cycle){i(l);continue}if(h.count>1&&n.reused==="ref"){i(l);continue}}const o=(l,h)=>{const g=this.seen.get(l),_=g.def??g.schema,p={..._};if(g.ref===null)return;const y=g.ref;if(g.ref=null,y){o(y,h);const f=this.seen.get(y).schema;f.$ref&&h.target==="draft-7"?(_.allOf=_.allOf??[],_.allOf.push(f)):(Object.assign(_,f),Object.assign(_,p))}g.isParent||this.override({zodSchema:l,jsonSchema:_,path:g.path??[]})};for(const l of[...this.seen.entries()].reverse())o(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 h=l[1];h.def&&h.defId&&(u[h.defId]=h.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 zm(t,e){if(t instanceof Hc){const n=new Xc(e),s={};for(const o of t._idmap.entries()){const[c,u]=o;n.process(u)}const a={},i={registry:t,uri:e?.uri,defs:s};for(const o of t._idmap.entries()){const[c,u]=o;a[c]=n.emit(u,{...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 Xc(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 Mm=A("ZodISODateTime",(t,e)=>{ip.init(t,e),Pe.init(t,e)});function eu(t){return lm(Mm,t)}const qm=A("ZodISODate",(t,e)=>{op.init(t,e),Pe.init(t,e)});function Zm(t){return dm(qm,t)}const Lm=A("ZodISOTime",(t,e)=>{cp.init(t,e),Pe.init(t,e)});function xm(t){return fm(Lm,t)}const Dm=A("ZodISODuration",(t,e)=>{up.init(t,e),Pe.init(t,e)});function Um(t){return hm(Dm,t)}const Xn=A("ZodError",(t,e)=>{wc.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>sh(t,r)},flatten:{value:r=>nh(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}),Vm=bc(Xn),Fm=Sc(Xn),Hm=kc(Xn),Wm=$c(Xn),Re=A("ZodType",(t,e)=>(be.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)=>Pt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>Vm(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Hm(t,r,n),t.parseAsync=async(r,n)=>Fm(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Wm(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(Z_(r,n)),t.superRefine=r=>t.check(L_(r)),t.overwrite=r=>t.check(Nr(r)),t.optional=()=>Oe(t),t.nullable=()=>du(t),t.nullish=()=>Oe(du(t)),t.nonoptional=r=>I_(t,r),t.array=()=>V(t),t.or=r=>$e([t,r]),t.and=r=>pa(t,r),t.transform=r=>_a(t,uu(r)),t.default=r=>T_(t,r),t.prefault=r=>C_(t,r),t.catch=r=>N_(t,r),t.pipe=r=>_a(t,r),t.readonly=()=>z_(t),t.describe=r=>{const n=t.clone();return Or.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Or.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Or.get(t);const n=t.clone();return Or.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),tu=A("_ZodString",(t,e)=>{ua.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(Sm(...n)),t.includes=(...n)=>t.check(Em(...n)),t.startsWith=(...n)=>t.check(Rm(...n)),t.endsWith=(...n)=>t.check(Tm(...n)),t.min=(...n)=>t.check(Qn(...n)),t.max=(...n)=>t.check(Yc(...n)),t.length=(...n)=>t.check(Qc(...n)),t.nonempty=(...n)=>t.check(Qn(1,...n)),t.lowercase=n=>t.check(km(n)),t.uppercase=n=>t.check($m(n)),t.trim=()=>t.check(Cm()),t.normalize=(...n)=>t.check(Pm(...n)),t.toLowerCase=()=>t.check(Im()),t.toUpperCase=()=>t.check(Om())}),Km=A("ZodString",(t,e)=>{ua.init(t,e),tu.init(t,e),t.email=r=>t.check(Fp(Jm,r)),t.url=r=>t.check(Kc(nu,r)),t.jwt=r=>t.check(um(l_,r)),t.emoji=r=>t.check(Gp(Bm,r)),t.guid=r=>t.check(Wc(ru,r)),t.uuid=r=>t.check(Hp(es,r)),t.uuidv4=r=>t.check(Wp(es,r)),t.uuidv6=r=>t.check(Kp(es,r)),t.uuidv7=r=>t.check(Jp(es,r)),t.nanoid=r=>t.check(Bp(Ym,r)),t.guid=r=>t.check(Wc(ru,r)),t.cuid=r=>t.check(Yp(Qm,r)),t.cuid2=r=>t.check(Qp(Xm,r)),t.ulid=r=>t.check(Xp(e_,r)),t.base64=r=>t.check(im(o_,r)),t.base64url=r=>t.check(om(c_,r)),t.xid=r=>t.check(em(t_,r)),t.ksuid=r=>t.check(tm(r_,r)),t.ipv4=r=>t.check(rm(n_,r)),t.ipv6=r=>t.check(nm(s_,r)),t.cidrv4=r=>t.check(sm(a_,r)),t.cidrv6=r=>t.check(am(i_,r)),t.e164=r=>t.check(cm(u_,r)),t.datetime=r=>t.check(eu(r)),t.date=r=>t.check(Zm(r)),t.time=r=>t.check(xm(r)),t.duration=r=>t.check(Um(r))});function R(t){return Vp(Km,t)}const Pe=A("ZodStringFormat",(t,e)=>{Ee.init(t,e),tu.init(t,e)}),Jm=A("ZodEmail",(t,e)=>{Yh.init(t,e),Pe.init(t,e)}),ru=A("ZodGUID",(t,e)=>{Gh.init(t,e),Pe.init(t,e)}),es=A("ZodUUID",(t,e)=>{Bh.init(t,e),Pe.init(t,e)}),nu=A("ZodURL",(t,e)=>{Qh.init(t,e),Pe.init(t,e)});function Gm(t){return Kc(nu,t)}const Bm=A("ZodEmoji",(t,e)=>{Xh.init(t,e),Pe.init(t,e)}),Ym=A("ZodNanoID",(t,e)=>{ep.init(t,e),Pe.init(t,e)}),Qm=A("ZodCUID",(t,e)=>{tp.init(t,e),Pe.init(t,e)}),Xm=A("ZodCUID2",(t,e)=>{rp.init(t,e),Pe.init(t,e)}),e_=A("ZodULID",(t,e)=>{np.init(t,e),Pe.init(t,e)}),t_=A("ZodXID",(t,e)=>{sp.init(t,e),Pe.init(t,e)}),r_=A("ZodKSUID",(t,e)=>{ap.init(t,e),Pe.init(t,e)}),n_=A("ZodIPv4",(t,e)=>{lp.init(t,e),Pe.init(t,e)}),s_=A("ZodIPv6",(t,e)=>{dp.init(t,e),Pe.init(t,e)}),a_=A("ZodCIDRv4",(t,e)=>{fp.init(t,e),Pe.init(t,e)}),i_=A("ZodCIDRv6",(t,e)=>{hp.init(t,e),Pe.init(t,e)}),o_=A("ZodBase64",(t,e)=>{pp.init(t,e),Pe.init(t,e)}),c_=A("ZodBase64URL",(t,e)=>{_p.init(t,e),Pe.init(t,e)}),u_=A("ZodE164",(t,e)=>{gp.init(t,e),Pe.init(t,e)}),l_=A("ZodJWT",(t,e)=>{vp.init(t,e),Pe.init(t,e)}),ha=A("ZodNumber",(t,e)=>{Ac.init(t,e),Re.init(t,e),t.gt=(n,s)=>t.check(Gc(n,s)),t.gte=(n,s)=>t.check(fa(n,s)),t.min=(n,s)=>t.check(fa(n,s)),t.lt=(n,s)=>t.check(Jc(n,s)),t.lte=(n,s)=>t.check(da(n,s)),t.max=(n,s)=>t.check(da(n,s)),t.int=n=>t.check(su(n)),t.safe=n=>t.check(su(n)),t.positive=n=>t.check(Gc(0,n)),t.nonnegative=n=>t.check(fa(0,n)),t.negative=n=>t.check(Jc(0,n)),t.nonpositive=n=>t.check(da(0,n)),t.multipleOf=(n,s)=>t.check(Bc(n,s)),t.step=(n,s)=>t.check(Bc(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 _e(t){return pm(ha,t)}const d_=A("ZodNumberFormat",(t,e)=>{wp.init(t,e),ha.init(t,e)});function su(t){return _m(d_,t)}const f_=A("ZodBoolean",(t,e)=>{bp.init(t,e),Re.init(t,e)});function ke(t){return gm(f_,t)}const h_=A("ZodNull",(t,e)=>{Sp.init(t,e),Re.init(t,e)});function au(t){return ym(h_,t)}const p_=A("ZodAny",(t,e)=>{kp.init(t,e),Re.init(t,e)});function m_(){return vm(p_)}const __=A("ZodUnknown",(t,e)=>{$p.init(t,e),Re.init(t,e)});function Ce(){return wm(__)}const g_=A("ZodNever",(t,e)=>{Ep.init(t,e),Re.init(t,e)});function y_(t){return bm(g_,t)}const v_=A("ZodArray",(t,e)=>{Rp.init(t,e),Re.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Qn(r,n)),t.nonempty=r=>t.check(Qn(1,r)),t.max=(r,n)=>t.check(Yc(r,n)),t.length=(r,n)=>t.check(Qc(r,n)),t.unwrap=()=>t.element});function V(t,e){return Nm(v_,t,e)}const iu=A("ZodObject",(t,e)=>{Mc.init(t,e),Re.init(t,e),Se(t,"shape",()=>e.shape),t.keyof=()=>et(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Ce()}),t.loose=()=>t.clone({...t._zod.def,catchall:Ce()}),t.strict=()=>t.clone({...t._zod.def,catchall:y_()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>Xf(t,r),t.merge=r=>eh(t,r),t.pick=r=>Yf(t,r),t.omit=r=>Qf(t,r),t.partial=(...r)=>th(lu,t,r[0]),t.required=(...r)=>rh(fu,t,r[0])});function H(t,e){const r={type:"object",get shape(){return Rr(this,"shape",{...t}),this.shape},...Q(e)};return new iu(r)}function Le(t,e){return new iu({type:"object",get shape(){return Rr(this,"shape",{...t}),this.shape},catchall:Ce(),...Q(e)})}const ou=A("ZodUnion",(t,e)=>{Zc.init(t,e),Re.init(t,e),t.options=e.options});function $e(t,e){return new ou({type:"union",options:t,...Q(e)})}const w_=A("ZodDiscriminatedUnion",(t,e)=>{ou.init(t,e),Tp.init(t,e)});function cu(t,e,r){return new w_({type:"union",options:e,discriminator:t,...Q(r)})}const b_=A("ZodIntersection",(t,e)=>{Pp.init(t,e),Re.init(t,e)});function pa(t,e){return new b_({type:"intersection",left:t,right:e})}const S_=A("ZodRecord",(t,e)=>{Cp.init(t,e),Re.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function Ie(t,e,r){return new S_({type:"record",keyType:t,valueType:e,...Q(r)})}const ma=A("ZodEnum",(t,e)=>{Ip.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 ma({...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 ma({...e,checks:[],...Q(s),entries:a})}});function et(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new ma({type:"enum",entries:r,...Q(e)})}const k_=A("ZodLiteral",(t,e)=>{Op.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 k_({type:"literal",values:Array.isArray(t)?t:[t],...Q(e)})}const $_=A("ZodTransform",(t,e)=>{Np.init(t,e),Re.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=a=>{if(typeof a=="string")r.issues.push(Ir(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(Ir(i))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(a=>(r.value=a,r)):(r.value=s,r)}});function uu(t){return new $_({type:"transform",transform:t})}const lu=A("ZodOptional",(t,e)=>{Ap.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Oe(t){return new lu({type:"optional",innerType:t})}const E_=A("ZodNullable",(t,e)=>{jp.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType});function du(t){return new E_({type:"nullable",innerType:t})}const R_=A("ZodDefault",(t,e)=>{zp.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function T_(t,e){return new R_({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const P_=A("ZodPrefault",(t,e)=>{Mp.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType});function C_(t,e){return new P_({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const fu=A("ZodNonOptional",(t,e)=>{qp.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType});function I_(t,e){return new fu({type:"nonoptional",innerType:t,...Q(e)})}const O_=A("ZodCatch",(t,e)=>{Zp.init(t,e),Re.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function N_(t,e){return new O_({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const A_=A("ZodPipe",(t,e)=>{Lp.init(t,e),Re.init(t,e),t.in=e.in,t.out=e.out});function _a(t,e){return new A_({type:"pipe",in:t,out:e})}const j_=A("ZodReadonly",(t,e)=>{xp.init(t,e),Re.init(t,e)});function z_(t){return new j_({type:"readonly",innerType:t})}const hu=A("ZodCustom",(t,e)=>{Dp.init(t,e),Re.init(t,e)});function M_(t){const e=new Je({check:"custom"});return e._zod.check=t,e}function q_(t,e){return Am(hu,t??(()=>!0),e)}function Z_(t,e={}){return jm(hu,t,e)}function L_(t){const e=M_(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Ir(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(Ir(s))}},t(r.value,r)));return e}function pu(t,e){return _a(uu(t),e)}const x_={custom:"custom"};function D_(t){return mm(ha,t)}const Ut="2025-11-25",U_="2025-03-26",ga=[Ut,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],It="io.modelcontextprotocol/related-task",Ar="2.0",xe=q_(t=>t!==null&&(typeof t=="object"||typeof t=="function")),ya=$e([R(),_e().int()]),va=R(),V_=Le({ttl:$e([_e(),au()]).optional(),pollInterval:_e().optional()}),mu=H({ttl:_e().optional()}),_u=H({taskId:R()}),wa=Le({progressToken:ya.optional(),[It]:_u.optional()}),tt=H({_meta:wa.optional()}),tr=tt.extend({task:mu.optional()}),gu=t=>tr.safeParse(t).success,ze=H({method:R(),params:tt.loose().optional()}),st=H({_meta:wa.optional()}),rt=H({method:R(),params:st.loose().optional()}),Me=Le({_meta:wa.optional()}),jr=$e([R(),_e().int()]),ba=H({jsonrpc:te(Ar),id:jr,...ze.shape}).strict(),ts=t=>ba.safeParse(t).success,Sa=H({jsonrpc:te(Ar),...rt.shape}).strict(),yu=t=>Sa.safeParse(t).success,rs=H({jsonrpc:te(Ar),id:jr,result:Me}).strict(),Vt=t=>rs.safeParse(t).success,F_=Vt;S.ErrorCode=void 0,(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"})(S.ErrorCode||(S.ErrorCode={}));const zr=H({jsonrpc:te(Ar),id:jr.optional(),error:H({code:_e().int(),message:R(),data:Ce().optional()})}).strict(),H_=zr,ka=t=>zr.safeParse(t).success,W_=ka,Mr=$e([ba,Sa,rs,zr]),K_=$e([rs,zr]),Ot=Me.strict(),vu=st.extend({requestId:jr.optional(),reason:R().optional()}),ns=rt.extend({method:te("notifications/cancelled"),params:vu}),wu=H({src:R(),mimeType:R().optional(),sizes:V(R()).optional(),theme:et(["light","dark"]).optional()}),rr=H({icons:V(wu).optional()}),Ft=H({name:R(),title:R().optional()}),$a=Ft.extend({...Ft.shape,...rr.shape,version:R(),websiteUrl:R().optional(),description:R().optional()}),J_=pa(H({applyDefaults:ke().optional()}),Ie(R(),Ce())),G_=pu(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,pa(H({form:J_.optional(),url:xe.optional()}),Ie(R(),Ce()).optional())),bu=Le({list:xe.optional(),cancel:xe.optional(),requests:Le({sampling:Le({createMessage:xe.optional()}).optional(),elicitation:Le({create:xe.optional()}).optional()}).optional()}),Su=Le({list:xe.optional(),cancel:xe.optional(),requests:Le({tools:Le({call:xe.optional()}).optional()}).optional()}),ku=H({experimental:Ie(R(),xe).optional(),sampling:H({context:xe.optional(),tools:xe.optional()}).optional(),elicitation:G_.optional(),roots:H({listChanged:ke().optional()}).optional(),tasks:bu.optional()}),$u=tt.extend({protocolVersion:R(),capabilities:ku,clientInfo:$a}),ss=ze.extend({method:te("initialize"),params:$u}),B_=t=>ss.safeParse(t).success,Eu=H({experimental:Ie(R(),xe).optional(),logging:xe.optional(),completions:xe.optional(),prompts:H({listChanged:ke().optional()}).optional(),resources:H({subscribe:ke().optional(),listChanged:ke().optional()}).optional(),tools:H({listChanged:ke().optional()}).optional(),tasks:Su.optional()}),Ea=Me.extend({protocolVersion:R(),capabilities:Eu,serverInfo:$a,instructions:R().optional()}),as=rt.extend({method:te("notifications/initialized"),params:st.optional()}),Ru=t=>as.safeParse(t).success,is=ze.extend({method:te("ping"),params:tt.optional()}),Tu=H({progress:_e(),total:Oe(_e()),message:Oe(R())}),Pu=H({...st.shape,...Tu.shape,progressToken:ya}),os=rt.extend({method:te("notifications/progress"),params:Pu}),Cu=tt.extend({cursor:va.optional()}),nr=ze.extend({params:Cu.optional()}),sr=Me.extend({nextCursor:va.optional()}),Iu=et(["working","input_required","completed","failed","cancelled"]),ar=H({taskId:R(),status:Iu,ttl:$e([_e(),au()]),createdAt:R(),lastUpdatedAt:R(),pollInterval:Oe(_e()),statusMessage:Oe(R())}),Ht=Me.extend({task:ar}),Ou=st.merge(ar),qr=rt.extend({method:te("notifications/tasks/status"),params:Ou}),cs=ze.extend({method:te("tasks/get"),params:tt.extend({taskId:R()})}),us=Me.merge(ar),ls=ze.extend({method:te("tasks/result"),params:tt.extend({taskId:R()})}),Y_=Me.loose(),ds=nr.extend({method:te("tasks/list")}),fs=sr.extend({tasks:V(ar)}),hs=ze.extend({method:te("tasks/cancel"),params:tt.extend({taskId:R()})}),Nu=Me.merge(ar),Ra=H({uri:R(),mimeType:Oe(R()),_meta:Ie(R(),Ce()).optional()}),Ta=Ra.extend({text:R()}),Pa=R().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ca=Ra.extend({blob:Pa}),ir=et(["user","assistant"]),Wt=H({audience:V(ir).optional(),priority:_e().min(0).max(1).optional(),lastModified:eu({offset:!0}).optional()}),Ia=H({...Ft.shape,...rr.shape,uri:R(),description:Oe(R()),mimeType:Oe(R()),annotations:Wt.optional(),_meta:Oe(Le({}))}),Au=H({...Ft.shape,...rr.shape,uriTemplate:R(),description:Oe(R()),mimeType:Oe(R()),annotations:Wt.optional(),_meta:Oe(Le({}))}),ps=nr.extend({method:te("resources/list")}),Oa=sr.extend({resources:V(Ia)}),ms=nr.extend({method:te("resources/templates/list")}),Na=sr.extend({resourceTemplates:V(Au)}),_s=tt.extend({uri:R()}),ju=_s,gs=ze.extend({method:te("resources/read"),params:ju}),Aa=Me.extend({contents:V($e([Ta,Ca]))}),ja=rt.extend({method:te("notifications/resources/list_changed"),params:st.optional()}),zu=_s,Mu=ze.extend({method:te("resources/subscribe"),params:zu}),qu=_s,Zu=ze.extend({method:te("resources/unsubscribe"),params:qu}),Lu=st.extend({uri:R()}),xu=rt.extend({method:te("notifications/resources/updated"),params:Lu}),Du=H({name:R(),description:Oe(R()),required:Oe(ke())}),Uu=H({...Ft.shape,...rr.shape,description:Oe(R()),arguments:Oe(V(Du)),_meta:Oe(Le({}))}),ys=nr.extend({method:te("prompts/list")}),za=sr.extend({prompts:V(Uu)}),Vu=tt.extend({name:R(),arguments:Ie(R(),R()).optional()}),vs=ze.extend({method:te("prompts/get"),params:Vu}),ws=H({type:te("text"),text:R(),annotations:Wt.optional(),_meta:Ie(R(),Ce()).optional()}),bs=H({type:te("image"),data:Pa,mimeType:R(),annotations:Wt.optional(),_meta:Ie(R(),Ce()).optional()}),Ss=H({type:te("audio"),data:Pa,mimeType:R(),annotations:Wt.optional(),_meta:Ie(R(),Ce()).optional()}),Fu=H({type:te("tool_use"),name:R(),id:R(),input:Ie(R(),Ce()),_meta:Ie(R(),Ce()).optional()}),Hu=H({type:te("resource"),resource:$e([Ta,Ca]),annotations:Wt.optional(),_meta:Ie(R(),Ce()).optional()}),Wu=Ia.extend({type:te("resource_link")}),ks=$e([ws,bs,Ss,Wu,Hu]),Ku=H({role:ir,content:ks}),Ma=Me.extend({description:R().optional(),messages:V(Ku)}),qa=rt.extend({method:te("notifications/prompts/list_changed"),params:st.optional()}),Ju=H({title:R().optional(),readOnlyHint:ke().optional(),destructiveHint:ke().optional(),idempotentHint:ke().optional(),openWorldHint:ke().optional()}),Gu=H({taskSupport:et(["required","optional","forbidden"]).optional()}),Za=H({...Ft.shape,...rr.shape,description:R().optional(),inputSchema:H({type:te("object"),properties:Ie(R(),xe).optional(),required:V(R()).optional()}).catchall(Ce()),outputSchema:H({type:te("object"),properties:Ie(R(),xe).optional(),required:V(R()).optional()}).catchall(Ce()).optional(),annotations:Ju.optional(),execution:Gu.optional(),_meta:Ie(R(),Ce()).optional()}),$s=nr.extend({method:te("tools/list")}),La=sr.extend({tools:V(Za)}),or=Me.extend({content:V(ks).default([]),structuredContent:Ie(R(),Ce()).optional(),isError:ke().optional()}),Q_=or.or(Me.extend({toolResult:Ce()})),Bu=tr.extend({name:R(),arguments:Ie(R(),Ce()).optional()}),Zr=ze.extend({method:te("tools/call"),params:Bu}),xa=rt.extend({method:te("notifications/tools/list_changed"),params:st.optional()}),Yu=H({autoRefresh:ke().default(!0),debounceMs:_e().int().nonnegative().default(300)}),Lr=et(["debug","info","notice","warning","error","critical","alert","emergency"]),Qu=tt.extend({level:Lr}),Da=ze.extend({method:te("logging/setLevel"),params:Qu}),Xu=st.extend({level:Lr,logger:R().optional(),data:Ce()}),el=rt.extend({method:te("notifications/message"),params:Xu}),tl=H({name:R().optional()}),rl=H({hints:V(tl).optional(),costPriority:_e().min(0).max(1).optional(),speedPriority:_e().min(0).max(1).optional(),intelligencePriority:_e().min(0).max(1).optional()}),nl=H({mode:et(["auto","required","none"]).optional()}),sl=H({type:te("tool_result"),toolUseId:R().describe("The unique identifier for the corresponding tool call."),content:V(ks).default([]),structuredContent:H({}).loose().optional(),isError:ke().optional(),_meta:Ie(R(),Ce()).optional()}),al=cu("type",[ws,bs,Ss]),xr=cu("type",[ws,bs,Ss,Fu,sl]),il=H({role:ir,content:$e([xr,V(xr)]),_meta:Ie(R(),Ce()).optional()}),ol=tr.extend({messages:V(il),modelPreferences:rl.optional(),systemPrompt:R().optional(),includeContext:et(["none","thisServer","allServers"]).optional(),temperature:_e().optional(),maxTokens:_e().int(),stopSequences:V(R()).optional(),metadata:xe.optional(),tools:V(Za).optional(),toolChoice:nl.optional()}),Ua=ze.extend({method:te("sampling/createMessage"),params:ol}),Es=Me.extend({model:R(),stopReason:Oe(et(["endTurn","stopSequence","maxTokens"]).or(R())),role:ir,content:al}),Rs=Me.extend({model:R(),stopReason:Oe(et(["endTurn","stopSequence","maxTokens","toolUse"]).or(R())),role:ir,content:$e([xr,V(xr)])}),cl=H({type:te("boolean"),title:R().optional(),description:R().optional(),default:ke().optional()}),ul=H({type:te("string"),title:R().optional(),description:R().optional(),minLength:_e().optional(),maxLength:_e().optional(),format:et(["email","uri","date","date-time"]).optional(),default:R().optional()}),ll=H({type:et(["number","integer"]),title:R().optional(),description:R().optional(),minimum:_e().optional(),maximum:_e().optional(),default:_e().optional()}),dl=H({type:te("string"),title:R().optional(),description:R().optional(),enum:V(R()),default:R().optional()}),fl=H({type:te("string"),title:R().optional(),description:R().optional(),oneOf:V(H({const:R(),title:R()})),default:R().optional()}),hl=H({type:te("string"),title:R().optional(),description:R().optional(),enum:V(R()),enumNames:V(R()).optional(),default:R().optional()}),pl=$e([dl,fl]),ml=H({type:te("array"),title:R().optional(),description:R().optional(),minItems:_e().optional(),maxItems:_e().optional(),items:H({type:te("string"),enum:V(R())}),default:V(R()).optional()}),_l=H({type:te("array"),title:R().optional(),description:R().optional(),minItems:_e().optional(),maxItems:_e().optional(),items:H({anyOf:V(H({const:R(),title:R()}))}),default:V(R()).optional()}),gl=$e([ml,_l]),yl=$e([hl,pl,gl]),vl=$e([yl,cl,ul,ll]),wl=tr.extend({mode:te("form").optional(),message:R(),requestedSchema:H({type:te("object"),properties:Ie(R(),vl),required:V(R()).optional()})}),bl=tr.extend({mode:te("url"),message:R(),elicitationId:R(),url:R().url()}),Sl=$e([wl,bl]),Va=ze.extend({method:te("elicitation/create"),params:Sl}),kl=st.extend({elicitationId:R()}),$l=rt.extend({method:te("notifications/elicitation/complete"),params:kl}),Dr=Me.extend({action:et(["accept","decline","cancel"]),content:pu(t=>t===null?void 0:t,Ie(R(),$e([R(),_e(),ke(),V(R())])).optional())}),Fa=H({type:te("ref/resource"),uri:R()}),X_=Fa,El=H({type:te("ref/prompt"),name:R()}),Rl=tt.extend({ref:$e([El,Fa]),argument:H({name:R(),value:R()}),context:H({arguments:Ie(R(),R()).optional()}).optional()}),Ts=ze.extend({method:te("completion/complete"),params:Rl});function Tl(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Pl(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}const Ha=Me.extend({completion:Le({values:V(R()).max(100),total:Oe(_e().int()),hasMore:Oe(ke())})}),Cl=H({uri:R().startsWith("file://"),name:R().optional(),_meta:Ie(R(),Ce()).optional()}),Il=ze.extend({method:te("roots/list"),params:tt.optional()}),Wa=Me.extend({roots:V(Cl)}),Ol=rt.extend({method:te("notifications/roots/list_changed"),params:st.optional()}),eg=$e([is,ss,Ts,Da,vs,ys,ps,ms,gs,Mu,Zu,Zr,$s,cs,ls,ds,hs]),tg=$e([ns,os,as,Ol,qr]),rg=$e([Ot,Es,Rs,Dr,Wa,us,fs,Ht]),ng=$e([is,Ua,Va,Il,cs,ls,ds,hs]),sg=$e([ns,os,el,xu,ja,xa,qa,qr,$l]),ag=$e([Ot,Ea,Ha,Ma,za,Oa,Na,Aa,or,La,us,fs,Ht]);class W 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===S.ErrorCode.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new Nl(s.elicitations,r)}return new W(e,r,n)}}class Nl extends W{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(S.ErrorCode.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}const Al=1e6,Ka=1e6,jl=1e4,ig=1e6;class bt{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){bt.validateLength(e,Al,"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>jl)throw new Error(`Template contains too many expressions (max ${jl})`);const o=e.slice(s+1,i),c=this.getOperator(o),u=o.includes("*"),l=this.getNames(o),h=l[0];for(const g of l)bt.validateLength(g,Ka,"Variable name");r.push({name:h,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 bt.validateLength(e,Ka,"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(h=>this.encodeValue(h,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(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)bt.validateLength(a,Ka,"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){bt.validateLength(e,Al,"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:u,name:l}of c)r+=u,n.push({name:l,exploded:o.exploded})}r+="$",bt.validateLength(r,ig,"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:u}=n[o],l=a[o+1],h=c.replace("*","");u&&l.includes(",")?i[h]=l.split(","):i[h]=l}return i}}const Ps=Symbol.for("mcp.completable");function og(t,e){return Object.defineProperty(t,Ps,{value:{complete:e},enumerable:!1,writable:!1,configurable:!1}),t}function Ja(t){return!!t&&typeof t=="object"&&Ps in t}function zl(t){return t[Ps]?.complete}function cg(t){return t}S.McpZodTypeKind=void 0,(function(t){t.Completable="McpCompletable"})(S.McpZodTypeKind||(S.McpZodTypeKind={}));function ug(t){return t.title!==void 0&&t.title!==""?t.title:"annotations"in t&&t.annotations?.title?t.annotations.title:t.name}var he;(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})(he||(he={}));var Ml;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Ml||(Ml={}));const B=he.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Nt=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=he.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"]);class St 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 u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(r(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof St))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,he.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()}}St.create=t=>new St(t);const Ga=(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,he.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:r=`Unrecognized key(s) in object: ${he.joinValues(t.keys,", ")}`;break;case Z.invalid_union:r="Invalid input";break;case Z.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${he.joinValues(t.options)}`;break;case Z.invalid_enum_value:r=`Invalid enum value. Expected ${he.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}"`:he.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,he.assertNever(t)}return{message:r}};let lg=Ga;function dg(){return lg}const fg=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(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}};function J(t,e){const r=dg(),n=fg({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ga?void 0:Ga].filter(s=>!!s)});t.common.issues.push(n)}class nt{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 a=await s.key,i=await s.value;n.push({key:a,value:i})}return nt.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 se;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 se=Object.freeze({status:"aborted"}),Ur=t=>({status:"dirty",value:t}),at=t=>({status:"valid",value:t}),ql=t=>t.status==="aborted",Zl=t=>t.status==="dirty",cr=t=>t.status==="valid",Cs=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 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 Ll=(t,e)=>{if(cr(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 St(t.common.issues);return this._error=r,this._error}}};function oe(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 fe{get description(){return this._def.description}_getType(e){return Nt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Nt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nt,ctx:{common:e.parent.common,data:e.data,parsedType:Nt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Cs(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:Nt(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Ll(n,s)}"~validate"(e){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nt(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:r});return cr(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=>cr(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:Nt(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Cs(s)?s:Promise.resolve(s));return Ll(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 dr({schema:this,typeName:x.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 kt.create(this,this._def)}nullable(){return fr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return gt.create(this)}promise(){return As.create(this,this._def)}or(e){return Os.create([this,e],this._def)}and(e){return Ns.create(this,e,this._def)}transform(e){return new dr({...oe(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Qa({...oe(this._def),innerType:this,defaultValue:r,typeName:x.ZodDefault})}brand(){return new zg({typeName:x.ZodBranded,type:this,...oe(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Xa({...oe(this._def),innerType:this,catchValue:r,typeName:x.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return ei.create(this,e)}readonly(){return ti.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const hg=/^c[^\s-]{8,}$/i,pg=/^[0-9a-z]+$/,mg=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_g=/^[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,gg=/^[a-z0-9_-]{21}$/i,yg=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,vg=/^[-+]?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)?)??$/,wg=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bg="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ba;const Sg=/^(?:(?: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])$/,kg=/^(?:(?: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])$/,$g=/^(([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]))$/,Eg=/^(([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])$/,Rg=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Tg=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,xl="((\\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])))",Pg=new RegExp(`^${xl}$`);function Dl(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 Cg(t){return new RegExp(`^${Dl(t)}$`)}function Ig(t){let e=`${xl}T${Dl(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 Og(t,e){return!!((e==="v4"||!e)&&Sg.test(t)||(e==="v6"||!e)&&$g.test(t))}function Ng(t,e){if(!yg.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 Ag(t,e){return!!((e==="v4"||!e)&&kg.test(t)||(e==="v6"||!e)&&Eg.test(t))}class Kt extends fe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==B.string){const a=this._getOrReturnCtx(e);return J(a,{code:Z.invalid_type,expected:B.string,received:a.parsedType}),se}const n=new nt;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),J(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),J(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?J(s,{code:Z.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&J(s,{code:Z.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")wg.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"email",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ba||(Ba=new RegExp(bg,"u")),Ba.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"emoji",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")_g.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"uuid",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")gg.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"nanoid",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")hg.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"cuid",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")pg.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"cuid2",code:Z.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")mg.test(e.data)||(s=this._getOrReturnCtx(e,s),J(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),J(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),J(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),J(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),J(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),J(s,{code:Z.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Ig(a).test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{code:Z.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Pg.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{code:Z.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Cg(a).test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{code:Z.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?vg.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"duration",code:Z.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Og(e.data,a.version)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"ip",code:Z.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Ng(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"jwt",code:Z.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Ag(e.data,a.version)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"cidr",code:Z.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Rg.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"base64",code:Z.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Tg.test(e.data)||(s=this._getOrReturnCtx(e,s),J(s,{validation:"base64url",code:Z.invalid_string,message:a.message}),n.dirty()):he.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 Kt({...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 Kt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Kt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Kt({...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}}Kt.create=t=>new Kt({checks:[],typeName:x.ZodString,coerce:t?.coerce??!1,...oe(t)});function jg(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 Vr extends fe{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 a=this._getOrReturnCtx(e);return J(a,{code:Z.invalid_type,expected:B.number,received:a.parsedType}),se}let n;const s=new nt;for(const a of this._def.checks)a.kind==="int"?he.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),J(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),J(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),J(n,{code:Z.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?jg(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),J(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),J(n,{code:Z.not_finite,message:a.message}),s.dirty()):he.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 Vr({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:X.toString(s)}]})}_addCheck(e){return new Vr({...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"&&he.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)}}Vr.create=t=>new Vr({checks:[],typeName:x.ZodNumber,coerce:t?.coerce||!1,...oe(t)});class Fr extends fe{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 nt;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),J(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),J(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),J(n,{code:Z.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):he.assertNever(a);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,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 Fr({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:X.toString(s)}]})}_addCheck(e){return new Fr({...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}}Fr.create=t=>new Fr({checks:[],typeName:x.ZodBigInt,coerce:t?.coerce??!1,...oe(t)});class Ul extends fe{_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 at(e.data)}}Ul.create=t=>new Ul({typeName:x.ZodBoolean,coerce:t?.coerce||!1,...oe(t)});class Is extends fe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==B.date){const a=this._getOrReturnCtx(e);return J(a,{code:Z.invalid_type,expected:B.date,received:a.parsedType}),se}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return J(a,{code:Z.invalid_date}),se}const n=new nt;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),J(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),J(s,{code:Z.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):he.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Is({...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}}Is.create=t=>new Is({checks:[],coerce:t?.coerce||!1,typeName:x.ZodDate,...oe(t)});class Vl extends fe{_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 at(e.data)}}Vl.create=t=>new Vl({typeName:x.ZodSymbol,...oe(t)});class Fl extends fe{_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 at(e.data)}}Fl.create=t=>new Fl({typeName:x.ZodUndefined,...oe(t)});class Hl extends fe{_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 at(e.data)}}Hl.create=t=>new Hl({typeName:x.ZodNull,...oe(t)});class Wl extends fe{constructor(){super(...arguments),this._any=!0}_parse(e){return at(e.data)}}Wl.create=t=>new Wl({typeName:x.ZodAny,...oe(t)});class Kl extends fe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return at(e.data)}}Kl.create=t=>new Kl({typeName:x.ZodUnknown,...oe(t)});class jt extends fe{_parse(e){const r=this._getOrReturnCtx(e);return J(r,{code:Z.invalid_type,expected:B.never,received:r.parsedType}),se}}jt.create=t=>new jt({typeName:x.ZodNever,...oe(t)});class Jl extends fe{_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 at(e.data)}}Jl.create=t=>new Jl({typeName:x.ZodVoid,...oe(t)});class gt extends fe{_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,o=r.data.length<s.exactLength.value;(i||o)&&(J(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&&(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,o)=>s.type._parseAsync(new At(r,i,r.path,o)))).then(i=>nt.mergeArray(n,i));const a=[...r.data].map((i,o)=>s.type._parseSync(new At(r,i,r.path,o)));return nt.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new gt({...this._def,minLength:{value:e,message:X.toString(r)}})}max(e,r){return new gt({...this._def,maxLength:{value:e,message:X.toString(r)}})}length(e,r){return new gt({...this._def,exactLength:{value:e,message:X.toString(r)}})}nonempty(e){return this.min(1,e)}}gt.create=(t,e)=>new gt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...oe(e)});function ur(t){if(t instanceof Ne){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=kt.create(ur(n))}return new Ne({...t._def,shape:()=>e})}else return t instanceof gt?new gt({...t._def,type:ur(t.element)}):t instanceof kt?kt.create(ur(t.unwrap())):t instanceof fr?fr.create(ur(t.unwrap())):t instanceof Jt?Jt.create(t.items.map(e=>ur(e))):t}class Ne extends fe{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=he.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:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof jt&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const l=a[u],h=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new At(s,h,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof jt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of o)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")o.length>0&&(J(s,{code:Z.unrecognized_keys,keys:o}),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 o){const h=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new At(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const h=await l.key,g=await l.value;u.push({key:h,value:g,alwaysSet:l.alwaysSet})}return u}).then(u=>nt.mergeObjectSync(n,u)):nt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return X.errToObj,new Ne({...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 Ne({...this._def,unknownKeys:"strip"})}passthrough(){return new Ne({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ne({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ne({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Ne({...this._def,catchall:e})}pick(e){const r={};for(const n of he.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Ne({...this._def,shape:()=>r})}omit(e){const r={};for(const n of he.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new Ne({...this._def,shape:()=>r})}deepPartial(){return ur(this)}partial(e){const r={};for(const n of he.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new Ne({...this._def,shape:()=>r})}required(e){const r={};for(const n of he.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof kt;)a=a._def.innerType;r[n]=a}return new Ne({...this._def,shape:()=>r})}keyof(){return Ql(he.objectKeys(this.shape))}}Ne.create=(t,e)=>new Ne({shape:()=>t,unknownKeys:"strip",catchall:jt.create(),typeName:x.ZodObject,...oe(e)}),Ne.strictCreate=(t,e)=>new Ne({shape:()=>t,unknownKeys:"strict",catchall:jt.create(),typeName:x.ZodObject,...oe(e)}),Ne.lazycreate=(t,e)=>new Ne({shape:t,unknownKeys:"strip",catchall:jt.create(),typeName:x.ZodObject,...oe(e)});class Os extends fe{_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 St(o.ctx.common.issues));return J(r,{code:Z.invalid_union,unionErrors:i}),se}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 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"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new St(c));return J(r,{code:Z.invalid_union,unionErrors:o}),se}}get options(){return this._def.options}}Os.create=(t,e)=>new Os({options:t,typeName:x.ZodUnion,...oe(e)});function Ya(t,e){const r=Nt(t),n=Nt(e);if(t===e)return{valid:!0,data:t};if(r===B.object&&n===B.object){const s=he.objectKeys(e),a=he.objectKeys(t).filter(o=>s.indexOf(o)!==-1),i={...t,...e};for(const o of a){const c=Ya(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=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 a=0;a<t.length;a++){const i=t[a],o=e[a],c=Ya(i,o);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 Ns extends fe{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(ql(a)||ql(i))return se;const o=Ya(a.value,i.value);return o.valid?((Zl(a)||Zl(i))&&r.dirty(),{status:r.value,value:o.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(([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}))}}Ns.create=(t,e,r)=>new Ns({left:t,right:e,typeName:x.ZodIntersection,...oe(r)});class Jt extends fe{_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 a=[...n.data].map((i,o)=>{const c=this._def.items[o]||this._def.rest;return c?c._parse(new At(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>nt.mergeArray(r,i)):nt.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Jt({...this._def,rest:e})}}Jt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Jt({items:t,typeName:x.ZodTuple,rest:null,...oe(e)})};class Gl extends fe{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,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new At(n,o,n.path,[u,"key"])),value:a._parse(new At(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=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(),o.set(u.value,l.value)}return{status:r.value,value:o}})}else{const o=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(),o.set(u.value,l.value)}return{status:r.value,value:o}}}}Gl.create=(t,e,r)=>new Gl({valueType:e,keyType:t,typeName:x.ZodMap,...oe(r)});class Hr extends fe{_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 a=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 o=[...n.data.values()].map((c,u)=>a._parse(new At(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,r){return new Hr({...this._def,minSize:{value:e,message:X.toString(r)}})}max(e,r){return new Hr({...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)}}Hr.create=(t,e)=>new Hr({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...oe(e)});class Bl extends fe{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})}}Bl.create=(t,e)=>new Bl({getter:t,typeName:x.ZodLazy,...oe(e)});class Yl extends fe{_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}}Yl.create=(t,e)=>new Yl({value:t,typeName:x.ZodLiteral,...oe(e)});function Ql(t,e){return new lr({values:t,typeName:x.ZodEnum,...oe(e)})}class lr extends fe{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return J(r,{expected:he.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 at(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 lr.create(e,{...this._def,...r})}exclude(e,r=this._def){return lr.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}lr.create=Ql;class Xl extends fe{_parse(e){const r=he.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==B.string&&n.parsedType!==B.number){const s=he.objectValues(r);return J(n,{expected:he.joinValues(s),received:n.parsedType,code:Z.invalid_type}),se}if(this._cache||(this._cache=new Set(he.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=he.objectValues(r);return J(n,{received:n.data,code:Z.invalid_enum_value,options:s}),se}return at(e.data)}get enum(){return this._def.values}}Xl.create=(t,e)=>new Xl({values:t,typeName:x.ZodNativeEnum,...oe(e)});class As extends fe{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 at(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}As.create=(t,e)=>new As({type:t,typeName:x.ZodPromise,...oe(e)});class dr extends fe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.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=>{J(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 se;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?se:c.status==="dirty"||r.value==="dirty"?Ur(c.value):c});{if(r.value==="aborted")return se;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?se:o.status==="dirty"||r.value==="dirty"?Ur(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"?se:(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"?se:(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(!cr(i))return se;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=>cr(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:r.value,value:o})):se);he.assertNever(s)}}dr.create=(t,e,r)=>new dr({schema:t,typeName:x.ZodEffects,effect:e,...oe(r)}),dr.createWithPreprocess=(t,e,r)=>new dr({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...oe(r)});class kt extends fe{_parse(e){return this._getType(e)===B.undefined?at(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}kt.create=(t,e)=>new kt({innerType:t,typeName:x.ZodOptional,...oe(e)});class fr extends fe{_parse(e){return this._getType(e)===B.null?at(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fr.create=(t,e)=>new fr({innerType:t,typeName:x.ZodNullable,...oe(e)});class Qa extends fe{_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}}Qa.create=(t,e)=>new Qa({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...oe(e)});class Xa extends fe{_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 Cs(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new St(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new St(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Xa.create=(t,e)=>new Xa({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...oe(e)});class ed extends fe{_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}}}ed.create=t=>new ed({typeName:x.ZodNaN,...oe(t)});class zg extends fe{_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 ei extends fe{_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"?se:a.status==="dirty"?(r.dirty(),Ur(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"?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 ei({in:e,out:r,typeName:x.ZodPipeline})}}class ti extends fe{_parse(e){const r=this._def.innerType._parse(e),n=s=>(cr(s)&&(s.value=Object.freeze(s.value)),s);return Cs(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}ti.create=(t,e)=>new ti({innerType:t,typeName:x.ZodReadonly,...oe(e)});var x;(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"})(x||(x={})),jt.create,gt.create;const Mg=Ne.create;Os.create,Ns.create,Jt.create,lr.create,As.create,kt.create,fr.create;const qg=A("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");be.init(t,e),t.def=e,t.parse=(r,n)=>ah(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>oa(t,r,n),t.parseAsync=async(r,n)=>ih(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>ca(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)=>Pt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))}),Zg=A("ZodMiniObject",(t,e)=>{Mc.init(t,e),qg.init(t,e),Se(t,"shape",()=>e.shape)});function td(t,e){const r={type:"object",get shape(){return Rr(this,"shape",{...t}),this.shape},...Q(e)};return new Zg(r)}function lt(t){return!!t._zod}function hr(t){const e=Object.values(t);if(e.length===0)return td({});const r=e.every(lt),n=e.every(s=>!lt(s));if(r)return td(t);if(n)return Mg(t);throw new Error("Mixed Zod versions detected in object shape.")}function dt(t,e){return lt(t)?oa(t,e):t.safeParse(e)}async function ri(t,e){return lt(t)?await ca(t,e):await t.safeParseAsync(e)}function pr(t){if(!t)return;let e;if(lt(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Wr(t){if(t){if(typeof t=="object"){const e=t,r=t;if(!e._def&&!r._zod){const n=Object.values(t);if(n.length>0&&n.every(s=>typeof s=="object"&&s!==null&&(s._def!==void 0||s._zod!==void 0||typeof s.parse=="function")))return hr(t)}}if(lt(t)){const r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function ni(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 Lg(t){return t.description}function xg(t){if(lt(t))return t._zod?.def?.type==="optional";const e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function rd(t){if(lt(t)){const a=t._zod?.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.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 Gt(t){return t==="completed"||t==="failed"||t==="cancelled"}const Dg=Symbol("Let zodToJsonSchema decide on which parser to use"),nd={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"},Ug=t=>typeof t=="string"?{...nd,name:t}:{...nd,...t},Vg=t=>{const e=Ug(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 sd(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ve(t,e,r,n,s){t[e]=r,sd(t,e,n,s)}const ad=(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 Ge(t){if(t.target!=="openAi")return{};const e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?ad(e,t.currentPath):e.join("/")}}function Fg(t,e){const r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==x.ZodAny&&(r.items=pe(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ve(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ve(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ve(r,"minItems",t.exactLength.value,t.exactLength.message,e),ve(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function Hg(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?ve(r,"minimum",n.value,n.message,e):ve(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ve(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ve(r,"maximum",n.value,n.message,e):ve(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ve(r,"maximum",n.value,n.message,e));break;case"multipleOf":ve(r,"multipleOf",n.value,n.message,e);break}return r}function Wg(){return{type:"boolean"}}function id(t,e){return pe(t.type._def,e)}const Kg=(t,e)=>pe(t.innerType._def,e);function od(t,e,r){const n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,a)=>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 Jg(t,e)}}const Jg=(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":ve(r,"minimum",n.value,n.message,e);break;case"max":ve(r,"maximum",n.value,n.message,e);break}return r};function Gg(t,e){return{...pe(t.innerType._def,e),default:t.defaultValue()}}function Bg(t,e){return e.effectStrategy==="input"?pe(t.schema._def,e):Ge(e)}function Yg(t){return{type:"string",enum:Array.from(t.values)}}const Qg=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Xg(t,e){const r=[pe(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),pe(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 ey(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 si;const ft={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:()=>(si===void 0&&(si=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),si),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 cd(t,e){const r={type:"string"};if(t.checks)for(const n of t.checks)switch(n.kind){case"min":ve(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ve(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":ht(r,"email",n.message,e);break;case"format:idn-email":ht(r,"idn-email",n.message,e);break;case"pattern:zod":He(r,ft.email,n.message,e);break}break;case"url":ht(r,"uri",n.message,e);break;case"uuid":ht(r,"uuid",n.message,e);break;case"regex":He(r,n.regex,n.message,e);break;case"cuid":He(r,ft.cuid,n.message,e);break;case"cuid2":He(r,ft.cuid2,n.message,e);break;case"startsWith":He(r,RegExp(`^${ai(n.value,e)}`),n.message,e);break;case"endsWith":He(r,RegExp(`${ai(n.value,e)}$`),n.message,e);break;case"datetime":ht(r,"date-time",n.message,e);break;case"date":ht(r,"date",n.message,e);break;case"time":ht(r,"time",n.message,e);break;case"duration":ht(r,"duration",n.message,e);break;case"length":ve(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ve(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{He(r,RegExp(ai(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&ht(r,"ipv4",n.message,e),n.version!=="v4"&&ht(r,"ipv6",n.message,e);break}case"base64url":He(r,ft.base64url,n.message,e);break;case"jwt":He(r,ft.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&He(r,ft.ipv4Cidr,n.message,e),n.version!=="v4"&&He(r,ft.ipv6Cidr,n.message,e);break}case"emoji":He(r,ft.emoji(),n.message,e);break;case"ulid":{He(r,ft.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{ht(r,"binary",n.message,e);break}case"contentEncoding:base64":{ve(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{He(r,ft.base64,n.message,e);break}}break}case"nanoid":He(r,ft.nanoid,n.message,e)}return r}function ai(t,e){return e.patternStrategy==="escape"?ry(t):t}const ty=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ry(t){let e="";for(let r=0;r<t.length;r++)ty.has(t[r])||(e+="\\"),e+=t[r];return e}function ht(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}}})):ve(t,"format",e,r,n)}function He(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:ud(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ve(t,"pattern",ud(e,n),r,n)}function ud(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 f=l[1];if(e===l[0]){i(l);continue}if(n.external){const v=n.external.registry.get(l[0])?.id;if(e!==l[0]&&v){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(f.cycle){i(l);continue}if(f.count>1&&n.reused==="ref"){i(l);continue}}const o=(l,f)=>{const b=this.seen.get(l),v=b.def??b.schema,g={...v};if(b.ref===null)return;const w=b.ref;if(b.ref=null,w){o(w,f);const m=this.seen.get(w).schema;m.$ref&&f.target==="draft-7"?(v.allOf=v.allOf??[],v.allOf.push(m)):(Object.assign(v,m),Object.assign(v,g))}b.isParent||this.override({zodSchema:l,jsonSchema:v,path:b.path??[]})};for(const l of[...this.seen.entries()].reverse())o(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 f=l[1];f.def&&f.defId&&(u[f.defId]=f.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 xm(t,e){if(t instanceof Kc){const n=new tu(e),s={};for(const o of t._idmap.entries()){const[c,u]=o;n.process(u)}const a={},i={registry:t,uri:e?.uri,defs:s};for(const o of t._idmap.entries()){const[c,u]=o;a[c]=n.emit(u,{...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 tu(e);return r.process(t),r.emit(t,e)}function ze(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 ze(s.element,r);case"object":{for(const a in s.shape)if(ze(s.shape[a],r))return!0;return!1}case"union":{for(const a of s.options)if(ze(a,r))return!0;return!1}case"intersection":return ze(s.left,r)||ze(s.right,r);case"tuple":{for(const a of s.items)if(ze(a,r))return!0;return!!(s.rest&&ze(s.rest,r))}case"record":return ze(s.keyType,r)||ze(s.valueType,r);case"map":return ze(s.keyType,r)||ze(s.valueType,r);case"set":return ze(s.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return ze(s.innerType,r);case"lazy":return ze(s.getter(),r);case"default":return ze(s.innerType,r);case"prefault":return ze(s.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return ze(s.in,r)||ze(s.out,r);case"success":return!1;case"catch":return!1}throw new Error(`Unknown schema type: ${s.type}`)}const Lm=q("ZodISODateTime",(t,e)=>{lp.init(t,e),Ce.init(t,e)});function ru(t){return pm(Lm,t)}const Dm=q("ZodISODate",(t,e)=>{dp.init(t,e),Ce.init(t,e)});function Um(t){return mm(Dm,t)}const Vm=q("ZodISOTime",(t,e)=>{fp.init(t,e),Ce.init(t,e)});function Fm(t){return gm(Vm,t)}const Hm=q("ZodISODuration",(t,e)=>{hp.init(t,e),Ce.init(t,e)});function Wm(t){return _m(Hm,t)}const es=q("ZodError",(t,e)=>{Sc.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>ch(t,r)},flatten:{value:r=>oh(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}),Km=$c(es),Jm=kc(es),Bm=Ec(es),Gm=Rc(es),Te=q("ZodType",(t,e)=>(be.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)=>Pt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>Km(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Bm(t,r,n),t.parseAsync=async(r,n)=>Jm(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Gm(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(Ug(r,n)),t.superRefine=r=>t.check(Vg(r)),t.overwrite=r=>t.check(Ar(r)),t.optional=()=>Ne(t),t.nullable=()=>hu(t),t.nullish=()=>Ne(hu(t)),t.nonoptional=r=>zg(t,r),t.array=()=>K(t),t.or=r=>Ee([t,r]),t.and=r=>ma(t,r),t.transform=r=>_a(t,du(r)),t.default=r=>Og(t,r),t.prefault=r=>Ag(t,r),t.catch=r=>Mg(t,r),t.pipe=r=>_a(t,r),t.readonly=()=>xg(t),t.describe=r=>{const n=t.clone();return Nr.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Nr.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Nr.get(t);const n=t.clone();return Nr.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),nu=q("_ZodString",(t,e)=>{la.init(t,e),Te.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(Rm(...n)),t.includes=(...n)=>t.check(Cm(...n)),t.startsWith=(...n)=>t.check(Im(...n)),t.endsWith=(...n)=>t.check(Om(...n)),t.min=(...n)=>t.check(Xn(...n)),t.max=(...n)=>t.check(Xc(...n)),t.length=(...n)=>t.check(eu(...n)),t.nonempty=(...n)=>t.check(Xn(1,...n)),t.lowercase=n=>t.check(Tm(n)),t.uppercase=n=>t.check(Pm(n)),t.trim=()=>t.check(Am()),t.normalize=(...n)=>t.check(Nm(...n)),t.toLowerCase=()=>t.check(zm()),t.toUpperCase=()=>t.check(jm())}),Ym=q("ZodString",(t,e)=>{la.init(t,e),nu.init(t,e),t.email=r=>t.check(Jp(Qm,r)),t.url=r=>t.check(Bc(au,r)),t.jwt=r=>t.check(hm(pg,r)),t.emoji=r=>t.check(Xp(eg,r)),t.guid=r=>t.check(Jc(su,r)),t.uuid=r=>t.check(Bp(ts,r)),t.uuidv4=r=>t.check(Gp(ts,r)),t.uuidv6=r=>t.check(Yp(ts,r)),t.uuidv7=r=>t.check(Qp(ts,r)),t.nanoid=r=>t.check(em(tg,r)),t.guid=r=>t.check(Jc(su,r)),t.cuid=r=>t.check(tm(rg,r)),t.cuid2=r=>t.check(rm(ng,r)),t.ulid=r=>t.check(nm(sg,r)),t.base64=r=>t.check(lm(dg,r)),t.base64url=r=>t.check(dm(fg,r)),t.xid=r=>t.check(sm(ag,r)),t.ksuid=r=>t.check(am(ig,r)),t.ipv4=r=>t.check(im(og,r)),t.ipv6=r=>t.check(om(cg,r)),t.cidrv4=r=>t.check(cm(ug,r)),t.cidrv6=r=>t.check(um(lg,r)),t.e164=r=>t.check(fm(hg,r)),t.datetime=r=>t.check(ru(r)),t.date=r=>t.check(Um(r)),t.time=r=>t.check(Fm(r)),t.duration=r=>t.check(Wm(r))});function T(t){return Kp(Ym,t)}const Ce=q("ZodStringFormat",(t,e)=>{Re.init(t,e),nu.init(t,e)}),Qm=q("ZodEmail",(t,e)=>{tp.init(t,e),Ce.init(t,e)}),su=q("ZodGUID",(t,e)=>{Xh.init(t,e),Ce.init(t,e)}),ts=q("ZodUUID",(t,e)=>{ep.init(t,e),Ce.init(t,e)}),au=q("ZodURL",(t,e)=>{rp.init(t,e),Ce.init(t,e)});function Xm(t){return Bc(au,t)}const eg=q("ZodEmoji",(t,e)=>{np.init(t,e),Ce.init(t,e)}),tg=q("ZodNanoID",(t,e)=>{sp.init(t,e),Ce.init(t,e)}),rg=q("ZodCUID",(t,e)=>{ap.init(t,e),Ce.init(t,e)}),ng=q("ZodCUID2",(t,e)=>{ip.init(t,e),Ce.init(t,e)}),sg=q("ZodULID",(t,e)=>{op.init(t,e),Ce.init(t,e)}),ag=q("ZodXID",(t,e)=>{cp.init(t,e),Ce.init(t,e)}),ig=q("ZodKSUID",(t,e)=>{up.init(t,e),Ce.init(t,e)}),og=q("ZodIPv4",(t,e)=>{pp.init(t,e),Ce.init(t,e)}),cg=q("ZodIPv6",(t,e)=>{mp.init(t,e),Ce.init(t,e)}),ug=q("ZodCIDRv4",(t,e)=>{gp.init(t,e),Ce.init(t,e)}),lg=q("ZodCIDRv6",(t,e)=>{_p.init(t,e),Ce.init(t,e)}),dg=q("ZodBase64",(t,e)=>{yp.init(t,e),Ce.init(t,e)}),fg=q("ZodBase64URL",(t,e)=>{wp.init(t,e),Ce.init(t,e)}),hg=q("ZodE164",(t,e)=>{bp.init(t,e),Ce.init(t,e)}),pg=q("ZodJWT",(t,e)=>{$p.init(t,e),Ce.init(t,e)}),pa=q("ZodNumber",(t,e)=>{jc.init(t,e),Te.init(t,e),t.gt=(n,s)=>t.check(Yc(n,s)),t.gte=(n,s)=>t.check(ha(n,s)),t.min=(n,s)=>t.check(ha(n,s)),t.lt=(n,s)=>t.check(Gc(n,s)),t.lte=(n,s)=>t.check(fa(n,s)),t.max=(n,s)=>t.check(fa(n,s)),t.int=n=>t.check(iu(n)),t.safe=n=>t.check(iu(n)),t.positive=n=>t.check(Yc(0,n)),t.nonnegative=n=>t.check(ha(0,n)),t.negative=n=>t.check(Gc(0,n)),t.nonpositive=n=>t.check(fa(0,n)),t.multipleOf=(n,s)=>t.check(Qc(n,s)),t.step=(n,s)=>t.check(Qc(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 ye(t){return ym(pa,t)}const mg=q("ZodNumberFormat",(t,e)=>{kp.init(t,e),pa.init(t,e)});function iu(t){return wm(mg,t)}const gg=q("ZodBoolean",(t,e)=>{Ep.init(t,e),Te.init(t,e)});function ke(t){return bm(gg,t)}const _g=q("ZodNull",(t,e)=>{Rp.init(t,e),Te.init(t,e)});function ou(t){return Sm(_g,t)}const yg=q("ZodAny",(t,e)=>{Tp.init(t,e),Te.init(t,e)});function vg(){return $m(yg)}const wg=q("ZodUnknown",(t,e)=>{Pp.init(t,e),Te.init(t,e)});function Ie(){return km(wg)}const bg=q("ZodNever",(t,e)=>{Cp.init(t,e),Te.init(t,e)});function Sg(t){return Em(bg,t)}const $g=q("ZodArray",(t,e)=>{Ip.init(t,e),Te.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Xn(r,n)),t.nonempty=r=>t.check(Xn(1,r)),t.max=(r,n)=>t.check(Xc(r,n)),t.length=(r,n)=>t.check(eu(r,n)),t.unwrap=()=>t.element});function K(t,e){return Mm($g,t,e)}const cu=q("ZodObject",(t,e)=>{Zc.init(t,e),Te.init(t,e),Se(t,"shape",()=>e.shape),t.keyof=()=>et(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:Ie()}),t.loose=()=>t.clone({...t._zod.def,catchall:Ie()}),t.strict=()=>t.clone({...t._zod.def,catchall:Sg()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>nh(t,r),t.merge=r=>sh(t,r),t.pick=r=>th(t,r),t.omit=r=>rh(t,r),t.partial=(...r)=>ah(fu,t,r[0]),t.required=(...r)=>ih(pu,t,r[0])});function J(t,e){const r={type:"object",get shape(){return Tr(this,"shape",{...t}),this.shape},...Q(e)};return new cu(r)}function De(t,e){return new cu({type:"object",get shape(){return Tr(this,"shape",{...t}),this.shape},catchall:Ie(),...Q(e)})}const uu=q("ZodUnion",(t,e)=>{Lc.init(t,e),Te.init(t,e),t.options=e.options});function Ee(t,e){return new uu({type:"union",options:t,...Q(e)})}const kg=q("ZodDiscriminatedUnion",(t,e)=>{uu.init(t,e),Op.init(t,e)});function lu(t,e,r){return new kg({type:"union",options:e,discriminator:t,...Q(r)})}const Eg=q("ZodIntersection",(t,e)=>{Np.init(t,e),Te.init(t,e)});function ma(t,e){return new Eg({type:"intersection",left:t,right:e})}const Rg=q("ZodRecord",(t,e)=>{Ap.init(t,e),Te.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function Oe(t,e,r){return new Rg({type:"record",keyType:t,valueType:e,...Q(r)})}const ga=q("ZodEnum",(t,e)=>{zp.init(t,e),Te.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 ga({...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 ga({...e,checks:[],...Q(s),entries:a})}});function et(t,e){const r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new ga({type:"enum",entries:r,...Q(e)})}const Tg=q("ZodLiteral",(t,e)=>{jp.init(t,e),Te.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 Tg({type:"literal",values:Array.isArray(t)?t:[t],...Q(e)})}const Pg=q("ZodTransform",(t,e)=>{Mp.init(t,e),Te.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=a=>{if(typeof a=="string")r.issues.push(Or(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(Or(i))}};const s=e.transform(r.value,r);return s instanceof Promise?s.then(a=>(r.value=a,r)):(r.value=s,r)}});function du(t){return new Pg({type:"transform",transform:t})}const fu=q("ZodOptional",(t,e)=>{qp.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ne(t){return new fu({type:"optional",innerType:t})}const Cg=q("ZodNullable",(t,e)=>{Zp.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType});function hu(t){return new Cg({type:"nullable",innerType:t})}const Ig=q("ZodDefault",(t,e)=>{xp.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Og(t,e){return new Ig({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const Ng=q("ZodPrefault",(t,e)=>{Lp.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Ag(t,e){return new Ng({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}const pu=q("ZodNonOptional",(t,e)=>{Dp.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType});function zg(t,e){return new pu({type:"nonoptional",innerType:t,...Q(e)})}const jg=q("ZodCatch",(t,e)=>{Up.init(t,e),Te.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Mg(t,e){return new jg({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}const qg=q("ZodPipe",(t,e)=>{Vp.init(t,e),Te.init(t,e),t.in=e.in,t.out=e.out});function _a(t,e){return new qg({type:"pipe",in:t,out:e})}const Zg=q("ZodReadonly",(t,e)=>{Fp.init(t,e),Te.init(t,e)});function xg(t){return new Zg({type:"readonly",innerType:t})}const mu=q("ZodCustom",(t,e)=>{Hp.init(t,e),Te.init(t,e)});function Lg(t){const e=new Je({check:"custom"});return e._zod.check=t,e}function Dg(t,e){return qm(mu,t??(()=>!0),e)}function Ug(t,e={}){return Zm(mu,t,e)}function Vg(t){const e=Lg(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(Or(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(Or(s))}},t(r.value,r)));return e}function gu(t,e){return _a(du(t),e)}const Fg={custom:"custom"};function Hg(t){return vm(pa,t)}const Ut="2025-11-25",Wg="2025-03-26",ya=[Ut,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],It="io.modelcontextprotocol/related-task",zr="2.0",Ue=Dg(t=>t!==null&&(typeof t=="object"||typeof t=="function")),va=Ee([T(),ye().int()]),wa=T(),Kg=De({ttl:Ee([ye(),ou()]).optional(),pollInterval:ye().optional()}),_u=J({ttl:ye().optional()}),yu=J({taskId:T()}),ba=De({progressToken:va.optional(),[It]:yu.optional()}),tt=J({_meta:ba.optional()}),rr=tt.extend({task:_u.optional()}),vu=t=>rr.safeParse(t).success,Me=J({method:T(),params:tt.loose().optional()}),st=J({_meta:ba.optional()}),rt=J({method:T(),params:st.loose().optional()}),qe=De({_meta:ba.optional()}),jr=Ee([T(),ye().int()]),Sa=J({jsonrpc:te(zr),id:jr,...Me.shape}).strict(),rs=t=>Sa.safeParse(t).success,$a=J({jsonrpc:te(zr),...rt.shape}).strict(),wu=t=>$a.safeParse(t).success,ns=J({jsonrpc:te(zr),id:jr,result:qe}).strict(),Vt=t=>ns.safeParse(t).success,Jg=Vt;$.ErrorCode=void 0,(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"})($.ErrorCode||($.ErrorCode={}));const Mr=J({jsonrpc:te(zr),id:jr.optional(),error:J({code:ye().int(),message:T(),data:Ie().optional()})}).strict(),Bg=Mr,ka=t=>Mr.safeParse(t).success,Gg=ka,qr=Ee([Sa,$a,ns,Mr]),Yg=Ee([ns,Mr]),Ot=qe.strict(),bu=st.extend({requestId:jr.optional(),reason:T().optional()}),ss=rt.extend({method:te("notifications/cancelled"),params:bu}),Su=J({src:T(),mimeType:T().optional(),sizes:K(T()).optional(),theme:et(["light","dark"]).optional()}),nr=J({icons:K(Su).optional()}),Ft=J({name:T(),title:T().optional()}),Ea=Ft.extend({...Ft.shape,...nr.shape,version:T(),websiteUrl:T().optional(),description:T().optional()}),Qg=ma(J({applyDefaults:ke().optional()}),Oe(T(),Ie())),Xg=gu(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ma(J({form:Qg.optional(),url:Ue.optional()}),Oe(T(),Ie()).optional())),$u=De({list:Ue.optional(),cancel:Ue.optional(),requests:De({sampling:De({createMessage:Ue.optional()}).optional(),elicitation:De({create:Ue.optional()}).optional()}).optional()}),ku=De({list:Ue.optional(),cancel:Ue.optional(),requests:De({tools:De({call:Ue.optional()}).optional()}).optional()}),Eu=J({experimental:Oe(T(),Ue).optional(),sampling:J({context:Ue.optional(),tools:Ue.optional()}).optional(),elicitation:Xg.optional(),roots:J({listChanged:ke().optional()}).optional(),tasks:$u.optional()}),Ru=tt.extend({protocolVersion:T(),capabilities:Eu,clientInfo:Ea}),as=Me.extend({method:te("initialize"),params:Ru}),e_=t=>as.safeParse(t).success,Tu=J({experimental:Oe(T(),Ue).optional(),logging:Ue.optional(),completions:Ue.optional(),prompts:J({listChanged:ke().optional()}).optional(),resources:J({subscribe:ke().optional(),listChanged:ke().optional()}).optional(),tools:J({listChanged:ke().optional()}).optional(),tasks:ku.optional()}),Ra=qe.extend({protocolVersion:T(),capabilities:Tu,serverInfo:Ea,instructions:T().optional()}),is=rt.extend({method:te("notifications/initialized"),params:st.optional()}),Pu=t=>is.safeParse(t).success,os=Me.extend({method:te("ping"),params:tt.optional()}),Cu=J({progress:ye(),total:Ne(ye()),message:Ne(T())}),Iu=J({...st.shape,...Cu.shape,progressToken:va}),cs=rt.extend({method:te("notifications/progress"),params:Iu}),Ou=tt.extend({cursor:wa.optional()}),sr=Me.extend({params:Ou.optional()}),ar=qe.extend({nextCursor:wa.optional()}),Nu=et(["working","input_required","completed","failed","cancelled"]),ir=J({taskId:T(),status:Nu,ttl:Ee([ye(),ou()]),createdAt:T(),lastUpdatedAt:T(),pollInterval:Ne(ye()),statusMessage:Ne(T())}),Ht=qe.extend({task:ir}),Au=st.merge(ir),Zr=rt.extend({method:te("notifications/tasks/status"),params:Au}),us=Me.extend({method:te("tasks/get"),params:tt.extend({taskId:T()})}),ls=qe.merge(ir),ds=Me.extend({method:te("tasks/result"),params:tt.extend({taskId:T()})}),t_=qe.loose(),fs=sr.extend({method:te("tasks/list")}),hs=ar.extend({tasks:K(ir)}),ps=Me.extend({method:te("tasks/cancel"),params:tt.extend({taskId:T()})}),zu=qe.merge(ir),Ta=J({uri:T(),mimeType:Ne(T()),_meta:Oe(T(),Ie()).optional()}),Pa=Ta.extend({text:T()}),Ca=T().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ia=Ta.extend({blob:Ca}),or=et(["user","assistant"]),Wt=J({audience:K(or).optional(),priority:ye().min(0).max(1).optional(),lastModified:ru({offset:!0}).optional()}),Oa=J({...Ft.shape,...nr.shape,uri:T(),description:Ne(T()),mimeType:Ne(T()),annotations:Wt.optional(),_meta:Ne(De({}))}),ju=J({...Ft.shape,...nr.shape,uriTemplate:T(),description:Ne(T()),mimeType:Ne(T()),annotations:Wt.optional(),_meta:Ne(De({}))}),ms=sr.extend({method:te("resources/list")}),Na=ar.extend({resources:K(Oa)}),gs=sr.extend({method:te("resources/templates/list")}),Aa=ar.extend({resourceTemplates:K(ju)}),_s=tt.extend({uri:T()}),Mu=_s,ys=Me.extend({method:te("resources/read"),params:Mu}),za=qe.extend({contents:K(Ee([Pa,Ia]))}),ja=rt.extend({method:te("notifications/resources/list_changed"),params:st.optional()}),qu=_s,Zu=Me.extend({method:te("resources/subscribe"),params:qu}),xu=_s,Lu=Me.extend({method:te("resources/unsubscribe"),params:xu}),Du=st.extend({uri:T()}),Uu=rt.extend({method:te("notifications/resources/updated"),params:Du}),Vu=J({name:T(),description:Ne(T()),required:Ne(ke())}),Fu=J({...Ft.shape,...nr.shape,description:Ne(T()),arguments:Ne(K(Vu)),_meta:Ne(De({}))}),vs=sr.extend({method:te("prompts/list")}),Ma=ar.extend({prompts:K(Fu)}),Hu=tt.extend({name:T(),arguments:Oe(T(),T()).optional()}),ws=Me.extend({method:te("prompts/get"),params:Hu}),bs=J({type:te("text"),text:T(),annotations:Wt.optional(),_meta:Oe(T(),Ie()).optional()}),Ss=J({type:te("image"),data:Ca,mimeType:T(),annotations:Wt.optional(),_meta:Oe(T(),Ie()).optional()}),$s=J({type:te("audio"),data:Ca,mimeType:T(),annotations:Wt.optional(),_meta:Oe(T(),Ie()).optional()}),Wu=J({type:te("tool_use"),name:T(),id:T(),input:Oe(T(),Ie()),_meta:Oe(T(),Ie()).optional()}),Ku=J({type:te("resource"),resource:Ee([Pa,Ia]),annotations:Wt.optional(),_meta:Oe(T(),Ie()).optional()}),Ju=Oa.extend({type:te("resource_link")}),ks=Ee([bs,Ss,$s,Ju,Ku]),Bu=J({role:or,content:ks}),qa=qe.extend({description:T().optional(),messages:K(Bu)}),Za=rt.extend({method:te("notifications/prompts/list_changed"),params:st.optional()}),Gu=J({title:T().optional(),readOnlyHint:ke().optional(),destructiveHint:ke().optional(),idempotentHint:ke().optional(),openWorldHint:ke().optional()}),Yu=J({taskSupport:et(["required","optional","forbidden"]).optional()}),xa=J({...Ft.shape,...nr.shape,description:T().optional(),inputSchema:J({type:te("object"),properties:Oe(T(),Ue).optional(),required:K(T()).optional()}).catchall(Ie()),outputSchema:J({type:te("object"),properties:Oe(T(),Ue).optional(),required:K(T()).optional()}).catchall(Ie()).optional(),annotations:Gu.optional(),execution:Yu.optional(),_meta:Oe(T(),Ie()).optional()}),Es=sr.extend({method:te("tools/list")}),La=ar.extend({tools:K(xa)}),cr=qe.extend({content:K(ks).default([]),structuredContent:Oe(T(),Ie()).optional(),isError:ke().optional()}),r_=cr.or(qe.extend({toolResult:Ie()})),Qu=rr.extend({name:T(),arguments:Oe(T(),Ie()).optional()}),xr=Me.extend({method:te("tools/call"),params:Qu}),Da=rt.extend({method:te("notifications/tools/list_changed"),params:st.optional()}),Xu=J({autoRefresh:ke().default(!0),debounceMs:ye().int().nonnegative().default(300)}),Lr=et(["debug","info","notice","warning","error","critical","alert","emergency"]),el=tt.extend({level:Lr}),Ua=Me.extend({method:te("logging/setLevel"),params:el}),tl=st.extend({level:Lr,logger:T().optional(),data:Ie()}),rl=rt.extend({method:te("notifications/message"),params:tl}),nl=J({name:T().optional()}),sl=J({hints:K(nl).optional(),costPriority:ye().min(0).max(1).optional(),speedPriority:ye().min(0).max(1).optional(),intelligencePriority:ye().min(0).max(1).optional()}),al=J({mode:et(["auto","required","none"]).optional()}),il=J({type:te("tool_result"),toolUseId:T().describe("The unique identifier for the corresponding tool call."),content:K(ks).default([]),structuredContent:J({}).loose().optional(),isError:ke().optional(),_meta:Oe(T(),Ie()).optional()}),ol=lu("type",[bs,Ss,$s]),Dr=lu("type",[bs,Ss,$s,Wu,il]),cl=J({role:or,content:Ee([Dr,K(Dr)]),_meta:Oe(T(),Ie()).optional()}),ul=rr.extend({messages:K(cl),modelPreferences:sl.optional(),systemPrompt:T().optional(),includeContext:et(["none","thisServer","allServers"]).optional(),temperature:ye().optional(),maxTokens:ye().int(),stopSequences:K(T()).optional(),metadata:Ue.optional(),tools:K(xa).optional(),toolChoice:al.optional()}),Va=Me.extend({method:te("sampling/createMessage"),params:ul}),Rs=qe.extend({model:T(),stopReason:Ne(et(["endTurn","stopSequence","maxTokens"]).or(T())),role:or,content:ol}),Ts=qe.extend({model:T(),stopReason:Ne(et(["endTurn","stopSequence","maxTokens","toolUse"]).or(T())),role:or,content:Ee([Dr,K(Dr)])}),ll=J({type:te("boolean"),title:T().optional(),description:T().optional(),default:ke().optional()}),dl=J({type:te("string"),title:T().optional(),description:T().optional(),minLength:ye().optional(),maxLength:ye().optional(),format:et(["email","uri","date","date-time"]).optional(),default:T().optional()}),fl=J({type:et(["number","integer"]),title:T().optional(),description:T().optional(),minimum:ye().optional(),maximum:ye().optional(),default:ye().optional()}),hl=J({type:te("string"),title:T().optional(),description:T().optional(),enum:K(T()),default:T().optional()}),pl=J({type:te("string"),title:T().optional(),description:T().optional(),oneOf:K(J({const:T(),title:T()})),default:T().optional()}),ml=J({type:te("string"),title:T().optional(),description:T().optional(),enum:K(T()),enumNames:K(T()).optional(),default:T().optional()}),gl=Ee([hl,pl]),_l=J({type:te("array"),title:T().optional(),description:T().optional(),minItems:ye().optional(),maxItems:ye().optional(),items:J({type:te("string"),enum:K(T())}),default:K(T()).optional()}),yl=J({type:te("array"),title:T().optional(),description:T().optional(),minItems:ye().optional(),maxItems:ye().optional(),items:J({anyOf:K(J({const:T(),title:T()}))}),default:K(T()).optional()}),vl=Ee([_l,yl]),wl=Ee([ml,gl,vl]),bl=Ee([wl,ll,dl,fl]),Sl=rr.extend({mode:te("form").optional(),message:T(),requestedSchema:J({type:te("object"),properties:Oe(T(),bl),required:K(T()).optional()})}),$l=rr.extend({mode:te("url"),message:T(),elicitationId:T(),url:T().url()}),kl=Ee([Sl,$l]),Fa=Me.extend({method:te("elicitation/create"),params:kl}),El=st.extend({elicitationId:T()}),Rl=rt.extend({method:te("notifications/elicitation/complete"),params:El}),Ur=qe.extend({action:et(["accept","decline","cancel"]),content:gu(t=>t===null?void 0:t,Oe(T(),Ee([T(),ye(),ke(),K(T())])).optional())}),Ha=J({type:te("ref/resource"),uri:T()}),n_=Ha,Tl=J({type:te("ref/prompt"),name:T()}),Pl=tt.extend({ref:Ee([Tl,Ha]),argument:J({name:T(),value:T()}),context:J({arguments:Oe(T(),T()).optional()}).optional()}),Ps=Me.extend({method:te("completion/complete"),params:Pl});function Cl(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Il(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}const Wa=qe.extend({completion:De({values:K(T()).max(100),total:Ne(ye().int()),hasMore:Ne(ke())})}),Ol=J({uri:T().startsWith("file://"),name:T().optional(),_meta:Oe(T(),Ie()).optional()}),Nl=Me.extend({method:te("roots/list"),params:tt.optional()}),Ka=qe.extend({roots:K(Ol)}),Al=rt.extend({method:te("notifications/roots/list_changed"),params:st.optional()}),s_=Ee([os,as,Ps,Ua,ws,vs,ms,gs,ys,Zu,Lu,xr,Es,us,ds,fs,ps]),a_=Ee([ss,cs,is,Al,Zr]),i_=Ee([Ot,Rs,Ts,Ur,Ka,ls,hs,Ht]),o_=Ee([os,Va,Fa,Nl,us,ds,fs,ps]),c_=Ee([ss,cs,rl,Uu,ja,Da,Za,Zr,Rl]),u_=Ee([Ot,Ra,Wa,qa,Ma,Na,Aa,za,cr,La,ls,hs,Ht]);class B 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===$.ErrorCode.UrlElicitationRequired&&n){const s=n;if(s.elicitations)return new zl(s.elicitations,r)}return new B(e,r,n)}}class zl extends B{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super($.ErrorCode.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}}const jl=1e6,Ja=1e6,Ml=1e4,l_=1e6;class bt{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){bt.validateLength(e,jl,"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>Ml)throw new Error(`Template contains too many expressions (max ${Ml})`);const o=e.slice(s+1,i),c=this.getOperator(o),u=o.includes("*"),l=this.getNames(o),f=l[0];for(const b of l)bt.validateLength(b,Ja,"Variable name");r.push({name:f,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 bt.validateLength(e,Ja,"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(f=>this.encodeValue(f,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(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)bt.validateLength(a,Ja,"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){bt.validateLength(e,jl,"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:u,name:l}of c)r+=u,n.push({name:l,exploded:o.exploded})}r+="$",bt.validateLength(r,l_,"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:u}=n[o],l=a[o+1],f=c.replace("*","");u&&l.includes(",")?i[f]=l.split(","):i[f]=l}return i}}const Cs=Symbol.for("mcp.completable");function d_(t,e){return Object.defineProperty(t,Cs,{value:{complete:e},enumerable:!1,writable:!1,configurable:!1}),t}function Ba(t){return!!t&&typeof t=="object"&&Cs in t}function ql(t){return t[Cs]?.complete}function f_(t){return t}$.McpZodTypeKind=void 0,(function(t){t.Completable="McpCompletable"})($.McpZodTypeKind||($.McpZodTypeKind={}));function h_(t){return t.title!==void 0&&t.title!==""?t.title:"annotations"in t&&t.annotations?.title?t.annotations.title:t.name}var pe;(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})(pe||(pe={}));var Zl;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Zl||(Zl={}));const Y=pe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Nt=t=>{switch(typeof t){case"undefined":return Y.undefined;case"string":return Y.string;case"number":return Number.isNaN(t)?Y.nan:Y.number;case"boolean":return Y.boolean;case"function":return Y.function;case"bigint":return Y.bigint;case"symbol":return Y.symbol;case"object":return Array.isArray(t)?Y.array:t===null?Y.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?Y.promise:typeof Map<"u"&&t instanceof Map?Y.map:typeof Set<"u"&&t instanceof Set?Y.set:typeof Date<"u"&&t instanceof Date?Y.date:Y.object;default:return Y.unknown}},U=pe.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"]);class St 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 u=i.path[c];c===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(r(i))):o[u]=o[u]||{_errors:[]},o=o[u],c++}}};return s(this),n}static assert(e){if(!(e instanceof St))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,pe.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()}}St.create=t=>new St(t);const Ga=(t,e)=>{let r;switch(t.code){case U.invalid_type:t.received===Y.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case U.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,pe.jsonStringifyReplacer)}`;break;case U.unrecognized_keys:r=`Unrecognized key(s) in object: ${pe.joinValues(t.keys,", ")}`;break;case U.invalid_union:r="Invalid input";break;case U.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${pe.joinValues(t.options)}`;break;case U.invalid_enum_value:r=`Invalid enum value. Expected ${pe.joinValues(t.options)}, received '${t.received}'`;break;case U.invalid_arguments:r="Invalid function arguments";break;case U.invalid_return_type:r="Invalid function return type";break;case U.invalid_date:r="Invalid date";break;case U.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}"`:pe.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case U.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 U.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 U.custom:r="Invalid input";break;case U.invalid_intersection_types:r="Intersection results could not be merged";break;case U.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case U.not_finite:r="Number must be finite";break;default:r=e.defaultError,pe.assertNever(t)}return{message:r}};let p_=Ga;function m_(){return p_}const g_=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(u=>!!u).slice().reverse();for(const u of c)o=u(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}};function G(t,e){const r=m_(),n=g_({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ga?void 0:Ga].filter(s=>!!s)});t.common.issues.push(n)}class nt{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 a=await s.key,i=await s.value;n.push({key:a,value:i})}return nt.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 se;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 se=Object.freeze({status:"aborted"}),Vr=t=>({status:"dirty",value:t}),at=t=>({status:"valid",value:t}),xl=t=>t.status==="aborted",Ll=t=>t.status==="dirty",ur=t=>t.status==="valid",Is=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 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 Dl=(t,e)=>{if(ur(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 St(t.common.issues);return this._error=r,this._error}}};function ce(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 he{get description(){return this._def.description}_getType(e){return Nt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Nt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new nt,ctx:{common:e.parent.common,data:e.data,parsedType:Nt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Is(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:Nt(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Dl(n,s)}"~validate"(e){const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Nt(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:r});return ur(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=>ur(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:Nt(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Is(s)?s:Promise.resolve(s));return Dl(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:U.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 fr({schema:this,typeName:V.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 $t.create(this,this._def)}nullable(){return hr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _t.create(this)}promise(){return zs.create(this,this._def)}or(e){return Ns.create([this,e],this._def)}and(e){return As.create(this,e,this._def)}transform(e){return new fr({...ce(this._def),schema:this,typeName:V.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Xa({...ce(this._def),innerType:this,defaultValue:r,typeName:V.ZodDefault})}brand(){return new x_({typeName:V.ZodBranded,type:this,...ce(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new ei({...ce(this._def),innerType:this,catchValue:r,typeName:V.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return ti.create(this,e)}readonly(){return ri.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const __=/^c[^\s-]{8,}$/i,y_=/^[0-9a-z]+$/,v_=/^[0-9A-HJKMNP-TV-Z]{26}$/i,w_=/^[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,b_=/^[a-z0-9_-]{21}$/i,S_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,$_=/^[-+]?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)?)??$/,k_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,E_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ya;const R_=/^(?:(?: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])$/,T_=/^(?:(?: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])$/,P_=/^(([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]))$/,C_=/^(([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])$/,I_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,O_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ul="((\\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])))",N_=new RegExp(`^${Ul}$`);function Vl(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 A_(t){return new RegExp(`^${Vl(t)}$`)}function z_(t){let e=`${Ul}T${Vl(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 j_(t,e){return!!((e==="v4"||!e)&&R_.test(t)||(e==="v6"||!e)&&P_.test(t))}function M_(t,e){if(!S_.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 q_(t,e){return!!((e==="v4"||!e)&&T_.test(t)||(e==="v6"||!e)&&C_.test(t))}class Kt extends he{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Y.string){const a=this._getOrReturnCtx(e);return G(a,{code:U.invalid_type,expected:Y.string,received:a.parsedType}),se}const n=new nt;let s;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),G(s,{code:U.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),G(s,{code:U.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?G(s,{code:U.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&G(s,{code:U.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")k_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"email",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ya||(Ya=new RegExp(E_,"u")),Ya.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"emoji",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")w_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"uuid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")b_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"nanoid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")__.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"cuid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")y_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"cuid2",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")v_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"ulid",code:U.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),G(s,{validation:"url",code:U.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),G(s,{validation:"regex",code:U.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),G(s,{code:U.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),G(s,{code:U.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),G(s,{code:U.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?z_(a).test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{code:U.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?N_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{code:U.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?A_(a).test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{code:U.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?$_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"duration",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?j_(e.data,a.version)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"ip",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?M_(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"jwt",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?q_(e.data,a.version)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"cidr",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?I_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"base64",code:U.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?O_.test(e.data)||(s=this._getOrReturnCtx(e,s),G(s,{validation:"base64url",code:U.invalid_string,message:a.message}),n.dirty()):pe.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(s=>e.test(s),{validation:r,code:U.invalid_string,...X.errToObj(n)})}_addCheck(e){return new Kt({...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 Kt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Kt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Kt({...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}}Kt.create=t=>new Kt({checks:[],typeName:V.ZodString,coerce:t?.coerce??!1,...ce(t)});function Z_(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 Fr 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)!==Y.number){const a=this._getOrReturnCtx(e);return G(a,{code:U.invalid_type,expected:Y.number,received:a.parsedType}),se}let n;const s=new nt;for(const a of this._def.checks)a.kind==="int"?pe.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:U.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),G(n,{code:U.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),G(n,{code:U.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Z_(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),G(n,{code:U.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:U.not_finite,message:a.message}),s.dirty()):pe.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 Fr({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:X.toString(s)}]})}_addCheck(e){return new Fr({...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"&&pe.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)}}Fr.create=t=>new Fr({checks:[],typeName:V.ZodNumber,coerce:t?.coerce||!1,...ce(t)});class Hr 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)!==Y.bigint)return this._getInvalidInput(e);let n;const s=new nt;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),G(n,{code:U.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),G(n,{code:U.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),G(n,{code:U.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):pe.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return G(r,{code:U.invalid_type,expected:Y.bigint,received:r.parsedType}),se}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 Hr({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:X.toString(s)}]})}_addCheck(e){return new Hr({...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}}Hr.create=t=>new Hr({checks:[],typeName:V.ZodBigInt,coerce:t?.coerce??!1,...ce(t)});class Fl extends he{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Y.boolean){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.boolean,received:n.parsedType}),se}return at(e.data)}}Fl.create=t=>new Fl({typeName:V.ZodBoolean,coerce:t?.coerce||!1,...ce(t)});class Os extends he{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Y.date){const a=this._getOrReturnCtx(e);return G(a,{code:U.invalid_type,expected:Y.date,received:a.parsedType}),se}if(Number.isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return G(a,{code:U.invalid_date}),se}const n=new nt;let s;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),G(s,{code:U.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),G(s,{code:U.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):pe.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Os({...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}}Os.create=t=>new Os({checks:[],coerce:t?.coerce||!1,typeName:V.ZodDate,...ce(t)});class Hl extends he{_parse(e){if(this._getType(e)!==Y.symbol){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.symbol,received:n.parsedType}),se}return at(e.data)}}Hl.create=t=>new Hl({typeName:V.ZodSymbol,...ce(t)});class Wl extends he{_parse(e){if(this._getType(e)!==Y.undefined){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.undefined,received:n.parsedType}),se}return at(e.data)}}Wl.create=t=>new Wl({typeName:V.ZodUndefined,...ce(t)});class Kl extends he{_parse(e){if(this._getType(e)!==Y.null){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.null,received:n.parsedType}),se}return at(e.data)}}Kl.create=t=>new Kl({typeName:V.ZodNull,...ce(t)});class Jl extends he{constructor(){super(...arguments),this._any=!0}_parse(e){return at(e.data)}}Jl.create=t=>new Jl({typeName:V.ZodAny,...ce(t)});class Bl extends he{constructor(){super(...arguments),this._unknown=!0}_parse(e){return at(e.data)}}Bl.create=t=>new Bl({typeName:V.ZodUnknown,...ce(t)});class zt extends he{_parse(e){const r=this._getOrReturnCtx(e);return G(r,{code:U.invalid_type,expected:Y.never,received:r.parsedType}),se}}zt.create=t=>new zt({typeName:V.ZodNever,...ce(t)});class Gl extends he{_parse(e){if(this._getType(e)!==Y.undefined){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.void,received:n.parsedType}),se}return at(e.data)}}Gl.create=t=>new Gl({typeName:V.ZodVoid,...ce(t)});class _t extends he{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),s=this._def;if(r.parsedType!==Y.array)return G(r,{code:U.invalid_type,expected:Y.array,received:r.parsedType}),se;if(s.exactLength!==null){const i=r.data.length>s.exactLength.value,o=r.data.length<s.exactLength.value;(i||o)&&(G(r,{code:i?U.too_big:U.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&&(G(r,{code:U.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&&(G(r,{code:U.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 At(r,i,r.path,o)))).then(i=>nt.mergeArray(n,i));const a=[...r.data].map((i,o)=>s.type._parseSync(new At(r,i,r.path,o)));return nt.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:V.ZodArray,...ce(e)});function lr(t){if(t instanceof Ae){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=$t.create(lr(n))}return new Ae({...t._def,shape:()=>e})}else return t instanceof _t?new _t({...t._def,type:lr(t.element)}):t instanceof $t?$t.create(lr(t.unwrap())):t instanceof hr?hr.create(lr(t.unwrap())):t instanceof Jt?Jt.create(t.items.map(e=>lr(e))):t}class Ae 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=pe.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==Y.object){const u=this._getOrReturnCtx(e);return G(u,{code:U.invalid_type,expected:Y.object,received:u.parsedType}),se}const{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof zt&&this._def.unknownKeys==="strip"))for(const u in s.data)i.includes(u)||o.push(u);const c=[];for(const u of i){const l=a[u],f=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new At(s,f,s.path,u)),alwaysSet:u in s.data})}if(this._def.catchall instanceof zt){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of o)c.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(u==="strict")o.length>0&&(G(s,{code:U.unrecognized_keys,keys:o}),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 o){const f=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new At(s,f,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of c){const f=await l.key,b=await l.value;u.push({key:f,value:b,alwaysSet:l.alwaysSet})}return u}).then(u=>nt.mergeObjectSync(n,u)):nt.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return X.errToObj,new Ae({...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 Ae({...this._def,unknownKeys:"strip"})}passthrough(){return new Ae({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ae({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ae({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:V.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Ae({...this._def,catchall:e})}pick(e){const r={};for(const n of pe.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new Ae({...this._def,shape:()=>r})}omit(e){const r={};for(const n of pe.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new Ae({...this._def,shape:()=>r})}deepPartial(){return lr(this)}partial(e){const r={};for(const n of pe.objectKeys(this.shape)){const s=this.shape[n];e&&!e[n]?r[n]=s:r[n]=s.optional()}return new Ae({...this._def,shape:()=>r})}required(e){const r={};for(const n of pe.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof $t;)a=a._def.innerType;r[n]=a}return new Ae({...this._def,shape:()=>r})}keyof(){return ed(pe.objectKeys(this.shape))}}Ae.create=(t,e)=>new Ae({shape:()=>t,unknownKeys:"strip",catchall:zt.create(),typeName:V.ZodObject,...ce(e)}),Ae.strictCreate=(t,e)=>new Ae({shape:()=>t,unknownKeys:"strict",catchall:zt.create(),typeName:V.ZodObject,...ce(e)}),Ae.lazycreate=(t,e)=>new Ae({shape:t,unknownKeys:"strip",catchall:zt.create(),typeName:V.ZodObject,...ce(e)});class Ns extends he{_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 St(o.ctx.common.issues));return G(r,{code:U.invalid_union,unionErrors:i}),se}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 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"&&!a&&(a={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new St(c));return G(r,{code:U.invalid_union,unionErrors:o}),se}}get options(){return this._def.options}}Ns.create=(t,e)=>new Ns({options:t,typeName:V.ZodUnion,...ce(e)});function Qa(t,e){const r=Nt(t),n=Nt(e);if(t===e)return{valid:!0,data:t};if(r===Y.object&&n===Y.object){const s=pe.objectKeys(e),a=pe.objectKeys(t).filter(o=>s.indexOf(o)!==-1),i={...t,...e};for(const o of a){const c=Qa(t[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(r===Y.array&&n===Y.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=Qa(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return r===Y.date&&n===Y.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class As extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(xl(a)||xl(i))return se;const o=Qa(a.value,i.value);return o.valid?((Ll(a)||Ll(i))&&r.dirty(),{status:r.value,value:o.data}):(G(n,{code:U.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(([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}))}}As.create=(t,e,r)=>new As({left:t,right:e,typeName:V.ZodIntersection,...ce(r)});class Jt extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.array)return G(n,{code:U.invalid_type,expected:Y.array,received:n.parsedType}),se;if(n.data.length<this._def.items.length)return G(n,{code:U.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),se;!this._def.rest&&n.data.length>this._def.items.length&&(G(n,{code:U.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 At(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>nt.mergeArray(r,i)):nt.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Jt({...this._def,rest:e})}}Jt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Jt({items:t,typeName:V.ZodTuple,rest:null,...ce(e)})};class Yl 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!==Y.map)return G(n,{code:U.invalid_type,expected:Y.map,received:n.parsedType}),se;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],u)=>({key:s._parse(new At(n,o,n.path,[u,"key"])),value:a._parse(new At(n,c,n.path,[u,"value"]))}));if(n.common.async){const o=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(),o.set(u.value,l.value)}return{status:r.value,value:o}})}else{const o=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(),o.set(u.value,l.value)}return{status:r.value,value:o}}}}Yl.create=(t,e,r)=>new Yl({valueType:e,keyType:t,typeName:V.ZodMap,...ce(r)});class Wr extends he{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.set)return G(n,{code:U.invalid_type,expected:Y.set,received:n.parsedType}),se;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(G(n,{code:U.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&&(G(n,{code:U.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 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 o=[...n.data.values()].map((c,u)=>a._parse(new At(n,c,n.path,u)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,r){return new Wr({...this._def,minSize:{value:e,message:X.toString(r)}})}max(e,r){return new Wr({...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)}}Wr.create=(t,e)=>new Wr({valueType:t,minSize:null,maxSize:null,typeName:V.ZodSet,...ce(e)});class Ql 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})}}Ql.create=(t,e)=>new Ql({getter:t,typeName:V.ZodLazy,...ce(e)});class Xl extends he{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return G(r,{received:r.data,code:U.invalid_literal,expected:this._def.value}),se}return{status:"valid",value:e.data}}get value(){return this._def.value}}Xl.create=(t,e)=>new Xl({value:t,typeName:V.ZodLiteral,...ce(e)});function ed(t,e){return new dr({values:t,typeName:V.ZodEnum,...ce(e)})}class dr extends he{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return G(r,{expected:pe.joinValues(n),received:r.parsedType,code:U.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 G(r,{received:r.data,code:U.invalid_enum_value,options:n}),se}return at(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 dr.create(e,{...this._def,...r})}exclude(e,r=this._def){return dr.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}dr.create=ed;class td extends he{_parse(e){const r=pe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Y.string&&n.parsedType!==Y.number){const s=pe.objectValues(r);return G(n,{expected:pe.joinValues(s),received:n.parsedType,code:U.invalid_type}),se}if(this._cache||(this._cache=new Set(pe.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const s=pe.objectValues(r);return G(n,{received:n.data,code:U.invalid_enum_value,options:s}),se}return at(e.data)}get enum(){return this._def.values}}td.create=(t,e)=>new td({values:t,typeName:V.ZodNativeEnum,...ce(e)});class zs extends he{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==Y.promise&&r.common.async===!1)return G(r,{code:U.invalid_type,expected:Y.promise,received:r.parsedType}),se;const n=r.parsedType===Y.promise?r.data:Promise.resolve(r.data);return at(n.then(s=>this._def.type.parseAsync(s,{path:r.path,errorMap:r.common.contextualErrorMap})))}}zs.create=(t,e)=>new zs({type:t,typeName:V.ZodPromise,...ce(e)});class fr extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===V.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=>{G(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 se;const c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?se:c.status==="dirty"||r.value==="dirty"?Vr(c.value):c});{if(r.value==="aborted")return se;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?se:o.status==="dirty"||r.value==="dirty"?Vr(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"?se:(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"?se:(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(!ur(i))return se;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=>ur(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:r.value,value:o})):se);pe.assertNever(s)}}fr.create=(t,e,r)=>new fr({schema:t,typeName:V.ZodEffects,effect:e,...ce(r)}),fr.createWithPreprocess=(t,e,r)=>new fr({schema:e,effect:{type:"preprocess",transform:t},typeName:V.ZodEffects,...ce(r)});class $t extends he{_parse(e){return this._getType(e)===Y.undefined?at(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}$t.create=(t,e)=>new $t({innerType:t,typeName:V.ZodOptional,...ce(e)});class hr extends he{_parse(e){return this._getType(e)===Y.null?at(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}hr.create=(t,e)=>new hr({innerType:t,typeName:V.ZodNullable,...ce(e)});class Xa extends he{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===Y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}Xa.create=(t,e)=>new Xa({innerType:t,typeName:V.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ce(e)});class ei 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 Is(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new St(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new St(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ei.create=(t,e)=>new ei({innerType:t,typeName:V.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ce(e)});class rd extends he{_parse(e){if(this._getType(e)!==Y.nan){const n=this._getOrReturnCtx(e);return G(n,{code:U.invalid_type,expected:Y.nan,received:n.parsedType}),se}return{status:"valid",value:e.data}}}rd.create=t=>new rd({typeName:V.ZodNaN,...ce(t)});class x_ 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 ti extends he{_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"?se:a.status==="dirty"?(r.dirty(),Vr(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"?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 ti({in:e,out:r,typeName:V.ZodPipeline})}}class ri extends he{_parse(e){const r=this._def.innerType._parse(e),n=s=>(ur(s)&&(s.value=Object.freeze(s.value)),s);return Is(r)?r.then(s=>n(s)):n(r)}unwrap(){return this._def.innerType}}ri.create=(t,e)=>new ri({innerType:t,typeName:V.ZodReadonly,...ce(e)});var V;(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"})(V||(V={})),zt.create,_t.create;const L_=Ae.create;Ns.create,As.create,Jt.create,dr.create,zs.create,$t.create,hr.create;const D_=q("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");be.init(t,e),t.def=e,t.parse=(r,n)=>uh(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>ca(t,r,n),t.parseAsync=async(r,n)=>lh(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>ua(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)=>Pt(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))}),U_=q("ZodMiniObject",(t,e)=>{Zc.init(t,e),D_.init(t,e),Se(t,"shape",()=>e.shape)});function nd(t,e){const r={type:"object",get shape(){return Tr(this,"shape",{...t}),this.shape},...Q(e)};return new U_(r)}function lt(t){return!!t._zod}function pr(t){const e=Object.values(t);if(e.length===0)return nd({});const r=e.every(lt),n=e.every(s=>!lt(s));if(r)return nd(t);if(n)return L_(t);throw new Error("Mixed Zod versions detected in object shape.")}function dt(t,e){return lt(t)?ca(t,e):t.safeParse(e)}async function ni(t,e){return lt(t)?await ua(t,e):await t.safeParseAsync(e)}function mr(t){if(!t)return;let e;if(lt(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Kr(t){if(t){if(typeof t=="object"){const e=t,r=t;if(!e._def&&!r._zod){const n=Object.values(t);if(n.length>0&&n.every(s=>typeof s=="object"&&s!==null&&(s._def!==void 0||s._zod!==void 0||typeof s.parse=="function")))return pr(t)}}if(lt(t)){const r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function si(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 V_(t){return t.description}function F_(t){if(lt(t))return t._zod?.def?.type==="optional";const e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function sd(t){if(lt(t)){const a=t._zod?.def;if(a){if(a.value!==void 0)return a.value;if(Array.isArray(a.values)&&a.values.length>0)return a.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 Bt(t){return t==="completed"||t==="failed"||t==="cancelled"}const H_=Symbol("Let zodToJsonSchema decide on which parser to use"),ad={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"},W_=t=>typeof t=="string"?{...ad,name:t}:{...ad,...t},K_=t=>{const e=W_(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 id(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function we(t,e,r,n,s){t[e]=r,id(t,e,n,s)}const od=(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 Be(t){if(t.target!=="openAi")return{};const e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?od(e,t.currentPath):e.join("/")}}function J_(t,e){const r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==V.ZodAny&&(r.items=me(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&we(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&we(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(we(r,"minItems",t.exactLength.value,t.exactLength.message,e),we(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}function B_(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?we(r,"minimum",n.value,n.message,e):we(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),we(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?we(r,"maximum",n.value,n.message,e):we(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),we(r,"maximum",n.value,n.message,e));break;case"multipleOf":we(r,"multipleOf",n.value,n.message,e);break}return r}function G_(){return{type:"boolean"}}function cd(t,e){return me(t.type._def,e)}const Y_=(t,e)=>me(t.innerType._def,e);function ud(t,e,r){const n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((s,a)=>ud(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 Q_(t,e)}}const Q_=(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":we(r,"minimum",n.value,n.message,e);break;case"max":we(r,"maximum",n.value,n.message,e);break}return r};function X_(t,e){return{...me(t.innerType._def,e),default:t.defaultValue()}}function ey(t,e){return e.effectStrategy==="input"?me(t.schema._def,e):Be(e)}function ty(t){return{type:"string",enum:Array.from(t.values)}}const ry=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function ny(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(ry(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 sy(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 ai;const ft={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:()=>(ai===void 0&&(ai=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ai),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 ld(t,e){const r={type:"string"};if(t.checks)for(const n of t.checks)switch(n.kind){case"min":we(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":we(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":ht(r,"email",n.message,e);break;case"format:idn-email":ht(r,"idn-email",n.message,e);break;case"pattern:zod":Ke(r,ft.email,n.message,e);break}break;case"url":ht(r,"uri",n.message,e);break;case"uuid":ht(r,"uuid",n.message,e);break;case"regex":Ke(r,n.regex,n.message,e);break;case"cuid":Ke(r,ft.cuid,n.message,e);break;case"cuid2":Ke(r,ft.cuid2,n.message,e);break;case"startsWith":Ke(r,RegExp(`^${ii(n.value,e)}`),n.message,e);break;case"endsWith":Ke(r,RegExp(`${ii(n.value,e)}$`),n.message,e);break;case"datetime":ht(r,"date-time",n.message,e);break;case"date":ht(r,"date",n.message,e);break;case"time":ht(r,"time",n.message,e);break;case"duration":ht(r,"duration",n.message,e);break;case"length":we(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),we(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Ke(r,RegExp(ii(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&ht(r,"ipv4",n.message,e),n.version!=="v4"&&ht(r,"ipv6",n.message,e);break}case"base64url":Ke(r,ft.base64url,n.message,e);break;case"jwt":Ke(r,ft.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Ke(r,ft.ipv4Cidr,n.message,e),n.version!=="v4"&&Ke(r,ft.ipv6Cidr,n.message,e);break}case"emoji":Ke(r,ft.emoji(),n.message,e);break;case"ulid":{Ke(r,ft.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{ht(r,"binary",n.message,e);break}case"contentEncoding:base64":{we(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Ke(r,ft.base64,n.message,e);break}}break}case"nanoid":Ke(r,ft.nanoid,n.message,e)}return r}function ii(t,e){return e.patternStrategy==="escape"?iy(t):t}const ay=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function iy(t){let e="";for(let r=0;r<t.length;r++)ay.has(t[r])||(e+="\\"),e+=t[r];return e}function ht(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}}})):we(t,"format",e,r,n)}function Ke(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:dd(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):we(t,"pattern",dd(e,n),r,n)}function dd(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
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 ld(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===x.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,s)=>({...n,[s]:pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",s]})??Ge(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};const r={type:"object",additionalProperties:pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===x.ZodString&&t.keyType._def.checks?.length){const{type:n,...s}=cd(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===x.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===x.ZodBranded&&t.keyType._def.type._def.typeName===x.ZodString&&t.keyType._def.type._def.checks?.length){const{type:n,...s}=id(t.keyType._def,e);return{...r,propertyNames:s}}}return r}function ny(t,e){if(e.mapStrategy==="record")return ld(t,e);const r=pe(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Ge(e),n=pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Ge(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function sy(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 ay(t){return t.target==="openAi"?void 0:{not:Ge({...t,currentPath:[...t.currentPath,"not"]})}}function iy(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const js={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function oy(t,e){if(e.target==="openApi3")return dd(t,e);const r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in js&&(!n._def.checks||!n._def.checks.length))){const n=r.reduce((s,a)=>{const i=js[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 dd(t,e)}const dd=(t,e)=>{const r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,s)=>pe(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 cy(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:js[t.innerType._def.typeName],nullable:!0}:{type:[js[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){const n=pe(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}const r=pe(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function uy(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",sd(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?ve(r,"minimum",n.value,n.message,e):ve(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ve(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ve(r,"maximum",n.value,n.message,e):ve(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ve(r,"maximum",n.value,n.message,e));break;case"multipleOf":ve(r,"multipleOf",n.value,n.message,e);break}return r}function ly(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 u=fy(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);const l=pe(c._def,{...e,currentPath:[...e.currentPath,"properties",o],propertyPath:[...e.currentPath,"properties",o]});l!==void 0&&(n.properties[o]=l,u||s.push(o))}s.length&&(n.required=s);const i=dy(t,e);return i!==void 0&&(n.additionalProperties=i),n}function dy(t,e){if(t.catchall._def.typeName!=="ZodNever")return pe(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 fy(t){try{return t.isOptional()}catch{return!0}}const hy=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return pe(t.innerType._def,e);const r=pe(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:Ge(e)},r]}:Ge(e)},py=(t,e)=>{if(e.pipeStrategy==="input")return pe(t.in._def,e);if(e.pipeStrategy==="output")return pe(t.out._def,e);const r=pe(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=pe(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(s=>s!==void 0)}};function my(t,e){return pe(t.type._def,e)}function _y(t,e){const n={type:"array",uniqueItems:!0,items:pe(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&ve(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&ve(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function gy(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>pe(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:pe(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>pe(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function yy(t){return{not:Ge(t)}}function vy(t){return Ge(t)}const wy=(t,e)=>pe(t.innerType._def,e),by=(t,e,r)=>{switch(e){case x.ZodString:return cd(t,r);case x.ZodNumber:return uy(t,r);case x.ZodObject:return ly(t,r);case x.ZodBigInt:return Hg(t,r);case x.ZodBoolean:return Wg();case x.ZodDate:return od(t,r);case x.ZodUndefined:return yy(r);case x.ZodNull:return iy(r);case x.ZodArray:return Fg(t,r);case x.ZodUnion:case x.ZodDiscriminatedUnion:return oy(t,r);case x.ZodIntersection:return Xg(t,r);case x.ZodTuple:return gy(t,r);case x.ZodRecord:return ld(t,r);case x.ZodLiteral:return ey(t,r);case x.ZodEnum:return Yg(t);case x.ZodNativeEnum:return sy(t);case x.ZodNullable:return cy(t,r);case x.ZodOptional:return hy(t,r);case x.ZodMap:return ny(t,r);case x.ZodSet:return _y(t,r);case x.ZodLazy:return()=>t.getter()._def;case x.ZodPromise:return my(t,r);case x.ZodNaN:case x.ZodNever:return ay(r);case x.ZodEffects:return Bg(t,r);case x.ZodAny:return Ge(r);case x.ZodUnknown:return vy(r);case x.ZodDefault:return Gg(t,r);case x.ZodBranded:return id(t,r);case x.ZodReadonly:return wy(t,r);case x.ZodCatch:return Kg(t,r);case x.ZodPipeline:return py(t,r);case x.ZodFunction:case x.ZodVoid:case x.ZodSymbol:return;default:return(n=>{})()}};function pe(t,e,r=!1){const n=e.seen.get(t);if(e.override){const o=e.override?.(t,e,n,r);if(o!==Dg)return o}if(n&&!r){const o=Sy(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=by(t,t.typeName,e),i=typeof a=="function"?pe(a(),e):a;if(i&&ky(t,e,i),e.postProcess){const o=e.postProcess(i,t,e);return s.jsonSchema=i,o}return s.jsonSchema=i,i}const Sy=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:ad(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`),Ge(e)):e.$refStrategy==="seen"?Ge(e):void 0}},ky=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r),$y=(t,e)=>{const r=Vg(e);let n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:pe(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Ge(r)}),{}):void 0;const s=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,a=pe(t._def,s===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,s]},!1)??Ge(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 Ey(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function fd(t,e){return lt(t)?zm(t,{target:Ey(e?.target),io:e?.pipeStrategy??"input"}):$y(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function hd(t){const r=pr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const n=rd(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function pd(t,e){const r=dt(t,e);if(!r.success)throw r.error;return r.data}const md=6e4;class ii{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(ns,r=>{this._oncancel(r)}),this.setNotificationHandler(os,r=>{this._onprogress(r)}),this.setRequestHandler(is,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(cs,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new W(S.ErrorCode.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(ls,async(r,n)=>{const s=async()=>{const a=r.params.taskId;if(this._taskMessageQueue){let o;for(;o=await this._taskMessageQueue.dequeue(a,n.sessionId);){if(o.type==="response"||o.type==="error"){const c=o.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),o.type==="response")l(c);else{const h=c,g=new W(h.error.code,h.error.message,h.error.data);l(g)}else{const h=o.type==="response"?"Response":"Error";this._onerror(new Error(`${h} handler missing for request ${u}`))}continue}await this._transport?.send(o.message,{relatedRequestId:n.requestId})}}const i=await this._taskStore.getTask(a,n.sessionId);if(!i)throw new W(S.ErrorCode.InvalidParams,`Task not found: ${a}`);if(!Gt(i.status))return await this._waitForTaskUpdate(a,n.signal),await s();if(Gt(i.status)){const o=await this._taskStore.getTaskResult(a,n.sessionId);return this._clearTaskQueue(a),{...o,_meta:{...o._meta,[It]:{taskId:a}}}}return await s()};return await s()}),this.setRequestHandler(ds,async(r,n)=>{try{const{tasks:s,nextCursor:a}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:s,nextCursor:a,_meta:{}}}catch(s){throw new W(S.ErrorCode.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(hs,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new W(S.ErrorCode.InvalidParams,`Task not found: ${r.params.taskId}`);if(Gt(s.status))throw new W(S.ErrorCode.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 W(S.ErrorCode.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...a}}catch(s){throw s instanceof W?s:new W(S.ErrorCode.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,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),W.fromError(S.ErrorCode.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=a=>{n?.(a),this._onerror(a)};const s=this._transport?.onmessage;this._transport.onmessage=(a,i)=>{s?.(a,i),Vt(a)||ka(a)?this._onresponse(a):ts(a)?this._onrequest(a,i):yu(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const r=W.fromError(S.ErrorCode.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,a=e.params?._meta?.[It]?.taskId;if(n===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:S.ErrorCode.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},s?.sessionId).catch(h=>this._onerror(new Error(`Failed to enqueue error response: ${h}`))):s?.send(l).catch(h=>this._onerror(new Error(`Failed to send an error response: ${h}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);const o=gu(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 h={relatedRequestId:e.id};a&&(h.relatedTask={taskId:a}),await this.notification(l,h)},sendRequest:async(l,h,g)=>{const _={...g,relatedRequestId:e.id};a&&!_.relatedTask&&(_.relatedTask={taskId:a});const p=_.relatedTask?.taskId??a;return p&&c&&await c.updateTaskStatus(p,"input_required"),await this.request(l,h,_)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:a,taskStore:c,taskRequestedTtl:o?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;const h={result:l,jsonrpc:"2.0",id:e.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:h,timestamp:Date.now()},s?.sessionId):await s?.send(h)},async l=>{if(i.signal.aborted)return;const h={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:S.ErrorCode.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:h,timestamp:Date.now()},s?.sessionId):await s?.send(h)}).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),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),Vt(e))n(e);else{const i=new W(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(Vt(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),Vt(e))s(e);else{const i=W.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 W?i:new W(S.ErrorCode.InternalError,String(i))}}return}let a;try{const i=await this.request(e,Ht,n);if(i.task)a=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new W(S.ErrorCode.InternalError,"Task creation did not return a task");for(;;){const o=await this.getTask({taskId:a},n);if(yield{type:"taskStatus",task:o},Gt(o.status)){o.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)}:o.status==="failed"?yield{type:"error",error:new W(S.ErrorCode.InternalError,`Task ${a} failed`)}:o.status==="cancelled"&&(yield{type:"error",error:new W(S.ErrorCode.InternalError,`Task ${a} was cancelled`)});return}if(o.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)};return}const c=o.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof W?i:new W(S.ErrorCode.InternalError,String(i))}}}request(e,r,n){const{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i,task:o,relatedTask:c}=n??{};return new Promise((u,l)=>{const h=d=>{l(d)};if(!this._transport){h(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(d){h(d);return}n?.signal?.throwIfAborted();const g=this._requestMessageId++,_={...e,jsonrpc:"2.0",id:g};n?.onprogress&&(this._progressHandlers.set(g,n.onprogress),_.params={...e.params,_meta:{...e.params?._meta||{},progressToken:g}}),o&&(_.params={..._.params,task:o}),c&&(_.params={..._.params,_meta:{..._.params?._meta||{},[It]:c}});const p=d=>{this._responseHandlers.delete(g),this._progressHandlers.delete(g),this._cleanupTimeout(g),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:g,reason:String(d)}},{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(b=>this._onerror(new Error(`Failed to send cancellation: ${b}`)));const m=d instanceof W?d:new W(S.ErrorCode.RequestTimeout,String(d));l(m)};this._responseHandlers.set(g,d=>{if(!n?.signal?.aborted){if(d instanceof Error)return l(d);try{const m=dt(r,d.result);m.success?u(m.data):l(m.error)}catch(m){l(m)}}}),n?.signal?.addEventListener("abort",()=>{p(n?.signal?.reason)});const y=n?.timeout??md,f=()=>p(W.fromError(S.ErrorCode.RequestTimeout,"Request timed out",{timeout:y}));this._setupTimeout(g,y,n?.maxTotalTimeout,f,n?.resetTimeoutOnProgress??!1);const w=c?.taskId;if(w){const d=m=>{const b=this._responseHandlers.get(g);b?b(m):this._onerror(new Error(`Response handler missing for side-channeled request ${g}`))};this._requestResolvers.set(g,d),this._enqueueTaskMessage(w,{type:"request",message:_,timestamp:Date.now()}).catch(m=>{this._cleanupTimeout(g),l(m)})}else this._transport.send(_,{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(d=>{this._cleanupTimeout(g),l(d)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},us,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},fs,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Nu,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 o={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[It]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:o,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 o={...e,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[It]:r.relatedTask}}}),this._transport?.send(o,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[It]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){const n=hd(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,a)=>{const i=pd(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=hd(e);this._notificationHandlers.set(n,s=>{const a=pd(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){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"&&ts(s.message)){const a=s.message.id,i=this._requestResolvers.get(a);i?(i(new W(S.ErrorCode.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){let n=this._options?.defaultTaskPollInterval??1e3;try{const s=await this._taskStore?.getTask(e);s?.pollInterval&&(n=s.pollInterval)}catch{}return new Promise((s,a)=>{if(r.aborted){a(new W(S.ErrorCode.InvalidRequest,"Request cancelled"));return}const i=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(i),a(new W(S.ErrorCode.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 W(S.ErrorCode.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=qr.parse({method:"notifications/tasks/status",params:o});await this.notification(c),Gt(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 W(S.ErrorCode.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(Gt(o.status))throw new W(S.ErrorCode.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 u=qr.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Gt(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function _d(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function oi(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];_d(i)&&_d(a)?r[s]={...i,...a}:r[s]=a}return r}var zs={exports:{}},ci={},gd;function Ry(){return gd||(gd=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatNames=t.fastFormats=t.fullFormats=void 0;function e(z,F){return{validate:z,compare:F}}t.fullFormats={date:e(a,i),time:e(c(!0),u),"date-time":e(g(!0),_),"iso-time":e(c(),l),"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:w,"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:K,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:$},int64:{type:"number",validate:E},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,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(z){return z%4===0&&(z%100!==0||z%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(z){const F=n.exec(z);if(!F)return!1;const G=+F[1],Y=+F[2],ge=+F[3];return Y>=1&&Y<=12&&ge>=1&&ge<=(Y===2&&r(G)?29:s[Y])}function i(z,F){if(z&&F)return z>F?1:z<F?-1:0}const o=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(z){return function(G){const Y=o.exec(G);if(!Y)return!1;const ge=+Y[1],We=+Y[2],Ke=+Y[3],we=Y[4],mt=Y[5]==="-"?-1:1,D=+(Y[6]||0),C=+(Y[7]||0);if(D>23||C>59||z&&!we)return!1;if(ge<=23&&We<=59&&Ke<60)return!0;const q=We-C*mt,O=ge-D*mt-(q<0?1:0);return(O===23||O===-1)&&(q===59||q===-1)&&Ke<61}}function u(z,F){if(!(z&&F))return;const G=new Date("2020-01-01T"+z).valueOf(),Y=new Date("2020-01-01T"+F).valueOf();if(G&&Y)return G-Y}function l(z,F){if(!(z&&F))return;const G=o.exec(z),Y=o.exec(F);if(G&&Y)return z=G[1]+G[2]+G[3],F=Y[1]+Y[2]+Y[3],z>F?1:z<F?-1:0}const h=/t|\s/i;function g(z){const F=c(z);return function(Y){const ge=Y.split(h);return ge.length===2&&a(ge[0])&&F(ge[1])}}function _(z,F){if(!(z&&F))return;const G=new Date(z).valueOf(),Y=new Date(F).valueOf();if(G&&Y)return G-Y}function p(z,F){if(!(z&&F))return;const[G,Y]=z.split(h),[ge,We]=F.split(h),Ke=i(G,ge);if(Ke!==void 0)return Ke||u(Y,We)}const y=/\/|:/,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 w(z){return y.test(z)&&f.test(z)}const d=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function m(z){return d.lastIndex=0,d.test(z)}const b=-2147483648,v=2**31-1;function $(z){return Number.isInteger(z)&&z<=v&&z>=b}function E(z){return Number.isInteger(z)}function N(){return!0}const L=/[^\\]\\Z/;function K(z){if(L.test(z))return!1;try{return new RegExp(z),!0}catch{return!1}}})(ci)),ci}var ui={},yd;function Ty(){return yd||(yd=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatLimitDefinition=void 0;const e=pc(),r=ae(),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:u,schemaCode:l,keyword:h,it:g}=o,{opts:_,self:p}=g;if(!_.validateFormats)return;const y=new e.KeywordCxt(g,p.RULES.all.format.definition,"format");y.$data?f():w();function f(){const m=c.scopeValue("formats",{ref:p.formats,code:_.code.formats}),b=c.const("fmt",(0,r._)`${m}[${y.schemaCode}]`);o.fail$data((0,r.or)((0,r._)`typeof ${b} != "object"`,(0,r._)`${b} instanceof RegExp`,(0,r._)`typeof ${b}.compare != "function"`,d(b)))}function w(){const m=y.schema,b=p.formats[m];if(!b||b===!0)return;if(typeof b!="object"||b instanceof RegExp||typeof b.compare!="function")throw new Error(`"${h}": format "${m}" does not define "compare" function`);const v=c.scopeValue("formats",{key:m,ref:b,code:_.code.formats?(0,r._)`${_.code.formats}${(0,r.getProperty)(m)}`:void 0});o.fail$data(d(v))}function d(m){return(0,r._)`${m}.compare(${u}, ${l}) ${s[h].fail} 0`}},dependencies:["format"]};const i=o=>(o.addKeyword(t.formatLimitDefinition),o);t.default=i})(ui)),ui}var vd;function Py(){return vd||(vd=1,(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=Ry(),n=Ty(),s=ae(),a=new s.Name("fullFormats"),i=new s.Name("fastFormats"),o=(u,l={keywords:!0})=>{if(Array.isArray(l))return c(u,l,r.fullFormats,a),u;const[h,g]=l.mode==="fast"?[r.fastFormats,i]:[r.fullFormats,a],_=l.formats||r.formatNames;return c(u,_,h,g),l.keywords&&(0,n.default)(u),u};o.get=(u,l="full")=>{const g=(l==="fast"?r.fastFormats:r.fullFormats)[u];if(!g)throw new Error(`Unknown format "${u}"`);return g};function c(u,l,h,g){var _,p;(_=(p=u.opts.code).formats)!==null&&_!==void 0||(p.formats=(0,s._)`require("ajv-formats/dist/formats").${g}`);for(const y of l)u.addFormat(y,h[y])}t.exports=e=o,Object.defineProperty(e,"__esModule",{value:!0}),e.default=o})(zs,zs.exports)),zs.exports}var Cy=Py();const Iy=Qt(Cy);function Oy(){const t=new mc({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return Iy(t),t}class wd{constructor(e){this._ajv=e??Oy()}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 Ny{constructor(e){this._client=e}async*callToolStream(e,r=or,n){const s=this._client,a={...n,task:n?.task??(s.isToolTask(e.name)?{}:void 0)},i=s.requestStream({method:"tools/call",params:e},r,a),o=s.getToolOutputValidator(e.name);for await(const c of i){if(c.type==="result"&&o){const u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new W(S.ErrorCode.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{const l=o(u.structuredContent);if(!l.valid){yield{type:"error",error:new W(S.ErrorCode.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof W){yield{type:"error",error:l};return}yield{type:"error",error:new W(S.ErrorCode.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 bd(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 Sd(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 Ms(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&&Ms(a,r[s])}}if(Array.isArray(t.anyOf))for(const r of t.anyOf)typeof r!="boolean"&&Ms(r,e);if(Array.isArray(t.oneOf))for(const r of t.oneOf)typeof r!="boolean"&&Ms(r,e)}}function kd(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 Ay extends ii{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 wd,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",xa,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",qa,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",ja,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new Ny(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=oi(this._capabilities,e)}setRequestHandler(e,r){const s=pr(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let a;if(lt(s)){const o=s;a=o._zod?.def?.value??o.value}else{const o=s;a=o._def?.value??o.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");const i=a;if(i==="elicitation/create"){const o=async(c,u)=>{const l=dt(Va,c);if(!l.success){const d=l.error instanceof Error?l.error.message:String(l.error);throw new W(S.ErrorCode.InvalidParams,`Invalid elicitation request: ${d}`)}const{params:h}=l.data;h.mode=h.mode??"form";const{supportsFormMode:g,supportsUrlMode:_}=kd(this._capabilities.elicitation);if(h.mode==="form"&&!g)throw new W(S.ErrorCode.InvalidParams,"Client does not support form-mode elicitation requests");if(h.mode==="url"&&!_)throw new W(S.ErrorCode.InvalidParams,"Client does not support URL-mode elicitation requests");const p=await Promise.resolve(r(c,u));if(h.task){const d=dt(Ht,p);if(!d.success){const m=d.error instanceof Error?d.error.message:String(d.error);throw new W(S.ErrorCode.InvalidParams,`Invalid task creation result: ${m}`)}return d.data}const y=dt(Dr,p);if(!y.success){const d=y.error instanceof Error?y.error.message:String(y.error);throw new W(S.ErrorCode.InvalidParams,`Invalid elicitation result: ${d}`)}const f=y.data,w=h.mode==="form"?h.requestedSchema:void 0;if(h.mode==="form"&&f.action==="accept"&&f.content&&w&&this._capabilities.elicitation?.form?.applyDefaults)try{Ms(w,f.content)}catch{}return f};return super.setRequestHandler(e,o)}if(i==="sampling/createMessage"){const o=async(c,u)=>{const l=dt(Ua,c);if(!l.success){const f=l.error instanceof Error?l.error.message:String(l.error);throw new W(S.ErrorCode.InvalidParams,`Invalid sampling request: ${f}`)}const{params:h}=l.data,g=await Promise.resolve(r(c,u));if(h.task){const f=dt(Ht,g);if(!f.success){const w=f.error instanceof Error?f.error.message:String(f.error);throw new W(S.ErrorCode.InvalidParams,`Invalid task creation result: ${w}`)}return f.data}const p=h.tools||h.toolChoice?Rs:Es,y=dt(p,g);if(!y.success){const f=y.error instanceof Error?y.error.message:String(y.error);throw new W(S.ErrorCode.InvalidParams,`Invalid sampling result: ${f}`)}return y.data};return super.setRequestHandler(e,o)}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:Ut,capabilities:this._capabilities,clientInfo:this._clientInfo}},Ea,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!ga.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){bd(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&Sd(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},Ot,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},Ha,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},Ot,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},Ma,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},za,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},Oa,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},Na,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},Aa,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},Ot,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},Ot,r)}async callTool(e,r=or,n){if(this.isToolTaskRequired(e.name))throw new W(S.ErrorCode.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 W(S.ErrorCode.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 W(S.ErrorCode.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof W?i:new W(S.ErrorCode.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},La,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,r,n,s){const a=Yu.safeParse(n);if(!a.success)throw new Error(`Invalid ${e} listChanged options: ${a.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:i,debounceMs:o}=a.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{const h=await s();c(null,h)}catch(h){const g=h instanceof Error?h:new Error(String(h));c(g,null)}},l=()=>{if(o){const h=this._listChangedDebounceTimers.get(e);h&&clearTimeout(h);const g=setTimeout(u,o);this._listChangedDebounceTimers.set(e,g)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}let li;li=globalThis.crypto;async function jy(t){return(await li).getRandomValues(new Uint8Array(t))}async function zy(t){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length;let n="";for(;n.length<t;){const s=await jy(t-n.length);for(const a of s)a<r&&(n+=e[a%e.length])}return n}async function My(t){return await zy(t)}async function qy(t){const e=await(await li).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Zy(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;const e=await My(t),r=await qy(e);return{code_verifier:e,code_challenge:r}}const De=Gm().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:x_.custom,message:"URL must be parseable",fatal:!0}),Ff}).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"}),Ly=Le({resource:R().url(),authorization_servers:V(De).optional(),jwks_uri:R().url().optional(),scopes_supported:V(R()).optional(),bearer_methods_supported:V(R()).optional(),resource_signing_alg_values_supported:V(R()).optional(),resource_name:R().optional(),resource_documentation:R().optional(),resource_policy_uri:R().url().optional(),resource_tos_uri:R().url().optional(),tls_client_certificate_bound_access_tokens:ke().optional(),authorization_details_types_supported:V(R()).optional(),dpop_signing_alg_values_supported:V(R()).optional(),dpop_bound_access_tokens_required:ke().optional()}),di=Le({issuer:R(),authorization_endpoint:De,token_endpoint:De,registration_endpoint:De.optional(),scopes_supported:V(R()).optional(),response_types_supported:V(R()),response_modes_supported:V(R()).optional(),grant_types_supported:V(R()).optional(),token_endpoint_auth_methods_supported:V(R()).optional(),token_endpoint_auth_signing_alg_values_supported:V(R()).optional(),service_documentation:De.optional(),revocation_endpoint:De.optional(),revocation_endpoint_auth_methods_supported:V(R()).optional(),revocation_endpoint_auth_signing_alg_values_supported:V(R()).optional(),introspection_endpoint:R().optional(),introspection_endpoint_auth_methods_supported:V(R()).optional(),introspection_endpoint_auth_signing_alg_values_supported:V(R()).optional(),code_challenge_methods_supported:V(R()).optional(),client_id_metadata_document_supported:ke().optional()}),xy=Le({issuer:R(),authorization_endpoint:De,token_endpoint:De,userinfo_endpoint:De.optional(),jwks_uri:De,registration_endpoint:De.optional(),scopes_supported:V(R()).optional(),response_types_supported:V(R()),response_modes_supported:V(R()).optional(),grant_types_supported:V(R()).optional(),acr_values_supported:V(R()).optional(),subject_types_supported:V(R()),id_token_signing_alg_values_supported:V(R()),id_token_encryption_alg_values_supported:V(R()).optional(),id_token_encryption_enc_values_supported:V(R()).optional(),userinfo_signing_alg_values_supported:V(R()).optional(),userinfo_encryption_alg_values_supported:V(R()).optional(),userinfo_encryption_enc_values_supported:V(R()).optional(),request_object_signing_alg_values_supported:V(R()).optional(),request_object_encryption_alg_values_supported:V(R()).optional(),request_object_encryption_enc_values_supported:V(R()).optional(),token_endpoint_auth_methods_supported:V(R()).optional(),token_endpoint_auth_signing_alg_values_supported:V(R()).optional(),display_values_supported:V(R()).optional(),claim_types_supported:V(R()).optional(),claims_supported:V(R()).optional(),service_documentation:R().optional(),claims_locales_supported:V(R()).optional(),ui_locales_supported:V(R()).optional(),claims_parameter_supported:ke().optional(),request_parameter_supported:ke().optional(),request_uri_parameter_supported:ke().optional(),require_request_uri_registration:ke().optional(),op_policy_uri:De.optional(),op_tos_uri:De.optional(),client_id_metadata_document_supported:ke().optional()}),Dy=H({...xy.shape,...di.pick({code_challenge_methods_supported:!0}).shape}),Uy=H({access_token:R(),id_token:R().optional(),token_type:R(),expires_in:D_().optional(),scope:R().optional(),refresh_token:R().optional()}).strip(),Vy=H({error:R(),error_description:R().optional(),error_uri:R().optional()}),$d=De.optional().or(te("").transform(()=>{})),Fy=H({redirect_uris:V(De),token_endpoint_auth_method:R().optional(),grant_types:V(R()).optional(),response_types:V(R()).optional(),client_name:R().optional(),client_uri:De.optional(),logo_uri:$d,scope:R().optional(),contacts:V(R()).optional(),tos_uri:$d,policy_uri:R().optional(),jwks_uri:De.optional(),jwks:m_().optional(),software_id:R().optional(),software_version:R().optional(),software_statement:R().optional()}).strip(),Hy=H({client_id:R(),client_secret:R().optional(),client_id_issued_at:_e().optional(),client_secret_expires_at:_e().optional()}).strip(),Wy=Fy.merge(Hy);H({error:R(),error_description:R().optional()}).strip(),H({token:R(),token_type_hint:R().optional()}).strip();function Ky(t){const e=typeof t=="string"?new URL(t):new URL(t.href);return e.hash="",e}function Jy({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 fi extends qe{}fi.errorCode="invalid_request";class qs extends qe{}qs.errorCode="invalid_client";class Zs extends qe{}Zs.errorCode="invalid_grant";class Ls extends qe{}Ls.errorCode="unauthorized_client";class hi extends qe{}hi.errorCode="unsupported_grant_type";class pi extends qe{}pi.errorCode="invalid_scope";class mi extends qe{}mi.errorCode="access_denied";class mr extends qe{}mr.errorCode="server_error";class _i extends qe{}_i.errorCode="temporarily_unavailable";class gi extends qe{}gi.errorCode="unsupported_response_type";class yi extends qe{}yi.errorCode="unsupported_token_type";class vi extends qe{}vi.errorCode="invalid_token";class wi extends qe{}wi.errorCode="method_not_allowed";class bi extends qe{}bi.errorCode="too_many_requests";class xs extends qe{}xs.errorCode="invalid_client_metadata";class Si extends qe{}Si.errorCode="insufficient_scope";class ki extends qe{}ki.errorCode="invalid_target";const Gy={[fi.errorCode]:fi,[qs.errorCode]:qs,[Zs.errorCode]:Zs,[Ls.errorCode]:Ls,[hi.errorCode]:hi,[pi.errorCode]:pi,[mi.errorCode]:mi,[mr.errorCode]:mr,[_i.errorCode]:_i,[gi.errorCode]:gi,[yi.errorCode]:yi,[vi.errorCode]:vi,[wi.errorCode]:wi,[bi.errorCode]:bi,[xs.errorCode]:xs,[Si.errorCode]:Si,[ki.errorCode]:ki};class it extends Error{constructor(e){super(e??"Unauthorized")}}function By(t){return["client_secret_basic","client_secret_post","none"].includes(t)}const $i="code",Ei="S256";function Ed(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&&By(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 Yy(t,e,r,n){const{client_id:s,client_secret:a}=e;switch(t){case"client_secret_basic":Qy(s,a,r);return;case"client_secret_post":Xy(s,a,n);return;case"none":ev(s,n);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function Qy(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 Xy(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function ev(t,e){e.set("client_id",t)}async function Ri(t){const e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{const n=Vy.parse(JSON.parse(r)),{error:s,error_description:a,error_uri:i}=n,o=Gy[s]||mr;return new o(a||"",i)}catch(n){const s=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new mr(s)}}async function zt(t,e){try{return await Ti(t,e)}catch(r){if(r instanceof qs||r instanceof Ls)return await t.invalidateCredentials?.("all"),await Ti(t,e);if(r instanceof Zs)return await t.invalidateCredentials?.("tokens"),await Ti(t,e);throw r}}async function Ti(t,{serverUrl:e,authorizationCode:r,scope:n,resourceMetadataUrl:s,fetchFn:a}){let i,o;try{i=await Pd(e,{resourceMetadataUrl:s},a),i.authorization_servers&&i.authorization_servers.length>0&&(o=i.authorization_servers[0])}catch{}o||(o=new URL("/",e));const c=await Td(e,t,i),u=await Nd(o,{fetchFn:a});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,w=t.clientMetadataUrl;if(w&&!Rd(w))throw new xs(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${w}`);if(f&&w)l={client_id:w},await t.saveClientInformation?.(l);else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const m=await Md(o,{metadata:u,clientMetadata:t.clientMetadata,fetchFn:a});await t.saveClientInformation(m),l=m}}const h=!t.redirectUrl;if(r!==void 0||h){const f=await zd(t,o,{metadata:u,resource:c,authorizationCode:r,fetchFn:a});return await t.saveTokens(f),"AUTHORIZED"}const g=await t.tokens();if(g?.refresh_token)try{const f=await jd(o,{metadata:u,clientInformation:l,refreshToken:g.refresh_token,resource:c,addClientAuthentication:t.addClientAuthentication,fetchFn:a});return await t.saveTokens(f),"AUTHORIZED"}catch(f){if(!(!(f instanceof qe)||f instanceof mr))throw f}const _=t.state?await t.state():void 0,{authorizationUrl:p,codeVerifier:y}=await Ad(o,{metadata:u,clientInformation:l,state:_,redirectUrl:t.redirectUrl,scope:n||i?.scopes_supported?.join(" ")||t.clientMetadata.scope,resource:c});return await t.saveCodeVerifier(y),await t.redirectToAuthorization(p),"REDIRECT"}function Rd(t){if(!t)return!1;try{const e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function Td(t,e,r){const n=Ky(t);if(e.validateResourceURL)return await e.validateResourceURL(n,r?.resource);if(r){if(!Jy({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 Kr(t){const e=t.headers.get("WWW-Authenticate");if(!e)return{};const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};const s=Pi(t,"resource_metadata")||void 0;let a;if(s)try{a=new URL(s)}catch{}const i=Pi(t,"scope")||void 0,o=Pi(t,"error")||void 0;return{resourceMetadataUrl:a,scope:i,error:o}}function Pi(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}function tv(t){const e=t.headers.get("WWW-Authenticate");if(!e)return;const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return;const a=/resource_metadata="([^"]*)"/.exec(e);if(a)try{return new URL(a[1])}catch{return}}async function Pd(t,e,r=fetch){const n=await Id(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 Ly.parse(await n.json())}async function Ci(t,e,r=fetch){try{return await r(t,{headers:e})}catch(n){if(n instanceof TypeError)return e?Ci(t,void 0,r):void 0;throw n}}function rv(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function Cd(t,e,r=fetch){return await Ci(t,{"MCP-Protocol-Version":e},r)}function nv(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function Id(t,e,r,n){const s=new URL(t),a=n?.protocolVersion??Ut;let i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{const c=rv(e,s.pathname);i=new URL(c,n?.metadataServerUrl??s),i.search=s.search}let o=await Cd(i,a,r);if(!n?.metadataUrl&&nv(o,s.pathname)){const c=new URL(`/.well-known/${e}`,s);o=await Cd(c,a,r)}return o}async function sv(t,{authorizationServerUrl:e,protocolVersion:r}={},n=fetch){typeof t=="string"&&(t=new URL(t)),e||(e=t),typeof e=="string"&&(e=new URL(e)),r??(r=Ut);const s=await Id(e,"oauth-authorization-server",n,{protocolVersion:r,metadataServerUrl:e});if(!s||s.status===404){await s?.body?.cancel();return}if(!s.ok)throw await s.body?.cancel(),new Error(`HTTP ${s.status} trying to load well-known OAuth metadata`);return di.parse(await s.json())}function Od(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 Nd(t,{fetchFn:e=fetch,protocolVersion:r=Ut}={}){const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=Od(t);for(const{url:a,type:i}of s){const o=await Ci(a,n,e);if(o){if(!o.ok){if(await o.body?.cancel(),o.status>=400&&o.status<500)continue;throw new Error(`HTTP ${o.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}return i==="oauth"?di.parse(await o.json()):Dy.parse(await o.json())}}}async function Ad(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($i))throw new Error(`Incompatible auth server: does not support response type ${$i}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(Ei))throw new Error(`Incompatible auth server: does not support code challenge method ${Ei}`)}else o=new URL("/authorize",t);const c=await Zy(),u=c.code_verifier,l=c.code_challenge;return o.searchParams.set("response_type",$i),o.searchParams.set("client_id",r.client_id),o.searchParams.set("code_challenge",l),o.searchParams.set("code_challenge_method",Ei),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:u}}function Ii(t,e,r){return new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:String(r)})}async function Oi(t,{metadata:e,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:a,fetchFn:i}){const o=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(a&&r.set("resource",a.href),s)await s(c,r,o,e);else if(n){const l=e?.token_endpoint_auth_methods_supported??[],h=Ed(n,l);Yy(h,n,c,r)}const u=await(i??fetch)(o,{method:"POST",headers:c,body:r});if(!u.ok)throw await Ri(u);return Uy.parse(await u.json())}async function av(t,{metadata:e,clientInformation:r,authorizationCode:n,codeVerifier:s,redirectUri:a,resource:i,addClientAuthentication:o,fetchFn:c}){const u=Ii(n,s,a);return Oi(t,{metadata:e,tokenRequestParams:u,clientInformation:r,addClientAuthentication:o,resource:i,fetchFn:c})}async function jd(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 Oi(t,{metadata:e,tokenRequestParams:o,clientInformation:r,addClientAuthentication:a,resource:s,fetchFn:i});return{refresh_token:n,...c}}async function zd(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 u=await t.codeVerifier();o=Ii(s,u,t.redirectUrl)}const c=await t.clientInformation();return Oi(e,{metadata:r,tokenRequestParams:o,clientInformation:c??void 0,addClientAuthentication:t.addClientAuthentication,resource:n,fetchFn:a})}async function Md(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 Ri(a);return Wy.parse(await a.json())}class qd 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 Ni(t){}function Zd(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=Ni,onError:r=Ni,onRetry:n=Ni,onComment:s}=t;let a="",i=!0,o,c="",u="";function l(y){const f=i?y.replace(/^\xEF\xBB\xBF/,""):y,[w,d]=iv(`${a}${f}`);for(const m of w)h(m);a=d,i=!1}function h(y){if(y===""){_();return}if(y.startsWith(":")){s&&s(y.slice(y.startsWith(": ")?2:1));return}const f=y.indexOf(":");if(f!==-1){const w=y.slice(0,f),d=y[f+1]===" "?2:1,m=y.slice(f+d);g(w,m,y);return}g(y,"",y)}function g(y,f,w){switch(y){case"event":u=f;break;case"data":c=`${c}${f}
40
- `;break;case"id":o=f.includes("\0")?void 0:f;break;case"retry":/^\d+$/.test(f)?n(parseInt(f,10)):r(new qd(`Invalid \`retry\` value: "${f}"`,{type:"invalid-retry",value:f,line:w}));break;default:r(new qd(`Unknown field "${y.length>20?`${y.slice(0,20)}…`:y}"`,{type:"unknown-field",field:y,value:f,line:w}));break}}function _(){c.length>0&&e({id:o,event:u||void 0,data:c.endsWith(`
41
- `)?c.slice(0,-1):c}),o=void 0,c="",u=""}function p(y={}){a&&y.consume&&h(a),i=!0,o=void 0,c="",u="",a=""}return{feed:l,reset:p}}function iv(t){const e=[];let r="",n=0;for(;n<t.length;){const s=t.indexOf("\r",n),a=t.indexOf(`
42
- `,n);let i=-1;if(s!==-1&&a!==-1?i=Math.min(s,a):s!==-1?s===t.length-1?i=-1:i=s:a!==-1&&(i=a),i===-1){r=t.slice(n);break}else{const o=t.slice(n,i);e.push(o),n=i+1,t[n-1]==="\r"&&t[n]===`
43
- `&&n++}}return[e,r]}class Ld 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(xd(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(xd(this),r)}}function ov(t){const e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function Ai(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(Ai).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${Ai(t.cause)}`:t.message:`${t}`}function xd(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var Dd=t=>{throw TypeError(t)},ji=(t,e,r)=>e.has(t)||Dd("Cannot "+r),ue=(t,e,r)=>(ji(t,e,"read from private field"),r?r.call(t):e.get(t)),je=(t,e,r)=>e.has(t)?Dd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Te=(t,e,r,n)=>(ji(t,e,"write to private field"),e.set(t,r),r),$t=(t,e,r)=>(ji(t,e,"access private method"),r),Be,Bt,_r,Ds,Us,Jr,gr,Gr,Mt,yr,vr,wr,Br,pt,zi,Mi,qi,Ud,Zi,Li,Yr,xi,Di;class Vs extends EventTarget{constructor(e,r){var n,s;super(),je(this,pt),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,je(this,Be),je(this,Bt),je(this,_r),je(this,Ds),je(this,Us),je(this,Jr),je(this,gr),je(this,Gr,null),je(this,Mt),je(this,yr),je(this,vr,null),je(this,wr,null),je(this,Br,null),je(this,Mi,async a=>{var i;ue(this,yr).reset();const{body:o,redirected:c,status:u,headers:l}=a;if(u===204){$t(this,pt,Yr).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?Te(this,_r,new URL(a.url)):Te(this,_r,void 0),u!==200){$t(this,pt,Yr).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){$t(this,pt,Yr).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(ue(this,Be)===this.CLOSED)return;Te(this,Be,this.OPEN);const h=new Event("open");if((i=ue(this,Br))==null||i.call(this,h),this.dispatchEvent(h),typeof o!="object"||!o||!("getReader"in o)){$t(this,pt,Yr).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}const g=new TextDecoder,_=o.getReader();let p=!0;do{const{done:y,value:f}=await _.read();f&&ue(this,yr).feed(g.decode(f,{stream:!y})),y&&(p=!1,ue(this,yr).reset(),$t(this,pt,xi).call(this))}while(p)}),je(this,qi,a=>{Te(this,Mt,void 0),!(a.name==="AbortError"||a.type==="aborted")&&$t(this,pt,xi).call(this,Ai(a))}),je(this,Zi,a=>{typeof a.id=="string"&&Te(this,Gr,a.id);const i=new MessageEvent(a.event||"message",{data:a.data,origin:ue(this,_r)?ue(this,_r).origin:ue(this,Bt).origin,lastEventId:a.id||""});ue(this,wr)&&(!a.event||a.event==="message")&&ue(this,wr).call(this,i),this.dispatchEvent(i)}),je(this,Li,a=>{Te(this,Jr,a)}),je(this,Di,()=>{Te(this,gr,void 0),ue(this,Be)===this.CONNECTING&&$t(this,pt,zi).call(this)});try{if(e instanceof URL)Te(this,Bt,e);else if(typeof e=="string")Te(this,Bt,new URL(e,cv()));else throw new Error("Invalid URL")}catch{throw ov("An invalid or illegal string was specified")}Te(this,yr,Zd({onEvent:ue(this,Zi),onRetry:ue(this,Li)})),Te(this,Be,this.CONNECTING),Te(this,Jr,3e3),Te(this,Us,(n=r?.fetch)!=null?n:globalThis.fetch),Te(this,Ds,(s=r?.withCredentials)!=null?s:!1),$t(this,pt,zi).call(this)}get readyState(){return ue(this,Be)}get url(){return ue(this,Bt).href}get withCredentials(){return ue(this,Ds)}get onerror(){return ue(this,vr)}set onerror(e){Te(this,vr,e)}get onmessage(){return ue(this,wr)}set onmessage(e){Te(this,wr,e)}get onopen(){return ue(this,Br)}set onopen(e){Te(this,Br,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(){ue(this,gr)&&clearTimeout(ue(this,gr)),ue(this,Be)!==this.CLOSED&&(ue(this,Mt)&&ue(this,Mt).abort(),Te(this,Be,this.CLOSED),Te(this,Mt,void 0))}}Be=new WeakMap,Bt=new WeakMap,_r=new WeakMap,Ds=new WeakMap,Us=new WeakMap,Jr=new WeakMap,gr=new WeakMap,Gr=new WeakMap,Mt=new WeakMap,yr=new WeakMap,vr=new WeakMap,wr=new WeakMap,Br=new WeakMap,pt=new WeakSet,zi=function(){Te(this,Be,this.CONNECTING),Te(this,Mt,new AbortController),ue(this,Us)(ue(this,Bt),$t(this,pt,Ud).call(this)).then(ue(this,Mi)).catch(ue(this,qi))},Mi=new WeakMap,qi=new WeakMap,Ud=function(){var t;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...ue(this,Gr)?{"Last-Event-ID":ue(this,Gr)}:void 0},cache:"no-store",signal:(t=ue(this,Mt))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Zi=new WeakMap,Li=new WeakMap,Yr=function(t,e){var r;ue(this,Be)!==this.CLOSED&&Te(this,Be,this.CLOSED);const n=new Ld("error",{code:e,message:t});(r=ue(this,vr))==null||r.call(this,n),this.dispatchEvent(n)},xi=function(t,e){var r;if(ue(this,Be)===this.CLOSED)return;Te(this,Be,this.CONNECTING);const n=new Ld("error",{code:e,message:t});(r=ue(this,vr))==null||r.call(this,n),this.dispatchEvent(n),Te(this,gr,setTimeout(ue(this,Di),ue(this,Jr)))},Di=new WeakMap,Vs.CONNECTING=0,Vs.OPEN=1,Vs.CLOSED=2;function cv(){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 Qr(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function Ui(t=fetch,e){return e?async(r,n)=>{const s={...e,...n,headers:n?.headers?{...Qr(e.headers),...Qr(n.headers)}:e.headers};return t(r,s)}:t}class Vd extends Error{constructor(e,r,n){super(`SSE error: ${r}`),this.code=e,this.event=n}}class uv{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=Ui(r?.fetch,r?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new it("No auth provider");let e;try{e=await zt(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 it;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=Qr(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 Vs(this._url.href,{...this._eventSourceInit,fetch:async(s,a)=>{const i=await this._commonHeaders();i.set("Accept","text/event-stream");const o=await e(s,{...a,headers:i});if(o.status===401&&o.headers.has("www-authenticate")){const{resourceMetadataUrl:c,scope:u}=Kr(o);this._resourceMetadataUrl=c,this._scope=u}return o}}),this._abortController=new AbortController,this._eventSource.onerror=s=>{if(s.code===401&&this._authProvider){this._authThenStart().then(r,n);return}const a=new Vd(s.code,s.message,s);n(a),this.onerror?.(a)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",s=>{const a=s;try{if(this._endpoint=new URL(a.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 a=s;let i;try{i=Mr.parse(JSON.parse(a.data))}catch(o){this.onerror?.(o);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 it("No auth provider");if(await zt(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it("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 a=await s.text().catch(()=>null);if(s.status===401&&this._authProvider){const{resourceMetadataUrl:i,scope:o}=Kr(s);if(this._resourceMetadataUrl=i,this._scope=o,await zt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it;return this.send(e)}throw new Error(`Error POSTing to endpoint (HTTP ${s.status}): ${a}`)}await s.body?.cancel()}catch(r){throw this.onerror?.(r),r}}setProtocolVersion(e){this._protocolVersion=e}}class lv extends TransformStream{constructor({onError:e,onRetry:r,onComment:n}={}){let s;super({start(a){s=Zd({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 dv={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Yt extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}}class fv{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=Ui(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??dv}async _authThenStart(){if(!this._authProvider)throw new it("No auth provider");let e;try{e=await zt(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 it;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=Qr(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 Yt(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(a=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(e,r+1)})},s)}_handleSseStream(e,r,n){if(!e)return;const{onresumptiontoken:s,replayMessageId:a}=r;let i,o=!1,c=!1;(async()=>{try{const l=e.pipeThrough(new TextDecoderStream).pipeThrough(new lv({onRetry:_=>{this._serverRetryMs=_}})).getReader();for(;;){const{value:_,done:p}=await l.read();if(p)break;if(_.id&&(i=_.id,o=!0,s?.(_.id)),!!_.data&&(!_.event||_.event==="message"))try{const y=Mr.parse(JSON.parse(_.data));Vt(y)&&(c=!0,a!==void 0&&(y.id=a)),this.onmessage?.(y)}catch(y){this.onerror?.(y)}}(n||o)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:a},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(n||o)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:a},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 it("No auth provider");if(await zt(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it("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:ts(e)?e.id:void 0}).catch(g=>this.onerror?.(g));return}const a=await this._commonHeaders();a.set("content-type","application/json"),a.set("accept","application/json, text/event-stream");const i={...this._requestInit,method:"POST",headers:a,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,i),c=o.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!o.ok){const g=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Yt(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:_,scope:p}=Kr(o);if(this._resourceMetadataUrl=_,this._scope=p,await zt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){const{resourceMetadataUrl:_,scope:p,error:y}=Kr(o);if(y==="insufficient_scope"){const f=o.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===f)throw new Yt(403,"Server returned 403 after trying upscoping");if(p&&(this._scope=p),_&&(this._resourceMetadataUrl=_),this._lastUpscopingHeader=f??void 0,await zt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new it;return this.send(e)}}throw new Yt(o.status,`Error POSTing to endpoint: ${g}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),Ru(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(g=>this.onerror?.(g));return}const l=(Array.isArray(e)?e:[e]).filter(g=>"method"in g&&"id"in g&&g.id!==void 0).length>0,h=o.headers.get("content-type");if(l)if(h?.includes("text/event-stream"))this._handleSseStream(o.body,{onresumptiontoken:s},!1);else if(h?.includes("application/json")){const g=await o.json(),_=Array.isArray(g)?g.map(p=>Mr.parse(p)):[Mr.parse(g)];for(const p of _)this.onmessage?.(p)}else throw await o.body?.cancel(),new Yt(-1,`Unexpected content type: ${h}`);else await o.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 Yt(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})}}class hv{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 pv extends ii{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Lr.options.map((n,s)=>[n,s])),this.isMessageIgnored=(n,s)=>{const a=this._loggingLevels.get(s);return a?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(a):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new wd,this.setRequestHandler(ss,n=>this._oninitialize(n)),this.setNotificationHandler(as,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Da,async(n,s)=>{const a=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,o=Lr.safeParse(i);return o.success&&this._loggingLevels.set(a,o.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new hv(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=oi(this._capabilities,e)}setRequestHandler(e,r){const s=pr(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let a;if(lt(s)){const o=s;a=o._zod?.def?.value??o.value}else{const o=s;a=o._def?.value??o.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");if(a==="tools/call"){const o=async(c,u)=>{const l=dt(Zr,c);if(!l.success){const p=l.error instanceof Error?l.error.message:String(l.error);throw new W(S.ErrorCode.InvalidParams,`Invalid tools/call request: ${p}`)}const{params:h}=l.data,g=await Promise.resolve(r(c,u));if(h.task){const p=dt(Ht,g);if(!p.success){const y=p.error instanceof Error?p.error.message:String(p.error);throw new W(S.ErrorCode.InvalidParams,`Invalid task creation result: ${y}`)}return p.data}const _=dt(or,g);if(!_.success){const p=_.error instanceof Error?_.error.message:String(_.error);throw new W(S.ErrorCode.InvalidParams,`Invalid tools/call result: ${p}`)}return _.data};return super.setRequestHandler(e,o)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break}}assertNotificationCapability(e){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(!this._clientCapabilities?.elicitation?.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){Sd(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&bd(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){const r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:ga.includes(r)?r:Ut,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"},Ot)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const n=e.messages[e.messages.length-1],s=Array.isArray(n.content)?n.content:[n.content],a=s.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,o=i?Array.isArray(i.content)?i.content:[i.content]:[],c=o.some(u=>u.type==="tool_use");if(a){if(s.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){const u=new Set(o.filter(h=>h.type==="tool_use").map(h=>h.id)),l=new Set(s.filter(h=>h.type==="tool_result").map(h=>h.toolUseId));if(u.size!==l.size||![...u].every(h=>l.has(h)))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},Rs,r):this.request({method:"sampling/createMessage",params:e},Es,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");const s=e;return this.request({method:"elicitation/create",params:s},Dr,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");const s=e.mode==="form"?e:{...e,mode:"form"},a=await this.request({method:"elicitation/create",params:s},Dr,r);if(a.action==="accept"&&a.content&&s.requestedSchema)try{const o=this._jsonSchemaValidator.getValidator(s.requestedSchema)(a.content);if(!o.valid)throw new W(S.ErrorCode.InvalidParams,`Elicitation response content does not match requested schema: ${o.errorMessage}`)}catch(i){throw i instanceof W?i:new W(S.ErrorCode.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return a}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.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},Wa,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 mv=/^[A-Za-z0-9._-]{1,128}$/;function _v(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"),!mv.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 gv(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 Fd(t){const e=_v(t);return gv(t,e.warnings),e.isValid}class yv{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 vv{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 pv(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new yv(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(qt($s)),this.server.assertCanSetRequestHandler(qt(Zr)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler($s,()=>({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=Wr(r.inputSchema);return s?fd(s,{strictUnions:!0,pipeStrategy:"input"}):bv})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){const s=Wr(r.outputSchema);s&&(n.outputSchema=fd(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Zr,async(e,r)=>{try{const n=this._registeredTools[e.params.name];if(!n)throw new W(S.ErrorCode.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new W(S.ErrorCode.InvalidParams,`Tool ${e.params.name} disabled`);const s=!!e.params.task,a=n.execution?.taskSupport,i="createTask"in n.handler;if((a==="required"||a==="optional")&&!i)throw new W(S.ErrorCode.InternalError,`Tool ${e.params.name} has taskSupport '${a}' but was not registered with registerToolTask`);if(a==="required"&&!s)throw new W(S.ErrorCode.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(a==="optional"&&!s&&i)return await this.handleAutomaticTaskPolling(n,e,r);const o=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,o,r);return s||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof W&&n.code===S.ErrorCode.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;const a=Wr(e.inputSchema)??e.inputSchema,i=await ri(a,r);if(!i.success){const o="error"in i?i.error:"Unknown error",c=ni(o);throw new W(S.ErrorCode.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 W(S.ErrorCode.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);const s=Wr(e.outputSchema),a=await ri(s,r.structuredContent);if(!a.success){const i="error"in a?a.error:"Unknown error",o=ni(i);throw new W(S.ErrorCode.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){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");const s=await this.validateToolInput(e,r.params.arguments,r.params.name),a=e.handler,i={...n,taskStore:n.taskStore},o=s?await Promise.resolve(a.createTask(s,i)):await Promise.resolve(a.createTask(i)),c=o.task.taskId;let u=o.task;const l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(g=>setTimeout(g,l));const h=await n.taskStore.getTask(c);if(!h)throw new W(S.ErrorCode.InternalError,`Task ${c} not found during polling`);u=h}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(qt(Ts)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Ts,async e=>{switch(e.params.ref.type){case"ref/prompt":return Tl(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Pl(e),this.handleResourceCompletion(e,e.params.ref);default:throw new W(S.ErrorCode.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){const n=this._registeredPrompts[r.name];if(!n)throw new W(S.ErrorCode.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new W(S.ErrorCode.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Xr;const a=pr(n.argsSchema)?.[e.params.argument.name];if(!Ja(a))return Xr;const i=zl(a);if(!i)return Xr;const o=await i(e.params.argument.value,e.params.context);return Kd(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 Xr;throw new W(S.ErrorCode.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return Xr;const a=await s(e.params.argument.value,e.params.context);return Kd(a)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(qt(ps)),this.server.assertCanSetRequestHandler(qt(ms)),this.server.assertCanSetRequestHandler(qt(gs)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(ps,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(ms,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(gs,async(e,r)=>{const n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new W(S.ErrorCode.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 W(S.ErrorCode.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(qt(ys)),this.server.assertCanSetRequestHandler(qt(vs)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(ys,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?kv(r.argsSchema):void 0}))})),this.server.setRequestHandler(vs,async(e,r)=>{const n=this._registeredPrompts[e.params.name];if(!n)throw new W(S.ErrorCode.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new W(S.ErrorCode.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){const s=Wr(n.argsSchema),a=await ri(s,e.params.arguments);if(!a.success){const c="error"in a?a.error:"Unknown error",u=ni(c);throw new W(S.ErrorCode.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}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._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:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=i)),typeof u.title<"u"&&(i.title=u.title),typeof u.template<"u"&&(i.resourceTemplate=u.template),typeof u.metadata<"u"&&(i.metadata=u.metadata),typeof u.callback<"u"&&(i.readCallback=u.callback),typeof u.enabled<"u"&&(i.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;const o=n.uriTemplate.variableNames;return Array.isArray(o)&&o.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,s,a){const i={title:r,description:n,argsSchema:s===void 0?void 0:hr(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=hr(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,s&&Object.values(s).some(c=>{const u=c instanceof kt?c._def?.innerType:c;return Ja(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,s,a,i,o,c,u){Fd(e);const l={title:r,description:n,inputSchema:Wd(s),outputSchema:Wd(a),annotations:i,execution:o,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:h=>{typeof h.name<"u"&&h.name!==e&&(typeof h.name=="string"&&Fd(h.name),delete this._registeredTools[e],h.name&&(this._registeredTools[h.name]=l)),typeof h.title<"u"&&(l.title=h.title),typeof h.description<"u"&&(l.description=h.description),typeof h.paramsSchema<"u"&&(l.inputSchema=hr(h.paramsSchema)),typeof h.outputSchema<"u"&&(l.outputSchema=hr(h.outputSchema)),typeof h.callback<"u"&&(l.handler=h.callback),typeof h.annotations<"u"&&(l.annotations=h.annotations),typeof h._meta<"u"&&(l._meta=h._meta),typeof h.enabled<"u"&&(l.enabled=h.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}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];Vi(c)?(s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Vi(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:u}=r;return this._createRegisteredTool(e,s,a,i,o,c,{taskSupport:"forbidden"},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 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 wv{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new bt(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}}const bv={type:"object",properties:{}};function Hd(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Sv(t){return"_def"in t||"_zod"in t||Hd(t)}function Vi(t){return typeof t!="object"||t===null||Sv(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(Hd)}function Wd(t){if(t)return Vi(t)?hr(t):t}function kv(t){const e=pr(t);return e?Object.entries(e).map(([r,n])=>{const s=Lg(n),a=xg(n);return{name:r,description:s,required:!a}}):[]}function qt(t){const r=pr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const n=rd(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function Kd(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}const Xr={completion:{values:[],hasMore:!1}};S.Ajv=mc,S.AnnotationsSchema=Wt,S.AudioContentSchema=Ss,S.BaseMetadataSchema=Ft,S.BlobResourceContentsSchema=Ca,S.BooleanSchemaSchema=cl,S.COMPLETABLE_SYMBOL=Ps,S.CallToolRequestParamsSchema=Bu,S.CallToolRequestSchema=Zr,S.CallToolResultSchema=or,S.CancelTaskRequestSchema=hs,S.CancelTaskResultSchema=Nu,S.CancelledNotificationParamsSchema=vu,S.CancelledNotificationSchema=ns,S.Client=Ay,S.ClientCapabilitiesSchema=ku,S.ClientNotificationSchema=tg,S.ClientRequestSchema=eg,S.ClientResultSchema=rg,S.ClientTasksCapabilitySchema=bu,S.CompatibilityCallToolResultSchema=Q_,S.CompleteRequestParamsSchema=Rl,S.CompleteRequestSchema=Ts,S.CompleteResultSchema=Ha,S.ContentBlockSchema=ks,S.CreateMessageRequestParamsSchema=ol,S.CreateMessageRequestSchema=Ua,S.CreateMessageResultSchema=Es,S.CreateMessageResultWithToolsSchema=Rs,S.CreateTaskResultSchema=Ht,S.CursorSchema=va,S.DEFAULT_NEGOTIATED_PROTOCOL_VERSION=U_,S.DEFAULT_REQUEST_TIMEOUT_MSEC=md,S.ElicitRequestFormParamsSchema=wl,S.ElicitRequestParamsSchema=Sl,S.ElicitRequestSchema=Va,S.ElicitRequestURLParamsSchema=bl,S.ElicitResultSchema=Dr,S.ElicitationCompleteNotificationParamsSchema=kl,S.ElicitationCompleteNotificationSchema=$l,S.EmbeddedResourceSchema=Hu,S.EmptyResultSchema=Ot,S.EnumSchemaSchema=yl,S.GetPromptRequestParamsSchema=Vu,S.GetPromptRequestSchema=vs,S.GetPromptResultSchema=Ma,S.GetTaskPayloadRequestSchema=ls,S.GetTaskPayloadResultSchema=Y_,S.GetTaskRequestSchema=cs,S.GetTaskResultSchema=us,S.IconSchema=wu,S.IconsSchema=rr,S.ImageContentSchema=bs,S.ImplementationSchema=$a,S.InitializeRequestParamsSchema=$u,S.InitializeRequestSchema=ss,S.InitializeResultSchema=Ea,S.InitializedNotificationSchema=as,S.JSONRPCErrorResponseSchema=zr,S.JSONRPCErrorSchema=H_,S.JSONRPCMessageSchema=Mr,S.JSONRPCNotificationSchema=Sa,S.JSONRPCRequestSchema=ba,S.JSONRPCResponseSchema=K_,S.JSONRPCResultResponseSchema=rs,S.JSONRPC_VERSION=Ar,S.LATEST_PROTOCOL_VERSION=Ut,S.LegacyTitledEnumSchemaSchema=hl,S.ListChangedOptionsBaseSchema=Yu,S.ListPromptsRequestSchema=ys,S.ListPromptsResultSchema=za,S.ListResourceTemplatesRequestSchema=ms,S.ListResourceTemplatesResultSchema=Na,S.ListResourcesRequestSchema=ps,S.ListResourcesResultSchema=Oa,S.ListRootsRequestSchema=Il,S.ListRootsResultSchema=Wa,S.ListTasksRequestSchema=ds,S.ListTasksResultSchema=fs,S.ListToolsRequestSchema=$s,S.ListToolsResultSchema=La,S.LoggingLevelSchema=Lr,S.LoggingMessageNotificationParamsSchema=Xu,S.LoggingMessageNotificationSchema=el,S.McpError=W,S.McpServer=vv,S.ModelHintSchema=tl,S.ModelPreferencesSchema=rl,S.MultiSelectEnumSchemaSchema=gl,S.NotificationSchema=rt,S.NumberSchemaSchema=ll,S.PaginatedRequestParamsSchema=Cu,S.PaginatedRequestSchema=nr,S.PaginatedResultSchema=sr,S.PingRequestSchema=is,S.PrimitiveSchemaDefinitionSchema=vl,S.ProgressNotificationParamsSchema=Pu,S.ProgressNotificationSchema=os,S.ProgressSchema=Tu,S.ProgressTokenSchema=ya,S.PromptArgumentSchema=Du,S.PromptListChangedNotificationSchema=qa,S.PromptMessageSchema=Ku,S.PromptReferenceSchema=El,S.PromptSchema=Uu,S.Protocol=ii,S.RELATED_TASK_META_KEY=It,S.ReadResourceRequestParamsSchema=ju,S.ReadResourceRequestSchema=gs,S.ReadResourceResultSchema=Aa,S.RelatedTaskMetadataSchema=_u,S.RequestIdSchema=jr,S.RequestSchema=ze,S.ResourceContentsSchema=Ra,S.ResourceLinkSchema=Wu,S.ResourceListChangedNotificationSchema=ja,S.ResourceReferenceSchema=X_,S.ResourceRequestParamsSchema=_s,S.ResourceSchema=Ia,S.ResourceTemplate=wv,S.ResourceTemplateReferenceSchema=Fa,S.ResourceTemplateSchema=Au,S.ResourceUpdatedNotificationParamsSchema=Lu,S.ResourceUpdatedNotificationSchema=xu,S.ResultSchema=Me,S.RoleSchema=ir,S.RootSchema=Cl,S.RootsListChangedNotificationSchema=Ol,S.SSEClientTransport=uv,S.SUPPORTED_PROTOCOL_VERSIONS=ga,S.SamplingContentSchema=al,S.SamplingMessageContentBlockSchema=xr,S.SamplingMessageSchema=il,S.ServerCapabilitiesSchema=Eu,S.ServerNotificationSchema=sg,S.ServerRequestSchema=ng,S.ServerResultSchema=ag,S.ServerTasksCapabilitySchema=Su,S.SetLevelRequestParamsSchema=Qu,S.SetLevelRequestSchema=Da,S.SingleSelectEnumSchemaSchema=pl,S.SseError=Vd,S.StreamableHTTPClientTransport=fv,S.StreamableHTTPError=Yt,S.StringSchemaSchema=ul,S.SubscribeRequestParamsSchema=zu,S.SubscribeRequestSchema=Mu,S.TaskAugmentedRequestParamsSchema=tr,S.TaskCreationParamsSchema=V_,S.TaskMetadataSchema=mu,S.TaskSchema=ar,S.TaskStatusNotificationParamsSchema=Ou,S.TaskStatusNotificationSchema=qr,S.TaskStatusSchema=Iu,S.TextContentSchema=ws,S.TextResourceContentsSchema=Ta,S.TitledMultiSelectEnumSchemaSchema=_l,S.TitledSingleSelectEnumSchemaSchema=fl,S.ToolAnnotationsSchema=Ju,S.ToolChoiceSchema=nl,S.ToolExecutionSchema=Gu,S.ToolListChangedNotificationSchema=xa,S.ToolResultContentSchema=sl,S.ToolSchema=Za,S.ToolUseContentSchema=Fu,S.UnauthorizedError=it,S.UnsubscribeRequestParamsSchema=qu,S.UnsubscribeRequestSchema=Zu,S.UntitledMultiSelectEnumSchemaSchema=ml,S.UntitledSingleSelectEnumSchemaSchema=dl,S.UriTemplate=bt,S.UrlElicitationRequiredError=Nl,S.assertCompleteRequestPrompt=Tl,S.assertCompleteRequestResourceTemplate=Pl,S.auth=zt,S.buildDiscoveryUrls=Od,S.completable=og,S.createFetchWithInit=Ui,S.discoverAuthorizationServerMetadata=Nd,S.discoverOAuthMetadata=sv,S.discoverOAuthProtectedResourceMetadata=Pd,S.exchangeAuthorization=av,S.extractResourceMetadataUrl=tv,S.extractWWWAuthenticateParams=Kr,S.fetchToken=zd,S.getCompleter=zl,S.getDisplayName=ug,S.getSupportedElicitationModes=kd,S.isCompletable=Ja,S.isHttpsUrl=Rd,S.isInitializeRequest=B_,S.isInitializedNotification=Ru,S.isJSONRPCError=W_,S.isJSONRPCErrorResponse=ka,S.isJSONRPCNotification=yu,S.isJSONRPCRequest=ts,S.isJSONRPCResponse=F_,S.isJSONRPCResultResponse=Vt,S.isTaskAugmentedRequestParams=gu,S.mergeCapabilities=oi,S.normalizeHeaders=Qr,S.parseErrorResponse=Ri,S.prepareAuthorizationCodeRequest=Ii,S.refreshAuthorization=jd,S.registerClient=Md,S.selectClientAuthMethod=Ed,S.selectResourceURL=Td,S.startAuthorization=Ad,S.unwrapCompletable=cg,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
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 fd(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===V.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]})??Be(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===V.ZodString&&t.keyType._def.checks?.length){const{type:n,...s}=ld(t.keyType._def,e);return{...r,propertyNames:s}}else{if(t.keyType?._def.typeName===V.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===V.ZodBranded&&t.keyType._def.type._def.typeName===V.ZodString&&t.keyType._def.type._def.checks?.length){const{type:n,...s}=cd(t.keyType._def,e);return{...r,propertyNames:s}}}return r}function oy(t,e){if(e.mapStrategy==="record")return fd(t,e);const r=me(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||Be(e),n=me(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||Be(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function cy(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 uy(t){return t.target==="openAi"?void 0:{not:Be({...t,currentPath:[...t.currentPath,"not"]})}}function ly(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const js={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function dy(t,e){if(e.target==="openApi3")return hd(t,e);const r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in js&&(!n._def.checks||!n._def.checks.length))){const n=r.reduce((s,a)=>{const i=js[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 hd(t,e)}const hd=(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 fy(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:js[t.innerType._def.typeName],nullable:!0}:{type:[js[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 hy(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",id(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?we(r,"minimum",n.value,n.message,e):we(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),we(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?we(r,"maximum",n.value,n.message,e):we(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),we(r,"maximum",n.value,n.message,e));break;case"multipleOf":we(r,"multipleOf",n.value,n.message,e);break}return r}function py(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 u=gy(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);const l=me(c._def,{...e,currentPath:[...e.currentPath,"properties",o],propertyPath:[...e.currentPath,"properties",o]});l!==void 0&&(n.properties[o]=l,u||s.push(o))}s.length&&(n.required=s);const i=my(t,e);return i!==void 0&&(n.additionalProperties=i),n}function my(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 gy(t){try{return t.isOptional()}catch{return!0}}const _y=(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:Be(e)},r]}:Be(e)},yy=(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 vy(t,e){return me(t.type._def,e)}function wy(t,e){const n={type:"array",uniqueItems:!0,items:me(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&we(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&we(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function by(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:Be(t)}}function $y(t){return Be(t)}const ky=(t,e)=>me(t.innerType._def,e),Ey=(t,e,r)=>{switch(e){case V.ZodString:return ld(t,r);case V.ZodNumber:return hy(t,r);case V.ZodObject:return py(t,r);case V.ZodBigInt:return B_(t,r);case V.ZodBoolean:return G_();case V.ZodDate:return ud(t,r);case V.ZodUndefined:return Sy(r);case V.ZodNull:return ly(r);case V.ZodArray:return J_(t,r);case V.ZodUnion:case V.ZodDiscriminatedUnion:return dy(t,r);case V.ZodIntersection:return ny(t,r);case V.ZodTuple:return by(t,r);case V.ZodRecord:return fd(t,r);case V.ZodLiteral:return sy(t,r);case V.ZodEnum:return ty(t);case V.ZodNativeEnum:return cy(t);case V.ZodNullable:return fy(t,r);case V.ZodOptional:return _y(t,r);case V.ZodMap:return oy(t,r);case V.ZodSet:return wy(t,r);case V.ZodLazy:return()=>t.getter()._def;case V.ZodPromise:return vy(t,r);case V.ZodNaN:case V.ZodNever:return uy(r);case V.ZodEffects:return ey(t,r);case V.ZodAny:return Be(r);case V.ZodUnknown:return $y(r);case V.ZodDefault:return X_(t,r);case V.ZodBranded:return cd(t,r);case V.ZodReadonly:return ky(t,r);case V.ZodCatch:return Y_(t,r);case V.ZodPipeline:return yy(t,r);case V.ZodFunction:case V.ZodVoid:case V.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!==H_)return o}if(n&&!r){const o=Ry(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=Ey(t,t.typeName,e),i=typeof a=="function"?me(a(),e):a;if(i&&Ty(t,e,i),e.postProcess){const o=e.postProcess(i,t,e);return s.jsonSchema=i,o}return s.jsonSchema=i,i}const Ry=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:od(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`),Be(e)):e.$refStrategy==="seen"?Be(e):void 0}},Ty=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r),Py=(t,e)=>{const r=K_(e);let n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:me(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??Be(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)??Be(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 Cy(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function pd(t,e){return lt(t)?xm(t,{target:Cy(e?.target),io:e?.pipeStrategy??"input"}):Py(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function md(t){const r=mr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const n=sd(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function gd(t,e){const r=dt(t,e);if(!r.success)throw r.error;return r.data}const _d=6e4;class oi{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(ss,r=>{this._oncancel(r)}),this.setNotificationHandler(cs,r=>{this._onprogress(r)}),this.setRequestHandler(os,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(us,async(r,n)=>{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new B($.ErrorCode.InvalidParams,"Failed to retrieve task: Task not found");return{...s}}),this.setRequestHandler(ds,async(r,n)=>{const s=async()=>{const a=r.params.taskId;if(this._taskMessageQueue){let o;for(;o=await this._taskMessageQueue.dequeue(a,n.sessionId);){if(o.type==="response"||o.type==="error"){const c=o.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),o.type==="response")l(c);else{const f=c,b=new B(f.error.code,f.error.message,f.error.data);l(b)}else{const f=o.type==="response"?"Response":"Error";this._onerror(new Error(`${f} handler missing for request ${u}`))}continue}await this._transport?.send(o.message,{relatedRequestId:n.requestId})}}const i=await this._taskStore.getTask(a,n.sessionId);if(!i)throw new B($.ErrorCode.InvalidParams,`Task not found: ${a}`);if(!Bt(i.status))return await this._waitForTaskUpdate(a,n.signal),await s();if(Bt(i.status)){const o=await this._taskStore.getTaskResult(a,n.sessionId);return this._clearTaskQueue(a),{...o,_meta:{...o._meta,[It]:{taskId:a}}}}return await s()};return await s()}),this.setRequestHandler(fs,async(r,n)=>{try{const{tasks:s,nextCursor:a}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:s,nextCursor:a,_meta:{}}}catch(s){throw new B($.ErrorCode.InvalidParams,`Failed to list tasks: ${s instanceof Error?s.message:String(s)}`)}}),this.setRequestHandler(ps,async(r,n)=>{try{const s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new B($.ErrorCode.InvalidParams,`Task not found: ${r.params.taskId}`);if(Bt(s.status))throw new B($.ErrorCode.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 B($.ErrorCode.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...a}}catch(s){throw s instanceof B?s:new B($.ErrorCode.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,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),B.fromError($.ErrorCode.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=a=>{n?.(a),this._onerror(a)};const s=this._transport?.onmessage;this._transport.onmessage=(a,i)=>{s?.(a,i),Vt(a)||ka(a)?this._onresponse(a):rs(a)?this._onrequest(a,i):wu(a)?this._onnotification(a):this._onerror(new Error(`Unknown message type: ${JSON.stringify(a)}`))},await this._transport.start()}_onclose(){const e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();const r=B.fromError($.ErrorCode.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,a=e.params?._meta?.[It]?.taskId;if(n===void 0){const l={jsonrpc:"2.0",id:e.id,error:{code:$.ErrorCode.MethodNotFound,message:"Method not found"}};a&&this._taskMessageQueue?this._enqueueTaskMessage(a,{type:"error",message:l,timestamp:Date.now()},s?.sessionId).catch(f=>this._onerror(new Error(`Failed to enqueue error response: ${f}`))):s?.send(l).catch(f=>this._onerror(new Error(`Failed to send an error response: ${f}`)));return}const i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);const o=vu(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 f={relatedRequestId:e.id};a&&(f.relatedTask={taskId:a}),await this.notification(l,f)},sendRequest:async(l,f,b)=>{const v={...b,relatedRequestId:e.id};a&&!v.relatedTask&&(v.relatedTask={taskId:a});const g=v.relatedTask?.taskId??a;return g&&c&&await c.updateTaskStatus(g,"input_required"),await this.request(l,f,v)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:a,taskStore:c,taskRequestedTtl:o?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;const f={result:l,jsonrpc:"2.0",id:e.id};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"response",message:f,timestamp:Date.now()},s?.sessionId):await s?.send(f)},async l=>{if(i.signal.aborted)return;const f={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:$.ErrorCode.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};a&&this._taskMessageQueue?await this._enqueueTaskMessage(a,{type:"error",message:f,timestamp:Date.now()},s?.sessionId):await s?.send(f)}).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),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),Vt(e))n(e);else{const i=new B(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(Vt(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),Vt(e))s(e);else{const i=B.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 B?i:new B($.ErrorCode.InternalError,String(i))}}return}let a;try{const i=await this.request(e,Ht,n);if(i.task)a=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new B($.ErrorCode.InternalError,"Task creation did not return a task");for(;;){const o=await this.getTask({taskId:a},n);if(yield{type:"taskStatus",task:o},Bt(o.status)){o.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)}:o.status==="failed"?yield{type:"error",error:new B($.ErrorCode.InternalError,`Task ${a} failed`)}:o.status==="cancelled"&&(yield{type:"error",error:new B($.ErrorCode.InternalError,`Task ${a} was cancelled`)});return}if(o.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:a},r,n)};return}const c=o.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof B?i:new B($.ErrorCode.InternalError,String(i))}}}request(e,r,n){const{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i,task:o,relatedTask:c}=n??{};return new Promise((u,l)=>{const f=p=>{l(p)};if(!this._transport){f(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(p){f(p);return}n?.signal?.throwIfAborted();const b=this._requestMessageId++,v={...e,jsonrpc:"2.0",id:b};n?.onprogress&&(this._progressHandlers.set(b,n.onprogress),v.params={...e.params,_meta:{...e.params?._meta||{},progressToken:b}}),o&&(v.params={...v.params,task:o}),c&&(v.params={...v.params,_meta:{...v.params?._meta||{},[It]:c}});const g=p=>{this._responseHandlers.delete(b),this._progressHandlers.delete(b),this._cleanupTimeout(b),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:b,reason:String(p)}},{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(R=>this._onerror(new Error(`Failed to send cancellation: ${R}`)));const y=p instanceof B?p:new B($.ErrorCode.RequestTimeout,String(p));l(y)};this._responseHandlers.set(b,p=>{if(!n?.signal?.aborted){if(p instanceof Error)return l(p);try{const y=dt(r,p.result);y.success?u(y.data):l(y.error)}catch(y){l(y)}}}),n?.signal?.addEventListener("abort",()=>{g(n?.signal?.reason)});const w=n?.timeout??_d,m=()=>g(B.fromError($.ErrorCode.RequestTimeout,"Request timed out",{timeout:w}));this._setupTimeout(b,w,n?.maxTotalTimeout,m,n?.resetTimeoutOnProgress??!1);const S=c?.taskId;if(S){const p=y=>{const R=this._responseHandlers.get(b);R?R(y):this._onerror(new Error(`Response handler missing for side-channeled request ${b}`))};this._requestResolvers.set(b,p),this._enqueueTaskMessage(S,{type:"request",message:v,timestamp:Date.now()}).catch(y=>{this._cleanupTimeout(b),l(y)})}else this._transport.send(v,{relatedRequestId:s,resumptionToken:a,onresumptiontoken:i}).catch(p=>{this._cleanupTimeout(b),l(p)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},ls,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},hs,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},zu,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 o={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[It]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:o,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 o={...e,jsonrpc:"2.0"};r?.relatedTask&&(o={...o,params:{...o.params,_meta:{...o.params?._meta||{},[It]:r.relatedTask}}}),this._transport?.send(o,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[It]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){const n=md(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(s,a)=>{const i=gd(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=md(e);this._notificationHandlers.set(n,s=>{const a=gd(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){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"&&rs(s.message)){const a=s.message.id,i=this._requestResolvers.get(a);i?(i(new B($.ErrorCode.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){let n=this._options?.defaultTaskPollInterval??1e3;try{const s=await this._taskStore?.getTask(e);s?.pollInterval&&(n=s.pollInterval)}catch{}return new Promise((s,a)=>{if(r.aborted){a(new B($.ErrorCode.InvalidRequest,"Request cancelled"));return}const i=setTimeout(s,n);r.addEventListener("abort",()=>{clearTimeout(i),a(new B($.ErrorCode.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 B($.ErrorCode.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=Zr.parse({method:"notifications/tasks/status",params:o});await this.notification(c),Bt(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 B($.ErrorCode.InvalidParams,`Task "${s}" not found - it may have been cleaned up`);if(Bt(o.status))throw new B($.ErrorCode.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 u=Zr.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Bt(c.status)&&this._cleanupTaskProgressHandler(s)}},listTasks:s=>n.listTasks(s,r)}}}function yd(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function ci(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];yd(i)&&yd(a)?r[s]={...i,...a}:r[s]=a}return r}var Ms={exports:{}},ui={},vd;function Iy(){return vd||(vd=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatNames=t.fastFormats=t.fullFormats=void 0;function e(C,M){return{validate:C,compare:M}}t.fullFormats={date:e(a,i),time:e(c(!0),u),"date-time":e(b(!0),v),"iso-time":e(c(),l),"iso-date-time":e(b(),g),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:S,"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:j,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:y,int32:{type:"number",validate:h},int64:{type:"number",validate:_},float:{type:"number",validate:E},double:{type:"number",validate:E},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,v),"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,g),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(C){return C%4===0&&(C%100!==0||C%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(C){const M=n.exec(C);if(!M)return!1;const F=+M[1],D=+M[2],ae=+M[3];return D>=1&&D<=12&&ae>=1&&ae<=(D===2&&r(F)?29:s[D])}function i(C,M){if(C&&M)return C>M?1:C<M?-1:0}const o=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function c(C){return function(F){const D=o.exec(F);if(!D)return!1;const ae=+D[1],$e=+D[2],xe=+D[3],ge=D[4],mt=D[5]==="-"?-1:1,H=+(D[6]||0),N=+(D[7]||0);if(H>23||N>59||C&&!ge)return!1;if(ae<=23&&$e<=59&&xe<60)return!0;const L=$e-N*mt,z=ae-H*mt-(L<0?1:0);return(z===23||z===-1)&&(L===59||L===-1)&&xe<61}}function u(C,M){if(!(C&&M))return;const F=new Date("2020-01-01T"+C).valueOf(),D=new Date("2020-01-01T"+M).valueOf();if(F&&D)return F-D}function l(C,M){if(!(C&&M))return;const F=o.exec(C),D=o.exec(M);if(F&&D)return C=F[1]+F[2]+F[3],M=D[1]+D[2]+D[3],C>M?1:C<M?-1:0}const f=/t|\s/i;function b(C){const M=c(C);return function(D){const ae=D.split(f);return ae.length===2&&a(ae[0])&&M(ae[1])}}function v(C,M){if(!(C&&M))return;const F=new Date(C).valueOf(),D=new Date(M).valueOf();if(F&&D)return F-D}function g(C,M){if(!(C&&M))return;const[F,D]=C.split(f),[ae,$e]=M.split(f),xe=i(F,ae);if(xe!==void 0)return xe||u(D,$e)}const w=/\/|:/,m=/^(?:[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 S(C){return w.test(C)&&m.test(C)}const p=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function y(C){return p.lastIndex=0,p.test(C)}const R=-2147483648,d=2**31-1;function h(C){return Number.isInteger(C)&&C<=d&&C>=R}function _(C){return Number.isInteger(C)}function E(){return!0}const I=/[^\\]\\Z/;function j(C){if(I.test(C))return!1;try{return new RegExp(C),!0}catch{return!1}}})(ui)),ui}var li={},wd;function Oy(){return wd||(wd=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.formatLimitDefinition=void 0;const e=gc(),r=ie(),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:u,schemaCode:l,keyword:f,it:b}=o,{opts:v,self:g}=b;if(!v.validateFormats)return;const w=new e.KeywordCxt(b,g.RULES.all.format.definition,"format");w.$data?m():S();function m(){const y=c.scopeValue("formats",{ref:g.formats,code:v.code.formats}),R=c.const("fmt",(0,r._)`${y}[${w.schemaCode}]`);o.fail$data((0,r.or)((0,r._)`typeof ${R} != "object"`,(0,r._)`${R} instanceof RegExp`,(0,r._)`typeof ${R}.compare != "function"`,p(R)))}function S(){const y=w.schema,R=g.formats[y];if(!R||R===!0)return;if(typeof R!="object"||R instanceof RegExp||typeof R.compare!="function")throw new Error(`"${f}": format "${y}" does not define "compare" function`);const d=c.scopeValue("formats",{key:y,ref:R,code:v.code.formats?(0,r._)`${v.code.formats}${(0,r.getProperty)(y)}`:void 0});o.fail$data(p(d))}function p(y){return(0,r._)`${y}.compare(${u}, ${l}) ${s[f].fail} 0`}},dependencies:["format"]};const i=o=>(o.addKeyword(t.formatLimitDefinition),o);t.default=i})(li)),li}var bd;function Ny(){return bd||(bd=1,(function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=Iy(),n=Oy(),s=ie(),a=new s.Name("fullFormats"),i=new s.Name("fastFormats"),o=(u,l={keywords:!0})=>{if(Array.isArray(l))return c(u,l,r.fullFormats,a),u;const[f,b]=l.mode==="fast"?[r.fastFormats,i]:[r.fullFormats,a],v=l.formats||r.formatNames;return c(u,v,f,b),l.keywords&&(0,n.default)(u),u};o.get=(u,l="full")=>{const b=(l==="fast"?r.fastFormats:r.fullFormats)[u];if(!b)throw new Error(`Unknown format "${u}"`);return b};function c(u,l,f,b){var v,g;(v=(g=u.opts.code).formats)!==null&&v!==void 0||(g.formats=(0,s._)`require("ajv-formats/dist/formats").${b}`);for(const w of l)u.addFormat(w,f[w])}t.exports=e=o,Object.defineProperty(e,"__esModule",{value:!0}),e.default=o})(Ms,Ms.exports)),Ms.exports}var Ay=Ny();const zy=Xt(Ay);function jy(){const t=new _c({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return zy(t),t}class Sd{constructor(e){this._ajv=e??jy()}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 My{constructor(e){this._client=e}async*callToolStream(e,r=cr,n){const s=this._client,a={...n,task:n?.task??(s.isToolTask(e.name)?{}:void 0)},i=s.requestStream({method:"tools/call",params:e},r,a),o=s.getToolOutputValidator(e.name);for await(const c of i){if(c.type==="result"&&o){const u=c.result;if(!u.structuredContent&&!u.isError){yield{type:"error",error:new B($.ErrorCode.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`)};return}if(u.structuredContent)try{const l=o(u.structuredContent);if(!l.valid){yield{type:"error",error:new B($.ErrorCode.InvalidParams,`Structured content does not match the tool's output schema: ${l.errorMessage}`)};return}}catch(l){if(l instanceof B){yield{type:"error",error:l};return}yield{type:"error",error:new B($.ErrorCode.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 $d(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 kd(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 qs(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&&qs(a,r[s])}}if(Array.isArray(t.anyOf))for(const r of t.anyOf)typeof r!="boolean"&&qs(r,e);if(Array.isArray(t.oneOf))for(const r of t.oneOf)typeof r!="boolean"&&qs(r,e)}}function Ed(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 qy extends oi{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 Sd,r?.listChanged&&(this._pendingListChangedConfig=r.listChanged)}_setupListChangedHandlers(e){e.tools&&this._serverCapabilities?.tools?.listChanged&&this._setupListChangedHandler("tools",Da,e.tools,async()=>(await this.listTools()).tools),e.prompts&&this._serverCapabilities?.prompts?.listChanged&&this._setupListChangedHandler("prompts",Za,e.prompts,async()=>(await this.listPrompts()).prompts),e.resources&&this._serverCapabilities?.resources?.listChanged&&this._setupListChangedHandler("resources",ja,e.resources,async()=>(await this.listResources()).resources)}get experimental(){return this._experimental||(this._experimental={tasks:new My(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=ci(this._capabilities,e)}setRequestHandler(e,r){const s=mr(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let a;if(lt(s)){const o=s;a=o._zod?.def?.value??o.value}else{const o=s;a=o._def?.value??o.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");const i=a;if(i==="elicitation/create"){const o=async(c,u)=>{const l=dt(Fa,c);if(!l.success){const p=l.error instanceof Error?l.error.message:String(l.error);throw new B($.ErrorCode.InvalidParams,`Invalid elicitation request: ${p}`)}const{params:f}=l.data;f.mode=f.mode??"form";const{supportsFormMode:b,supportsUrlMode:v}=Ed(this._capabilities.elicitation);if(f.mode==="form"&&!b)throw new B($.ErrorCode.InvalidParams,"Client does not support form-mode elicitation requests");if(f.mode==="url"&&!v)throw new B($.ErrorCode.InvalidParams,"Client does not support URL-mode elicitation requests");const g=await Promise.resolve(r(c,u));if(f.task){const p=dt(Ht,g);if(!p.success){const y=p.error instanceof Error?p.error.message:String(p.error);throw new B($.ErrorCode.InvalidParams,`Invalid task creation result: ${y}`)}return p.data}const w=dt(Ur,g);if(!w.success){const p=w.error instanceof Error?w.error.message:String(w.error);throw new B($.ErrorCode.InvalidParams,`Invalid elicitation result: ${p}`)}const m=w.data,S=f.mode==="form"?f.requestedSchema:void 0;if(f.mode==="form"&&m.action==="accept"&&m.content&&S&&this._capabilities.elicitation?.form?.applyDefaults)try{qs(S,m.content)}catch{}return m};return super.setRequestHandler(e,o)}if(i==="sampling/createMessage"){const o=async(c,u)=>{const l=dt(Va,c);if(!l.success){const m=l.error instanceof Error?l.error.message:String(l.error);throw new B($.ErrorCode.InvalidParams,`Invalid sampling request: ${m}`)}const{params:f}=l.data,b=await Promise.resolve(r(c,u));if(f.task){const m=dt(Ht,b);if(!m.success){const S=m.error instanceof Error?m.error.message:String(m.error);throw new B($.ErrorCode.InvalidParams,`Invalid task creation result: ${S}`)}return m.data}const g=f.tools||f.toolChoice?Ts:Rs,w=dt(g,b);if(!w.success){const m=w.error instanceof Error?w.error.message:String(w.error);throw new B($.ErrorCode.InvalidParams,`Invalid sampling result: ${m}`)}return w.data};return super.setRequestHandler(e,o)}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:Ut,capabilities:this._capabilities,clientInfo:this._clientInfo}},Ra,r);if(n===void 0)throw new Error(`Server sent invalid initialize result: ${n}`);if(!ya.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){$d(this._serverCapabilities?.tasks?.requests,e,"Server")}assertTaskHandlerCapability(e){this._capabilities&&kd(this._capabilities.tasks?.requests,e,"Client")}async ping(e){return this.request({method:"ping"},Ot,e)}async complete(e,r){return this.request({method:"completion/complete",params:e},Wa,r)}async setLoggingLevel(e,r){return this.request({method:"logging/setLevel",params:{level:e}},Ot,r)}async getPrompt(e,r){return this.request({method:"prompts/get",params:e},qa,r)}async listPrompts(e,r){return this.request({method:"prompts/list",params:e},Ma,r)}async listResources(e,r){return this.request({method:"resources/list",params:e},Na,r)}async listResourceTemplates(e,r){return this.request({method:"resources/templates/list",params:e},Aa,r)}async readResource(e,r){return this.request({method:"resources/read",params:e},za,r)}async subscribeResource(e,r){return this.request({method:"resources/subscribe",params:e},Ot,r)}async unsubscribeResource(e,r){return this.request({method:"resources/unsubscribe",params:e},Ot,r)}async callTool(e,r=cr,n){if(this.isToolTaskRequired(e.name))throw new B($.ErrorCode.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 B($.ErrorCode.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 B($.ErrorCode.InvalidParams,`Structured content does not match the tool's output schema: ${i.errorMessage}`)}catch(i){throw i instanceof B?i:new B($.ErrorCode.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},La,r);return this.cacheToolMetadata(n.tools),n}_setupListChangedHandler(e,r,n,s){const a=Xu.safeParse(n);if(!a.success)throw new Error(`Invalid ${e} listChanged options: ${a.error.message}`);if(typeof n.onChanged!="function")throw new Error(`Invalid ${e} listChanged options: onChanged must be a function`);const{autoRefresh:i,debounceMs:o}=a.data,{onChanged:c}=n,u=async()=>{if(!i){c(null,null);return}try{const f=await s();c(null,f)}catch(f){const b=f instanceof Error?f:new Error(String(f));c(b,null)}},l=()=>{if(o){const f=this._listChangedDebounceTimers.get(e);f&&clearTimeout(f);const b=setTimeout(u,o);this._listChangedDebounceTimers.set(e,b)}else u()};this.setNotificationHandler(r,l)}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}let di;di=globalThis.crypto;async function Zy(t){return(await di).getRandomValues(new Uint8Array(t))}async function xy(t){const e="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~",r=Math.pow(2,8)-Math.pow(2,8)%e.length;let n="";for(;n.length<t;){const s=await Zy(t-n.length);for(const a of s)a<r&&(n+=e[a%e.length])}return n}async function Ly(t){return await xy(t)}async function Dy(t){const e=await(await di).subtle.digest("SHA-256",new TextEncoder().encode(t));return btoa(String.fromCharCode(...new Uint8Array(e))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function Uy(t){if(t||(t=43),t<43||t>128)throw`Expected a length between 43 and 128. Received ${t}.`;const e=await Ly(t),r=await Dy(e);return{code_verifier:e,code_challenge:r}}const Ve=Xm().superRefine((t,e)=>{if(!URL.canParse(t))return e.addIssue({code:Fg.custom,message:"URL must be parseable",fatal:!0}),Jf}).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"}),Vy=De({resource:T().url(),authorization_servers:K(Ve).optional(),jwks_uri:T().url().optional(),scopes_supported:K(T()).optional(),bearer_methods_supported:K(T()).optional(),resource_signing_alg_values_supported:K(T()).optional(),resource_name:T().optional(),resource_documentation:T().optional(),resource_policy_uri:T().url().optional(),resource_tos_uri:T().url().optional(),tls_client_certificate_bound_access_tokens:ke().optional(),authorization_details_types_supported:K(T()).optional(),dpop_signing_alg_values_supported:K(T()).optional(),dpop_bound_access_tokens_required:ke().optional()}),fi=De({issuer:T(),authorization_endpoint:Ve,token_endpoint:Ve,registration_endpoint:Ve.optional(),scopes_supported:K(T()).optional(),response_types_supported:K(T()),response_modes_supported:K(T()).optional(),grant_types_supported:K(T()).optional(),token_endpoint_auth_methods_supported:K(T()).optional(),token_endpoint_auth_signing_alg_values_supported:K(T()).optional(),service_documentation:Ve.optional(),revocation_endpoint:Ve.optional(),revocation_endpoint_auth_methods_supported:K(T()).optional(),revocation_endpoint_auth_signing_alg_values_supported:K(T()).optional(),introspection_endpoint:T().optional(),introspection_endpoint_auth_methods_supported:K(T()).optional(),introspection_endpoint_auth_signing_alg_values_supported:K(T()).optional(),code_challenge_methods_supported:K(T()).optional(),client_id_metadata_document_supported:ke().optional()}),Fy=De({issuer:T(),authorization_endpoint:Ve,token_endpoint:Ve,userinfo_endpoint:Ve.optional(),jwks_uri:Ve,registration_endpoint:Ve.optional(),scopes_supported:K(T()).optional(),response_types_supported:K(T()),response_modes_supported:K(T()).optional(),grant_types_supported:K(T()).optional(),acr_values_supported:K(T()).optional(),subject_types_supported:K(T()),id_token_signing_alg_values_supported:K(T()),id_token_encryption_alg_values_supported:K(T()).optional(),id_token_encryption_enc_values_supported:K(T()).optional(),userinfo_signing_alg_values_supported:K(T()).optional(),userinfo_encryption_alg_values_supported:K(T()).optional(),userinfo_encryption_enc_values_supported:K(T()).optional(),request_object_signing_alg_values_supported:K(T()).optional(),request_object_encryption_alg_values_supported:K(T()).optional(),request_object_encryption_enc_values_supported:K(T()).optional(),token_endpoint_auth_methods_supported:K(T()).optional(),token_endpoint_auth_signing_alg_values_supported:K(T()).optional(),display_values_supported:K(T()).optional(),claim_types_supported:K(T()).optional(),claims_supported:K(T()).optional(),service_documentation:T().optional(),claims_locales_supported:K(T()).optional(),ui_locales_supported:K(T()).optional(),claims_parameter_supported:ke().optional(),request_parameter_supported:ke().optional(),request_uri_parameter_supported:ke().optional(),require_request_uri_registration:ke().optional(),op_policy_uri:Ve.optional(),op_tos_uri:Ve.optional(),client_id_metadata_document_supported:ke().optional()}),Hy=J({...Fy.shape,...fi.pick({code_challenge_methods_supported:!0}).shape}),Wy=J({access_token:T(),id_token:T().optional(),token_type:T(),expires_in:Hg().optional(),scope:T().optional(),refresh_token:T().optional()}).strip(),Ky=J({error:T(),error_description:T().optional(),error_uri:T().optional()}),Rd=Ve.optional().or(te("").transform(()=>{})),Jy=J({redirect_uris:K(Ve),token_endpoint_auth_method:T().optional(),grant_types:K(T()).optional(),response_types:K(T()).optional(),client_name:T().optional(),client_uri:Ve.optional(),logo_uri:Rd,scope:T().optional(),contacts:K(T()).optional(),tos_uri:Rd,policy_uri:T().optional(),jwks_uri:Ve.optional(),jwks:vg().optional(),software_id:T().optional(),software_version:T().optional(),software_statement:T().optional()}).strip(),By=J({client_id:T(),client_secret:T().optional(),client_id_issued_at:ye().optional(),client_secret_expires_at:ye().optional()}).strip(),Gy=Jy.merge(By);J({error:T(),error_description:T().optional()}).strip(),J({token:T(),token_type_hint:T().optional()}).strip();function Yy(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 Ze 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 hi extends Ze{}hi.errorCode="invalid_request";class Zs extends Ze{}Zs.errorCode="invalid_client";class xs extends Ze{}xs.errorCode="invalid_grant";class Ls extends Ze{}Ls.errorCode="unauthorized_client";class pi extends Ze{}pi.errorCode="unsupported_grant_type";class mi extends Ze{}mi.errorCode="invalid_scope";class gi extends Ze{}gi.errorCode="access_denied";class gr extends Ze{}gr.errorCode="server_error";class _i extends Ze{}_i.errorCode="temporarily_unavailable";class yi extends Ze{}yi.errorCode="unsupported_response_type";class vi extends Ze{}vi.errorCode="unsupported_token_type";class wi extends Ze{}wi.errorCode="invalid_token";class bi extends Ze{}bi.errorCode="method_not_allowed";class Si extends Ze{}Si.errorCode="too_many_requests";class Ds extends Ze{}Ds.errorCode="invalid_client_metadata";class $i extends Ze{}$i.errorCode="insufficient_scope";class ki extends Ze{}ki.errorCode="invalid_target";const Xy={[hi.errorCode]:hi,[Zs.errorCode]:Zs,[xs.errorCode]:xs,[Ls.errorCode]:Ls,[pi.errorCode]:pi,[mi.errorCode]:mi,[gi.errorCode]:gi,[gr.errorCode]:gr,[_i.errorCode]:_i,[yi.errorCode]:yi,[vi.errorCode]:vi,[wi.errorCode]:wi,[bi.errorCode]:bi,[Si.errorCode]:Si,[Ds.errorCode]:Ds,[$i.errorCode]:$i,[ki.errorCode]:ki};class it extends Error{constructor(e){super(e??"Unauthorized")}}function ev(t){return["client_secret_basic","client_secret_post","none"].includes(t)}const Ei="code",Ri="S256";function Td(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&&ev(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 tv(t,e,r,n){const{client_id:s,client_secret:a}=e;switch(t){case"client_secret_basic":rv(s,a,r);return;case"client_secret_post":nv(s,a,n);return;case"none":sv(s,n);return;default:throw new Error(`Unsupported client authentication method: ${t}`)}}function rv(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 nv(t,e,r){r.set("client_id",t),e&&r.set("client_secret",e)}function sv(t,e){e.set("client_id",t)}async function Ti(t){const e=t instanceof Response?t.status:void 0,r=t instanceof Response?await t.text():t;try{const n=Ky.parse(JSON.parse(r)),{error:s,error_description:a,error_uri:i}=n,o=Xy[s]||gr;return new o(a||"",i)}catch(n){const s=`${e?`HTTP ${e}: `:""}Invalid OAuth error response: ${n}. Raw body: ${r}`;return new gr(s)}}async function jt(t,e){try{return await Pi(t,e)}catch(r){if(r instanceof Zs||r instanceof Ls)return await t.invalidateCredentials?.("all"),await Pi(t,e);if(r instanceof xs)return await t.invalidateCredentials?.("tokens"),await Pi(t,e);throw r}}async function Pi(t,{serverUrl:e,authorizationCode:r,scope:n,resourceMetadataUrl:s,fetchFn:a}){let i,o;try{i=await Id(e,{resourceMetadataUrl:s},a),i.authorization_servers&&i.authorization_servers.length>0&&(o=i.authorization_servers[0])}catch{}o||(o=new URL("/",e));const c=await Cd(e,t,i),u=await zd(o,{fetchFn:a});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 m=u?.client_id_metadata_document_supported===!0,S=t.clientMetadataUrl;if(S&&!Pd(S))throw new Ds(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${S}`);if(m&&S)l={client_id:S},await t.saveClientInformation?.(l);else{if(!t.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const y=await Zd(o,{metadata:u,clientMetadata:t.clientMetadata,fetchFn:a});await t.saveClientInformation(y),l=y}}const f=!t.redirectUrl;if(r!==void 0||f){const m=await qd(t,o,{metadata:u,resource:c,authorizationCode:r,fetchFn:a});return await t.saveTokens(m),"AUTHORIZED"}const b=await t.tokens();if(b?.refresh_token)try{const m=await Md(o,{metadata:u,clientInformation:l,refreshToken:b.refresh_token,resource:c,addClientAuthentication:t.addClientAuthentication,fetchFn:a});return await t.saveTokens(m),"AUTHORIZED"}catch(m){if(!(!(m instanceof Ze)||m instanceof gr))throw m}const v=t.state?await t.state():void 0,{authorizationUrl:g,codeVerifier:w}=await jd(o,{metadata:u,clientInformation:l,state:v,redirectUrl:t.redirectUrl,scope:n||i?.scopes_supported?.join(" ")||t.clientMetadata.scope,resource:c});return await t.saveCodeVerifier(w),await t.redirectToAuthorization(g),"REDIRECT"}function Pd(t){if(!t)return!1;try{const e=new URL(t);return e.protocol==="https:"&&e.pathname!=="/"}catch{return!1}}async function Cd(t,e,r){const n=Yy(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 Jr(t){const e=t.headers.get("WWW-Authenticate");if(!e)return{};const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return{};const s=Ci(t,"resource_metadata")||void 0;let a;if(s)try{a=new URL(s)}catch{}const i=Ci(t,"scope")||void 0,o=Ci(t,"error")||void 0;return{resourceMetadataUrl:a,scope:i,error:o}}function Ci(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}function av(t){const e=t.headers.get("WWW-Authenticate");if(!e)return;const[r,n]=e.split(" ");if(r.toLowerCase()!=="bearer"||!n)return;const a=/resource_metadata="([^"]*)"/.exec(e);if(a)try{return new URL(a[1])}catch{return}}async function Id(t,e,r=fetch){const n=await Nd(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 Vy.parse(await n.json())}async function Ii(t,e,r=fetch){try{return await r(t,{headers:e})}catch(n){if(n instanceof TypeError)return e?Ii(t,void 0,r):void 0;throw n}}function iv(t,e="",r={}){return e.endsWith("/")&&(e=e.slice(0,-1)),r.prependPathname?`${e}/.well-known/${t}`:`/.well-known/${t}${e}`}async function Od(t,e,r=fetch){return await Ii(t,{"MCP-Protocol-Version":e},r)}function ov(t,e){return!t||t.status>=400&&t.status<500&&e!=="/"}async function Nd(t,e,r,n){const s=new URL(t),a=n?.protocolVersion??Ut;let i;if(n?.metadataUrl)i=new URL(n.metadataUrl);else{const c=iv(e,s.pathname);i=new URL(c,n?.metadataServerUrl??s),i.search=s.search}let o=await Od(i,a,r);if(!n?.metadataUrl&&ov(o,s.pathname)){const c=new URL(`/.well-known/${e}`,s);o=await Od(c,a,r)}return o}async function cv(t,{authorizationServerUrl:e,protocolVersion:r}={},n=fetch){typeof t=="string"&&(t=new URL(t)),e||(e=t),typeof e=="string"&&(e=new URL(e)),r??(r=Ut);const s=await Nd(e,"oauth-authorization-server",n,{protocolVersion:r,metadataServerUrl:e});if(!s||s.status===404){await s?.body?.cancel();return}if(!s.ok)throw await s.body?.cancel(),new Error(`HTTP ${s.status} trying to load well-known OAuth metadata`);return fi.parse(await s.json())}function Ad(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 zd(t,{fetchFn:e=fetch,protocolVersion:r=Ut}={}){const n={"MCP-Protocol-Version":r,Accept:"application/json"},s=Ad(t);for(const{url:a,type:i}of s){const o=await Ii(a,n,e);if(o){if(!o.ok){if(await o.body?.cancel(),o.status>=400&&o.status<500)continue;throw new Error(`HTTP ${o.status} trying to load ${i==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}return i==="oauth"?fi.parse(await o.json()):Hy.parse(await o.json())}}}async function jd(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(Ei))throw new Error(`Incompatible auth server: does not support response type ${Ei}`);if(e.code_challenge_methods_supported&&!e.code_challenge_methods_supported.includes(Ri))throw new Error(`Incompatible auth server: does not support code challenge method ${Ri}`)}else o=new URL("/authorize",t);const c=await Uy(),u=c.code_verifier,l=c.code_challenge;return o.searchParams.set("response_type",Ei),o.searchParams.set("client_id",r.client_id),o.searchParams.set("code_challenge",l),o.searchParams.set("code_challenge_method",Ri),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:u}}function Oi(t,e,r){return new URLSearchParams({grant_type:"authorization_code",code:t,code_verifier:e,redirect_uri:String(r)})}async function Ni(t,{metadata:e,tokenRequestParams:r,clientInformation:n,addClientAuthentication:s,resource:a,fetchFn:i}){const o=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(a&&r.set("resource",a.href),s)await s(c,r,o,e);else if(n){const l=e?.token_endpoint_auth_methods_supported??[],f=Td(n,l);tv(f,n,c,r)}const u=await(i??fetch)(o,{method:"POST",headers:c,body:r});if(!u.ok)throw await Ti(u);return Wy.parse(await u.json())}async function uv(t,{metadata:e,clientInformation:r,authorizationCode:n,codeVerifier:s,redirectUri:a,resource:i,addClientAuthentication:o,fetchFn:c}){const u=Oi(n,s,a);return Ni(t,{metadata:e,tokenRequestParams:u,clientInformation:r,addClientAuthentication:o,resource:i,fetchFn:c})}async function Md(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 Ni(t,{metadata:e,tokenRequestParams:o,clientInformation:r,addClientAuthentication:a,resource:s,fetchFn:i});return{refresh_token:n,...c}}async function qd(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 u=await t.codeVerifier();o=Oi(s,u,t.redirectUrl)}const c=await t.clientInformation();return Ni(e,{metadata:r,tokenRequestParams:o,clientInformation:c??void 0,addClientAuthentication:t.addClientAuthentication,resource:n,fetchFn:a})}async function Zd(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 Ti(a);return Gy.parse(await a.json())}class Ai 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}}const xd=10,lv=13,Gt=32;function zi(t){}function Ld(t){if(typeof t=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:e=zi,onError:r=zi,onRetry:n=zi,onComment:s,maxBufferSize:a}=t,i=[];let o=0,c=!0,u,l="",f=0,b,v=!1;function g(d){if(v)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,d.charCodeAt(0)===239&&d.charCodeAt(1)===187&&d.charCodeAt(2)===191&&(d=d.slice(3))),i.length===0){const E=m(d);E!==""&&(i.push(E),o=E.length),w();return}if(d.indexOf(`
40
+ `)===-1&&d.indexOf("\r")===-1){i.push(d),o+=d.length,w();return}i.push(d);const h=i.join("");i.length=0,o=0;const _=m(h);_!==""&&(i.push(_),o=_.length),w()}function w(){a!==void 0&&(o+l.length<=a||(v=!0,i.length=0,o=0,u=void 0,l="",f=0,b=void 0,r(new Ai(`Buffered data exceeded max buffer size of ${a} characters`,{type:"max-buffer-size-exceeded"}))))}function m(d){let h=0;if(d.indexOf("\r")===-1){let _=d.indexOf(`
41
+ `,h);for(;_!==-1;){if(h===_){f>0&&e({id:u,event:b,data:l}),u=void 0,l="",f=0,b=void 0,h=_+1,_=d.indexOf(`
42
+ `,h);continue}const E=d.charCodeAt(h);if(Dd(d,h,E)){const I=d.charCodeAt(h+5)===Gt?h+6:h+5,j=d.slice(I,_);if(f===0&&d.charCodeAt(_+1)===xd){e({id:u,event:b,data:j}),u=void 0,l="",b=void 0,h=_+2,_=d.indexOf(`
43
+ `,h);continue}l=f===0?j:`${l}
44
+ ${j}`,f++}else Ud(d,h,E)?b=d.slice(d.charCodeAt(h+6)===Gt?h+7:h+6,_)||void 0:S(d,h,_);h=_+1,_=d.indexOf(`
45
+ `,h)}return d.slice(h)}for(;h<d.length;){const _=d.indexOf("\r",h),E=d.indexOf(`
46
+ `,h);let I=-1;if(_!==-1&&E!==-1?I=_<E?_:E:_!==-1?_===d.length-1?I=-1:I=_:E!==-1&&(I=E),I===-1)break;S(d,h,I),h=I+1,d.charCodeAt(h-1)===lv&&d.charCodeAt(h)===xd&&h++}return d.slice(h)}function S(d,h,_){if(h===_){y();return}const E=d.charCodeAt(h);if(Dd(d,h,E)){const D=d.charCodeAt(h+5)===Gt?h+6:h+5,ae=d.slice(D,_);l=f===0?ae:`${l}
47
+ ${ae}`,f++;return}if(Ud(d,h,E)){b=d.slice(d.charCodeAt(h+6)===Gt?h+7:h+6,_)||void 0;return}if(E===105&&d.charCodeAt(h+1)===100&&d.charCodeAt(h+2)===58){const D=d.slice(d.charCodeAt(h+3)===Gt?h+4:h+3,_);u=D.includes("\0")?void 0:D;return}if(E===58){if(s){const D=d.slice(h,_);s(D.slice(d.charCodeAt(h+1)===Gt?2:1))}return}const I=d.slice(h,_),j=I.indexOf(":");if(j===-1){p(I,"",I);return}const C=I.slice(0,j),M=I.charCodeAt(j+1)===Gt?2:1,F=I.slice(j+M);p(C,F,I)}function p(d,h,_){switch(d){case"event":b=h||void 0;break;case"data":l=f===0?h:`${l}
48
+ ${h}`,f++;break;case"id":u=h.includes("\0")?void 0:h;break;case"retry":/^\d+$/.test(h)?n(parseInt(h,10)):r(new Ai(`Invalid \`retry\` value: "${h}"`,{type:"invalid-retry",value:h,line:_}));break;default:r(new Ai(`Unknown field "${d.length>20?`${d.slice(0,20)}…`:d}"`,{type:"unknown-field",field:d,value:h,line:_}));break}}function y(){f>0&&e({id:u,event:b,data:l}),u=void 0,l="",f=0,b=void 0}function R(d={}){if(d.consume&&i.length>0){const h=i.join("");S(h,0,h.length)}c=!0,u=void 0,l="",f=0,b=void 0,i.length=0,o=0,v=!1}return{feed:g,reset:R}}function Dd(t,e,r){return r===100&&t.charCodeAt(e+1)===97&&t.charCodeAt(e+2)===116&&t.charCodeAt(e+3)===97&&t.charCodeAt(e+4)===58}function Ud(t,e,r){return r===101&&t.charCodeAt(e+1)===118&&t.charCodeAt(e+2)===101&&t.charCodeAt(e+3)===110&&t.charCodeAt(e+4)===116&&t.charCodeAt(e+5)===58}class Vd 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(Fd(this),r)}[Symbol.for("Deno.customInspect")](e,r){return e(Fd(this),r)}}function dv(t){const e=globalThis.DOMException;return typeof e=="function"?new e(t,"SyntaxError"):new SyntaxError(t)}function ji(t){return t instanceof Error?"errors"in t&&Array.isArray(t.errors)?t.errors.map(ji).join(", "):"cause"in t&&t.cause instanceof Error?`${t}: ${ji(t.cause)}`:t.message:`${t}`}function Fd(t){return{type:t.type,message:t.message,code:t.code,defaultPrevented:t.defaultPrevented,cancelable:t.cancelable,timeStamp:t.timeStamp}}var Hd=t=>{throw TypeError(t)},Mi=(t,e,r)=>e.has(t)||Hd("Cannot "+r),le=(t,e,r)=>(Mi(t,e,"read from private field"),r?r.call(t):e.get(t)),je=(t,e,r)=>e.has(t)?Hd("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),Pe=(t,e,r,n)=>(Mi(t,e,"write to private field"),e.set(t,r),r),kt=(t,e,r)=>(Mi(t,e,"access private method"),r),Ge,Yt,_r,Us,Vs,Br,yr,Gr,Mt,vr,wr,br,Yr,pt,qi,Zi,xi,Wd,Li,Di,Qr,Ui,Vi;class Fs extends EventTarget{constructor(e,r){var n,s;super(),je(this,pt),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,je(this,Ge),je(this,Yt),je(this,_r),je(this,Us),je(this,Vs),je(this,Br),je(this,yr),je(this,Gr,null),je(this,Mt),je(this,vr),je(this,wr,null),je(this,br,null),je(this,Yr,null),je(this,Zi,async a=>{var i;le(this,vr).reset();const{body:o,redirected:c,status:u,headers:l}=a;if(u===204){kt(this,pt,Qr).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?Pe(this,_r,new URL(a.url)):Pe(this,_r,void 0),u!==200){kt(this,pt,Qr).call(this,`Non-200 status code (${u})`,u);return}if(!(l.get("content-type")||"").startsWith("text/event-stream")){kt(this,pt,Qr).call(this,'Invalid content type, expected "text/event-stream"',u);return}if(le(this,Ge)===this.CLOSED)return;Pe(this,Ge,this.OPEN);const f=new Event("open");if((i=le(this,Yr))==null||i.call(this,f),this.dispatchEvent(f),typeof o!="object"||!o||!("getReader"in o)){kt(this,pt,Qr).call(this,"Invalid response body, expected a web ReadableStream",u),this.close();return}const b=new TextDecoder,v=o.getReader();let g=!0;do{const{done:w,value:m}=await v.read();m&&le(this,vr).feed(b.decode(m,{stream:!w})),w&&(g=!1,le(this,vr).reset(),kt(this,pt,Ui).call(this))}while(g)}),je(this,xi,a=>{Pe(this,Mt,void 0),!(a.name==="AbortError"||a.type==="aborted")&&kt(this,pt,Ui).call(this,ji(a))}),je(this,Li,a=>{typeof a.id=="string"&&Pe(this,Gr,a.id);const i=new MessageEvent(a.event||"message",{data:a.data,origin:le(this,_r)?le(this,_r).origin:le(this,Yt).origin,lastEventId:a.id||""});le(this,br)&&(!a.event||a.event==="message")&&le(this,br).call(this,i),this.dispatchEvent(i)}),je(this,Di,a=>{Pe(this,Br,a)}),je(this,Vi,()=>{Pe(this,yr,void 0),le(this,Ge)===this.CONNECTING&&kt(this,pt,qi).call(this)});try{if(e instanceof URL)Pe(this,Yt,e);else if(typeof e=="string")Pe(this,Yt,new URL(e,fv()));else throw new Error("Invalid URL")}catch{throw dv("An invalid or illegal string was specified")}Pe(this,vr,Ld({onEvent:le(this,Li),onRetry:le(this,Di)})),Pe(this,Ge,this.CONNECTING),Pe(this,Br,3e3),Pe(this,Vs,(n=r?.fetch)!=null?n:globalThis.fetch),Pe(this,Us,(s=r?.withCredentials)!=null?s:!1),kt(this,pt,qi).call(this)}get readyState(){return le(this,Ge)}get url(){return le(this,Yt).href}get withCredentials(){return le(this,Us)}get onerror(){return le(this,wr)}set onerror(e){Pe(this,wr,e)}get onmessage(){return le(this,br)}set onmessage(e){Pe(this,br,e)}get onopen(){return le(this,Yr)}set onopen(e){Pe(this,Yr,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(){le(this,yr)&&clearTimeout(le(this,yr)),le(this,Ge)!==this.CLOSED&&(le(this,Mt)&&le(this,Mt).abort(),Pe(this,Ge,this.CLOSED),Pe(this,Mt,void 0))}}Ge=new WeakMap,Yt=new WeakMap,_r=new WeakMap,Us=new WeakMap,Vs=new WeakMap,Br=new WeakMap,yr=new WeakMap,Gr=new WeakMap,Mt=new WeakMap,vr=new WeakMap,wr=new WeakMap,br=new WeakMap,Yr=new WeakMap,pt=new WeakSet,qi=function(){Pe(this,Ge,this.CONNECTING),Pe(this,Mt,new AbortController),le(this,Vs)(le(this,Yt),kt(this,pt,Wd).call(this)).then(le(this,Zi)).catch(le(this,xi))},Zi=new WeakMap,xi=new WeakMap,Wd=function(){var t;const e={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...le(this,Gr)?{"Last-Event-ID":le(this,Gr)}:void 0},cache:"no-store",signal:(t=le(this,Mt))==null?void 0:t.signal};return"window"in globalThis&&(e.credentials=this.withCredentials?"include":"same-origin"),e},Li=new WeakMap,Di=new WeakMap,Qr=function(t,e){var r;le(this,Ge)!==this.CLOSED&&Pe(this,Ge,this.CLOSED);const n=new Vd("error",{code:e,message:t});(r=le(this,wr))==null||r.call(this,n),this.dispatchEvent(n)},Ui=function(t,e){var r;if(le(this,Ge)===this.CLOSED)return;Pe(this,Ge,this.CONNECTING);const n=new Vd("error",{code:e,message:t});(r=le(this,wr))==null||r.call(this,n),this.dispatchEvent(n),Pe(this,yr,setTimeout(le(this,Vi),le(this,Br)))},Vi=new WeakMap,Fs.CONNECTING=0,Fs.OPEN=1,Fs.CLOSED=2;function fv(){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 Xr(t){return t?t instanceof Headers?Object.fromEntries(t.entries()):Array.isArray(t)?Object.fromEntries(t):{...t}:{}}function Fi(t=fetch,e){return e?async(r,n)=>{const s={...e,...n,headers:n?.headers?{...Xr(e.headers),...Xr(n.headers)}:e.headers};return t(r,s)}:t}class Kd extends Error{constructor(e,r,n){super(`SSE error: ${r}`),this.code=e,this.event=n}}class hv{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=Fi(r?.fetch,r?.requestInit)}async _authThenStart(){if(!this._authProvider)throw new it("No auth provider");let e;try{e=await jt(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 it;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=Xr(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 Fs(this._url.href,{...this._eventSourceInit,fetch:async(s,a)=>{const i=await this._commonHeaders();i.set("Accept","text/event-stream");const o=await e(s,{...a,headers:i});if(o.status===401&&o.headers.has("www-authenticate")){const{resourceMetadataUrl:c,scope:u}=Jr(o);this._resourceMetadataUrl=c,this._scope=u}return o}}),this._abortController=new AbortController,this._eventSource.onerror=s=>{if(s.code===401&&this._authProvider){this._authThenStart().then(r,n);return}const a=new Kd(s.code,s.message,s);n(a),this.onerror?.(a)},this._eventSource.onopen=()=>{},this._eventSource.addEventListener("endpoint",s=>{const a=s;try{if(this._endpoint=new URL(a.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 a=s;let i;try{i=qr.parse(JSON.parse(a.data))}catch(o){this.onerror?.(o);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 it("No auth provider");if(await jt(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it("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 a=await s.text().catch(()=>null);if(s.status===401&&this._authProvider){const{resourceMetadataUrl:i,scope:o}=Jr(s);if(this._resourceMetadataUrl=i,this._scope=o,await jt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it;return this.send(e)}throw new Error(`Error POSTing to endpoint (HTTP ${s.status}): ${a}`)}await s.body?.cancel()}catch(r){throw this.onerror?.(r),r}}setProtocolVersion(e){this._protocolVersion=e}}class pv extends TransformStream{constructor({onError:e,onRetry:r,onComment:n,maxBufferSize:s}={}){let a;super({start(i){a=Ld({onEvent:o=>{i.enqueue(o)},onError(o){typeof e=="function"&&e(o),(e==="terminate"||o.type==="max-buffer-size-exceeded")&&i.error(o)},onRetry:r,onComment:n,maxBufferSize:s})},transform(i){a.feed(i)}})}}const mv={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Qt extends Error{constructor(e,r){super(`Streamable HTTP error: ${r}`),this.code=e}}class gv{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=Fi(r?.fetch,r?.requestInit),this._sessionId=r?.sessionId,this._reconnectionOptions=r?.reconnectionOptions??mv}async _authThenStart(){if(!this._authProvider)throw new it("No auth provider");let e;try{e=await jt(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 it;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=Xr(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 Qt(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(a=>{this.onerror?.(new Error(`Failed to reconnect SSE stream: ${a instanceof Error?a.message:String(a)}`)),this._scheduleReconnection(e,r+1)})},s)}_handleSseStream(e,r,n){if(!e)return;const{onresumptiontoken:s,replayMessageId:a}=r;let i,o=!1,c=!1;(async()=>{try{const l=e.pipeThrough(new TextDecoderStream).pipeThrough(new pv({onRetry:v=>{this._serverRetryMs=v}})).getReader();for(;;){const{value:v,done:g}=await l.read();if(g)break;if(v.id&&(i=v.id,o=!0,s?.(v.id)),!!v.data&&(!v.event||v.event==="message"))try{const w=qr.parse(JSON.parse(v.data));Vt(w)&&(c=!0,a!==void 0&&(w.id=a)),this.onmessage?.(w)}catch(w){this.onerror?.(w)}}(n||o)&&!c&&this._abortController&&!this._abortController.signal.aborted&&this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:a},0)}catch(l){if(this.onerror?.(new Error(`SSE stream disconnected: ${l}`)),(n||o)&&!c&&this._abortController&&!this._abortController.signal.aborted)try{this._scheduleReconnection({resumptionToken:i,onresumptiontoken:s,replayMessageId:a},0)}catch(v){this.onerror?.(new Error(`Failed to reconnect: ${v instanceof Error?v.message:String(v)}`))}}})()}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 it("No auth provider");if(await jt(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it("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:rs(e)?e.id:void 0}).catch(b=>this.onerror?.(b));return}const a=await this._commonHeaders();a.set("content-type","application/json"),a.set("accept","application/json, text/event-stream");const i={...this._requestInit,method:"POST",headers:a,body:JSON.stringify(e),signal:this._abortController?.signal},o=await(this._fetch??fetch)(this._url,i),c=o.headers.get("mcp-session-id");if(c&&(this._sessionId=c),!o.ok){const b=await o.text().catch(()=>null);if(o.status===401&&this._authProvider){if(this._hasCompletedAuthFlow)throw new Qt(401,"Server returned 401 after successful authentication");const{resourceMetadataUrl:v,scope:g}=Jr(o);if(this._resourceMetadataUrl=v,this._scope=g,await jt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit})!=="AUTHORIZED")throw new it;return this._hasCompletedAuthFlow=!0,this.send(e)}if(o.status===403&&this._authProvider){const{resourceMetadataUrl:v,scope:g,error:w}=Jr(o);if(w==="insufficient_scope"){const m=o.headers.get("WWW-Authenticate");if(this._lastUpscopingHeader===m)throw new Qt(403,"Server returned 403 after trying upscoping");if(g&&(this._scope=g),v&&(this._resourceMetadataUrl=v),this._lastUpscopingHeader=m??void 0,await jt(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch})!=="AUTHORIZED")throw new it;return this.send(e)}}throw new Qt(o.status,`Error POSTing to endpoint: ${b}`)}if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,o.status===202){await o.body?.cancel(),Pu(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(b=>this.onerror?.(b));return}const l=(Array.isArray(e)?e:[e]).filter(b=>"method"in b&&"id"in b&&b.id!==void 0).length>0,f=o.headers.get("content-type");if(l)if(f?.includes("text/event-stream"))this._handleSseStream(o.body,{onresumptiontoken:s},!1);else if(f?.includes("application/json")){const b=await o.json(),v=Array.isArray(b)?b.map(g=>qr.parse(g)):[qr.parse(b)];for(const g of v)this.onmessage?.(g)}else throw await o.body?.cancel(),new Qt(-1,`Unexpected content type: ${f}`);else await o.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 Qt(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})}}class _v{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 yv extends oi{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Lr.options.map((n,s)=>[n,s])),this.isMessageIgnored=(n,s)=>{const a=this._loggingLevels.get(s);return a?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(a):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new Sd,this.setRequestHandler(as,n=>this._oninitialize(n)),this.setNotificationHandler(is,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Ua,async(n,s)=>{const a=s.sessionId||s.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,o=Lr.safeParse(i);return o.success&&this._loggingLevels.set(a,o.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new _v(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=ci(this._capabilities,e)}setRequestHandler(e,r){const s=mr(e)?.method;if(!s)throw new Error("Schema is missing a method literal");let a;if(lt(s)){const o=s;a=o._zod?.def?.value??o.value}else{const o=s;a=o._def?.value??o.value}if(typeof a!="string")throw new Error("Schema method literal must be a string");if(a==="tools/call"){const o=async(c,u)=>{const l=dt(xr,c);if(!l.success){const g=l.error instanceof Error?l.error.message:String(l.error);throw new B($.ErrorCode.InvalidParams,`Invalid tools/call request: ${g}`)}const{params:f}=l.data,b=await Promise.resolve(r(c,u));if(f.task){const g=dt(Ht,b);if(!g.success){const w=g.error instanceof Error?g.error.message:String(g.error);throw new B($.ErrorCode.InvalidParams,`Invalid task creation result: ${w}`)}return g.data}const v=dt(cr,b);if(!v.success){const g=v.error instanceof Error?v.error.message:String(v.error);throw new B($.ErrorCode.InvalidParams,`Invalid tools/call result: ${g}`)}return v.data};return super.setRequestHandler(e,o)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break}}assertNotificationCapability(e){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(!this._clientCapabilities?.elicitation?.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){kd(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&$d(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){const r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:ya.includes(r)?r:Ut,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"},Ot)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){const n=e.messages[e.messages.length-1],s=Array.isArray(n.content)?n.content:[n.content],a=s.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,o=i?Array.isArray(i.content)?i.content:[i.content]:[],c=o.some(u=>u.type==="tool_use");if(a){if(s.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){const u=new Set(o.filter(f=>f.type==="tool_use").map(f=>f.id)),l=new Set(s.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(u.size!==l.size||![...u].every(f=>l.has(f)))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},Ts,r):this.request({method:"sampling/createMessage",params:e},Rs,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");const s=e;return this.request({method:"elicitation/create",params:s},Ur,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");const s=e.mode==="form"?e:{...e,mode:"form"},a=await this.request({method:"elicitation/create",params:s},Ur,r);if(a.action==="accept"&&a.content&&s.requestedSchema)try{const o=this._jsonSchemaValidator.getValidator(s.requestedSchema)(a.content);if(!o.valid)throw new B($.ErrorCode.InvalidParams,`Elicitation response content does not match requested schema: ${o.errorMessage}`)}catch(i){throw i instanceof B?i:new B($.ErrorCode.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return a}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.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},Ka,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 vv=/^[A-Za-z0-9._-]{1,128}$/;function wv(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"),!vv.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 bv(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 Jd(t){const e=wv(t);return bv(t,e.warnings),e.isValid}class Sv{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 $v{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 yv(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Sv(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(qt(Es)),this.server.assertCanSetRequestHandler(qt(xr)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Es,()=>({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=Kr(r.inputSchema);return s?pd(s,{strictUnions:!0,pipeStrategy:"input"}):Ev})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){const s=Kr(r.outputSchema);s&&(n.outputSchema=pd(s,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(xr,async(e,r)=>{try{const n=this._registeredTools[e.params.name];if(!n)throw new B($.ErrorCode.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new B($.ErrorCode.InvalidParams,`Tool ${e.params.name} disabled`);const s=!!e.params.task,a=n.execution?.taskSupport,i="createTask"in n.handler;if((a==="required"||a==="optional")&&!i)throw new B($.ErrorCode.InternalError,`Tool ${e.params.name} has taskSupport '${a}' but was not registered with registerToolTask`);if(a==="required"&&!s)throw new B($.ErrorCode.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(a==="optional"&&!s&&i)return await this.handleAutomaticTaskPolling(n,e,r);const o=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,o,r);return s||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof B&&n.code===$.ErrorCode.UrlElicitationRequired)throw n;return this.createToolError(n instanceof Error?n.message:String(n))}}),this._toolHandlersInitialized=!0)}createToolError(e){return{content:[{type:"text",text:e}],isError:!0}}async validateToolInput(e,r,n){if(!e.inputSchema)return;const a=Kr(e.inputSchema)??e.inputSchema,i=await ni(a,r);if(!i.success){const o="error"in i?i.error:"Unknown error",c=si(o);throw new B($.ErrorCode.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 B($.ErrorCode.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);const s=Kr(e.outputSchema),a=await ni(s,r.structuredContent);if(!a.success){const i="error"in a?a.error:"Unknown error",o=si(i);throw new B($.ErrorCode.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){if(!n.taskStore)throw new Error("No task store provided for task-capable tool.");const s=await this.validateToolInput(e,r.params.arguments,r.params.name),a=e.handler,i={...n,taskStore:n.taskStore},o=s?await Promise.resolve(a.createTask(s,i)):await Promise.resolve(a.createTask(i)),c=o.task.taskId;let u=o.task;const l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(b=>setTimeout(b,l));const f=await n.taskStore.getTask(c);if(!f)throw new B($.ErrorCode.InternalError,`Task ${c} not found during polling`);u=f}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(qt(Ps)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Ps,async e=>{switch(e.params.ref.type){case"ref/prompt":return Cl(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Il(e),this.handleResourceCompletion(e,e.params.ref);default:throw new B($.ErrorCode.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){const n=this._registeredPrompts[r.name];if(!n)throw new B($.ErrorCode.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new B($.ErrorCode.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return en;const a=mr(n.argsSchema)?.[e.params.argument.name];if(!Ba(a))return en;const i=ql(a);if(!i)return en;const o=await i(e.params.argument.value,e.params.context);return Yd(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 en;throw new B($.ErrorCode.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}const s=n.resourceTemplate.completeCallback(e.params.argument.name);if(!s)return en;const a=await s(e.params.argument.value,e.params.context);return Yd(a)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(qt(ms)),this.server.assertCanSetRequestHandler(qt(gs)),this.server.assertCanSetRequestHandler(qt(ys)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(ms,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(gs,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(ys,async(e,r)=>{const n=new URL(e.params.uri),s=this._registeredResources[n.toString()];if(s){if(!s.enabled)throw new B($.ErrorCode.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 B($.ErrorCode.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(qt(vs)),this.server.assertCanSetRequestHandler(qt(ws)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(vs,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?Tv(r.argsSchema):void 0}))})),this.server.setRequestHandler(ws,async(e,r)=>{const n=this._registeredPrompts[e.params.name];if(!n)throw new B($.ErrorCode.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new B($.ErrorCode.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){const s=Kr(n.argsSchema),a=await ni(s,e.params.arguments);if(!a.success){const c="error"in a?a.error:"Unknown error",u=si(c);throw new B($.ErrorCode.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}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._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:u=>{typeof u.name<"u"&&u.name!==e&&(delete this._registeredResourceTemplates[e],u.name&&(this._registeredResourceTemplates[u.name]=i)),typeof u.title<"u"&&(i.title=u.title),typeof u.template<"u"&&(i.resourceTemplate=u.template),typeof u.metadata<"u"&&(i.metadata=u.metadata),typeof u.callback<"u"&&(i.readCallback=u.callback),typeof u.enabled<"u"&&(i.enabled=u.enabled),this.sendResourceListChanged()}};this._registeredResourceTemplates[e]=i;const o=n.uriTemplate.variableNames;return Array.isArray(o)&&o.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,s,a){const i={title:r,description:n,argsSchema:s===void 0?void 0:pr(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=pr(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,s&&Object.values(s).some(c=>{const u=c instanceof $t?c._def?.innerType:c;return Ba(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,s,a,i,o,c,u){Jd(e);const l={title:r,description:n,inputSchema:Gd(s),outputSchema:Gd(a),annotations:i,execution:o,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:f=>{typeof f.name<"u"&&f.name!==e&&(typeof f.name=="string"&&Jd(f.name),delete this._registeredTools[e],f.name&&(this._registeredTools[f.name]=l)),typeof f.title<"u"&&(l.title=f.title),typeof f.description<"u"&&(l.description=f.description),typeof f.paramsSchema<"u"&&(l.inputSchema=pr(f.paramsSchema)),typeof f.outputSchema<"u"&&(l.outputSchema=pr(f.outputSchema)),typeof f.callback<"u"&&(l.handler=f.callback),typeof f.annotations<"u"&&(l.annotations=f.annotations),typeof f._meta<"u"&&(l._meta=f._meta),typeof f.enabled<"u"&&(l.enabled=f.enabled),this.sendToolListChanged()}};return this._registeredTools[e]=l,this.setToolRequestHandlers(),this.sendToolListChanged(),l}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];Hi(c)?(s=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!Hi(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:u}=r;return this._createRegisteredTool(e,s,a,i,o,c,{taskSupport:"forbidden"},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 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 kv{constructor(e,r){this._callbacks=r,this._uriTemplate=typeof e=="string"?new bt(e):e}get uriTemplate(){return this._uriTemplate}get listCallback(){return this._callbacks.list}completeCallback(e){return this._callbacks.complete?.[e]}}const Ev={type:"object",properties:{}};function Bd(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Rv(t){return"_def"in t||"_zod"in t||Bd(t)}function Hi(t){return typeof t!="object"||t===null||Rv(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(Bd)}function Gd(t){if(t)return Hi(t)?pr(t):t}function Tv(t){const e=mr(t);return e?Object.entries(e).map(([r,n])=>{const s=V_(n),a=F_(n);return{name:r,description:s,required:!a}}):[]}function qt(t){const r=mr(t)?.method;if(!r)throw new Error("Schema is missing a method literal");const n=sd(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function Yd(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}const en={completion:{values:[],hasMore:!1}};$.Ajv=_c,$.AnnotationsSchema=Wt,$.AudioContentSchema=$s,$.BaseMetadataSchema=Ft,$.BlobResourceContentsSchema=Ia,$.BooleanSchemaSchema=ll,$.COMPLETABLE_SYMBOL=Cs,$.CallToolRequestParamsSchema=Qu,$.CallToolRequestSchema=xr,$.CallToolResultSchema=cr,$.CancelTaskRequestSchema=ps,$.CancelTaskResultSchema=zu,$.CancelledNotificationParamsSchema=bu,$.CancelledNotificationSchema=ss,$.Client=qy,$.ClientCapabilitiesSchema=Eu,$.ClientNotificationSchema=a_,$.ClientRequestSchema=s_,$.ClientResultSchema=i_,$.ClientTasksCapabilitySchema=$u,$.CompatibilityCallToolResultSchema=r_,$.CompleteRequestParamsSchema=Pl,$.CompleteRequestSchema=Ps,$.CompleteResultSchema=Wa,$.ContentBlockSchema=ks,$.CreateMessageRequestParamsSchema=ul,$.CreateMessageRequestSchema=Va,$.CreateMessageResultSchema=Rs,$.CreateMessageResultWithToolsSchema=Ts,$.CreateTaskResultSchema=Ht,$.CursorSchema=wa,$.DEFAULT_NEGOTIATED_PROTOCOL_VERSION=Wg,$.DEFAULT_REQUEST_TIMEOUT_MSEC=_d,$.ElicitRequestFormParamsSchema=Sl,$.ElicitRequestParamsSchema=kl,$.ElicitRequestSchema=Fa,$.ElicitRequestURLParamsSchema=$l,$.ElicitResultSchema=Ur,$.ElicitationCompleteNotificationParamsSchema=El,$.ElicitationCompleteNotificationSchema=Rl,$.EmbeddedResourceSchema=Ku,$.EmptyResultSchema=Ot,$.EnumSchemaSchema=wl,$.GetPromptRequestParamsSchema=Hu,$.GetPromptRequestSchema=ws,$.GetPromptResultSchema=qa,$.GetTaskPayloadRequestSchema=ds,$.GetTaskPayloadResultSchema=t_,$.GetTaskRequestSchema=us,$.GetTaskResultSchema=ls,$.IconSchema=Su,$.IconsSchema=nr,$.ImageContentSchema=Ss,$.ImplementationSchema=Ea,$.InitializeRequestParamsSchema=Ru,$.InitializeRequestSchema=as,$.InitializeResultSchema=Ra,$.InitializedNotificationSchema=is,$.JSONRPCErrorResponseSchema=Mr,$.JSONRPCErrorSchema=Bg,$.JSONRPCMessageSchema=qr,$.JSONRPCNotificationSchema=$a,$.JSONRPCRequestSchema=Sa,$.JSONRPCResponseSchema=Yg,$.JSONRPCResultResponseSchema=ns,$.JSONRPC_VERSION=zr,$.LATEST_PROTOCOL_VERSION=Ut,$.LegacyTitledEnumSchemaSchema=ml,$.ListChangedOptionsBaseSchema=Xu,$.ListPromptsRequestSchema=vs,$.ListPromptsResultSchema=Ma,$.ListResourceTemplatesRequestSchema=gs,$.ListResourceTemplatesResultSchema=Aa,$.ListResourcesRequestSchema=ms,$.ListResourcesResultSchema=Na,$.ListRootsRequestSchema=Nl,$.ListRootsResultSchema=Ka,$.ListTasksRequestSchema=fs,$.ListTasksResultSchema=hs,$.ListToolsRequestSchema=Es,$.ListToolsResultSchema=La,$.LoggingLevelSchema=Lr,$.LoggingMessageNotificationParamsSchema=tl,$.LoggingMessageNotificationSchema=rl,$.McpError=B,$.McpServer=$v,$.ModelHintSchema=nl,$.ModelPreferencesSchema=sl,$.MultiSelectEnumSchemaSchema=vl,$.NotificationSchema=rt,$.NumberSchemaSchema=fl,$.PaginatedRequestParamsSchema=Ou,$.PaginatedRequestSchema=sr,$.PaginatedResultSchema=ar,$.PingRequestSchema=os,$.PrimitiveSchemaDefinitionSchema=bl,$.ProgressNotificationParamsSchema=Iu,$.ProgressNotificationSchema=cs,$.ProgressSchema=Cu,$.ProgressTokenSchema=va,$.PromptArgumentSchema=Vu,$.PromptListChangedNotificationSchema=Za,$.PromptMessageSchema=Bu,$.PromptReferenceSchema=Tl,$.PromptSchema=Fu,$.Protocol=oi,$.RELATED_TASK_META_KEY=It,$.ReadResourceRequestParamsSchema=Mu,$.ReadResourceRequestSchema=ys,$.ReadResourceResultSchema=za,$.RelatedTaskMetadataSchema=yu,$.RequestIdSchema=jr,$.RequestSchema=Me,$.ResourceContentsSchema=Ta,$.ResourceLinkSchema=Ju,$.ResourceListChangedNotificationSchema=ja,$.ResourceReferenceSchema=n_,$.ResourceRequestParamsSchema=_s,$.ResourceSchema=Oa,$.ResourceTemplate=kv,$.ResourceTemplateReferenceSchema=Ha,$.ResourceTemplateSchema=ju,$.ResourceUpdatedNotificationParamsSchema=Du,$.ResourceUpdatedNotificationSchema=Uu,$.ResultSchema=qe,$.RoleSchema=or,$.RootSchema=Ol,$.RootsListChangedNotificationSchema=Al,$.SSEClientTransport=hv,$.SUPPORTED_PROTOCOL_VERSIONS=ya,$.SamplingContentSchema=ol,$.SamplingMessageContentBlockSchema=Dr,$.SamplingMessageSchema=cl,$.ServerCapabilitiesSchema=Tu,$.ServerNotificationSchema=c_,$.ServerRequestSchema=o_,$.ServerResultSchema=u_,$.ServerTasksCapabilitySchema=ku,$.SetLevelRequestParamsSchema=el,$.SetLevelRequestSchema=Ua,$.SingleSelectEnumSchemaSchema=gl,$.SseError=Kd,$.StreamableHTTPClientTransport=gv,$.StreamableHTTPError=Qt,$.StringSchemaSchema=dl,$.SubscribeRequestParamsSchema=qu,$.SubscribeRequestSchema=Zu,$.TaskAugmentedRequestParamsSchema=rr,$.TaskCreationParamsSchema=Kg,$.TaskMetadataSchema=_u,$.TaskSchema=ir,$.TaskStatusNotificationParamsSchema=Au,$.TaskStatusNotificationSchema=Zr,$.TaskStatusSchema=Nu,$.TextContentSchema=bs,$.TextResourceContentsSchema=Pa,$.TitledMultiSelectEnumSchemaSchema=yl,$.TitledSingleSelectEnumSchemaSchema=pl,$.ToolAnnotationsSchema=Gu,$.ToolChoiceSchema=al,$.ToolExecutionSchema=Yu,$.ToolListChangedNotificationSchema=Da,$.ToolResultContentSchema=il,$.ToolSchema=xa,$.ToolUseContentSchema=Wu,$.UnauthorizedError=it,$.UnsubscribeRequestParamsSchema=xu,$.UnsubscribeRequestSchema=Lu,$.UntitledMultiSelectEnumSchemaSchema=_l,$.UntitledSingleSelectEnumSchemaSchema=hl,$.UriTemplate=bt,$.UrlElicitationRequiredError=zl,$.assertCompleteRequestPrompt=Cl,$.assertCompleteRequestResourceTemplate=Il,$.auth=jt,$.buildDiscoveryUrls=Ad,$.completable=d_,$.createFetchWithInit=Fi,$.discoverAuthorizationServerMetadata=zd,$.discoverOAuthMetadata=cv,$.discoverOAuthProtectedResourceMetadata=Id,$.exchangeAuthorization=uv,$.extractResourceMetadataUrl=av,$.extractWWWAuthenticateParams=Jr,$.fetchToken=qd,$.getCompleter=ql,$.getDisplayName=h_,$.getSupportedElicitationModes=Ed,$.isCompletable=Ba,$.isHttpsUrl=Pd,$.isInitializeRequest=e_,$.isInitializedNotification=Pu,$.isJSONRPCError=Gg,$.isJSONRPCErrorResponse=ka,$.isJSONRPCNotification=wu,$.isJSONRPCRequest=rs,$.isJSONRPCResponse=Jg,$.isJSONRPCResultResponse=Vt,$.isTaskAugmentedRequestParams=vu,$.mergeCapabilities=ci,$.normalizeHeaders=Xr,$.parseErrorResponse=Ti,$.prepareAuthorizationCodeRequest=Oi,$.refreshAuthorization=Md,$.registerClient=Zd,$.selectClientAuthMethod=Td,$.selectResourceURL=Cd,$.startAuthorization=jd,$.unwrapCompletable=f_,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})}));