@neurynae/toolcairn-mcp 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { createRequire as __nodeCreateRequire } from 'module'; const require = __nodeCreateRequire(import.meta.url);
|
|
2
|
-
import{A as np,B as op,C as sp,D as ip,E as ap,F as cp,G as up,H as lp,I as dp,K as pp,L as fp,M as mp,N as hp,O as gp,P as _p,a as P,b as Ld,c as Me,d,e as Ud,f as U,g as Vd,h as Ur,i as or,j as Uo,k as Fd,l as Cn,m as Tt,n as Hd,o as Bd,p as Vo,q as Jd,r as Kd,s as Gd,t as Wd,u as Yd,v as Xd,w as Qd,x as ep,y as tp,z as rp}from"./chunk-RCMWAY37.js";var io=P(te=>{"use strict";d();Object.defineProperty(te,"__esModule",{value:!0});te.regexpCode=te.getEsmExportName=te.getProperty=te.safeStringify=te.stringify=te.strConcat=te.addCodeArg=te.str=te._=te.nil=te._Code=te.Name=te.IDENTIFIER=te._CodeOrName=void 0;var oo=class{};te._CodeOrName=oo;te.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var pr=class extends oo{constructor(e){if(super(),!te.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};te.Name=pr;var et=class extends oo{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof pr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};te._Code=et;te.nil=new et("");function th(t,...e){let r=[t[0]],n=0;for(;n<e.length;)bu(r,e[n]),r.push(t[++n]);return new et(r)}te._=th;var vu=new et("+");function rh(t,...e){let r=[so(t[0])],n=0;for(;n<e.length;)r.push(vu),bu(r,e[n]),r.push(vu,so(t[++n]));return M0(r),new et(r)}te.str=rh;function bu(t,e){e instanceof et?t.push(...e._items):e instanceof pr?t.push(e):t.push(L0(e))}te.addCodeArg=bu;function M0(t){let e=1;for(;e<t.length-1;){if(t[e]===vu){let r=D0(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function D0(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof pr||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof pr))return`"${t}${e.slice(1)}`}function q0(t,e){return e.emptyStr()?t:t.emptyStr()?e:rh`${t}${e}`}te.strConcat=q0;function L0(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:so(Array.isArray(t)?t.join(","):t)}function U0(t){return new et(so(t))}te.stringify=U0;function so(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}te.safeStringify=so;function V0(t){return typeof t=="string"&&te.IDENTIFIER.test(t)?new et(`.${t}`):th`[${t}]`}te.getProperty=V0;function F0(t){if(typeof t=="string"&&te.IDENTIFIER.test(t))return new et(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}te.getEsmExportName=F0;function H0(t){return new et(t.toString())}te.regexpCode=H0});var $u=P(Le=>{"use strict";d();Object.defineProperty(Le,"__esModule",{value:!0});Le.ValueScope=Le.ValueScopeName=Le.Scope=Le.varKinds=Le.UsedValueState=void 0;var qe=io(),wu=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},qs;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(qs||(Le.UsedValueState=qs={}));Le.varKinds={const:new qe.Name("const"),let:new qe.Name("let"),var:new qe.Name("var")};var Ls=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof qe.Name?e:this.name(e)}name(e){return new qe.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Le.Scope=Ls;var Us=class extends qe.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,qe._)`.${new qe.Name(r)}[${n}]`}};Le.ValueScopeName=Us;var B0=(0,qe._)`\n`,xu=class extends Ls{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?B0:qe.nil}}get(){return this._scope}name(e){return new Us(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,qe._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=qe.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,qs.Started);let l=r(u);if(l){let p=this.opts.es5?Le.varKinds.var:Le.varKinds.const;s=(0,qe._)`${s}${p} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,qe._)`${s}${l}${this.opts._n}`;else throw new wu(u);c.set(u,qs.Completed)})}return s}};Le.ValueScope=xu});var B=P(J=>{"use strict";d();Object.defineProperty(J,"__esModule",{value:!0});J.or=J.and=J.not=J.CodeGen=J.operators=J.varKinds=J.ValueScopeName=J.ValueScope=J.Scope=J.Name=J.regexpCode=J.stringify=J.getProperty=J.nil=J.strConcat=J.str=J._=void 0;var X=io(),lt=$u(),Ft=io();Object.defineProperty(J,"_",{enumerable:!0,get:function(){return Ft._}});Object.defineProperty(J,"str",{enumerable:!0,get:function(){return Ft.str}});Object.defineProperty(J,"strConcat",{enumerable:!0,get:function(){return Ft.strConcat}});Object.defineProperty(J,"nil",{enumerable:!0,get:function(){return Ft.nil}});Object.defineProperty(J,"getProperty",{enumerable:!0,get:function(){return Ft.getProperty}});Object.defineProperty(J,"stringify",{enumerable:!0,get:function(){return Ft.stringify}});Object.defineProperty(J,"regexpCode",{enumerable:!0,get:function(){return Ft.regexpCode}});Object.defineProperty(J,"Name",{enumerable:!0,get:function(){return Ft.Name}});var Bs=$u();Object.defineProperty(J,"Scope",{enumerable:!0,get:function(){return Bs.Scope}});Object.defineProperty(J,"ValueScope",{enumerable:!0,get:function(){return Bs.ValueScope}});Object.defineProperty(J,"ValueScopeName",{enumerable:!0,get:function(){return Bs.ValueScopeName}});Object.defineProperty(J,"varKinds",{enumerable:!0,get:function(){return Bs.varKinds}});J.operators={GT:new X._Code(">"),GTE:new X._Code(">="),LT:new X._Code("<"),LTE:new X._Code("<="),EQ:new X._Code("==="),NEQ:new X._Code("!=="),NOT:new X._Code("!"),OR:new X._Code("||"),AND:new X._Code("&&"),ADD:new X._Code("+")};var It=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},ku=class extends It{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?lt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=tn(this.rhs,e,r)),this}get names(){return this.rhs instanceof X._CodeOrName?this.rhs.names:{}}},Vs=class extends It{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof X.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=tn(this.rhs,e,r),this}get names(){let e=this.lhs instanceof X.Name?{}:{...this.lhs.names};return Hs(e,this.rhs)}},Su=class extends Vs{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Tu=class extends It{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},zu=class extends It{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Pu=class extends It{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Iu=class extends It{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=tn(this.code,e,r),this}get names(){return this.code instanceof X._CodeOrName?this.code.names:{}}},ao=class extends It{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(J0(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>hr(e,r.names),{})}},Et=class extends ao{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Eu=class extends ao{},en=class extends Et{};en.kind="else";var fr=class t extends Et{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new en(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(nh(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=tn(this.condition,e,r),this}get names(){let e=super.names;return Hs(e,this.condition),this.else&&hr(e,this.else.names),e}};fr.kind="if";var mr=class extends Et{};mr.kind="for";var Ru=class extends mr{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=tn(this.iteration,e,r),this}get names(){return hr(super.names,this.iteration.names)}},Cu=class extends mr{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?lt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Hs(super.names,this.from);return Hs(e,this.to)}},Fs=class extends mr{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=tn(this.iterable,e,r),this}get names(){return hr(super.names,this.iterable.names)}},co=class extends Et{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};co.kind="func";var uo=class extends ao{render(e){return"return "+super.render(e)}};uo.kind="return";var Zu=class extends Et{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&hr(e,this.catch.names),this.finally&&hr(e,this.finally.names),e}},lo=class extends Et{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};lo.kind="catch";var po=class extends Et{render(e){return"finally"+super.render(e)}};po.kind="finally";var Ou=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
-
`:""},this._extScope=e,this._scope=new lt.Scope({parent:e}),this._nodes=[new Eu]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new ku(e,s,n)),s}const(e,r,n){return this._def(lt.varKinds.const,e,r,n)}let(e,r,n){return this._def(lt.varKinds.let,e,r,n)}var(e,r,n){return this._def(lt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Vs(e,r,n))}add(e,r){return this._leafNode(new Su(e,J.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==X.nil&&this._leafNode(new Iu(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,X.addCodeArg)(r,o));return r.push("}"),new X._Code(r)}if(e,r,n){if(this._blockNode(new fr(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new fr(e))}else(){return this._elseNode(new en)}endIf(){return this._endBlockNode(fr,en)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Ru(e),r)}forRange(e,r,n,o,s=this.opts.es5?lt.varKinds.var:lt.varKinds.let){let i=this._scope.toName(e);return this._for(new Cu(s,i,r,n),()=>o(i))}forOf(e,r,n,o=lt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof X.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,X._)`${i}.length`,a=>{this.var(s,(0,X._)`${i}[${a}]`),n(s)})}return this._for(new Fs("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?lt.varKinds.var:lt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,X._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Fs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(mr)}label(e){return this._leafNode(new Tu(e))}break(e){return this._leafNode(new zu(e))}return(e){let r=new uo;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(uo)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Zu;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new lo(s),r(s)}return n&&(this._currNode=o.finally=new po,this.code(n)),this._endBlockNode(lo,po)}throw(e){return this._leafNode(new Pu(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=X.nil,n,o){return this._blockNode(new co(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(co)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof fr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};J.CodeGen=Ou;function hr(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Hs(t,e){return e instanceof X._CodeOrName?hr(t,e.names):t}function tn(t,e,r){if(t instanceof X.Name)return n(t);if(!o(t))return t;return new X._Code(t._items.reduce((s,i)=>(i instanceof X.Name&&(i=n(i)),i instanceof X._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof X._Code&&s._items.some(i=>i instanceof X.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function J0(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function nh(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,X._)`!${ju(t)}`}J.not=nh;var K0=oh(J.operators.AND);function G0(...t){return t.reduce(K0)}J.and=G0;var W0=oh(J.operators.OR);function Y0(...t){return t.reduce(W0)}J.or=Y0;function oh(t){return(e,r)=>e===X.nil?r:r===X.nil?e:(0,X._)`${ju(e)} ${t} ${ju(r)}`}function ju(t){return t instanceof X.Name?t:(0,X._)`(${t})`}});var Q=P(K=>{"use strict";d();Object.defineProperty(K,"__esModule",{value:!0});K.checkStrictMode=K.getErrorPath=K.Type=K.useFunc=K.setEvaluated=K.evaluatedPropsToName=K.mergeEvaluated=K.eachItem=K.unescapeJsonPointer=K.escapeJsonPointer=K.escapeFragment=K.unescapeFragment=K.schemaRefOrVal=K.schemaHasRulesButRef=K.schemaHasRules=K.checkUnknownRules=K.alwaysValidSchema=K.toHash=void 0;var ie=B(),X0=io();function Q0(t){let e={};for(let r of t)e[r]=!0;return e}K.toHash=Q0;function ex(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(ah(t,e),!ch(e,t.self.RULES.all))}K.alwaysValidSchema=ex;function ah(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||dh(t,`unknown keyword: "${s}"`)}K.checkUnknownRules=ah;function ch(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}K.schemaHasRules=ch;function tx(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}K.schemaHasRulesButRef=tx;function rx({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ie._)`${r}`}return(0,ie._)`${t}${e}${(0,ie.getProperty)(n)}`}K.schemaRefOrVal=rx;function nx(t){return uh(decodeURIComponent(t))}K.unescapeFragment=nx;function ox(t){return encodeURIComponent(Nu(t))}K.escapeFragment=ox;function Nu(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}K.escapeJsonPointer=Nu;function uh(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}K.unescapeJsonPointer=uh;function sx(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}K.eachItem=sx;function sh({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof ie.Name?(s instanceof ie.Name?t(o,s,i):e(o,s,i),i):s instanceof ie.Name?(e(o,i,s),s):r(s,i);return a===ie.Name&&!(c instanceof ie.Name)?n(o,c):c}}K.mergeEvaluated={props:sh({mergeNames:(t,e,r)=>t.if((0,ie._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ie._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ie._)`${r} || {}`).code((0,ie._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ie._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ie._)`${r} || {}`),Mu(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:lh}),items:sh({mergeNames:(t,e,r)=>t.if((0,ie._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ie._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ie._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ie._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function lh(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ie._)`{}`);return e!==void 0&&Mu(t,r,e),r}K.evaluatedPropsToName=lh;function Mu(t,e,r){Object.keys(r).forEach(n=>t.assign((0,ie._)`${e}${(0,ie.getProperty)(n)}`,!0))}K.setEvaluated=Mu;var ih={};function ix(t,e){return t.scopeValue("func",{ref:e,code:ih[e.code]||(ih[e.code]=new X0._Code(e.code))})}K.useFunc=ix;var Au;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Au||(K.Type=Au={}));function ax(t,e,r){if(t instanceof ie.Name){let n=e===Au.Num;return r?n?(0,ie._)`"[" + ${t} + "]"`:(0,ie._)`"['" + ${t} + "']"`:n?(0,ie._)`"/" + ${t}`:(0,ie._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ie.getProperty)(t).toString():"/"+Nu(t)}K.getErrorPath=ax;function dh(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}K.checkStrictMode=dh});var Rt=P(Du=>{"use strict";d();Object.defineProperty(Du,"__esModule",{value:!0});var Pe=B(),cx={data:new Pe.Name("data"),valCxt:new Pe.Name("valCxt"),instancePath:new Pe.Name("instancePath"),parentData:new Pe.Name("parentData"),parentDataProperty:new Pe.Name("parentDataProperty"),rootData:new Pe.Name("rootData"),dynamicAnchors:new Pe.Name("dynamicAnchors"),vErrors:new Pe.Name("vErrors"),errors:new Pe.Name("errors"),this:new Pe.Name("this"),self:new Pe.Name("self"),scope:new Pe.Name("scope"),json:new Pe.Name("json"),jsonPos:new Pe.Name("jsonPos"),jsonLen:new Pe.Name("jsonLen"),jsonPart:new Pe.Name("jsonPart")};Du.default=cx});var fo=P(Ie=>{"use strict";d();Object.defineProperty(Ie,"__esModule",{value:!0});Ie.extendErrors=Ie.resetErrorsCount=Ie.reportExtraError=Ie.reportError=Ie.keyword$DataError=Ie.keywordError=void 0;var ee=B(),Js=Q(),je=Rt();Ie.keywordError={message:({keyword:t})=>(0,ee.str)`must pass "${t}" keyword validation`};Ie.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,ee.str)`"${t}" keyword must be ${e} ($data)`:(0,ee.str)`"${t}" keyword is invalid ($data)`};function ux(t,e=Ie.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=mh(t,e,r);n??(i||a)?ph(s,c):fh(o,(0,ee._)`[${c}]`)}Ie.reportError=ux;function lx(t,e=Ie.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=mh(t,e,r);ph(o,a),s||i||fh(n,je.default.vErrors)}Ie.reportExtraError=lx;function dx(t,e){t.assign(je.default.errors,e),t.if((0,ee._)`${je.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,ee._)`${je.default.vErrors}.length`,e),()=>t.assign(je.default.vErrors,null)))}Ie.resetErrorsCount=dx;function px({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,je.default.errors,a=>{t.const(i,(0,ee._)`${je.default.vErrors}[${a}]`),t.if((0,ee._)`${i}.instancePath === undefined`,()=>t.assign((0,ee._)`${i}.instancePath`,(0,ee.strConcat)(je.default.instancePath,s.errorPath))),t.assign((0,ee._)`${i}.schemaPath`,(0,ee.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,ee._)`${i}.schema`,r),t.assign((0,ee._)`${i}.data`,n))})}Ie.extendErrors=px;function ph(t,e){let r=t.const("err",e);t.if((0,ee._)`${je.default.vErrors} === null`,()=>t.assign(je.default.vErrors,(0,ee._)`[${r}]`),(0,ee._)`${je.default.vErrors}.push(${r})`),t.code((0,ee._)`${je.default.errors}++`)}function fh(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,ee._)`new ${t.ValidationError}(${e})`):(r.assign((0,ee._)`${n}.errors`,e),r.return(!1))}var gr={keyword:new ee.Name("keyword"),schemaPath:new ee.Name("schemaPath"),params:new ee.Name("params"),propertyName:new ee.Name("propertyName"),message:new ee.Name("message"),schema:new ee.Name("schema"),parentSchema:new ee.Name("parentSchema")};function mh(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,ee._)`{}`:fx(t,e,r)}function fx(t,e,r={}){let{gen:n,it:o}=t,s=[mx(o,r),hx(t,r)];return gx(t,e,s),n.object(...s)}function mx({errorPath:t},{instancePath:e}){let r=e?(0,ee.str)`${t}${(0,Js.getErrorPath)(e,Js.Type.Str)}`:t;return[je.default.instancePath,(0,ee.strConcat)(je.default.instancePath,r)]}function hx({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,ee.str)`${e}/${t}`;return r&&(o=(0,ee.str)`${o}${(0,Js.getErrorPath)(r,Js.Type.Str)}`),[gr.schemaPath,o]}function gx(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:p}=a;n.push([gr.keyword,o],[gr.params,typeof e=="function"?e(t):e||(0,ee._)`{}`]),c.messages&&n.push([gr.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([gr.schema,i],[gr.parentSchema,(0,ee._)`${l}${p}`],[je.default.data,s]),u&&n.push([gr.propertyName,u])}});var gh=P(rn=>{"use strict";d();Object.defineProperty(rn,"__esModule",{value:!0});rn.boolOrEmptySchema=rn.topBoolOrEmptySchema=void 0;var _x=fo(),yx=B(),vx=Rt(),bx={message:"boolean schema is false"};function wx(t){let{gen:e,schema:r,validateName:n}=t;r===!1?hh(t,!1):typeof r=="object"&&r.$async===!0?e.return(vx.default.data):(e.assign((0,yx._)`${n}.errors`,null),e.return(!0))}rn.topBoolOrEmptySchema=wx;function xx(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),hh(t)):r.var(e,!0)}rn.boolOrEmptySchema=xx;function hh(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,_x.reportError)(o,bx,void 0,e)}});var qu=P(nn=>{"use strict";d();Object.defineProperty(nn,"__esModule",{value:!0});nn.getRules=nn.isJSONType=void 0;var $x=["string","number","integer","boolean","null","object","array"],kx=new Set($x);function Sx(t){return typeof t=="string"&&kx.has(t)}nn.isJSONType=Sx;function Tx(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}nn.getRules=Tx});var Lu=P(Ht=>{"use strict";d();Object.defineProperty(Ht,"__esModule",{value:!0});Ht.shouldUseRule=Ht.shouldUseGroup=Ht.schemaHasRulesForType=void 0;function zx({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&_h(t,n)}Ht.schemaHasRulesForType=zx;function _h(t,e){return e.rules.some(r=>yh(t,r))}Ht.shouldUseGroup=_h;function yh(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Ht.shouldUseRule=yh});var mo=P(Ee=>{"use strict";d();Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var Px=qu(),Ix=Lu(),Ex=fo(),H=B(),vh=Q(),on;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(on||(Ee.DataType=on={}));function Rx(t){let e=bh(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ee.getSchemaTypes=Rx;function bh(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(Px.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ee.getJSONTypes=bh;function Cx(t,e){let{gen:r,data:n,opts:o}=t,s=Zx(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,Ix.schemaHasRulesForType)(t,e[0]));if(i){let a=Vu(e,n,o.strictNumbers,on.Wrong);r.if(a,()=>{s.length?Ox(t,e,s):Fu(t)})}return i}Ee.coerceAndCheckDataType=Cx;var wh=new Set(["string","number","integer","boolean","null"]);function Zx(t,e){return e?t.filter(r=>wh.has(r)||e==="array"&&r==="array"):[]}function Ox(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,H._)`typeof ${o}`),a=n.let("coerced",(0,H._)`undefined`);s.coerceTypes==="array"&&n.if((0,H._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,H._)`${o}[0]`).assign(i,(0,H._)`typeof ${o}`).if(Vu(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,H._)`${a} !== undefined`);for(let u of r)(wh.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Fu(t),n.endIf(),n.if((0,H._)`${a} !== undefined`,()=>{n.assign(o,a),jx(t,a)});function c(u){switch(u){case"string":n.elseIf((0,H._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,H._)`"" + ${o}`).elseIf((0,H._)`${o} === null`).assign(a,(0,H._)`""`);return;case"number":n.elseIf((0,H._)`${i} == "boolean" || ${o} === null
|
|
2
|
+
import{A as np,B as op,C as sp,D as ip,E as ap,F as cp,G as up,H as lp,I as dp,J as pp,L as fp,M as mp,N as hp,O as gp,P as _p,Q as yp,a as P,b as Ld,c as Me,d,e as Ud,f as U,g as Vd,h as Ur,i as or,j as Uo,k as Fd,l as Cn,m as Tt,n as Hd,o as Bd,p as Vo,q as Jd,r as Kd,s as Gd,t as Wd,u as Yd,v as Xd,w as Qd,x as ep,y as tp,z as rp}from"./chunk-U7RBABZP.js";var io=P(te=>{"use strict";d();Object.defineProperty(te,"__esModule",{value:!0});te.regexpCode=te.getEsmExportName=te.getProperty=te.safeStringify=te.stringify=te.strConcat=te.addCodeArg=te.str=te._=te.nil=te._Code=te.Name=te.IDENTIFIER=te._CodeOrName=void 0;var oo=class{};te._CodeOrName=oo;te.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var pr=class extends oo{constructor(e){if(super(),!te.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};te.Name=pr;var et=class extends oo{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof pr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};te._Code=et;te.nil=new et("");function rh(t,...e){let r=[t[0]],n=0;for(;n<e.length;)bu(r,e[n]),r.push(t[++n]);return new et(r)}te._=rh;var vu=new et("+");function nh(t,...e){let r=[so(t[0])],n=0;for(;n<e.length;)r.push(vu),bu(r,e[n]),r.push(vu,so(t[++n]));return D0(r),new et(r)}te.str=nh;function bu(t,e){e instanceof et?t.push(...e._items):e instanceof pr?t.push(e):t.push(U0(e))}te.addCodeArg=bu;function D0(t){let e=1;for(;e<t.length-1;){if(t[e]===vu){let r=q0(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function q0(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof pr||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof pr))return`"${t}${e.slice(1)}`}function L0(t,e){return e.emptyStr()?t:t.emptyStr()?e:nh`${t}${e}`}te.strConcat=L0;function U0(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:so(Array.isArray(t)?t.join(","):t)}function V0(t){return new et(so(t))}te.stringify=V0;function so(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}te.safeStringify=so;function F0(t){return typeof t=="string"&&te.IDENTIFIER.test(t)?new et(`.${t}`):rh`[${t}]`}te.getProperty=F0;function H0(t){if(typeof t=="string"&&te.IDENTIFIER.test(t))return new et(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}te.getEsmExportName=H0;function B0(t){return new et(t.toString())}te.regexpCode=B0});var ku=P(Le=>{"use strict";d();Object.defineProperty(Le,"__esModule",{value:!0});Le.ValueScope=Le.ValueScopeName=Le.Scope=Le.varKinds=Le.UsedValueState=void 0;var qe=io(),wu=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},qs;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(qs||(Le.UsedValueState=qs={}));Le.varKinds={const:new qe.Name("const"),let:new qe.Name("let"),var:new qe.Name("var")};var Ls=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof qe.Name?e:this.name(e)}name(e){return new qe.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Le.Scope=Ls;var Us=class extends qe.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,qe._)`.${new qe.Name(r)}[${n}]`}};Le.ValueScopeName=Us;var J0=(0,qe._)`\n`,xu=class extends Ls{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?J0:qe.nil}}get(){return this._scope}name(e){return new Us(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,qe._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=qe.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,qs.Started);let l=r(u);if(l){let p=this.opts.es5?Le.varKinds.var:Le.varKinds.const;s=(0,qe._)`${s}${p} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,qe._)`${s}${l}${this.opts._n}`;else throw new wu(u);c.set(u,qs.Completed)})}return s}};Le.ValueScope=xu});var B=P(J=>{"use strict";d();Object.defineProperty(J,"__esModule",{value:!0});J.or=J.and=J.not=J.CodeGen=J.operators=J.varKinds=J.ValueScopeName=J.ValueScope=J.Scope=J.Name=J.regexpCode=J.stringify=J.getProperty=J.nil=J.strConcat=J.str=J._=void 0;var X=io(),lt=ku(),Ft=io();Object.defineProperty(J,"_",{enumerable:!0,get:function(){return Ft._}});Object.defineProperty(J,"str",{enumerable:!0,get:function(){return Ft.str}});Object.defineProperty(J,"strConcat",{enumerable:!0,get:function(){return Ft.strConcat}});Object.defineProperty(J,"nil",{enumerable:!0,get:function(){return Ft.nil}});Object.defineProperty(J,"getProperty",{enumerable:!0,get:function(){return Ft.getProperty}});Object.defineProperty(J,"stringify",{enumerable:!0,get:function(){return Ft.stringify}});Object.defineProperty(J,"regexpCode",{enumerable:!0,get:function(){return Ft.regexpCode}});Object.defineProperty(J,"Name",{enumerable:!0,get:function(){return Ft.Name}});var Bs=ku();Object.defineProperty(J,"Scope",{enumerable:!0,get:function(){return Bs.Scope}});Object.defineProperty(J,"ValueScope",{enumerable:!0,get:function(){return Bs.ValueScope}});Object.defineProperty(J,"ValueScopeName",{enumerable:!0,get:function(){return Bs.ValueScopeName}});Object.defineProperty(J,"varKinds",{enumerable:!0,get:function(){return Bs.varKinds}});J.operators={GT:new X._Code(">"),GTE:new X._Code(">="),LT:new X._Code("<"),LTE:new X._Code("<="),EQ:new X._Code("==="),NEQ:new X._Code("!=="),NOT:new X._Code("!"),OR:new X._Code("||"),AND:new X._Code("&&"),ADD:new X._Code("+")};var It=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},$u=class extends It{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?lt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=tn(this.rhs,e,r)),this}get names(){return this.rhs instanceof X._CodeOrName?this.rhs.names:{}}},Vs=class extends It{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof X.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=tn(this.rhs,e,r),this}get names(){let e=this.lhs instanceof X.Name?{}:{...this.lhs.names};return Hs(e,this.rhs)}},Su=class extends Vs{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Tu=class extends It{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},zu=class extends It{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Pu=class extends It{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Iu=class extends It{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=tn(this.code,e,r),this}get names(){return this.code instanceof X._CodeOrName?this.code.names:{}}},ao=class extends It{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(K0(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>hr(e,r.names),{})}},Et=class extends ao{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Eu=class extends ao{},en=class extends Et{};en.kind="else";var fr=class t extends Et{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new en(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(oh(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=tn(this.condition,e,r),this}get names(){let e=super.names;return Hs(e,this.condition),this.else&&hr(e,this.else.names),e}};fr.kind="if";var mr=class extends Et{};mr.kind="for";var Ru=class extends mr{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=tn(this.iteration,e,r),this}get names(){return hr(super.names,this.iteration.names)}},Cu=class extends mr{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?lt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Hs(super.names,this.from);return Hs(e,this.to)}},Fs=class extends mr{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=tn(this.iterable,e,r),this}get names(){return hr(super.names,this.iterable.names)}},co=class extends Et{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};co.kind="func";var uo=class extends ao{render(e){return"return "+super.render(e)}};uo.kind="return";var Zu=class extends Et{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&hr(e,this.catch.names),this.finally&&hr(e,this.finally.names),e}},lo=class extends Et{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};lo.kind="catch";var po=class extends Et{render(e){return"finally"+super.render(e)}};po.kind="finally";var Ou=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
+
`:""},this._extScope=e,this._scope=new lt.Scope({parent:e}),this._nodes=[new Eu]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new $u(e,s,n)),s}const(e,r,n){return this._def(lt.varKinds.const,e,r,n)}let(e,r,n){return this._def(lt.varKinds.let,e,r,n)}var(e,r,n){return this._def(lt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Vs(e,r,n))}add(e,r){return this._leafNode(new Su(e,J.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==X.nil&&this._leafNode(new Iu(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,X.addCodeArg)(r,o));return r.push("}"),new X._Code(r)}if(e,r,n){if(this._blockNode(new fr(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new fr(e))}else(){return this._elseNode(new en)}endIf(){return this._endBlockNode(fr,en)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Ru(e),r)}forRange(e,r,n,o,s=this.opts.es5?lt.varKinds.var:lt.varKinds.let){let i=this._scope.toName(e);return this._for(new Cu(s,i,r,n),()=>o(i))}forOf(e,r,n,o=lt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof X.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,X._)`${i}.length`,a=>{this.var(s,(0,X._)`${i}[${a}]`),n(s)})}return this._for(new Fs("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?lt.varKinds.var:lt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,X._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Fs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(mr)}label(e){return this._leafNode(new Tu(e))}break(e){return this._leafNode(new zu(e))}return(e){let r=new uo;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(uo)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Zu;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new lo(s),r(s)}return n&&(this._currNode=o.finally=new po,this.code(n)),this._endBlockNode(lo,po)}throw(e){return this._leafNode(new Pu(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=X.nil,n,o){return this._blockNode(new co(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(co)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof fr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};J.CodeGen=Ou;function hr(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Hs(t,e){return e instanceof X._CodeOrName?hr(t,e.names):t}function tn(t,e,r){if(t instanceof X.Name)return n(t);if(!o(t))return t;return new X._Code(t._items.reduce((s,i)=>(i instanceof X.Name&&(i=n(i)),i instanceof X._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof X._Code&&s._items.some(i=>i instanceof X.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function K0(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function oh(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,X._)`!${ju(t)}`}J.not=oh;var G0=sh(J.operators.AND);function W0(...t){return t.reduce(G0)}J.and=W0;var Y0=sh(J.operators.OR);function X0(...t){return t.reduce(Y0)}J.or=X0;function sh(t){return(e,r)=>e===X.nil?r:r===X.nil?e:(0,X._)`${ju(e)} ${t} ${ju(r)}`}function ju(t){return t instanceof X.Name?t:(0,X._)`(${t})`}});var Q=P(K=>{"use strict";d();Object.defineProperty(K,"__esModule",{value:!0});K.checkStrictMode=K.getErrorPath=K.Type=K.useFunc=K.setEvaluated=K.evaluatedPropsToName=K.mergeEvaluated=K.eachItem=K.unescapeJsonPointer=K.escapeJsonPointer=K.escapeFragment=K.unescapeFragment=K.schemaRefOrVal=K.schemaHasRulesButRef=K.schemaHasRules=K.checkUnknownRules=K.alwaysValidSchema=K.toHash=void 0;var ie=B(),Q0=io();function ex(t){let e={};for(let r of t)e[r]=!0;return e}K.toHash=ex;function tx(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(ch(t,e),!uh(e,t.self.RULES.all))}K.alwaysValidSchema=tx;function ch(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||ph(t,`unknown keyword: "${s}"`)}K.checkUnknownRules=ch;function uh(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}K.schemaHasRules=uh;function rx(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}K.schemaHasRulesButRef=rx;function nx({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ie._)`${r}`}return(0,ie._)`${t}${e}${(0,ie.getProperty)(n)}`}K.schemaRefOrVal=nx;function ox(t){return lh(decodeURIComponent(t))}K.unescapeFragment=ox;function sx(t){return encodeURIComponent(Nu(t))}K.escapeFragment=sx;function Nu(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}K.escapeJsonPointer=Nu;function lh(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}K.unescapeJsonPointer=lh;function ix(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}K.eachItem=ix;function ih({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof ie.Name?(s instanceof ie.Name?t(o,s,i):e(o,s,i),i):s instanceof ie.Name?(e(o,i,s),s):r(s,i);return a===ie.Name&&!(c instanceof ie.Name)?n(o,c):c}}K.mergeEvaluated={props:ih({mergeNames:(t,e,r)=>t.if((0,ie._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ie._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ie._)`${r} || {}`).code((0,ie._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ie._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ie._)`${r} || {}`),Mu(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:dh}),items:ih({mergeNames:(t,e,r)=>t.if((0,ie._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ie._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ie._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ie._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function dh(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ie._)`{}`);return e!==void 0&&Mu(t,r,e),r}K.evaluatedPropsToName=dh;function Mu(t,e,r){Object.keys(r).forEach(n=>t.assign((0,ie._)`${e}${(0,ie.getProperty)(n)}`,!0))}K.setEvaluated=Mu;var ah={};function ax(t,e){return t.scopeValue("func",{ref:e,code:ah[e.code]||(ah[e.code]=new Q0._Code(e.code))})}K.useFunc=ax;var Au;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Au||(K.Type=Au={}));function cx(t,e,r){if(t instanceof ie.Name){let n=e===Au.Num;return r?n?(0,ie._)`"[" + ${t} + "]"`:(0,ie._)`"['" + ${t} + "']"`:n?(0,ie._)`"/" + ${t}`:(0,ie._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ie.getProperty)(t).toString():"/"+Nu(t)}K.getErrorPath=cx;function ph(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}K.checkStrictMode=ph});var Rt=P(Du=>{"use strict";d();Object.defineProperty(Du,"__esModule",{value:!0});var Pe=B(),ux={data:new Pe.Name("data"),valCxt:new Pe.Name("valCxt"),instancePath:new Pe.Name("instancePath"),parentData:new Pe.Name("parentData"),parentDataProperty:new Pe.Name("parentDataProperty"),rootData:new Pe.Name("rootData"),dynamicAnchors:new Pe.Name("dynamicAnchors"),vErrors:new Pe.Name("vErrors"),errors:new Pe.Name("errors"),this:new Pe.Name("this"),self:new Pe.Name("self"),scope:new Pe.Name("scope"),json:new Pe.Name("json"),jsonPos:new Pe.Name("jsonPos"),jsonLen:new Pe.Name("jsonLen"),jsonPart:new Pe.Name("jsonPart")};Du.default=ux});var fo=P(Ie=>{"use strict";d();Object.defineProperty(Ie,"__esModule",{value:!0});Ie.extendErrors=Ie.resetErrorsCount=Ie.reportExtraError=Ie.reportError=Ie.keyword$DataError=Ie.keywordError=void 0;var ee=B(),Js=Q(),je=Rt();Ie.keywordError={message:({keyword:t})=>(0,ee.str)`must pass "${t}" keyword validation`};Ie.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,ee.str)`"${t}" keyword must be ${e} ($data)`:(0,ee.str)`"${t}" keyword is invalid ($data)`};function lx(t,e=Ie.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=hh(t,e,r);n??(i||a)?fh(s,c):mh(o,(0,ee._)`[${c}]`)}Ie.reportError=lx;function dx(t,e=Ie.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=hh(t,e,r);fh(o,a),s||i||mh(n,je.default.vErrors)}Ie.reportExtraError=dx;function px(t,e){t.assign(je.default.errors,e),t.if((0,ee._)`${je.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,ee._)`${je.default.vErrors}.length`,e),()=>t.assign(je.default.vErrors,null)))}Ie.resetErrorsCount=px;function fx({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,je.default.errors,a=>{t.const(i,(0,ee._)`${je.default.vErrors}[${a}]`),t.if((0,ee._)`${i}.instancePath === undefined`,()=>t.assign((0,ee._)`${i}.instancePath`,(0,ee.strConcat)(je.default.instancePath,s.errorPath))),t.assign((0,ee._)`${i}.schemaPath`,(0,ee.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,ee._)`${i}.schema`,r),t.assign((0,ee._)`${i}.data`,n))})}Ie.extendErrors=fx;function fh(t,e){let r=t.const("err",e);t.if((0,ee._)`${je.default.vErrors} === null`,()=>t.assign(je.default.vErrors,(0,ee._)`[${r}]`),(0,ee._)`${je.default.vErrors}.push(${r})`),t.code((0,ee._)`${je.default.errors}++`)}function mh(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,ee._)`new ${t.ValidationError}(${e})`):(r.assign((0,ee._)`${n}.errors`,e),r.return(!1))}var gr={keyword:new ee.Name("keyword"),schemaPath:new ee.Name("schemaPath"),params:new ee.Name("params"),propertyName:new ee.Name("propertyName"),message:new ee.Name("message"),schema:new ee.Name("schema"),parentSchema:new ee.Name("parentSchema")};function hh(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,ee._)`{}`:mx(t,e,r)}function mx(t,e,r={}){let{gen:n,it:o}=t,s=[hx(o,r),gx(t,r)];return _x(t,e,s),n.object(...s)}function hx({errorPath:t},{instancePath:e}){let r=e?(0,ee.str)`${t}${(0,Js.getErrorPath)(e,Js.Type.Str)}`:t;return[je.default.instancePath,(0,ee.strConcat)(je.default.instancePath,r)]}function gx({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,ee.str)`${e}/${t}`;return r&&(o=(0,ee.str)`${o}${(0,Js.getErrorPath)(r,Js.Type.Str)}`),[gr.schemaPath,o]}function _x(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:p}=a;n.push([gr.keyword,o],[gr.params,typeof e=="function"?e(t):e||(0,ee._)`{}`]),c.messages&&n.push([gr.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([gr.schema,i],[gr.parentSchema,(0,ee._)`${l}${p}`],[je.default.data,s]),u&&n.push([gr.propertyName,u])}});var _h=P(rn=>{"use strict";d();Object.defineProperty(rn,"__esModule",{value:!0});rn.boolOrEmptySchema=rn.topBoolOrEmptySchema=void 0;var yx=fo(),vx=B(),bx=Rt(),wx={message:"boolean schema is false"};function xx(t){let{gen:e,schema:r,validateName:n}=t;r===!1?gh(t,!1):typeof r=="object"&&r.$async===!0?e.return(bx.default.data):(e.assign((0,vx._)`${n}.errors`,null),e.return(!0))}rn.topBoolOrEmptySchema=xx;function kx(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),gh(t)):r.var(e,!0)}rn.boolOrEmptySchema=kx;function gh(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,yx.reportError)(o,wx,void 0,e)}});var qu=P(nn=>{"use strict";d();Object.defineProperty(nn,"__esModule",{value:!0});nn.getRules=nn.isJSONType=void 0;var $x=["string","number","integer","boolean","null","object","array"],Sx=new Set($x);function Tx(t){return typeof t=="string"&&Sx.has(t)}nn.isJSONType=Tx;function zx(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}nn.getRules=zx});var Lu=P(Ht=>{"use strict";d();Object.defineProperty(Ht,"__esModule",{value:!0});Ht.shouldUseRule=Ht.shouldUseGroup=Ht.schemaHasRulesForType=void 0;function Px({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&yh(t,n)}Ht.schemaHasRulesForType=Px;function yh(t,e){return e.rules.some(r=>vh(t,r))}Ht.shouldUseGroup=yh;function vh(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Ht.shouldUseRule=vh});var mo=P(Ee=>{"use strict";d();Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var Ix=qu(),Ex=Lu(),Rx=fo(),H=B(),bh=Q(),on;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(on||(Ee.DataType=on={}));function Cx(t){let e=wh(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ee.getSchemaTypes=Cx;function wh(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(Ix.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ee.getJSONTypes=wh;function Zx(t,e){let{gen:r,data:n,opts:o}=t,s=Ox(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,Ex.schemaHasRulesForType)(t,e[0]));if(i){let a=Vu(e,n,o.strictNumbers,on.Wrong);r.if(a,()=>{s.length?jx(t,e,s):Fu(t)})}return i}Ee.coerceAndCheckDataType=Zx;var xh=new Set(["string","number","integer","boolean","null"]);function Ox(t,e){return e?t.filter(r=>xh.has(r)||e==="array"&&r==="array"):[]}function jx(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,H._)`typeof ${o}`),a=n.let("coerced",(0,H._)`undefined`);s.coerceTypes==="array"&&n.if((0,H._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,H._)`${o}[0]`).assign(i,(0,H._)`typeof ${o}`).if(Vu(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,H._)`${a} !== undefined`);for(let u of r)(xh.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Fu(t),n.endIf(),n.if((0,H._)`${a} !== undefined`,()=>{n.assign(o,a),Ax(t,a)});function c(u){switch(u){case"string":n.elseIf((0,H._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,H._)`"" + ${o}`).elseIf((0,H._)`${o} === null`).assign(a,(0,H._)`""`);return;case"number":n.elseIf((0,H._)`${i} == "boolean" || ${o} === null
|
|
4
4
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,H._)`+${o}`);return;case"integer":n.elseIf((0,H._)`${i} === "boolean" || ${o} === null
|
|
5
5
|
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,H._)`+${o}`);return;case"boolean":n.elseIf((0,H._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,H._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,H._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,H._)`${i} === "string" || ${i} === "number"
|
|
6
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,H._)`[${o}]`)}}}function jx({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,H._)`${e} !== undefined`,()=>t.assign((0,H._)`${e}[${r}]`,n))}function Uu(t,e,r,n=on.Correct){let o=n===on.Correct?H.operators.EQ:H.operators.NEQ,s;switch(t){case"null":return(0,H._)`${e} ${o} null`;case"array":s=(0,H._)`Array.isArray(${e})`;break;case"object":s=(0,H._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,H._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,H._)`typeof ${e} ${o} ${t}`}return n===on.Correct?s:(0,H.not)(s);function i(a=H.nil){return(0,H.and)((0,H._)`typeof ${e} == "number"`,a,r?(0,H._)`isFinite(${e})`:H.nil)}}Ee.checkDataType=Uu;function Vu(t,e,r,n){if(t.length===1)return Uu(t[0],e,r,n);let o,s=(0,vh.toHash)(t);if(s.array&&s.object){let i=(0,H._)`typeof ${e} != "object"`;o=s.null?i:(0,H._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=H.nil;s.number&&delete s.integer;for(let i in s)o=(0,H.and)(o,Uu(i,e,r,n));return o}Ee.checkDataTypes=Vu;var Ax={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,H._)`{type: ${t}}`:(0,H._)`{type: ${e}}`};function Fu(t){let e=Nx(t);(0,Ex.reportError)(e,Ax)}Ee.reportTypeError=Fu;function Nx(t){let{gen:e,data:r,schema:n}=t,o=(0,vh.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var $h=P(Ks=>{"use strict";d();Object.defineProperty(Ks,"__esModule",{value:!0});Ks.assignDefaults=void 0;var sn=B(),Mx=Q();function Dx(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)xh(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>xh(t,s,o.default))}Ks.assignDefaults=Dx;function xh(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,sn._)`${s}${(0,sn.getProperty)(e)}`;if(o){(0,Mx.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,sn._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,sn._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,sn._)`${a} = ${(0,sn.stringify)(r)}`)}});var tt=P(se=>{"use strict";d();Object.defineProperty(se,"__esModule",{value:!0});se.validateUnion=se.validateArray=se.usePattern=se.callValidateCode=se.schemaProperties=se.allSchemaProperties=se.noPropertyInData=se.propertyInData=se.isOwnProperty=se.hasPropFunc=se.reportMissingProp=se.checkMissingProp=se.checkReportMissingProp=void 0;var pe=B(),Hu=Q(),Bt=Rt(),qx=Q();function Lx(t,e){let{gen:r,data:n,it:o}=t;r.if(Ju(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,pe._)`${e}`},!0),t.error()})}se.checkReportMissingProp=Lx;function Ux({gen:t,data:e,it:{opts:r}},n,o){return(0,pe.or)(...n.map(s=>(0,pe.and)(Ju(t,e,s,r.ownProperties),(0,pe._)`${o} = ${s}`)))}se.checkMissingProp=Ux;function Vx(t,e){t.setParams({missingProperty:e},!0),t.error()}se.reportMissingProp=Vx;function kh(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,pe._)`Object.prototype.hasOwnProperty`})}se.hasPropFunc=kh;function Bu(t,e,r){return(0,pe._)`${kh(t)}.call(${e}, ${r})`}se.isOwnProperty=Bu;function Fx(t,e,r,n){let o=(0,pe._)`${e}${(0,pe.getProperty)(r)} !== undefined`;return n?(0,pe._)`${o} && ${Bu(t,e,r)}`:o}se.propertyInData=Fx;function Ju(t,e,r,n){let o=(0,pe._)`${e}${(0,pe.getProperty)(r)} === undefined`;return n?(0,pe.or)(o,(0,pe.not)(Bu(t,e,r))):o}se.noPropertyInData=Ju;function Sh(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}se.allSchemaProperties=Sh;function Hx(t,e){return Sh(e).filter(r=>!(0,Hu.alwaysValidSchema)(t,e[r]))}se.schemaProperties=Hx;function Bx({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,pe._)`${t}, ${e}, ${n}${o}`:e,p=[[Bt.default.instancePath,(0,pe.strConcat)(Bt.default.instancePath,s)],[Bt.default.parentData,i.parentData],[Bt.default.parentDataProperty,i.parentDataProperty],[Bt.default.rootData,Bt.default.rootData]];i.opts.dynamicRef&&p.push([Bt.default.dynamicAnchors,Bt.default.dynamicAnchors]);let m=(0,pe._)`${l}, ${r.object(...p)}`;return c!==pe.nil?(0,pe._)`${a}.call(${c}, ${m})`:(0,pe._)`${a}(${m})`}se.callValidateCode=Bx;var Jx=(0,pe._)`new RegExp`;function Kx({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,pe._)`${o.code==="new RegExp"?Jx:(0,qx.useFunc)(t,o)}(${r}, ${n})`})}se.usePattern=Kx;function Gx(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,pe._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:Hu.Type.Num},s),e.if((0,pe.not)(s),a)})}}se.validateArray=Gx;function Wx(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Hu.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,pe._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,pe.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}se.validateUnion=Wx});var Ph=P(_t=>{"use strict";d();Object.defineProperty(_t,"__esModule",{value:!0});_t.validateKeywordUsage=_t.validSchemaType=_t.funcKeywordCode=_t.macroKeywordCode=void 0;var Ae=B(),_r=Rt(),Yx=tt(),Xx=fo();function Qx(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=zh(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:Ae.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}_t.macroKeywordCode=Qx;function e$(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;r$(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=zh(n,o,u),p=n.let("valid");t.block$data(p,m),t.ok((r=e.valid)!==null&&r!==void 0?r:p);function m(){if(e.errors===!1)_(),e.modifying&&Th(t),w(()=>t.error());else{let k=e.async?h():f();e.modifying&&Th(t),w(()=>t$(t,k))}}function h(){let k=n.let("ruleErrs",null);return n.try(()=>_((0,Ae._)`await `),S=>n.assign(p,!1).if((0,Ae._)`${S} instanceof ${c.ValidationError}`,()=>n.assign(k,(0,Ae._)`${S}.errors`),()=>n.throw(S))),k}function f(){let k=(0,Ae._)`${l}.errors`;return n.assign(k,null),_(Ae.nil),k}function _(k=e.async?(0,Ae._)`await `:Ae.nil){let S=c.opts.passContext?_r.default.this:_r.default.self,T=!("compile"in e&&!a||e.schema===!1);n.assign(p,(0,Ae._)`${k}${(0,Yx.callValidateCode)(t,l,S,T)}`,e.modifying)}function w(k){var S;n.if((0,Ae.not)((S=e.valid)!==null&&S!==void 0?S:p),k)}}_t.funcKeywordCode=e$;function Th(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Ae._)`${n.parentData}[${n.parentDataProperty}]`))}function t$(t,e){let{gen:r}=t;r.if((0,Ae._)`Array.isArray(${e})`,()=>{r.assign(_r.default.vErrors,(0,Ae._)`${_r.default.vErrors} === null ? ${e} : ${_r.default.vErrors}.concat(${e})`).assign(_r.default.errors,(0,Ae._)`${_r.default.vErrors}.length`),(0,Xx.extendErrors)(t)},()=>t.error())}function r$({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function zh(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Ae.stringify)(r)})}function n$(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}_t.validSchemaType=n$;function o$({schema:t,opts:e,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}_t.validateKeywordUsage=o$});var Eh=P(Jt=>{"use strict";d();Object.defineProperty(Jt,"__esModule",{value:!0});Jt.extendSubschemaMode=Jt.extendSubschemaData=Jt.getSubschema=void 0;var yt=B(),Ih=Q();function s$(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,yt._)`${t.schemaPath}${(0,yt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,yt._)`${t.schemaPath}${(0,yt.getProperty)(e)}${(0,yt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Ih.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Jt.getSubschema=s$;function i$(t,e,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:p}=e,m=a.let("data",(0,yt._)`${e.data}${(0,yt.getProperty)(r)}`,!0);c(m),t.errorPath=(0,yt.str)`${u}${(0,Ih.getErrorPath)(r,n,p.jsPropertySyntax)}`,t.parentDataProperty=(0,yt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof yt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Jt.extendSubschemaData=i$;function a$(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Jt.extendSubschemaMode=a$});var Ku=P((Nj,Rh)=>{"use strict";d();Rh.exports=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,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))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(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Zh=P((Dj,Ch)=>{"use strict";d();var Kt=Ch.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Gs(e,n,o,t,"",t)};Kt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Kt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Kt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Kt.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 Gs(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var p=n[l];if(Array.isArray(p)){if(l in Kt.arrayKeywords)for(var m=0;m<p.length;m++)Gs(t,e,r,p[m],o+"/"+l+"/"+m,s,o,l,n,m)}else if(l in Kt.propsKeywords){if(p&&typeof p=="object")for(var h in p)Gs(t,e,r,p[h],o+"/"+l+"/"+c$(h),s,o,l,n,h)}else(l in Kt.keywords||t.allKeys&&!(l in Kt.skipKeywords))&&Gs(t,e,r,p,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function c$(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var ho=P(Ue=>{"use strict";d();Object.defineProperty(Ue,"__esModule",{value:!0});Ue.getSchemaRefs=Ue.resolveUrl=Ue.normalizeId=Ue._getFullPath=Ue.getFullPath=Ue.inlineRef=void 0;var u$=Q(),l$=Ku(),d$=Zh(),p$=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function f$(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Gu(t):e?Oh(t)<=e:!1}Ue.inlineRef=f$;var m$=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Gu(t){for(let e in t){if(m$.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Gu)||typeof r=="object"&&Gu(r))return!0}return!1}function Oh(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!p$.has(r)&&(typeof t[r]=="object"&&(0,u$.eachItem)(t[r],n=>e+=Oh(n)),e===1/0))return 1/0}return e}function jh(t,e="",r){r!==!1&&(e=an(e));let n=t.parse(e);return Ah(t,n)}Ue.getFullPath=jh;function Ah(t,e){return t.serialize(e).split("#")[0]+"#"}Ue._getFullPath=Ah;var h$=/#\/?$/;function an(t){return t?t.replace(h$,""):""}Ue.normalizeId=an;function g$(t,e,r){return r=an(r),t.resolve(e,r)}Ue.resolveUrl=g$;var _$=/^[a-z_][-a-z0-9._]*$/i;function y$(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=an(t[r]||e),s={"":o},i=jh(n,o,!1),a={},c=new Set;return d$(t,{allKeys:!0},(p,m,h,f)=>{if(f===void 0)return;let _=i+m,w=s[f];typeof p[r]=="string"&&(w=k.call(this,p[r])),S.call(this,p.$anchor),S.call(this,p.$dynamicAnchor),s[m]=w;function k(T){let R=this.opts.uriResolver.resolve;if(T=an(w?R(w,T):T),c.has(T))throw l(T);c.add(T);let N=this.refs[T];return typeof N=="string"&&(N=this.refs[N]),typeof N=="object"?u(p,N.schema,T):T!==an(_)&&(T[0]==="#"?(u(p,a[T],T),a[T]=p):this.refs[T]=_),T}function S(T){if(typeof T=="string"){if(!_$.test(T))throw new Error(`invalid anchor "${T}"`);k.call(this,`#${T}`)}}}),a;function u(p,m,h){if(m!==void 0&&!l$(p,m))throw l(h)}function l(p){return new Error(`reference "${p}" resolves to more than one schema`)}}Ue.getSchemaRefs=y$});var yo=P(Gt=>{"use strict";d();Object.defineProperty(Gt,"__esModule",{value:!0});Gt.getData=Gt.KeywordCxt=Gt.validateFunctionCode=void 0;var Lh=gh(),Nh=mo(),Yu=Lu(),Ws=mo(),v$=$h(),_o=Ph(),Wu=Eh(),O=B(),L=Rt(),b$=ho(),Ct=Q(),go=fo();function w$(t){if(Fh(t)&&(Hh(t),Vh(t))){k$(t);return}Uh(t,()=>(0,Lh.topBoolOrEmptySchema)(t))}Gt.validateFunctionCode=w$;function Uh({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,O._)`${L.default.data}, ${L.default.valCxt}`,n.$async,()=>{t.code((0,O._)`"use strict"; ${Mh(r,o)}`),$$(t,o),t.code(s)}):t.func(e,(0,O._)`${L.default.data}, ${x$(o)}`,n.$async,()=>t.code(Mh(r,o)).code(s))}function x$(t){return(0,O._)`{${L.default.instancePath}="", ${L.default.parentData}, ${L.default.parentDataProperty}, ${L.default.rootData}=${L.default.data}${t.dynamicRef?(0,O._)`, ${L.default.dynamicAnchors}={}`:O.nil}}={}`}function $$(t,e){t.if(L.default.valCxt,()=>{t.var(L.default.instancePath,(0,O._)`${L.default.valCxt}.${L.default.instancePath}`),t.var(L.default.parentData,(0,O._)`${L.default.valCxt}.${L.default.parentData}`),t.var(L.default.parentDataProperty,(0,O._)`${L.default.valCxt}.${L.default.parentDataProperty}`),t.var(L.default.rootData,(0,O._)`${L.default.valCxt}.${L.default.rootData}`),e.dynamicRef&&t.var(L.default.dynamicAnchors,(0,O._)`${L.default.valCxt}.${L.default.dynamicAnchors}`)},()=>{t.var(L.default.instancePath,(0,O._)`""`),t.var(L.default.parentData,(0,O._)`undefined`),t.var(L.default.parentDataProperty,(0,O._)`undefined`),t.var(L.default.rootData,L.default.data),e.dynamicRef&&t.var(L.default.dynamicAnchors,(0,O._)`{}`)})}function k$(t){let{schema:e,opts:r,gen:n}=t;Uh(t,()=>{r.$comment&&e.$comment&&Jh(t),I$(t),n.let(L.default.vErrors,null),n.let(L.default.errors,0),r.unevaluated&&S$(t),Bh(t),C$(t)})}function S$(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,O._)`${r}.evaluated`),e.if((0,O._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,O._)`${t.evaluated}.props`,(0,O._)`undefined`)),e.if((0,O._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,O._)`${t.evaluated}.items`,(0,O._)`undefined`))}function Mh(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,O._)`/*# sourceURL=${r} */`:O.nil}function T$(t,e){if(Fh(t)&&(Hh(t),Vh(t))){z$(t,e);return}(0,Lh.boolOrEmptySchema)(t,e)}function Vh({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function Fh(t){return typeof t.schema!="boolean"}function z$(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&Jh(t),E$(t),R$(t);let s=n.const("_errs",L.default.errors);Bh(t,s),n.var(e,(0,O._)`${s} === ${L.default.errors}`)}function Hh(t){(0,Ct.checkUnknownRules)(t),P$(t)}function Bh(t,e){if(t.opts.jtd)return Dh(t,[],!1,e);let r=(0,Nh.getSchemaTypes)(t.schema),n=(0,Nh.coerceAndCheckDataType)(t,r);Dh(t,r,!n,e)}function P$(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Ct.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function I$(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ct.checkStrictMode)(t,"default is ignored in the schema root")}function E$(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,b$.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function R$(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Jh({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,O._)`${L.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,O.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,O._)`${L.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function C$(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,O._)`${L.default.errors} === 0`,()=>e.return(L.default.data),()=>e.throw((0,O._)`new ${o}(${L.default.vErrors})`)):(e.assign((0,O._)`${n}.errors`,L.default.vErrors),s.unevaluated&&Z$(t),e.return((0,O._)`${L.default.errors} === 0`))}function Z$({gen:t,evaluated:e,props:r,items:n}){r instanceof O.Name&&t.assign((0,O._)`${e}.props`,r),n instanceof O.Name&&t.assign((0,O._)`${e}.items`,n)}function Dh(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Ct.schemaHasRulesButRef)(s,l))){o.block(()=>Gh(t,"$ref",l.all.$ref.definition));return}c.jtd||O$(t,e),o.block(()=>{for(let m of l.rules)p(m);p(l.post)});function p(m){(0,Yu.shouldUseGroup)(s,m)&&(m.type?(o.if((0,Ws.checkDataType)(m.type,i,c.strictNumbers)),qh(t,m),e.length===1&&e[0]===m.type&&r&&(o.else(),(0,Ws.reportTypeError)(t)),o.endIf()):qh(t,m),a||o.if((0,O._)`${L.default.errors} === ${n||0}`))}}function qh(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,v$.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Yu.shouldUseRule)(n,s)&&Gh(t,s.keyword,s.definition,e.type)})}function O$(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(j$(t,e),t.opts.allowUnionTypes||A$(t,e),N$(t,t.dataTypes))}function j$(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Kh(t.dataTypes,r)||Xu(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),D$(t,e)}}function A$(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Xu(t,"use allowUnionTypes to allow union type keyword")}function N$(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Yu.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>M$(e,i))&&Xu(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function M$(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Kh(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function D$(t,e){let r=[];for(let n of t.dataTypes)Kh(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Xu(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ct.checkStrictMode)(t,e,t.opts.strictTypes)}var Ys=class{constructor(e,r,n){if((0,_o.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ct.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",Wh(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,_o.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",L.default.errors))}result(e,r,n){this.failResult((0,O.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,O.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,O._)`${r} !== undefined && (${(0,O.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?go.reportExtraError:go.reportError)(this,this.def.error,r)}$dataError(){(0,go.reportError)(this,this.def.$dataError||go.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,go.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=O.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=O.nil,r=O.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,O.or)((0,O._)`${o} === undefined`,r)),e!==O.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==O.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,O.or)(i(),a());function i(){if(n.length){if(!(r instanceof O.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,O._)`${(0,Ws.checkDataTypes)(c,r,s.opts.strictNumbers,Ws.DataType.Wrong)}`}return O.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,O._)`!${c}(${r})`}return O.nil}}subschema(e,r){let n=(0,Wu.getSubschema)(this.it,e);(0,Wu.extendSubschemaData)(n,this.it,e),(0,Wu.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return T$(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Ct.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Ct.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,O.Name)),!0}};Gt.KeywordCxt=Ys;function Gh(t,e,r,n){let o=new Ys(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,_o.funcKeywordCode)(o,r):"macro"in r?(0,_o.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,_o.funcKeywordCode)(o,r)}var q$=/^\/(?:[^~]|~0|~1)*$/,L$=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Wh(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return L.default.rootData;if(t[0]==="/"){if(!q$.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=L.default.rootData}else{let u=L$.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,O._)`${s}${(0,O.getProperty)((0,Ct.unescapeJsonPointer)(u))}`,i=(0,O._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Gt.getData=Wh});var Xs=P(el=>{"use strict";d();Object.defineProperty(el,"__esModule",{value:!0});var Qu=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};el.default=Qu});var vo=P(nl=>{"use strict";d();Object.defineProperty(nl,"__esModule",{value:!0});var tl=ho(),rl=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,tl.resolveUrl)(e,r,n),this.missingSchema=(0,tl.normalizeId)((0,tl.getFullPath)(e,this.missingRef))}};nl.default=rl});var ei=P(rt=>{"use strict";d();Object.defineProperty(rt,"__esModule",{value:!0});rt.resolveSchema=rt.getCompilingSchema=rt.resolveRef=rt.compileSchema=rt.SchemaEnv=void 0;var dt=B(),U$=Xs(),yr=Rt(),pt=ho(),Yh=Q(),V$=yo(),cn=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,pt.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};rt.SchemaEnv=cn;function sl(t){let e=Xh.call(this,t);if(e)return e;let r=(0,pt.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new dt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:U$.default,code:(0,dt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:yr.default.data,parentData:yr.default.parentData,parentDataProperty:yr.default.parentDataProperty,dataNames:[yr.default.data],dataPathArr:[dt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,dt.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:dt.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,dt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,V$.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let p=i.toString();l=`${i.scopeRefs(yr.default.scope)}return ${p}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let h=new Function(`${yr.default.self}`,`${yr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:h}),h.errors=null,h.schema=t.schema,h.schemaEnv=t,t.$async&&(h.$async=!0),this.opts.code.source===!0&&(h.source={validateName:c,validateCode:p,scopeValues:i._values}),this.opts.unevaluated){let{props:f,items:_}=u;h.evaluated={props:f instanceof dt.Name?void 0:f,items:_ instanceof dt.Name?void 0:_,dynamicProps:f instanceof dt.Name,dynamicItems:_ instanceof dt.Name},h.source&&(h.source.evaluated=(0,dt.stringify)(h.evaluated))}return t.validate=h,t}catch(p){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),p}finally{this._compilations.delete(t)}}rt.compileSchema=sl;function F$(t,e,r){var n;r=(0,pt.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=J$.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new cn({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=H$.call(this,s)}rt.resolveRef=F$;function H$(t){return(0,pt.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:sl.call(this,t)}function Xh(t){for(let e of this._compilations)if(B$(e,t))return e}rt.getCompilingSchema=Xh;function B$(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function J$(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Qs.call(this,t,e)}function Qs(t,e){let r=this.opts.uriResolver.parse(e),n=(0,pt._getFullPath)(this.opts.uriResolver,r),o=(0,pt.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return ol.call(this,r,t);let s=(0,pt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Qs.call(this,t,i);return typeof a?.schema!="object"?void 0:ol.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||sl.call(this,i),s===(0,pt.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,pt.resolveUrl)(this.opts.uriResolver,o,u)),new cn({schema:a,schemaId:c,root:t,baseId:o})}return ol.call(this,r,i)}}rt.resolveSchema=Qs;var K$=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ol(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Yh.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!K$.has(a)&&u&&(e=(0,pt.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Yh.schemaHasRulesButRef)(r,this.RULES)){let a=(0,pt.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=Qs.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new cn({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var Qh=P((Yj,G$)=>{G$.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var al=P((Xj,ng)=>{"use strict";d();var W$=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),tg=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 il(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var Y$=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function eg(t){return t.length=0,!0}function X$(t,e,r){if(t.length){let n=il(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function Q$(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=X$;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=eg}else{o.push(u);continue}}return o.length&&(a===eg?r.zone=o.join(""):i?n.push(o.join("")):n.push(il(o))),r.address=n.join(""),r}function rg(t){if(ek(t,":")<2)return{host:t,isIPV6:!1};let e=Q$(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function ek(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function tk(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}function rk(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function nk(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!tg(r)){let n=rg(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}ng.exports={nonSimpleDomain:Y$,recomposeAuthority:nk,normalizeComponentEncoding:rk,removeDotSegments:tk,isIPv4:tg,isUUID:W$,normalizeIPv6:rg,stringArrayToHexStripped:il}});var cg=P((eA,ag)=>{"use strict";d();var{isUUID:ok}=al(),sk=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,ik=["http","https","ws","wss","urn","urn:uuid"];function ak(t){return ik.indexOf(t)!==-1}function cl(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function og(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function sg(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function ck(t){return t.secure=cl(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function uk(t){if((t.port===(cl(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function lk(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(sk);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=ul(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function dk(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=ul(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function pk(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!ok(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function fk(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var ig={scheme:"http",domainHost:!0,parse:og,serialize:sg},mk={scheme:"https",domainHost:ig.domainHost,parse:og,serialize:sg},ti={scheme:"ws",domainHost:!0,parse:ck,serialize:uk},hk={scheme:"wss",domainHost:ti.domainHost,parse:ti.parse,serialize:ti.serialize},gk={scheme:"urn",parse:lk,serialize:dk,skipNormalize:!0},_k={scheme:"urn:uuid",parse:pk,serialize:fk,skipNormalize:!0},ri={http:ig,https:mk,ws:ti,wss:hk,urn:gk,"urn:uuid":_k};Object.setPrototypeOf(ri,null);function ul(t){return t&&(ri[t]||ri[t.toLowerCase()])||void 0}ag.exports={wsIsSecure:cl,SCHEMES:ri,isValidSchemeName:ak,getSchemeHandler:ul}});var dg=P((rA,oi)=>{"use strict";d();var{normalizeIPv6:yk,removeDotSegments:bo,recomposeAuthority:vk,normalizeComponentEncoding:ni,isIPv4:bk,nonSimpleDomain:wk}=al(),{SCHEMES:xk,getSchemeHandler:ug}=cg();function $k(t,e){return typeof t=="string"?t=vt(Zt(t,e),e):typeof t=="object"&&(t=Zt(vt(t,e),e)),t}function kk(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=lg(Zt(t,n),Zt(e,n),n,!0);return n.skipEscape=!0,vt(o,n)}function lg(t,e,r,n){let o={};return n||(t=Zt(vt(t,r),r),e=Zt(vt(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=bo(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=bo(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=bo(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=bo(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function Sk(t,e,r){return typeof t=="string"?(t=unescape(t),t=vt(ni(Zt(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=vt(ni(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=vt(ni(Zt(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=vt(ni(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function vt(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=ug(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=vk(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=bo(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var Tk=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Zt(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let s=t.match(Tk);if(s){if(n.scheme=s[1],n.userinfo=s[3],n.host=s[4],n.port=parseInt(s[5],10),n.path=s[6]||"",n.query=s[7],n.fragment=s[8],isNaN(n.port)&&(n.port=s[5]),n.host)if(bk(n.host)===!1){let c=yk(n.host);n.host=c.host.toLowerCase(),o=c.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let i=ug(r.scheme||n.scheme);if(!r.unicodeSupport&&(!i||!i.unicodeSupport)&&n.host&&(r.domainHost||i&&i.domainHost)&&o===!1&&wk(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!i||i&&!i.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),i&&i.parse&&i.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var ll={SCHEMES:xk,normalize:$k,resolve:kk,resolveComponent:lg,equal:Sk,serialize:vt,parse:Zt};oi.exports=ll;oi.exports.default=ll;oi.exports.fastUri=ll});var fg=P(dl=>{"use strict";d();Object.defineProperty(dl,"__esModule",{value:!0});var pg=dg();pg.code='require("ajv/dist/runtime/uri").default';dl.default=pg});var wg=P(Te=>{"use strict";d();Object.defineProperty(Te,"__esModule",{value:!0});Te.CodeGen=Te.Name=Te.nil=Te.stringify=Te.str=Te._=Te.KeywordCxt=void 0;var zk=yo();Object.defineProperty(Te,"KeywordCxt",{enumerable:!0,get:function(){return zk.KeywordCxt}});var un=B();Object.defineProperty(Te,"_",{enumerable:!0,get:function(){return un._}});Object.defineProperty(Te,"str",{enumerable:!0,get:function(){return un.str}});Object.defineProperty(Te,"stringify",{enumerable:!0,get:function(){return un.stringify}});Object.defineProperty(Te,"nil",{enumerable:!0,get:function(){return un.nil}});Object.defineProperty(Te,"Name",{enumerable:!0,get:function(){return un.Name}});Object.defineProperty(Te,"CodeGen",{enumerable:!0,get:function(){return un.CodeGen}});var Pk=Xs(),yg=vo(),Ik=qu(),wo=ei(),Ek=B(),xo=ho(),si=mo(),fl=Q(),mg=Qh(),Rk=fg(),vg=(t,e)=>new RegExp(t,e);vg.code="new RegExp";var Ck=["removeAdditional","useDefaults","coerceTypes"],Zk=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Ok={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."},jk={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},hg=200;function Ak(t){var e,r,n,o,s,i,a,c,u,l,p,m,h,f,_,w,k,S,T,R,N,Ce,We,Lr,Ui;let Rn=t.strict,Vi=(e=t.code)===null||e===void 0?void 0:e.optimize,Dd=Vi===!0||Vi===void 0?1:Vi||0,qd=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:vg,Wy=(o=t.uriResolver)!==null&&o!==void 0?o:Rk.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:Rn)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:Rn)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:Rn)!==null&&l!==void 0?l:"log",strictTuples:(m=(p=t.strictTuples)!==null&&p!==void 0?p:Rn)!==null&&m!==void 0?m:"log",strictRequired:(f=(h=t.strictRequired)!==null&&h!==void 0?h:Rn)!==null&&f!==void 0?f:!1,code:t.code?{...t.code,optimize:Dd,regExp:qd}:{optimize:Dd,regExp:qd},loopRequired:(_=t.loopRequired)!==null&&_!==void 0?_:hg,loopEnum:(w=t.loopEnum)!==null&&w!==void 0?w:hg,meta:(k=t.meta)!==null&&k!==void 0?k:!0,messages:(S=t.messages)!==null&&S!==void 0?S:!0,inlineRefs:(T=t.inlineRefs)!==null&&T!==void 0?T:!0,schemaId:(R=t.schemaId)!==null&&R!==void 0?R:"$id",addUsedSchema:(N=t.addUsedSchema)!==null&&N!==void 0?N:!0,validateSchema:(Ce=t.validateSchema)!==null&&Ce!==void 0?Ce:!0,validateFormats:(We=t.validateFormats)!==null&&We!==void 0?We:!0,unicodeRegExp:(Lr=t.unicodeRegExp)!==null&&Lr!==void 0?Lr:!0,int32range:(Ui=t.int32range)!==null&&Ui!==void 0?Ui:!0,uriResolver:Wy}}var $o=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Ak(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new Ek.ValueScope({scope:{},prefixes:Zk,es5:r,lines:n}),this.logger=Uk(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,Ik.getRules)(),gg.call(this,Ok,e,"NOT SUPPORTED"),gg.call(this,jk,e,"DEPRECATED","warn"),this._metaOpts=qk.call(this),e.formats&&Mk.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&Dk.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),Nk.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=mg;n==="id"&&(o={...mg},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,e,r);async function o(l,p){await s.call(this,l.$schema);let m=this._addSchema(l,p);return m.validate||i.call(this,m)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(p){if(!(p instanceof yg.default))throw p;return a.call(this,p),await c.call(this,p.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:p}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${p} cannot be resolved`)}async function c(l){let p=await u.call(this,l);this.refs[l]||await s.call(this,p.$schema),this.refs[l]||this.addSchema(p,l,r)}async function u(l){let p=this._loading[l];if(p)return p;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,xo.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,e);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(e){let r;for(;typeof(r=_g.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new wo.SchemaEnv({schema:{},schemaId:n});if(r=wo.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=_g.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,xo.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Fk.call(this,n,r),!r)return(0,fl.eachItem)(n,s=>pl.call(this,s)),this;Bk.call(this,r);let o={...r,type:(0,si.getJSONTypes)(r.type),schemaType:(0,si.getJSONTypes)(r.schemaType)};return(0,fl.eachItem)(n,o.type.length===0?s=>pl.call(this,s,o):s=>o.type.forEach(i=>pl.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=bg(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,xo.normalizeId)(i||n);let u=xo.getSchemaRefs.call(this,e,n);return c=new wo.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):wo.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{wo.compileSchema.call(this,e)}finally{this.opts=r}}};$o.ValidationError=Pk.default;$o.MissingRefError=yg.default;Te.default=$o;function gg(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function _g(t){return t=(0,xo.normalizeId)(t),this.schemas[t]||this.refs[t]}function Nk(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function Mk(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function Dk(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function qk(){let t={...this.opts};for(let e of Ck)delete t[e];return t}var Lk={log(){},warn(){},error(){}};function Uk(t){if(t===!1)return Lk;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var Vk=/^[a-z_$][a-z0-9_$:-]*$/i;function Fk(t,e){let{RULES:r}=this;if((0,fl.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Vk.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function pl(t,e,r){var n;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,si.getJSONTypes)(e.type),schemaType:(0,si.getJSONTypes)(e.schemaType)}};e.before?Hk.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function Hk(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function Bk(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=bg(e)),t.validateSchema=this.compile(e,!0))}var Jk={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function bg(t){return{anyOf:[t,Jk]}}});var xg=P(ml=>{"use strict";d();Object.defineProperty(ml,"__esModule",{value:!0});var Kk={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ml.default=Kk});var Tg=P(vr=>{"use strict";d();Object.defineProperty(vr,"__esModule",{value:!0});vr.callRef=vr.getValidate=void 0;var Gk=vo(),$g=tt(),Ve=B(),ln=Rt(),kg=ei(),ii=Q(),Wk={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return p();let l=kg.resolveRef.call(c,u,o,r);if(l===void 0)throw new Gk.default(n.opts.uriResolver,o,r);if(l instanceof kg.SchemaEnv)return m(l);return h(l);function p(){if(s===u)return ai(t,i,s,s.$async);let f=e.scopeValue("root",{ref:u});return ai(t,(0,Ve._)`${f}.validate`,u,u.$async)}function m(f){let _=Sg(t,f);ai(t,_,f,f.$async)}function h(f){let _=e.scopeValue("schema",a.code.source===!0?{ref:f,code:(0,Ve.stringify)(f)}:{ref:f}),w=e.name("valid"),k=t.subschema({schema:f,dataTypes:[],schemaPath:Ve.nil,topSchemaRef:_,errSchemaPath:r},w);t.mergeEvaluated(k),t.ok(w)}}};function Sg(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Ve._)`${r.scopeValue("wrapper",{ref:e})}.validate`}vr.getValidate=Sg;function ai(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?ln.default.this:Ve.nil;n?l():p();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let f=o.let("valid");o.try(()=>{o.code((0,Ve._)`await ${(0,$g.callValidateCode)(t,e,u)}`),h(e),i||o.assign(f,!0)},_=>{o.if((0,Ve._)`!(${_} instanceof ${s.ValidationError})`,()=>o.throw(_)),m(_),i||o.assign(f,!1)}),t.ok(f)}function p(){t.result((0,$g.callValidateCode)(t,e,u),()=>h(e),()=>m(e))}function m(f){let _=(0,Ve._)`${f}.errors`;o.assign(ln.default.vErrors,(0,Ve._)`${ln.default.vErrors} === null ? ${_} : ${ln.default.vErrors}.concat(${_})`),o.assign(ln.default.errors,(0,Ve._)`${ln.default.vErrors}.length`)}function h(f){var _;if(!s.opts.unevaluated)return;let w=(_=r?.validate)===null||_===void 0?void 0:_.evaluated;if(s.props!==!0)if(w&&!w.dynamicProps)w.props!==void 0&&(s.props=ii.mergeEvaluated.props(o,w.props,s.props));else{let k=o.var("props",(0,Ve._)`${f}.evaluated.props`);s.props=ii.mergeEvaluated.props(o,k,s.props,Ve.Name)}if(s.items!==!0)if(w&&!w.dynamicItems)w.items!==void 0&&(s.items=ii.mergeEvaluated.items(o,w.items,s.items));else{let k=o.var("items",(0,Ve._)`${f}.evaluated.items`);s.items=ii.mergeEvaluated.items(o,k,s.items,Ve.Name)}}}vr.callRef=ai;vr.default=Wk});var zg=P(hl=>{"use strict";d();Object.defineProperty(hl,"__esModule",{value:!0});var Yk=xg(),Xk=Tg(),Qk=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Yk.default,Xk.default];hl.default=Qk});var Pg=P(gl=>{"use strict";d();Object.defineProperty(gl,"__esModule",{value:!0});var ci=B(),Wt=ci.operators,ui={maximum:{okStr:"<=",ok:Wt.LTE,fail:Wt.GT},minimum:{okStr:">=",ok:Wt.GTE,fail:Wt.LT},exclusiveMaximum:{okStr:"<",ok:Wt.LT,fail:Wt.GTE},exclusiveMinimum:{okStr:">",ok:Wt.GT,fail:Wt.LTE}},eS={message:({keyword:t,schemaCode:e})=>(0,ci.str)`must be ${ui[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ci._)`{comparison: ${ui[t].okStr}, limit: ${e}}`},tS={keyword:Object.keys(ui),type:"number",schemaType:"number",$data:!0,error:eS,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,ci._)`${r} ${ui[e].fail} ${n} || isNaN(${r})`)}};gl.default=tS});var Ig=P(_l=>{"use strict";d();Object.defineProperty(_l,"__esModule",{value:!0});var ko=B(),rS={message:({schemaCode:t})=>(0,ko.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,ko._)`{multipleOf: ${t}}`},nS={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:rS,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,ko._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,ko._)`${i} !== parseInt(${i})`;t.fail$data((0,ko._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};_l.default=nS});var Rg=P(yl=>{"use strict";d();Object.defineProperty(yl,"__esModule",{value:!0});function Eg(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}yl.default=Eg;Eg.code='require("ajv/dist/runtime/ucs2length").default'});var Cg=P(vl=>{"use strict";d();Object.defineProperty(vl,"__esModule",{value:!0});var br=B(),oS=Q(),sS=Rg(),iS={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,br.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,br._)`{limit: ${t}}`},aS={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:iS,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?br.operators.GT:br.operators.LT,i=o.opts.unicode===!1?(0,br._)`${r}.length`:(0,br._)`${(0,oS.useFunc)(t.gen,sS.default)}(${r})`;t.fail$data((0,br._)`${i} ${s} ${n}`)}};vl.default=aS});var Zg=P(bl=>{"use strict";d();Object.defineProperty(bl,"__esModule",{value:!0});var cS=tt(),uS=Q(),dn=B(),lS={message:({schemaCode:t})=>(0,dn.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,dn._)`{pattern: ${t}}`},dS={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:lS,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,dn._)`new RegExp`:(0,uS.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,dn._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,dn._)`!${l}`)}else{let c=(0,cS.usePattern)(t,o);t.fail$data((0,dn._)`!${c}.test(${r})`)}}};bl.default=dS});var Og=P(wl=>{"use strict";d();Object.defineProperty(wl,"__esModule",{value:!0});var So=B(),pS={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,So.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,So._)`{limit: ${t}}`},fS={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:pS,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?So.operators.GT:So.operators.LT;t.fail$data((0,So._)`Object.keys(${r}).length ${o} ${n}`)}};wl.default=fS});var jg=P(xl=>{"use strict";d();Object.defineProperty(xl,"__esModule",{value:!0});var To=tt(),zo=B(),mS=Q(),hS={message:({params:{missingProperty:t}})=>(0,zo.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,zo._)`{missingProperty: ${t}}`},gS={keyword:"required",type:"object",schemaType:"array",$data:!0,error:hS,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let h=t.parentSchema.properties,{definedProperties:f}=t.it;for(let _ of r)if(h?.[_]===void 0&&!f.has(_)){let w=i.schemaEnv.baseId+i.errSchemaPath,k=`required property "${_}" is not defined at "${w}" (strictRequired)`;(0,mS.checkStrictMode)(i,k,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(zo.nil,p);else for(let h of r)(0,To.checkReportMissingProp)(t,h)}function l(){let h=e.let("missing");if(c||s){let f=e.let("valid",!0);t.block$data(f,()=>m(h,f)),t.ok(f)}else e.if((0,To.checkMissingProp)(t,r,h)),(0,To.reportMissingProp)(t,h),e.else()}function p(){e.forOf("prop",n,h=>{t.setParams({missingProperty:h}),e.if((0,To.noPropertyInData)(e,o,h,a.ownProperties),()=>t.error())})}function m(h,f){t.setParams({missingProperty:h}),e.forOf(h,n,()=>{e.assign(f,(0,To.propertyInData)(e,o,h,a.ownProperties)),e.if((0,zo.not)(f),()=>{t.error(),e.break()})},zo.nil)}}};xl.default=gS});var Ag=P($l=>{"use strict";d();Object.defineProperty($l,"__esModule",{value:!0});var Po=B(),_S={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Po.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Po._)`{limit: ${t}}`},yS={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:_S,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?Po.operators.GT:Po.operators.LT;t.fail$data((0,Po._)`${r}.length ${o} ${n}`)}};$l.default=yS});var li=P(kl=>{"use strict";d();Object.defineProperty(kl,"__esModule",{value:!0});var Ng=Ku();Ng.code='require("ajv/dist/runtime/equal").default';kl.default=Ng});var Mg=P(Tl=>{"use strict";d();Object.defineProperty(Tl,"__esModule",{value:!0});var Sl=mo(),ze=B(),vS=Q(),bS=li(),wS={message:({params:{i:t,j:e}})=>(0,ze.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ze._)`{i: ${t}, j: ${e}}`},xS={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:wS,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,Sl.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,ze._)`${i} === false`),t.ok(c);function l(){let f=e.let("i",(0,ze._)`${r}.length`),_=e.let("j");t.setParams({i:f,j:_}),e.assign(c,!0),e.if((0,ze._)`${f} > 1`,()=>(p()?m:h)(f,_))}function p(){return u.length>0&&!u.some(f=>f==="object"||f==="array")}function m(f,_){let w=e.name("item"),k=(0,Sl.checkDataTypes)(u,w,a.opts.strictNumbers,Sl.DataType.Wrong),S=e.const("indices",(0,ze._)`{}`);e.for((0,ze._)`;${f}--;`,()=>{e.let(w,(0,ze._)`${r}[${f}]`),e.if(k,(0,ze._)`continue`),u.length>1&&e.if((0,ze._)`typeof ${w} == "string"`,(0,ze._)`${w} += "_"`),e.if((0,ze._)`typeof ${S}[${w}] == "number"`,()=>{e.assign(_,(0,ze._)`${S}[${w}]`),t.error(),e.assign(c,!1).break()}).code((0,ze._)`${S}[${w}] = ${f}`)})}function h(f,_){let w=(0,vS.useFunc)(e,bS.default),k=e.name("outer");e.label(k).for((0,ze._)`;${f}--;`,()=>e.for((0,ze._)`${_} = ${f}; ${_}--;`,()=>e.if((0,ze._)`${w}(${r}[${f}], ${r}[${_}])`,()=>{t.error(),e.assign(c,!1).break(k)})))}}};Tl.default=xS});var Dg=P(Pl=>{"use strict";d();Object.defineProperty(Pl,"__esModule",{value:!0});var zl=B(),$S=Q(),kS=li(),SS={message:"must be equal to constant",params:({schemaCode:t})=>(0,zl._)`{allowedValue: ${t}}`},TS={keyword:"const",$data:!0,error:SS,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,zl._)`!${(0,$S.useFunc)(e,kS.default)}(${r}, ${o})`):t.fail((0,zl._)`${s} !== ${r}`)}};Pl.default=TS});var qg=P(Il=>{"use strict";d();Object.defineProperty(Il,"__esModule",{value:!0});var Io=B(),zS=Q(),PS=li(),IS={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Io._)`{allowedValues: ${t}}`},ES={keyword:"enum",schemaType:"array",$data:!0,error:IS,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,zS.useFunc)(e,PS.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,p);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let h=e.const("vSchema",s);l=(0,Io.or)(...o.map((f,_)=>m(h,_)))}t.pass(l);function p(){e.assign(l,!1),e.forOf("v",s,h=>e.if((0,Io._)`${u()}(${r}, ${h})`,()=>e.assign(l,!0).break()))}function m(h,f){let _=o[f];return typeof _=="object"&&_!==null?(0,Io._)`${u()}(${r}, ${h}[${f}])`:(0,Io._)`${r} === ${_}`}}};Il.default=ES});var Lg=P(El=>{"use strict";d();Object.defineProperty(El,"__esModule",{value:!0});var RS=Pg(),CS=Ig(),ZS=Cg(),OS=Zg(),jS=Og(),AS=jg(),NS=Ag(),MS=Mg(),DS=Dg(),qS=qg(),LS=[RS.default,CS.default,ZS.default,OS.default,jS.default,AS.default,NS.default,MS.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},DS.default,qS.default];El.default=LS});var Cl=P(Eo=>{"use strict";d();Object.defineProperty(Eo,"__esModule",{value:!0});Eo.validateAdditionalItems=void 0;var wr=B(),Rl=Q(),US={message:({params:{len:t}})=>(0,wr.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,wr._)`{limit: ${t}}`},VS={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:US,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Rl.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Ug(t,n)}};function Ug(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,wr._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,wr._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Rl.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,wr._)`${a} <= ${e.length}`);r.if((0,wr.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:Rl.Type.Num},u),i.allErrors||r.if((0,wr.not)(u),()=>r.break())})}}Eo.validateAdditionalItems=Ug;Eo.default=VS});var Zl=P(Ro=>{"use strict";d();Object.defineProperty(Ro,"__esModule",{value:!0});Ro.validateTuple=void 0;var Vg=B(),di=Q(),FS=tt(),HS={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Fg(t,"additionalItems",e);r.items=!0,!(0,di.alwaysValidSchema)(r,e)&&t.ok((0,FS.validateArray)(t))}};function Fg(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=di.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Vg._)`${s}.length`);r.forEach((p,m)=>{(0,di.alwaysValidSchema)(a,p)||(n.if((0,Vg._)`${u} > ${m}`,()=>t.subschema({keyword:i,schemaProp:m,dataProp:m},c)),t.ok(c))});function l(p){let{opts:m,errSchemaPath:h}=a,f=r.length,_=f===p.minItems&&(f===p.maxItems||p[e]===!1);if(m.strictTuples&&!_){let w=`"${i}" is ${f}-tuple, but minItems or maxItems/${e} are not specified or different at path "${h}"`;(0,di.checkStrictMode)(a,w,m.strictTuples)}}}Ro.validateTuple=Fg;Ro.default=HS});var Hg=P(Ol=>{"use strict";d();Object.defineProperty(Ol,"__esModule",{value:!0});var BS=Zl(),JS={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,BS.validateTuple)(t,"items")};Ol.default=JS});var Jg=P(jl=>{"use strict";d();Object.defineProperty(jl,"__esModule",{value:!0});var Bg=B(),KS=Q(),GS=tt(),WS=Cl(),YS={message:({params:{len:t}})=>(0,Bg.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Bg._)`{limit: ${t}}`},XS={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:YS,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,KS.alwaysValidSchema)(n,e)&&(o?(0,WS.validateAdditionalItems)(t,o):t.ok((0,GS.validateArray)(t)))}};jl.default=XS});var Kg=P(Al=>{"use strict";d();Object.defineProperty(Al,"__esModule",{value:!0});var nt=B(),pi=Q(),QS={message:({params:{min:t,max:e}})=>e===void 0?(0,nt.str)`must contain at least ${t} valid item(s)`:(0,nt.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,nt._)`{minContains: ${t}}`:(0,nt._)`{minContains: ${t}, maxContains: ${e}}`},eT={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:QS,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,nt._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,pi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,pi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,pi.alwaysValidSchema)(s,r)){let _=(0,nt._)`${l} >= ${i}`;a!==void 0&&(_=(0,nt._)`${_} && ${l} <= ${a}`),t.pass(_);return}s.items=!0;let p=e.name("valid");a===void 0&&i===1?h(p,()=>e.if(p,()=>e.break())):i===0?(e.let(p,!0),a!==void 0&&e.if((0,nt._)`${o}.length > 0`,m)):(e.let(p,!1),m()),t.result(p,()=>t.reset());function m(){let _=e.name("_valid"),w=e.let("count",0);h(_,()=>e.if(_,()=>f(w)))}function h(_,w){e.forRange("i",0,l,k=>{t.subschema({keyword:"contains",dataProp:k,dataPropType:pi.Type.Num,compositeRule:!0},_),w()})}function f(_){e.code((0,nt._)`${_}++`),a===void 0?e.if((0,nt._)`${_} >= ${i}`,()=>e.assign(p,!0).break()):(e.if((0,nt._)`${_} > ${a}`,()=>e.assign(p,!1).break()),i===1?e.assign(p,!0):e.if((0,nt._)`${_} >= ${i}`,()=>e.assign(p,!0)))}}};Al.default=eT});var Yg=P(bt=>{"use strict";d();Object.defineProperty(bt,"__esModule",{value:!0});bt.validateSchemaDeps=bt.validatePropertyDeps=bt.error=void 0;var Nl=B(),tT=Q(),Co=tt();bt.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Nl.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Nl._)`{property: ${t},
|
|
6
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,H._)`[${o}]`)}}}function Ax({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,H._)`${e} !== undefined`,()=>t.assign((0,H._)`${e}[${r}]`,n))}function Uu(t,e,r,n=on.Correct){let o=n===on.Correct?H.operators.EQ:H.operators.NEQ,s;switch(t){case"null":return(0,H._)`${e} ${o} null`;case"array":s=(0,H._)`Array.isArray(${e})`;break;case"object":s=(0,H._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,H._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,H._)`typeof ${e} ${o} ${t}`}return n===on.Correct?s:(0,H.not)(s);function i(a=H.nil){return(0,H.and)((0,H._)`typeof ${e} == "number"`,a,r?(0,H._)`isFinite(${e})`:H.nil)}}Ee.checkDataType=Uu;function Vu(t,e,r,n){if(t.length===1)return Uu(t[0],e,r,n);let o,s=(0,bh.toHash)(t);if(s.array&&s.object){let i=(0,H._)`typeof ${e} != "object"`;o=s.null?i:(0,H._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=H.nil;s.number&&delete s.integer;for(let i in s)o=(0,H.and)(o,Uu(i,e,r,n));return o}Ee.checkDataTypes=Vu;var Nx={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,H._)`{type: ${t}}`:(0,H._)`{type: ${e}}`};function Fu(t){let e=Mx(t);(0,Rx.reportError)(e,Nx)}Ee.reportTypeError=Fu;function Mx(t){let{gen:e,data:r,schema:n}=t,o=(0,bh.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var $h=P(Ks=>{"use strict";d();Object.defineProperty(Ks,"__esModule",{value:!0});Ks.assignDefaults=void 0;var sn=B(),Dx=Q();function qx(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)kh(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>kh(t,s,o.default))}Ks.assignDefaults=qx;function kh(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,sn._)`${s}${(0,sn.getProperty)(e)}`;if(o){(0,Dx.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,sn._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,sn._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,sn._)`${a} = ${(0,sn.stringify)(r)}`)}});var tt=P(se=>{"use strict";d();Object.defineProperty(se,"__esModule",{value:!0});se.validateUnion=se.validateArray=se.usePattern=se.callValidateCode=se.schemaProperties=se.allSchemaProperties=se.noPropertyInData=se.propertyInData=se.isOwnProperty=se.hasPropFunc=se.reportMissingProp=se.checkMissingProp=se.checkReportMissingProp=void 0;var pe=B(),Hu=Q(),Bt=Rt(),Lx=Q();function Ux(t,e){let{gen:r,data:n,it:o}=t;r.if(Ju(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,pe._)`${e}`},!0),t.error()})}se.checkReportMissingProp=Ux;function Vx({gen:t,data:e,it:{opts:r}},n,o){return(0,pe.or)(...n.map(s=>(0,pe.and)(Ju(t,e,s,r.ownProperties),(0,pe._)`${o} = ${s}`)))}se.checkMissingProp=Vx;function Fx(t,e){t.setParams({missingProperty:e},!0),t.error()}se.reportMissingProp=Fx;function Sh(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,pe._)`Object.prototype.hasOwnProperty`})}se.hasPropFunc=Sh;function Bu(t,e,r){return(0,pe._)`${Sh(t)}.call(${e}, ${r})`}se.isOwnProperty=Bu;function Hx(t,e,r,n){let o=(0,pe._)`${e}${(0,pe.getProperty)(r)} !== undefined`;return n?(0,pe._)`${o} && ${Bu(t,e,r)}`:o}se.propertyInData=Hx;function Ju(t,e,r,n){let o=(0,pe._)`${e}${(0,pe.getProperty)(r)} === undefined`;return n?(0,pe.or)(o,(0,pe.not)(Bu(t,e,r))):o}se.noPropertyInData=Ju;function Th(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}se.allSchemaProperties=Th;function Bx(t,e){return Th(e).filter(r=>!(0,Hu.alwaysValidSchema)(t,e[r]))}se.schemaProperties=Bx;function Jx({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,pe._)`${t}, ${e}, ${n}${o}`:e,p=[[Bt.default.instancePath,(0,pe.strConcat)(Bt.default.instancePath,s)],[Bt.default.parentData,i.parentData],[Bt.default.parentDataProperty,i.parentDataProperty],[Bt.default.rootData,Bt.default.rootData]];i.opts.dynamicRef&&p.push([Bt.default.dynamicAnchors,Bt.default.dynamicAnchors]);let m=(0,pe._)`${l}, ${r.object(...p)}`;return c!==pe.nil?(0,pe._)`${a}.call(${c}, ${m})`:(0,pe._)`${a}(${m})`}se.callValidateCode=Jx;var Kx=(0,pe._)`new RegExp`;function Gx({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,pe._)`${o.code==="new RegExp"?Kx:(0,Lx.useFunc)(t,o)}(${r}, ${n})`})}se.usePattern=Gx;function Wx(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,pe._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:Hu.Type.Num},s),e.if((0,pe.not)(s),a)})}}se.validateArray=Wx;function Yx(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Hu.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,pe._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,pe.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}se.validateUnion=Yx});var Ih=P(_t=>{"use strict";d();Object.defineProperty(_t,"__esModule",{value:!0});_t.validateKeywordUsage=_t.validSchemaType=_t.funcKeywordCode=_t.macroKeywordCode=void 0;var Ae=B(),_r=Rt(),Xx=tt(),Qx=fo();function ek(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=Ph(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:Ae.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}_t.macroKeywordCode=ek;function tk(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;nk(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=Ph(n,o,u),p=n.let("valid");t.block$data(p,m),t.ok((r=e.valid)!==null&&r!==void 0?r:p);function m(){if(e.errors===!1)_(),e.modifying&&zh(t),w(()=>t.error());else{let $=e.async?h():f();e.modifying&&zh(t),w(()=>rk(t,$))}}function h(){let $=n.let("ruleErrs",null);return n.try(()=>_((0,Ae._)`await `),S=>n.assign(p,!1).if((0,Ae._)`${S} instanceof ${c.ValidationError}`,()=>n.assign($,(0,Ae._)`${S}.errors`),()=>n.throw(S))),$}function f(){let $=(0,Ae._)`${l}.errors`;return n.assign($,null),_(Ae.nil),$}function _($=e.async?(0,Ae._)`await `:Ae.nil){let S=c.opts.passContext?_r.default.this:_r.default.self,T=!("compile"in e&&!a||e.schema===!1);n.assign(p,(0,Ae._)`${$}${(0,Xx.callValidateCode)(t,l,S,T)}`,e.modifying)}function w($){var S;n.if((0,Ae.not)((S=e.valid)!==null&&S!==void 0?S:p),$)}}_t.funcKeywordCode=tk;function zh(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Ae._)`${n.parentData}[${n.parentDataProperty}]`))}function rk(t,e){let{gen:r}=t;r.if((0,Ae._)`Array.isArray(${e})`,()=>{r.assign(_r.default.vErrors,(0,Ae._)`${_r.default.vErrors} === null ? ${e} : ${_r.default.vErrors}.concat(${e})`).assign(_r.default.errors,(0,Ae._)`${_r.default.vErrors}.length`),(0,Qx.extendErrors)(t)},()=>t.error())}function nk({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Ph(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Ae.stringify)(r)})}function ok(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}_t.validSchemaType=ok;function sk({schema:t,opts:e,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}_t.validateKeywordUsage=sk});var Rh=P(Jt=>{"use strict";d();Object.defineProperty(Jt,"__esModule",{value:!0});Jt.extendSubschemaMode=Jt.extendSubschemaData=Jt.getSubschema=void 0;var yt=B(),Eh=Q();function ik(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,yt._)`${t.schemaPath}${(0,yt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,yt._)`${t.schemaPath}${(0,yt.getProperty)(e)}${(0,yt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Eh.escapeFragment)(r)}`}}if(n!==void 0){if(o===void 0||s===void 0||i===void 0)throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"');return{schema:n,schemaPath:o,topSchemaRef:i,errSchemaPath:s}}throw new Error('either "keyword" or "schema" must be passed')}Jt.getSubschema=ik;function ak(t,e,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:p}=e,m=a.let("data",(0,yt._)`${e.data}${(0,yt.getProperty)(r)}`,!0);c(m),t.errorPath=(0,yt.str)`${u}${(0,Eh.getErrorPath)(r,n,p.jsPropertySyntax)}`,t.parentDataProperty=(0,yt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof yt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Jt.extendSubschemaData=ak;function ck(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Jt.extendSubschemaMode=ck});var Ku=P((Lj,Ch)=>{"use strict";d();Ch.exports=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,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))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(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Oh=P((Vj,Zh)=>{"use strict";d();var Kt=Zh.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Gs(e,n,o,t,"",t)};Kt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Kt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Kt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Kt.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 Gs(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var p=n[l];if(Array.isArray(p)){if(l in Kt.arrayKeywords)for(var m=0;m<p.length;m++)Gs(t,e,r,p[m],o+"/"+l+"/"+m,s,o,l,n,m)}else if(l in Kt.propsKeywords){if(p&&typeof p=="object")for(var h in p)Gs(t,e,r,p[h],o+"/"+l+"/"+uk(h),s,o,l,n,h)}else(l in Kt.keywords||t.allKeys&&!(l in Kt.skipKeywords))&&Gs(t,e,r,p,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function uk(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var ho=P(Ue=>{"use strict";d();Object.defineProperty(Ue,"__esModule",{value:!0});Ue.getSchemaRefs=Ue.resolveUrl=Ue.normalizeId=Ue._getFullPath=Ue.getFullPath=Ue.inlineRef=void 0;var lk=Q(),dk=Ku(),pk=Oh(),fk=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function mk(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Gu(t):e?jh(t)<=e:!1}Ue.inlineRef=mk;var hk=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Gu(t){for(let e in t){if(hk.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Gu)||typeof r=="object"&&Gu(r))return!0}return!1}function jh(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!fk.has(r)&&(typeof t[r]=="object"&&(0,lk.eachItem)(t[r],n=>e+=jh(n)),e===1/0))return 1/0}return e}function Ah(t,e="",r){r!==!1&&(e=an(e));let n=t.parse(e);return Nh(t,n)}Ue.getFullPath=Ah;function Nh(t,e){return t.serialize(e).split("#")[0]+"#"}Ue._getFullPath=Nh;var gk=/#\/?$/;function an(t){return t?t.replace(gk,""):""}Ue.normalizeId=an;function _k(t,e,r){return r=an(r),t.resolve(e,r)}Ue.resolveUrl=_k;var yk=/^[a-z_][-a-z0-9._]*$/i;function vk(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=an(t[r]||e),s={"":o},i=Ah(n,o,!1),a={},c=new Set;return pk(t,{allKeys:!0},(p,m,h,f)=>{if(f===void 0)return;let _=i+m,w=s[f];typeof p[r]=="string"&&(w=$.call(this,p[r])),S.call(this,p.$anchor),S.call(this,p.$dynamicAnchor),s[m]=w;function $(T){let R=this.opts.uriResolver.resolve;if(T=an(w?R(w,T):T),c.has(T))throw l(T);c.add(T);let N=this.refs[T];return typeof N=="string"&&(N=this.refs[N]),typeof N=="object"?u(p,N.schema,T):T!==an(_)&&(T[0]==="#"?(u(p,a[T],T),a[T]=p):this.refs[T]=_),T}function S(T){if(typeof T=="string"){if(!yk.test(T))throw new Error(`invalid anchor "${T}"`);$.call(this,`#${T}`)}}}),a;function u(p,m,h){if(m!==void 0&&!dk(p,m))throw l(h)}function l(p){return new Error(`reference "${p}" resolves to more than one schema`)}}Ue.getSchemaRefs=vk});var yo=P(Gt=>{"use strict";d();Object.defineProperty(Gt,"__esModule",{value:!0});Gt.getData=Gt.KeywordCxt=Gt.validateFunctionCode=void 0;var Uh=_h(),Mh=mo(),Yu=Lu(),Ws=mo(),bk=$h(),_o=Ih(),Wu=Rh(),O=B(),L=Rt(),wk=ho(),Ct=Q(),go=fo();function xk(t){if(Hh(t)&&(Bh(t),Fh(t))){Sk(t);return}Vh(t,()=>(0,Uh.topBoolOrEmptySchema)(t))}Gt.validateFunctionCode=xk;function Vh({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,O._)`${L.default.data}, ${L.default.valCxt}`,n.$async,()=>{t.code((0,O._)`"use strict"; ${Dh(r,o)}`),$k(t,o),t.code(s)}):t.func(e,(0,O._)`${L.default.data}, ${kk(o)}`,n.$async,()=>t.code(Dh(r,o)).code(s))}function kk(t){return(0,O._)`{${L.default.instancePath}="", ${L.default.parentData}, ${L.default.parentDataProperty}, ${L.default.rootData}=${L.default.data}${t.dynamicRef?(0,O._)`, ${L.default.dynamicAnchors}={}`:O.nil}}={}`}function $k(t,e){t.if(L.default.valCxt,()=>{t.var(L.default.instancePath,(0,O._)`${L.default.valCxt}.${L.default.instancePath}`),t.var(L.default.parentData,(0,O._)`${L.default.valCxt}.${L.default.parentData}`),t.var(L.default.parentDataProperty,(0,O._)`${L.default.valCxt}.${L.default.parentDataProperty}`),t.var(L.default.rootData,(0,O._)`${L.default.valCxt}.${L.default.rootData}`),e.dynamicRef&&t.var(L.default.dynamicAnchors,(0,O._)`${L.default.valCxt}.${L.default.dynamicAnchors}`)},()=>{t.var(L.default.instancePath,(0,O._)`""`),t.var(L.default.parentData,(0,O._)`undefined`),t.var(L.default.parentDataProperty,(0,O._)`undefined`),t.var(L.default.rootData,L.default.data),e.dynamicRef&&t.var(L.default.dynamicAnchors,(0,O._)`{}`)})}function Sk(t){let{schema:e,opts:r,gen:n}=t;Vh(t,()=>{r.$comment&&e.$comment&&Kh(t),Ek(t),n.let(L.default.vErrors,null),n.let(L.default.errors,0),r.unevaluated&&Tk(t),Jh(t),Zk(t)})}function Tk(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,O._)`${r}.evaluated`),e.if((0,O._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,O._)`${t.evaluated}.props`,(0,O._)`undefined`)),e.if((0,O._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,O._)`${t.evaluated}.items`,(0,O._)`undefined`))}function Dh(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,O._)`/*# sourceURL=${r} */`:O.nil}function zk(t,e){if(Hh(t)&&(Bh(t),Fh(t))){Pk(t,e);return}(0,Uh.boolOrEmptySchema)(t,e)}function Fh({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function Hh(t){return typeof t.schema!="boolean"}function Pk(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&Kh(t),Rk(t),Ck(t);let s=n.const("_errs",L.default.errors);Jh(t,s),n.var(e,(0,O._)`${s} === ${L.default.errors}`)}function Bh(t){(0,Ct.checkUnknownRules)(t),Ik(t)}function Jh(t,e){if(t.opts.jtd)return qh(t,[],!1,e);let r=(0,Mh.getSchemaTypes)(t.schema),n=(0,Mh.coerceAndCheckDataType)(t,r);qh(t,r,!n,e)}function Ik(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Ct.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Ek(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ct.checkStrictMode)(t,"default is ignored in the schema root")}function Rk(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,wk.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function Ck(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Kh({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,O._)`${L.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,O.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,O._)`${L.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function Zk(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,O._)`${L.default.errors} === 0`,()=>e.return(L.default.data),()=>e.throw((0,O._)`new ${o}(${L.default.vErrors})`)):(e.assign((0,O._)`${n}.errors`,L.default.vErrors),s.unevaluated&&Ok(t),e.return((0,O._)`${L.default.errors} === 0`))}function Ok({gen:t,evaluated:e,props:r,items:n}){r instanceof O.Name&&t.assign((0,O._)`${e}.props`,r),n instanceof O.Name&&t.assign((0,O._)`${e}.items`,n)}function qh(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Ct.schemaHasRulesButRef)(s,l))){o.block(()=>Wh(t,"$ref",l.all.$ref.definition));return}c.jtd||jk(t,e),o.block(()=>{for(let m of l.rules)p(m);p(l.post)});function p(m){(0,Yu.shouldUseGroup)(s,m)&&(m.type?(o.if((0,Ws.checkDataType)(m.type,i,c.strictNumbers)),Lh(t,m),e.length===1&&e[0]===m.type&&r&&(o.else(),(0,Ws.reportTypeError)(t)),o.endIf()):Lh(t,m),a||o.if((0,O._)`${L.default.errors} === ${n||0}`))}}function Lh(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,bk.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Yu.shouldUseRule)(n,s)&&Wh(t,s.keyword,s.definition,e.type)})}function jk(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Ak(t,e),t.opts.allowUnionTypes||Nk(t,e),Mk(t,t.dataTypes))}function Ak(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Gh(t.dataTypes,r)||Xu(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),qk(t,e)}}function Nk(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Xu(t,"use allowUnionTypes to allow union type keyword")}function Mk(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Yu.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Dk(e,i))&&Xu(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Dk(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Gh(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function qk(t,e){let r=[];for(let n of t.dataTypes)Gh(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Xu(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ct.checkStrictMode)(t,e,t.opts.strictTypes)}var Ys=class{constructor(e,r,n){if((0,_o.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Ct.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",Yh(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,_o.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",L.default.errors))}result(e,r,n){this.failResult((0,O.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,O.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,O._)`${r} !== undefined && (${(0,O.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?go.reportExtraError:go.reportError)(this,this.def.error,r)}$dataError(){(0,go.reportError)(this,this.def.$dataError||go.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,go.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=O.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=O.nil,r=O.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,O.or)((0,O._)`${o} === undefined`,r)),e!==O.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==O.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,O.or)(i(),a());function i(){if(n.length){if(!(r instanceof O.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,O._)`${(0,Ws.checkDataTypes)(c,r,s.opts.strictNumbers,Ws.DataType.Wrong)}`}return O.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,O._)`!${c}(${r})`}return O.nil}}subschema(e,r){let n=(0,Wu.getSubschema)(this.it,e);(0,Wu.extendSubschemaData)(n,this.it,e),(0,Wu.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return zk(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Ct.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Ct.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,O.Name)),!0}};Gt.KeywordCxt=Ys;function Wh(t,e,r,n){let o=new Ys(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,_o.funcKeywordCode)(o,r):"macro"in r?(0,_o.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,_o.funcKeywordCode)(o,r)}var Lk=/^\/(?:[^~]|~0|~1)*$/,Uk=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Yh(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return L.default.rootData;if(t[0]==="/"){if(!Lk.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=L.default.rootData}else{let u=Uk.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,O._)`${s}${(0,O.getProperty)((0,Ct.unescapeJsonPointer)(u))}`,i=(0,O._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}Gt.getData=Yh});var Xs=P(el=>{"use strict";d();Object.defineProperty(el,"__esModule",{value:!0});var Qu=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};el.default=Qu});var vo=P(nl=>{"use strict";d();Object.defineProperty(nl,"__esModule",{value:!0});var tl=ho(),rl=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,tl.resolveUrl)(e,r,n),this.missingSchema=(0,tl.normalizeId)((0,tl.getFullPath)(e,this.missingRef))}};nl.default=rl});var ei=P(rt=>{"use strict";d();Object.defineProperty(rt,"__esModule",{value:!0});rt.resolveSchema=rt.getCompilingSchema=rt.resolveRef=rt.compileSchema=rt.SchemaEnv=void 0;var dt=B(),Vk=Xs(),yr=Rt(),pt=ho(),Xh=Q(),Fk=yo(),cn=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,pt.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};rt.SchemaEnv=cn;function sl(t){let e=Qh.call(this,t);if(e)return e;let r=(0,pt.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new dt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:Vk.default,code:(0,dt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:yr.default.data,parentData:yr.default.parentData,parentDataProperty:yr.default.parentDataProperty,dataNames:[yr.default.data],dataPathArr:[dt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,dt.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:dt.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,dt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,Fk.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let p=i.toString();l=`${i.scopeRefs(yr.default.scope)}return ${p}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let h=new Function(`${yr.default.self}`,`${yr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:h}),h.errors=null,h.schema=t.schema,h.schemaEnv=t,t.$async&&(h.$async=!0),this.opts.code.source===!0&&(h.source={validateName:c,validateCode:p,scopeValues:i._values}),this.opts.unevaluated){let{props:f,items:_}=u;h.evaluated={props:f instanceof dt.Name?void 0:f,items:_ instanceof dt.Name?void 0:_,dynamicProps:f instanceof dt.Name,dynamicItems:_ instanceof dt.Name},h.source&&(h.source.evaluated=(0,dt.stringify)(h.evaluated))}return t.validate=h,t}catch(p){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),p}finally{this._compilations.delete(t)}}rt.compileSchema=sl;function Hk(t,e,r){var n;r=(0,pt.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Kk.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new cn({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=Bk.call(this,s)}rt.resolveRef=Hk;function Bk(t){return(0,pt.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:sl.call(this,t)}function Qh(t){for(let e of this._compilations)if(Jk(e,t))return e}rt.getCompilingSchema=Qh;function Jk(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Kk(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Qs.call(this,t,e)}function Qs(t,e){let r=this.opts.uriResolver.parse(e),n=(0,pt._getFullPath)(this.opts.uriResolver,r),o=(0,pt.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return ol.call(this,r,t);let s=(0,pt.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Qs.call(this,t,i);return typeof a?.schema!="object"?void 0:ol.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||sl.call(this,i),s===(0,pt.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,pt.resolveUrl)(this.opts.uriResolver,o,u)),new cn({schema:a,schemaId:c,root:t,baseId:o})}return ol.call(this,r,i)}}rt.resolveSchema=Qs;var Gk=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function ol(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Xh.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Gk.has(a)&&u&&(e=(0,pt.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Xh.schemaHasRulesButRef)(r,this.RULES)){let a=(0,pt.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=Qs.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new cn({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var eg=P((tA,Wk)=>{Wk.exports={$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON AnySchema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1}});var al=P((rA,og)=>{"use strict";d();var Yk=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),rg=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 il(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var Xk=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function tg(t){return t.length=0,!0}function Qk(t,e,r){if(t.length){let n=il(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function e$(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=Qk;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=tg}else{o.push(u);continue}}return o.length&&(a===tg?r.zone=o.join(""):i?n.push(o.join("")):n.push(il(o))),r.address=n.join(""),r}function ng(t){if(t$(t,":")<2)return{host:t,isIPV6:!1};let e=e$(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function t$(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function r$(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}function n$(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function o$(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!rg(r)){let n=ng(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}og.exports={nonSimpleDomain:Xk,recomposeAuthority:o$,normalizeComponentEncoding:n$,removeDotSegments:r$,isIPv4:rg,isUUID:Yk,normalizeIPv6:ng,stringArrayToHexStripped:il}});var ug=P((oA,cg)=>{"use strict";d();var{isUUID:s$}=al(),i$=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,a$=["http","https","ws","wss","urn","urn:uuid"];function c$(t){return a$.indexOf(t)!==-1}function cl(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function sg(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function ig(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function u$(t){return t.secure=cl(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function l$(t){if((t.port===(cl(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function d$(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(i$);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=ul(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function p$(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=ul(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function f$(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!s$(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function m$(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var ag={scheme:"http",domainHost:!0,parse:sg,serialize:ig},h$={scheme:"https",domainHost:ag.domainHost,parse:sg,serialize:ig},ti={scheme:"ws",domainHost:!0,parse:u$,serialize:l$},g$={scheme:"wss",domainHost:ti.domainHost,parse:ti.parse,serialize:ti.serialize},_$={scheme:"urn",parse:d$,serialize:p$,skipNormalize:!0},y$={scheme:"urn:uuid",parse:f$,serialize:m$,skipNormalize:!0},ri={http:ag,https:h$,ws:ti,wss:g$,urn:_$,"urn:uuid":y$};Object.setPrototypeOf(ri,null);function ul(t){return t&&(ri[t]||ri[t.toLowerCase()])||void 0}cg.exports={wsIsSecure:cl,SCHEMES:ri,isValidSchemeName:c$,getSchemeHandler:ul}});var pg=P((iA,oi)=>{"use strict";d();var{normalizeIPv6:v$,removeDotSegments:bo,recomposeAuthority:b$,normalizeComponentEncoding:ni,isIPv4:w$,nonSimpleDomain:x$}=al(),{SCHEMES:k$,getSchemeHandler:lg}=ug();function $$(t,e){return typeof t=="string"?t=vt(Zt(t,e),e):typeof t=="object"&&(t=Zt(vt(t,e),e)),t}function S$(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=dg(Zt(t,n),Zt(e,n),n,!0);return n.skipEscape=!0,vt(o,n)}function dg(t,e,r,n){let o={};return n||(t=Zt(vt(t,r),r),e=Zt(vt(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=bo(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=bo(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=bo(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=bo(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function T$(t,e,r){return typeof t=="string"?(t=unescape(t),t=vt(ni(Zt(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=vt(ni(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=vt(ni(Zt(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=vt(ni(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function vt(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=lg(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=b$(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=bo(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var z$=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function Zt(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let s=t.match(z$);if(s){if(n.scheme=s[1],n.userinfo=s[3],n.host=s[4],n.port=parseInt(s[5],10),n.path=s[6]||"",n.query=s[7],n.fragment=s[8],isNaN(n.port)&&(n.port=s[5]),n.host)if(w$(n.host)===!1){let c=v$(n.host);n.host=c.host.toLowerCase(),o=c.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let i=lg(r.scheme||n.scheme);if(!r.unicodeSupport&&(!i||!i.unicodeSupport)&&n.host&&(r.domainHost||i&&i.domainHost)&&o===!1&&x$(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!i||i&&!i.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),i&&i.parse&&i.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var ll={SCHEMES:k$,normalize:$$,resolve:S$,resolveComponent:dg,equal:T$,serialize:vt,parse:Zt};oi.exports=ll;oi.exports.default=ll;oi.exports.fastUri=ll});var mg=P(dl=>{"use strict";d();Object.defineProperty(dl,"__esModule",{value:!0});var fg=pg();fg.code='require("ajv/dist/runtime/uri").default';dl.default=fg});var xg=P(Te=>{"use strict";d();Object.defineProperty(Te,"__esModule",{value:!0});Te.CodeGen=Te.Name=Te.nil=Te.stringify=Te.str=Te._=Te.KeywordCxt=void 0;var P$=yo();Object.defineProperty(Te,"KeywordCxt",{enumerable:!0,get:function(){return P$.KeywordCxt}});var un=B();Object.defineProperty(Te,"_",{enumerable:!0,get:function(){return un._}});Object.defineProperty(Te,"str",{enumerable:!0,get:function(){return un.str}});Object.defineProperty(Te,"stringify",{enumerable:!0,get:function(){return un.stringify}});Object.defineProperty(Te,"nil",{enumerable:!0,get:function(){return un.nil}});Object.defineProperty(Te,"Name",{enumerable:!0,get:function(){return un.Name}});Object.defineProperty(Te,"CodeGen",{enumerable:!0,get:function(){return un.CodeGen}});var I$=Xs(),vg=vo(),E$=qu(),wo=ei(),R$=B(),xo=ho(),si=mo(),fl=Q(),hg=eg(),C$=mg(),bg=(t,e)=>new RegExp(t,e);bg.code="new RegExp";var Z$=["removeAdditional","useDefaults","coerceTypes"],O$=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),j$={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."},A$={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},gg=200;function N$(t){var e,r,n,o,s,i,a,c,u,l,p,m,h,f,_,w,$,S,T,R,N,Ce,We,Lr,Ui;let Rn=t.strict,Vi=(e=t.code)===null||e===void 0?void 0:e.optimize,Dd=Vi===!0||Vi===void 0?1:Vi||0,qd=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:bg,Yy=(o=t.uriResolver)!==null&&o!==void 0?o:C$.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:Rn)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:Rn)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:Rn)!==null&&l!==void 0?l:"log",strictTuples:(m=(p=t.strictTuples)!==null&&p!==void 0?p:Rn)!==null&&m!==void 0?m:"log",strictRequired:(f=(h=t.strictRequired)!==null&&h!==void 0?h:Rn)!==null&&f!==void 0?f:!1,code:t.code?{...t.code,optimize:Dd,regExp:qd}:{optimize:Dd,regExp:qd},loopRequired:(_=t.loopRequired)!==null&&_!==void 0?_:gg,loopEnum:(w=t.loopEnum)!==null&&w!==void 0?w:gg,meta:($=t.meta)!==null&&$!==void 0?$:!0,messages:(S=t.messages)!==null&&S!==void 0?S:!0,inlineRefs:(T=t.inlineRefs)!==null&&T!==void 0?T:!0,schemaId:(R=t.schemaId)!==null&&R!==void 0?R:"$id",addUsedSchema:(N=t.addUsedSchema)!==null&&N!==void 0?N:!0,validateSchema:(Ce=t.validateSchema)!==null&&Ce!==void 0?Ce:!0,validateFormats:(We=t.validateFormats)!==null&&We!==void 0?We:!0,unicodeRegExp:(Lr=t.unicodeRegExp)!==null&&Lr!==void 0?Lr:!0,int32range:(Ui=t.int32range)!==null&&Ui!==void 0?Ui:!0,uriResolver:Yy}}var ko=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...N$(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new R$.ValueScope({scope:{},prefixes:O$,es5:r,lines:n}),this.logger=V$(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,E$.getRules)(),_g.call(this,j$,e,"NOT SUPPORTED"),_g.call(this,A$,e,"DEPRECATED","warn"),this._metaOpts=L$.call(this),e.formats&&D$.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&q$.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),M$.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=hg;n==="id"&&(o={...hg},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,e,r);async function o(l,p){await s.call(this,l.$schema);let m=this._addSchema(l,p);return m.validate||i.call(this,m)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(p){if(!(p instanceof vg.default))throw p;return a.call(this,p),await c.call(this,p.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:p}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${p} cannot be resolved`)}async function c(l){let p=await u.call(this,l);this.refs[l]||await s.call(this,p.$schema),this.refs[l]||this.addSchema(p,l,r)}async function u(l){let p=this._loading[l];if(p)return p;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,xo.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,e);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(e){let r;for(;typeof(r=yg.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new wo.SchemaEnv({schema:{},schemaId:n});if(r=wo.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=yg.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,xo.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(H$.call(this,n,r),!r)return(0,fl.eachItem)(n,s=>pl.call(this,s)),this;J$.call(this,r);let o={...r,type:(0,si.getJSONTypes)(r.type),schemaType:(0,si.getJSONTypes)(r.schemaType)};return(0,fl.eachItem)(n,o.type.length===0?s=>pl.call(this,s,o):s=>o.type.forEach(i=>pl.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=wg(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,xo.normalizeId)(i||n);let u=xo.getSchemaRefs.call(this,e,n);return c=new wo.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):wo.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{wo.compileSchema.call(this,e)}finally{this.opts=r}}};ko.ValidationError=I$.default;ko.MissingRefError=vg.default;Te.default=ko;function _g(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function yg(t){return t=(0,xo.normalizeId)(t),this.schemas[t]||this.refs[t]}function M$(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function D$(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function q$(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function L$(){let t={...this.opts};for(let e of Z$)delete t[e];return t}var U$={log(){},warn(){},error(){}};function V$(t){if(t===!1)return U$;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var F$=/^[a-z_$][a-z0-9_$:-]*$/i;function H$(t,e){let{RULES:r}=this;if((0,fl.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!F$.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function pl(t,e,r){var n;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,si.getJSONTypes)(e.type),schemaType:(0,si.getJSONTypes)(e.schemaType)}};e.before?B$.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function B$(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function J$(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=wg(e)),t.validateSchema=this.compile(e,!0))}var K$={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function wg(t){return{anyOf:[t,K$]}}});var kg=P(ml=>{"use strict";d();Object.defineProperty(ml,"__esModule",{value:!0});var G$={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ml.default=G$});var zg=P(vr=>{"use strict";d();Object.defineProperty(vr,"__esModule",{value:!0});vr.callRef=vr.getValidate=void 0;var W$=vo(),$g=tt(),Ve=B(),ln=Rt(),Sg=ei(),ii=Q(),Y$={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return p();let l=Sg.resolveRef.call(c,u,o,r);if(l===void 0)throw new W$.default(n.opts.uriResolver,o,r);if(l instanceof Sg.SchemaEnv)return m(l);return h(l);function p(){if(s===u)return ai(t,i,s,s.$async);let f=e.scopeValue("root",{ref:u});return ai(t,(0,Ve._)`${f}.validate`,u,u.$async)}function m(f){let _=Tg(t,f);ai(t,_,f,f.$async)}function h(f){let _=e.scopeValue("schema",a.code.source===!0?{ref:f,code:(0,Ve.stringify)(f)}:{ref:f}),w=e.name("valid"),$=t.subschema({schema:f,dataTypes:[],schemaPath:Ve.nil,topSchemaRef:_,errSchemaPath:r},w);t.mergeEvaluated($),t.ok(w)}}};function Tg(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Ve._)`${r.scopeValue("wrapper",{ref:e})}.validate`}vr.getValidate=Tg;function ai(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?ln.default.this:Ve.nil;n?l():p();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let f=o.let("valid");o.try(()=>{o.code((0,Ve._)`await ${(0,$g.callValidateCode)(t,e,u)}`),h(e),i||o.assign(f,!0)},_=>{o.if((0,Ve._)`!(${_} instanceof ${s.ValidationError})`,()=>o.throw(_)),m(_),i||o.assign(f,!1)}),t.ok(f)}function p(){t.result((0,$g.callValidateCode)(t,e,u),()=>h(e),()=>m(e))}function m(f){let _=(0,Ve._)`${f}.errors`;o.assign(ln.default.vErrors,(0,Ve._)`${ln.default.vErrors} === null ? ${_} : ${ln.default.vErrors}.concat(${_})`),o.assign(ln.default.errors,(0,Ve._)`${ln.default.vErrors}.length`)}function h(f){var _;if(!s.opts.unevaluated)return;let w=(_=r?.validate)===null||_===void 0?void 0:_.evaluated;if(s.props!==!0)if(w&&!w.dynamicProps)w.props!==void 0&&(s.props=ii.mergeEvaluated.props(o,w.props,s.props));else{let $=o.var("props",(0,Ve._)`${f}.evaluated.props`);s.props=ii.mergeEvaluated.props(o,$,s.props,Ve.Name)}if(s.items!==!0)if(w&&!w.dynamicItems)w.items!==void 0&&(s.items=ii.mergeEvaluated.items(o,w.items,s.items));else{let $=o.var("items",(0,Ve._)`${f}.evaluated.items`);s.items=ii.mergeEvaluated.items(o,$,s.items,Ve.Name)}}}vr.callRef=ai;vr.default=Y$});var Pg=P(hl=>{"use strict";d();Object.defineProperty(hl,"__esModule",{value:!0});var X$=kg(),Q$=zg(),eS=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",X$.default,Q$.default];hl.default=eS});var Ig=P(gl=>{"use strict";d();Object.defineProperty(gl,"__esModule",{value:!0});var ci=B(),Wt=ci.operators,ui={maximum:{okStr:"<=",ok:Wt.LTE,fail:Wt.GT},minimum:{okStr:">=",ok:Wt.GTE,fail:Wt.LT},exclusiveMaximum:{okStr:"<",ok:Wt.LT,fail:Wt.GTE},exclusiveMinimum:{okStr:">",ok:Wt.GT,fail:Wt.LTE}},tS={message:({keyword:t,schemaCode:e})=>(0,ci.str)`must be ${ui[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ci._)`{comparison: ${ui[t].okStr}, limit: ${e}}`},rS={keyword:Object.keys(ui),type:"number",schemaType:"number",$data:!0,error:tS,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,ci._)`${r} ${ui[e].fail} ${n} || isNaN(${r})`)}};gl.default=rS});var Eg=P(_l=>{"use strict";d();Object.defineProperty(_l,"__esModule",{value:!0});var $o=B(),nS={message:({schemaCode:t})=>(0,$o.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,$o._)`{multipleOf: ${t}}`},oS={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:nS,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,$o._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,$o._)`${i} !== parseInt(${i})`;t.fail$data((0,$o._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};_l.default=oS});var Cg=P(yl=>{"use strict";d();Object.defineProperty(yl,"__esModule",{value:!0});function Rg(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}yl.default=Rg;Rg.code='require("ajv/dist/runtime/ucs2length").default'});var Zg=P(vl=>{"use strict";d();Object.defineProperty(vl,"__esModule",{value:!0});var br=B(),sS=Q(),iS=Cg(),aS={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,br.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,br._)`{limit: ${t}}`},cS={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:aS,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?br.operators.GT:br.operators.LT,i=o.opts.unicode===!1?(0,br._)`${r}.length`:(0,br._)`${(0,sS.useFunc)(t.gen,iS.default)}(${r})`;t.fail$data((0,br._)`${i} ${s} ${n}`)}};vl.default=cS});var Og=P(bl=>{"use strict";d();Object.defineProperty(bl,"__esModule",{value:!0});var uS=tt(),lS=Q(),dn=B(),dS={message:({schemaCode:t})=>(0,dn.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,dn._)`{pattern: ${t}}`},pS={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:dS,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,dn._)`new RegExp`:(0,lS.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,dn._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,dn._)`!${l}`)}else{let c=(0,uS.usePattern)(t,o);t.fail$data((0,dn._)`!${c}.test(${r})`)}}};bl.default=pS});var jg=P(wl=>{"use strict";d();Object.defineProperty(wl,"__esModule",{value:!0});var So=B(),fS={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,So.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,So._)`{limit: ${t}}`},mS={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:fS,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?So.operators.GT:So.operators.LT;t.fail$data((0,So._)`Object.keys(${r}).length ${o} ${n}`)}};wl.default=mS});var Ag=P(xl=>{"use strict";d();Object.defineProperty(xl,"__esModule",{value:!0});var To=tt(),zo=B(),hS=Q(),gS={message:({params:{missingProperty:t}})=>(0,zo.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,zo._)`{missingProperty: ${t}}`},_S={keyword:"required",type:"object",schemaType:"array",$data:!0,error:gS,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let h=t.parentSchema.properties,{definedProperties:f}=t.it;for(let _ of r)if(h?.[_]===void 0&&!f.has(_)){let w=i.schemaEnv.baseId+i.errSchemaPath,$=`required property "${_}" is not defined at "${w}" (strictRequired)`;(0,hS.checkStrictMode)(i,$,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(zo.nil,p);else for(let h of r)(0,To.checkReportMissingProp)(t,h)}function l(){let h=e.let("missing");if(c||s){let f=e.let("valid",!0);t.block$data(f,()=>m(h,f)),t.ok(f)}else e.if((0,To.checkMissingProp)(t,r,h)),(0,To.reportMissingProp)(t,h),e.else()}function p(){e.forOf("prop",n,h=>{t.setParams({missingProperty:h}),e.if((0,To.noPropertyInData)(e,o,h,a.ownProperties),()=>t.error())})}function m(h,f){t.setParams({missingProperty:h}),e.forOf(h,n,()=>{e.assign(f,(0,To.propertyInData)(e,o,h,a.ownProperties)),e.if((0,zo.not)(f),()=>{t.error(),e.break()})},zo.nil)}}};xl.default=_S});var Ng=P(kl=>{"use strict";d();Object.defineProperty(kl,"__esModule",{value:!0});var Po=B(),yS={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Po.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Po._)`{limit: ${t}}`},vS={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:yS,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?Po.operators.GT:Po.operators.LT;t.fail$data((0,Po._)`${r}.length ${o} ${n}`)}};kl.default=vS});var li=P($l=>{"use strict";d();Object.defineProperty($l,"__esModule",{value:!0});var Mg=Ku();Mg.code='require("ajv/dist/runtime/equal").default';$l.default=Mg});var Dg=P(Tl=>{"use strict";d();Object.defineProperty(Tl,"__esModule",{value:!0});var Sl=mo(),ze=B(),bS=Q(),wS=li(),xS={message:({params:{i:t,j:e}})=>(0,ze.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ze._)`{i: ${t}, j: ${e}}`},kS={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:xS,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,Sl.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,ze._)`${i} === false`),t.ok(c);function l(){let f=e.let("i",(0,ze._)`${r}.length`),_=e.let("j");t.setParams({i:f,j:_}),e.assign(c,!0),e.if((0,ze._)`${f} > 1`,()=>(p()?m:h)(f,_))}function p(){return u.length>0&&!u.some(f=>f==="object"||f==="array")}function m(f,_){let w=e.name("item"),$=(0,Sl.checkDataTypes)(u,w,a.opts.strictNumbers,Sl.DataType.Wrong),S=e.const("indices",(0,ze._)`{}`);e.for((0,ze._)`;${f}--;`,()=>{e.let(w,(0,ze._)`${r}[${f}]`),e.if($,(0,ze._)`continue`),u.length>1&&e.if((0,ze._)`typeof ${w} == "string"`,(0,ze._)`${w} += "_"`),e.if((0,ze._)`typeof ${S}[${w}] == "number"`,()=>{e.assign(_,(0,ze._)`${S}[${w}]`),t.error(),e.assign(c,!1).break()}).code((0,ze._)`${S}[${w}] = ${f}`)})}function h(f,_){let w=(0,bS.useFunc)(e,wS.default),$=e.name("outer");e.label($).for((0,ze._)`;${f}--;`,()=>e.for((0,ze._)`${_} = ${f}; ${_}--;`,()=>e.if((0,ze._)`${w}(${r}[${f}], ${r}[${_}])`,()=>{t.error(),e.assign(c,!1).break($)})))}}};Tl.default=kS});var qg=P(Pl=>{"use strict";d();Object.defineProperty(Pl,"__esModule",{value:!0});var zl=B(),$S=Q(),SS=li(),TS={message:"must be equal to constant",params:({schemaCode:t})=>(0,zl._)`{allowedValue: ${t}}`},zS={keyword:"const",$data:!0,error:TS,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,zl._)`!${(0,$S.useFunc)(e,SS.default)}(${r}, ${o})`):t.fail((0,zl._)`${s} !== ${r}`)}};Pl.default=zS});var Lg=P(Il=>{"use strict";d();Object.defineProperty(Il,"__esModule",{value:!0});var Io=B(),PS=Q(),IS=li(),ES={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Io._)`{allowedValues: ${t}}`},RS={keyword:"enum",schemaType:"array",$data:!0,error:ES,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,PS.useFunc)(e,IS.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,p);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let h=e.const("vSchema",s);l=(0,Io.or)(...o.map((f,_)=>m(h,_)))}t.pass(l);function p(){e.assign(l,!1),e.forOf("v",s,h=>e.if((0,Io._)`${u()}(${r}, ${h})`,()=>e.assign(l,!0).break()))}function m(h,f){let _=o[f];return typeof _=="object"&&_!==null?(0,Io._)`${u()}(${r}, ${h}[${f}])`:(0,Io._)`${r} === ${_}`}}};Il.default=RS});var Ug=P(El=>{"use strict";d();Object.defineProperty(El,"__esModule",{value:!0});var CS=Ig(),ZS=Eg(),OS=Zg(),jS=Og(),AS=jg(),NS=Ag(),MS=Ng(),DS=Dg(),qS=qg(),LS=Lg(),US=[CS.default,ZS.default,OS.default,jS.default,AS.default,NS.default,MS.default,DS.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},qS.default,LS.default];El.default=US});var Cl=P(Eo=>{"use strict";d();Object.defineProperty(Eo,"__esModule",{value:!0});Eo.validateAdditionalItems=void 0;var wr=B(),Rl=Q(),VS={message:({params:{len:t}})=>(0,wr.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,wr._)`{limit: ${t}}`},FS={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:VS,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Rl.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Vg(t,n)}};function Vg(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,wr._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,wr._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Rl.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,wr._)`${a} <= ${e.length}`);r.if((0,wr.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:Rl.Type.Num},u),i.allErrors||r.if((0,wr.not)(u),()=>r.break())})}}Eo.validateAdditionalItems=Vg;Eo.default=FS});var Zl=P(Ro=>{"use strict";d();Object.defineProperty(Ro,"__esModule",{value:!0});Ro.validateTuple=void 0;var Fg=B(),di=Q(),HS=tt(),BS={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Hg(t,"additionalItems",e);r.items=!0,!(0,di.alwaysValidSchema)(r,e)&&t.ok((0,HS.validateArray)(t))}};function Hg(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=di.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Fg._)`${s}.length`);r.forEach((p,m)=>{(0,di.alwaysValidSchema)(a,p)||(n.if((0,Fg._)`${u} > ${m}`,()=>t.subschema({keyword:i,schemaProp:m,dataProp:m},c)),t.ok(c))});function l(p){let{opts:m,errSchemaPath:h}=a,f=r.length,_=f===p.minItems&&(f===p.maxItems||p[e]===!1);if(m.strictTuples&&!_){let w=`"${i}" is ${f}-tuple, but minItems or maxItems/${e} are not specified or different at path "${h}"`;(0,di.checkStrictMode)(a,w,m.strictTuples)}}}Ro.validateTuple=Hg;Ro.default=BS});var Bg=P(Ol=>{"use strict";d();Object.defineProperty(Ol,"__esModule",{value:!0});var JS=Zl(),KS={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,JS.validateTuple)(t,"items")};Ol.default=KS});var Kg=P(jl=>{"use strict";d();Object.defineProperty(jl,"__esModule",{value:!0});var Jg=B(),GS=Q(),WS=tt(),YS=Cl(),XS={message:({params:{len:t}})=>(0,Jg.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Jg._)`{limit: ${t}}`},QS={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:XS,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,GS.alwaysValidSchema)(n,e)&&(o?(0,YS.validateAdditionalItems)(t,o):t.ok((0,WS.validateArray)(t)))}};jl.default=QS});var Gg=P(Al=>{"use strict";d();Object.defineProperty(Al,"__esModule",{value:!0});var nt=B(),pi=Q(),eT={message:({params:{min:t,max:e}})=>e===void 0?(0,nt.str)`must contain at least ${t} valid item(s)`:(0,nt.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,nt._)`{minContains: ${t}}`:(0,nt._)`{minContains: ${t}, maxContains: ${e}}`},tT={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:eT,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,nt._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,pi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,pi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,pi.alwaysValidSchema)(s,r)){let _=(0,nt._)`${l} >= ${i}`;a!==void 0&&(_=(0,nt._)`${_} && ${l} <= ${a}`),t.pass(_);return}s.items=!0;let p=e.name("valid");a===void 0&&i===1?h(p,()=>e.if(p,()=>e.break())):i===0?(e.let(p,!0),a!==void 0&&e.if((0,nt._)`${o}.length > 0`,m)):(e.let(p,!1),m()),t.result(p,()=>t.reset());function m(){let _=e.name("_valid"),w=e.let("count",0);h(_,()=>e.if(_,()=>f(w)))}function h(_,w){e.forRange("i",0,l,$=>{t.subschema({keyword:"contains",dataProp:$,dataPropType:pi.Type.Num,compositeRule:!0},_),w()})}function f(_){e.code((0,nt._)`${_}++`),a===void 0?e.if((0,nt._)`${_} >= ${i}`,()=>e.assign(p,!0).break()):(e.if((0,nt._)`${_} > ${a}`,()=>e.assign(p,!1).break()),i===1?e.assign(p,!0):e.if((0,nt._)`${_} >= ${i}`,()=>e.assign(p,!0)))}}};Al.default=tT});var Xg=P(bt=>{"use strict";d();Object.defineProperty(bt,"__esModule",{value:!0});bt.validateSchemaDeps=bt.validatePropertyDeps=bt.error=void 0;var Nl=B(),rT=Q(),Co=tt();bt.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Nl.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Nl._)`{property: ${t},
|
|
7
7
|
missingProperty: ${n},
|
|
8
8
|
depsCount: ${e},
|
|
9
|
-
deps: ${r}}`};var rT={keyword:"dependencies",type:"object",schemaType:"object",error:bt.error,code(t){let[e,r]=nT(t);Gg(t,e),Wg(t,r)}};function nT({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function Gg(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Co.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,Co.checkReportMissingProp)(t,u)}):(r.if((0,Nl._)`${c} && (${(0,Co.checkMissingProp)(t,a,s)})`),(0,Co.reportMissingProp)(t,s),r.else())}}bt.validatePropertyDeps=Gg;function Wg(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,tT.alwaysValidSchema)(s,e[a])||(r.if((0,Co.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}bt.validateSchemaDeps=Wg;bt.default=rT});var Qg=P(Ml=>{"use strict";d();Object.defineProperty(Ml,"__esModule",{value:!0});var Xg=B(),oT=Q(),sT={message:"property name must be valid",params:({params:t})=>(0,Xg._)`{propertyName: ${t.propertyName}}`},iT={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:sT,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,oT.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,Xg.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};Ml.default=iT});var ql=P(Dl=>{"use strict";d();Object.defineProperty(Dl,"__esModule",{value:!0});var fi=tt(),ft=B(),aT=Rt(),mi=Q(),cT={message:"must NOT have additional properties",params:({params:t})=>(0,ft._)`{additionalProperty: ${t.additionalProperty}}`},uT={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:cT,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,mi.alwaysValidSchema)(i,r))return;let u=(0,fi.allSchemaProperties)(n.properties),l=(0,fi.allSchemaProperties)(n.patternProperties);p(),t.ok((0,ft._)`${s} === ${aT.default.errors}`);function p(){e.forIn("key",o,w=>{!u.length&&!l.length?f(w):e.if(m(w),()=>f(w))})}function m(w){let k;if(u.length>8){let S=(0,mi.schemaRefOrVal)(i,n.properties,"properties");k=(0,fi.isOwnProperty)(e,S,w)}else u.length?k=(0,ft.or)(...u.map(S=>(0,ft._)`${w} === ${S}`)):k=ft.nil;return l.length&&(k=(0,ft.or)(k,...l.map(S=>(0,ft._)`${(0,fi.usePattern)(t,S)}.test(${w})`))),(0,ft.not)(k)}function h(w){e.code((0,ft._)`delete ${o}[${w}]`)}function f(w){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){h(w);return}if(r===!1){t.setParams({additionalProperty:w}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,mi.alwaysValidSchema)(i,r)){let k=e.name("valid");c.removeAdditional==="failing"?(_(w,k,!1),e.if((0,ft.not)(k),()=>{t.reset(),h(w)})):(_(w,k),a||e.if((0,ft.not)(k),()=>e.break()))}}function _(w,k,S){let T={keyword:"additionalProperties",dataProp:w,dataPropType:mi.Type.Str};S===!1&&Object.assign(T,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(T,k)}}};Dl.default=uT});var r_=P(Ul=>{"use strict";d();Object.defineProperty(Ul,"__esModule",{value:!0});var lT=yo(),e_=tt(),Ll=Q(),t_=ql(),dT={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&t_.default.code(new lT.KeywordCxt(s,t_.default,"additionalProperties"));let i=(0,e_.allSchemaProperties)(r);for(let p of i)s.definedProperties.add(p);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Ll.mergeEvaluated.props(e,(0,Ll.toHash)(i),s.props));let a=i.filter(p=>!(0,Ll.alwaysValidSchema)(s,r[p]));if(a.length===0)return;let c=e.name("valid");for(let p of a)u(p)?l(p):(e.if((0,e_.propertyInData)(e,o,p,s.opts.ownProperties)),l(p),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(p),t.ok(c);function u(p){return s.opts.useDefaults&&!s.compositeRule&&r[p].default!==void 0}function l(p){t.subschema({keyword:"properties",schemaProp:p,dataProp:p},c)}}};Ul.default=dT});var i_=P(Vl=>{"use strict";d();Object.defineProperty(Vl,"__esModule",{value:!0});var n_=tt(),hi=B(),o_=Q(),s_=Q(),pT={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,n_.allSchemaProperties)(r),c=a.filter(_=>(0,o_.alwaysValidSchema)(s,r[_]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof hi.Name)&&(s.props=(0,s_.evaluatedPropsToName)(e,s.props));let{props:p}=s;m();function m(){for(let _ of a)u&&h(_),s.allErrors?f(_):(e.var(l,!0),f(_),e.if(l))}function h(_){for(let w in u)new RegExp(_).test(w)&&(0,o_.checkStrictMode)(s,`property ${w} matches pattern ${_} (use allowMatchingProperties)`)}function f(_){e.forIn("key",n,w=>{e.if((0,hi._)`${(0,n_.usePattern)(t,_)}.test(${w})`,()=>{let k=c.includes(_);k||t.subschema({keyword:"patternProperties",schemaProp:_,dataProp:w,dataPropType:s_.Type.Str},l),s.opts.unevaluated&&p!==!0?e.assign((0,hi._)`${p}[${w}]`,!0):!k&&!s.allErrors&&e.if((0,hi.not)(l),()=>e.break())})})}}};Vl.default=pT});var a_=P(Fl=>{"use strict";d();Object.defineProperty(Fl,"__esModule",{value:!0});var fT=Q(),mT={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,fT.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Fl.default=mT});var c_=P(Hl=>{"use strict";d();Object.defineProperty(Hl,"__esModule",{value:!0});var hT=tt(),gT={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:hT.validateUnion,error:{message:"must match a schema in anyOf"}};Hl.default=gT});var u_=P(Bl=>{"use strict";d();Object.defineProperty(Bl,"__esModule",{value:!0});var gi=B(),_T=Q(),yT={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,gi._)`{passingSchemas: ${t.passing}}`},vT={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:yT,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,p)=>{let m;(0,_T.alwaysValidSchema)(o,l)?e.var(c,!0):m=t.subschema({keyword:"oneOf",schemaProp:p,compositeRule:!0},c),p>0&&e.if((0,gi._)`${c} && ${i}`).assign(i,!1).assign(a,(0,gi._)`[${a}, ${p}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,p),m&&t.mergeEvaluated(m,gi.Name)})})}}};Bl.default=vT});var l_=P(Jl=>{"use strict";d();Object.defineProperty(Jl,"__esModule",{value:!0});var bT=Q(),wT={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,bT.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};Jl.default=wT});var f_=P(Kl=>{"use strict";d();Object.defineProperty(Kl,"__esModule",{value:!0});var _i=B(),p_=Q(),xT={message:({params:t})=>(0,_i.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,_i._)`{failingKeyword: ${t.ifClause}}`},$T={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:xT,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,p_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=d_(n,"then"),s=d_(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,_i.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,p){return()=>{let m=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(m,i),p?e.assign(p,(0,_i._)`${l}`):t.setParams({ifClause:l})}}}};function d_(t,e){let r=t.schema[e];return r!==void 0&&!(0,p_.alwaysValidSchema)(t,r)}Kl.default=$T});var m_=P(Gl=>{"use strict";d();Object.defineProperty(Gl,"__esModule",{value:!0});var kT=Q(),ST={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,kT.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Gl.default=ST});var h_=P(Wl=>{"use strict";d();Object.defineProperty(Wl,"__esModule",{value:!0});var TT=Cl(),zT=Hg(),PT=Zl(),IT=Jg(),ET=Kg(),RT=Yg(),CT=Qg(),ZT=ql(),OT=r_(),jT=i_(),AT=a_(),NT=c_(),MT=u_(),DT=l_(),qT=f_(),LT=m_();function UT(t=!1){let e=[AT.default,NT.default,MT.default,DT.default,qT.default,LT.default,CT.default,ZT.default,RT.default,OT.default,jT.default];return t?e.push(zT.default,IT.default):e.push(TT.default,PT.default),e.push(ET.default),e}Wl.default=UT});var g_=P(Yl=>{"use strict";d();Object.defineProperty(Yl,"__esModule",{value:!0});var ve=B(),VT={message:({schemaCode:t})=>(0,ve.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ve._)`{format: ${t}}`},FT={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:VT,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:p}=a;if(!c.validateFormats)return;o?m():h();function m(){let f=r.scopeValue("formats",{ref:p.formats,code:c.code.formats}),_=r.const("fDef",(0,ve._)`${f}[${i}]`),w=r.let("fType"),k=r.let("format");r.if((0,ve._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(w,(0,ve._)`${_}.type || "string"`).assign(k,(0,ve._)`${_}.validate`),()=>r.assign(w,(0,ve._)`"string"`).assign(k,_)),t.fail$data((0,ve.or)(S(),T()));function S(){return c.strictSchema===!1?ve.nil:(0,ve._)`${i} && !${k}`}function T(){let R=l.$async?(0,ve._)`(${_}.async ? await ${k}(${n}) : ${k}(${n}))`:(0,ve._)`${k}(${n})`,N=(0,ve._)`(typeof ${k} == "function" ? ${R} : ${k}.test(${n}))`;return(0,ve._)`${k} && ${k} !== true && ${w} === ${e} && !${N}`}}function h(){let f=p.formats[s];if(!f){S();return}if(f===!0)return;let[_,w,k]=T(f);_===e&&t.pass(R());function S(){if(c.strictSchema===!1){p.logger.warn(N());return}throw new Error(N());function N(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function T(N){let Ce=N instanceof RegExp?(0,ve.regexpCode)(N):c.code.formats?(0,ve._)`${c.code.formats}${(0,ve.getProperty)(s)}`:void 0,We=r.scopeValue("formats",{key:s,ref:N,code:Ce});return typeof N=="object"&&!(N instanceof RegExp)?[N.type||"string",N.validate,(0,ve._)`${We}.validate`]:["string",N,We]}function R(){if(typeof f=="object"&&!(f instanceof RegExp)&&f.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ve._)`await ${k}(${n})`}return typeof w=="function"?(0,ve._)`${k}(${n})`:(0,ve._)`${k}.test(${n})`}}}};Yl.default=FT});var __=P(Xl=>{"use strict";d();Object.defineProperty(Xl,"__esModule",{value:!0});var HT=g_(),BT=[HT.default];Xl.default=BT});var y_=P(pn=>{"use strict";d();Object.defineProperty(pn,"__esModule",{value:!0});pn.contentVocabulary=pn.metadataVocabulary=void 0;pn.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];pn.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var b_=P(Ql=>{"use strict";d();Object.defineProperty(Ql,"__esModule",{value:!0});var JT=zg(),KT=Lg(),GT=h_(),WT=__(),v_=y_(),YT=[JT.default,KT.default,(0,GT.default)(),WT.default,v_.metadataVocabulary,v_.contentVocabulary];Ql.default=YT});var x_=P(yi=>{"use strict";d();Object.defineProperty(yi,"__esModule",{value:!0});yi.DiscrError=void 0;var w_;(function(t){t.Tag="tag",t.Mapping="mapping"})(w_||(yi.DiscrError=w_={}))});var k_=P(td=>{"use strict";d();Object.defineProperty(td,"__esModule",{value:!0});var fn=B(),ed=x_(),$_=ei(),XT=vo(),QT=Q(),ez={message:({params:{discrError:t,tagName:e}})=>t===ed.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,fn._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},tz={keyword:"discriminator",type:"object",schemaType:"object",error:ez,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,fn._)`${r}${(0,fn.getProperty)(a)}`);e.if((0,fn._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:ed.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let h=m();e.if(!1);for(let f in h)e.elseIf((0,fn._)`${u} === ${f}`),e.assign(c,p(h[f]));e.else(),t.error(!1,{discrError:ed.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function p(h){let f=e.name("valid"),_=t.subschema({keyword:"oneOf",schemaProp:h},f);return t.mergeEvaluated(_,fn.Name),f}function m(){var h;let f={},_=k(o),w=!0;for(let R=0;R<i.length;R++){let N=i[R];if(N?.$ref&&!(0,QT.schemaHasRulesButRef)(N,s.self.RULES)){let We=N.$ref;if(N=$_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,We),N instanceof $_.SchemaEnv&&(N=N.schema),N===void 0)throw new XT.default(s.opts.uriResolver,s.baseId,We)}let Ce=(h=N?.properties)===null||h===void 0?void 0:h[a];if(typeof Ce!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);w=w&&(_||k(N)),S(Ce,R)}if(!w)throw new Error(`discriminator: "${a}" must be required`);return f;function k({required:R}){return Array.isArray(R)&&R.includes(a)}function S(R,N){if(R.const)T(R.const,N);else if(R.enum)for(let Ce of R.enum)T(Ce,N);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function T(R,N){if(typeof R!="string"||R in f)throw new Error(`discriminator: "${a}" values must be unique strings`);f[R]=N}}}};td.default=tz});var S_=P((CN,rz)=>{rz.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var nd=P((fe,rd)=>{"use strict";d();Object.defineProperty(fe,"__esModule",{value:!0});fe.MissingRefError=fe.ValidationError=fe.CodeGen=fe.Name=fe.nil=fe.stringify=fe.str=fe._=fe.KeywordCxt=fe.Ajv=void 0;var nz=wg(),oz=b_(),sz=k_(),T_=S_(),iz=["/properties"],vi="http://json-schema.org/draft-07/schema",mn=class extends nz.default{_addVocabularies(){super._addVocabularies(),oz.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(sz.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(T_,iz):T_;this.addMetaSchema(e,vi,!1),this.refs["http://json-schema.org/schema"]=vi}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(vi)?vi:void 0)}};fe.Ajv=mn;rd.exports=fe=mn;rd.exports.Ajv=mn;Object.defineProperty(fe,"__esModule",{value:!0});fe.default=mn;var az=yo();Object.defineProperty(fe,"KeywordCxt",{enumerable:!0,get:function(){return az.KeywordCxt}});var hn=B();Object.defineProperty(fe,"_",{enumerable:!0,get:function(){return hn._}});Object.defineProperty(fe,"str",{enumerable:!0,get:function(){return hn.str}});Object.defineProperty(fe,"stringify",{enumerable:!0,get:function(){return hn.stringify}});Object.defineProperty(fe,"nil",{enumerable:!0,get:function(){return hn.nil}});Object.defineProperty(fe,"Name",{enumerable:!0,get:function(){return hn.Name}});Object.defineProperty(fe,"CodeGen",{enumerable:!0,get:function(){return hn.CodeGen}});var cz=Xs();Object.defineProperty(fe,"ValidationError",{enumerable:!0,get:function(){return cz.default}});var uz=vo();Object.defineProperty(fe,"MissingRefError",{enumerable:!0,get:function(){return uz.default}})});var O_=P(xt=>{"use strict";d();Object.defineProperty(xt,"__esModule",{value:!0});xt.formatNames=xt.fastFormats=xt.fullFormats=void 0;function wt(t,e){return{validate:t,compare:e}}xt.fullFormats={date:wt(E_,ad),time:wt(sd(!0),cd),"date-time":wt(z_(!0),C_),"iso-time":wt(sd(),R_),"iso-date-time":wt(z_(),Z_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:hz,"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:xz,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:gz,int32:{type:"number",validate:vz},int64:{type:"number",validate:bz},float:{type:"number",validate:I_},double:{type:"number",validate:I_},password:!0,binary:!0};xt.fastFormats={...xt.fullFormats,date:wt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,ad),time:wt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,cd),"date-time":wt(/^\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,C_),"iso-time":wt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,R_),"iso-date-time":wt(/^\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,Z_),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};xt.formatNames=Object.keys(xt.fullFormats);function lz(t){return t%4===0&&(t%100!==0||t%400===0)}var dz=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,pz=[0,31,28,31,30,31,30,31,31,30,31,30,31];function E_(t){let e=dz.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&lz(r)?29:pz[n])}function ad(t,e){if(t&&e)return t>e?1:t<e?-1:0}var od=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function sd(t){return function(r){let n=od.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let p=s-l*c,m=o-u*c-(p<0?1:0);return(m===23||m===-1)&&(p===59||p===-1)&&i<61}}function cd(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function R_(t,e){if(!(t&&e))return;let r=od.exec(t),n=od.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var id=/t|\s/i;function z_(t){let e=sd(t);return function(n){let o=n.split(id);return o.length===2&&E_(o[0])&&e(o[1])}}function C_(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function Z_(t,e){if(!(t&&e))return;let[r,n]=t.split(id),[o,s]=e.split(id),i=ad(r,o);if(i!==void 0)return i||cd(n,s)}var fz=/\/|:/,mz=/^(?:[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 hz(t){return fz.test(t)&&mz.test(t)}var P_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function gz(t){return P_.lastIndex=0,P_.test(t)}var _z=-(2**31),yz=2**31-1;function vz(t){return Number.isInteger(t)&&t<=yz&&t>=_z}function bz(t){return Number.isInteger(t)}function I_(){return!0}var wz=/[^\\]\\Z/;function xz(t){if(wz.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var j_=P(gn=>{"use strict";d();Object.defineProperty(gn,"__esModule",{value:!0});gn.formatLimitDefinition=void 0;var $z=nd(),mt=B(),Yt=mt.operators,bi={formatMaximum:{okStr:"<=",ok:Yt.LTE,fail:Yt.GT},formatMinimum:{okStr:">=",ok:Yt.GTE,fail:Yt.LT},formatExclusiveMaximum:{okStr:"<",ok:Yt.LT,fail:Yt.GTE},formatExclusiveMinimum:{okStr:">",ok:Yt.GT,fail:Yt.LTE}},kz={message:({keyword:t,schemaCode:e})=>(0,mt.str)`should be ${bi[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,mt._)`{comparison: ${bi[t].okStr}, limit: ${e}}`};gn.formatLimitDefinition={keyword:Object.keys(bi),type:"string",schemaType:"string",$data:!0,error:kz,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new $z.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let m=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),h=e.const("fmt",(0,mt._)`${m}[${c.schemaCode}]`);t.fail$data((0,mt.or)((0,mt._)`typeof ${h} != "object"`,(0,mt._)`${h} instanceof RegExp`,(0,mt._)`typeof ${h}.compare != "function"`,p(h)))}function l(){let m=c.schema,h=a.formats[m];if(!h||h===!0)return;if(typeof h!="object"||h instanceof RegExp||typeof h.compare!="function")throw new Error(`"${o}": format "${m}" does not define "compare" function`);let f=e.scopeValue("formats",{key:m,ref:h,code:i.code.formats?(0,mt._)`${i.code.formats}${(0,mt.getProperty)(m)}`:void 0});t.fail$data(p(f))}function p(m){return(0,mt._)`${m}.compare(${r}, ${n}) ${bi[o].fail} 0`}},dependencies:["format"]};var Sz=t=>(t.addKeyword(gn.formatLimitDefinition),t);gn.default=Sz});var D_=P((Zo,M_)=>{"use strict";d();Object.defineProperty(Zo,"__esModule",{value:!0});var _n=O_(),Tz=j_(),ud=B(),A_=new ud.Name("fullFormats"),zz=new ud.Name("fastFormats"),ld=(t,e={keywords:!0})=>{if(Array.isArray(e))return N_(t,e,_n.fullFormats,A_),t;let[r,n]=e.mode==="fast"?[_n.fastFormats,zz]:[_n.fullFormats,A_],o=e.formats||_n.formatNames;return N_(t,o,r,n),e.keywords&&(0,Tz.default)(t),t};ld.get=(t,e="full")=>{let n=(e==="fast"?_n.fastFormats:_n.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function N_(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,ud._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}M_.exports=Zo=ld;Object.defineProperty(Zo,"__esModule",{value:!0});Zo.default=ld});var jo=P(le=>{"use strict";d();Object.defineProperty(le,"__esModule",{value:!0});le.getParsedType=le.ZodParsedType=le.objectUtil=le.util=void 0;var md;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(md||(le.util=md={}));var Y_;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Y_||(le.objectUtil=Y_={}));le.ZodParsedType=md.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);var Oz=t=>{switch(typeof t){case"undefined":return le.ZodParsedType.undefined;case"string":return le.ZodParsedType.string;case"number":return Number.isNaN(t)?le.ZodParsedType.nan:le.ZodParsedType.number;case"boolean":return le.ZodParsedType.boolean;case"function":return le.ZodParsedType.function;case"bigint":return le.ZodParsedType.bigint;case"symbol":return le.ZodParsedType.symbol;case"object":return Array.isArray(t)?le.ZodParsedType.array:t===null?le.ZodParsedType.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?le.ZodParsedType.promise:typeof Map<"u"&&t instanceof Map?le.ZodParsedType.map:typeof Set<"u"&&t instanceof Set?le.ZodParsedType.set:typeof Date<"u"&&t instanceof Date?le.ZodParsedType.date:le.ZodParsedType.object;default:return le.ZodParsedType.unknown}};le.getParsedType=Oz});var Si=P(Qt=>{"use strict";d();Object.defineProperty(Qt,"__esModule",{value:!0});Qt.ZodError=Qt.quotelessJson=Qt.ZodIssueCode=void 0;var X_=jo();Qt.ZodIssueCode=X_.util.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"]);var jz=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");Qt.quotelessJson=jz;var Ao=class t 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]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,X_.util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Qt.ZodError=Ao;Ao.create=t=>new Ao(t)});var gd=P(hd=>{"use strict";d();Object.defineProperty(hd,"__esModule",{value:!0});var Re=Si(),xr=jo(),Az=(t,e)=>{let r;switch(t.code){case Re.ZodIssueCode.invalid_type:t.received===xr.ZodParsedType.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case Re.ZodIssueCode.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,xr.util.jsonStringifyReplacer)}`;break;case Re.ZodIssueCode.unrecognized_keys:r=`Unrecognized key(s) in object: ${xr.util.joinValues(t.keys,", ")}`;break;case Re.ZodIssueCode.invalid_union:r="Invalid input";break;case Re.ZodIssueCode.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${xr.util.joinValues(t.options)}`;break;case Re.ZodIssueCode.invalid_enum_value:r=`Invalid enum value. Expected ${xr.util.joinValues(t.options)}, received '${t.received}'`;break;case Re.ZodIssueCode.invalid_arguments:r="Invalid function arguments";break;case Re.ZodIssueCode.invalid_return_type:r="Invalid function return type";break;case Re.ZodIssueCode.invalid_date:r="Invalid date";break;case Re.ZodIssueCode.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}"`:xr.util.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case Re.ZodIssueCode.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 Re.ZodIssueCode.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 Re.ZodIssueCode.custom:r="Invalid input";break;case Re.ZodIssueCode.invalid_intersection_types:r="Intersection results could not be merged";break;case Re.ZodIssueCode.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case Re.ZodIssueCode.not_finite:r="Number must be finite";break;default:r=e.defaultError,xr.util.assertNever(t)}return{message:r}};hd.default=Az});var Ti=P(er=>{"use strict";d();var Nz=er&&er.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(er,"__esModule",{value:!0});er.defaultErrorMap=void 0;er.setErrorMap=Mz;er.getErrorMap=Dz;var Q_=Nz(gd());er.defaultErrorMap=Q_.default;var ey=Q_.default;function Mz(t){ey=t}function Dz(){return ey}});var yd=P(ne=>{"use strict";d();var qz=ne&&ne.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ne,"__esModule",{value:!0});ne.isAsync=ne.isValid=ne.isDirty=ne.isAborted=ne.OK=ne.DIRTY=ne.INVALID=ne.ParseStatus=ne.EMPTY_PATH=ne.makeIssue=void 0;ne.addIssueToContext=Vz;var Lz=Ti(),ty=qz(gd()),Uz=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}};ne.makeIssue=Uz;ne.EMPTY_PATH=[];function Vz(t,e){let r=(0,Lz.getErrorMap)(),n=(0,ne.makeIssue)({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ty.default?void 0:ty.default].filter(o=>!!o)});t.common.issues.push(n)}var _d=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return ne.INVALID;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let s=await o.key,i=await o.value;n.push({key:s,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return ne.INVALID;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}};ne.ParseStatus=_d;ne.INVALID=Object.freeze({status:"aborted"});var Fz=t=>({status:"dirty",value:t});ne.DIRTY=Fz;var Hz=t=>({status:"valid",value:t});ne.OK=Hz;var Bz=t=>t.status==="aborted";ne.isAborted=Bz;var Jz=t=>t.status==="dirty";ne.isDirty=Jz;var Kz=t=>t.status==="valid";ne.isValid=Kz;var Gz=t=>typeof Promise<"u"&&t instanceof Promise;ne.isAsync=Gz});var ny=P(ry=>{"use strict";d();Object.defineProperty(ry,"__esModule",{value:!0})});var sy=P(zi=>{"use strict";d();Object.defineProperty(zi,"__esModule",{value:!0});zi.errorUtil=void 0;var oy;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(oy||(zi.errorUtil=oy={}))});var _y=P(g=>{"use strict";d();Object.defineProperty(g,"__esModule",{value:!0});g.discriminatedUnion=g.date=g.boolean=g.bigint=g.array=g.any=g.coerce=g.ZodFirstPartyTypeKind=g.late=g.ZodSchema=g.Schema=g.ZodReadonly=g.ZodPipeline=g.ZodBranded=g.BRAND=g.ZodNaN=g.ZodCatch=g.ZodDefault=g.ZodNullable=g.ZodOptional=g.ZodTransformer=g.ZodEffects=g.ZodPromise=g.ZodNativeEnum=g.ZodEnum=g.ZodLiteral=g.ZodLazy=g.ZodFunction=g.ZodSet=g.ZodMap=g.ZodRecord=g.ZodTuple=g.ZodIntersection=g.ZodDiscriminatedUnion=g.ZodUnion=g.ZodObject=g.ZodArray=g.ZodVoid=g.ZodNever=g.ZodUnknown=g.ZodAny=g.ZodNull=g.ZodUndefined=g.ZodSymbol=g.ZodDate=g.ZodBoolean=g.ZodBigInt=g.ZodNumber=g.ZodString=g.ZodType=void 0;g.NEVER=g.void=g.unknown=g.union=g.undefined=g.tuple=g.transformer=g.symbol=g.string=g.strictObject=g.set=g.record=g.promise=g.preprocess=g.pipeline=g.ostring=g.optional=g.onumber=g.oboolean=g.object=g.number=g.nullable=g.null=g.never=g.nativeEnum=g.nan=g.map=g.literal=g.lazy=g.intersection=g.instanceof=g.function=g.enum=g.effect=void 0;g.datetimeRegex=ly;g.custom=py;var z=Si(),Pi=Ti(),j=sy(),b=yd(),I=jo(),st=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}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}},iy=(t,e)=>{if((0,b.isValid)(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;let r=new z.ZodError(t.common.issues);return this._error=r,this._error}}};function V(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=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:o}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:o}}var F=class{get description(){return this._def.description}_getType(e){return(0,I.getParsedType)(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:(0,I.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new b.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,I.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if((0,b.isAsync)(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,I.getParsedType)(e)},o=this._parseSync({data:e,path:n.path,parent:n});return iy(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,I.getParsedType)(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return(0,b.isValid)(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=>(0,b.isValid)(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,I.getParsedType)(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await((0,b.isAsync)(o)?o:Promise.resolve(o));return iy(n,s)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:z.ZodIssueCode.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new Ge({schema:this,typeName:q.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 ot.create(this,this._def)}nullable(){return kt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return At.create(this)}promise(){return nr.create(this,this._def)}or(e){return Ir.create([this,e],this._def)}and(e){return Er.create(this,e,this._def)}transform(e){return new Ge({...V(this._def),schema:this,typeName:q.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new jr({...V(this._def),innerType:this,defaultValue:r,typeName:q.ZodDefault})}brand(){return new No({typeName:q.ZodBranded,type:this,...V(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Ar({...V(this._def),innerType:this,catchValue:r,typeName:q.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Mo.create(this,e)}readonly(){return Nr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};g.ZodType=F;g.Schema=F;g.ZodSchema=F;var Wz=/^c[^\s-]{8,}$/i,Yz=/^[0-9a-z]+$/,Xz=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Qz=/^[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,eP=/^[a-z0-9_-]{21}$/i,tP=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,rP=/^[-+]?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)?)??$/,nP=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,oP="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",vd,sP=/^(?:(?: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])$/,iP=/^(?:(?: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])$/,aP=/^(([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]))$/,cP=/^(([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])$/,uP=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,lP=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,cy="((\\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])))",dP=new RegExp(`^${cy}$`);function uy(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function pP(t){return new RegExp(`^${uy(t)}$`)}function ly(t){let e=`${cy}T${uy(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function fP(t,e){return!!((e==="v4"||!e)&&sP.test(t)||(e==="v6"||!e)&&aP.test(t))}function mP(t,e){if(!tP.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function hP(t,e){return!!((e==="v4"||!e)&&iP.test(t)||(e==="v6"||!e)&&cP.test(t))}var tr=class t extends F{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==I.ZodParsedType.string){let s=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(s,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.string,received:s.parsedType}),b.INVALID}let n=new b.ParseStatus,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")nP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"email",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")vd||(vd=new RegExp(oP,"u")),vd.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"emoji",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")Qz.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"uuid",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")eP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"nanoid",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")Wz.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"cuid",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Yz.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"cuid2",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Xz.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"ulid",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"url",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"regex",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?ly(s).test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?dP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?pP(s).test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?rP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"duration",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?fP(e.data,s.version)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"ip",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?mP(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"jwt",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?hP(e.data,s.version)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"cidr",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?uP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"base64",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?lP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"base64url",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):I.util.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:z.ZodIssueCode.invalid_string,...j.errorUtil.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...j.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...j.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...j.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...j.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...j.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...j.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...j.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...j.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...j.errorUtil.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...j.errorUtil.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...j.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...j.errorUtil.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...j.errorUtil.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,...j.errorUtil.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,...j.errorUtil.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...j.errorUtil.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...j.errorUtil.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...j.errorUtil.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...j.errorUtil.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...j.errorUtil.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...j.errorUtil.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...j.errorUtil.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...j.errorUtil.errToObj(r)})}nonempty(e){return this.min(1,j.errorUtil.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...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(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};g.ZodString=tr;tr.create=t=>new tr({checks:[],typeName:q.ZodString,coerce:t?.coerce??!1,...V(t)});function gP(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var $r=class t extends F{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)!==I.ZodParsedType.number){let s=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(s,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.number,received:s.parsedType}),b.INVALID}let n,o=new b.ParseStatus;for(let s of this._def.checks)s.kind==="int"?I.util.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?gP(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.not_finite,message:s.message}),o.dirty()):I.util.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,j.errorUtil.toString(r))}gt(e,r){return this.setLimit("min",e,!1,j.errorUtil.toString(r))}lte(e,r){return this.setLimit("max",e,!0,j.errorUtil.toString(r))}lt(e,r){return this.setLimit("max",e,!1,j.errorUtil.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:j.errorUtil.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:j.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:j.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:j.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:j.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:j.errorUtil.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:j.errorUtil.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:j.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:j.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:j.errorUtil.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let 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"&&I.util.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let 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)}};g.ZodNumber=$r;$r.create=t=>new $r({checks:[],typeName:q.ZodNumber,coerce:t?.coerce||!1,...V(t)});var kr=class t extends F{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)!==I.ZodParsedType.bigint)return this._getInvalidInput(e);let n,o=new b.ParseStatus;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):I.util.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.bigint,received:r.parsedType}),b.INVALID}gte(e,r){return this.setLimit("min",e,!0,j.errorUtil.toString(r))}gt(e,r){return this.setLimit("min",e,!1,j.errorUtil.toString(r))}lte(e,r){return this.setLimit("max",e,!0,j.errorUtil.toString(r))}lt(e,r){return this.setLimit("max",e,!1,j.errorUtil.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:j.errorUtil.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:j.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:j.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:j.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:j.errorUtil.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:j.errorUtil.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};g.ZodBigInt=kr;kr.create=t=>new kr({checks:[],typeName:q.ZodBigInt,coerce:t?.coerce??!1,...V(t)});var Sr=class extends F{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==I.ZodParsedType.boolean){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.boolean,received:n.parsedType}),b.INVALID}return(0,b.OK)(e.data)}};g.ZodBoolean=Sr;Sr.create=t=>new Sr({typeName:q.ZodBoolean,coerce:t?.coerce||!1,...V(t)});var Tr=class t extends F{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==I.ZodParsedType.date){let s=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(s,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.date,received:s.parsedType}),b.INVALID}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(s,{code:z.ZodIssueCode.invalid_date}),b.INVALID}let n=new b.ParseStatus,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):I.util.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:j.errorUtil.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:j.errorUtil.toString(r)})}get minDate(){let e=null;for(let 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(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};g.ZodDate=Tr;Tr.create=t=>new Tr({checks:[],coerce:t?.coerce||!1,typeName:q.ZodDate,...V(t)});var bn=class extends F{_parse(e){if(this._getType(e)!==I.ZodParsedType.symbol){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.symbol,received:n.parsedType}),b.INVALID}return(0,b.OK)(e.data)}};g.ZodSymbol=bn;bn.create=t=>new bn({typeName:q.ZodSymbol,...V(t)});var zr=class extends F{_parse(e){if(this._getType(e)!==I.ZodParsedType.undefined){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.undefined,received:n.parsedType}),b.INVALID}return(0,b.OK)(e.data)}};g.ZodUndefined=zr;zr.create=t=>new zr({typeName:q.ZodUndefined,...V(t)});var Pr=class extends F{_parse(e){if(this._getType(e)!==I.ZodParsedType.null){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.null,received:n.parsedType}),b.INVALID}return(0,b.OK)(e.data)}};g.ZodNull=Pr;Pr.create=t=>new Pr({typeName:q.ZodNull,...V(t)});var rr=class extends F{constructor(){super(...arguments),this._any=!0}_parse(e){return(0,b.OK)(e.data)}};g.ZodAny=rr;rr.create=t=>new rr({typeName:q.ZodAny,...V(t)});var jt=class extends F{constructor(){super(...arguments),this._unknown=!0}_parse(e){return(0,b.OK)(e.data)}};g.ZodUnknown=jt;jt.create=t=>new jt({typeName:q.ZodUnknown,...V(t)});var ht=class extends F{_parse(e){let r=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.never,received:r.parsedType}),b.INVALID}};g.ZodNever=ht;ht.create=t=>new ht({typeName:q.ZodNever,...V(t)});var wn=class extends F{_parse(e){if(this._getType(e)!==I.ZodParsedType.undefined){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.void,received:n.parsedType}),b.INVALID}return(0,b.OK)(e.data)}};g.ZodVoid=wn;wn.create=t=>new wn({typeName:q.ZodVoid,...V(t)});var At=class t extends F{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==I.ZodParsedType.array)return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.array,received:r.parsedType}),b.INVALID;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(i||a)&&((0,b.addIssueToContext)(r,{code:i?z.ZodIssueCode.too_big:z.ZodIssueCode.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&((0,b.addIssueToContext)(r,{code:z.ZodIssueCode.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&((0,b.addIssueToContext)(r,{code:z.ZodIssueCode.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>o.type._parseAsync(new st(r,i,r.path,a)))).then(i=>b.ParseStatus.mergeArray(n,i));let s=[...r.data].map((i,a)=>o.type._parseSync(new st(r,i,r.path,a)));return b.ParseStatus.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:j.errorUtil.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:j.errorUtil.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:j.errorUtil.toString(r)}})}nonempty(e){return this.min(1,e)}};g.ZodArray=At;At.create=(t,e)=>new At({type:t,minLength:null,maxLength:null,exactLength:null,typeName:q.ZodArray,...V(e)});function vn(t){if(t instanceof Fe){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=ot.create(vn(n))}return new Fe({...t._def,shape:()=>e})}else return t instanceof At?new At({...t._def,type:vn(t.element)}):t instanceof ot?ot.create(vn(t.unwrap())):t instanceof kt?kt.create(vn(t.unwrap())):t instanceof $t?$t.create(t.items.map(e=>vn(e))):t}var Fe=class t extends F{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=I.util.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==I.ZodParsedType.object){let u=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(u,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.object,received:u.parsedType}),b.INVALID}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ht&&this._def.unknownKeys==="strip"))for(let u in o.data)i.includes(u)||a.push(u);let c=[];for(let u of i){let l=s[u],p=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new st(o,p,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof ht){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")a.length>0&&((0,b.addIssueToContext)(o,{code:z.ZodIssueCode.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let p=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new st(o,p,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let p=await l.key,m=await l.value;u.push({key:p,value:m,alwaysSet:l.alwaysSet})}return u}).then(u=>b.ParseStatus.mergeObjectSync(n,u)):b.ParseStatus.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return j.errorUtil.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:j.errorUtil.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:q.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of I.util.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of I.util.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return vn(this)}partial(e){let r={};for(let n of I.util.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of I.util.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof ot;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:()=>r})}keyof(){return dy(I.util.objectKeys(this.shape))}};g.ZodObject=Fe;Fe.create=(t,e)=>new Fe({shape:()=>t,unknownKeys:"strip",catchall:ht.create(),typeName:q.ZodObject,...V(e)});Fe.strictCreate=(t,e)=>new Fe({shape:()=>t,unknownKeys:"strict",catchall:ht.create(),typeName:q.ZodObject,...V(e)});Fe.lazycreate=(t,e)=>new Fe({shape:t,unknownKeys:"strip",catchall:ht.create(),typeName:q.ZodObject,...V(e)});var Ir=class extends F{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new z.ZodError(a.ctx.common.issues));return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_union,unionErrors:i}),b.INVALID}if(r.common.async)return Promise.all(n.map(async s=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let c of n){let 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"&&!s&&(s={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(c=>new z.ZodError(c));return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_union,unionErrors:a}),b.INVALID}}get options(){return this._def.options}};g.ZodUnion=Ir;Ir.create=(t,e)=>new Ir({options:t,typeName:q.ZodUnion,...V(e)});var Ot=t=>t instanceof Rr?Ot(t.schema):t instanceof Ge?Ot(t.innerType()):t instanceof Cr?[t.value]:t instanceof Zr?t.options:t instanceof Or?I.util.objectValues(t.enum):t instanceof jr?Ot(t._def.innerType):t instanceof zr?[void 0]:t instanceof Pr?[null]:t instanceof ot?[void 0,...Ot(t.unwrap())]:t instanceof kt?[null,...Ot(t.unwrap())]:t instanceof No||t instanceof Nr?Ot(t.unwrap()):t instanceof Ar?Ot(t._def.innerType):[],Ii=class t extends F{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==I.ZodParsedType.object)return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.object,received:r.parsedType}),b.INVALID;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):((0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),b.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let s of r){let i=Ot(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s)}}return new t({typeName:q.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...V(n)})}};g.ZodDiscriminatedUnion=Ii;function bd(t,e){let r=(0,I.getParsedType)(t),n=(0,I.getParsedType)(e);if(t===e)return{valid:!0,data:t};if(r===I.ZodParsedType.object&&n===I.ZodParsedType.object){let o=I.util.objectKeys(e),s=I.util.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=bd(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===I.ZodParsedType.array&&n===I.ZodParsedType.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],c=bd(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===I.ZodParsedType.date&&n===I.ZodParsedType.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Er=class extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if((0,b.isAborted)(s)||(0,b.isAborted)(i))return b.INVALID;let a=bd(s.value,i.value);return a.valid?(((0,b.isDirty)(s)||(0,b.isDirty)(i))&&r.dirty(),{status:r.value,value:a.data}):((0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_intersection_types}),b.INVALID)};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(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};g.ZodIntersection=Er;Er.create=(t,e,r)=>new Er({left:t,right:e,typeName:q.ZodIntersection,...V(r)});var $t=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==I.ZodParsedType.array)return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.array,received:n.parsedType}),b.INVALID;if(n.data.length<this._def.items.length)return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b.INVALID;!this._def.rest&&n.data.length>this._def.items.length&&((0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new st(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>b.ParseStatus.mergeArray(r,i)):b.ParseStatus.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};g.ZodTuple=$t;$t.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new $t({items:t,typeName:q.ZodTuple,rest:null,...V(e)})};var Ei=class t extends F{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==I.ZodParsedType.object)return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.object,received:n.parsedType}),b.INVALID;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in n.data)o.push({key:s._parse(new st(n,a,n.path,a)),value:i._parse(new st(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?b.ParseStatus.mergeObjectAsync(r,o):b.ParseStatus.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof F?new t({keyType:e,valueType:r,typeName:q.ZodRecord,...V(n)}):new t({keyType:tr.create(),valueType:e,typeName:q.ZodRecord,...V(r)})}};g.ZodRecord=Ei;var xn=class extends F{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==I.ZodParsedType.map)return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.map,received:n.parsedType}),b.INVALID;let o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new st(n,a,n.path,[u,"key"])),value:s._parse(new st(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return b.INVALID;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return b.INVALID;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};g.ZodMap=xn;xn.create=(t,e,r)=>new xn({valueType:e,keyType:t,typeName:q.ZodMap,...V(r)});var $n=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==I.ZodParsedType.set)return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.set,received:n.parsedType}),b.INVALID;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&((0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&((0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return b.INVALID;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>s._parse(new st(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:j.errorUtil.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:j.errorUtil.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};g.ZodSet=$n;$n.create=(t,e)=>new $n({valueType:t,minSize:null,maxSize:null,typeName:q.ZodSet,...V(e)});var Ri=class t extends F{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==I.ZodParsedType.function)return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.function,received:r.parsedType}),b.INVALID;function n(a,c){return(0,b.makeIssue)({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,(0,Pi.getErrorMap)(),Pi.defaultErrorMap].filter(u=>!!u),issueData:{code:z.ZodIssueCode.invalid_arguments,argumentsError:c}})}function o(a,c){return(0,b.makeIssue)({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,(0,Pi.getErrorMap)(),Pi.defaultErrorMap].filter(u=>!!u),issueData:{code:z.ZodIssueCode.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof nr){let a=this;return(0,b.OK)(async function(...c){let u=new z.ZodError([]),l=await a._def.args.parseAsync(c,s).catch(h=>{throw u.addIssue(n(c,h)),u}),p=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(p,s).catch(h=>{throw u.addIssue(o(p,h)),u})})}else{let a=this;return(0,b.OK)(function(...c){let u=a._def.args.safeParse(c,s);if(!u.success)throw new z.ZodError([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),p=a._def.returns.safeParse(l,s);if(!p.success)throw new z.ZodError([o(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:$t.create(e).rest(jt.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||$t.create([]).rest(jt.create()),returns:r||jt.create(),typeName:q.ZodFunction,...V(n)})}};g.ZodFunction=Ri;var Rr=class extends F{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};g.ZodLazy=Rr;Rr.create=(t,e)=>new Rr({getter:t,typeName:q.ZodLazy,...V(e)});var Cr=class extends F{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(r,{received:r.data,code:z.ZodIssueCode.invalid_literal,expected:this._def.value}),b.INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}};g.ZodLiteral=Cr;Cr.create=(t,e)=>new Cr({value:t,typeName:q.ZodLiteral,...V(e)});function dy(t,e){return new Zr({values:t,typeName:q.ZodEnum,...V(e)})}var Zr=class t extends F{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return(0,b.addIssueToContext)(r,{expected:I.util.joinValues(n),received:r.parsedType,code:z.ZodIssueCode.invalid_type}),b.INVALID}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return(0,b.addIssueToContext)(r,{received:r.data,code:z.ZodIssueCode.invalid_enum_value,options:n}),b.INVALID}return(0,b.OK)(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};g.ZodEnum=Zr;Zr.create=dy;var Or=class extends F{_parse(e){let r=I.util.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==I.ZodParsedType.string&&n.parsedType!==I.ZodParsedType.number){let o=I.util.objectValues(r);return(0,b.addIssueToContext)(n,{expected:I.util.joinValues(o),received:n.parsedType,code:z.ZodIssueCode.invalid_type}),b.INVALID}if(this._cache||(this._cache=new Set(I.util.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=I.util.objectValues(r);return(0,b.addIssueToContext)(n,{received:n.data,code:z.ZodIssueCode.invalid_enum_value,options:o}),b.INVALID}return(0,b.OK)(e.data)}get enum(){return this._def.values}};g.ZodNativeEnum=Or;Or.create=(t,e)=>new Or({values:t,typeName:q.ZodNativeEnum,...V(e)});var nr=class extends F{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==I.ZodParsedType.promise&&r.common.async===!1)return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.promise,received:r.parsedType}),b.INVALID;let n=r.parsedType===I.ZodParsedType.promise?r.data:Promise.resolve(r.data);return(0,b.OK)(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};g.ZodPromise=nr;nr.create=(t,e)=>new nr({type:t,typeName:q.ZodPromise,...V(e)});var Ge=class extends F{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{(0,b.addIssueToContext)(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return b.INVALID;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?b.INVALID:c.status==="dirty"||r.value==="dirty"?(0,b.DIRTY)(c.value):c});{if(r.value==="aborted")return b.INVALID;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?b.INVALID:a.status==="dirty"||r.value==="dirty"?(0,b.DIRTY)(a.value):a}}if(o.type==="refinement"){let i=a=>{let c=o.refinement(a,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?b.INVALID:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?b.INVALID:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(o.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!(0,b.isValid)(i))return b.INVALID;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>(0,b.isValid)(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:r.value,value:a})):b.INVALID);I.util.assertNever(o)}};g.ZodEffects=Ge;g.ZodTransformer=Ge;Ge.create=(t,e,r)=>new Ge({schema:t,typeName:q.ZodEffects,effect:e,...V(r)});Ge.createWithPreprocess=(t,e,r)=>new Ge({schema:e,effect:{type:"preprocess",transform:t},typeName:q.ZodEffects,...V(r)});var ot=class extends F{_parse(e){return this._getType(e)===I.ZodParsedType.undefined?(0,b.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};g.ZodOptional=ot;ot.create=(t,e)=>new ot({innerType:t,typeName:q.ZodOptional,...V(e)});var kt=class extends F{_parse(e){return this._getType(e)===I.ZodParsedType.null?(0,b.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};g.ZodNullable=kt;kt.create=(t,e)=>new kt({innerType:t,typeName:q.ZodNullable,...V(e)});var jr=class extends F{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===I.ZodParsedType.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};g.ZodDefault=jr;jr.create=(t,e)=>new jr({innerType:t,typeName:q.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...V(e)});var Ar=class extends F{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return(0,b.isAsync)(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new z.ZodError(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new z.ZodError(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};g.ZodCatch=Ar;Ar.create=(t,e)=>new Ar({innerType:t,typeName:q.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...V(e)});var kn=class extends F{_parse(e){if(this._getType(e)!==I.ZodParsedType.nan){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.nan,received:n.parsedType}),b.INVALID}return{status:"valid",value:e.data}}};g.ZodNaN=kn;kn.create=t=>new kn({typeName:q.ZodNaN,...V(t)});g.BRAND=Symbol("zod_brand");var No=class extends F{_parse(e){let{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}};g.ZodBranded=No;var Mo=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?b.INVALID:s.status==="dirty"?(r.dirty(),(0,b.DIRTY)(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?b.INVALID:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:q.ZodPipeline})}};g.ZodPipeline=Mo;var Nr=class extends F{_parse(e){let r=this._def.innerType._parse(e),n=o=>((0,b.isValid)(o)&&(o.value=Object.freeze(o.value)),o);return(0,b.isAsync)(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};g.ZodReadonly=Nr;Nr.create=(t,e)=>new Nr({innerType:t,typeName:q.ZodReadonly,...V(e)});function ay(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function py(t,e={},r){return t?rr.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(i=>{if(!i){let a=ay(e,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=ay(e,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}}):rr.create()}g.late={object:Fe.lazycreate};var q;(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"})(q||(g.ZodFirstPartyTypeKind=q={}));var _P=(t,e={message:`Input not instance of ${t.name}`})=>py(r=>r instanceof t,e);g.instanceof=_P;var fy=tr.create;g.string=fy;var my=$r.create;g.number=my;var yP=kn.create;g.nan=yP;var vP=kr.create;g.bigint=vP;var hy=Sr.create;g.boolean=hy;var bP=Tr.create;g.date=bP;var wP=bn.create;g.symbol=wP;var xP=zr.create;g.undefined=xP;var $P=Pr.create;g.null=$P;var kP=rr.create;g.any=kP;var SP=jt.create;g.unknown=SP;var TP=ht.create;g.never=TP;var zP=wn.create;g.void=zP;var PP=At.create;g.array=PP;var IP=Fe.create;g.object=IP;var EP=Fe.strictCreate;g.strictObject=EP;var RP=Ir.create;g.union=RP;var CP=Ii.create;g.discriminatedUnion=CP;var ZP=Er.create;g.intersection=ZP;var OP=$t.create;g.tuple=OP;var jP=Ei.create;g.record=jP;var AP=xn.create;g.map=AP;var NP=$n.create;g.set=NP;var MP=Ri.create;g.function=MP;var DP=Rr.create;g.lazy=DP;var qP=Cr.create;g.literal=qP;var LP=Zr.create;g.enum=LP;var UP=Or.create;g.nativeEnum=UP;var VP=nr.create;g.promise=VP;var gy=Ge.create;g.effect=gy;g.transformer=gy;var FP=ot.create;g.optional=FP;var HP=kt.create;g.nullable=HP;var BP=Ge.createWithPreprocess;g.preprocess=BP;var JP=Mo.create;g.pipeline=JP;var KP=()=>fy().optional();g.ostring=KP;var GP=()=>my().optional();g.onumber=GP;var WP=()=>hy().optional();g.oboolean=WP;g.coerce={string:(t=>tr.create({...t,coerce:!0})),number:(t=>$r.create({...t,coerce:!0})),boolean:(t=>Sr.create({...t,coerce:!0})),bigint:(t=>kr.create({...t,coerce:!0})),date:(t=>Tr.create({...t,coerce:!0}))};g.NEVER=b.INVALID});var wd=P(it=>{"use strict";d();var YP=it&&it.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),Sn=it&&it.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&YP(e,t,r)};Object.defineProperty(it,"__esModule",{value:!0});Sn(Ti(),it);Sn(yd(),it);Sn(ny(),it);Sn(jo(),it);Sn(_y(),it);Sn(Si(),it)});var by=P(He=>{"use strict";d();var yy=He&&He.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),XP=He&&He.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),QP=He&&He.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&yy(e,t,r);return XP(e,t),e},eI=He&&He.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&yy(e,t,r)};Object.defineProperty(He,"__esModule",{value:!0});He.z=void 0;var vy=QP(wd());He.z=vy;eI(wd(),He);He.default=vy});var Tn=P(Ci=>{"use strict";d();Object.defineProperty(Ci,"__esModule",{value:!0});Ci.config=void 0;var Mr=by(),tI=Mr.z.object({MCP_SERVER_PORT:Mr.z.coerce.number().int().positive().default(3001),MCP_SERVER_HOST:Mr.z.string().default("0.0.0.0"),TOOLPILOT_MODE:Mr.z.enum(["dev","staging","production"]).default("dev"),TOOLPILOT_API_URL:Mr.z.string().default("https://api.neurynae.com"),NODE_ENV:Mr.z.enum(["development","test","production"]).default("development"),LOG_LEVEL:Mr.z.enum(["fatal","error","warn","info","debug","trace"]).default("info")});function rI(){let t=tI.safeParse(process.env);return t.success||(console.error("\u274C Invalid environment configuration:"),console.error(t.error.format()),process.exit(1)),t.data}Ci.config=rI()});d();d();d();d();d();d();d();d();var Yy=Object.freeze({status:"aborted"});function $(t,e,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(let l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var zt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Fo={};function Be(t){return t&&Object.assign(Fo,t),Fo}d();d();var G={};Ld(G,{BIGINT_FORMAT_RANGES:()=>vp,Class:()=>Hi,NUMBER_FORMAT_RANGES:()=>Xi,aborted:()=>ir,allowsEval:()=>Gi,assert:()=>rv,assertEqual:()=>Xy,assertIs:()=>ev,assertNever:()=>tv,assertNotEqual:()=>Qy,assignProp:()=>Ki,cached:()=>jn,captureStackTrace:()=>Bo,cleanEnum:()=>hv,cleanRegex:()=>Nn,clone:()=>Je,createTransparentProxy:()=>cv,defineLazy:()=>ae,esc:()=>sr,escapeRegex:()=>Nt,extend:()=>dv,finalizeIssue:()=>at,floatSafeRemainder:()=>Ji,getElementAtPath:()=>nv,getEnumValues:()=>On,getLengthableOrigin:()=>Mn,getParsedType:()=>av,getSizableOrigin:()=>bp,isObject:()=>Vr,isPlainObject:()=>Fr,issue:()=>Qi,joinValues:()=>Ho,jsonStringifyReplacer:()=>Bi,merge:()=>pv,normalizeParams:()=>M,nullish:()=>An,numKeys:()=>iv,omit:()=>lv,optionalKeys:()=>Yi,partial:()=>fv,pick:()=>uv,prefixIssues:()=>gt,primitiveTypes:()=>yp,promiseAllObject:()=>ov,propertyKeyTypes:()=>Wi,randomString:()=>sv,required:()=>mv,stringifyPrimitive:()=>Jo,unwrapMessage:()=>Zn});d();function Xy(t){return t}function Qy(t){return t}function ev(t){}function tv(t){throw new Error}function rv(t){}function On(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function Ho(t,e="|"){return t.map(r=>Jo(r)).join(e)}function Bi(t,e){return typeof e=="bigint"?e.toString():e}function jn(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function An(t){return t==null}function Nn(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Ji(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}function ae(t,e,r){Object.defineProperty(t,e,{get(){{let o=r();return t[e]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function Ki(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function nv(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function ov(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function sv(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function sr(t){return JSON.stringify(t)}var Bo=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Vr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Gi=jn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Fr(t){if(Vr(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(Vr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function iv(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var av=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Wi=new Set(["string","number","symbol"]),yp=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Nt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Je(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function M(t){let 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 cv(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function Jo(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function Yi(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var Xi={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]},vp={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function uv(t,e){let r={},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(r[o]=n.shape[o])}return Je(t,{...t._zod.def,shape:r,checks:[]})}function lv(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&delete r[o]}return Je(t,{...t._zod.def,shape:r,checks:[]})}function dv(t,e){if(!Fr(e))throw new Error("Invalid input to extend: expected a plain object");let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return Ki(this,"shape",n),n},checks:[]};return Je(t,r)}function pv(t,e){return Je(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return Ki(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function fv(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=t?new t({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=t?new t({type:"optional",innerType:n[s]}):n[s];return Je(e,{...e._zod.def,shape:o,checks:[]})}function mv(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new t({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new t({type:"nonoptional",innerType:n[s]});return Je(e,{...e._zod.def,shape:o,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 gt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Zn(t){return typeof t=="string"?t:t?.message}function at(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let o=Zn(t.inst?._zod.def?.error?.(t))??Zn(e?.error?.(t))??Zn(r.customError?.(t))??Zn(r.localeError?.(t))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function bp(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Mn(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Qi(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function hv(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var Hi=class{constructor(...e){}};var wp=(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,Bi,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Ko=$("$ZodError",wp),Dn=$("$ZodError",wp,{Parent:Error});function ea(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function ta(t,e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(t),n}var ra=t=>(e,r,n,o)=>{let s=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new zt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>at(c,s,Be())));throw Bo(a,o?.callee),a}return i.value},na=ra(Dn),oa=t=>async(e,r,n,o)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>at(c,s,Be())));throw Bo(a,o?.callee),a}return i.value},sa=oa(Dn),ia=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new zt;return s.issues.length?{success:!1,error:new(t??Ko)(s.issues.map(i=>at(i,o,Be())))}:{success:!0,data:s.value}},ar=ia(Dn),aa=t=>async(e,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>at(i,o,Be())))}:{success:!0,data:s.value}},cr=aa(Dn);d();d();d();var xp=/^[cC][^\s-]{8,}$/,$p=/^[0-9a-z]+$/,kp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Sp=/^[0-9a-vA-V]{20}$/,Tp=/^[A-Za-z0-9]{27}$/,zp=/^[a-zA-Z0-9_-]{21}$/,Pp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Ip=/^([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})$/,ca=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)$/;var Ep=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var _v="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Rp(){return new RegExp(_v,"u")}var Cp=/^(?:(?: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])$/,Zp=/^(([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})$/,Op=/^((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])$/,jp=/^(([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])$/,Ap=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ua=/^[A-Za-z0-9_-]*$/,Np=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Mp=/^\+(?:[0-9]){6,14}[0-9]$/,Dp="(?:(?:\\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])))",qp=new RegExp(`^${Dp}$`);function Lp(t){let 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 Up(t){return new RegExp(`^${Lp(t)}$`)}function Vp(t){let e=Lp({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${Dp}T(?:${n})$`)}var Fp=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var Hp=/^\d+$/,Bp=/^-?\d+(?:\.\d+)?/i,Jp=/true|false/i,Kp=/null/i;var Gp=/^[^A-Z]*$/,Wp=/^[^a-z]*$/;var $e=$("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Yp={number:"number",bigint:"bigint",object:"date"},la=$("$ZodCheckLessThan",(t,e)=>{$e.init(t,e);let r=Yp[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.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})}}),da=$("$ZodCheckGreaterThan",(t,e)=>{$e.init(t,e);let r=Yp[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.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})}}),Xp=$("$ZodCheckMultipleOf",(t,e)=>{$e.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):Ji(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})}}),Qp=$("$ZodCheckNumberFormat",(t,e)=>{$e.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=Xi[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=Hp)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:t})}});var ef=$("$ZodCheckMaxLength",(t,e)=>{var r;$e.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!An(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=Mn(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),tf=$("$ZodCheckMinLength",(t,e)=>{var r;$e.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!An(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=Mn(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),rf=$("$ZodCheckLengthEquals",(t,e)=>{var r;$e.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!An(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=Mn(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),qn=$("$ZodCheckStringFormat",(t,e)=>{var r,n;$e.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),nf=$("$ZodCheckRegex",(t,e)=>{qn.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})}}),of=$("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Gp),qn.init(t,e)}),sf=$("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Wp),qn.init(t,e)}),af=$("$ZodCheckIncludes",(t,e)=>{$e.init(t,e);let r=Nt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),cf=$("$ZodCheckStartsWith",(t,e)=>{$e.init(t,e);let r=new RegExp(`^${Nt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.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})}}),uf=$("$ZodCheckEndsWith",(t,e)=>{$e.init(t,e);let r=new RegExp(`.*${Nt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.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})}});var lf=$("$ZodCheckOverwrite",(t,e)=>{$e.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});d();var Wo=class{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}let n=e.split(`
|
|
9
|
+
deps: ${r}}`};var nT={keyword:"dependencies",type:"object",schemaType:"object",error:bt.error,code(t){let[e,r]=oT(t);Wg(t,e),Yg(t,r)}};function oT({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function Wg(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Co.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,Co.checkReportMissingProp)(t,u)}):(r.if((0,Nl._)`${c} && (${(0,Co.checkMissingProp)(t,a,s)})`),(0,Co.reportMissingProp)(t,s),r.else())}}bt.validatePropertyDeps=Wg;function Yg(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,rT.alwaysValidSchema)(s,e[a])||(r.if((0,Co.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}bt.validateSchemaDeps=Yg;bt.default=nT});var e_=P(Ml=>{"use strict";d();Object.defineProperty(Ml,"__esModule",{value:!0});var Qg=B(),sT=Q(),iT={message:"property name must be valid",params:({params:t})=>(0,Qg._)`{propertyName: ${t.propertyName}}`},aT={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:iT,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,sT.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,Qg.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};Ml.default=aT});var ql=P(Dl=>{"use strict";d();Object.defineProperty(Dl,"__esModule",{value:!0});var fi=tt(),ft=B(),cT=Rt(),mi=Q(),uT={message:"must NOT have additional properties",params:({params:t})=>(0,ft._)`{additionalProperty: ${t.additionalProperty}}`},lT={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:uT,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,mi.alwaysValidSchema)(i,r))return;let u=(0,fi.allSchemaProperties)(n.properties),l=(0,fi.allSchemaProperties)(n.patternProperties);p(),t.ok((0,ft._)`${s} === ${cT.default.errors}`);function p(){e.forIn("key",o,w=>{!u.length&&!l.length?f(w):e.if(m(w),()=>f(w))})}function m(w){let $;if(u.length>8){let S=(0,mi.schemaRefOrVal)(i,n.properties,"properties");$=(0,fi.isOwnProperty)(e,S,w)}else u.length?$=(0,ft.or)(...u.map(S=>(0,ft._)`${w} === ${S}`)):$=ft.nil;return l.length&&($=(0,ft.or)($,...l.map(S=>(0,ft._)`${(0,fi.usePattern)(t,S)}.test(${w})`))),(0,ft.not)($)}function h(w){e.code((0,ft._)`delete ${o}[${w}]`)}function f(w){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){h(w);return}if(r===!1){t.setParams({additionalProperty:w}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,mi.alwaysValidSchema)(i,r)){let $=e.name("valid");c.removeAdditional==="failing"?(_(w,$,!1),e.if((0,ft.not)($),()=>{t.reset(),h(w)})):(_(w,$),a||e.if((0,ft.not)($),()=>e.break()))}}function _(w,$,S){let T={keyword:"additionalProperties",dataProp:w,dataPropType:mi.Type.Str};S===!1&&Object.assign(T,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(T,$)}}};Dl.default=lT});var n_=P(Ul=>{"use strict";d();Object.defineProperty(Ul,"__esModule",{value:!0});var dT=yo(),t_=tt(),Ll=Q(),r_=ql(),pT={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&r_.default.code(new dT.KeywordCxt(s,r_.default,"additionalProperties"));let i=(0,t_.allSchemaProperties)(r);for(let p of i)s.definedProperties.add(p);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Ll.mergeEvaluated.props(e,(0,Ll.toHash)(i),s.props));let a=i.filter(p=>!(0,Ll.alwaysValidSchema)(s,r[p]));if(a.length===0)return;let c=e.name("valid");for(let p of a)u(p)?l(p):(e.if((0,t_.propertyInData)(e,o,p,s.opts.ownProperties)),l(p),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(p),t.ok(c);function u(p){return s.opts.useDefaults&&!s.compositeRule&&r[p].default!==void 0}function l(p){t.subschema({keyword:"properties",schemaProp:p,dataProp:p},c)}}};Ul.default=pT});var a_=P(Vl=>{"use strict";d();Object.defineProperty(Vl,"__esModule",{value:!0});var o_=tt(),hi=B(),s_=Q(),i_=Q(),fT={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,o_.allSchemaProperties)(r),c=a.filter(_=>(0,s_.alwaysValidSchema)(s,r[_]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof hi.Name)&&(s.props=(0,i_.evaluatedPropsToName)(e,s.props));let{props:p}=s;m();function m(){for(let _ of a)u&&h(_),s.allErrors?f(_):(e.var(l,!0),f(_),e.if(l))}function h(_){for(let w in u)new RegExp(_).test(w)&&(0,s_.checkStrictMode)(s,`property ${w} matches pattern ${_} (use allowMatchingProperties)`)}function f(_){e.forIn("key",n,w=>{e.if((0,hi._)`${(0,o_.usePattern)(t,_)}.test(${w})`,()=>{let $=c.includes(_);$||t.subschema({keyword:"patternProperties",schemaProp:_,dataProp:w,dataPropType:i_.Type.Str},l),s.opts.unevaluated&&p!==!0?e.assign((0,hi._)`${p}[${w}]`,!0):!$&&!s.allErrors&&e.if((0,hi.not)(l),()=>e.break())})})}}};Vl.default=fT});var c_=P(Fl=>{"use strict";d();Object.defineProperty(Fl,"__esModule",{value:!0});var mT=Q(),hT={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,mT.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Fl.default=hT});var u_=P(Hl=>{"use strict";d();Object.defineProperty(Hl,"__esModule",{value:!0});var gT=tt(),_T={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:gT.validateUnion,error:{message:"must match a schema in anyOf"}};Hl.default=_T});var l_=P(Bl=>{"use strict";d();Object.defineProperty(Bl,"__esModule",{value:!0});var gi=B(),yT=Q(),vT={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,gi._)`{passingSchemas: ${t.passing}}`},bT={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:vT,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,p)=>{let m;(0,yT.alwaysValidSchema)(o,l)?e.var(c,!0):m=t.subschema({keyword:"oneOf",schemaProp:p,compositeRule:!0},c),p>0&&e.if((0,gi._)`${c} && ${i}`).assign(i,!1).assign(a,(0,gi._)`[${a}, ${p}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,p),m&&t.mergeEvaluated(m,gi.Name)})})}}};Bl.default=bT});var d_=P(Jl=>{"use strict";d();Object.defineProperty(Jl,"__esModule",{value:!0});var wT=Q(),xT={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,wT.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};Jl.default=xT});var m_=P(Kl=>{"use strict";d();Object.defineProperty(Kl,"__esModule",{value:!0});var _i=B(),f_=Q(),kT={message:({params:t})=>(0,_i.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,_i._)`{failingKeyword: ${t.ifClause}}`},$T={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:kT,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,f_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=p_(n,"then"),s=p_(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,_i.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,p){return()=>{let m=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(m,i),p?e.assign(p,(0,_i._)`${l}`):t.setParams({ifClause:l})}}}};function p_(t,e){let r=t.schema[e];return r!==void 0&&!(0,f_.alwaysValidSchema)(t,r)}Kl.default=$T});var h_=P(Gl=>{"use strict";d();Object.defineProperty(Gl,"__esModule",{value:!0});var ST=Q(),TT={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,ST.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Gl.default=TT});var g_=P(Wl=>{"use strict";d();Object.defineProperty(Wl,"__esModule",{value:!0});var zT=Cl(),PT=Bg(),IT=Zl(),ET=Kg(),RT=Gg(),CT=Xg(),ZT=e_(),OT=ql(),jT=n_(),AT=a_(),NT=c_(),MT=u_(),DT=l_(),qT=d_(),LT=m_(),UT=h_();function VT(t=!1){let e=[NT.default,MT.default,DT.default,qT.default,LT.default,UT.default,ZT.default,OT.default,CT.default,jT.default,AT.default];return t?e.push(PT.default,ET.default):e.push(zT.default,IT.default),e.push(RT.default),e}Wl.default=VT});var __=P(Yl=>{"use strict";d();Object.defineProperty(Yl,"__esModule",{value:!0});var ve=B(),FT={message:({schemaCode:t})=>(0,ve.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ve._)`{format: ${t}}`},HT={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:FT,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:p}=a;if(!c.validateFormats)return;o?m():h();function m(){let f=r.scopeValue("formats",{ref:p.formats,code:c.code.formats}),_=r.const("fDef",(0,ve._)`${f}[${i}]`),w=r.let("fType"),$=r.let("format");r.if((0,ve._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(w,(0,ve._)`${_}.type || "string"`).assign($,(0,ve._)`${_}.validate`),()=>r.assign(w,(0,ve._)`"string"`).assign($,_)),t.fail$data((0,ve.or)(S(),T()));function S(){return c.strictSchema===!1?ve.nil:(0,ve._)`${i} && !${$}`}function T(){let R=l.$async?(0,ve._)`(${_}.async ? await ${$}(${n}) : ${$}(${n}))`:(0,ve._)`${$}(${n})`,N=(0,ve._)`(typeof ${$} == "function" ? ${R} : ${$}.test(${n}))`;return(0,ve._)`${$} && ${$} !== true && ${w} === ${e} && !${N}`}}function h(){let f=p.formats[s];if(!f){S();return}if(f===!0)return;let[_,w,$]=T(f);_===e&&t.pass(R());function S(){if(c.strictSchema===!1){p.logger.warn(N());return}throw new Error(N());function N(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function T(N){let Ce=N instanceof RegExp?(0,ve.regexpCode)(N):c.code.formats?(0,ve._)`${c.code.formats}${(0,ve.getProperty)(s)}`:void 0,We=r.scopeValue("formats",{key:s,ref:N,code:Ce});return typeof N=="object"&&!(N instanceof RegExp)?[N.type||"string",N.validate,(0,ve._)`${We}.validate`]:["string",N,We]}function R(){if(typeof f=="object"&&!(f instanceof RegExp)&&f.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ve._)`await ${$}(${n})`}return typeof w=="function"?(0,ve._)`${$}(${n})`:(0,ve._)`${$}.test(${n})`}}}};Yl.default=HT});var y_=P(Xl=>{"use strict";d();Object.defineProperty(Xl,"__esModule",{value:!0});var BT=__(),JT=[BT.default];Xl.default=JT});var v_=P(pn=>{"use strict";d();Object.defineProperty(pn,"__esModule",{value:!0});pn.contentVocabulary=pn.metadataVocabulary=void 0;pn.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];pn.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var w_=P(Ql=>{"use strict";d();Object.defineProperty(Ql,"__esModule",{value:!0});var KT=Pg(),GT=Ug(),WT=g_(),YT=y_(),b_=v_(),XT=[KT.default,GT.default,(0,WT.default)(),YT.default,b_.metadataVocabulary,b_.contentVocabulary];Ql.default=XT});var k_=P(yi=>{"use strict";d();Object.defineProperty(yi,"__esModule",{value:!0});yi.DiscrError=void 0;var x_;(function(t){t.Tag="tag",t.Mapping="mapping"})(x_||(yi.DiscrError=x_={}))});var S_=P(td=>{"use strict";d();Object.defineProperty(td,"__esModule",{value:!0});var fn=B(),ed=k_(),$_=ei(),QT=vo(),ez=Q(),tz={message:({params:{discrError:t,tagName:e}})=>t===ed.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,fn._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},rz={keyword:"discriminator",type:"object",schemaType:"object",error:tz,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,fn._)`${r}${(0,fn.getProperty)(a)}`);e.if((0,fn._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:ed.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let h=m();e.if(!1);for(let f in h)e.elseIf((0,fn._)`${u} === ${f}`),e.assign(c,p(h[f]));e.else(),t.error(!1,{discrError:ed.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function p(h){let f=e.name("valid"),_=t.subschema({keyword:"oneOf",schemaProp:h},f);return t.mergeEvaluated(_,fn.Name),f}function m(){var h;let f={},_=$(o),w=!0;for(let R=0;R<i.length;R++){let N=i[R];if(N?.$ref&&!(0,ez.schemaHasRulesButRef)(N,s.self.RULES)){let We=N.$ref;if(N=$_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,We),N instanceof $_.SchemaEnv&&(N=N.schema),N===void 0)throw new QT.default(s.opts.uriResolver,s.baseId,We)}let Ce=(h=N?.properties)===null||h===void 0?void 0:h[a];if(typeof Ce!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);w=w&&(_||$(N)),S(Ce,R)}if(!w)throw new Error(`discriminator: "${a}" must be required`);return f;function $({required:R}){return Array.isArray(R)&&R.includes(a)}function S(R,N){if(R.const)T(R.const,N);else if(R.enum)for(let Ce of R.enum)T(Ce,N);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function T(R,N){if(typeof R!="string"||R in f)throw new Error(`discriminator: "${a}" values must be unique strings`);f[R]=N}}}};td.default=rz});var T_=P((AN,nz)=>{nz.exports={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0}});var nd=P((fe,rd)=>{"use strict";d();Object.defineProperty(fe,"__esModule",{value:!0});fe.MissingRefError=fe.ValidationError=fe.CodeGen=fe.Name=fe.nil=fe.stringify=fe.str=fe._=fe.KeywordCxt=fe.Ajv=void 0;var oz=xg(),sz=w_(),iz=S_(),z_=T_(),az=["/properties"],vi="http://json-schema.org/draft-07/schema",mn=class extends oz.default{_addVocabularies(){super._addVocabularies(),sz.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(iz.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(z_,az):z_;this.addMetaSchema(e,vi,!1),this.refs["http://json-schema.org/schema"]=vi}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(vi)?vi:void 0)}};fe.Ajv=mn;rd.exports=fe=mn;rd.exports.Ajv=mn;Object.defineProperty(fe,"__esModule",{value:!0});fe.default=mn;var cz=yo();Object.defineProperty(fe,"KeywordCxt",{enumerable:!0,get:function(){return cz.KeywordCxt}});var hn=B();Object.defineProperty(fe,"_",{enumerable:!0,get:function(){return hn._}});Object.defineProperty(fe,"str",{enumerable:!0,get:function(){return hn.str}});Object.defineProperty(fe,"stringify",{enumerable:!0,get:function(){return hn.stringify}});Object.defineProperty(fe,"nil",{enumerable:!0,get:function(){return hn.nil}});Object.defineProperty(fe,"Name",{enumerable:!0,get:function(){return hn.Name}});Object.defineProperty(fe,"CodeGen",{enumerable:!0,get:function(){return hn.CodeGen}});var uz=Xs();Object.defineProperty(fe,"ValidationError",{enumerable:!0,get:function(){return uz.default}});var lz=vo();Object.defineProperty(fe,"MissingRefError",{enumerable:!0,get:function(){return lz.default}})});var j_=P(xt=>{"use strict";d();Object.defineProperty(xt,"__esModule",{value:!0});xt.formatNames=xt.fastFormats=xt.fullFormats=void 0;function wt(t,e){return{validate:t,compare:e}}xt.fullFormats={date:wt(R_,ad),time:wt(sd(!0),cd),"date-time":wt(P_(!0),Z_),"iso-time":wt(sd(),C_),"iso-date-time":wt(P_(),O_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:gz,"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:kz,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:_z,int32:{type:"number",validate:bz},int64:{type:"number",validate:wz},float:{type:"number",validate:E_},double:{type:"number",validate:E_},password:!0,binary:!0};xt.fastFormats={...xt.fullFormats,date:wt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,ad),time:wt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,cd),"date-time":wt(/^\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,Z_),"iso-time":wt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,C_),"iso-date-time":wt(/^\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,O_),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};xt.formatNames=Object.keys(xt.fullFormats);function dz(t){return t%4===0&&(t%100!==0||t%400===0)}var pz=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,fz=[0,31,28,31,30,31,30,31,31,30,31,30,31];function R_(t){let e=pz.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&dz(r)?29:fz[n])}function ad(t,e){if(t&&e)return t>e?1:t<e?-1:0}var od=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function sd(t){return function(r){let n=od.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let p=s-l*c,m=o-u*c-(p<0?1:0);return(m===23||m===-1)&&(p===59||p===-1)&&i<61}}function cd(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function C_(t,e){if(!(t&&e))return;let r=od.exec(t),n=od.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var id=/t|\s/i;function P_(t){let e=sd(t);return function(n){let o=n.split(id);return o.length===2&&R_(o[0])&&e(o[1])}}function Z_(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function O_(t,e){if(!(t&&e))return;let[r,n]=t.split(id),[o,s]=e.split(id),i=ad(r,o);if(i!==void 0)return i||cd(n,s)}var mz=/\/|:/,hz=/^(?:[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 gz(t){return mz.test(t)&&hz.test(t)}var I_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function _z(t){return I_.lastIndex=0,I_.test(t)}var yz=-(2**31),vz=2**31-1;function bz(t){return Number.isInteger(t)&&t<=vz&&t>=yz}function wz(t){return Number.isInteger(t)}function E_(){return!0}var xz=/[^\\]\\Z/;function kz(t){if(xz.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var A_=P(gn=>{"use strict";d();Object.defineProperty(gn,"__esModule",{value:!0});gn.formatLimitDefinition=void 0;var $z=nd(),mt=B(),Yt=mt.operators,bi={formatMaximum:{okStr:"<=",ok:Yt.LTE,fail:Yt.GT},formatMinimum:{okStr:">=",ok:Yt.GTE,fail:Yt.LT},formatExclusiveMaximum:{okStr:"<",ok:Yt.LT,fail:Yt.GTE},formatExclusiveMinimum:{okStr:">",ok:Yt.GT,fail:Yt.LTE}},Sz={message:({keyword:t,schemaCode:e})=>(0,mt.str)`should be ${bi[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,mt._)`{comparison: ${bi[t].okStr}, limit: ${e}}`};gn.formatLimitDefinition={keyword:Object.keys(bi),type:"string",schemaType:"string",$data:!0,error:Sz,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new $z.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let m=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),h=e.const("fmt",(0,mt._)`${m}[${c.schemaCode}]`);t.fail$data((0,mt.or)((0,mt._)`typeof ${h} != "object"`,(0,mt._)`${h} instanceof RegExp`,(0,mt._)`typeof ${h}.compare != "function"`,p(h)))}function l(){let m=c.schema,h=a.formats[m];if(!h||h===!0)return;if(typeof h!="object"||h instanceof RegExp||typeof h.compare!="function")throw new Error(`"${o}": format "${m}" does not define "compare" function`);let f=e.scopeValue("formats",{key:m,ref:h,code:i.code.formats?(0,mt._)`${i.code.formats}${(0,mt.getProperty)(m)}`:void 0});t.fail$data(p(f))}function p(m){return(0,mt._)`${m}.compare(${r}, ${n}) ${bi[o].fail} 0`}},dependencies:["format"]};var Tz=t=>(t.addKeyword(gn.formatLimitDefinition),t);gn.default=Tz});var q_=P((Zo,D_)=>{"use strict";d();Object.defineProperty(Zo,"__esModule",{value:!0});var _n=j_(),zz=A_(),ud=B(),N_=new ud.Name("fullFormats"),Pz=new ud.Name("fastFormats"),ld=(t,e={keywords:!0})=>{if(Array.isArray(e))return M_(t,e,_n.fullFormats,N_),t;let[r,n]=e.mode==="fast"?[_n.fastFormats,Pz]:[_n.fullFormats,N_],o=e.formats||_n.formatNames;return M_(t,o,r,n),e.keywords&&(0,zz.default)(t),t};ld.get=(t,e="full")=>{let n=(e==="fast"?_n.fastFormats:_n.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function M_(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,ud._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}D_.exports=Zo=ld;Object.defineProperty(Zo,"__esModule",{value:!0});Zo.default=ld});var jo=P(le=>{"use strict";d();Object.defineProperty(le,"__esModule",{value:!0});le.getParsedType=le.ZodParsedType=le.objectUtil=le.util=void 0;var md;(function(t){t.assertEqual=o=>{};function e(o){}t.assertIs=e;function r(o){throw new Error}t.assertNever=r,t.arrayToEnum=o=>{let s={};for(let i of o)s[i]=i;return s},t.getValidEnumValues=o=>{let s=t.objectKeys(o).filter(a=>typeof o[o[a]]!="number"),i={};for(let a of s)i[a]=o[a];return t.objectValues(i)},t.objectValues=o=>t.objectKeys(o).map(function(s){return o[s]}),t.objectKeys=typeof Object.keys=="function"?o=>Object.keys(o):o=>{let s=[];for(let i in o)Object.prototype.hasOwnProperty.call(o,i)&&s.push(i);return s},t.find=(o,s)=>{for(let i of o)if(s(i))return i},t.isInteger=typeof Number.isInteger=="function"?o=>Number.isInteger(o):o=>typeof o=="number"&&Number.isFinite(o)&&Math.floor(o)===o;function n(o,s=" | "){return o.map(i=>typeof i=="string"?`'${i}'`:i).join(s)}t.joinValues=n,t.jsonStringifyReplacer=(o,s)=>typeof s=="bigint"?s.toString():s})(md||(le.util=md={}));var X_;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(X_||(le.objectUtil=X_={}));le.ZodParsedType=md.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);var jz=t=>{switch(typeof t){case"undefined":return le.ZodParsedType.undefined;case"string":return le.ZodParsedType.string;case"number":return Number.isNaN(t)?le.ZodParsedType.nan:le.ZodParsedType.number;case"boolean":return le.ZodParsedType.boolean;case"function":return le.ZodParsedType.function;case"bigint":return le.ZodParsedType.bigint;case"symbol":return le.ZodParsedType.symbol;case"object":return Array.isArray(t)?le.ZodParsedType.array:t===null?le.ZodParsedType.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?le.ZodParsedType.promise:typeof Map<"u"&&t instanceof Map?le.ZodParsedType.map:typeof Set<"u"&&t instanceof Set?le.ZodParsedType.set:typeof Date<"u"&&t instanceof Date?le.ZodParsedType.date:le.ZodParsedType.object;default:return le.ZodParsedType.unknown}};le.getParsedType=jz});var Si=P(Qt=>{"use strict";d();Object.defineProperty(Qt,"__esModule",{value:!0});Qt.ZodError=Qt.quotelessJson=Qt.ZodIssueCode=void 0;var Q_=jo();Qt.ZodIssueCode=Q_.util.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"]);var Az=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");Qt.quotelessJson=Az;var Ao=class t 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]};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union")i.unionErrors.map(o);else if(i.code==="invalid_return_type")o(i.returnTypeError);else if(i.code==="invalid_arguments")o(i.argumentsError);else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(this),n}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Q_.util.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){let r={},n=[];for(let o of this.issues)if(o.path.length>0){let s=o.path[0];r[s]=r[s]||[],r[s].push(e(o))}else n.push(e(o));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};Qt.ZodError=Ao;Ao.create=t=>new Ao(t)});var gd=P(hd=>{"use strict";d();Object.defineProperty(hd,"__esModule",{value:!0});var Re=Si(),xr=jo(),Nz=(t,e)=>{let r;switch(t.code){case Re.ZodIssueCode.invalid_type:t.received===xr.ZodParsedType.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case Re.ZodIssueCode.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,xr.util.jsonStringifyReplacer)}`;break;case Re.ZodIssueCode.unrecognized_keys:r=`Unrecognized key(s) in object: ${xr.util.joinValues(t.keys,", ")}`;break;case Re.ZodIssueCode.invalid_union:r="Invalid input";break;case Re.ZodIssueCode.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${xr.util.joinValues(t.options)}`;break;case Re.ZodIssueCode.invalid_enum_value:r=`Invalid enum value. Expected ${xr.util.joinValues(t.options)}, received '${t.received}'`;break;case Re.ZodIssueCode.invalid_arguments:r="Invalid function arguments";break;case Re.ZodIssueCode.invalid_return_type:r="Invalid function return type";break;case Re.ZodIssueCode.invalid_date:r="Invalid date";break;case Re.ZodIssueCode.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}"`:xr.util.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case Re.ZodIssueCode.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 Re.ZodIssueCode.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 Re.ZodIssueCode.custom:r="Invalid input";break;case Re.ZodIssueCode.invalid_intersection_types:r="Intersection results could not be merged";break;case Re.ZodIssueCode.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case Re.ZodIssueCode.not_finite:r="Number must be finite";break;default:r=e.defaultError,xr.util.assertNever(t)}return{message:r}};hd.default=Nz});var Ti=P(er=>{"use strict";d();var Mz=er&&er.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(er,"__esModule",{value:!0});er.defaultErrorMap=void 0;er.setErrorMap=Dz;er.getErrorMap=qz;var ey=Mz(gd());er.defaultErrorMap=ey.default;var ty=ey.default;function Dz(t){ty=t}function qz(){return ty}});var yd=P(ne=>{"use strict";d();var Lz=ne&&ne.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(ne,"__esModule",{value:!0});ne.isAsync=ne.isValid=ne.isDirty=ne.isAborted=ne.OK=ne.DIRTY=ne.INVALID=ne.ParseStatus=ne.EMPTY_PATH=ne.makeIssue=void 0;ne.addIssueToContext=Fz;var Uz=Ti(),ry=Lz(gd()),Vz=t=>{let{data:e,path:r,errorMaps:n,issueData:o}=t,s=[...r,...o.path||[]],i={...o,path:s};if(o.message!==void 0)return{...o,path:s,message:o.message};let a="",c=n.filter(u=>!!u).slice().reverse();for(let u of c)a=u(i,{data:e,defaultError:a}).message;return{...o,path:s,message:a}};ne.makeIssue=Vz;ne.EMPTY_PATH=[];function Fz(t,e){let r=(0,Uz.getErrorMap)(),n=(0,ne.makeIssue)({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===ry.default?void 0:ry.default].filter(o=>!!o)});t.common.issues.push(n)}var _d=class t{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){let n=[];for(let o of r){if(o.status==="aborted")return ne.INVALID;o.status==="dirty"&&e.dirty(),n.push(o.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){let n=[];for(let o of r){let s=await o.key,i=await o.value;n.push({key:s,value:i})}return t.mergeObjectSync(e,n)}static mergeObjectSync(e,r){let n={};for(let o of r){let{key:s,value:i}=o;if(s.status==="aborted"||i.status==="aborted")return ne.INVALID;s.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof i.value<"u"||o.alwaysSet)&&(n[s.value]=i.value)}return{status:e.value,value:n}}};ne.ParseStatus=_d;ne.INVALID=Object.freeze({status:"aborted"});var Hz=t=>({status:"dirty",value:t});ne.DIRTY=Hz;var Bz=t=>({status:"valid",value:t});ne.OK=Bz;var Jz=t=>t.status==="aborted";ne.isAborted=Jz;var Kz=t=>t.status==="dirty";ne.isDirty=Kz;var Gz=t=>t.status==="valid";ne.isValid=Gz;var Wz=t=>typeof Promise<"u"&&t instanceof Promise;ne.isAsync=Wz});var oy=P(ny=>{"use strict";d();Object.defineProperty(ny,"__esModule",{value:!0})});var iy=P(zi=>{"use strict";d();Object.defineProperty(zi,"__esModule",{value:!0});zi.errorUtil=void 0;var sy;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(sy||(zi.errorUtil=sy={}))});var yy=P(g=>{"use strict";d();Object.defineProperty(g,"__esModule",{value:!0});g.discriminatedUnion=g.date=g.boolean=g.bigint=g.array=g.any=g.coerce=g.ZodFirstPartyTypeKind=g.late=g.ZodSchema=g.Schema=g.ZodReadonly=g.ZodPipeline=g.ZodBranded=g.BRAND=g.ZodNaN=g.ZodCatch=g.ZodDefault=g.ZodNullable=g.ZodOptional=g.ZodTransformer=g.ZodEffects=g.ZodPromise=g.ZodNativeEnum=g.ZodEnum=g.ZodLiteral=g.ZodLazy=g.ZodFunction=g.ZodSet=g.ZodMap=g.ZodRecord=g.ZodTuple=g.ZodIntersection=g.ZodDiscriminatedUnion=g.ZodUnion=g.ZodObject=g.ZodArray=g.ZodVoid=g.ZodNever=g.ZodUnknown=g.ZodAny=g.ZodNull=g.ZodUndefined=g.ZodSymbol=g.ZodDate=g.ZodBoolean=g.ZodBigInt=g.ZodNumber=g.ZodString=g.ZodType=void 0;g.NEVER=g.void=g.unknown=g.union=g.undefined=g.tuple=g.transformer=g.symbol=g.string=g.strictObject=g.set=g.record=g.promise=g.preprocess=g.pipeline=g.ostring=g.optional=g.onumber=g.oboolean=g.object=g.number=g.nullable=g.null=g.never=g.nativeEnum=g.nan=g.map=g.literal=g.lazy=g.intersection=g.instanceof=g.function=g.enum=g.effect=void 0;g.datetimeRegex=dy;g.custom=fy;var z=Si(),Pi=Ti(),j=iy(),b=yd(),I=jo(),st=class{constructor(e,r,n,o){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=o}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}},ay=(t,e)=>{if((0,b.isValid)(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;let r=new z.ZodError(t.common.issues);return this._error=r,this._error}}};function V(t){if(!t)return{};let{errorMap:e,invalid_type_error:r,required_error:n,description:o}=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:o}:{errorMap:(i,a)=>{let{message:c}=t;return i.code==="invalid_enum_value"?{message:c??a.defaultError}:typeof a.data>"u"?{message:c??n??a.defaultError}:i.code!=="invalid_type"?{message:a.defaultError}:{message:c??r??a.defaultError}},description:o}}var F=class{get description(){return this._def.description}_getType(e){return(0,I.getParsedType)(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:(0,I.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new b.ParseStatus,ctx:{common:e.parent.common,data:e.data,parsedType:(0,I.getParsedType)(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if((0,b.isAsync)(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){let r=this._parse(e);return Promise.resolve(r)}parse(e,r){let n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){let n={common:{issues:[],async:r?.async??!1,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,I.getParsedType)(e)},o=this._parseSync({data:e,path:n.path,parent:n});return ay(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,I.getParsedType)(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return(0,b.isValid)(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=>(0,b.isValid)(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(e,r){let n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:!0},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:(0,I.getParsedType)(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await((0,b.isAsync)(o)?o:Promise.resolve(o));return ay(n,s)}refine(e,r){let n=o=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(o):r;return this._refinement((o,s)=>{let i=e(o),a=()=>s.addIssue({code:z.ZodIssueCode.custom,...n(o)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,r){return this._refinement((n,o)=>e(n)?!0:(o.addIssue(typeof r=="function"?r(n,o):r),!1))}_refinement(e){return new Ge({schema:this,typeName:q.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 ot.create(this,this._def)}nullable(){return $t.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return At.create(this)}promise(){return nr.create(this,this._def)}or(e){return Ir.create([this,e],this._def)}and(e){return Er.create(this,e,this._def)}transform(e){return new Ge({...V(this._def),schema:this,typeName:q.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new jr({...V(this._def),innerType:this,defaultValue:r,typeName:q.ZodDefault})}brand(){return new No({typeName:q.ZodBranded,type:this,...V(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new Ar({...V(this._def),innerType:this,catchValue:r,typeName:q.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Mo.create(this,e)}readonly(){return Nr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};g.ZodType=F;g.Schema=F;g.ZodSchema=F;var Yz=/^c[^\s-]{8,}$/i,Xz=/^[0-9a-z]+$/,Qz=/^[0-9A-HJKMNP-TV-Z]{26}$/i,eP=/^[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,tP=/^[a-z0-9_-]{21}$/i,rP=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,nP=/^[-+]?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)?)??$/,oP=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,sP="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",vd,iP=/^(?:(?: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])$/,aP=/^(?:(?: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])$/,cP=/^(([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]))$/,uP=/^(([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])$/,lP=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,dP=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,uy="((\\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])))",pP=new RegExp(`^${uy}$`);function ly(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);let r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function fP(t){return new RegExp(`^${ly(t)}$`)}function dy(t){let e=`${uy}T${ly(t)}`,r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function mP(t,e){return!!((e==="v4"||!e)&&iP.test(t)||(e==="v6"||!e)&&cP.test(t))}function hP(t,e){if(!rP.test(t))return!1;try{let[r]=t.split(".");if(!r)return!1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),o=JSON.parse(atob(n));return!(typeof o!="object"||o===null||"typ"in o&&o?.typ!=="JWT"||!o.alg||e&&o.alg!==e)}catch{return!1}}function gP(t,e){return!!((e==="v4"||!e)&&aP.test(t)||(e==="v6"||!e)&&uP.test(t))}var tr=class t extends F{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==I.ZodParsedType.string){let s=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(s,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.string,received:s.parsedType}),b.INVALID}let n=new b.ParseStatus,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="max")e.data.length>s.value&&(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),n.dirty());else if(s.kind==="length"){let i=e.data.length>s.value,a=e.data.length<s.value;(i||a)&&(o=this._getOrReturnCtx(e,o),i?(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")oP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"email",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")vd||(vd=new RegExp(sP,"u")),vd.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"emoji",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")eP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"uuid",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")tP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"nanoid",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")Yz.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"cuid",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Xz.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"cuid2",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")Qz.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"ulid",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"url",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"regex",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),n.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?dy(s).test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?pP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?fP(s).test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?nP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"duration",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?mP(e.data,s.version)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"ip",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?hP(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"jwt",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?gP(e.data,s.version)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"cidr",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?lP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"base64",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?dP.test(e.data)||(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{validation:"base64url",code:z.ZodIssueCode.invalid_string,message:s.message}),n.dirty()):I.util.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:z.ZodIssueCode.invalid_string,...j.errorUtil.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...j.errorUtil.errToObj(e)})}url(e){return this._addCheck({kind:"url",...j.errorUtil.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...j.errorUtil.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...j.errorUtil.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...j.errorUtil.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...j.errorUtil.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...j.errorUtil.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...j.errorUtil.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...j.errorUtil.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...j.errorUtil.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...j.errorUtil.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...j.errorUtil.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...j.errorUtil.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,...j.errorUtil.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,...j.errorUtil.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...j.errorUtil.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...j.errorUtil.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...j.errorUtil.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...j.errorUtil.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...j.errorUtil.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...j.errorUtil.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...j.errorUtil.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...j.errorUtil.errToObj(r)})}nonempty(e){return this.min(1,j.errorUtil.errToObj(e))}trim(){return new t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t({...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(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};g.ZodString=tr;tr.create=t=>new tr({checks:[],typeName:q.ZodString,coerce:t?.coerce??!1,...V(t)});function _P(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}var kr=class t extends F{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)!==I.ZodParsedType.number){let s=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(s,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.number,received:s.parsedType}),b.INVALID}let n,o=new b.ParseStatus;for(let s of this._def.checks)s.kind==="int"?I.util.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:"integer",received:"float",message:s.message}),o.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?_P(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.not_finite,message:s.message}),o.dirty()):I.util.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,j.errorUtil.toString(r))}gt(e,r){return this.setLimit("min",e,!1,j.errorUtil.toString(r))}lte(e,r){return this.setLimit("max",e,!0,j.errorUtil.toString(r))}lt(e,r){return this.setLimit("max",e,!1,j.errorUtil.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:j.errorUtil.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:j.errorUtil.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:j.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:j.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:j.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:j.errorUtil.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:j.errorUtil.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:j.errorUtil.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:j.errorUtil.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:j.errorUtil.toString(e)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let 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"&&I.util.isInteger(e.value))}get isFinite(){let e=null,r=null;for(let 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)}};g.ZodNumber=kr;kr.create=t=>new kr({checks:[],typeName:q.ZodNumber,coerce:t?.coerce||!1,...V(t)});var $r=class t extends F{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)!==I.ZodParsedType.bigint)return this._getInvalidInput(e);let n,o=new b.ParseStatus;for(let s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),o.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):I.util.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.bigint,received:r.parsedType}),b.INVALID}gte(e,r){return this.setLimit("min",e,!0,j.errorUtil.toString(r))}gt(e,r){return this.setLimit("min",e,!1,j.errorUtil.toString(r))}lte(e,r){return this.setLimit("max",e,!0,j.errorUtil.toString(r))}lt(e,r){return this.setLimit("max",e,!1,j.errorUtil.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:j.errorUtil.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:j.errorUtil.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:j.errorUtil.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:j.errorUtil.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:j.errorUtil.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:j.errorUtil.toString(r)})}get minValue(){let e=null;for(let r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}};g.ZodBigInt=$r;$r.create=t=>new $r({checks:[],typeName:q.ZodBigInt,coerce:t?.coerce??!1,...V(t)});var Sr=class extends F{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==I.ZodParsedType.boolean){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.boolean,received:n.parsedType}),b.INVALID}return(0,b.OK)(e.data)}};g.ZodBoolean=Sr;Sr.create=t=>new Sr({typeName:q.ZodBoolean,coerce:t?.coerce||!1,...V(t)});var Tr=class t extends F{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==I.ZodParsedType.date){let s=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(s,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.date,received:s.parsedType}),b.INVALID}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(s,{code:z.ZodIssueCode.invalid_date}),b.INVALID}let n=new b.ParseStatus,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),n.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(o=this._getOrReturnCtx(e,o),(0,b.addIssueToContext)(o,{code:z.ZodIssueCode.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):I.util.assertNever(s);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:j.errorUtil.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:j.errorUtil.toString(r)})}get minDate(){let e=null;for(let 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(let r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}};g.ZodDate=Tr;Tr.create=t=>new Tr({checks:[],coerce:t?.coerce||!1,typeName:q.ZodDate,...V(t)});var bn=class extends F{_parse(e){if(this._getType(e)!==I.ZodParsedType.symbol){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.symbol,received:n.parsedType}),b.INVALID}return(0,b.OK)(e.data)}};g.ZodSymbol=bn;bn.create=t=>new bn({typeName:q.ZodSymbol,...V(t)});var zr=class extends F{_parse(e){if(this._getType(e)!==I.ZodParsedType.undefined){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.undefined,received:n.parsedType}),b.INVALID}return(0,b.OK)(e.data)}};g.ZodUndefined=zr;zr.create=t=>new zr({typeName:q.ZodUndefined,...V(t)});var Pr=class extends F{_parse(e){if(this._getType(e)!==I.ZodParsedType.null){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.null,received:n.parsedType}),b.INVALID}return(0,b.OK)(e.data)}};g.ZodNull=Pr;Pr.create=t=>new Pr({typeName:q.ZodNull,...V(t)});var rr=class extends F{constructor(){super(...arguments),this._any=!0}_parse(e){return(0,b.OK)(e.data)}};g.ZodAny=rr;rr.create=t=>new rr({typeName:q.ZodAny,...V(t)});var jt=class extends F{constructor(){super(...arguments),this._unknown=!0}_parse(e){return(0,b.OK)(e.data)}};g.ZodUnknown=jt;jt.create=t=>new jt({typeName:q.ZodUnknown,...V(t)});var ht=class extends F{_parse(e){let r=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.never,received:r.parsedType}),b.INVALID}};g.ZodNever=ht;ht.create=t=>new ht({typeName:q.ZodNever,...V(t)});var wn=class extends F{_parse(e){if(this._getType(e)!==I.ZodParsedType.undefined){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.void,received:n.parsedType}),b.INVALID}return(0,b.OK)(e.data)}};g.ZodVoid=wn;wn.create=t=>new wn({typeName:q.ZodVoid,...V(t)});var At=class t extends F{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==I.ZodParsedType.array)return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.array,received:r.parsedType}),b.INVALID;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(i||a)&&((0,b.addIssueToContext)(r,{code:i?z.ZodIssueCode.too_big:z.ZodIssueCode.too_small,minimum:a?o.exactLength.value:void 0,maximum:i?o.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:o.exactLength.message}),n.dirty())}if(o.minLength!==null&&r.data.length<o.minLength.value&&((0,b.addIssueToContext)(r,{code:z.ZodIssueCode.too_small,minimum:o.minLength.value,type:"array",inclusive:!0,exact:!1,message:o.minLength.message}),n.dirty()),o.maxLength!==null&&r.data.length>o.maxLength.value&&((0,b.addIssueToContext)(r,{code:z.ZodIssueCode.too_big,maximum:o.maxLength.value,type:"array",inclusive:!0,exact:!1,message:o.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((i,a)=>o.type._parseAsync(new st(r,i,r.path,a)))).then(i=>b.ParseStatus.mergeArray(n,i));let s=[...r.data].map((i,a)=>o.type._parseSync(new st(r,i,r.path,a)));return b.ParseStatus.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:j.errorUtil.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:j.errorUtil.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:j.errorUtil.toString(r)}})}nonempty(e){return this.min(1,e)}};g.ZodArray=At;At.create=(t,e)=>new At({type:t,minLength:null,maxLength:null,exactLength:null,typeName:q.ZodArray,...V(e)});function vn(t){if(t instanceof Fe){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=ot.create(vn(n))}return new Fe({...t._def,shape:()=>e})}else return t instanceof At?new At({...t._def,type:vn(t.element)}):t instanceof ot?ot.create(vn(t.unwrap())):t instanceof $t?$t.create(vn(t.unwrap())):t instanceof kt?kt.create(t.items.map(e=>vn(e))):t}var Fe=class t extends F{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),r=I.util.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==I.ZodParsedType.object){let u=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(u,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.object,received:u.parsedType}),b.INVALID}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ht&&this._def.unknownKeys==="strip"))for(let u in o.data)i.includes(u)||a.push(u);let c=[];for(let u of i){let l=s[u],p=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new st(o,p,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof ht){let u=this._def.unknownKeys;if(u==="passthrough")for(let l of a)c.push({key:{status:"valid",value:l},value:{status:"valid",value:o.data[l]}});else if(u==="strict")a.length>0&&((0,b.addIssueToContext)(o,{code:z.ZodIssueCode.unrecognized_keys,keys:a}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let u=this._def.catchall;for(let l of a){let p=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new st(o,p,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let p=await l.key,m=await l.value;u.push({key:p,value:m,alwaysSet:l.alwaysSet})}return u}).then(u=>b.ParseStatus.mergeObjectSync(n,u)):b.ParseStatus.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return j.errorUtil.errToObj,new t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{let o=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:j.errorUtil.errToObj(e).message??o}:{message:o}}}:{}})}strip(){return new t({...this._def,unknownKeys:"strip"})}passthrough(){return new t({...this._def,unknownKeys:"passthrough"})}extend(e){return new t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:q.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new t({...this._def,catchall:e})}pick(e){let r={};for(let n of I.util.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}omit(e){let r={};for(let n of I.util.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return vn(this)}partial(e){let r={};for(let n of I.util.objectKeys(this.shape)){let o=this.shape[n];e&&!e[n]?r[n]=o:r[n]=o.optional()}return new t({...this._def,shape:()=>r})}required(e){let r={};for(let n of I.util.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof ot;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:()=>r})}keyof(){return py(I.util.objectKeys(this.shape))}};g.ZodObject=Fe;Fe.create=(t,e)=>new Fe({shape:()=>t,unknownKeys:"strip",catchall:ht.create(),typeName:q.ZodObject,...V(e)});Fe.strictCreate=(t,e)=>new Fe({shape:()=>t,unknownKeys:"strict",catchall:ht.create(),typeName:q.ZodObject,...V(e)});Fe.lazycreate=(t,e)=>new Fe({shape:t,unknownKeys:"strip",catchall:ht.create(),typeName:q.ZodObject,...V(e)});var Ir=class extends F{_parse(e){let{ctx:r}=this._processInputParams(e),n=this._def.options;function o(s){for(let a of s)if(a.result.status==="valid")return a.result;for(let a of s)if(a.result.status==="dirty")return r.common.issues.push(...a.ctx.common.issues),a.result;let i=s.map(a=>new z.ZodError(a.ctx.common.issues));return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_union,unionErrors:i}),b.INVALID}if(r.common.async)return Promise.all(n.map(async s=>{let i={...r,common:{...r.common,issues:[]},parent:null};return{result:await s._parseAsync({data:r.data,path:r.path,parent:i}),ctx:i}})).then(o);{let s,i=[];for(let c of n){let 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"&&!s&&(s={result:l,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(s)return r.common.issues.push(...s.ctx.common.issues),s.result;let a=i.map(c=>new z.ZodError(c));return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_union,unionErrors:a}),b.INVALID}}get options(){return this._def.options}};g.ZodUnion=Ir;Ir.create=(t,e)=>new Ir({options:t,typeName:q.ZodUnion,...V(e)});var Ot=t=>t instanceof Rr?Ot(t.schema):t instanceof Ge?Ot(t.innerType()):t instanceof Cr?[t.value]:t instanceof Zr?t.options:t instanceof Or?I.util.objectValues(t.enum):t instanceof jr?Ot(t._def.innerType):t instanceof zr?[void 0]:t instanceof Pr?[null]:t instanceof ot?[void 0,...Ot(t.unwrap())]:t instanceof $t?[null,...Ot(t.unwrap())]:t instanceof No||t instanceof Nr?Ot(t.unwrap()):t instanceof Ar?Ot(t._def.innerType):[],Ii=class t extends F{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==I.ZodParsedType.object)return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.object,received:r.parsedType}),b.INVALID;let n=this.discriminator,o=r.data[n],s=this.optionsMap.get(o);return s?r.common.async?s._parseAsync({data:r.data,path:r.path,parent:r}):s._parseSync({data:r.data,path:r.path,parent:r}):((0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),b.INVALID)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){let o=new Map;for(let s of r){let i=Ot(s.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of i){if(o.has(a))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);o.set(a,s)}}return new t({typeName:q.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...V(n)})}};g.ZodDiscriminatedUnion=Ii;function bd(t,e){let r=(0,I.getParsedType)(t),n=(0,I.getParsedType)(e);if(t===e)return{valid:!0,data:t};if(r===I.ZodParsedType.object&&n===I.ZodParsedType.object){let o=I.util.objectKeys(e),s=I.util.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=bd(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===I.ZodParsedType.array&&n===I.ZodParsedType.array){if(t.length!==e.length)return{valid:!1};let o=[];for(let s=0;s<t.length;s++){let i=t[s],a=e[s],c=bd(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===I.ZodParsedType.date&&n===I.ZodParsedType.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var Er=class extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if((0,b.isAborted)(s)||(0,b.isAborted)(i))return b.INVALID;let a=bd(s.value,i.value);return a.valid?(((0,b.isDirty)(s)||(0,b.isDirty)(i))&&r.dirty(),{status:r.value,value:a.data}):((0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_intersection_types}),b.INVALID)};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(([s,i])=>o(s,i)):o(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};g.ZodIntersection=Er;Er.create=(t,e,r)=>new Er({left:t,right:e,typeName:q.ZodIntersection,...V(r)});var kt=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==I.ZodParsedType.array)return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.array,received:n.parsedType}),b.INVALID;if(n.data.length<this._def.items.length)return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b.INVALID;!this._def.rest&&n.data.length>this._def.items.length&&((0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());let s=[...n.data].map((i,a)=>{let c=this._def.items[a]||this._def.rest;return c?c._parse(new st(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>b.ParseStatus.mergeArray(r,i)):b.ParseStatus.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};g.ZodTuple=kt;kt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new kt({items:t,typeName:q.ZodTuple,rest:null,...V(e)})};var Ei=class t extends F{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==I.ZodParsedType.object)return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.object,received:n.parsedType}),b.INVALID;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in n.data)o.push({key:s._parse(new st(n,a,n.path,a)),value:i._parse(new st(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?b.ParseStatus.mergeObjectAsync(r,o):b.ParseStatus.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof F?new t({keyType:e,valueType:r,typeName:q.ZodRecord,...V(n)}):new t({keyType:tr.create(),valueType:e,typeName:q.ZodRecord,...V(r)})}};g.ZodRecord=Ei;var xn=class extends F{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==I.ZodParsedType.map)return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.map,received:n.parsedType}),b.INVALID;let o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new st(n,a,n.path,[u,"key"])),value:s._parse(new st(n,c,n.path,[u,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let c of i){let u=await c.key,l=await c.value;if(u.status==="aborted"||l.status==="aborted")return b.INVALID;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}})}else{let a=new Map;for(let c of i){let u=c.key,l=c.value;if(u.status==="aborted"||l.status==="aborted")return b.INVALID;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};g.ZodMap=xn;xn.create=(t,e,r)=>new xn({valueType:e,keyType:t,typeName:q.ZodMap,...V(r)});var kn=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==I.ZodParsedType.set)return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.set,received:n.parsedType}),b.INVALID;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&((0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_small,minimum:o.minSize.value,type:"set",inclusive:!0,exact:!1,message:o.minSize.message}),r.dirty()),o.maxSize!==null&&n.data.size>o.maxSize.value&&((0,b.addIssueToContext)(n,{code:z.ZodIssueCode.too_big,maximum:o.maxSize.value,type:"set",inclusive:!0,exact:!1,message:o.maxSize.message}),r.dirty());let s=this._def.valueType;function i(c){let u=new Set;for(let l of c){if(l.status==="aborted")return b.INVALID;l.status==="dirty"&&r.dirty(),u.add(l.value)}return{status:r.value,value:u}}let a=[...n.data.values()].map((c,u)=>s._parse(new st(n,c,n.path,u)));return n.common.async?Promise.all(a).then(c=>i(c)):i(a)}min(e,r){return new t({...this._def,minSize:{value:e,message:j.errorUtil.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:j.errorUtil.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};g.ZodSet=kn;kn.create=(t,e)=>new kn({valueType:t,minSize:null,maxSize:null,typeName:q.ZodSet,...V(e)});var Ri=class t extends F{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==I.ZodParsedType.function)return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.function,received:r.parsedType}),b.INVALID;function n(a,c){return(0,b.makeIssue)({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,(0,Pi.getErrorMap)(),Pi.defaultErrorMap].filter(u=>!!u),issueData:{code:z.ZodIssueCode.invalid_arguments,argumentsError:c}})}function o(a,c){return(0,b.makeIssue)({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,(0,Pi.getErrorMap)(),Pi.defaultErrorMap].filter(u=>!!u),issueData:{code:z.ZodIssueCode.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof nr){let a=this;return(0,b.OK)(async function(...c){let u=new z.ZodError([]),l=await a._def.args.parseAsync(c,s).catch(h=>{throw u.addIssue(n(c,h)),u}),p=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(p,s).catch(h=>{throw u.addIssue(o(p,h)),u})})}else{let a=this;return(0,b.OK)(function(...c){let u=a._def.args.safeParse(c,s);if(!u.success)throw new z.ZodError([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),p=a._def.returns.safeParse(l,s);if(!p.success)throw new z.ZodError([o(l,p.error)]);return p.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:kt.create(e).rest(jt.create())})}returns(e){return new t({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new t({args:e||kt.create([]).rest(jt.create()),returns:r||jt.create(),typeName:q.ZodFunction,...V(n)})}};g.ZodFunction=Ri;var Rr=class extends F{get schema(){return this._def.getter()}_parse(e){let{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};g.ZodLazy=Rr;Rr.create=(t,e)=>new Rr({getter:t,typeName:q.ZodLazy,...V(e)});var Cr=class extends F{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(r,{received:r.data,code:z.ZodIssueCode.invalid_literal,expected:this._def.value}),b.INVALID}return{status:"valid",value:e.data}}get value(){return this._def.value}};g.ZodLiteral=Cr;Cr.create=(t,e)=>new Cr({value:t,typeName:q.ZodLiteral,...V(e)});function py(t,e){return new Zr({values:t,typeName:q.ZodEnum,...V(e)})}var Zr=class t extends F{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return(0,b.addIssueToContext)(r,{expected:I.util.joinValues(n),received:r.parsedType,code:z.ZodIssueCode.invalid_type}),b.INVALID}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let r=this._getOrReturnCtx(e),n=this._def.values;return(0,b.addIssueToContext)(r,{received:r.data,code:z.ZodIssueCode.invalid_enum_value,options:n}),b.INVALID}return(0,b.OK)(e.data)}get options(){return this._def.values}get enum(){let e={};for(let r of this._def.values)e[r]=r;return e}get Values(){let e={};for(let r of this._def.values)e[r]=r;return e}get Enum(){let e={};for(let r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return t.create(e,{...this._def,...r})}exclude(e,r=this._def){return t.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}};g.ZodEnum=Zr;Zr.create=py;var Or=class extends F{_parse(e){let r=I.util.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==I.ZodParsedType.string&&n.parsedType!==I.ZodParsedType.number){let o=I.util.objectValues(r);return(0,b.addIssueToContext)(n,{expected:I.util.joinValues(o),received:n.parsedType,code:z.ZodIssueCode.invalid_type}),b.INVALID}if(this._cache||(this._cache=new Set(I.util.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=I.util.objectValues(r);return(0,b.addIssueToContext)(n,{received:n.data,code:z.ZodIssueCode.invalid_enum_value,options:o}),b.INVALID}return(0,b.OK)(e.data)}get enum(){return this._def.values}};g.ZodNativeEnum=Or;Or.create=(t,e)=>new Or({values:t,typeName:q.ZodNativeEnum,...V(e)});var nr=class extends F{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==I.ZodParsedType.promise&&r.common.async===!1)return(0,b.addIssueToContext)(r,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.promise,received:r.parsedType}),b.INVALID;let n=r.parsedType===I.ZodParsedType.promise?r.data:Promise.resolve(r.data);return(0,b.OK)(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};g.ZodPromise=nr;nr.create=(t,e)=>new nr({type:t,typeName:q.ZodPromise,...V(e)});var Ge=class extends F{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=this._def.effect||null,s={addIssue:i=>{(0,b.addIssueToContext)(n,i),i.fatal?r.abort():r.dirty()},get path(){return n.path}};if(s.addIssue=s.addIssue.bind(s),o.type==="preprocess"){let i=o.transform(n.data,s);if(n.common.async)return Promise.resolve(i).then(async a=>{if(r.value==="aborted")return b.INVALID;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?b.INVALID:c.status==="dirty"||r.value==="dirty"?(0,b.DIRTY)(c.value):c});{if(r.value==="aborted")return b.INVALID;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?b.INVALID:a.status==="dirty"||r.value==="dirty"?(0,b.DIRTY)(a.value):a}}if(o.type==="refinement"){let i=a=>{let c=o.refinement(a,s);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?b.INVALID:(a.status==="dirty"&&r.dirty(),i(a.value),{status:r.value,value:a.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(a=>a.status==="aborted"?b.INVALID:(a.status==="dirty"&&r.dirty(),i(a.value).then(()=>({status:r.value,value:a.value}))))}if(o.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!(0,b.isValid)(i))return b.INVALID;let a=o.transform(i.value,s);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>(0,b.isValid)(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:r.value,value:a})):b.INVALID);I.util.assertNever(o)}};g.ZodEffects=Ge;g.ZodTransformer=Ge;Ge.create=(t,e,r)=>new Ge({schema:t,typeName:q.ZodEffects,effect:e,...V(r)});Ge.createWithPreprocess=(t,e,r)=>new Ge({schema:e,effect:{type:"preprocess",transform:t},typeName:q.ZodEffects,...V(r)});var ot=class extends F{_parse(e){return this._getType(e)===I.ZodParsedType.undefined?(0,b.OK)(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};g.ZodOptional=ot;ot.create=(t,e)=>new ot({innerType:t,typeName:q.ZodOptional,...V(e)});var $t=class extends F{_parse(e){return this._getType(e)===I.ZodParsedType.null?(0,b.OK)(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};g.ZodNullable=$t;$t.create=(t,e)=>new $t({innerType:t,typeName:q.ZodNullable,...V(e)});var jr=class extends F{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===I.ZodParsedType.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};g.ZodDefault=jr;jr.create=(t,e)=>new jr({innerType:t,typeName:q.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...V(e)});var Ar=class extends F{_parse(e){let{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},o=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return(0,b.isAsync)(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new z.ZodError(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new z.ZodError(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};g.ZodCatch=Ar;Ar.create=(t,e)=>new Ar({innerType:t,typeName:q.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...V(e)});var $n=class extends F{_parse(e){if(this._getType(e)!==I.ZodParsedType.nan){let n=this._getOrReturnCtx(e);return(0,b.addIssueToContext)(n,{code:z.ZodIssueCode.invalid_type,expected:I.ZodParsedType.nan,received:n.parsedType}),b.INVALID}return{status:"valid",value:e.data}}};g.ZodNaN=$n;$n.create=t=>new $n({typeName:q.ZodNaN,...V(t)});g.BRAND=Symbol("zod_brand");var No=class extends F{_parse(e){let{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}};g.ZodBranded=No;var Mo=class t extends F{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?b.INVALID:s.status==="dirty"?(r.dirty(),(0,b.DIRTY)(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{let o=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?b.INVALID:o.status==="dirty"?(r.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:n.path,parent:n})}}static create(e,r){return new t({in:e,out:r,typeName:q.ZodPipeline})}};g.ZodPipeline=Mo;var Nr=class extends F{_parse(e){let r=this._def.innerType._parse(e),n=o=>((0,b.isValid)(o)&&(o.value=Object.freeze(o.value)),o);return(0,b.isAsync)(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};g.ZodReadonly=Nr;Nr.create=(t,e)=>new Nr({innerType:t,typeName:q.ZodReadonly,...V(e)});function cy(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function fy(t,e={},r){return t?rr.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(i=>{if(!i){let a=cy(e,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=cy(e,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}}):rr.create()}g.late={object:Fe.lazycreate};var q;(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"})(q||(g.ZodFirstPartyTypeKind=q={}));var yP=(t,e={message:`Input not instance of ${t.name}`})=>fy(r=>r instanceof t,e);g.instanceof=yP;var my=tr.create;g.string=my;var hy=kr.create;g.number=hy;var vP=$n.create;g.nan=vP;var bP=$r.create;g.bigint=bP;var gy=Sr.create;g.boolean=gy;var wP=Tr.create;g.date=wP;var xP=bn.create;g.symbol=xP;var kP=zr.create;g.undefined=kP;var $P=Pr.create;g.null=$P;var SP=rr.create;g.any=SP;var TP=jt.create;g.unknown=TP;var zP=ht.create;g.never=zP;var PP=wn.create;g.void=PP;var IP=At.create;g.array=IP;var EP=Fe.create;g.object=EP;var RP=Fe.strictCreate;g.strictObject=RP;var CP=Ir.create;g.union=CP;var ZP=Ii.create;g.discriminatedUnion=ZP;var OP=Er.create;g.intersection=OP;var jP=kt.create;g.tuple=jP;var AP=Ei.create;g.record=AP;var NP=xn.create;g.map=NP;var MP=kn.create;g.set=MP;var DP=Ri.create;g.function=DP;var qP=Rr.create;g.lazy=qP;var LP=Cr.create;g.literal=LP;var UP=Zr.create;g.enum=UP;var VP=Or.create;g.nativeEnum=VP;var FP=nr.create;g.promise=FP;var _y=Ge.create;g.effect=_y;g.transformer=_y;var HP=ot.create;g.optional=HP;var BP=$t.create;g.nullable=BP;var JP=Ge.createWithPreprocess;g.preprocess=JP;var KP=Mo.create;g.pipeline=KP;var GP=()=>my().optional();g.ostring=GP;var WP=()=>hy().optional();g.onumber=WP;var YP=()=>gy().optional();g.oboolean=YP;g.coerce={string:(t=>tr.create({...t,coerce:!0})),number:(t=>kr.create({...t,coerce:!0})),boolean:(t=>Sr.create({...t,coerce:!0})),bigint:(t=>$r.create({...t,coerce:!0})),date:(t=>Tr.create({...t,coerce:!0}))};g.NEVER=b.INVALID});var wd=P(it=>{"use strict";d();var XP=it&&it.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),Sn=it&&it.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&XP(e,t,r)};Object.defineProperty(it,"__esModule",{value:!0});Sn(Ti(),it);Sn(yd(),it);Sn(oy(),it);Sn(jo(),it);Sn(yy(),it);Sn(Si(),it)});var wy=P(He=>{"use strict";d();var vy=He&&He.__createBinding||(Object.create?(function(t,e,r,n){n===void 0&&(n=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,o)}):(function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]})),QP=He&&He.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),eI=He&&He.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&vy(e,t,r);return QP(e,t),e},tI=He&&He.__exportStar||function(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&vy(e,t,r)};Object.defineProperty(He,"__esModule",{value:!0});He.z=void 0;var by=eI(wd());He.z=by;tI(wd(),He);He.default=by});var Tn=P(Ci=>{"use strict";d();Object.defineProperty(Ci,"__esModule",{value:!0});Ci.config=void 0;var Mr=wy(),rI=Mr.z.object({MCP_SERVER_PORT:Mr.z.coerce.number().int().positive().default(3001),MCP_SERVER_HOST:Mr.z.string().default("0.0.0.0"),TOOLPILOT_MODE:Mr.z.enum(["dev","staging","production"]).default("dev"),TOOLPILOT_API_URL:Mr.z.string().default("https://api.neurynae.com"),NODE_ENV:Mr.z.enum(["development","test","production"]).default("development"),LOG_LEVEL:Mr.z.enum(["fatal","error","warn","info","debug","trace"]).default("info")});function nI(){let t=rI.safeParse(process.env);return t.success||(console.error("\u274C Invalid environment configuration:"),console.error(t.error.format()),process.exit(1)),t.data}Ci.config=nI()});d();d();d();d();d();d();d();d();var Xy=Object.freeze({status:"aborted"});function k(t,e,r){function n(a,c){var u;Object.defineProperty(a,"_zod",{value:a._zod??{},enumerable:!1}),(u=a._zod).traits??(u.traits=new Set),a._zod.traits.add(t),e(a,c);for(let l in i.prototype)l in a||Object.defineProperty(a,l,{value:i.prototype[l].bind(a)});a._zod.constr=i,a._zod.def=c}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var zt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Fo={};function Be(t){return t&&Object.assign(Fo,t),Fo}d();d();var G={};Ld(G,{BIGINT_FORMAT_RANGES:()=>bp,Class:()=>Hi,NUMBER_FORMAT_RANGES:()=>Xi,aborted:()=>ir,allowsEval:()=>Gi,assert:()=>nv,assertEqual:()=>Qy,assertIs:()=>tv,assertNever:()=>rv,assertNotEqual:()=>ev,assignProp:()=>Ki,cached:()=>jn,captureStackTrace:()=>Bo,cleanEnum:()=>gv,cleanRegex:()=>Nn,clone:()=>Je,createTransparentProxy:()=>uv,defineLazy:()=>ae,esc:()=>sr,escapeRegex:()=>Nt,extend:()=>pv,finalizeIssue:()=>at,floatSafeRemainder:()=>Ji,getElementAtPath:()=>ov,getEnumValues:()=>On,getLengthableOrigin:()=>Mn,getParsedType:()=>cv,getSizableOrigin:()=>wp,isObject:()=>Vr,isPlainObject:()=>Fr,issue:()=>Qi,joinValues:()=>Ho,jsonStringifyReplacer:()=>Bi,merge:()=>fv,normalizeParams:()=>M,nullish:()=>An,numKeys:()=>av,omit:()=>dv,optionalKeys:()=>Yi,partial:()=>mv,pick:()=>lv,prefixIssues:()=>gt,primitiveTypes:()=>vp,promiseAllObject:()=>sv,propertyKeyTypes:()=>Wi,randomString:()=>iv,required:()=>hv,stringifyPrimitive:()=>Jo,unwrapMessage:()=>Zn});d();function Qy(t){return t}function ev(t){return t}function tv(t){}function rv(t){throw new Error}function nv(t){}function On(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function Ho(t,e="|"){return t.map(r=>Jo(r)).join(e)}function Bi(t,e){return typeof e=="bigint"?e.toString():e}function jn(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function An(t){return t==null}function Nn(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Ji(t,e){let r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,o=r>n?r:n,s=Number.parseInt(t.toFixed(o).replace(".","")),i=Number.parseInt(e.toFixed(o).replace(".",""));return s%i/10**o}function ae(t,e,r){Object.defineProperty(t,e,{get(){{let o=r();return t[e]=o,o}throw new Error("cached value already set")},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function Ki(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ov(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function sv(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function iv(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function sr(t){return JSON.stringify(t)}var Bo=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function Vr(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Gi=jn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Fr(t){if(Vr(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(Vr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function av(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var cv=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Wi=new Set(["string","number","symbol"]),vp=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Nt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Je(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function M(t){let 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 uv(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function Jo(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function Yi(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var Xi={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]},bp={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function lv(t,e){let r={},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&(r[o]=n.shape[o])}return Je(t,{...t._zod.def,shape:r,checks:[]})}function dv(t,e){let r={...t._zod.def.shape},n=t._zod.def;for(let o in e){if(!(o in n.shape))throw new Error(`Unrecognized key: "${o}"`);e[o]&&delete r[o]}return Je(t,{...t._zod.def,shape:r,checks:[]})}function pv(t,e){if(!Fr(e))throw new Error("Invalid input to extend: expected a plain object");let r={...t._zod.def,get shape(){let n={...t._zod.def.shape,...e};return Ki(this,"shape",n),n},checks:[]};return Je(t,r)}function fv(t,e){return Je(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return Ki(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function mv(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in n))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=t?new t({type:"optional",innerType:n[s]}):n[s])}else for(let s in n)o[s]=t?new t({type:"optional",innerType:n[s]}):n[s];return Je(e,{...e._zod.def,shape:o,checks:[]})}function hv(t,e,r){let n=e._zod.def.shape,o={...n};if(r)for(let s in r){if(!(s in o))throw new Error(`Unrecognized key: "${s}"`);r[s]&&(o[s]=new t({type:"nonoptional",innerType:n[s]}))}else for(let s in n)o[s]=new t({type:"nonoptional",innerType:n[s]});return Je(e,{...e._zod.def,shape:o,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 gt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Zn(t){return typeof t=="string"?t:t?.message}function at(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let o=Zn(t.inst?._zod.def?.error?.(t))??Zn(e?.error?.(t))??Zn(r.customError?.(t))??Zn(r.localeError?.(t))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function wp(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Mn(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Qi(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function gv(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var Hi=class{constructor(...e){}};var xp=(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,Bi,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},Ko=k("$ZodError",xp),Dn=k("$ZodError",xp,{Parent:Error});function ea(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function ta(t,e){let r=e||function(s){return s.message},n={_errors:[]},o=s=>{for(let i of s.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(r(i));else{let a=n,c=0;for(;c<i.path.length;){let u=i.path[c];c===i.path.length-1?(a[u]=a[u]||{_errors:[]},a[u]._errors.push(r(i))):a[u]=a[u]||{_errors:[]},a=a[u],c++}}};return o(t),n}var ra=t=>(e,r,n,o)=>{let s=n?Object.assign(n,{async:!1}):{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new zt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>at(c,s,Be())));throw Bo(a,o?.callee),a}return i.value},na=ra(Dn),oa=t=>async(e,r,n,o)=>{let s=n?Object.assign(n,{async:!0}):{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>at(c,s,Be())));throw Bo(a,o?.callee),a}return i.value},sa=oa(Dn),ia=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new zt;return s.issues.length?{success:!1,error:new(t??Ko)(s.issues.map(i=>at(i,o,Be())))}:{success:!0,data:s.value}},ar=ia(Dn),aa=t=>async(e,r,n)=>{let o=n?Object.assign(n,{async:!0}):{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>at(i,o,Be())))}:{success:!0,data:s.value}},cr=aa(Dn);d();d();d();var kp=/^[cC][^\s-]{8,}$/,$p=/^[0-9a-z]+$/,Sp=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Tp=/^[0-9a-vA-V]{20}$/,zp=/^[A-Za-z0-9]{27}$/,Pp=/^[a-zA-Z0-9_-]{21}$/,Ip=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Ep=/^([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})$/,ca=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)$/;var Rp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var yv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Cp(){return new RegExp(yv,"u")}var Zp=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Op=/^(([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})$/,jp=/^((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])$/,Ap=/^(([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])$/,Np=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ua=/^[A-Za-z0-9_-]*$/,Mp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var Dp=/^\+(?:[0-9]){6,14}[0-9]$/,qp="(?:(?:\\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])))",Lp=new RegExp(`^${qp}$`);function Up(t){let 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 Vp(t){return new RegExp(`^${Up(t)}$`)}function Fp(t){let e=Up({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-]\\d{2}:\\d{2})");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${qp}T(?:${n})$`)}var Hp=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var Bp=/^\d+$/,Jp=/^-?\d+(?:\.\d+)?/i,Kp=/true|false/i,Gp=/null/i;var Wp=/^[^A-Z]*$/,Yp=/^[^a-z]*$/;var ke=k("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Xp={number:"number",bigint:"bigint",object:"date"},la=k("$ZodCheckLessThan",(t,e)=>{ke.init(t,e);let r=Xp[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.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})}}),da=k("$ZodCheckGreaterThan",(t,e)=>{ke.init(t,e);let r=Xp[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.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})}}),Qp=k("$ZodCheckMultipleOf",(t,e)=>{ke.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):Ji(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})}}),ef=k("$ZodCheckNumberFormat",(t,e)=>{ke.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=Xi[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=Bp)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inst:t})}});var tf=k("$ZodCheckMaxLength",(t,e)=>{var r;ke.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!An(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=Mn(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),rf=k("$ZodCheckMinLength",(t,e)=>{var r;ke.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!An(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=Mn(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),nf=k("$ZodCheckLengthEquals",(t,e)=>{var r;ke.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!An(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=Mn(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),qn=k("$ZodCheckStringFormat",(t,e)=>{var r,n;ke.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),of=k("$ZodCheckRegex",(t,e)=>{qn.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})}}),sf=k("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Wp),qn.init(t,e)}),af=k("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Yp),qn.init(t,e)}),cf=k("$ZodCheckIncludes",(t,e)=>{ke.init(t,e);let r=Nt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),uf=k("$ZodCheckStartsWith",(t,e)=>{ke.init(t,e);let r=new RegExp(`^${Nt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.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})}}),lf=k("$ZodCheckEndsWith",(t,e)=>{ke.init(t,e);let r=new RegExp(`.*${Nt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.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})}});var df=k("$ZodCheckOverwrite",(t,e)=>{ke.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});d();var Wo=class{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}let n=e.split(`
|
|
10
10
|
`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let e=Function,r=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...r,o.join(`
|
|
11
|
-
`))}};d();var
|
|
11
|
+
`))}};d();var ff={major:4,minor:0,patch:0};var oe=k("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=ff;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let o of n)for(let s of o._zod.onattach)s(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(s,i,a)=>{let c=ir(s),u;for(let l of i){if(l._zod.def.when){if(!l._zod.def.when(s))continue}else if(c)continue;let p=s.issues.length,m=l._zod.check(s);if(m instanceof Promise&&a?.async===!1)throw new zt;if(u||m instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await m,s.issues.length!==p&&(c||(c=ir(s,p)))});else{if(s.issues.length===p)continue;c||(c=ir(s,p))}}return u?u.then(()=>s):s};t._zod.run=(s,i)=>{let a=t._zod.parse(s,i);if(a instanceof Promise){if(i.async===!1)throw new zt;return a.then(c=>o(c,n,i))}return o(a,n,i)}}t["~standard"]={validate:o=>{try{let s=ar(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return cr(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),Ln=k("$ZodString",(t,e)=>{oe.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Hp(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}}),ce=k("$ZodStringFormat",(t,e)=>{qn.init(t,e),Ln.init(t,e)}),fa=k("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Ep),ce.init(t,e)}),ma=k("$ZodUUID",(t,e)=>{if(e.version){let 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=ca(n))}else e.pattern??(e.pattern=ca());ce.init(t,e)}),ha=k("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Rp),ce.init(t,e)}),ga=k("$ZodURL",(t,e)=>{ce.init(t,e),t._zod.check=r=>{try{let n=r.value,o=new URL(n),s=o.href;e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:Mp.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.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("/")&&s.endsWith("/")?r.value=s.slice(0,-1):r.value=s;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),_a=k("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Cp()),ce.init(t,e)}),ya=k("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Pp),ce.init(t,e)}),va=k("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=kp),ce.init(t,e)}),ba=k("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=$p),ce.init(t,e)}),wa=k("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Sp),ce.init(t,e)}),xa=k("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Tp),ce.init(t,e)}),ka=k("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=zp),ce.init(t,e)}),kf=k("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Fp(e)),ce.init(t,e)}),$f=k("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Lp),ce.init(t,e)}),Sf=k("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Vp(e)),ce.init(t,e)}),Tf=k("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Ip),ce.init(t,e)}),$a=k("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Zp),ce.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Sa=k("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Op),ce.init(t,e),t._zod.onattach.push(r=>{let 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})}}}),Ta=k("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=jp),ce.init(t,e)}),za=k("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Ap),ce.init(t,e),t._zod.check=r=>{let[n,o]=r.value.split("/");try{if(!o)throw new Error;let s=Number(o);if(`${s}`!==o)throw new Error;if(s<0||s>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 zf(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var Pa=k("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Np),ce.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{zf(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function vv(t){if(!ua.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return zf(r)}var Ia=k("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=ua),ce.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{vv(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Ea=k("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Dp),ce.init(t,e)});function bv(t,e=null){try{let r=t.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||e&&(!("alg"in o)||o.alg!==e))}catch{return!1}}var Ra=k("$ZodJWT",(t,e)=>{ce.init(t,e),t._zod.check=r=>{bv(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var Xo=k("$ZodNumber",(t,e)=>{oe.init(t,e),t._zod.pattern=t._zod.bag.pattern??Jp,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:t,...s?{received:s}:{}}),r}}),Ca=k("$ZodNumber",(t,e)=>{ef.init(t,e),Xo.init(t,e)}),Za=k("$ZodBoolean",(t,e)=>{oe.init(t,e),t._zod.pattern=Kp,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:t}),r}});var Oa=k("$ZodNull",(t,e)=>{oe.init(t,e),t._zod.pattern=Gp,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:t}),r}});var ja=k("$ZodUnknown",(t,e)=>{oe.init(t,e),t._zod.parse=r=>r}),Aa=k("$ZodNever",(t,e)=>{oe.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function mf(t,e,r){t.issues.length&&e.issues.push(...gt(r,t.issues)),e.value[r]=t.value}var Na=k("$ZodArray",(t,e)=>{oe.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:t}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(u=>mf(u,r,i))):mf(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function Yo(t,e,r){t.issues.length&&e.issues.push(...gt(r,t.issues)),e.value[r]=t.value}function hf(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(...gt(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}var Qo=k("$ZodObject",(t,e)=>{oe.init(t,e);let r=jn(()=>{let p=Object.keys(e.shape);for(let h of p)if(!(e.shape[h]instanceof oe))throw new Error(`Invalid element at key "${h}": expected a Zod schema`);let m=Yi(e.shape);return{shape:e.shape,keys:p,keySet:new Set(p),numKeys:p.length,optionalKeys:new Set(m)}});ae(t._zod,"propValues",()=>{let p=e.shape,m={};for(let h in p){let f=p[h]._zod;if(f.values){m[h]??(m[h]=new Set);for(let _ of f.values)m[h].add(_)}}return m});let n=p=>{let m=new Wo(["shape","payload","ctx"]),h=r.value,f=S=>{let T=sr(S);return`shape[${T}]._zod.run({ value: input[${T}], issues: [] }, ctx)`};m.write("const input = payload.value;");let _=Object.create(null),w=0;for(let S of h.keys)_[S]=`key_${w++}`;m.write("const newResult = {}");for(let S of h.keys)if(h.optionalKeys.has(S)){let T=_[S];m.write(`const ${T} = ${f(S)};`);let R=sr(S);m.write(`
|
|
12
12
|
if (${T}.issues.length) {
|
|
13
13
|
if (input[${R}] === undefined) {
|
|
14
14
|
if (${R} in input) {
|
|
@@ -31,13 +31,13 @@ import{A as np,B as op,C as sp,D as ip,E as ap,F as cp,G as up,H as lp,I as dp,K
|
|
|
31
31
|
if (${T}.issues.length) payload.issues = payload.issues.concat(${T}.issues.map(iss => ({
|
|
32
32
|
...iss,
|
|
33
33
|
path: iss.path ? [${sr(S)}, ...iss.path] : [${sr(S)}]
|
|
34
|
-
})));`),m.write(`newResult[${sr(S)}] = ${T}.value`)}m.write("payload.value = newResult;"),m.write("return payload;");let k=m.compile();return(S,T)=>k(p,S,T)},o,s=Vr,i=!Fo.jitless,c=i&&Gi.value,u=e.catchall,l;t._zod.parse=(p,m)=>{l??(l=r.value);let h=p.value;if(!s(h))return p.issues.push({expected:"object",code:"invalid_type",input:h,inst:t}),p;let f=[];if(i&&c&&m?.async===!1&&m.jitless!==!0)o||(o=n(e.shape)),p=o(p,m);else{p.value={};let T=l.shape;for(let R of l.keys){let N=T[R],Ce=N._zod.run({value:h[R],issues:[]},m),We=N._zod.optin==="optional"&&N._zod.optout==="optional";Ce instanceof Promise?f.push(Ce.then(Lr=>We?mf(Lr,p,R,h):Yo(Lr,p,R))):We?mf(Ce,p,R,h):Yo(Ce,p,R)}}if(!u)return f.length?Promise.all(f).then(()=>p):p;let _=[],w=l.keySet,k=u._zod,S=k.def.type;for(let T of Object.keys(h)){if(w.has(T))continue;if(S==="never"){_.push(T);continue}let R=k.run({value:h[T],issues:[]},m);R instanceof Promise?f.push(R.then(N=>Yo(N,p,T))):Yo(R,p,T)}return _.length&&p.issues.push({code:"unrecognized_keys",keys:_,input:h,inst:t}),f.length?Promise.all(f).then(()=>p):p}});function hf(t,e,r,n){for(let o of t)if(o.issues.length===0)return e.value=o.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(s=>at(s,n,Be())))}),e}var es=$("$ZodUnion",(t,e)=>{oe.init(t,e),ae(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ae(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ae(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),ae(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>Nn(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let o=!1,s=[];for(let i of e.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>hf(i,r,t,n)):hf(s,r,t,n)}}),Ma=$("$ZodDiscriminatedUnion",(t,e)=>{es.init(t,e);let r=t._zod.parse;ae(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=jn(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!Vr(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),o)}}),Da=$("$ZodIntersection",(t,e)=>{oe.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>gf(r,c,u)):gf(r,s,i)}});function pa(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(Fr(t)&&Fr(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=pa(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=pa(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function gf(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),ir(t))return t;let n=pa(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}var qa=$("$ZodRecord",(t,e)=>{oe.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Fr(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[];if(e.keyType._zod.values){let i=e.keyType._zod.values;r.value={};for(let c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let u=e.valueType._zod.run({value:o[c],issues:[]},n);u instanceof Promise?s.push(u.then(l=>{l.issues.length&&r.issues.push(...gt(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...gt(c,u.issues)),r.value[c]=u.value)}let a;for(let c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(o)){if(i==="__proto__")continue;let a=e.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>at(u,n,Be())),input:i,path:[i],inst:t}),r.value[a.value]=a.value;continue}let c=e.valueType._zod.run({value:o[i],issues:[]},n);c instanceof Promise?s.push(c.then(u=>{u.issues.length&&r.issues.push(...gt(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...gt(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var La=$("$ZodEnum",(t,e)=>{oe.init(t,e);let r=On(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>Wi.has(typeof n)).map(n=>typeof n=="string"?Nt(n):n.toString()).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return t._zod.values.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:t}),n}}),Ua=$("$ZodLiteral",(t,e)=>{oe.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Nt(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{let o=r.value;return t._zod.values.has(o)||r.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),r}});var Va=$("$ZodTransform",(t,e)=>{oe.init(t,e),t._zod.parse=(r,n)=>{let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new zt;return r.value=o,r}}),Fa=$("$ZodOptional",(t,e)=>{oe.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ae(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ae(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Nn(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)}),Ha=$("$ZodNullable",(t,e)=>{oe.init(t,e),ae(t._zod,"optin",()=>e.innerType._zod.optin),ae(t._zod,"optout",()=>e.innerType._zod.optout),ae(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Nn(r.source)}|null)$`):void 0}),ae(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)}),Ba=$("$ZodDefault",(t,e)=>{oe.init(t,e),t._zod.optin="optional",ae(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>_f(s,e)):_f(o,e)}});function _f(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var Ja=$("$ZodPrefault",(t,e)=>{oe.init(t,e),t._zod.optin="optional",ae(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))}),Ka=$("$ZodNonOptional",(t,e)=>{oe.init(t,e),ae(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>yf(s,t)):yf(o,t)}});function yf(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var Ga=$("$ZodCatch",(t,e)=>{oe.init(t,e),t._zod.optin="optional",ae(t._zod,"optout",()=>e.innerType._zod.optout),ae(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>at(i,n,Be()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>at(s,n,Be()))},input:r.value}),r.issues=[]),r)}});var Wa=$("$ZodPipe",(t,e)=>{oe.init(t,e),ae(t._zod,"values",()=>e.in._zod.values),ae(t._zod,"optin",()=>e.in._zod.optin),ae(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>vf(s,e,n)):vf(o,e,n)}});function vf(t,e,r){return ir(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var Ya=$("$ZodReadonly",(t,e)=>{oe.init(t,e),ae(t._zod,"propValues",()=>e.innerType._zod.propValues),ae(t._zod,"values",()=>e.innerType._zod.values),ae(t._zod,"optin",()=>e.innerType._zod.optin),ae(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(bf):bf(o)}});function bf(t){return t.value=Object.freeze(t.value),t}var Xa=$("$ZodCustom",(t,e)=>{$e.init(t,e),oe.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>wf(s,r,n,t));wf(o,r,n,t)}});function wf(t,e,r,n){if(!t){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),e.issues.push(Qi(o))}}d();var bv=t=>{let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"NaN":"number";case"object":{if(Array.isArray(t))return"array";if(t===null)return"null";if(Object.getPrototypeOf(t)!==Object.prototype&&t.constructor)return t.constructor.name}}return e},wv=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function e(n){return t[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${bv(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${Jo(n.values[0])}`:`Invalid option: expected one of ${Ho(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",s=e(n.origin);return s?`Too big: expected ${n.origin??"value"} to have ${o}${n.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",s=e(n.origin);return s?`Too small: expected ${n.origin} to have ${o}${n.minimum.toString()} ${s.unit}`:`Too small: expected ${n.origin} to be ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Ho(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function zf(){return{localeError:wv()}}d();var Un=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){let 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){let 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){let r=e._zod.parent;if(r){let 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 Pf(){return new Un}var Mt=Pf();d();function Qa(t,e){return new t({type:"string",...M(e)})}function ec(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...M(e)})}function ts(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...M(e)})}function tc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...M(e)})}function rc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...M(e)})}function nc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...M(e)})}function oc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...M(e)})}function sc(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...M(e)})}function ic(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...M(e)})}function ac(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...M(e)})}function cc(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...M(e)})}function uc(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...M(e)})}function lc(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...M(e)})}function dc(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...M(e)})}function pc(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...M(e)})}function fc(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...M(e)})}function mc(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...M(e)})}function hc(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...M(e)})}function gc(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...M(e)})}function _c(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...M(e)})}function yc(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...M(e)})}function vc(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...M(e)})}function bc(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...M(e)})}function If(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...M(e)})}function Ef(t,e){return new t({type:"string",format:"date",check:"string_format",...M(e)})}function Rf(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...M(e)})}function Cf(t,e){return new t({type:"string",format:"duration",check:"string_format",...M(e)})}function wc(t,e){return new t({type:"number",checks:[],...M(e)})}function xc(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...M(e)})}function $c(t,e){return new t({type:"boolean",...M(e)})}function kc(t,e){return new t({type:"null",...M(e)})}function Sc(t){return new t({type:"unknown"})}function Tc(t,e){return new t({type:"never",...M(e)})}function rs(t,e){return new la({check:"less_than",...M(e),value:t,inclusive:!1})}function Vn(t,e){return new la({check:"less_than",...M(e),value:t,inclusive:!0})}function ns(t,e){return new da({check:"greater_than",...M(e),value:t,inclusive:!1})}function Fn(t,e){return new da({check:"greater_than",...M(e),value:t,inclusive:!0})}function os(t,e){return new Xp({check:"multiple_of",...M(e),value:t})}function ss(t,e){return new ef({check:"max_length",...M(e),maximum:t})}function Hr(t,e){return new tf({check:"min_length",...M(e),minimum:t})}function is(t,e){return new rf({check:"length_equals",...M(e),length:t})}function zc(t,e){return new nf({check:"string_format",format:"regex",...M(e),pattern:t})}function Pc(t){return new of({check:"string_format",format:"lowercase",...M(t)})}function Ic(t){return new sf({check:"string_format",format:"uppercase",...M(t)})}function Ec(t,e){return new af({check:"string_format",format:"includes",...M(e),includes:t})}function Rc(t,e){return new cf({check:"string_format",format:"starts_with",...M(e),prefix:t})}function Cc(t,e){return new uf({check:"string_format",format:"ends_with",...M(e),suffix:t})}function ur(t){return new lf({check:"overwrite",tx:t})}function Zc(t){return ur(e=>e.normalize(t))}function Oc(){return ur(t=>t.trim())}function jc(){return ur(t=>t.toLowerCase())}function Ac(){return ur(t=>t.toUpperCase())}function Zf(t,e,r){return new t({type:"array",element:e,...M(r)})}function Nc(t,e,r){let n=M(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Mc(t,e,r){return new t({type:"custom",check:"custom",fn:e,...M(r)})}d();var as=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Mt,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;let o=e._zod.def,s={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;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path},m=e._zod.parent;if(m)a.ref=m,this.process(m,p),this.seen.get(m).isParent=!0;else{let h=a.schema;switch(o.type){case"string":{let f=h;f.type="string";let{minimum:_,maximum:w,format:k,patterns:S,contentEncoding:T}=e._zod.bag;if(typeof _=="number"&&(f.minLength=_),typeof w=="number"&&(f.maxLength=w),k&&(f.format=s[k]??k,f.format===""&&delete f.format),T&&(f.contentEncoding=T),S&&S.size>0){let R=[...S];R.length===1?f.pattern=R[0].source:R.length>1&&(a.schema.allOf=[...R.map(N=>({...this.target==="draft-7"?{type:"string"}:{},pattern:N.source}))])}break}case"number":{let f=h,{minimum:_,maximum:w,format:k,multipleOf:S,exclusiveMaximum:T,exclusiveMinimum:R}=e._zod.bag;typeof k=="string"&&k.includes("int")?f.type="integer":f.type="number",typeof R=="number"&&(f.exclusiveMinimum=R),typeof _=="number"&&(f.minimum=_,typeof R=="number"&&(R>=_?delete f.minimum:delete f.exclusiveMinimum)),typeof T=="number"&&(f.exclusiveMaximum=T),typeof w=="number"&&(f.maximum=w,typeof T=="number"&&(T<=w?delete f.maximum:delete f.exclusiveMaximum)),typeof S=="number"&&(f.multipleOf=S);break}case"boolean":{let f=h;f.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":{h.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":{h.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let f=h,{minimum:_,maximum:w}=e._zod.bag;typeof _=="number"&&(f.minItems=_),typeof w=="number"&&(f.maxItems=w),f.type="array",f.items=this.process(o.element,{...p,path:[...p.path,"items"]});break}case"object":{let f=h;f.type="object",f.properties={};let _=o.shape;for(let S in _)f.properties[S]=this.process(_[S],{...p,path:[...p.path,"properties",S]});let w=new Set(Object.keys(_)),k=new Set([...w].filter(S=>{let T=o.shape[S]._zod;return this.io==="input"?T.optin===void 0:T.optout===void 0}));k.size>0&&(f.required=Array.from(k)),o.catchall?._zod.def.type==="never"?f.additionalProperties=!1:o.catchall?o.catchall&&(f.additionalProperties=this.process(o.catchall,{...p,path:[...p.path,"additionalProperties"]})):this.io==="output"&&(f.additionalProperties=!1);break}case"union":{let f=h;f.anyOf=o.options.map((_,w)=>this.process(_,{...p,path:[...p.path,"anyOf",w]}));break}case"intersection":{let f=h,_=this.process(o.left,{...p,path:[...p.path,"allOf",0]}),w=this.process(o.right,{...p,path:[...p.path,"allOf",1]}),k=T=>"allOf"in T&&Object.keys(T).length===1,S=[...k(_)?_.allOf:[_],...k(w)?w.allOf:[w]];f.allOf=S;break}case"tuple":{let f=h;f.type="array";let _=o.items.map((S,T)=>this.process(S,{...p,path:[...p.path,"prefixItems",T]}));if(this.target==="draft-2020-12"?f.prefixItems=_:f.items=_,o.rest){let S=this.process(o.rest,{...p,path:[...p.path,"items"]});this.target==="draft-2020-12"?f.items=S:f.additionalItems=S}o.rest&&(f.items=this.process(o.rest,{...p,path:[...p.path,"items"]}));let{minimum:w,maximum:k}=e._zod.bag;typeof w=="number"&&(f.minItems=w),typeof k=="number"&&(f.maxItems=k);break}case"record":{let f=h;f.type="object",f.propertyNames=this.process(o.keyType,{...p,path:[...p.path,"propertyNames"]}),f.additionalProperties=this.process(o.valueType,{...p,path:[...p.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":{let f=h,_=On(o.entries);_.every(w=>typeof w=="number")&&(f.type="number"),_.every(w=>typeof w=="string")&&(f.type="string"),f.enum=_;break}case"literal":{let f=h,_=[];for(let w of o.values)if(w===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof w=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");_.push(Number(w))}else _.push(w);if(_.length!==0)if(_.length===1){let w=_[0];f.type=w===null?"null":typeof w,f.const=w}else _.every(w=>typeof w=="number")&&(f.type="number"),_.every(w=>typeof w=="string")&&(f.type="string"),_.every(w=>typeof w=="boolean")&&(f.type="string"),_.every(w=>w===null)&&(f.type="null"),f.enum=_;break}case"file":{let f=h,_={type:"string",format:"binary",contentEncoding:"binary"},{minimum:w,maximum:k,mime:S}=e._zod.bag;w!==void 0&&(_.minLength=w),k!==void 0&&(_.maxLength=k),S?S.length===1?(_.contentMediaType=S[0],Object.assign(f,_)):f.anyOf=S.map(T=>({..._,contentMediaType:T})):Object.assign(f,_);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let f=this.process(o.innerType,p);h.anyOf=[f,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,p),a.ref=o.innerType;break}case"success":{let f=h;f.type="boolean";break}case"default":{this.process(o.innerType,p),a.ref=o.innerType,h.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,p),a.ref=o.innerType,this.io==="input"&&(h._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,p),a.ref=o.innerType;let f;try{f=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}h.default=f;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let f=h,_=e._zod.pattern;if(!_)throw new Error("Pattern not found in template literal");f.type="string",f.pattern=_.source;break}case"pipe":{let f=this.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(f,p),a.ref=f;break}case"readonly":{this.process(o.innerType,p),a.ref=o.innerType,h.readOnly=!0;break}case"promise":{this.process(o.innerType,p),a.ref=o.innerType;break}case"optional":{this.process(o.innerType,p),a.ref=o.innerType;break}case"lazy":{let f=e._zod.innerType;this.process(f,p),a.ref=f;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let u=this.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),this.io==="input"&&be(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},o=this.seen.get(e);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let s=l=>{let p=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let _=n.external.registry.get(l[0])?.id,w=n.external.uri??(S=>S);if(_)return{ref:w(_)};let k=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=k,{defId:k,ref:`${w("__shared")}#/${p}/${k}`}}if(l[1]===o)return{ref:"#"};let h=`#/${p}/`,f=l[1].schema.id??`__schema${this.counter++}`;return{defId:f,ref:h+f}},i=l=>{if(l[1].schema.$ref)return;let p=l[1],{ref:m,defId:h}=s(l);p.def={...p.schema},h&&(p.defId=h);let f=p.schema;for(let _ in f)delete f[_];f.$ref=m};if(n.cycles==="throw")for(let l of this.seen.entries()){let p=l[1];if(p.cycle)throw new Error(`Cycle detected: #/${p.cycle?.join("/")}/<root>
|
|
34
|
+
})));`),m.write(`newResult[${sr(S)}] = ${T}.value`)}m.write("payload.value = newResult;"),m.write("return payload;");let $=m.compile();return(S,T)=>$(p,S,T)},o,s=Vr,i=!Fo.jitless,c=i&&Gi.value,u=e.catchall,l;t._zod.parse=(p,m)=>{l??(l=r.value);let h=p.value;if(!s(h))return p.issues.push({expected:"object",code:"invalid_type",input:h,inst:t}),p;let f=[];if(i&&c&&m?.async===!1&&m.jitless!==!0)o||(o=n(e.shape)),p=o(p,m);else{p.value={};let T=l.shape;for(let R of l.keys){let N=T[R],Ce=N._zod.run({value:h[R],issues:[]},m),We=N._zod.optin==="optional"&&N._zod.optout==="optional";Ce instanceof Promise?f.push(Ce.then(Lr=>We?hf(Lr,p,R,h):Yo(Lr,p,R))):We?hf(Ce,p,R,h):Yo(Ce,p,R)}}if(!u)return f.length?Promise.all(f).then(()=>p):p;let _=[],w=l.keySet,$=u._zod,S=$.def.type;for(let T of Object.keys(h)){if(w.has(T))continue;if(S==="never"){_.push(T);continue}let R=$.run({value:h[T],issues:[]},m);R instanceof Promise?f.push(R.then(N=>Yo(N,p,T))):Yo(R,p,T)}return _.length&&p.issues.push({code:"unrecognized_keys",keys:_,input:h,inst:t}),f.length?Promise.all(f).then(()=>p):p}});function gf(t,e,r,n){for(let o of t)if(o.issues.length===0)return e.value=o.value,e;return e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(o=>o.issues.map(s=>at(s,n,Be())))}),e}var es=k("$ZodUnion",(t,e)=>{oe.init(t,e),ae(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ae(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ae(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),ae(t._zod,"pattern",()=>{if(e.options.every(r=>r._zod.pattern)){let r=e.options.map(n=>n._zod.pattern);return new RegExp(`^(${r.map(n=>Nn(n.source)).join("|")})$`)}}),t._zod.parse=(r,n)=>{let o=!1,s=[];for(let i of e.options){let a=i._zod.run({value:r.value,issues:[]},n);if(a instanceof Promise)s.push(a),o=!0;else{if(a.issues.length===0)return a;s.push(a)}}return o?Promise.all(s).then(i=>gf(i,r,t,n)):gf(s,r,t,n)}}),Ma=k("$ZodDiscriminatedUnion",(t,e)=>{es.init(t,e);let r=t._zod.parse;ae(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=jn(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!Vr(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:i,path:[e.discriminator],inst:t}),o)}}),Da=k("$ZodIntersection",(t,e)=>{oe.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>_f(r,c,u)):_f(r,s,i)}});function pa(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(Fr(t)&&Fr(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=pa(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=pa(o,s);if(!i.valid)return{valid:!1,mergeErrorPath:[n,...i.mergeErrorPath]};r.push(i.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function _f(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),ir(t))return t;let n=pa(e.value,r.value);if(!n.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(n.mergeErrorPath)}`);return t.value=n.data,t}var qa=k("$ZodRecord",(t,e)=>{oe.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Fr(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[];if(e.keyType._zod.values){let i=e.keyType._zod.values;r.value={};for(let c of i)if(typeof c=="string"||typeof c=="number"||typeof c=="symbol"){let u=e.valueType._zod.run({value:o[c],issues:[]},n);u instanceof Promise?s.push(u.then(l=>{l.issues.length&&r.issues.push(...gt(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...gt(c,u.issues)),r.value[c]=u.value)}let a;for(let c in o)i.has(c)||(a=a??[],a.push(c));a&&a.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:a})}else{r.value={};for(let i of Reflect.ownKeys(o)){if(i==="__proto__")continue;let a=e.keyType._zod.run({value:i,issues:[]},n);if(a instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(a.issues.length){r.issues.push({origin:"record",code:"invalid_key",issues:a.issues.map(u=>at(u,n,Be())),input:i,path:[i],inst:t}),r.value[a.value]=a.value;continue}let c=e.valueType._zod.run({value:o[i],issues:[]},n);c instanceof Promise?s.push(c.then(u=>{u.issues.length&&r.issues.push(...gt(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...gt(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var La=k("$ZodEnum",(t,e)=>{oe.init(t,e);let r=On(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>Wi.has(typeof n)).map(n=>typeof n=="string"?Nt(n):n.toString()).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return t._zod.values.has(s)||n.issues.push({code:"invalid_value",values:r,input:s,inst:t}),n}}),Ua=k("$ZodLiteral",(t,e)=>{oe.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Nt(r):r?r.toString():String(r)).join("|")})$`),t._zod.parse=(r,n)=>{let o=r.value;return t._zod.values.has(o)||r.issues.push({code:"invalid_value",values:e.values,input:o,inst:t}),r}});var Va=k("$ZodTransform",(t,e)=>{oe.init(t,e),t._zod.parse=(r,n)=>{let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new zt;return r.value=o,r}}),Fa=k("$ZodOptional",(t,e)=>{oe.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ae(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ae(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Nn(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)}),Ha=k("$ZodNullable",(t,e)=>{oe.init(t,e),ae(t._zod,"optin",()=>e.innerType._zod.optin),ae(t._zod,"optout",()=>e.innerType._zod.optout),ae(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Nn(r.source)}|null)$`):void 0}),ae(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)}),Ba=k("$ZodDefault",(t,e)=>{oe.init(t,e),t._zod.optin="optional",ae(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>yf(s,e)):yf(o,e)}});function yf(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var Ja=k("$ZodPrefault",(t,e)=>{oe.init(t,e),t._zod.optin="optional",ae(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))}),Ka=k("$ZodNonOptional",(t,e)=>{oe.init(t,e),ae(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>vf(s,t)):vf(o,t)}});function vf(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var Ga=k("$ZodCatch",(t,e)=>{oe.init(t,e),t._zod.optin="optional",ae(t._zod,"optout",()=>e.innerType._zod.optout),ae(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>at(i,n,Be()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>at(s,n,Be()))},input:r.value}),r.issues=[]),r)}});var Wa=k("$ZodPipe",(t,e)=>{oe.init(t,e),ae(t._zod,"values",()=>e.in._zod.values),ae(t._zod,"optin",()=>e.in._zod.optin),ae(t._zod,"optout",()=>e.out._zod.optout),t._zod.parse=(r,n)=>{let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>bf(s,e,n)):bf(o,e,n)}});function bf(t,e,r){return ir(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var Ya=k("$ZodReadonly",(t,e)=>{oe.init(t,e),ae(t._zod,"propValues",()=>e.innerType._zod.propValues),ae(t._zod,"values",()=>e.innerType._zod.values),ae(t._zod,"optin",()=>e.innerType._zod.optin),ae(t._zod,"optout",()=>e.innerType._zod.optout),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(wf):wf(o)}});function wf(t){return t.value=Object.freeze(t.value),t}var Xa=k("$ZodCustom",(t,e)=>{ke.init(t,e),oe.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>xf(s,r,n,t));xf(o,r,n,t)}});function xf(t,e,r,n){if(!t){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),e.issues.push(Qi(o))}}d();var wv=t=>{let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"NaN":"number";case"object":{if(Array.isArray(t))return"array";if(t===null)return"null";if(Object.getPrototypeOf(t)!==Object.prototype&&t.constructor)return t.constructor.name}}return e},xv=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function e(n){return t[n]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Invalid input: expected ${n.expected}, received ${wv(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${Jo(n.values[0])}`:`Invalid option: expected one of ${Ho(n.values,"|")}`;case"too_big":{let o=n.inclusive?"<=":"<",s=e(n.origin);return s?`Too big: expected ${n.origin??"value"} to have ${o}${n.maximum.toString()} ${s.unit??"elements"}`:`Too big: expected ${n.origin??"value"} to be ${o}${n.maximum.toString()}`}case"too_small":{let o=n.inclusive?">=":">",s=e(n.origin);return s?`Too small: expected ${n.origin} to have ${o}${n.minimum.toString()} ${s.unit}`:`Too small: expected ${n.origin} to be ${o}${n.minimum.toString()}`}case"invalid_format":{let o=n;return o.format==="starts_with"?`Invalid string: must start with "${o.prefix}"`:o.format==="ends_with"?`Invalid string: must end with "${o.suffix}"`:o.format==="includes"?`Invalid string: must include "${o.includes}"`:o.format==="regex"?`Invalid string: must match pattern ${o.pattern}`:`Invalid ${r[o.format]??n.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${n.divisor}`;case"unrecognized_keys":return`Unrecognized key${n.keys.length>1?"s":""}: ${Ho(n.keys,", ")}`;case"invalid_key":return`Invalid key in ${n.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${n.origin}`;default:return"Invalid input"}}};function Pf(){return{localeError:xv()}}d();var Un=class{constructor(){this._map=new Map,this._idmap=new Map}add(e,...r){let 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){let 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){let r=e._zod.parent;if(r){let 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 If(){return new Un}var Mt=If();d();function Qa(t,e){return new t({type:"string",...M(e)})}function ec(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...M(e)})}function ts(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...M(e)})}function tc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...M(e)})}function rc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...M(e)})}function nc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...M(e)})}function oc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...M(e)})}function sc(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...M(e)})}function ic(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...M(e)})}function ac(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...M(e)})}function cc(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...M(e)})}function uc(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...M(e)})}function lc(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...M(e)})}function dc(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...M(e)})}function pc(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...M(e)})}function fc(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...M(e)})}function mc(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...M(e)})}function hc(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...M(e)})}function gc(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...M(e)})}function _c(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...M(e)})}function yc(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...M(e)})}function vc(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...M(e)})}function bc(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...M(e)})}function Ef(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...M(e)})}function Rf(t,e){return new t({type:"string",format:"date",check:"string_format",...M(e)})}function Cf(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...M(e)})}function Zf(t,e){return new t({type:"string",format:"duration",check:"string_format",...M(e)})}function wc(t,e){return new t({type:"number",checks:[],...M(e)})}function xc(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...M(e)})}function kc(t,e){return new t({type:"boolean",...M(e)})}function $c(t,e){return new t({type:"null",...M(e)})}function Sc(t){return new t({type:"unknown"})}function Tc(t,e){return new t({type:"never",...M(e)})}function rs(t,e){return new la({check:"less_than",...M(e),value:t,inclusive:!1})}function Vn(t,e){return new la({check:"less_than",...M(e),value:t,inclusive:!0})}function ns(t,e){return new da({check:"greater_than",...M(e),value:t,inclusive:!1})}function Fn(t,e){return new da({check:"greater_than",...M(e),value:t,inclusive:!0})}function os(t,e){return new Qp({check:"multiple_of",...M(e),value:t})}function ss(t,e){return new tf({check:"max_length",...M(e),maximum:t})}function Hr(t,e){return new rf({check:"min_length",...M(e),minimum:t})}function is(t,e){return new nf({check:"length_equals",...M(e),length:t})}function zc(t,e){return new of({check:"string_format",format:"regex",...M(e),pattern:t})}function Pc(t){return new sf({check:"string_format",format:"lowercase",...M(t)})}function Ic(t){return new af({check:"string_format",format:"uppercase",...M(t)})}function Ec(t,e){return new cf({check:"string_format",format:"includes",...M(e),includes:t})}function Rc(t,e){return new uf({check:"string_format",format:"starts_with",...M(e),prefix:t})}function Cc(t,e){return new lf({check:"string_format",format:"ends_with",...M(e),suffix:t})}function ur(t){return new df({check:"overwrite",tx:t})}function Zc(t){return ur(e=>e.normalize(t))}function Oc(){return ur(t=>t.trim())}function jc(){return ur(t=>t.toLowerCase())}function Ac(){return ur(t=>t.toUpperCase())}function Of(t,e,r){return new t({type:"array",element:e,...M(r)})}function Nc(t,e,r){let n=M(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Mc(t,e,r){return new t({type:"custom",check:"custom",fn:e,...M(r)})}d();var as=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Mt,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;let o=e._zod.def,s={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;let a={schema:{},count:1,cycle:void 0,path:r.path};this.seen.set(e,a);let c=e._zod.toJSONSchema?.();if(c)a.schema=c;else{let p={...r,schemaPath:[...r.schemaPath,e],path:r.path},m=e._zod.parent;if(m)a.ref=m,this.process(m,p),this.seen.get(m).isParent=!0;else{let h=a.schema;switch(o.type){case"string":{let f=h;f.type="string";let{minimum:_,maximum:w,format:$,patterns:S,contentEncoding:T}=e._zod.bag;if(typeof _=="number"&&(f.minLength=_),typeof w=="number"&&(f.maxLength=w),$&&(f.format=s[$]??$,f.format===""&&delete f.format),T&&(f.contentEncoding=T),S&&S.size>0){let R=[...S];R.length===1?f.pattern=R[0].source:R.length>1&&(a.schema.allOf=[...R.map(N=>({...this.target==="draft-7"?{type:"string"}:{},pattern:N.source}))])}break}case"number":{let f=h,{minimum:_,maximum:w,format:$,multipleOf:S,exclusiveMaximum:T,exclusiveMinimum:R}=e._zod.bag;typeof $=="string"&&$.includes("int")?f.type="integer":f.type="number",typeof R=="number"&&(f.exclusiveMinimum=R),typeof _=="number"&&(f.minimum=_,typeof R=="number"&&(R>=_?delete f.minimum:delete f.exclusiveMinimum)),typeof T=="number"&&(f.exclusiveMaximum=T),typeof w=="number"&&(f.maximum=w,typeof T=="number"&&(T<=w?delete f.maximum:delete f.exclusiveMaximum)),typeof S=="number"&&(f.multipleOf=S);break}case"boolean":{let f=h;f.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":{h.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":{h.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let f=h,{minimum:_,maximum:w}=e._zod.bag;typeof _=="number"&&(f.minItems=_),typeof w=="number"&&(f.maxItems=w),f.type="array",f.items=this.process(o.element,{...p,path:[...p.path,"items"]});break}case"object":{let f=h;f.type="object",f.properties={};let _=o.shape;for(let S in _)f.properties[S]=this.process(_[S],{...p,path:[...p.path,"properties",S]});let w=new Set(Object.keys(_)),$=new Set([...w].filter(S=>{let T=o.shape[S]._zod;return this.io==="input"?T.optin===void 0:T.optout===void 0}));$.size>0&&(f.required=Array.from($)),o.catchall?._zod.def.type==="never"?f.additionalProperties=!1:o.catchall?o.catchall&&(f.additionalProperties=this.process(o.catchall,{...p,path:[...p.path,"additionalProperties"]})):this.io==="output"&&(f.additionalProperties=!1);break}case"union":{let f=h;f.anyOf=o.options.map((_,w)=>this.process(_,{...p,path:[...p.path,"anyOf",w]}));break}case"intersection":{let f=h,_=this.process(o.left,{...p,path:[...p.path,"allOf",0]}),w=this.process(o.right,{...p,path:[...p.path,"allOf",1]}),$=T=>"allOf"in T&&Object.keys(T).length===1,S=[...$(_)?_.allOf:[_],...$(w)?w.allOf:[w]];f.allOf=S;break}case"tuple":{let f=h;f.type="array";let _=o.items.map((S,T)=>this.process(S,{...p,path:[...p.path,"prefixItems",T]}));if(this.target==="draft-2020-12"?f.prefixItems=_:f.items=_,o.rest){let S=this.process(o.rest,{...p,path:[...p.path,"items"]});this.target==="draft-2020-12"?f.items=S:f.additionalItems=S}o.rest&&(f.items=this.process(o.rest,{...p,path:[...p.path,"items"]}));let{minimum:w,maximum:$}=e._zod.bag;typeof w=="number"&&(f.minItems=w),typeof $=="number"&&(f.maxItems=$);break}case"record":{let f=h;f.type="object",f.propertyNames=this.process(o.keyType,{...p,path:[...p.path,"propertyNames"]}),f.additionalProperties=this.process(o.valueType,{...p,path:[...p.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":{let f=h,_=On(o.entries);_.every(w=>typeof w=="number")&&(f.type="number"),_.every(w=>typeof w=="string")&&(f.type="string"),f.enum=_;break}case"literal":{let f=h,_=[];for(let w of o.values)if(w===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof w=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");_.push(Number(w))}else _.push(w);if(_.length!==0)if(_.length===1){let w=_[0];f.type=w===null?"null":typeof w,f.const=w}else _.every(w=>typeof w=="number")&&(f.type="number"),_.every(w=>typeof w=="string")&&(f.type="string"),_.every(w=>typeof w=="boolean")&&(f.type="string"),_.every(w=>w===null)&&(f.type="null"),f.enum=_;break}case"file":{let f=h,_={type:"string",format:"binary",contentEncoding:"binary"},{minimum:w,maximum:$,mime:S}=e._zod.bag;w!==void 0&&(_.minLength=w),$!==void 0&&(_.maxLength=$),S?S.length===1?(_.contentMediaType=S[0],Object.assign(f,_)):f.anyOf=S.map(T=>({..._,contentMediaType:T})):Object.assign(f,_);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let f=this.process(o.innerType,p);h.anyOf=[f,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,p),a.ref=o.innerType;break}case"success":{let f=h;f.type="boolean";break}case"default":{this.process(o.innerType,p),a.ref=o.innerType,h.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,p),a.ref=o.innerType,this.io==="input"&&(h._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,p),a.ref=o.innerType;let f;try{f=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}h.default=f;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let f=h,_=e._zod.pattern;if(!_)throw new Error("Pattern not found in template literal");f.type="string",f.pattern=_.source;break}case"pipe":{let f=this.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(f,p),a.ref=f;break}case"readonly":{this.process(o.innerType,p),a.ref=o.innerType,h.readOnly=!0;break}case"promise":{this.process(o.innerType,p),a.ref=o.innerType;break}case"optional":{this.process(o.innerType,p),a.ref=o.innerType;break}case"lazy":{let f=e._zod.innerType;this.process(f,p),a.ref=f;break}case"custom":{if(this.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema");break}default:}}}let u=this.metadataRegistry.get(e);return u&&Object.assign(a.schema,u),this.io==="input"&&be(e)&&(delete a.schema.examples,delete a.schema.default),this.io==="input"&&a.schema._prefault&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,this.seen.get(e).schema}emit(e,r){let n={cycles:r?.cycles??"ref",reused:r?.reused??"inline",external:r?.external??void 0},o=this.seen.get(e);if(!o)throw new Error("Unprocessed schema. This is a bug in Zod.");let s=l=>{let p=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let _=n.external.registry.get(l[0])?.id,w=n.external.uri??(S=>S);if(_)return{ref:w(_)};let $=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=$,{defId:$,ref:`${w("__shared")}#/${p}/${$}`}}if(l[1]===o)return{ref:"#"};let h=`#/${p}/`,f=l[1].schema.id??`__schema${this.counter++}`;return{defId:f,ref:h+f}},i=l=>{if(l[1].schema.$ref)return;let p=l[1],{ref:m,defId:h}=s(l);p.def={...p.schema},h&&(p.defId=h);let f=p.schema;for(let _ in f)delete f[_];f.$ref=m};if(n.cycles==="throw")for(let l of this.seen.entries()){let p=l[1];if(p.cycle)throw new Error(`Cycle detected: #/${p.cycle?.join("/")}/<root>
|
|
35
35
|
|
|
36
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let p=l[1];if(e===l[0]){i(l);continue}if(n.external){let h=n.external.registry.get(l[0])?.id;if(e!==l[0]&&h){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(p.cycle){i(l);continue}if(p.count>1&&n.reused==="ref"){i(l);continue}}let a=(l,p)=>{let m=this.seen.get(l),h=m.def??m.schema,f={...h};if(m.ref===null)return;let _=m.ref;if(m.ref=null,_){a(_,p);let w=this.seen.get(_).schema;w.$ref&&p.target==="draft-7"?(h.allOf=h.allOf??[],h.allOf.push(w)):(Object.assign(h,w),Object.assign(h,f))}m.isParent||this.override({zodSchema:l,jsonSchema:h,path:m.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let 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){let 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,o.def);let u=n.external?.defs??{};for(let l of this.seen.entries()){let p=l[1];p.def&&p.defId&&(u[p.defId]=p.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 Dc(t,e){if(t instanceof Un){let n=new as(e),o={};for(let a of t._idmap.entries()){let[c,u]=a;n.process(u)}let s={},i={registry:t,uri:e?.uri,defs:o};for(let a of t._idmap.entries()){let[c,u]=a;s[c]=n.emit(u,{...e,external:i})}if(Object.keys(o).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:o}}return{schemas:s}}let r=new as(e);return r.process(t),r.emit(t,e)}function be(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let o=t._zod.def;switch(o.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 be(o.element,r);case"object":{for(let s in o.shape)if(be(o.shape[s],r))return!0;return!1}case"union":{for(let s of o.options)if(be(s,r))return!0;return!1}case"intersection":return be(o.left,r)||be(o.right,r);case"tuple":{for(let s of o.items)if(be(s,r))return!0;return!!(o.rest&&be(o.rest,r))}case"record":return be(o.keyType,r)||be(o.valueType,r);case"map":return be(o.keyType,r)||be(o.valueType,r);case"set":return be(o.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return be(o.innerType,r);case"lazy":return be(o.getter(),r);case"default":return be(o.innerType,r);case"prefault":return be(o.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return be(o.in,r)||be(o.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${o.type}`)}d();d();var rb=$("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");oe.init(t,e),t.def=e,t.parse=(r,n)=>na(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>ar(t,r,n),t.parseAsync=async(r,n)=>sa(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>cr(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)=>Je(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))});var nb=$("ZodMiniObject",(t,e)=>{Qo.init(t,e),rb.init(t,e),G.defineLazy(t,"shape",()=>e.shape)});function qc(t,e){let r={type:"object",get shape(){return G.assignProp(this,"shape",{...t}),this.shape},...G.normalizeParams(e)};return new nb(r)}function Ye(t){return!!t._zod}function dr(t){let e=Object.values(t);if(e.length===0)return qc({});let r=e.every(Ye),n=e.every(o=>!Ye(o));if(r)return qc(t);if(n)return Vd(t);throw new Error("Mixed Zod versions detected in object shape.")}function Dt(t,e){return Ye(t)?ar(t,e):t.safeParse(e)}async function cs(t,e){return Ye(t)?await cr(t,e):await t.safeParseAsync(e)}function qt(t){if(!t)return;let e;if(Ye(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Br(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return dr(t)}}if(Ye(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function us(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){let 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 jf(t){return t.description}function Af(t){if(Ye(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function ls(t){if(Ye(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let 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]}let n=t.value;if(n!==void 0)return n}d();d();d();d();var Hn={};Ld(Hn,{ZodISODate:()=>Mf,ZodISODateTime:()=>Nf,ZodISODuration:()=>qf,ZodISOTime:()=>Df,date:()=>Uc,datetime:()=>Lc,duration:()=>Fc,time:()=>Vc});d();var Nf=$("ZodISODateTime",(t,e)=>{xf.init(t,e),me.init(t,e)});function Lc(t){return If(Nf,t)}var Mf=$("ZodISODate",(t,e)=>{$f.init(t,e),me.init(t,e)});function Uc(t){return Ef(Mf,t)}var Df=$("ZodISOTime",(t,e)=>{kf.init(t,e),me.init(t,e)});function Vc(t){return Rf(Df,t)}var qf=$("ZodISODuration",(t,e)=>{Sf.init(t,e),me.init(t,e)});function Fc(t){return Cf(qf,t)}d();d();var Lf=(t,e)=>{Ko.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>ta(t,r)},flatten:{value:r=>ea(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},FR=$("ZodError",Lf),Bn=$("ZodError",Lf,{Parent:Error});var Uf=ra(Bn),Vf=oa(Bn),Ff=ia(Bn),Hf=aa(Bn);var ye=$("ZodType",(t,e)=>(oe.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)=>Je(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>Uf(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Ff(t,r,n),t.parseAsync=async(r,n)=>Vf(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Hf(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(ew(r,n)),t.superRefine=r=>t.check(tw(r)),t.overwrite=r=>t.check(ur(r)),t.optional=()=>ge(t),t.nullable=()=>Kf(t),t.nullish=()=>ge(Kf(t)),t.nonoptional=r=>Jb(t,r),t.array=()=>W(t),t.or=r=>de([t,r]),t.and=r=>ps(t,r),t.transform=r=>Bc(t,em(r)),t.default=r=>Fb(t,r),t.prefault=r=>Bb(t,r),t.catch=r=>Gb(t,r),t.pipe=r=>Bc(t,r),t.readonly=()=>Xb(t),t.describe=r=>{let n=t.clone();return Mt.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Mt.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Mt.get(t);let n=t.clone();return Mt.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),Gf=$("_ZodString",(t,e)=>{Ln.init(t,e),ye.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(zc(...n)),t.includes=(...n)=>t.check(Ec(...n)),t.startsWith=(...n)=>t.check(Rc(...n)),t.endsWith=(...n)=>t.check(Cc(...n)),t.min=(...n)=>t.check(Hr(...n)),t.max=(...n)=>t.check(ss(...n)),t.length=(...n)=>t.check(is(...n)),t.nonempty=(...n)=>t.check(Hr(1,...n)),t.lowercase=n=>t.check(Pc(n)),t.uppercase=n=>t.check(Ic(n)),t.trim=()=>t.check(Oc()),t.normalize=(...n)=>t.check(Zc(...n)),t.toLowerCase=()=>t.check(jc()),t.toUpperCase=()=>t.check(Ac())}),pb=$("ZodString",(t,e)=>{Ln.init(t,e),Gf.init(t,e),t.email=r=>t.check(ec(fb,r)),t.url=r=>t.check(sc(mb,r)),t.jwt=r=>t.check(bc(Ib,r)),t.emoji=r=>t.check(ic(hb,r)),t.guid=r=>t.check(ts(Bf,r)),t.uuid=r=>t.check(tc(ds,r)),t.uuidv4=r=>t.check(rc(ds,r)),t.uuidv6=r=>t.check(nc(ds,r)),t.uuidv7=r=>t.check(oc(ds,r)),t.nanoid=r=>t.check(ac(gb,r)),t.guid=r=>t.check(ts(Bf,r)),t.cuid=r=>t.check(cc(_b,r)),t.cuid2=r=>t.check(uc(yb,r)),t.ulid=r=>t.check(lc(vb,r)),t.base64=r=>t.check(_c(Tb,r)),t.base64url=r=>t.check(yc(zb,r)),t.xid=r=>t.check(dc(bb,r)),t.ksuid=r=>t.check(pc(wb,r)),t.ipv4=r=>t.check(fc(xb,r)),t.ipv6=r=>t.check(mc($b,r)),t.cidrv4=r=>t.check(hc(kb,r)),t.cidrv6=r=>t.check(gc(Sb,r)),t.e164=r=>t.check(vc(Pb,r)),t.datetime=r=>t.check(Lc(r)),t.date=r=>t.check(Uc(r)),t.time=r=>t.check(Vc(r)),t.duration=r=>t.check(Fc(r))});function x(t){return Qa(pb,t)}var me=$("ZodStringFormat",(t,e)=>{ce.init(t,e),Gf.init(t,e)}),fb=$("ZodEmail",(t,e)=>{ha.init(t,e),me.init(t,e)});var Bf=$("ZodGUID",(t,e)=>{fa.init(t,e),me.init(t,e)});var ds=$("ZodUUID",(t,e)=>{ma.init(t,e),me.init(t,e)});var mb=$("ZodURL",(t,e)=>{ga.init(t,e),me.init(t,e)});var hb=$("ZodEmoji",(t,e)=>{_a.init(t,e),me.init(t,e)});var gb=$("ZodNanoID",(t,e)=>{ya.init(t,e),me.init(t,e)});var _b=$("ZodCUID",(t,e)=>{va.init(t,e),me.init(t,e)});var yb=$("ZodCUID2",(t,e)=>{ba.init(t,e),me.init(t,e)});var vb=$("ZodULID",(t,e)=>{wa.init(t,e),me.init(t,e)});var bb=$("ZodXID",(t,e)=>{xa.init(t,e),me.init(t,e)});var wb=$("ZodKSUID",(t,e)=>{$a.init(t,e),me.init(t,e)});var xb=$("ZodIPv4",(t,e)=>{ka.init(t,e),me.init(t,e)});var $b=$("ZodIPv6",(t,e)=>{Sa.init(t,e),me.init(t,e)});var kb=$("ZodCIDRv4",(t,e)=>{Ta.init(t,e),me.init(t,e)});var Sb=$("ZodCIDRv6",(t,e)=>{za.init(t,e),me.init(t,e)});var Tb=$("ZodBase64",(t,e)=>{Pa.init(t,e),me.init(t,e)});var zb=$("ZodBase64URL",(t,e)=>{Ia.init(t,e),me.init(t,e)});var Pb=$("ZodE164",(t,e)=>{Ea.init(t,e),me.init(t,e)});var Ib=$("ZodJWT",(t,e)=>{Ra.init(t,e),me.init(t,e)});var Wf=$("ZodNumber",(t,e)=>{Xo.init(t,e),ye.init(t,e),t.gt=(n,o)=>t.check(ns(n,o)),t.gte=(n,o)=>t.check(Fn(n,o)),t.min=(n,o)=>t.check(Fn(n,o)),t.lt=(n,o)=>t.check(rs(n,o)),t.lte=(n,o)=>t.check(Vn(n,o)),t.max=(n,o)=>t.check(Vn(n,o)),t.int=n=>t.check(Jf(n)),t.safe=n=>t.check(Jf(n)),t.positive=n=>t.check(ns(0,n)),t.nonnegative=n=>t.check(Fn(0,n)),t.negative=n=>t.check(rs(0,n)),t.nonpositive=n=>t.check(Vn(0,n)),t.multipleOf=(n,o)=>t.check(os(n,o)),t.step=(n,o)=>t.check(os(n,o)),t.finite=()=>t;let 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 re(t){return wc(Wf,t)}var Eb=$("ZodNumberFormat",(t,e)=>{Ca.init(t,e),Wf.init(t,e)});function Jf(t){return xc(Eb,t)}var Rb=$("ZodBoolean",(t,e)=>{Za.init(t,e),ye.init(t,e)});function xe(t){return $c(Rb,t)}var Cb=$("ZodNull",(t,e)=>{Oa.init(t,e),ye.init(t,e)});function Yf(t){return kc(Cb,t)}var Zb=$("ZodUnknown",(t,e)=>{ja.init(t,e),ye.init(t,e)});function he(){return Sc(Zb)}var Ob=$("ZodNever",(t,e)=>{Aa.init(t,e),ye.init(t,e)});function jb(t){return Tc(Ob,t)}var Ab=$("ZodArray",(t,e)=>{Na.init(t,e),ye.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Hr(r,n)),t.nonempty=r=>t.check(Hr(1,r)),t.max=(r,n)=>t.check(ss(r,n)),t.length=(r,n)=>t.check(is(r,n)),t.unwrap=()=>t.element});function W(t,e){return Zf(Ab,t,e)}var Xf=$("ZodObject",(t,e)=>{Qo.init(t,e),ye.init(t,e),G.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>De(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:he()}),t.loose=()=>t.clone({...t._zod.def,catchall:he()}),t.strict=()=>t.clone({...t._zod.def,catchall:jb()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>G.extend(t,r),t.merge=r=>G.merge(t,r),t.pick=r=>G.pick(t,r),t.omit=r=>G.omit(t,r),t.partial=(...r)=>G.partial(tm,t,r[0]),t.required=(...r)=>G.required(rm,t,r[0])});function E(t,e){let r={type:"object",get shape(){return G.assignProp(this,"shape",{...t}),this.shape},...G.normalizeParams(e)};return new Xf(r)}function Ze(t,e){return new Xf({type:"object",get shape(){return G.assignProp(this,"shape",{...t}),this.shape},catchall:he(),...G.normalizeParams(e)})}var Qf=$("ZodUnion",(t,e)=>{es.init(t,e),ye.init(t,e),t.options=e.options});function de(t,e){return new Qf({type:"union",options:t,...G.normalizeParams(e)})}var Nb=$("ZodDiscriminatedUnion",(t,e)=>{Qf.init(t,e),Ma.init(t,e)});function Jc(t,e,r){return new Nb({type:"union",options:e,discriminator:t,...G.normalizeParams(r)})}var Mb=$("ZodIntersection",(t,e)=>{Da.init(t,e),ye.init(t,e)});function ps(t,e){return new Mb({type:"intersection",left:t,right:e})}var Db=$("ZodRecord",(t,e)=>{qa.init(t,e),ye.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function ue(t,e,r){return new Db({type:"record",keyType:t,valueType:e,...G.normalizeParams(r)})}var Hc=$("ZodEnum",(t,e)=>{La.init(t,e),ye.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Hc({...e,checks:[],...G.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Hc({...e,checks:[],...G.normalizeParams(o),entries:s})}});function De(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Hc({type:"enum",entries:r,...G.normalizeParams(e)})}var qb=$("ZodLiteral",(t,e)=>{Ua.init(t,e),ye.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Z(t,e){return new qb({type:"literal",values:Array.isArray(t)?t:[t],...G.normalizeParams(e)})}var Lb=$("ZodTransform",(t,e)=>{Va.init(t,e),ye.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(G.issue(s,r.value,e));else{let i=s;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(G.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function em(t){return new Lb({type:"transform",transform:t})}var tm=$("ZodOptional",(t,e)=>{Fa.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ge(t){return new tm({type:"optional",innerType:t})}var Ub=$("ZodNullable",(t,e)=>{Ha.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Kf(t){return new Ub({type:"nullable",innerType:t})}var Vb=$("ZodDefault",(t,e)=>{Ba.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Fb(t,e){return new Vb({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var Hb=$("ZodPrefault",(t,e)=>{Ja.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Bb(t,e){return new Hb({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var rm=$("ZodNonOptional",(t,e)=>{Ka.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Jb(t,e){return new rm({type:"nonoptional",innerType:t,...G.normalizeParams(e)})}var Kb=$("ZodCatch",(t,e)=>{Ga.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Gb(t,e){return new Kb({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Wb=$("ZodPipe",(t,e)=>{Wa.init(t,e),ye.init(t,e),t.in=e.in,t.out=e.out});function Bc(t,e){return new Wb({type:"pipe",in:t,out:e})}var Yb=$("ZodReadonly",(t,e)=>{Ya.init(t,e),ye.init(t,e)});function Xb(t){return new Yb({type:"readonly",innerType:t})}var nm=$("ZodCustom",(t,e)=>{Xa.init(t,e),ye.init(t,e)});function Qb(t){let e=new $e({check:"custom"});return e._zod.check=t,e}function om(t,e){return Nc(nm,t??(()=>!0),e)}function ew(t,e={}){return Mc(nm,t,e)}function tw(t){let e=Qb(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(G.issue(n,r.value,e._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),o.continue??(o.continue=!e._zod.def.abort),r.issues.push(G.issue(o))}},t(r.value,r)));return e}function Kc(t,e){return Bc(em(t),e)}Be(zf());var Wc="2025-11-25",sm="2025-03-26",Kr=[Wc,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Lt="io.modelcontextprotocol/related-task",ms="2.0",we=om(t=>t!==null&&(typeof t=="object"||typeof t=="function")),im=de([x(),re().int()]),am=x(),cC=Ze({ttl:re().optional(),pollInterval:re().optional()}),rw=E({ttl:re().optional()}),nw=E({taskId:x()}),Yc=Ze({progressToken:im.optional(),[Lt]:nw.optional()}),Ke=E({_meta:Yc.optional()}),Jn=Ke.extend({task:rw.optional()}),cm=t=>Jn.safeParse(t).success,ke=E({method:x(),params:Ke.loose().optional()}),Xe=E({_meta:Yc.optional()}),Qe=E({method:x(),params:Xe.loose().optional()}),Se=Ze({_meta:Yc.optional()}),hs=de([x(),re().int()]),um=E({jsonrpc:Z(ms),id:hs,...ke.shape}).strict(),Ut=t=>um.safeParse(t).success,lm=E({jsonrpc:Z(ms),...Qe.shape}).strict(),dm=t=>lm.safeParse(t).success,Xc=E({jsonrpc:Z(ms),id:hs,result:Se}).strict(),Pt=t=>Xc.safeParse(t).success;var A;(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"})(A||(A={}));var Qc=E({jsonrpc:Z(ms),id:hs.optional(),error:E({code:re().int(),message:x(),data:he().optional()})}).strict();var Gr=t=>Qc.safeParse(t).success;var Kn=de([um,lm,Xc,Qc]),uC=de([Xc,Qc]),gs=Se.strict(),ow=Xe.extend({requestId:hs.optional(),reason:x().optional()}),_s=Qe.extend({method:Z("notifications/cancelled"),params:ow}),sw=E({src:x(),mimeType:x().optional(),sizes:W(x()).optional(),theme:De(["light","dark"]).optional()}),Gn=E({icons:W(sw).optional()}),Jr=E({name:x(),title:x().optional()}),pm=Jr.extend({...Jr.shape,...Gn.shape,version:x(),websiteUrl:x().optional(),description:x().optional()}),iw=ps(E({applyDefaults:xe().optional()}),ue(x(),he())),aw=Kc(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ps(E({form:iw.optional(),url:we.optional()}),ue(x(),he()).optional())),cw=Ze({list:we.optional(),cancel:we.optional(),requests:Ze({sampling:Ze({createMessage:we.optional()}).optional(),elicitation:Ze({create:we.optional()}).optional()}).optional()}),uw=Ze({list:we.optional(),cancel:we.optional(),requests:Ze({tools:Ze({call:we.optional()}).optional()}).optional()}),lw=E({experimental:ue(x(),we).optional(),sampling:E({context:we.optional(),tools:we.optional()}).optional(),elicitation:aw.optional(),roots:E({listChanged:xe().optional()}).optional(),tasks:cw.optional(),extensions:ue(x(),we).optional()}),dw=Ke.extend({protocolVersion:x(),capabilities:lw,clientInfo:pm}),ys=ke.extend({method:Z("initialize"),params:dw}),eu=t=>ys.safeParse(t).success,pw=E({experimental:ue(x(),we).optional(),logging:we.optional(),completions:we.optional(),prompts:E({listChanged:xe().optional()}).optional(),resources:E({subscribe:xe().optional(),listChanged:xe().optional()}).optional(),tools:E({listChanged:xe().optional()}).optional(),tasks:uw.optional(),extensions:ue(x(),we).optional()}),fw=Se.extend({protocolVersion:x(),capabilities:pw,serverInfo:pm,instructions:x().optional()}),tu=Qe.extend({method:Z("notifications/initialized"),params:Xe.optional()});var vs=ke.extend({method:Z("ping"),params:Ke.optional()}),mw=E({progress:re(),total:ge(re()),message:ge(x())}),hw=E({...Xe.shape,...mw.shape,progressToken:im}),bs=Qe.extend({method:Z("notifications/progress"),params:hw}),gw=Ke.extend({cursor:am.optional()}),Wn=ke.extend({params:gw.optional()}),Yn=Se.extend({nextCursor:am.optional()}),_w=De(["working","input_required","completed","failed","cancelled"]),Xn=E({taskId:x(),status:_w,ttl:de([re(),Yf()]),createdAt:x(),lastUpdatedAt:x(),pollInterval:ge(re()),statusMessage:ge(x())}),Wr=Se.extend({task:Xn}),yw=Xe.merge(Xn),Qn=Qe.extend({method:Z("notifications/tasks/status"),params:yw}),ws=ke.extend({method:Z("tasks/get"),params:Ke.extend({taskId:x()})}),xs=Se.merge(Xn),$s=ke.extend({method:Z("tasks/result"),params:Ke.extend({taskId:x()})}),lC=Se.loose(),ks=Wn.extend({method:Z("tasks/list")}),Ss=Yn.extend({tasks:W(Xn)}),Ts=ke.extend({method:Z("tasks/cancel"),params:Ke.extend({taskId:x()})}),fm=Se.merge(Xn),mm=E({uri:x(),mimeType:ge(x()),_meta:ue(x(),he()).optional()}),hm=mm.extend({text:x()}),ru=x().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),gm=mm.extend({blob:ru}),eo=De(["user","assistant"]),Yr=E({audience:W(eo).optional(),priority:re().min(0).max(1).optional(),lastModified:Hn.datetime({offset:!0}).optional()}),_m=E({...Jr.shape,...Gn.shape,uri:x(),description:ge(x()),mimeType:ge(x()),size:ge(re()),annotations:Yr.optional(),_meta:ge(Ze({}))}),vw=E({...Jr.shape,...Gn.shape,uriTemplate:x(),description:ge(x()),mimeType:ge(x()),annotations:Yr.optional(),_meta:ge(Ze({}))}),zs=Wn.extend({method:Z("resources/list")}),bw=Yn.extend({resources:W(_m)}),Ps=Wn.extend({method:Z("resources/templates/list")}),ww=Yn.extend({resourceTemplates:W(vw)}),nu=Ke.extend({uri:x()}),xw=nu,Is=ke.extend({method:Z("resources/read"),params:xw}),$w=Se.extend({contents:W(de([hm,gm]))}),kw=Qe.extend({method:Z("notifications/resources/list_changed"),params:Xe.optional()}),Sw=nu,Tw=ke.extend({method:Z("resources/subscribe"),params:Sw}),zw=nu,Pw=ke.extend({method:Z("resources/unsubscribe"),params:zw}),Iw=Xe.extend({uri:x()}),Ew=Qe.extend({method:Z("notifications/resources/updated"),params:Iw}),Rw=E({name:x(),description:ge(x()),required:ge(xe())}),Cw=E({...Jr.shape,...Gn.shape,description:ge(x()),arguments:ge(W(Rw)),_meta:ge(Ze({}))}),Es=Wn.extend({method:Z("prompts/list")}),Zw=Yn.extend({prompts:W(Cw)}),Ow=Ke.extend({name:x(),arguments:ue(x(),x()).optional()}),Rs=ke.extend({method:Z("prompts/get"),params:Ow}),ou=E({type:Z("text"),text:x(),annotations:Yr.optional(),_meta:ue(x(),he()).optional()}),su=E({type:Z("image"),data:ru,mimeType:x(),annotations:Yr.optional(),_meta:ue(x(),he()).optional()}),iu=E({type:Z("audio"),data:ru,mimeType:x(),annotations:Yr.optional(),_meta:ue(x(),he()).optional()}),jw=E({type:Z("tool_use"),name:x(),id:x(),input:ue(x(),he()),_meta:ue(x(),he()).optional()}),Aw=E({type:Z("resource"),resource:de([hm,gm]),annotations:Yr.optional(),_meta:ue(x(),he()).optional()}),Nw=_m.extend({type:Z("resource_link")}),au=de([ou,su,iu,Nw,Aw]),Mw=E({role:eo,content:au}),Dw=Se.extend({description:x().optional(),messages:W(Mw)}),qw=Qe.extend({method:Z("notifications/prompts/list_changed"),params:Xe.optional()}),Lw=E({title:x().optional(),readOnlyHint:xe().optional(),destructiveHint:xe().optional(),idempotentHint:xe().optional(),openWorldHint:xe().optional()}),Uw=E({taskSupport:De(["required","optional","forbidden"]).optional()}),ym=E({...Jr.shape,...Gn.shape,description:x().optional(),inputSchema:E({type:Z("object"),properties:ue(x(),we).optional(),required:W(x()).optional()}).catchall(he()),outputSchema:E({type:Z("object"),properties:ue(x(),we).optional(),required:W(x()).optional()}).catchall(he()).optional(),annotations:Lw.optional(),execution:Uw.optional(),_meta:ue(x(),he()).optional()}),Cs=Wn.extend({method:Z("tools/list")}),Vw=Yn.extend({tools:W(ym)}),Zs=Se.extend({content:W(au).default([]),structuredContent:ue(x(),he()).optional(),isError:xe().optional()}),dC=Zs.or(Se.extend({toolResult:he()})),Fw=Jn.extend({name:x(),arguments:ue(x(),he()).optional()}),Xr=ke.extend({method:Z("tools/call"),params:Fw}),Hw=Qe.extend({method:Z("notifications/tools/list_changed"),params:Xe.optional()}),pC=E({autoRefresh:xe().default(!0),debounceMs:re().int().nonnegative().default(300)}),to=De(["debug","info","notice","warning","error","critical","alert","emergency"]),Bw=Ke.extend({level:to}),cu=ke.extend({method:Z("logging/setLevel"),params:Bw}),Jw=Xe.extend({level:to,logger:x().optional(),data:he()}),Kw=Qe.extend({method:Z("notifications/message"),params:Jw}),Gw=E({name:x().optional()}),Ww=E({hints:W(Gw).optional(),costPriority:re().min(0).max(1).optional(),speedPriority:re().min(0).max(1).optional(),intelligencePriority:re().min(0).max(1).optional()}),Yw=E({mode:De(["auto","required","none"]).optional()}),Xw=E({type:Z("tool_result"),toolUseId:x().describe("The unique identifier for the corresponding tool call."),content:W(au).default([]),structuredContent:E({}).loose().optional(),isError:xe().optional(),_meta:ue(x(),he()).optional()}),Qw=Jc("type",[ou,su,iu]),fs=Jc("type",[ou,su,iu,jw,Xw]),e0=E({role:eo,content:de([fs,W(fs)]),_meta:ue(x(),he()).optional()}),t0=Jn.extend({messages:W(e0),modelPreferences:Ww.optional(),systemPrompt:x().optional(),includeContext:De(["none","thisServer","allServers"]).optional(),temperature:re().optional(),maxTokens:re().int(),stopSequences:W(x()).optional(),metadata:we.optional(),tools:W(ym).optional(),toolChoice:Yw.optional()}),r0=ke.extend({method:Z("sampling/createMessage"),params:t0}),ro=Se.extend({model:x(),stopReason:ge(De(["endTurn","stopSequence","maxTokens"]).or(x())),role:eo,content:Qw}),uu=Se.extend({model:x(),stopReason:ge(De(["endTurn","stopSequence","maxTokens","toolUse"]).or(x())),role:eo,content:de([fs,W(fs)])}),n0=E({type:Z("boolean"),title:x().optional(),description:x().optional(),default:xe().optional()}),o0=E({type:Z("string"),title:x().optional(),description:x().optional(),minLength:re().optional(),maxLength:re().optional(),format:De(["email","uri","date","date-time"]).optional(),default:x().optional()}),s0=E({type:De(["number","integer"]),title:x().optional(),description:x().optional(),minimum:re().optional(),maximum:re().optional(),default:re().optional()}),i0=E({type:Z("string"),title:x().optional(),description:x().optional(),enum:W(x()),default:x().optional()}),a0=E({type:Z("string"),title:x().optional(),description:x().optional(),oneOf:W(E({const:x(),title:x()})),default:x().optional()}),c0=E({type:Z("string"),title:x().optional(),description:x().optional(),enum:W(x()),enumNames:W(x()).optional(),default:x().optional()}),u0=de([i0,a0]),l0=E({type:Z("array"),title:x().optional(),description:x().optional(),minItems:re().optional(),maxItems:re().optional(),items:E({type:Z("string"),enum:W(x())}),default:W(x()).optional()}),d0=E({type:Z("array"),title:x().optional(),description:x().optional(),minItems:re().optional(),maxItems:re().optional(),items:E({anyOf:W(E({const:x(),title:x()}))}),default:W(x()).optional()}),p0=de([l0,d0]),f0=de([c0,u0,p0]),m0=de([f0,n0,o0,s0]),h0=Jn.extend({mode:Z("form").optional(),message:x(),requestedSchema:E({type:Z("object"),properties:ue(x(),m0),required:W(x()).optional()})}),g0=Jn.extend({mode:Z("url"),message:x(),elicitationId:x(),url:x().url()}),_0=de([h0,g0]),y0=ke.extend({method:Z("elicitation/create"),params:_0}),v0=Xe.extend({elicitationId:x()}),b0=Qe.extend({method:Z("notifications/elicitation/complete"),params:v0}),Qr=Se.extend({action:De(["accept","decline","cancel"]),content:Kc(t=>t===null?void 0:t,ue(x(),de([x(),re(),xe(),W(x())])).optional())}),w0=E({type:Z("ref/resource"),uri:x()});var x0=E({type:Z("ref/prompt"),name:x()}),$0=Ke.extend({ref:de([x0,w0]),argument:E({name:x(),value:x()}),context:E({arguments:ue(x(),x()).optional()}).optional()}),Os=ke.extend({method:Z("completion/complete"),params:$0});function vm(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function bm(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var k0=Se.extend({completion:Ze({values:W(x()).max(100),total:ge(re().int()),hasMore:ge(xe())})}),S0=E({uri:x().startsWith("file://"),name:x().optional(),_meta:ue(x(),he()).optional()}),T0=ke.extend({method:Z("roots/list"),params:Ke.optional()}),lu=Se.extend({roots:W(S0)}),z0=Qe.extend({method:Z("notifications/roots/list_changed"),params:Xe.optional()}),fC=de([vs,ys,Os,cu,Rs,Es,zs,Ps,Is,Tw,Pw,Xr,Cs,ws,$s,ks,Ts]),mC=de([_s,bs,tu,z0,Qn]),hC=de([gs,ro,uu,Qr,lu,xs,Ss,Wr]),gC=de([vs,r0,y0,T0,ws,$s,ks,Ts]),_C=de([_s,bs,Kw,Ew,kw,Hw,qw,Qn,b0]),yC=de([gs,fw,k0,Dw,Zw,bw,ww,$w,Zs,Vw,xs,Ss,Wr]),C=class t 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===A.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Gc(o.elicitations,r)}return new t(e,r,n)}},Gc=class extends C{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(A.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};d();function Vt(t){return t==="completed"||t==="failed"||t==="cancelled"}d();d();d();var xm=Symbol("Let zodToJsonSchema decide on which parser to use");var wm={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"},$m=t=>typeof t=="string"?{...wm,name:t}:{...wm,...t};d();var km=t=>{let e=$m(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,o])=>[o._def,{def:o._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};d();function du(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function Y(t,e,r,n,o){t[e]=r,du(t,e,n,o)}d();var js=(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("/")};d();d();d();function _e(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?js(e,t.currentPath):e.join("/")}}d();function Sm(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==U.ZodAny&&(r.items=D(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&Y(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&Y(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(Y(r,"minItems",t.exactLength.value,t.exactLength.message,e),Y(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}d();function Tm(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?Y(r,"minimum",n.value,n.message,e):Y(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),Y(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?Y(r,"maximum",n.value,n.message,e):Y(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),Y(r,"maximum",n.value,n.message,e));break;case"multipleOf":Y(r,"multipleOf",n.value,n.message,e);break}return r}d();function zm(){return{type:"boolean"}}d();function As(t,e){return D(t.type._def,e)}d();var Pm=(t,e)=>D(t.innerType._def,e);d();function pu(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>pu(t,e,o))};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 P0(t,e)}}var P0=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":Y(r,"minimum",n.value,n.message,e);break;case"max":Y(r,"maximum",n.value,n.message,e);break}return r};d();function Im(t,e){return{...D(t.innerType._def,e),default:t.defaultValue()}}d();function Em(t,e){return e.effectStrategy==="input"?D(t.schema._def,e):_e(e)}d();function Rm(t){return{type:"string",enum:Array.from(t.values)}}d();var I0=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Cm(t,e){let r=[D(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),D(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(s=>!!s),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,o=[];return r.forEach(s=>{if(I0(s))o.push(...s.allOf),s.unevaluatedProperties===void 0&&(n=void 0);else{let i=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:a,...c}=s;i=c}else n=void 0;o.push(i)}}),o.length?{allOf:o,...n}:void 0}d();function Zm(t,e){let 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}}d();d();d();var fu,ct={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:()=>(fu===void 0&&(fu=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),fu),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 Ns(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":Y(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":Y(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":ut(r,"email",n.message,e);break;case"format:idn-email":ut(r,"idn-email",n.message,e);break;case"pattern:zod":Oe(r,ct.email,n.message,e);break}break;case"url":ut(r,"uri",n.message,e);break;case"uuid":ut(r,"uuid",n.message,e);break;case"regex":Oe(r,n.regex,n.message,e);break;case"cuid":Oe(r,ct.cuid,n.message,e);break;case"cuid2":Oe(r,ct.cuid2,n.message,e);break;case"startsWith":Oe(r,RegExp(`^${mu(n.value,e)}`),n.message,e);break;case"endsWith":Oe(r,RegExp(`${mu(n.value,e)}$`),n.message,e);break;case"datetime":ut(r,"date-time",n.message,e);break;case"date":ut(r,"date",n.message,e);break;case"time":ut(r,"time",n.message,e);break;case"duration":ut(r,"duration",n.message,e);break;case"length":Y(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),Y(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Oe(r,RegExp(mu(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&ut(r,"ipv4",n.message,e),n.version!=="v4"&&ut(r,"ipv6",n.message,e);break}case"base64url":Oe(r,ct.base64url,n.message,e);break;case"jwt":Oe(r,ct.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Oe(r,ct.ipv4Cidr,n.message,e),n.version!=="v4"&&Oe(r,ct.ipv6Cidr,n.message,e);break}case"emoji":Oe(r,ct.emoji(),n.message,e);break;case"ulid":{Oe(r,ct.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{ut(r,"binary",n.message,e);break}case"contentEncoding:base64":{Y(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Oe(r,ct.base64,n.message,e);break}}break}case"nanoid":Oe(r,ct.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function mu(t,e){return e.patternStrategy==="escape"?R0(t):t}var E0=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function R0(t){let e="";for(let r=0;r<t.length;r++)E0.has(t[r])||(e+="\\"),e+=t[r];return e}function ut(t,e,r,n){t.format||t.anyOf?.some(o=>o.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}}})):Y(t,"format",e,r,n)}function Oe(t,e,r,n){t.pattern||t.allOf?.some(o=>o.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:Om(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):Y(t,"pattern",Om(e,n),r,n)}function Om(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,o="",s=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(s){o+=n[c],s=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(o+=n[c],o+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(o+=n[c],a=!0):o+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){o+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){o+=`(^|(?<=[\r
|
|
36
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let l of this.seen.entries()){let p=l[1];if(e===l[0]){i(l);continue}if(n.external){let h=n.external.registry.get(l[0])?.id;if(e!==l[0]&&h){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(p.cycle){i(l);continue}if(p.count>1&&n.reused==="ref"){i(l);continue}}let a=(l,p)=>{let m=this.seen.get(l),h=m.def??m.schema,f={...h};if(m.ref===null)return;let _=m.ref;if(m.ref=null,_){a(_,p);let w=this.seen.get(_).schema;w.$ref&&p.target==="draft-7"?(h.allOf=h.allOf??[],h.allOf.push(w)):(Object.assign(h,w),Object.assign(h,f))}m.isParent||this.override({zodSchema:l,jsonSchema:h,path:m.path??[]})};for(let l of[...this.seen.entries()].reverse())a(l[0],{target:this.target});let 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){let 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,o.def);let u=n.external?.defs??{};for(let l of this.seen.entries()){let p=l[1];p.def&&p.defId&&(u[p.defId]=p.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 Dc(t,e){if(t instanceof Un){let n=new as(e),o={};for(let a of t._idmap.entries()){let[c,u]=a;n.process(u)}let s={},i={registry:t,uri:e?.uri,defs:o};for(let a of t._idmap.entries()){let[c,u]=a;s[c]=n.emit(u,{...e,external:i})}if(Object.keys(o).length>0){let a=n.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[a]:o}}return{schemas:s}}let r=new as(e);return r.process(t),r.emit(t,e)}function be(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let o=t._zod.def;switch(o.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 be(o.element,r);case"object":{for(let s in o.shape)if(be(o.shape[s],r))return!0;return!1}case"union":{for(let s of o.options)if(be(s,r))return!0;return!1}case"intersection":return be(o.left,r)||be(o.right,r);case"tuple":{for(let s of o.items)if(be(s,r))return!0;return!!(o.rest&&be(o.rest,r))}case"record":return be(o.keyType,r)||be(o.valueType,r);case"map":return be(o.keyType,r)||be(o.valueType,r);case"set":return be(o.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return be(o.innerType,r);case"lazy":return be(o.getter(),r);case"default":return be(o.innerType,r);case"prefault":return be(o.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return be(o.in,r)||be(o.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${o.type}`)}d();d();var nb=k("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");oe.init(t,e),t.def=e,t.parse=(r,n)=>na(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>ar(t,r,n),t.parseAsync=async(r,n)=>sa(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>cr(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)=>Je(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))});var ob=k("ZodMiniObject",(t,e)=>{Qo.init(t,e),nb.init(t,e),G.defineLazy(t,"shape",()=>e.shape)});function qc(t,e){let r={type:"object",get shape(){return G.assignProp(this,"shape",{...t}),this.shape},...G.normalizeParams(e)};return new ob(r)}function Ye(t){return!!t._zod}function dr(t){let e=Object.values(t);if(e.length===0)return qc({});let r=e.every(Ye),n=e.every(o=>!Ye(o));if(r)return qc(t);if(n)return Vd(t);throw new Error("Mixed Zod versions detected in object shape.")}function Dt(t,e){return Ye(t)?ar(t,e):t.safeParse(e)}async function cs(t,e){return Ye(t)?await cr(t,e):await t.safeParseAsync(e)}function qt(t){if(!t)return;let e;if(Ye(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Br(t){if(t){if(typeof t=="object"){let e=t,r=t;if(!e._def&&!r._zod){let n=Object.values(t);if(n.length>0&&n.every(o=>typeof o=="object"&&o!==null&&(o._def!==void 0||o._zod!==void 0||typeof o.parse=="function")))return dr(t)}}if(Ye(t)){let r=t._zod?.def;if(r&&(r.type==="object"||r.shape!==void 0))return t}else if(t.shape!==void 0)return t}}function us(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){let 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 Af(t){return t.description}function Nf(t){if(Ye(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function ls(t){if(Ye(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let 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]}let n=t.value;if(n!==void 0)return n}d();d();d();d();var Hn={};Ld(Hn,{ZodISODate:()=>Df,ZodISODateTime:()=>Mf,ZodISODuration:()=>Lf,ZodISOTime:()=>qf,date:()=>Uc,datetime:()=>Lc,duration:()=>Fc,time:()=>Vc});d();var Mf=k("ZodISODateTime",(t,e)=>{kf.init(t,e),me.init(t,e)});function Lc(t){return Ef(Mf,t)}var Df=k("ZodISODate",(t,e)=>{$f.init(t,e),me.init(t,e)});function Uc(t){return Rf(Df,t)}var qf=k("ZodISOTime",(t,e)=>{Sf.init(t,e),me.init(t,e)});function Vc(t){return Cf(qf,t)}var Lf=k("ZodISODuration",(t,e)=>{Tf.init(t,e),me.init(t,e)});function Fc(t){return Zf(Lf,t)}d();d();var Uf=(t,e)=>{Ko.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>ta(t,r)},flatten:{value:r=>ea(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},KR=k("ZodError",Uf),Bn=k("ZodError",Uf,{Parent:Error});var Vf=ra(Bn),Ff=oa(Bn),Hf=ia(Bn),Bf=aa(Bn);var ye=k("ZodType",(t,e)=>(oe.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)=>Je(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>Vf(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Hf(t,r,n),t.parseAsync=async(r,n)=>Ff(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Bf(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(tw(r,n)),t.superRefine=r=>t.check(rw(r)),t.overwrite=r=>t.check(ur(r)),t.optional=()=>ge(t),t.nullable=()=>Gf(t),t.nullish=()=>ge(Gf(t)),t.nonoptional=r=>Kb(t,r),t.array=()=>W(t),t.or=r=>de([t,r]),t.and=r=>ps(t,r),t.transform=r=>Bc(t,tm(r)),t.default=r=>Hb(t,r),t.prefault=r=>Jb(t,r),t.catch=r=>Wb(t,r),t.pipe=r=>Bc(t,r),t.readonly=()=>Qb(t),t.describe=r=>{let n=t.clone();return Mt.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Mt.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Mt.get(t);let n=t.clone();return Mt.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),Wf=k("_ZodString",(t,e)=>{Ln.init(t,e),ye.init(t,e);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,t.regex=(...n)=>t.check(zc(...n)),t.includes=(...n)=>t.check(Ec(...n)),t.startsWith=(...n)=>t.check(Rc(...n)),t.endsWith=(...n)=>t.check(Cc(...n)),t.min=(...n)=>t.check(Hr(...n)),t.max=(...n)=>t.check(ss(...n)),t.length=(...n)=>t.check(is(...n)),t.nonempty=(...n)=>t.check(Hr(1,...n)),t.lowercase=n=>t.check(Pc(n)),t.uppercase=n=>t.check(Ic(n)),t.trim=()=>t.check(Oc()),t.normalize=(...n)=>t.check(Zc(...n)),t.toLowerCase=()=>t.check(jc()),t.toUpperCase=()=>t.check(Ac())}),fb=k("ZodString",(t,e)=>{Ln.init(t,e),Wf.init(t,e),t.email=r=>t.check(ec(mb,r)),t.url=r=>t.check(sc(hb,r)),t.jwt=r=>t.check(bc(Eb,r)),t.emoji=r=>t.check(ic(gb,r)),t.guid=r=>t.check(ts(Jf,r)),t.uuid=r=>t.check(tc(ds,r)),t.uuidv4=r=>t.check(rc(ds,r)),t.uuidv6=r=>t.check(nc(ds,r)),t.uuidv7=r=>t.check(oc(ds,r)),t.nanoid=r=>t.check(ac(_b,r)),t.guid=r=>t.check(ts(Jf,r)),t.cuid=r=>t.check(cc(yb,r)),t.cuid2=r=>t.check(uc(vb,r)),t.ulid=r=>t.check(lc(bb,r)),t.base64=r=>t.check(_c(zb,r)),t.base64url=r=>t.check(yc(Pb,r)),t.xid=r=>t.check(dc(wb,r)),t.ksuid=r=>t.check(pc(xb,r)),t.ipv4=r=>t.check(fc(kb,r)),t.ipv6=r=>t.check(mc($b,r)),t.cidrv4=r=>t.check(hc(Sb,r)),t.cidrv6=r=>t.check(gc(Tb,r)),t.e164=r=>t.check(vc(Ib,r)),t.datetime=r=>t.check(Lc(r)),t.date=r=>t.check(Uc(r)),t.time=r=>t.check(Vc(r)),t.duration=r=>t.check(Fc(r))});function x(t){return Qa(fb,t)}var me=k("ZodStringFormat",(t,e)=>{ce.init(t,e),Wf.init(t,e)}),mb=k("ZodEmail",(t,e)=>{ha.init(t,e),me.init(t,e)});var Jf=k("ZodGUID",(t,e)=>{fa.init(t,e),me.init(t,e)});var ds=k("ZodUUID",(t,e)=>{ma.init(t,e),me.init(t,e)});var hb=k("ZodURL",(t,e)=>{ga.init(t,e),me.init(t,e)});var gb=k("ZodEmoji",(t,e)=>{_a.init(t,e),me.init(t,e)});var _b=k("ZodNanoID",(t,e)=>{ya.init(t,e),me.init(t,e)});var yb=k("ZodCUID",(t,e)=>{va.init(t,e),me.init(t,e)});var vb=k("ZodCUID2",(t,e)=>{ba.init(t,e),me.init(t,e)});var bb=k("ZodULID",(t,e)=>{wa.init(t,e),me.init(t,e)});var wb=k("ZodXID",(t,e)=>{xa.init(t,e),me.init(t,e)});var xb=k("ZodKSUID",(t,e)=>{ka.init(t,e),me.init(t,e)});var kb=k("ZodIPv4",(t,e)=>{$a.init(t,e),me.init(t,e)});var $b=k("ZodIPv6",(t,e)=>{Sa.init(t,e),me.init(t,e)});var Sb=k("ZodCIDRv4",(t,e)=>{Ta.init(t,e),me.init(t,e)});var Tb=k("ZodCIDRv6",(t,e)=>{za.init(t,e),me.init(t,e)});var zb=k("ZodBase64",(t,e)=>{Pa.init(t,e),me.init(t,e)});var Pb=k("ZodBase64URL",(t,e)=>{Ia.init(t,e),me.init(t,e)});var Ib=k("ZodE164",(t,e)=>{Ea.init(t,e),me.init(t,e)});var Eb=k("ZodJWT",(t,e)=>{Ra.init(t,e),me.init(t,e)});var Yf=k("ZodNumber",(t,e)=>{Xo.init(t,e),ye.init(t,e),t.gt=(n,o)=>t.check(ns(n,o)),t.gte=(n,o)=>t.check(Fn(n,o)),t.min=(n,o)=>t.check(Fn(n,o)),t.lt=(n,o)=>t.check(rs(n,o)),t.lte=(n,o)=>t.check(Vn(n,o)),t.max=(n,o)=>t.check(Vn(n,o)),t.int=n=>t.check(Kf(n)),t.safe=n=>t.check(Kf(n)),t.positive=n=>t.check(ns(0,n)),t.nonnegative=n=>t.check(Fn(0,n)),t.negative=n=>t.check(rs(0,n)),t.nonpositive=n=>t.check(Vn(0,n)),t.multipleOf=(n,o)=>t.check(os(n,o)),t.step=(n,o)=>t.check(os(n,o)),t.finite=()=>t;let 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 re(t){return wc(Yf,t)}var Rb=k("ZodNumberFormat",(t,e)=>{Ca.init(t,e),Yf.init(t,e)});function Kf(t){return xc(Rb,t)}var Cb=k("ZodBoolean",(t,e)=>{Za.init(t,e),ye.init(t,e)});function xe(t){return kc(Cb,t)}var Zb=k("ZodNull",(t,e)=>{Oa.init(t,e),ye.init(t,e)});function Xf(t){return $c(Zb,t)}var Ob=k("ZodUnknown",(t,e)=>{ja.init(t,e),ye.init(t,e)});function he(){return Sc(Ob)}var jb=k("ZodNever",(t,e)=>{Aa.init(t,e),ye.init(t,e)});function Ab(t){return Tc(jb,t)}var Nb=k("ZodArray",(t,e)=>{Na.init(t,e),ye.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(Hr(r,n)),t.nonempty=r=>t.check(Hr(1,r)),t.max=(r,n)=>t.check(ss(r,n)),t.length=(r,n)=>t.check(is(r,n)),t.unwrap=()=>t.element});function W(t,e){return Of(Nb,t,e)}var Qf=k("ZodObject",(t,e)=>{Qo.init(t,e),ye.init(t,e),G.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>De(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:he()}),t.loose=()=>t.clone({...t._zod.def,catchall:he()}),t.strict=()=>t.clone({...t._zod.def,catchall:Ab()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>G.extend(t,r),t.merge=r=>G.merge(t,r),t.pick=r=>G.pick(t,r),t.omit=r=>G.omit(t,r),t.partial=(...r)=>G.partial(rm,t,r[0]),t.required=(...r)=>G.required(nm,t,r[0])});function E(t,e){let r={type:"object",get shape(){return G.assignProp(this,"shape",{...t}),this.shape},...G.normalizeParams(e)};return new Qf(r)}function Ze(t,e){return new Qf({type:"object",get shape(){return G.assignProp(this,"shape",{...t}),this.shape},catchall:he(),...G.normalizeParams(e)})}var em=k("ZodUnion",(t,e)=>{es.init(t,e),ye.init(t,e),t.options=e.options});function de(t,e){return new em({type:"union",options:t,...G.normalizeParams(e)})}var Mb=k("ZodDiscriminatedUnion",(t,e)=>{em.init(t,e),Ma.init(t,e)});function Jc(t,e,r){return new Mb({type:"union",options:e,discriminator:t,...G.normalizeParams(r)})}var Db=k("ZodIntersection",(t,e)=>{Da.init(t,e),ye.init(t,e)});function ps(t,e){return new Db({type:"intersection",left:t,right:e})}var qb=k("ZodRecord",(t,e)=>{qa.init(t,e),ye.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function ue(t,e,r){return new qb({type:"record",keyType:t,valueType:e,...G.normalizeParams(r)})}var Hc=k("ZodEnum",(t,e)=>{La.init(t,e),ye.init(t,e),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Hc({...e,checks:[],...G.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Hc({...e,checks:[],...G.normalizeParams(o),entries:s})}});function De(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Hc({type:"enum",entries:r,...G.normalizeParams(e)})}var Lb=k("ZodLiteral",(t,e)=>{Ua.init(t,e),ye.init(t,e),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Z(t,e){return new Lb({type:"literal",values:Array.isArray(t)?t:[t],...G.normalizeParams(e)})}var Ub=k("ZodTransform",(t,e)=>{Va.init(t,e),ye.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(G.issue(s,r.value,e));else{let i=s;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(G.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function tm(t){return new Ub({type:"transform",transform:t})}var rm=k("ZodOptional",(t,e)=>{Fa.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType});function ge(t){return new rm({type:"optional",innerType:t})}var Vb=k("ZodNullable",(t,e)=>{Ha.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Gf(t){return new Vb({type:"nullable",innerType:t})}var Fb=k("ZodDefault",(t,e)=>{Ba.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Hb(t,e){return new Fb({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var Bb=k("ZodPrefault",(t,e)=>{Ja.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Jb(t,e){return new Bb({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var nm=k("ZodNonOptional",(t,e)=>{Ka.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Kb(t,e){return new nm({type:"nonoptional",innerType:t,...G.normalizeParams(e)})}var Gb=k("ZodCatch",(t,e)=>{Ga.init(t,e),ye.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function Wb(t,e){return new Gb({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Yb=k("ZodPipe",(t,e)=>{Wa.init(t,e),ye.init(t,e),t.in=e.in,t.out=e.out});function Bc(t,e){return new Yb({type:"pipe",in:t,out:e})}var Xb=k("ZodReadonly",(t,e)=>{Ya.init(t,e),ye.init(t,e)});function Qb(t){return new Xb({type:"readonly",innerType:t})}var om=k("ZodCustom",(t,e)=>{Xa.init(t,e),ye.init(t,e)});function ew(t){let e=new ke({check:"custom"});return e._zod.check=t,e}function sm(t,e){return Nc(om,t??(()=>!0),e)}function tw(t,e={}){return Mc(om,t,e)}function rw(t){let e=ew(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(G.issue(n,r.value,e._zod.def));else{let o=n;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),o.input??(o.input=r.value),o.inst??(o.inst=e),o.continue??(o.continue=!e._zod.def.abort),r.issues.push(G.issue(o))}},t(r.value,r)));return e}function Kc(t,e){return Bc(tm(t),e)}Be(Pf());var Wc="2025-11-25",im="2025-03-26",Kr=[Wc,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Lt="io.modelcontextprotocol/related-task",ms="2.0",we=sm(t=>t!==null&&(typeof t=="object"||typeof t=="function")),am=de([x(),re().int()]),cm=x(),pC=Ze({ttl:re().optional(),pollInterval:re().optional()}),nw=E({ttl:re().optional()}),ow=E({taskId:x()}),Yc=Ze({progressToken:am.optional(),[Lt]:ow.optional()}),Ke=E({_meta:Yc.optional()}),Jn=Ke.extend({task:nw.optional()}),um=t=>Jn.safeParse(t).success,$e=E({method:x(),params:Ke.loose().optional()}),Xe=E({_meta:Yc.optional()}),Qe=E({method:x(),params:Xe.loose().optional()}),Se=Ze({_meta:Yc.optional()}),hs=de([x(),re().int()]),lm=E({jsonrpc:Z(ms),id:hs,...$e.shape}).strict(),Ut=t=>lm.safeParse(t).success,dm=E({jsonrpc:Z(ms),...Qe.shape}).strict(),pm=t=>dm.safeParse(t).success,Xc=E({jsonrpc:Z(ms),id:hs,result:Se}).strict(),Pt=t=>Xc.safeParse(t).success;var A;(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"})(A||(A={}));var Qc=E({jsonrpc:Z(ms),id:hs.optional(),error:E({code:re().int(),message:x(),data:he().optional()})}).strict();var Gr=t=>Qc.safeParse(t).success;var Kn=de([lm,dm,Xc,Qc]),fC=de([Xc,Qc]),gs=Se.strict(),sw=Xe.extend({requestId:hs.optional(),reason:x().optional()}),_s=Qe.extend({method:Z("notifications/cancelled"),params:sw}),iw=E({src:x(),mimeType:x().optional(),sizes:W(x()).optional(),theme:De(["light","dark"]).optional()}),Gn=E({icons:W(iw).optional()}),Jr=E({name:x(),title:x().optional()}),fm=Jr.extend({...Jr.shape,...Gn.shape,version:x(),websiteUrl:x().optional(),description:x().optional()}),aw=ps(E({applyDefaults:xe().optional()}),ue(x(),he())),cw=Kc(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,ps(E({form:aw.optional(),url:we.optional()}),ue(x(),he()).optional())),uw=Ze({list:we.optional(),cancel:we.optional(),requests:Ze({sampling:Ze({createMessage:we.optional()}).optional(),elicitation:Ze({create:we.optional()}).optional()}).optional()}),lw=Ze({list:we.optional(),cancel:we.optional(),requests:Ze({tools:Ze({call:we.optional()}).optional()}).optional()}),dw=E({experimental:ue(x(),we).optional(),sampling:E({context:we.optional(),tools:we.optional()}).optional(),elicitation:cw.optional(),roots:E({listChanged:xe().optional()}).optional(),tasks:uw.optional(),extensions:ue(x(),we).optional()}),pw=Ke.extend({protocolVersion:x(),capabilities:dw,clientInfo:fm}),ys=$e.extend({method:Z("initialize"),params:pw}),eu=t=>ys.safeParse(t).success,fw=E({experimental:ue(x(),we).optional(),logging:we.optional(),completions:we.optional(),prompts:E({listChanged:xe().optional()}).optional(),resources:E({subscribe:xe().optional(),listChanged:xe().optional()}).optional(),tools:E({listChanged:xe().optional()}).optional(),tasks:lw.optional(),extensions:ue(x(),we).optional()}),mw=Se.extend({protocolVersion:x(),capabilities:fw,serverInfo:fm,instructions:x().optional()}),tu=Qe.extend({method:Z("notifications/initialized"),params:Xe.optional()});var vs=$e.extend({method:Z("ping"),params:Ke.optional()}),hw=E({progress:re(),total:ge(re()),message:ge(x())}),gw=E({...Xe.shape,...hw.shape,progressToken:am}),bs=Qe.extend({method:Z("notifications/progress"),params:gw}),_w=Ke.extend({cursor:cm.optional()}),Wn=$e.extend({params:_w.optional()}),Yn=Se.extend({nextCursor:cm.optional()}),yw=De(["working","input_required","completed","failed","cancelled"]),Xn=E({taskId:x(),status:yw,ttl:de([re(),Xf()]),createdAt:x(),lastUpdatedAt:x(),pollInterval:ge(re()),statusMessage:ge(x())}),Wr=Se.extend({task:Xn}),vw=Xe.merge(Xn),Qn=Qe.extend({method:Z("notifications/tasks/status"),params:vw}),ws=$e.extend({method:Z("tasks/get"),params:Ke.extend({taskId:x()})}),xs=Se.merge(Xn),ks=$e.extend({method:Z("tasks/result"),params:Ke.extend({taskId:x()})}),mC=Se.loose(),$s=Wn.extend({method:Z("tasks/list")}),Ss=Yn.extend({tasks:W(Xn)}),Ts=$e.extend({method:Z("tasks/cancel"),params:Ke.extend({taskId:x()})}),mm=Se.merge(Xn),hm=E({uri:x(),mimeType:ge(x()),_meta:ue(x(),he()).optional()}),gm=hm.extend({text:x()}),ru=x().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),_m=hm.extend({blob:ru}),eo=De(["user","assistant"]),Yr=E({audience:W(eo).optional(),priority:re().min(0).max(1).optional(),lastModified:Hn.datetime({offset:!0}).optional()}),ym=E({...Jr.shape,...Gn.shape,uri:x(),description:ge(x()),mimeType:ge(x()),size:ge(re()),annotations:Yr.optional(),_meta:ge(Ze({}))}),bw=E({...Jr.shape,...Gn.shape,uriTemplate:x(),description:ge(x()),mimeType:ge(x()),annotations:Yr.optional(),_meta:ge(Ze({}))}),zs=Wn.extend({method:Z("resources/list")}),ww=Yn.extend({resources:W(ym)}),Ps=Wn.extend({method:Z("resources/templates/list")}),xw=Yn.extend({resourceTemplates:W(bw)}),nu=Ke.extend({uri:x()}),kw=nu,Is=$e.extend({method:Z("resources/read"),params:kw}),$w=Se.extend({contents:W(de([gm,_m]))}),Sw=Qe.extend({method:Z("notifications/resources/list_changed"),params:Xe.optional()}),Tw=nu,zw=$e.extend({method:Z("resources/subscribe"),params:Tw}),Pw=nu,Iw=$e.extend({method:Z("resources/unsubscribe"),params:Pw}),Ew=Xe.extend({uri:x()}),Rw=Qe.extend({method:Z("notifications/resources/updated"),params:Ew}),Cw=E({name:x(),description:ge(x()),required:ge(xe())}),Zw=E({...Jr.shape,...Gn.shape,description:ge(x()),arguments:ge(W(Cw)),_meta:ge(Ze({}))}),Es=Wn.extend({method:Z("prompts/list")}),Ow=Yn.extend({prompts:W(Zw)}),jw=Ke.extend({name:x(),arguments:ue(x(),x()).optional()}),Rs=$e.extend({method:Z("prompts/get"),params:jw}),ou=E({type:Z("text"),text:x(),annotations:Yr.optional(),_meta:ue(x(),he()).optional()}),su=E({type:Z("image"),data:ru,mimeType:x(),annotations:Yr.optional(),_meta:ue(x(),he()).optional()}),iu=E({type:Z("audio"),data:ru,mimeType:x(),annotations:Yr.optional(),_meta:ue(x(),he()).optional()}),Aw=E({type:Z("tool_use"),name:x(),id:x(),input:ue(x(),he()),_meta:ue(x(),he()).optional()}),Nw=E({type:Z("resource"),resource:de([gm,_m]),annotations:Yr.optional(),_meta:ue(x(),he()).optional()}),Mw=ym.extend({type:Z("resource_link")}),au=de([ou,su,iu,Mw,Nw]),Dw=E({role:eo,content:au}),qw=Se.extend({description:x().optional(),messages:W(Dw)}),Lw=Qe.extend({method:Z("notifications/prompts/list_changed"),params:Xe.optional()}),Uw=E({title:x().optional(),readOnlyHint:xe().optional(),destructiveHint:xe().optional(),idempotentHint:xe().optional(),openWorldHint:xe().optional()}),Vw=E({taskSupport:De(["required","optional","forbidden"]).optional()}),vm=E({...Jr.shape,...Gn.shape,description:x().optional(),inputSchema:E({type:Z("object"),properties:ue(x(),we).optional(),required:W(x()).optional()}).catchall(he()),outputSchema:E({type:Z("object"),properties:ue(x(),we).optional(),required:W(x()).optional()}).catchall(he()).optional(),annotations:Uw.optional(),execution:Vw.optional(),_meta:ue(x(),he()).optional()}),Cs=Wn.extend({method:Z("tools/list")}),Fw=Yn.extend({tools:W(vm)}),Zs=Se.extend({content:W(au).default([]),structuredContent:ue(x(),he()).optional(),isError:xe().optional()}),hC=Zs.or(Se.extend({toolResult:he()})),Hw=Jn.extend({name:x(),arguments:ue(x(),he()).optional()}),Xr=$e.extend({method:Z("tools/call"),params:Hw}),Bw=Qe.extend({method:Z("notifications/tools/list_changed"),params:Xe.optional()}),gC=E({autoRefresh:xe().default(!0),debounceMs:re().int().nonnegative().default(300)}),to=De(["debug","info","notice","warning","error","critical","alert","emergency"]),Jw=Ke.extend({level:to}),cu=$e.extend({method:Z("logging/setLevel"),params:Jw}),Kw=Xe.extend({level:to,logger:x().optional(),data:he()}),Gw=Qe.extend({method:Z("notifications/message"),params:Kw}),Ww=E({name:x().optional()}),Yw=E({hints:W(Ww).optional(),costPriority:re().min(0).max(1).optional(),speedPriority:re().min(0).max(1).optional(),intelligencePriority:re().min(0).max(1).optional()}),Xw=E({mode:De(["auto","required","none"]).optional()}),Qw=E({type:Z("tool_result"),toolUseId:x().describe("The unique identifier for the corresponding tool call."),content:W(au).default([]),structuredContent:E({}).loose().optional(),isError:xe().optional(),_meta:ue(x(),he()).optional()}),e0=Jc("type",[ou,su,iu]),fs=Jc("type",[ou,su,iu,Aw,Qw]),t0=E({role:eo,content:de([fs,W(fs)]),_meta:ue(x(),he()).optional()}),r0=Jn.extend({messages:W(t0),modelPreferences:Yw.optional(),systemPrompt:x().optional(),includeContext:De(["none","thisServer","allServers"]).optional(),temperature:re().optional(),maxTokens:re().int(),stopSequences:W(x()).optional(),metadata:we.optional(),tools:W(vm).optional(),toolChoice:Xw.optional()}),n0=$e.extend({method:Z("sampling/createMessage"),params:r0}),ro=Se.extend({model:x(),stopReason:ge(De(["endTurn","stopSequence","maxTokens"]).or(x())),role:eo,content:e0}),uu=Se.extend({model:x(),stopReason:ge(De(["endTurn","stopSequence","maxTokens","toolUse"]).or(x())),role:eo,content:de([fs,W(fs)])}),o0=E({type:Z("boolean"),title:x().optional(),description:x().optional(),default:xe().optional()}),s0=E({type:Z("string"),title:x().optional(),description:x().optional(),minLength:re().optional(),maxLength:re().optional(),format:De(["email","uri","date","date-time"]).optional(),default:x().optional()}),i0=E({type:De(["number","integer"]),title:x().optional(),description:x().optional(),minimum:re().optional(),maximum:re().optional(),default:re().optional()}),a0=E({type:Z("string"),title:x().optional(),description:x().optional(),enum:W(x()),default:x().optional()}),c0=E({type:Z("string"),title:x().optional(),description:x().optional(),oneOf:W(E({const:x(),title:x()})),default:x().optional()}),u0=E({type:Z("string"),title:x().optional(),description:x().optional(),enum:W(x()),enumNames:W(x()).optional(),default:x().optional()}),l0=de([a0,c0]),d0=E({type:Z("array"),title:x().optional(),description:x().optional(),minItems:re().optional(),maxItems:re().optional(),items:E({type:Z("string"),enum:W(x())}),default:W(x()).optional()}),p0=E({type:Z("array"),title:x().optional(),description:x().optional(),minItems:re().optional(),maxItems:re().optional(),items:E({anyOf:W(E({const:x(),title:x()}))}),default:W(x()).optional()}),f0=de([d0,p0]),m0=de([u0,l0,f0]),h0=de([m0,o0,s0,i0]),g0=Jn.extend({mode:Z("form").optional(),message:x(),requestedSchema:E({type:Z("object"),properties:ue(x(),h0),required:W(x()).optional()})}),_0=Jn.extend({mode:Z("url"),message:x(),elicitationId:x(),url:x().url()}),y0=de([g0,_0]),v0=$e.extend({method:Z("elicitation/create"),params:y0}),b0=Xe.extend({elicitationId:x()}),w0=Qe.extend({method:Z("notifications/elicitation/complete"),params:b0}),Qr=Se.extend({action:De(["accept","decline","cancel"]),content:Kc(t=>t===null?void 0:t,ue(x(),de([x(),re(),xe(),W(x())])).optional())}),x0=E({type:Z("ref/resource"),uri:x()});var k0=E({type:Z("ref/prompt"),name:x()}),$0=Ke.extend({ref:de([k0,x0]),argument:E({name:x(),value:x()}),context:E({arguments:ue(x(),x()).optional()}).optional()}),Os=$e.extend({method:Z("completion/complete"),params:$0});function bm(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function wm(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var S0=Se.extend({completion:Ze({values:W(x()).max(100),total:ge(re().int()),hasMore:ge(xe())})}),T0=E({uri:x().startsWith("file://"),name:x().optional(),_meta:ue(x(),he()).optional()}),z0=$e.extend({method:Z("roots/list"),params:Ke.optional()}),lu=Se.extend({roots:W(T0)}),P0=Qe.extend({method:Z("notifications/roots/list_changed"),params:Xe.optional()}),_C=de([vs,ys,Os,cu,Rs,Es,zs,Ps,Is,zw,Iw,Xr,Cs,ws,ks,$s,Ts]),yC=de([_s,bs,tu,P0,Qn]),vC=de([gs,ro,uu,Qr,lu,xs,Ss,Wr]),bC=de([vs,n0,v0,z0,ws,ks,$s,Ts]),wC=de([_s,bs,Gw,Rw,Sw,Bw,Lw,Qn,w0]),xC=de([gs,mw,S0,qw,Ow,ww,xw,$w,Zs,Fw,xs,Ss,Wr]),C=class t 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===A.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Gc(o.elicitations,r)}return new t(e,r,n)}},Gc=class extends C{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(A.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};d();function Vt(t){return t==="completed"||t==="failed"||t==="cancelled"}d();d();d();var km=Symbol("Let zodToJsonSchema decide on which parser to use");var xm={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"},$m=t=>typeof t=="string"?{...xm,name:t}:{...xm,...t};d();var Sm=t=>{let e=$m(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,o])=>[o._def,{def:o._def,path:[...e.basePath,e.definitionPath,n],jsonSchema:void 0}]))}};d();function du(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function Y(t,e,r,n,o){t[e]=r,du(t,e,n,o)}d();var js=(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("/")};d();d();d();function _e(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?js(e,t.currentPath):e.join("/")}}d();function Tm(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==U.ZodAny&&(r.items=D(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&Y(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&Y(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(Y(r,"minItems",t.exactLength.value,t.exactLength.message,e),Y(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}d();function zm(t,e){let r={type:"integer",format:"int64"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"min":e.target==="jsonSchema7"?n.inclusive?Y(r,"minimum",n.value,n.message,e):Y(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),Y(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?Y(r,"maximum",n.value,n.message,e):Y(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),Y(r,"maximum",n.value,n.message,e));break;case"multipleOf":Y(r,"multipleOf",n.value,n.message,e);break}return r}d();function Pm(){return{type:"boolean"}}d();function As(t,e){return D(t.type._def,e)}d();var Im=(t,e)=>D(t.innerType._def,e);d();function pu(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>pu(t,e,o))};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 I0(t,e)}}var I0=(t,e)=>{let r={type:"integer",format:"unix-time"};if(e.target==="openApi3")return r;for(let n of t.checks)switch(n.kind){case"min":Y(r,"minimum",n.value,n.message,e);break;case"max":Y(r,"maximum",n.value,n.message,e);break}return r};d();function Em(t,e){return{...D(t.innerType._def,e),default:t.defaultValue()}}d();function Rm(t,e){return e.effectStrategy==="input"?D(t.schema._def,e):_e(e)}d();function Cm(t){return{type:"string",enum:Array.from(t.values)}}d();var E0=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function Zm(t,e){let r=[D(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),D(t.right._def,{...e,currentPath:[...e.currentPath,"allOf","1"]})].filter(s=>!!s),n=e.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,o=[];return r.forEach(s=>{if(E0(s))o.push(...s.allOf),s.unevaluatedProperties===void 0&&(n=void 0);else{let i=s;if("additionalProperties"in s&&s.additionalProperties===!1){let{additionalProperties:a,...c}=s;i=c}else n=void 0;o.push(i)}}),o.length?{allOf:o,...n}:void 0}d();function Om(t,e){let 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}}d();d();d();var fu,ct={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:()=>(fu===void 0&&(fu=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),fu),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 Ns(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":Y(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":Y(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":ut(r,"email",n.message,e);break;case"format:idn-email":ut(r,"idn-email",n.message,e);break;case"pattern:zod":Oe(r,ct.email,n.message,e);break}break;case"url":ut(r,"uri",n.message,e);break;case"uuid":ut(r,"uuid",n.message,e);break;case"regex":Oe(r,n.regex,n.message,e);break;case"cuid":Oe(r,ct.cuid,n.message,e);break;case"cuid2":Oe(r,ct.cuid2,n.message,e);break;case"startsWith":Oe(r,RegExp(`^${mu(n.value,e)}`),n.message,e);break;case"endsWith":Oe(r,RegExp(`${mu(n.value,e)}$`),n.message,e);break;case"datetime":ut(r,"date-time",n.message,e);break;case"date":ut(r,"date",n.message,e);break;case"time":ut(r,"time",n.message,e);break;case"duration":ut(r,"duration",n.message,e);break;case"length":Y(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),Y(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Oe(r,RegExp(mu(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&ut(r,"ipv4",n.message,e),n.version!=="v4"&&ut(r,"ipv6",n.message,e);break}case"base64url":Oe(r,ct.base64url,n.message,e);break;case"jwt":Oe(r,ct.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Oe(r,ct.ipv4Cidr,n.message,e),n.version!=="v4"&&Oe(r,ct.ipv6Cidr,n.message,e);break}case"emoji":Oe(r,ct.emoji(),n.message,e);break;case"ulid":{Oe(r,ct.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{ut(r,"binary",n.message,e);break}case"contentEncoding:base64":{Y(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Oe(r,ct.base64,n.message,e);break}}break}case"nanoid":Oe(r,ct.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function mu(t,e){return e.patternStrategy==="escape"?C0(t):t}var R0=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function C0(t){let e="";for(let r=0;r<t.length;r++)R0.has(t[r])||(e+="\\"),e+=t[r];return e}function ut(t,e,r,n){t.format||t.anyOf?.some(o=>o.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}}})):Y(t,"format",e,r,n)}function Oe(t,e,r,n){t.pattern||t.allOf?.some(o=>o.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:jm(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):Y(t,"pattern",jm(e,n),r,n)}function jm(t,e){if(!e.applyRegexFlags||!t.flags)return t.source;let r={i:t.flags.includes("i"),m:t.flags.includes("m"),s:t.flags.includes("s")},n=r.i?t.source.toLowerCase():t.source,o="",s=!1,i=!1,a=!1;for(let c=0;c<n.length;c++){if(s){o+=n[c],s=!1;continue}if(r.i){if(i){if(n[c].match(/[a-z]/)){a?(o+=n[c],o+=`${n[c-2]}-${n[c]}`.toUpperCase(),a=!1):n[c+1]==="-"&&n[c+2]?.match(/[a-z]/)?(o+=n[c],a=!0):o+=`${n[c]}${n[c].toUpperCase()}`;continue}}else if(n[c].match(/[a-z]/)){o+=`[${n[c]}${n[c].toUpperCase()}]`;continue}}if(r.m){if(n[c]==="^"){o+=`(^|(?<=[\r
|
|
37
37
|
]))`;continue}else if(n[c]==="$"){o+=`($|(?=[\r
|
|
38
38
|
]))`;continue}}if(r.s&&n[c]==="."){o+=i?`${n[c]}\r
|
|
39
39
|
`:`[${n[c]}\r
|
|
40
|
-
]`;continue}o+=n[c],n[c]==="\\"?s=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(o)}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 o}function Ms(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===U.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,o)=>({...n,[o]:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",o]})??_e(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===U.ZodString&&t.keyType._def.checks?.length){let{type:n,...o}=Ns(t.keyType._def,e);return{...r,propertyNames:o}}else{if(t.keyType?._def.typeName===U.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===U.ZodBranded&&t.keyType._def.type._def.typeName===U.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...o}=As(t.keyType._def,e);return{...r,propertyNames:o}}}return r}function jm(t,e){if(e.mapStrategy==="record")return Ms(t,e);let r=D(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||_e(e),n=D(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||_e(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}d();function Am(t){let e=t.values,n=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),o=Array.from(new Set(n.map(s=>typeof s)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:n}}d();function Nm(t){return t.target==="openAi"?void 0:{not:_e({...t,currentPath:[...t.currentPath,"not"]})}}d();function Mm(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}d();d();var no={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function qm(t,e){if(e.target==="openApi3")return Dm(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in no&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,s)=>{let i=no[s._def.typeName];return i&&!o.includes(i)?[...o,i]:o},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((o,s)=>{let i=typeof s._def.value;switch(i){case"string":case"number":case"boolean":return[...o,i];case"bigint":return[...o,"integer"];case"object":if(s._def.value===null)return[...o,"null"];default:return o}},[]);if(n.length===r.length){let o=n.filter((s,i,a)=>a.indexOf(s)===i);return{type:o.length>1?o:o[0],enum:r.reduce((s,i)=>s.includes(i._def.value)?s:[...s,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,o)=>[...n,...o._def.values.filter(s=>!n.includes(s))],[])};return Dm(t,e)}var Dm=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,o)=>D(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${o}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function Lm(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:no[t.innerType._def.typeName],nullable:!0}:{type:[no[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=D(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=D(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}d();function Um(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",du(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?Y(r,"minimum",n.value,n.message,e):Y(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),Y(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?Y(r,"maximum",n.value,n.message,e):Y(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),Y(r,"maximum",n.value,n.message,e));break;case"multipleOf":Y(r,"multipleOf",n.value,n.message,e);break}return r}d();function Vm(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},o=[],s=t.shape();for(let a in s){let c=s[a];if(c===void 0||c._def===void 0)continue;let u=Z0(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=D(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||o.push(a))}o.length&&(n.required=o);let i=C0(t,e);return i!==void 0&&(n.additionalProperties=i),n}function C0(t,e){if(t.catchall._def.typeName!=="ZodNever")return D(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 Z0(t){try{return t.isOptional()}catch{return!0}}d();var Fm=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return D(t.innerType._def,e);let r=D(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:_e(e)},r]}:_e(e)};d();var Hm=(t,e)=>{if(e.pipeStrategy==="input")return D(t.in._def,e);if(e.pipeStrategy==="output")return D(t.out._def,e);let r=D(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=D(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}};d();function Bm(t,e){return D(t.type._def,e)}d();function Jm(t,e){let n={type:"array",uniqueItems:!0,items:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&Y(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&Y(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}d();function Km(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>D(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:D(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>D(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}d();function Gm(t){return{not:_e(t)}}d();function Wm(t){return _e(t)}d();var Ym=(t,e)=>D(t.innerType._def,e);var Xm=(t,e,r)=>{switch(e){case U.ZodString:return Ns(t,r);case U.ZodNumber:return Um(t,r);case U.ZodObject:return Vm(t,r);case U.ZodBigInt:return Tm(t,r);case U.ZodBoolean:return zm();case U.ZodDate:return pu(t,r);case U.ZodUndefined:return Gm(r);case U.ZodNull:return Mm(r);case U.ZodArray:return Sm(t,r);case U.ZodUnion:case U.ZodDiscriminatedUnion:return qm(t,r);case U.ZodIntersection:return Cm(t,r);case U.ZodTuple:return Km(t,r);case U.ZodRecord:return Ms(t,r);case U.ZodLiteral:return Zm(t,r);case U.ZodEnum:return Rm(t);case U.ZodNativeEnum:return Am(t);case U.ZodNullable:return Lm(t,r);case U.ZodOptional:return Fm(t,r);case U.ZodMap:return jm(t,r);case U.ZodSet:return Jm(t,r);case U.ZodLazy:return()=>t.getter()._def;case U.ZodPromise:return Bm(t,r);case U.ZodNaN:case U.ZodNever:return Nm(r);case U.ZodEffects:return Em(t,r);case U.ZodAny:return _e(r);case U.ZodUnknown:return Wm(r);case U.ZodDefault:return Im(t,r);case U.ZodBranded:return As(t,r);case U.ZodReadonly:return Ym(t,r);case U.ZodCatch:return Pm(t,r);case U.ZodPipeline:return Hm(t,r);case U.ZodFunction:case U.ZodVoid:case U.ZodSymbol:return;default:return(n=>{})(e)}};function D(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==xm)return a}if(n&&!r){let a=O0(n,e);if(a!==void 0)return a}let o={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,o);let s=Xm(t,t.typeName,e),i=typeof s=="function"?D(s(),e):s;if(i&&j0(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return o.jsonSchema=i,a}return o.jsonSchema=i,i}var O0=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:js(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`),_e(e)):e.$refStrategy==="seen"?_e(e):void 0}},j0=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);d();d();var hu=(t,e)=>{let r=km(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:D(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??_e(r)}),{}):void 0,o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=D(t._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??_e(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(s.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("/")}}));let a=o===void 0?n?{...s,[r.definitionPath]:n}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:{...n,[o]:s}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function A0(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function gu(t,e){return Ye(t)?Dc(t,{target:A0(e?.target),io:e?.pipeStrategy??"input"}):hu(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function _u(t){let r=qt(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=ls(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function yu(t,e){let r=Dt(t,e);if(!r.success)throw r.error;return r.data}var N0=6e4,Ds=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(_s,r=>{this._oncancel(r)}),this.setNotificationHandler(bs,r=>{this._onprogress(r)}),this.setRequestHandler(vs,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ws,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new C(A.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler($s,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let p=c,m=new C(p.error.code,p.error.message,p.error.data);l(m)}else{let p=a.type==="response"?"Response":"Error";this._onerror(new Error(`${p} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new C(A.InvalidParams,`Task not found: ${s}`);if(!Vt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Vt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Lt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(ks,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new C(A.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ts,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new C(A.InvalidParams,`Task not found: ${r.params.taskId}`);if(Vt(o.status))throw new C(A.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new C(A.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof C?o:new C(A.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),C.fromError(A.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Pt(s)||Gr(s)?this._onresponse(s):Ut(s)?this._onrequest(s,i):dm(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=C.fromError(A.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let 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){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[Lt]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:A.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(p=>this._onerror(new Error(`Failed to enqueue error response: ${p}`))):o?.send(l).catch(p=>this._onerror(new Error(`Failed to send an error response: ${p}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=cm(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let p={relatedRequestId:e.id};s&&(p.relatedTask={taskId:s}),await this.notification(l,p)},sendRequest:async(l,p,m)=>{if(i.signal.aborted)throw new C(A.ConnectionClosed,"Request was cancelled");let h={...m,relatedRequestId:e.id};s&&!h.relatedTask&&(h.relatedTask={taskId:s});let f=h.relatedTask?.taskId??s;return f&&c&&await c.updateTaskStatus(f,"input_required"),await this.request(l,p,h)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let p={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:p,timestamp:Date.now()},o?.sessionId):await o?.send(p)},async l=>{if(i.signal.aborted)return;let p={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:A.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:p,timestamp:Date.now()},o?.sessionId):await o?.send(p)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Pt(e))n(e);else{let i=new C(e.error.code,e.error.message,e.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===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 s=!1;if(Pt(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),Pt(e))o(e);else{let i=C.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof C?i:new C(A.InternalError,String(i))}}return}let s;try{let i=await this.request(e,Wr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new C(A.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Vt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new C(A.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new C(A.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof C?i:new C(A.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let p=S=>{l(S)};if(!this._transport){p(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(S){p(S);return}n?.signal?.throwIfAborted();let m=this._requestMessageId++,h={...e,jsonrpc:"2.0",id:m};n?.onprogress&&(this._progressHandlers.set(m,n.onprogress),h.params={...e.params,_meta:{...e.params?._meta||{},progressToken:m}}),a&&(h.params={...h.params,task:a}),c&&(h.params={...h.params,_meta:{...h.params?._meta||{},[Lt]:c}});let f=S=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(S)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(R=>this._onerror(new Error(`Failed to send cancellation: ${R}`)));let T=S instanceof C?S:new C(A.RequestTimeout,String(S));l(T)};this._responseHandlers.set(m,S=>{if(!n?.signal?.aborted){if(S instanceof Error)return l(S);try{let T=Dt(r,S.result);T.success?u(T.data):l(T.error)}catch(T){l(T)}}}),n?.signal?.addEventListener("abort",()=>{f(n?.signal?.reason)});let _=n?.timeout??N0,w=()=>f(C.fromError(A.RequestTimeout,"Request timed out",{timeout:_}));this._setupTimeout(m,_,n?.maxTotalTimeout,w,n?.resetTimeoutOnProgress??!1);let k=c?.taskId;if(k){let S=T=>{let R=this._responseHandlers.get(m);R?R(T):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,S),this._enqueueTaskMessage(k,{type:"request",message:h,timestamp:Date.now()}).catch(T=>{this._cleanupTimeout(m),l(T)})}else this._transport.send(h,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(S=>{this._cleanupTimeout(m),l(S)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},xs,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},Ss,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},fm,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Lt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Lt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Lt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=_u(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=yu(e,o);return Promise.resolve(r(i,s))})}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){let n=_u(e);this._notificationHandlers.set(n,o=>{let s=yu(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let 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");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&Ut(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new C(A.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new C(A.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new C(A.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new C(A.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=Qn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Vt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new C(A.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Vt(a.status))throw new C(A.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=Qn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Vt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Qm(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function eh(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];Qm(i)&&Qm(s)?r[o]={...i,...s}:r[o]=s}return r}d();var q_=Me(nd(),1),L_=Me(D_(),1);function Pz(){let t=new q_.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,L_.default)(t),t}var wi=class{constructor(e){this._ajv=e??Pz()}getValidator(e){let 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)}}};d();var xi=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(m=>m.type==="tool_use").map(m=>m.id)),p=new Set(s.filter(m=>m.type==="tool_result").map(m=>m.toolUseId));if(l.size!==p.size||![...l].every(m=>p.has(m)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},ro,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:s},Qr,r)}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)}};d();function U_(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;default:break}}function V_(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;default:break}}var $i=class extends Ds{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(to.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new wi,this.setRequestHandler(ys,n=>this._oninitialize(n)),this.setNotificationHandler(tu,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(cu,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=to.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new xi(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=eh(this._capabilities,e)}setRequestHandler(e,r){let o=qt(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(Ye(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Dt(Xr,c);if(!l.success){let f=l.error instanceof Error?l.error.message:String(l.error);throw new C(A.InvalidParams,`Invalid tools/call request: ${f}`)}let{params:p}=l.data,m=await Promise.resolve(r(c,u));if(p.task){let f=Dt(Wr,m);if(!f.success){let _=f.error instanceof Error?f.error.message:String(f.error);throw new C(A.InvalidParams,`Invalid task creation result: ${_}`)}return f.data}let h=Dt(Zs,m);if(!h.success){let f=h.error instanceof Error?h.error.message:String(h.error);throw new C(A.InvalidParams,`Invalid tools/call result: ${f}`)}return h.data};return super.setRequestHandler(e,a)}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;case"ping":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;case"notifications/cancelled":break;case"notifications/progress":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;case"ping":case"initialize":break}}assertTaskCapability(e){V_(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&U_(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Kr.includes(r)?r:Wc,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"},gs)}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){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.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){let u=new Set(a.filter(p=>p.type==="tool_use").map(p=>p.id)),l=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(u.size!==l.size||![...u].every(p=>l.has(p)))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},uu,r):this.request({method:"sampling/createMessage",params:e},ro,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.");let o=e;return this.request({method:"elicitation/create",params:o},Qr,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Qr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new C(A.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof C?i:new C(A.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}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},lu,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"})}};d();var H_=Symbol.for("mcp.completable");function dd(t){return!!t&&typeof t=="object"&&H_ in t}function B_(t){return t[H_]?.complete}var F_;(function(t){t.Completable="McpCompletable"})(F_||(F_={}));d();d();var Iz=/^[A-Za-z0-9._-]{1,128}$/;function Ez(t){let 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"),!Iz.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,s)=>s.indexOf(n)===o);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 Rz(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let 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 pd(t){let e=Ez(t);return Rz(t,e.warnings),e.isValid}d();var ki=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let o={taskSupport:"required",...r.execution};if(o.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,o,r._meta,n)}};var yn=class{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 $i(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new ki(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Xt(Cs)),this.server.assertCanSetRequestHandler(Xt(Xr)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Cs,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let o=Br(r.inputSchema);return o?gu(o,{strictUnions:!0,pipeStrategy:"input"}):Cz})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=Br(r.outputSchema);o&&(n.outputSchema=gu(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Xr,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new C(A.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new C(A.InvalidParams,`Tool ${e.params.name} disabled`);let o=!!e.params.task,s=n.execution?.taskSupport,i="createTask"in n.handler;if((s==="required"||s==="optional")&&!i)throw new C(A.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if(s==="required"&&!o)throw new C(A.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(s==="optional"&&!o&&i)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return o||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof C&&n.code===A.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;let s=Br(e.inputSchema)??e.inputSchema,i=await cs(s,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=us(a);throw new C(A.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 C(A.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=Br(e.outputSchema),s=await cs(o,r.structuredContent);if(!s.success){let i="error"in s?s.error:"Unknown error",a=us(i);throw new C(A.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let o=e.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let i={...n,taskStore:n.taskStore};if(e.inputSchema){let a=o;return await Promise.resolve(a.createTask(r,i))}else{let a=o;return await Promise.resolve(a.createTask(i))}}if(e.inputSchema){let i=o;return await Promise.resolve(i(r,n))}else{let i=o;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.");let o=await this.validateToolInput(e,r.params.arguments,r.params.name),s=e.handler,i={...n,taskStore:n.taskStore},a=o?await Promise.resolve(s.createTask(o,i)):await Promise.resolve(s.createTask(i)),c=a.task.taskId,u=a.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(m=>setTimeout(m,l));let p=await n.taskStore.getTask(c);if(!p)throw new C(A.InternalError,`Task ${c} not found during polling`);u=p}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Xt(Os)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Os,async e=>{switch(e.params.ref.type){case"ref/prompt":return vm(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return bm(e),this.handleResourceCompletion(e,e.params.ref);default:throw new C(A.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new C(A.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new C(A.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Oo;let s=qt(n.argsSchema)?.[e.params.argument.name];if(!dd(s))return Oo;let i=B_(s);if(!i)return Oo;let a=await i(e.params.argument.value,e.params.context);return K_(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Oo;throw new C(A.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(e.params.argument.name);if(!o)return Oo;let s=await o(e.params.argument.value,e.params.context);return K_(s)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Xt(zs)),this.server.assertCanSetRequestHandler(Xt(Ps)),this.server.assertCanSetRequestHandler(Xt(Is)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(zs,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([s,i])=>i.enabled).map(([s,i])=>({uri:s,name:i.name,...i.metadata})),o=[];for(let s of Object.values(this._registeredResourceTemplates)){if(!s.resourceTemplate.listCallback)continue;let i=await s.resourceTemplate.listCallback(r);for(let a of i.resources)o.push({...s.metadata,...a})}return{resources:[...n,...o]}}),this.server.setRequestHandler(Ps,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Is,async(e,r)=>{let n=new URL(e.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new C(A.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let s of Object.values(this._registeredResourceTemplates)){let i=s.resourceTemplate.uriTemplate.match(n.toString());if(i)return s.readCallback(n,i,r)}throw new C(A.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Xt(Es)),this.server.assertCanSetRequestHandler(Xt(Rs)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Es,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?Zz(r.argsSchema):void 0}))})),this.server.setRequestHandler(Rs,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new C(A.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new C(A.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let o=Br(n.argsSchema),s=await cs(o,e.params.arguments);if(!s.success){let c="error"in s?s.error:"Unknown error",u=us(c);throw new C(A.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}let i=s.data,a=n.callback;return await Promise.resolve(a(i,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let s=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,r,n,o,s){let i={name:e,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,o,s){let i={resourceTemplate:n,title:r,metadata:o,readCallback:s,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;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,o,s){let i={title:r,description:n,argsSchema:o===void 0?void 0:dr(o),callback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=dr(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,o&&Object.values(o).some(c=>{let u=c instanceof Ud?c._def?.innerType:c;return dd(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,o,s,i,a,c,u){pd(e);let l={title:r,description:n,inputSchema:J_(o),outputSchema:J_(s),annotations:i,execution:a,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:p=>{typeof p.name<"u"&&p.name!==e&&(typeof p.name=="string"&&pd(p.name),delete this._registeredTools[e],p.name&&(this._registeredTools[p.name]=l)),typeof p.title<"u"&&(l.title=p.title),typeof p.description<"u"&&(l.description=p.description),typeof p.paramsSchema<"u"&&(l.inputSchema=dr(p.paramsSchema)),typeof p.outputSchema<"u"&&(l.outputSchema=dr(p.outputSchema)),typeof p.callback<"u"&&(l.handler=p.callback),typeof p.annotations<"u"&&(l.annotations=p.annotations),typeof p._meta<"u"&&(l._meta=p._meta),typeof p.enabled<"u"&&(l.enabled=p.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,o,s,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(fd(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!fd(r[0])&&(i=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(u=>typeof u=="object"&&u!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);i=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,n,o,s,i,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:o,description:s,inputSchema:i,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,o,s,i,a,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 o;r.length>1&&(o=r.shift());let s=r[0],i=this._createRegisteredPrompt(e,void 0,n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:o,description:s,argsSchema:i}=r,a=this._createRegisteredPrompt(e,o,s,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var Cz={type:"object",properties:{}};function G_(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function W_(t){return"_def"in t||"_zod"in t||G_(t)}function fd(t){return typeof t!="object"||t===null||W_(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(G_)}function J_(t){if(t){if(fd(t))return dr(t);if(!W_(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function Zz(t){let e=qt(t);return e?Object.entries(e).map(([r,n])=>{let o=jf(n),s=Af(n);return{name:r,description:o,required:!s}}):[]}function Xt(t){let r=qt(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=ls(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function K_(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Oo={completion:{values:[],hasMore:!1}};var Nd=Me(Tn(),1),Md=Me(or(),1);d();var wy=Me(Tn(),1),xy=Me(or(),1);import{existsSync as nI}from"fs";import{join as oI,resolve as sI}from"path";var St=(0,xy.createMcpLogger)({name:"@toolcairn/mcp-server:post-auth-init"});async function iI(){let t=await Tt();return t?new Uo({baseUrl:wy.config.TOOLPILOT_API_URL,apiKey:t.client_id,accessToken:t.access_token}):null}async function zn(t={}){let e=t.cwd??process.cwd(),r=t.agent??"claude",n=await iI();if(!n)return St.warn("runPostAuthInit called without valid credentials \u2014 skipping"),{cwd:e,roots_discovered:[],used_fallback:!1,projects:[],unknown_tools_total:0,first_turn_directive:""};let{roots:o,usedFallback:s}=await pp(e);St.info({cwd:e,roots:o.length,usedFallback:s},"Roots discovered post-auth");let i=[];for(let l of o){if(t.onlyMissingConfig){let p=oI(l,".toolcairn","config.json");if(nI(p)){St.debug({projectRoot:l},"Root already has config.json \u2014 skipping");continue}}try{let p=await fp({projectRoot:l,agent:r,batchResolve:m=>n.batchResolve(m),reason:t.onlyMissingConfig?"Startup auto-init (config missing)":"Post-auth auto-init"});i.push({project_root:l,status:"initialized",config_path:p.config_path,audit_log_path:p.audit_log_path,scan_summary:p.scan_summary,setup_steps:p.setup_steps,unknown_tools:p.unknown_tools,bootstrapped:p.bootstrapped,migrated:p.migrated})}catch(p){let m=p instanceof Error?p.message:String(p);St.error({err:p,projectRoot:l},"autoInitProject failed for root"),i.push({project_root:l,status:"failed",error:m})}}if(!t.disableAutoSubmit)for(let l of i){if(l.status!=="initialized")continue;let p=(l.unknown_tools??[]).filter(m=>!!m.github_url);if(p.length!==0)try{let m=await aI(n,p);l.auto_submitted=m;let h=[...m.staged,...m.already_staged,...m.already_indexed];h.length>0&&await cI(l.project_root,h).catch(f=>St.warn({err:f,projectRoot:l.project_root},"Failed to flip suggested flags after auto-submit")),St.info({projectRoot:l.project_root,staged:m.staged.length,already_staged:m.already_staged.length,already_indexed:m.already_indexed.length,rejected:m.rejected.length},"Auto-push to suggest_graph_update complete")}catch(m){St.warn({err:m,projectRoot:l.project_root},"Auto-push to suggest_graph_update failed \u2014 agent directive remains as fallback")}}let a=sI(e);if(!o.includes(a))try{let l=await mp(a,r);St.info({cwd:a,file:l.file,applied:l.applied,reason:l.reason},"Workspace-level instruction-file pass complete")}catch(l){St.debug({err:l,cwd:a},"Workspace-level instruction merge skipped (best-effort)")}let c=i.reduce((l,p)=>l+(p.unknown_tools??[]).filter(m=>!m.suggested).length,0),u=uI(i,c);return{cwd:e,roots_discovered:o,used_fallback:s,projects:i,unknown_tools_total:c,first_turn_directive:u}}async function aI(t,e){let n=(await t.suggestGraphUpdate({suggestion_type:"new_tool",data:{tools:e.map(a=>({tool_name:a.name,github_url:a.github_url,ecosystem:a.ecosystem}))},confidence:.5})).content?.[0],o={staged:[],already_staged:[],already_indexed:[],rejected:[]};if(!n||n.type!=="text")return o;let s;try{s=JSON.parse(n.text??"{}")}catch{return o}let i=s.data?.results??[];for(let a of i){let c=a.tool_name??"";c&&(a.already_indexed?o.already_indexed.push(c):a.already_staged?o.already_staged.push(c):a.staged===!0?o.staged.push(c):o.rejected.push({tool_name:c,reason:a.reason??"unknown"}))}return o}async function cI(t,e){let r=new Set(e),n=new Date().toISOString(),o=0;await dp(t,s=>{let i=s.tools.unknown_in_graph??[];for(let a of i)r.has(a.name)&&!a.suggested&&(a.suggested=!0,a.suggested_at=n,o++);s.tools.unknown_in_graph=i},{action:"mark_suggestions_sent",tool:`__auto_submit__:${e.length}`,reason:"Server auto-pushed unknown_in_graph tools to suggest_graph_update",metadata:{tool_names:e,tool_count:e.length}}),o===0&&St.debug({projectRoot:t,toolNames:e},"No unknown_in_graph entries flipped")}function uI(t,e){if(e===0)return"";let r=t.filter(o=>(o.unknown_tools??[]).filter(s=>!s.suggested).length>0);if(r.length===0)return"";let n=r.map(o=>o.project_root).join(", ");return[`The auto-init scan found ${e} tool(s) not yet in the ToolCairn graph`,`across ${r.length} project root(s): ${n}.`,"The server has already auto-submitted these to the admin review queue,","but you MAY repeat the call below to confirm \u2014 engine-side dedup prevents duplicates:",'(1) call `suggest_graph_update` with suggestion_type="new_tool" and'," data.tools=<that root's unknown_tools array>;",'(2) call `update_project_config` with action="mark_suggestions_sent",'," project_root, and data.tool_names=<names that staged or were already_staged>."].join(" ")}d();var zy=Me(or(),1);import{mkdir as gI}from"fs/promises";import{platform as _I,type as yI}from"os";import{join as vI}from"path";d();var Sy=Me(or(),1);import{mkdir as dI,writeFile as pI}from"fs/promises";import{basename as fI,join as mI}from"path";d();function $y(t){let e={rootName:t.rootName,generatedAt:new Date().toISOString(),entries:t.entries},r=JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");return lI.replace("__AUDIT_DATA_JSON__",r)}var lI=`<!DOCTYPE html>
|
|
40
|
+
]`;continue}o+=n[c],n[c]==="\\"?s=!0:i&&n[c]==="]"?i=!1:!i&&n[c]==="["&&(i=!0)}try{new RegExp(o)}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 o}function Ms(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===U.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,o)=>({...n,[o]:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",o]})??_e(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===U.ZodString&&t.keyType._def.checks?.length){let{type:n,...o}=Ns(t.keyType._def,e);return{...r,propertyNames:o}}else{if(t.keyType?._def.typeName===U.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===U.ZodBranded&&t.keyType._def.type._def.typeName===U.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...o}=As(t.keyType._def,e);return{...r,propertyNames:o}}}return r}function Am(t,e){if(e.mapStrategy==="record")return Ms(t,e);let r=D(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||_e(e),n=D(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||_e(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}d();function Nm(t){let e=t.values,n=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),o=Array.from(new Set(n.map(s=>typeof s)));return{type:o.length===1?o[0]==="string"?"string":"number":["string","number"],enum:n}}d();function Mm(t){return t.target==="openAi"?void 0:{not:_e({...t,currentPath:[...t.currentPath,"not"]})}}d();function Dm(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}d();d();var no={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function Lm(t,e){if(e.target==="openApi3")return qm(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in no&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,s)=>{let i=no[s._def.typeName];return i&&!o.includes(i)?[...o,i]:o},[]);return{type:n.length>1?n:n[0]}}else if(r.every(n=>n._def.typeName==="ZodLiteral"&&!n.description)){let n=r.reduce((o,s)=>{let i=typeof s._def.value;switch(i){case"string":case"number":case"boolean":return[...o,i];case"bigint":return[...o,"integer"];case"object":if(s._def.value===null)return[...o,"null"];default:return o}},[]);if(n.length===r.length){let o=n.filter((s,i,a)=>a.indexOf(s)===i);return{type:o.length>1?o:o[0],enum:r.reduce((s,i)=>s.includes(i._def.value)?s:[...s,i._def.value],[])}}}else if(r.every(n=>n._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((n,o)=>[...n,...o._def.values.filter(s=>!n.includes(s))],[])};return qm(t,e)}var qm=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,o)=>D(n._def,{...e,currentPath:[...e.currentPath,"anyOf",`${o}`]})).filter(n=>!!n&&(!e.strictUnions||typeof n=="object"&&Object.keys(n).length>0));return r.length?{anyOf:r}:void 0};function Um(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:no[t.innerType._def.typeName],nullable:!0}:{type:[no[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=D(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=D(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}d();function Vm(t,e){let r={type:"number"};if(!t.checks)return r;for(let n of t.checks)switch(n.kind){case"int":r.type="integer",du(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?Y(r,"minimum",n.value,n.message,e):Y(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),Y(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?Y(r,"maximum",n.value,n.message,e):Y(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),Y(r,"maximum",n.value,n.message,e));break;case"multipleOf":Y(r,"multipleOf",n.value,n.message,e);break}return r}d();function Fm(t,e){let r=e.target==="openAi",n={type:"object",properties:{}},o=[],s=t.shape();for(let a in s){let c=s[a];if(c===void 0||c._def===void 0)continue;let u=O0(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=D(c._def,{...e,currentPath:[...e.currentPath,"properties",a],propertyPath:[...e.currentPath,"properties",a]});l!==void 0&&(n.properties[a]=l,u||o.push(a))}o.length&&(n.required=o);let i=Z0(t,e);return i!==void 0&&(n.additionalProperties=i),n}function Z0(t,e){if(t.catchall._def.typeName!=="ZodNever")return D(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 O0(t){try{return t.isOptional()}catch{return!0}}d();var Hm=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return D(t.innerType._def,e);let r=D(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:_e(e)},r]}:_e(e)};d();var Bm=(t,e)=>{if(e.pipeStrategy==="input")return D(t.in._def,e);if(e.pipeStrategy==="output")return D(t.out._def,e);let r=D(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=D(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}};d();function Jm(t,e){return D(t.type._def,e)}d();function Km(t,e){let n={type:"array",uniqueItems:!0,items:D(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&Y(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&Y(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}d();function Gm(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>D(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:D(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>D(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}d();function Wm(t){return{not:_e(t)}}d();function Ym(t){return _e(t)}d();var Xm=(t,e)=>D(t.innerType._def,e);var Qm=(t,e,r)=>{switch(e){case U.ZodString:return Ns(t,r);case U.ZodNumber:return Vm(t,r);case U.ZodObject:return Fm(t,r);case U.ZodBigInt:return zm(t,r);case U.ZodBoolean:return Pm();case U.ZodDate:return pu(t,r);case U.ZodUndefined:return Wm(r);case U.ZodNull:return Dm(r);case U.ZodArray:return Tm(t,r);case U.ZodUnion:case U.ZodDiscriminatedUnion:return Lm(t,r);case U.ZodIntersection:return Zm(t,r);case U.ZodTuple:return Gm(t,r);case U.ZodRecord:return Ms(t,r);case U.ZodLiteral:return Om(t,r);case U.ZodEnum:return Cm(t);case U.ZodNativeEnum:return Nm(t);case U.ZodNullable:return Um(t,r);case U.ZodOptional:return Hm(t,r);case U.ZodMap:return Am(t,r);case U.ZodSet:return Km(t,r);case U.ZodLazy:return()=>t.getter()._def;case U.ZodPromise:return Jm(t,r);case U.ZodNaN:case U.ZodNever:return Mm(r);case U.ZodEffects:return Rm(t,r);case U.ZodAny:return _e(r);case U.ZodUnknown:return Ym(r);case U.ZodDefault:return Em(t,r);case U.ZodBranded:return As(t,r);case U.ZodReadonly:return Xm(t,r);case U.ZodCatch:return Im(t,r);case U.ZodPipeline:return Bm(t,r);case U.ZodFunction:case U.ZodVoid:case U.ZodSymbol:return;default:return(n=>{})(e)}};function D(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==km)return a}if(n&&!r){let a=j0(n,e);if(a!==void 0)return a}let o={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,o);let s=Qm(t,t.typeName,e),i=typeof s=="function"?D(s(),e):s;if(i&&A0(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return o.jsonSchema=i,a}return o.jsonSchema=i,i}var j0=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:js(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`),_e(e)):e.$refStrategy==="seen"?_e(e):void 0}},A0=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);d();d();var hu=(t,e)=>{let r=Sm(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:D(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??_e(r)}),{}):void 0,o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=D(t._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??_e(r),i=typeof e=="object"&&e.name!==void 0&&e.nameStrategy==="title"?e.name:void 0;i!==void 0&&(s.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("/")}}));let a=o===void 0?n?{...s,[r.definitionPath]:n}:s:{$ref:[...r.$refStrategy==="relative"?[]:r.basePath,r.definitionPath,o].join("/"),[r.definitionPath]:{...n,[o]:s}};return r.target==="jsonSchema7"?a.$schema="http://json-schema.org/draft-07/schema#":(r.target==="jsonSchema2019-09"||r.target==="openAi")&&(a.$schema="https://json-schema.org/draft/2019-09/schema#"),r.target==="openAi"&&("anyOf"in a||"oneOf"in a||"allOf"in a||"type"in a&&Array.isArray(a.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),a};function N0(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function gu(t,e){return Ye(t)?Dc(t,{target:N0(e?.target),io:e?.pipeStrategy??"input"}):hu(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function _u(t){let r=qt(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=ls(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function yu(t,e){let r=Dt(t,e);if(!r.success)throw r.error;return r.data}var M0=6e4,Ds=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(_s,r=>{this._oncancel(r)}),this.setNotificationHandler(bs,r=>{this._onprogress(r)}),this.setRequestHandler(vs,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ws,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new C(A.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ks,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let p=c,m=new C(p.error.code,p.error.message,p.error.data);l(m)}else{let p=a.type==="response"?"Response":"Error";this._onerror(new Error(`${p} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new C(A.InvalidParams,`Task not found: ${s}`);if(!Vt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Vt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Lt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler($s,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new C(A.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ts,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new C(A.InvalidParams,`Task not found: ${r.params.taskId}`);if(Vt(o.status))throw new C(A.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new C(A.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof C?o:new C(A.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),C.fromError(A.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Pt(s)||Gr(s)?this._onresponse(s):Ut(s)?this._onrequest(s,i):pm(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=C.fromError(A.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let 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){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[Lt]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:A.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(p=>this._onerror(new Error(`Failed to enqueue error response: ${p}`))):o?.send(l).catch(p=>this._onerror(new Error(`Failed to send an error response: ${p}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=um(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let p={relatedRequestId:e.id};s&&(p.relatedTask={taskId:s}),await this.notification(l,p)},sendRequest:async(l,p,m)=>{if(i.signal.aborted)throw new C(A.ConnectionClosed,"Request was cancelled");let h={...m,relatedRequestId:e.id};s&&!h.relatedTask&&(h.relatedTask={taskId:s});let f=h.relatedTask?.taskId??s;return f&&c&&await c.updateTaskStatus(f,"input_required"),await this.request(l,p,h)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let p={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:p,timestamp:Date.now()},o?.sessionId):await o?.send(p)},async l=>{if(i.signal.aborted)return;let p={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:A.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:p,timestamp:Date.now()},o?.sessionId):await o?.send(p)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Pt(e))n(e);else{let i=new C(e.error.code,e.error.message,e.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===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 s=!1;if(Pt(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),Pt(e))o(e);else{let i=C.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof C?i:new C(A.InternalError,String(i))}}return}let s;try{let i=await this.request(e,Wr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new C(A.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Vt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new C(A.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new C(A.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof C?i:new C(A.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let p=S=>{l(S)};if(!this._transport){p(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(S){p(S);return}n?.signal?.throwIfAborted();let m=this._requestMessageId++,h={...e,jsonrpc:"2.0",id:m};n?.onprogress&&(this._progressHandlers.set(m,n.onprogress),h.params={...e.params,_meta:{...e.params?._meta||{},progressToken:m}}),a&&(h.params={...h.params,task:a}),c&&(h.params={...h.params,_meta:{...h.params?._meta||{},[Lt]:c}});let f=S=>{this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(S)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(R=>this._onerror(new Error(`Failed to send cancellation: ${R}`)));let T=S instanceof C?S:new C(A.RequestTimeout,String(S));l(T)};this._responseHandlers.set(m,S=>{if(!n?.signal?.aborted){if(S instanceof Error)return l(S);try{let T=Dt(r,S.result);T.success?u(T.data):l(T.error)}catch(T){l(T)}}}),n?.signal?.addEventListener("abort",()=>{f(n?.signal?.reason)});let _=n?.timeout??M0,w=()=>f(C.fromError(A.RequestTimeout,"Request timed out",{timeout:_}));this._setupTimeout(m,_,n?.maxTotalTimeout,w,n?.resetTimeoutOnProgress??!1);let $=c?.taskId;if($){let S=T=>{let R=this._responseHandlers.get(m);R?R(T):this._onerror(new Error(`Response handler missing for side-channeled request ${m}`))};this._requestResolvers.set(m,S),this._enqueueTaskMessage($,{type:"request",message:h,timestamp:Date.now()}).catch(T=>{this._cleanupTimeout(m),l(T)})}else this._transport.send(h,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(S=>{this._cleanupTimeout(m),l(S)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},xs,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},Ss,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},mm,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Lt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Lt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Lt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=_u(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=yu(e,o);return Promise.resolve(r(i,s))})}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){let n=_u(e);this._notificationHandlers.set(n,o=>{let s=yu(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let 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");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&Ut(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new C(A.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new C(A.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new C(A.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new C(A.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=Qn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Vt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new C(A.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Vt(a.status))throw new C(A.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=Qn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Vt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function eh(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function th(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];eh(i)&&eh(s)?r[o]={...i,...s}:r[o]=s}return r}d();var L_=Me(nd(),1),U_=Me(q_(),1);function Iz(){let t=new L_.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,U_.default)(t),t}var wi=class{constructor(e){this._ajv=e??Iz()}getValidator(e){let 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)}}};d();var xi=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(m=>m.type==="tool_use").map(m=>m.id)),p=new Set(s.filter(m=>m.type==="tool_result").map(m=>m.toolUseId));if(l.size!==p.size||![...l].every(m=>p.has(m)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},ro,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:s},Qr,r)}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)}};d();function V_(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;default:break}}function F_(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;default:break}}var ki=class extends Ds{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(to.options.map((n,o)=>[n,o])),this.isMessageIgnored=(n,o)=>{let s=this._loggingLevels.get(o);return s?this.LOG_LEVEL_SEVERITY.get(n)<this.LOG_LEVEL_SEVERITY.get(s):!1},this._capabilities=r?.capabilities??{},this._instructions=r?.instructions,this._jsonSchemaValidator=r?.jsonSchemaValidator??new wi,this.setRequestHandler(ys,n=>this._oninitialize(n)),this.setNotificationHandler(tu,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(cu,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=to.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new xi(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=th(this._capabilities,e)}setRequestHandler(e,r){let o=qt(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(Ye(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Dt(Xr,c);if(!l.success){let f=l.error instanceof Error?l.error.message:String(l.error);throw new C(A.InvalidParams,`Invalid tools/call request: ${f}`)}let{params:p}=l.data,m=await Promise.resolve(r(c,u));if(p.task){let f=Dt(Wr,m);if(!f.success){let _=f.error instanceof Error?f.error.message:String(f.error);throw new C(A.InvalidParams,`Invalid task creation result: ${_}`)}return f.data}let h=Dt(Zs,m);if(!h.success){let f=h.error instanceof Error?h.error.message:String(h.error);throw new C(A.InvalidParams,`Invalid tools/call result: ${f}`)}return h.data};return super.setRequestHandler(e,a)}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;case"ping":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;case"notifications/cancelled":break;case"notifications/progress":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;case"ping":case"initialize":break}}assertTaskCapability(e){F_(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&V_(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Kr.includes(r)?r:Wc,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"},gs)}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){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.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){let u=new Set(a.filter(p=>p.type==="tool_use").map(p=>p.id)),l=new Set(o.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(u.size!==l.size||![...u].every(p=>l.has(p)))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},uu,r):this.request({method:"sampling/createMessage",params:e},ro,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.");let o=e;return this.request({method:"elicitation/create",params:o},Qr,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Qr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new C(A.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof C?i:new C(A.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}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},lu,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"})}};d();var B_=Symbol.for("mcp.completable");function dd(t){return!!t&&typeof t=="object"&&B_ in t}function J_(t){return t[B_]?.complete}var H_;(function(t){t.Completable="McpCompletable"})(H_||(H_={}));d();d();var Ez=/^[A-Za-z0-9._-]{1,128}$/;function Rz(t){let 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"),!Ez.test(t)){let r=t.split("").filter(n=>!/[A-Za-z0-9._-]/.test(n)).filter((n,o,s)=>s.indexOf(n)===o);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 Cz(t,e){if(e.length>0){console.warn(`Tool name validation warning for "${t}":`);for(let 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 pd(t){let e=Rz(t);return Cz(t,e.warnings),e.isValid}d();var $i=class{constructor(e){this._mcpServer=e}registerToolTask(e,r,n){let o={taskSupport:"required",...r.execution};if(o.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,o,r._meta,n)}};var yn=class{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 ki(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new $i(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(Xt(Cs)),this.server.assertCanSetRequestHandler(Xt(Xr)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Cs,()=>({tools:Object.entries(this._registeredTools).filter(([,e])=>e.enabled).map(([e,r])=>{let n={name:e,title:r.title,description:r.description,inputSchema:(()=>{let o=Br(r.inputSchema);return o?gu(o,{strictUnions:!0,pipeStrategy:"input"}):Zz})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=Br(r.outputSchema);o&&(n.outputSchema=gu(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(Xr,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new C(A.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new C(A.InvalidParams,`Tool ${e.params.name} disabled`);let o=!!e.params.task,s=n.execution?.taskSupport,i="createTask"in n.handler;if((s==="required"||s==="optional")&&!i)throw new C(A.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if(s==="required"&&!o)throw new C(A.MethodNotFound,`Tool ${e.params.name} requires task augmentation (taskSupport: 'required')`);if(s==="optional"&&!o&&i)return await this.handleAutomaticTaskPolling(n,e,r);let a=await this.validateToolInput(n,e.params.arguments,e.params.name),c=await this.executeToolHandler(n,a,r);return o||await this.validateToolOutput(n,c,e.params.name),c}catch(n){if(n instanceof C&&n.code===A.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;let s=Br(e.inputSchema)??e.inputSchema,i=await cs(s,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=us(a);throw new C(A.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 C(A.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=Br(e.outputSchema),s=await cs(o,r.structuredContent);if(!s.success){let i="error"in s?s.error:"Unknown error",a=us(i);throw new C(A.InvalidParams,`Output validation error: Invalid structured content for tool ${n}: ${a}`)}}async executeToolHandler(e,r,n){let o=e.handler;if("createTask"in o){if(!n.taskStore)throw new Error("No task store provided.");let i={...n,taskStore:n.taskStore};if(e.inputSchema){let a=o;return await Promise.resolve(a.createTask(r,i))}else{let a=o;return await Promise.resolve(a.createTask(i))}}if(e.inputSchema){let i=o;return await Promise.resolve(i(r,n))}else{let i=o;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.");let o=await this.validateToolInput(e,r.params.arguments,r.params.name),s=e.handler,i={...n,taskStore:n.taskStore},a=o?await Promise.resolve(s.createTask(o,i)):await Promise.resolve(s.createTask(i)),c=a.task.taskId,u=a.task,l=u.pollInterval??5e3;for(;u.status!=="completed"&&u.status!=="failed"&&u.status!=="cancelled";){await new Promise(m=>setTimeout(m,l));let p=await n.taskStore.getTask(c);if(!p)throw new C(A.InternalError,`Task ${c} not found during polling`);u=p}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(Xt(Os)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Os,async e=>{switch(e.params.ref.type){case"ref/prompt":return bm(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return wm(e),this.handleResourceCompletion(e,e.params.ref);default:throw new C(A.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new C(A.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new C(A.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return Oo;let s=qt(n.argsSchema)?.[e.params.argument.name];if(!dd(s))return Oo;let i=J_(s);if(!i)return Oo;let a=await i(e.params.argument.value,e.params.context);return G_(a)}async handleResourceCompletion(e,r){let n=Object.values(this._registeredResourceTemplates).find(i=>i.resourceTemplate.uriTemplate.toString()===r.uri);if(!n){if(this._registeredResources[r.uri])return Oo;throw new C(A.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(e.params.argument.name);if(!o)return Oo;let s=await o(e.params.argument.value,e.params.context);return G_(s)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(Xt(zs)),this.server.assertCanSetRequestHandler(Xt(Ps)),this.server.assertCanSetRequestHandler(Xt(Is)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(zs,async(e,r)=>{let n=Object.entries(this._registeredResources).filter(([s,i])=>i.enabled).map(([s,i])=>({uri:s,name:i.name,...i.metadata})),o=[];for(let s of Object.values(this._registeredResourceTemplates)){if(!s.resourceTemplate.listCallback)continue;let i=await s.resourceTemplate.listCallback(r);for(let a of i.resources)o.push({...s.metadata,...a})}return{resources:[...n,...o]}}),this.server.setRequestHandler(Ps,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(Is,async(e,r)=>{let n=new URL(e.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new C(A.InvalidParams,`Resource ${n} disabled`);return o.readCallback(n,r)}for(let s of Object.values(this._registeredResourceTemplates)){let i=s.resourceTemplate.uriTemplate.match(n.toString());if(i)return s.readCallback(n,i,r)}throw new C(A.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(Xt(Es)),this.server.assertCanSetRequestHandler(Xt(Rs)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(Es,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?Oz(r.argsSchema):void 0}))})),this.server.setRequestHandler(Rs,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new C(A.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new C(A.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let o=Br(n.argsSchema),s=await cs(o,e.params.arguments);if(!s.success){let c="error"in s?s.error:"Unknown error",u=us(c);throw new C(A.InvalidParams,`Invalid arguments for prompt ${e.params.name}: ${u}`)}let i=s.data,a=n.callback;return await Promise.resolve(a(i,r))}else{let o=n.callback;return await Promise.resolve(o(r))}}),this._promptHandlersInitialized=!0)}resource(e,r,...n){let o;typeof n[0]=="object"&&(o=n.shift());let s=n[0];if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let i=this._createRegisteredResource(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let i=this._createRegisteredResourceTemplate(e,void 0,r,o,s);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),i}}registerResource(e,r,n,o){if(typeof r=="string"){if(this._registeredResources[r])throw new Error(`Resource ${r} is already registered`);let s=this._createRegisteredResource(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}else{if(this._registeredResourceTemplates[e])throw new Error(`Resource template ${e} is already registered`);let s=this._createRegisteredResourceTemplate(e,n.title,r,n,o);return this.setResourceRequestHandlers(),this.sendResourceListChanged(),s}}_createRegisteredResource(e,r,n,o,s){let i={name:e,title:r,metadata:o,readCallback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({uri:null}),update:a=>{typeof a.uri<"u"&&a.uri!==n&&(delete this._registeredResources[n],a.uri&&(this._registeredResources[a.uri]=i)),typeof a.name<"u"&&(i.name=a.name),typeof a.title<"u"&&(i.title=a.title),typeof a.metadata<"u"&&(i.metadata=a.metadata),typeof a.callback<"u"&&(i.readCallback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendResourceListChanged()}};return this._registeredResources[n]=i,i}_createRegisteredResourceTemplate(e,r,n,o,s){let i={resourceTemplate:n,title:r,metadata:o,readCallback:s,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;let a=n.uriTemplate.variableNames;return Array.isArray(a)&&a.some(u=>!!n.completeCallback(u))&&this.setCompletionRequestHandler(),i}_createRegisteredPrompt(e,r,n,o,s){let i={title:r,description:n,argsSchema:o===void 0?void 0:dr(o),callback:s,enabled:!0,disable:()=>i.update({enabled:!1}),enable:()=>i.update({enabled:!0}),remove:()=>i.update({name:null}),update:a=>{typeof a.name<"u"&&a.name!==e&&(delete this._registeredPrompts[e],a.name&&(this._registeredPrompts[a.name]=i)),typeof a.title<"u"&&(i.title=a.title),typeof a.description<"u"&&(i.description=a.description),typeof a.argsSchema<"u"&&(i.argsSchema=dr(a.argsSchema)),typeof a.callback<"u"&&(i.callback=a.callback),typeof a.enabled<"u"&&(i.enabled=a.enabled),this.sendPromptListChanged()}};return this._registeredPrompts[e]=i,o&&Object.values(o).some(c=>{let u=c instanceof Ud?c._def?.innerType:c;return dd(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,o,s,i,a,c,u){pd(e);let l={title:r,description:n,inputSchema:K_(o),outputSchema:K_(s),annotations:i,execution:a,_meta:c,handler:u,enabled:!0,disable:()=>l.update({enabled:!1}),enable:()=>l.update({enabled:!0}),remove:()=>l.update({name:null}),update:p=>{typeof p.name<"u"&&p.name!==e&&(typeof p.name=="string"&&pd(p.name),delete this._registeredTools[e],p.name&&(this._registeredTools[p.name]=l)),typeof p.title<"u"&&(l.title=p.title),typeof p.description<"u"&&(l.description=p.description),typeof p.paramsSchema<"u"&&(l.inputSchema=dr(p.paramsSchema)),typeof p.outputSchema<"u"&&(l.outputSchema=dr(p.outputSchema)),typeof p.callback<"u"&&(l.handler=p.callback),typeof p.annotations<"u"&&(l.annotations=p.annotations),typeof p._meta<"u"&&(l._meta=p._meta),typeof p.enabled<"u"&&(l.enabled=p.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,o,s,i;if(typeof r[0]=="string"&&(n=r.shift()),r.length>1){let c=r[0];if(fd(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!fd(r[0])&&(i=r.shift());else if(typeof c=="object"&&c!==null){if(Object.values(c).some(u=>typeof u=="object"&&u!==null))throw new Error(`Tool ${e} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);i=r.shift()}}let a=r[0];return this._createRegisteredTool(e,void 0,n,o,s,i,{taskSupport:"forbidden"},void 0,a)}registerTool(e,r,n){if(this._registeredTools[e])throw new Error(`Tool ${e} is already registered`);let{title:o,description:s,inputSchema:i,outputSchema:a,annotations:c,_meta:u}=r;return this._createRegisteredTool(e,o,s,i,a,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 o;r.length>1&&(o=r.shift());let s=r[0],i=this._createRegisteredPrompt(e,void 0,n,o,s);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),i}registerPrompt(e,r,n){if(this._registeredPrompts[e])throw new Error(`Prompt ${e} is already registered`);let{title:o,description:s,argsSchema:i}=r,a=this._createRegisteredPrompt(e,o,s,i,n);return this.setPromptRequestHandlers(),this.sendPromptListChanged(),a}isConnected(){return this.server.transport!==void 0}async sendLoggingMessage(e,r){return this.server.sendLoggingMessage(e,r)}sendResourceListChanged(){this.isConnected()&&this.server.sendResourceListChanged()}sendToolListChanged(){this.isConnected()&&this.server.sendToolListChanged()}sendPromptListChanged(){this.isConnected()&&this.server.sendPromptListChanged()}};var Zz={type:"object",properties:{}};function W_(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Y_(t){return"_def"in t||"_zod"in t||W_(t)}function fd(t){return typeof t!="object"||t===null||Y_(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(W_)}function K_(t){if(t){if(fd(t))return dr(t);if(!Y_(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function Oz(t){let e=qt(t);return e?Object.entries(e).map(([r,n])=>{let o=Af(n),s=Nf(n);return{name:r,description:o,required:!s}}):[]}function Xt(t){let r=qt(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=ls(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function G_(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var Oo={completion:{values:[],hasMore:!1}};var Nd=Me(Tn(),1),Md=Me(or(),1);d();var xy=Me(Tn(),1),ky=Me(or(),1);import{existsSync as oI}from"fs";import{join as sI,resolve as iI}from"path";var St=(0,ky.createMcpLogger)({name:"@toolcairn/mcp-server:post-auth-init"});async function aI(){let t=await Tt();return t?new Uo({baseUrl:xy.config.TOOLPILOT_API_URL,apiKey:t.client_id,accessToken:t.access_token}):null}async function zn(t={}){let e=t.cwd??process.cwd(),r=t.agent??"claude",n=await aI();if(!n)return St.warn("runPostAuthInit called without valid credentials \u2014 skipping"),{cwd:e,roots_discovered:[],used_fallback:!1,projects:[],unknown_tools_total:0,first_turn_directive:""};let{roots:o,usedFallback:s}=await fp(e);St.info({cwd:e,roots:o.length,usedFallback:s},"Roots discovered post-auth");let i=[];for(let l of o){if(t.onlyMissingConfig){let p=sI(l,".toolcairn","config.json");if(oI(p)){St.debug({projectRoot:l},"Root already has config.json \u2014 skipping");continue}}try{let p=await mp({projectRoot:l,agent:r,batchResolve:m=>n.batchResolve(m),reason:t.onlyMissingConfig?"Startup auto-init (config missing)":"Post-auth auto-init"});i.push({project_root:l,status:"initialized",config_path:p.config_path,audit_log_path:p.audit_log_path,scan_summary:p.scan_summary,setup_steps:p.setup_steps,unknown_tools:p.unknown_tools,bootstrapped:p.bootstrapped,migrated:p.migrated})}catch(p){let m=p instanceof Error?p.message:String(p);St.error({err:p,projectRoot:l},"autoInitProject failed for root"),i.push({project_root:l,status:"failed",error:m})}}if(!t.disableAutoSubmit)for(let l of i){if(l.status!=="initialized")continue;let p=(l.unknown_tools??[]).filter(m=>!!m.github_url);if(p.length!==0)try{let m=await cI(n,p);l.auto_submitted=m;let h=[...m.staged,...m.already_staged,...m.already_indexed];h.length>0&&await uI(l.project_root,h).catch(f=>St.warn({err:f,projectRoot:l.project_root},"Failed to flip suggested flags after auto-submit")),St.info({projectRoot:l.project_root,staged:m.staged.length,already_staged:m.already_staged.length,already_indexed:m.already_indexed.length,rejected:m.rejected.length},"Auto-push to suggest_graph_update complete")}catch(m){St.warn({err:m,projectRoot:l.project_root},"Auto-push to suggest_graph_update failed \u2014 agent directive remains as fallback")}}let a=iI(e);if(!o.includes(a))try{let l=await hp(a,r);St.info({cwd:a,file:l.file,applied:l.applied,reason:l.reason},"Workspace-level instruction-file pass complete")}catch(l){St.debug({err:l,cwd:a},"Workspace-level instruction merge skipped (best-effort)")}let c=i.reduce((l,p)=>l+(p.unknown_tools??[]).filter(m=>!m.suggested).length,0),u=lI(i,c);return{cwd:e,roots_discovered:o,used_fallback:s,projects:i,unknown_tools_total:c,first_turn_directive:u}}async function cI(t,e){let n=(await t.suggestGraphUpdate({suggestion_type:"new_tool",data:{tools:e.map(a=>({tool_name:a.name,github_url:a.github_url,ecosystem:a.ecosystem}))},confidence:.5})).content?.[0],o={staged:[],already_staged:[],already_indexed:[],rejected:[]};if(!n||n.type!=="text")return o;let s;try{s=JSON.parse(n.text??"{}")}catch{return o}let i=s.data?.results??[];for(let a of i){let c=a.tool_name??"";c&&(a.already_indexed?o.already_indexed.push(c):a.already_staged?o.already_staged.push(c):a.staged===!0?o.staged.push(c):o.rejected.push({tool_name:c,reason:a.reason??"unknown"}))}return o}async function uI(t,e){let r=new Set(e),n=new Date().toISOString(),o=0;await pp(t,s=>{let i=s.tools.unknown_in_graph??[];for(let a of i)r.has(a.name)&&!a.suggested&&(a.suggested=!0,a.suggested_at=n,o++);s.tools.unknown_in_graph=i},{action:"mark_suggestions_sent",tool:`__auto_submit__:${e.length}`,reason:"Server auto-pushed unknown_in_graph tools to suggest_graph_update",metadata:{tool_names:e,tool_count:e.length}}),o===0&&St.debug({projectRoot:t,toolNames:e},"No unknown_in_graph entries flipped")}function lI(t,e){if(e===0)return"";let r=t.filter(o=>(o.unknown_tools??[]).filter(s=>!s.suggested).length>0);if(r.length===0)return"";let n=r.map(o=>o.project_root).join(", ");return[`The auto-init scan found ${e} tool(s) not yet in the ToolCairn graph`,`across ${r.length} project root(s): ${n}.`,"The server has already auto-submitted these to the admin review queue,","but you MAY repeat the call below to confirm \u2014 engine-side dedup prevents duplicates:",'(1) call `suggest_graph_update` with suggestion_type="new_tool" and'," data.tools=<that root's unknown_tools array>;",'(2) call `update_project_config` with action="mark_suggestions_sent",'," project_root, and data.tool_names=<names that staged or were already_staged>."].join(" ")}d();var Py=Me(or(),1);import{mkdir as _I}from"fs/promises";import{platform as yI,type as vI}from"os";import{join as bI}from"path";d();var Ty=Me(or(),1);import{mkdir as pI,writeFile as fI}from"fs/promises";import{basename as mI,join as hI}from"path";d();function $y(t){let e={rootName:t.rootName,generatedAt:new Date().toISOString(),entries:t.entries},r=JSON.stringify(e).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");return dI.replace("__AUDIT_DATA_JSON__",r)}var dI=`<!DOCTYPE html>
|
|
41
41
|
<html lang="en">
|
|
42
42
|
<head>
|
|
43
43
|
<meta charset="UTF-8" />
|
|
@@ -502,10 +502,10 @@ startAuto();
|
|
|
502
502
|
|
|
503
503
|
</body>
|
|
504
504
|
</html>
|
|
505
|
-
`;var
|
|
506
|
-
`,"utf-8")}catch(r){Oy.warn({err:r,path:t},"Failed to write event to JSONL file")}}async function KI(t){try{let e=await Tt();if(!e)return;let r={"Content-Type":"application/json"};e.access_token&&(r.Authorization=`Bearer ${e.access_token}`),e.client_id&&(r["X-ToolCairn-Key"]=e.client_id),await fetch(`${Cy.config.TOOLPILOT_API_URL}/v1/events`,{method:"POST",headers:r,body:JSON.stringify({tool_name:t.tool_name,query_id:t.query_id,duration_ms:t.duration_ms,status:t.status,metadata:t.metadata})})}catch(e){Oy.debug({err:e},"Failed to send event to API \u2014 non-fatal")}}function jy(t,e){return async r=>{if(!VI())return e(r);let n=Date.now(),o,s="ok";try{o=await e(r),o.isError&&(s="error")}catch(i){throw s="error",i}finally{let i=Date.now()-n,a={id:crypto.randomUUID(),tool_name:t,query_id:HI(r),duration_ms:i,status:s,metadata:o?BI(t,o):null,created_at:new Date().toISOString()};KI(a).catch(()=>{});let c=FI();c&&JI(c,a).catch(()=>{})}return o??{content:[],isError:!0}}}var zd=(0,Oi.createMcpLogger)({name:"@toolcairn/mcp-server:prod"}),GI='\n# ToolCairn \u2014 Agent Setup Instructions\n\nYou are connected to the ToolCairn MCP server. ToolCairn is your active tool intelligence co-pilot.\n\n## The Server Owns .toolcairn/ (v0.10.0+)\n\nThe MCP server reads and writes `.toolcairn/config.json` + `.toolcairn/audit-log.jsonl`\natomically under a cross-process lock. You never touch those files directly.\n\n## On Every Session Start \u2014 Do This First\n\nCall `read_project_config` with `project_root` (absolute path to the user\'s project).\n\nIn most sessions config is already there: when the user ran `toolcairn_auth` the\nserver auto-discovered every project root under its CWD and ran the full 12-ecosystem\nscan + graph classification + config write for each. The auth response carried back\nper-root `projects[]` entries with `setup_steps` (CLAUDE.md / .mcp.json / .gitignore)\nand `unknown_tools[]`.\n\n- If `read_project_config` returns `status: "not_initialized"` for some root\n (rare \u2014 only when auto-init skipped that root): call `toolcairn_init` explicitly\n for that `project_root`.\n- If it returns `status: "ready"`: you have the full snapshot \u2014 review\n `stale_tools` / `pending_tools` / `unknown_tools` and proceed.\n\n## First-Turn Drain Protocol (REQUIRED before replying to the user)\n\nIf the auth response OR `read_project_config` returned non-empty `unknown_tools[]`\nfor a root, you MUST submit them before your first user-facing response:\n\n1. `suggest_graph_update` with `suggestion_type: "new_tool"` and\n `data.tools: <the full unknown_tools array for that root>`. Entries are STAGED\n for admin review \u2014 they do NOT enter the live graph until approved.\n2. `update_project_config` with `action: "mark_suggestions_sent"`,\n `project_root`, and `data.tool_names: [names that staged successfully]`.\n\nIn multi-root workspaces, repeat per root. This closes the learning loop so every\nproject contributes its OSS dependency tail back to the ToolCairn graph.\n\n## Applying Mutations\n\nWhen the user selects / replaces / drops a tool, call `update_project_config`\nwith `project_root`, `action` (add_tool / remove_tool / update_tool / add_evaluation),\nand `tool_name`. The server:\n- atomically updates `.toolcairn/config.json`,\n- appends a new line to `.toolcairn/audit-log.jsonl` (FIFO-archived at 1000 entries),\n- returns the new `last_audit_entry` for your record.\n\nDo NOT construct or write these files yourself \u2014 you do not have the cross-process\nlock that protects them.\n\n## Schema Migration\n\nConfigs written by v0.9.x are on schema 1.0. The first `read_project_config` or\n`update_project_config` call after upgrade migrates in place to 1.1 (languages \u2192\narray, frameworks \u2192 array, `audit_log[]` relocated from config.json to\naudit-log.jsonl). The migration is logged as an audit entry.\n\n## When to Use ToolCairn Tools\n\n| Situation | Tool to call |\n|-----------|-------------|\n| User asks which tool to use for X | `classify_prompt` \u2192 `refine_requirement` \u2192 `search_tools` |\n| User needs to compare two tools | `compare_tools` |\n| User asks if tool A works with tool B | `check_compatibility` |\n| Error persists after 4+ retries AND docs checked | `check_issue` |\n| User asks for a recommended stack | `get_stack` |\n| search_tools returns empty or low confidence | `verify_suggestion` |\n| You discover a new tool relationship | `suggest_graph_update` |\n| A tool worked well or was replaced | `report_outcome` |\n| Tool added/removed from project | `update_project_config` |\n'.trim();async function Id(t){let e=await Tt();if(!e||!Cn(e))throw new Error("ToolCairn: authentication required.");let r=new Uo({baseUrl:Pd.config.TOOLPILOT_API_URL,apiKey:e.client_id,accessToken:e.access_token});zd.info({user:e.user_email},"Registering production tools");function n(o,s){return jy(o,Ry(o,(0,Oi.withErrorHandling)(o,zd,s)))}t.registerTool("classify_prompt",{description:"Classify a developer prompt to determine if ToolCairn tool search is needed. Returns a structured classification prompt for the agent to evaluate.",inputSchema:op},n("classify_prompt",async o=>ap(o))),t.registerTool("toolcairn_init",{description:"Bootstrap ToolCairn for the current project. Walks every workspace, parses manifests across 12 ecosystems, classifies tools against the ToolCairn graph, and writes .toolcairn/config.json + audit-log.jsonl atomically. Returns setup_steps for CLAUDE.md / .mcp.json / .gitignore (agent applies those).",inputSchema:tp},n("toolcairn_init",async o=>hp(o,{batchResolve:s=>r.batchResolve(s)}))),t.registerTool("read_project_config",{description:"Read .toolcairn/config.json from disk and return the structured project snapshot: project metadata, confirmed tools, stale tools, pending evaluations, and last audit entry. Auto-migrates v1.0 configs to v1.1 on first read.",inputSchema:rp},n("read_project_config",async o=>gp(o))),t.registerTool("update_project_config",{description:"Apply a mutation to .toolcairn/config.json (add_tool / remove_tool / update_tool / add_evaluation). The server atomically rewrites config.json and appends a new line to audit-log.jsonl under a cross-process lock. Requires project_root.",inputSchema:np},n("update_project_config",async o=>_p(o))),t.registerTool("search_tools",{description:"Search for the best tool for a specific need using a natural language query. Initiates a guided discovery session with clarification questions when needed.",inputSchema:Jd},n("search_tools",async o=>r.searchTools(o))),t.registerTool("search_tools_respond",{description:"Submit clarification answers for an in-progress tool search session and receive refined results.",inputSchema:Kd},n("search_tools_respond",async o=>r.searchToolsRespond(o))),t.registerTool("get_stack",{description:'Build a complementary tool stack for a project use case. For best results, call refine_requirement first with classification "stack_building", evaluate its decomposition_prompt to get sub-needs, then pass each {sub_need_type, keyword_sentence} object as a sub_needs entry. This lets get_stack keyword-match per layer (e.g. "web-framework", "database", "auth") instead of one broad search. Falls back to balanced search when sub_needs is omitted. Each tool in the returned stack also carries a `version` object with the recommended version that is cross-compatible with the rest of the stack (downgraded from latest if needed to satisfy peer constraints), plus a top-level `compatibility_matrix` + `stack_compatibility` summarising cross-tool version fit.',inputSchema:Wd},n("get_stack",async o=>r.getStack(o))),t.registerTool("check_compatibility",{description:'Check compatibility between two tools with version-aware matching. When both tools have declared dependency metadata (npm peerDependencies, PyPI requires_dist, etc.) the handler evaluates range constraints directly and returns a version_checks array plus runtime_requirements. Pass optional tool_a_version / tool_b_version to evaluate specific versions (e.g. "is next@14 compatible with react@17?"). Falls back to graph-edge + shared-neighbors inference when version metadata is unavailable. Response includes `source`: "declared_dependency" | "graph_edges" | "shared_neighbors".',inputSchema:Xd},n("check_compatibility",async o=>r.checkCompatibility(o))),t.registerTool("compare_tools",{description:"Compare two tools head-to-head using health signals, graph relationships, and community data.",inputSchema:ep},n("compare_tools",async o=>r.compareTools(o))),t.registerTool("refine_requirement",{description:"Decompose a vague user use-case into specific, searchable tool requirements.",inputSchema:ip},n("refine_requirement",async o=>r.refineRequirement(o))),t.registerTool("check_issue",{description:"LAST RESORT \u2014 check GitHub Issues for a known error after 4+ retries and docs review.",inputSchema:Yd},n("check_issue",async o=>r.checkIssue(o))),t.registerTool("verify_suggestion",{description:"Validate agent-suggested tools against the ToolCairn graph.",inputSchema:sp},n("verify_suggestion",async o=>r.verifySuggestion(o))),t.registerTool("report_outcome",{description:"Report the outcome of using a tool recommended by ToolCairn (fire-and-forget).",inputSchema:Gd},n("report_outcome",async o=>r.reportOutcome(o))),t.registerTool("suggest_graph_update",{description:"Suggest a new tool, relationship, use case, or health update to the ToolCairn graph.",inputSchema:Qd},n("suggest_graph_update",async o=>r.suggestGraphUpdate(o))),t.registerTool("toolcairn_auth",{description:'Manage your ToolCairn authentication. Use "login" to authenticate via browser (unlocks higher rate limits), "status" to check current auth state, or "logout" to revert to anonymous mode.',inputSchema:Ur.object({action:Ur.enum(["login","status","logout"]).describe('"login" opens a browser to authenticate, "status" shows current auth state, "logout" clears authentication')})},n("toolcairn_auth",async o=>{let s=o.action;if(s==="status"){let i=await Tt(),a=i!==null&&Cn(i);return{content:[{type:"text",text:JSON.stringify({authenticated:a,user_email:i?.user_email??null,user_name:i?.user_name??null,authenticated_at:i?.authenticated_at??null})}]}}if(s==="logout")return await Hd(),{content:[{type:"text",text:JSON.stringify({ok:!0,message:"Signed out. Restart your agent to sign in again \u2014 authentication will start automatically."})}]};try{let i=await Vo(Pd.config.TOOLPILOT_API_URL),a=await zn({agent:"claude"}).catch(c=>(zd.warn({err:c},"runPostAuthInit failed post-login \u2014 auth still succeeds"),null));return{content:[{type:"text",text:JSON.stringify({ok:!0,message:`Successfully authenticated as ${i.email}. All tools are now authorized.`,user_email:i.email,user_name:i.name,roots_discovered:a?.roots_discovered??[],projects:a?.projects??[],unknown_tools_total:a?.unknown_tools_total??0,first_turn_directive:a?.first_turn_directive??""})}]}}catch(i){let a=i instanceof Error?i.message:"Authentication failed";return{content:[{type:"text",text:JSON.stringify({ok:!1,error:a})}],isError:!0}}}))}async function Ay(){let t=new yn({name:"toolcairn",version:"0.1.0"},{instructions:GI});return await Id(t),t}d();d();import My from"process";d();var ji=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
507
|
-
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),
|
|
508
|
-
`}var Ai=class{constructor(e=My.stdin,r=My.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new ji,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=Ny(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};d();d();import{Http2ServerRequest as Uy,constants as YI}from"http2";import{Http2ServerRequest as Ed}from"http2";import{Readable as Dy}from"stream";import uE from"crypto";var Dr=class extends Error{constructor(t,e){super(t,e),this.name="RequestError"}},XI=t=>t instanceof Dr?t:new Dr(t.message,{cause:t}),QI=global.Request,qo=class extends QI{constructor(t,e){typeof t=="object"&&En in t&&(t=t[En]()),typeof e?.body?.getReader<"u"&&(e.duplex??="half"),super(t,e)}},eE=t=>{let e=[],r=t.rawHeaders;for(let n=0;n<r.length;n+=2){let{[n]:o,[n+1]:s}=r;o.charCodeAt(0)!==58&&e.push([o,s])}return new Headers(e)},Vy=Symbol("wrapBodyStream"),tE=(t,e,r,n,o)=>{let s={method:t,headers:r,signal:o.signal};if(t==="TRACE"){s.method="GET";let i=new qo(e,s);return Object.defineProperty(i,"method",{get(){return"TRACE"}}),i}if(!(t==="GET"||t==="HEAD"))if("rawBody"in n&&n.rawBody instanceof Buffer)s.body=new ReadableStream({start(i){i.enqueue(n.rawBody),i.close()}});else if(n[Vy]){let i;s.body=new ReadableStream({async pull(a){try{i||=Dy.toWeb(n).getReader();let{done:c,value:u}=await i.read();c?a.close():a.enqueue(u)}catch(c){a.error(c)}}})}else s.body=Dy.toWeb(n);return new qo(e,s)},En=Symbol("getRequestCache"),rE=Symbol("requestCache"),Ni=Symbol("incomingKey"),Mi=Symbol("urlKey"),nE=Symbol("headersKey"),In=Symbol("abortControllerKey"),oE=Symbol("getAbortController"),Di={get method(){return this[Ni].method||"GET"},get url(){return this[Mi]},get headers(){return this[nE]||=eE(this[Ni])},[oE](){return this[En](),this[In]},[En](){return this[In]||=new AbortController,this[rE]||=tE(this.method,this[Mi],this.headers,this[Ni],this[In])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(t=>{Object.defineProperty(Di,t,{get(){return this[En]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(Di,t,{value:function(){return this[En]()[t]()}})});Object.setPrototypeOf(Di,qo.prototype);var sE=(t,e)=>{let r=Object.create(Di);r[Ni]=t;let n=t.url||"";if(n[0]!=="/"&&(n.startsWith("http://")||n.startsWith("https://"))){if(t instanceof Ed)throw new Dr("Absolute URL for :path is not allowed in HTTP/2");try{let a=new URL(n);r[Mi]=a.href}catch(a){throw new Dr("Invalid absolute URL",{cause:a})}return r}let o=(t instanceof Ed?t.authority:t.headers.host)||e;if(!o)throw new Dr("Missing host header");let s;if(t instanceof Ed){if(s=t.scheme,!(s==="http"||s==="https"))throw new Dr("Unsupported scheme")}else s=t.socket&&t.socket.encrypted?"https":"http";let i=new URL(`${s}://${o}${n}`);if(i.hostname.length!==o.length&&i.hostname!==o.replace(/:\d+$/,""))throw new Dr("Invalid host header");return r[Mi]=i.href,r},qy=Symbol("responseCache"),Pn=Symbol("getResponseCache"),qr=Symbol("cache"),Od=global.Response,Lo=class Fy{#t;#e;[Pn](){return delete this[qr],this[qy]||=new Od(this.#t,this.#e)}constructor(e,r){let n;if(this.#t=e,r instanceof Fy){let o=r[qy];if(o){this.#e=o,this[Pn]();return}else this.#e=r.#e,n=new Headers(r.#e.headers)}else this.#e=r;(typeof e=="string"||typeof e?.getReader<"u"||e instanceof Blob||e instanceof Uint8Array)&&(this[qr]=[r?.status||200,e,n||r?.headers])}get headers(){let e=this[qr];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":"text/plain; charset=UTF-8"})),e[2]):this[Pn]().headers}get status(){return this[qr]?.[0]??this[Pn]().status}get ok(){let e=this.status;return e>=200&&e<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(t=>{Object.defineProperty(Lo.prototype,t,{get(){return this[Pn]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(Lo.prototype,t,{value:function(){return this[Pn]()[t]()}})});Object.setPrototypeOf(Lo,Od);Object.setPrototypeOf(Lo.prototype,Od.prototype);async function iE(t){return Promise.race([t,Promise.resolve().then(()=>Promise.resolve(void 0))])}function Hy(t,e,r){let n=a=>{t.cancel(a).catch(()=>{})};return e.on("close",n),e.on("error",n),(r??t.read()).then(i,o),t.closed.finally(()=>{e.off("close",n),e.off("error",n)});function o(a){a&&e.destroy(a)}function s(){t.read().then(i,o)}function i({done:a,value:c}){try{if(a)e.end();else if(!e.write(c))e.once("drain",s);else return t.read().then(i,o)}catch(u){o(u)}}}function aE(t,e){if(t.locked)throw new TypeError("ReadableStream is locked.");return e.destroyed?void 0:Hy(t.getReader(),e)}var Cd=t=>{let e={};t instanceof Headers||(t=new Headers(t??void 0));let r=[];for(let[n,o]of t)n==="set-cookie"?r.push(o):e[n]=o;return r.length>0&&(e["set-cookie"]=r),e["content-type"]??="text/plain; charset=UTF-8",e},cE="x-hono-already-sent";typeof global.crypto>"u"&&(global.crypto=uE);var jd=Symbol("outgoingEnded"),Ly=Symbol("incomingDraining"),lE=500,dE=64*1024*1024,Rd=t=>{let e=t;if(t.destroyed||e[Ly])return;if(e[Ly]=!0,t instanceof Uy){try{t.stream?.close?.(YI.NGHTTP2_NO_ERROR)}catch{}return}let r=0,n=()=>{clearTimeout(s),t.off("data",i),t.off("end",n),t.off("error",n)},o=()=>{n();let a=t.socket;a&&!a.destroyed&&a.destroySoon()},s=setTimeout(o,lE);s.unref?.();let i=a=>{r+=a.length,r>dE&&o()};t.on("data",i),t.on("end",n),t.on("error",n),t.resume()},pE=()=>new Response(null,{status:400}),By=t=>new Response(null,{status:t instanceof Error&&(t.name==="TimeoutError"||t.constructor.name==="TimeoutError")?504:500}),Zd=(t,e)=>{let r=t instanceof Error?t:new Error("unknown error",{cause:t});r.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(t),e.headersSent||e.writeHead(500,{"Content-Type":"text/plain"}),e.end(`Error: ${r.message}`),e.destroy(r))},Jy=t=>{"flushHeaders"in t&&t.writable&&t.flushHeaders()},Ky=async(t,e)=>{let[r,n,o]=t[qr],s=!1;if(!o)o={"content-type":"text/plain; charset=UTF-8"};else if(o instanceof Headers)s=o.has("content-length"),o=Cd(o);else if(Array.isArray(o)){let i=new Headers(o);s=i.has("content-length"),o=Cd(i)}else for(let i in o)if(i.length===14&&i.toLowerCase()==="content-length"){s=!0;break}s||(typeof n=="string"?o["Content-Length"]=Buffer.byteLength(n):n instanceof Uint8Array?o["Content-Length"]=n.byteLength:n instanceof Blob&&(o["Content-Length"]=n.size)),e.writeHead(r,o),typeof n=="string"||n instanceof Uint8Array?e.end(n):n instanceof Blob?e.end(new Uint8Array(await n.arrayBuffer())):(Jy(e),await aE(n,e)?.catch(i=>Zd(i,e))),e[jd]?.()},fE=t=>typeof t.then=="function",mE=async(t,e,r={})=>{if(fE(t))if(r.errorHandler)try{t=await t}catch(o){let s=await r.errorHandler(o);if(!s)return;t=s}else t=await t.catch(By);if(qr in t)return Ky(t,e);let n=Cd(t.headers);if(t.body){let o=t.body.getReader(),s=[],i=!1,a;if(n["transfer-encoding"]!=="chunked"){let c=2;for(let u=0;u<c;u++){a||=o.read();let l=await iE(a).catch(p=>{console.error(p),i=!0});if(!l){if(u===1){await new Promise(p=>setTimeout(p)),c=3;continue}break}if(a=void 0,l.value&&s.push(l.value),l.done){i=!0;break}}i&&!("content-length"in n)&&(n["content-length"]=s.reduce((u,l)=>u+l.length,0))}e.writeHead(t.status,n),s.forEach(c=>{e.write(c)}),i?e.end():(s.length===0&&Jy(e),await Hy(o,e,a))}else n[cE]||(e.writeHead(t.status,n),e.end());e[jd]?.()},Ad=(t,e={})=>{let r=e.autoCleanupIncoming??!0;return e.overrideGlobalObjects!==!1&&global.Request!==qo&&(Object.defineProperty(global,"Request",{value:qo}),Object.defineProperty(global,"Response",{value:Lo})),async(n,o)=>{let s,i;try{i=sE(n,e.hostname);let a=!r||n.method==="GET"||n.method==="HEAD";if(a||(n[Vy]=!0,n.on("end",()=>{a=!0}),n instanceof Uy&&(o[jd]=()=>{a||setTimeout(()=>{a||setTimeout(()=>{Rd(n)})})}),o.on("finish",()=>{a||Rd(n)})),o.on("close",()=>{i[In]&&(n.errored?i[In].abort(n.errored.toString()):o.writableFinished||i[In].abort("Client connection prematurely closed.")),a||setTimeout(()=>{a||setTimeout(()=>{Rd(n)})})}),s=t(i,{incoming:n,outgoing:o}),qr in s)return Ky(s,o)}catch(a){if(s)return Zd(a,o);if(e.errorHandler){if(s=await e.errorHandler(i?a:XI(a)),!s)return}else i?s=By(a):s=pE()}try{return await mE(s,o,e)}catch(a){return Zd(a,o)}}};d();var qi=class{constructor(e={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval}async start(){if(this._started)throw new Error("Transport already started");this._started=!0}createJsonErrorResponse(e,r,n,o){let s={code:r,message:n};return o?.data!==void 0&&(s.data=o.data),new Response(JSON.stringify({jsonrpc:"2.0",error:s,id:null}),{status:e,headers:{"Content-Type":"application/json",...o?.headers}})}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let r=e.headers.get("host");if(!r||!this._allowedHosts.includes(r)){let n=`Invalid Host header: ${r}`;return this.onerror?.(new Error(n)),this.createJsonErrorResponse(403,-32e3,n)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let r=e.headers.get("origin");if(r&&!this._allowedOrigins.includes(r)){let n=`Invalid Origin header: ${r}`;return this.onerror?.(new Error(n)),this.createJsonErrorResponse(403,-32e3,n)}}}}async handleRequest(e,r){if(!this.sessionIdGenerator&&this._hasHandledRequest)throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let n=this.validateRequestHeaders(e);if(n)return n;switch(e.method){case"POST":return this.handlePostRequest(e,r);case"GET":return this.handleGetRequest(e);case"DELETE":return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(e,r,n,o){if(!this._eventStore||o<"2025-11-25")return;let s=await this._eventStore.storeEvent(n,{}),i=`id: ${s}
|
|
505
|
+
`;var Sy=(0,Ty.createMcpLogger)({name:"@toolcairn/mcp-server:write-tracker"}),gI=750,xd=new Map;async function Do(t){try{let e=up(t);await pI(e,{recursive:!0});let r=await dp(t).catch(()=>[]),n=$y({rootName:mI(t)||t,entries:r});await fI(hI(e,"tracker.html"),n,"utf-8"),Sy.debug({projectRoot:t,entryCount:r.length},"tracker.html written with embedded audit data")}catch(e){Sy.debug({err:e,projectRoot:t},"tracker.html write skipped (non-fatal)")}}function zy(t){let e=xd.get(t);e&&clearTimeout(e);let r=setTimeout(()=>{xd.delete(t),Do(t)},gI);typeof r.unref=="function"&&r.unref(),xd.set(t,r)}var kd=(0,Py.createMcpLogger)({name:"@toolcairn/mcp-server:project-setup"});function wI(){let t=yI();return{platform:t,label:{win32:"Windows",darwin:"macOS",linux:"Linux",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"Solaris",android:"Android"}[t]??vI()}}async function Iy(t=process.cwd()){let e=wI();kd.info({os:e.label,platform:e.platform,projectRoot:t},"Detected OS \u2014 starting project setup");let r=bI(t,".toolcairn");try{await _I(r,{recursive:!0}),await Do(t),kd.info({dir:r,os:e.label},".toolcairn tracker ready")}catch(n){kd.warn({err:n,dir:r,os:e.label},"tracker.html setup failed \u2014 continuing (config.json still bootstrapped by handlers)")}}d();var Pd=Me(Tn(),1),Oi=Me(or(),1);d();var Ry=Me(or(),1);import{existsSync as Ey}from"fs";import{dirname as xI,isAbsolute as kI,join as $I,resolve as SI}from"path";var Td=(0,Ry.createMcpLogger)({name:"@toolcairn/mcp-server:audit-logger"}),$d=new Map,TI=6e4,zI=5e3,PI=new Set(["search_tools","search_tools_respond","get_stack","refine_requirement"]),II=new Set(["feedback"]),EI=new Set([]);function Cy(t,e){return async r=>{let n=Date.now(),o,s="ok",i;try{o=await e(r),o.isError&&(s="error")}catch(c){s="error",i=c}let a=Date.now()-n;if(o&&s==="ok"&&PI.has(t)&&(o=DI(o,t)),o&&!II.has(t)&&(o=UI(o,t)),!EI.has(t)){let c=RI(r);if(c){let u=CI({toolName:t,args:r,result:o,status:s,duration_ms:a});lp(c,u).then(()=>{zy(c)}).catch(l=>{Td.debug({err:l,toolName:t,projectRoot:c},"audit-log: append failed (non-fatal)")})}}if(i!==void 0)throw i;return o??{content:[],isError:!0}}}function RI(t){let e=t.project_root;return typeof e=="string"&&e.length>0?kI(e)?Ey(e)?e:(Td.warn({project_root:e},"rejected non-existent project_root \u2014 falling back to cwd walk"),Sd(process.cwd())):(Td.warn({project_root:e},"rejected non-absolute project_root \u2014 falling back to cwd walk"),Sd(process.cwd())):Sd(process.cwd())}function Sd(t){let e=Date.now(),r=$d.get(t);if(r&&r.expiresAt>e)return r.value;let n=SI(t);for(;;){if(Ey($I(n,".toolcairn","config.json")))return $d.set(t,{value:n,expiresAt:e+TI}),n;let o=xI(n);if(o===n)return $d.set(t,{value:null,expiresAt:e+zI}),null;n=o}}function CI(t){let{toolName:e,args:r,result:n,status:o,duration_ms:s}=t,i=typeof r.query_id=="string"?r.query_id:void 0,a=n?VI(n):void 0,c=typeof a?.query_id=="string"?a.query_id:void 0,u=i??c,l=ZI(e,r,a),p=OI(e,r),m=jI(e,r),h=AI(e,a),f=NI(e,r,a),_=MI(e,r,o),w={action:"tool_call",tool:l,timestamp:new Date().toISOString(),reason:_,mcp_tool:e,duration_ms:s,status:o};return u&&(w.query_id=u),p&&(w.outcome=p),m&&(w.replaced_by=m),h&&h.length>0&&(w.candidates=h),f&&Object.keys(f).length>0&&(w.metadata=f),w}function ZI(t,e,r){return t==="report_outcome"&&typeof e.chosen_tool=="string"?e.chosen_tool:(t==="check_compatibility"||t==="compare_tools")&&typeof e.tool_a=="string"&&typeof e.tool_b=="string"?`${e.tool_a}|${e.tool_b}`:t==="check_issue"&&typeof e.tool_name=="string"?e.tool_name:t==="verify_suggestion"&&Array.isArray(r?.verified)?"__verify__":t==="update_project_config"&&typeof e.tool_name=="string"?e.tool_name:`__call__:${t}`}function OI(t,e){if(t!=="report_outcome")return;let r=e.outcome;if(r==="success"||r==="failure"||r==="replaced"||r==="pending")return r}function jI(t,e){if(t==="report_outcome")return typeof e.replaced_by=="string"?e.replaced_by:void 0}function AI(t,e){if(e){if(t==="search_tools"||t==="search_tools_respond"){let r=e.results;if(Array.isArray(r)){let n=r.map(o=>o&&typeof o=="object"?o.name:void 0).filter(o=>typeof o=="string").slice(0,5);return n.length>0?n:void 0}}if(t==="get_stack"){let r=e.stack;if(Array.isArray(r)){let n=r.map(o=>o&&typeof o=="object"?o.name:void 0).filter(o=>typeof o=="string").slice(0,10);return n.length>0?n:void 0}}}}function NI(t,e,r){let n={};return typeof e.query=="string"&&(n.query=Zi(e.query,200)),typeof e.use_case=="string"&&(n.use_case=Zi(e.use_case,200)),typeof e.action=="string"&&(n.config_action=e.action),typeof e.agent=="string"&&(n.agent=e.agent),r&&(typeof r.status=="string"&&(n.response_status=r.status),typeof r.stage=="number"&&(n.stage=r.stage),typeof r.is_two_option=="boolean"&&(n.is_two_option=r.is_two_option),typeof r.compatibility_signal=="string"&&(n.compatibility_signal=r.compatibility_signal),typeof r.recommendation=="string"&&(n.recommendation=r.recommendation),typeof r.staged=="number"&&(n.staged=r.staged)),n}function MI(t,e,r){if(r==="error")return`MCP tool ${t} failed`;if(t==="report_outcome"&&typeof e.outcome=="string")return`report_outcome: ${typeof e.chosen_tool=="string"?e.chosen_tool:"?"} \u2192 ${e.outcome}`;if(t==="search_tools"&&typeof e.query=="string")return`search_tools: ${Zi(e.query,120)}`;if(t==="get_stack"&&typeof e.use_case=="string")return`get_stack: ${Zi(e.use_case,120)}`;if(t==="update_project_config"&&typeof e.action=="string"){let n=typeof e.tool_name=="string"?` ${e.tool_name}`:"";return`update_project_config: ${e.action}${n}`}return`MCP tool ${t}`}function Zi(t,e){return t.length<=e?t:`${t.slice(0,e-1)}\u2026`}function DI(t,e){try{let r=t.content?.[0];if(!r||r.type!=="text")return t;let n=JSON.parse(r.text),o=n.data??void 0;if(!o)return t;let s=typeof o.query_id=="string"?o.query_id:void 0;return!s||typeof o.next_action=="string"&&o.next_action.length>0?t:(o.next_action=qI(e,s),n.data=o,{...t,content:[{type:"text",text:JSON.stringify(n)}]})}catch{return t}}function qI(t,e){return t==="refine_requirement"?`Use the decomposition to call get_stack or search_tools (passing query_id="${e}"); after the user actually uses the chosen tool, call report_outcome({ query_id: "${e}", chosen_tool, outcome }).`:`After the user actually uses one of the suggested tools (or replaces it), call report_outcome({ query_id: "${e}", chosen_tool, outcome }) to close the feedback loop.`}var LI="If this response was wrong/broken/low-quality, call feedback({ tool_name, severity, message, query_id }) \u2014 severity \u2208 {broken|wrong_result|low_quality|missing_capability|confusing}. Skip if the response was useful \u2014 feedback is for problems only, and free of daily quota.";function UI(t,e){try{let r=t.content?.[0];if(!r||r.type!=="text")return t;let n;try{n=JSON.parse(r.text)}catch{return t}if(!n||typeof n!="object")return t;let o=n.data,s=o&&typeof o=="object"?o:{};return typeof s.feedback_channel=="string"&&s.feedback_channel.length>0?t:(s.feedback_channel=LI,s.feedback_about_tool=e,n.data=s,{...t,content:[{type:"text",text:JSON.stringify(n)}]})}catch{return t}}function VI(t){try{let e=t.content?.[0];if(!e||e.type!=="text")return;let n=JSON.parse(e.text).data;return n&&typeof n=="object"?n:void 0}catch{return}}d();var Zy=Me(Tn(),1),Oy=Me(or(),1);import{appendFile as FI,mkdir as HI}from"fs/promises";import{dirname as BI}from"path";var jy=(0,Oy.createMcpLogger)({name:"@toolcairn/mcp-server:event-logger"});function JI(){return process.env.TOOLCAIRN_TRACKING_ENABLED!=="false"}function KI(){return process.env.TOOLCAIRN_EVENTS_PATH??null}function GI(t){return typeof t.query_id=="string"?t.query_id:null}function WI(t,e){try{let r=e.content?.[0];if(r?.type!=="text")return null;let o=JSON.parse(r.text).data,s={tool:t};return o&&("status"in o&&(s.status=o.status),"total_confirmed"in o&&(s.total_confirmed=o.total_confirmed),"staged"in o&&(s.staged=o.staged),"auto_graduated"in o&&(s.auto_graduated=o.auto_graduated),"is_two_option"in o&&(s.is_two_option=o.is_two_option),"non_indexed_guidance"in o&&(s.had_non_indexed_guidance=!0),"credibility_warning"in o&&(s.had_credibility_warning=!0),"deprecation_warning"in o&&o.deprecation_warning&&(s.had_deprecation_warning=!0),"recommendation"in o&&(s.recommendation=o.recommendation),"compatibility_signal"in o&&(s.compatibility_signal=o.compatibility_signal),"index_queued"in o&&(s.index_queued=o.index_queued)),s}catch{return null}}async function YI(t,e){try{await HI(BI(t),{recursive:!0}),await FI(t,`${JSON.stringify(e)}
|
|
506
|
+
`,"utf-8")}catch(r){jy.warn({err:r,path:t},"Failed to write event to JSONL file")}}async function XI(t){try{let e=await Tt();if(!e)return;let r={"Content-Type":"application/json"};e.access_token&&(r.Authorization=`Bearer ${e.access_token}`),e.client_id&&(r["X-ToolCairn-Key"]=e.client_id),await fetch(`${Zy.config.TOOLPILOT_API_URL}/v1/events`,{method:"POST",headers:r,body:JSON.stringify({tool_name:t.tool_name,query_id:t.query_id,duration_ms:t.duration_ms,status:t.status,metadata:t.metadata})})}catch(e){jy.debug({err:e},"Failed to send event to API \u2014 non-fatal")}}function Ay(t,e){return async r=>{if(!JI())return e(r);let n=Date.now(),o,s="ok";try{o=await e(r),o.isError&&(s="error")}catch(i){throw s="error",i}finally{let i=Date.now()-n,a={id:crypto.randomUUID(),tool_name:t,query_id:GI(r),duration_ms:i,status:s,metadata:o?WI(t,o):null,created_at:new Date().toISOString()};XI(a).catch(()=>{});let c=KI();c&&YI(c,a).catch(()=>{})}return o??{content:[],isError:!0}}}var zd=(0,Oi.createMcpLogger)({name:"@toolcairn/mcp-server:prod"}),QI='\n# ToolCairn \u2014 Agent Setup Instructions\n\nYou are connected to the ToolCairn MCP server. ToolCairn is your active tool intelligence co-pilot.\n\n## The Server Owns .toolcairn/ (v0.10.0+)\n\nThe MCP server reads and writes `.toolcairn/config.json` + `.toolcairn/audit-log.jsonl`\natomically under a cross-process lock. You never touch those files directly.\n\n## On Every Session Start \u2014 Do This First\n\nCall `read_project_config` with `project_root` (absolute path to the user\'s project).\n\nIn most sessions config is already there: when the user ran `toolcairn_auth` the\nserver auto-discovered every project root under its CWD and ran the full 12-ecosystem\nscan + graph classification + config write for each. The auth response carried back\nper-root `projects[]` entries with `setup_steps` (CLAUDE.md / .mcp.json / .gitignore)\nand `unknown_tools[]`.\n\n- If `read_project_config` returns `status: "not_initialized"` for some root\n (rare \u2014 only when auto-init skipped that root): call `toolcairn_init` explicitly\n for that `project_root`.\n- If it returns `status: "ready"`: you have the full snapshot \u2014 review\n `stale_tools` / `pending_tools` / `unknown_tools` and proceed.\n\n## First-Turn Drain Protocol (REQUIRED before replying to the user)\n\nIf the auth response OR `read_project_config` returned non-empty `unknown_tools[]`\nfor a root, you MUST submit them before your first user-facing response:\n\n1. `suggest_graph_update` with `suggestion_type: "new_tool"` and\n `data.tools: <the full unknown_tools array for that root>`. Entries are STAGED\n for admin review \u2014 they do NOT enter the live graph until approved.\n2. `update_project_config` with `action: "mark_suggestions_sent"`,\n `project_root`, and `data.tool_names: [names that staged successfully]`.\n\nIn multi-root workspaces, repeat per root. This closes the learning loop so every\nproject contributes its OSS dependency tail back to the ToolCairn graph.\n\n## Applying Mutations\n\nWhen the user selects / replaces / drops a tool, call `update_project_config`\nwith `project_root`, `action` (add_tool / remove_tool / update_tool / add_evaluation),\nand `tool_name`. The server:\n- atomically updates `.toolcairn/config.json`,\n- appends a new line to `.toolcairn/audit-log.jsonl` (FIFO-archived at 1000 entries),\n- returns the new `last_audit_entry` for your record.\n\nDo NOT construct or write these files yourself \u2014 you do not have the cross-process\nlock that protects them.\n\n## Schema Migration\n\nConfigs written by v0.9.x are on schema 1.0. The first `read_project_config` or\n`update_project_config` call after upgrade migrates in place to 1.1 (languages \u2192\narray, frameworks \u2192 array, `audit_log[]` relocated from config.json to\naudit-log.jsonl). The migration is logged as an audit entry.\n\n## When to Use ToolCairn Tools\n\n| Situation | Tool to call |\n|-----------|-------------|\n| User asks which tool to use for X | `classify_prompt` \u2192 `refine_requirement` \u2192 `search_tools` |\n| User needs to compare two tools | `compare_tools` |\n| User asks if tool A works with tool B | `check_compatibility` |\n| Error persists after 4+ retries AND docs checked | `check_issue` |\n| User asks for a recommended stack | `get_stack` |\n| search_tools returns empty or low confidence | `verify_suggestion` |\n| You discover a new tool relationship | `suggest_graph_update` |\n| A tool worked well or was replaced | `report_outcome` |\n| Tool added/removed from project | `update_project_config` |\n'.trim();async function Id(t){let e=await Tt();if(!e||!Cn(e))throw new Error("ToolCairn: authentication required.");let r=new Uo({baseUrl:Pd.config.TOOLPILOT_API_URL,apiKey:e.client_id,accessToken:e.access_token});zd.info({user:e.user_email},"Registering production tools");function n(o,s){return Ay(o,Cy(o,(0,Oi.withErrorHandling)(o,zd,s)))}t.registerTool("classify_prompt",{description:"Classify a developer prompt to determine if ToolCairn tool search is needed. Returns a structured classification prompt for the agent to evaluate.",inputSchema:op},n("classify_prompt",async o=>cp(o))),t.registerTool("toolcairn_init",{description:"Bootstrap ToolCairn for the current project. Walks every workspace, parses manifests across 12 ecosystems, classifies tools against the ToolCairn graph, and writes .toolcairn/config.json + audit-log.jsonl atomically. Returns setup_steps for CLAUDE.md / .mcp.json / .gitignore (agent applies those).",inputSchema:tp},n("toolcairn_init",async o=>gp(o,{batchResolve:s=>r.batchResolve(s)}))),t.registerTool("read_project_config",{description:"Read .toolcairn/config.json from disk and return the structured project snapshot: project metadata, confirmed tools, stale tools, pending evaluations, and last audit entry. Auto-migrates v1.0 configs to v1.1 on first read.",inputSchema:rp},n("read_project_config",async o=>_p(o))),t.registerTool("update_project_config",{description:"Apply a mutation to .toolcairn/config.json (add_tool / remove_tool / update_tool / add_evaluation). The server atomically rewrites config.json and appends a new line to audit-log.jsonl under a cross-process lock. Requires project_root.",inputSchema:np},n("update_project_config",async o=>yp(o))),t.registerTool("search_tools",{description:"Search for the best tool for a specific need using a natural language query. Initiates a guided discovery session with clarification questions when needed.",inputSchema:Jd},n("search_tools",async o=>r.searchTools(o))),t.registerTool("search_tools_respond",{description:"Submit clarification answers for an in-progress tool search session and receive refined results.",inputSchema:Kd},n("search_tools_respond",async o=>r.searchToolsRespond(o))),t.registerTool("get_stack",{description:'Build a complementary tool stack for a project use case. For best results, call refine_requirement first with classification "stack_building", evaluate its decomposition_prompt to get sub-needs, then pass each {sub_need_type, keyword_sentence} object as a sub_needs entry. This lets get_stack keyword-match per layer (e.g. "web-framework", "database", "auth") instead of one broad search. Falls back to balanced search when sub_needs is omitted. Each tool in the returned stack also carries a `version` object with the recommended version that is cross-compatible with the rest of the stack (downgraded from latest if needed to satisfy peer constraints), plus a top-level `compatibility_matrix` + `stack_compatibility` summarising cross-tool version fit.',inputSchema:Wd},n("get_stack",async o=>r.getStack(o))),t.registerTool("check_compatibility",{description:'Check compatibility between two tools with version-aware matching. When both tools have declared dependency metadata (npm peerDependencies, PyPI requires_dist, etc.) the handler evaluates range constraints directly and returns a version_checks array plus runtime_requirements. Pass optional tool_a_version / tool_b_version to evaluate specific versions (e.g. "is next@14 compatible with react@17?"). Falls back to graph-edge + shared-neighbors inference when version metadata is unavailable. Response includes `source`: "declared_dependency" | "graph_edges" | "shared_neighbors".',inputSchema:Xd},n("check_compatibility",async o=>r.checkCompatibility(o))),t.registerTool("compare_tools",{description:"Compare two tools head-to-head using health signals, graph relationships, and community data.",inputSchema:ep},n("compare_tools",async o=>r.compareTools(o))),t.registerTool("refine_requirement",{description:"Decompose a vague user use-case into specific, searchable tool requirements.",inputSchema:ip},n("refine_requirement",async o=>r.refineRequirement(o))),t.registerTool("check_issue",{description:"LAST RESORT \u2014 check GitHub Issues for a known error after 4+ retries and docs review.",inputSchema:Yd},n("check_issue",async o=>r.checkIssue(o))),t.registerTool("verify_suggestion",{description:"Validate agent-suggested tools against the ToolCairn graph.",inputSchema:sp},n("verify_suggestion",async o=>r.verifySuggestion(o))),t.registerTool("report_outcome",{description:"Report the outcome of using a tool recommended by ToolCairn (fire-and-forget).",inputSchema:Gd},n("report_outcome",async o=>r.reportOutcome(o))),t.registerTool("suggest_graph_update",{description:"Suggest a new tool, relationship, use case, or health update to the ToolCairn graph.",inputSchema:Qd},n("suggest_graph_update",async o=>r.suggestGraphUpdate(o))),t.registerTool("feedback",{description:"ONLY call when a ToolCairn response was wrong, broken, low-quality, or missed something obvious \u2014 NEVER for positive feedback or routine confirmation. Free (does not count toward daily quota), but spammy or duplicate calls are dropped server-side. Required: tool_name (which ToolCairn tool), severity (broken|wrong_result|low_quality|missing_capability|confusing), message (>=20 chars). Optional: query_id (link to the offending call), expected, actual. Fire-and-forget \u2014 do not await; the return value is just an ack.",inputSchema:ap},n("feedback",async o=>r.feedback(o))),t.registerTool("toolcairn_auth",{description:'Manage your ToolCairn authentication. Use "login" to authenticate via browser (unlocks higher rate limits), "status" to check current auth state, or "logout" to revert to anonymous mode.',inputSchema:Ur.object({action:Ur.enum(["login","status","logout"]).describe('"login" opens a browser to authenticate, "status" shows current auth state, "logout" clears authentication')})},n("toolcairn_auth",async o=>{let s=o.action;if(s==="status"){let i=await Tt(),a=i!==null&&Cn(i);return{content:[{type:"text",text:JSON.stringify({authenticated:a,user_email:i?.user_email??null,user_name:i?.user_name??null,authenticated_at:i?.authenticated_at??null})}]}}if(s==="logout")return await Hd(),{content:[{type:"text",text:JSON.stringify({ok:!0,message:"Signed out. Restart your agent to sign in again \u2014 authentication will start automatically."})}]};try{let i=await Vo(Pd.config.TOOLPILOT_API_URL),a=await zn({agent:"claude"}).catch(c=>(zd.warn({err:c},"runPostAuthInit failed post-login \u2014 auth still succeeds"),null));return{content:[{type:"text",text:JSON.stringify({ok:!0,message:`Successfully authenticated as ${i.email}. All tools are now authorized.`,user_email:i.email,user_name:i.name,roots_discovered:a?.roots_discovered??[],projects:a?.projects??[],unknown_tools_total:a?.unknown_tools_total??0,first_turn_directive:a?.first_turn_directive??""})}]}}catch(i){let a=i instanceof Error?i.message:"Authentication failed";return{content:[{type:"text",text:JSON.stringify({ok:!1,error:a})}],isError:!0}}}))}async function Ny(){let t=new yn({name:"toolcairn",version:"0.1.0"},{instructions:QI});return await Id(t),t}d();d();import Dy from"process";d();var ji=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
507
|
+
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),eE(r)}clear(){this._buffer=void 0}};function eE(t){return Kn.parse(JSON.parse(t))}function My(t){return JSON.stringify(t)+`
|
|
508
|
+
`}var Ai=class{constructor(e=Dy.stdin,r=Dy.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new ji,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=My(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};d();d();import{Http2ServerRequest as Vy,constants as tE}from"http2";import{Http2ServerRequest as Ed}from"http2";import{Readable as qy}from"stream";import fE from"crypto";var Dr=class extends Error{constructor(t,e){super(t,e),this.name="RequestError"}},rE=t=>t instanceof Dr?t:new Dr(t.message,{cause:t}),nE=global.Request,qo=class extends nE{constructor(t,e){typeof t=="object"&&En in t&&(t=t[En]()),typeof e?.body?.getReader<"u"&&(e.duplex??="half"),super(t,e)}},oE=t=>{let e=[],r=t.rawHeaders;for(let n=0;n<r.length;n+=2){let{[n]:o,[n+1]:s}=r;o.charCodeAt(0)!==58&&e.push([o,s])}return new Headers(e)},Fy=Symbol("wrapBodyStream"),sE=(t,e,r,n,o)=>{let s={method:t,headers:r,signal:o.signal};if(t==="TRACE"){s.method="GET";let i=new qo(e,s);return Object.defineProperty(i,"method",{get(){return"TRACE"}}),i}if(!(t==="GET"||t==="HEAD"))if("rawBody"in n&&n.rawBody instanceof Buffer)s.body=new ReadableStream({start(i){i.enqueue(n.rawBody),i.close()}});else if(n[Fy]){let i;s.body=new ReadableStream({async pull(a){try{i||=qy.toWeb(n).getReader();let{done:c,value:u}=await i.read();c?a.close():a.enqueue(u)}catch(c){a.error(c)}}})}else s.body=qy.toWeb(n);return new qo(e,s)},En=Symbol("getRequestCache"),iE=Symbol("requestCache"),Ni=Symbol("incomingKey"),Mi=Symbol("urlKey"),aE=Symbol("headersKey"),In=Symbol("abortControllerKey"),cE=Symbol("getAbortController"),Di={get method(){return this[Ni].method||"GET"},get url(){return this[Mi]},get headers(){return this[aE]||=oE(this[Ni])},[cE](){return this[En](),this[In]},[En](){return this[In]||=new AbortController,this[iE]||=sE(this.method,this[Mi],this.headers,this[Ni],this[In])}};["body","bodyUsed","cache","credentials","destination","integrity","mode","redirect","referrer","referrerPolicy","signal","keepalive"].forEach(t=>{Object.defineProperty(Di,t,{get(){return this[En]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(Di,t,{value:function(){return this[En]()[t]()}})});Object.setPrototypeOf(Di,qo.prototype);var uE=(t,e)=>{let r=Object.create(Di);r[Ni]=t;let n=t.url||"";if(n[0]!=="/"&&(n.startsWith("http://")||n.startsWith("https://"))){if(t instanceof Ed)throw new Dr("Absolute URL for :path is not allowed in HTTP/2");try{let a=new URL(n);r[Mi]=a.href}catch(a){throw new Dr("Invalid absolute URL",{cause:a})}return r}let o=(t instanceof Ed?t.authority:t.headers.host)||e;if(!o)throw new Dr("Missing host header");let s;if(t instanceof Ed){if(s=t.scheme,!(s==="http"||s==="https"))throw new Dr("Unsupported scheme")}else s=t.socket&&t.socket.encrypted?"https":"http";let i=new URL(`${s}://${o}${n}`);if(i.hostname.length!==o.length&&i.hostname!==o.replace(/:\d+$/,""))throw new Dr("Invalid host header");return r[Mi]=i.href,r},Ly=Symbol("responseCache"),Pn=Symbol("getResponseCache"),qr=Symbol("cache"),Od=global.Response,Lo=class Hy{#t;#e;[Pn](){return delete this[qr],this[Ly]||=new Od(this.#t,this.#e)}constructor(e,r){let n;if(this.#t=e,r instanceof Hy){let o=r[Ly];if(o){this.#e=o,this[Pn]();return}else this.#e=r.#e,n=new Headers(r.#e.headers)}else this.#e=r;(typeof e=="string"||typeof e?.getReader<"u"||e instanceof Blob||e instanceof Uint8Array)&&(this[qr]=[r?.status||200,e,n||r?.headers])}get headers(){let e=this[qr];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":"text/plain; charset=UTF-8"})),e[2]):this[Pn]().headers}get status(){return this[qr]?.[0]??this[Pn]().status}get ok(){let e=this.status;return e>=200&&e<300}};["body","bodyUsed","redirected","statusText","trailers","type","url"].forEach(t=>{Object.defineProperty(Lo.prototype,t,{get(){return this[Pn]()[t]}})});["arrayBuffer","blob","clone","formData","json","text"].forEach(t=>{Object.defineProperty(Lo.prototype,t,{value:function(){return this[Pn]()[t]()}})});Object.setPrototypeOf(Lo,Od);Object.setPrototypeOf(Lo.prototype,Od.prototype);async function lE(t){return Promise.race([t,Promise.resolve().then(()=>Promise.resolve(void 0))])}function By(t,e,r){let n=a=>{t.cancel(a).catch(()=>{})};return e.on("close",n),e.on("error",n),(r??t.read()).then(i,o),t.closed.finally(()=>{e.off("close",n),e.off("error",n)});function o(a){a&&e.destroy(a)}function s(){t.read().then(i,o)}function i({done:a,value:c}){try{if(a)e.end();else if(!e.write(c))e.once("drain",s);else return t.read().then(i,o)}catch(u){o(u)}}}function dE(t,e){if(t.locked)throw new TypeError("ReadableStream is locked.");return e.destroyed?void 0:By(t.getReader(),e)}var Cd=t=>{let e={};t instanceof Headers||(t=new Headers(t??void 0));let r=[];for(let[n,o]of t)n==="set-cookie"?r.push(o):e[n]=o;return r.length>0&&(e["set-cookie"]=r),e["content-type"]??="text/plain; charset=UTF-8",e},pE="x-hono-already-sent";typeof global.crypto>"u"&&(global.crypto=fE);var jd=Symbol("outgoingEnded"),Uy=Symbol("incomingDraining"),mE=500,hE=64*1024*1024,Rd=t=>{let e=t;if(t.destroyed||e[Uy])return;if(e[Uy]=!0,t instanceof Vy){try{t.stream?.close?.(tE.NGHTTP2_NO_ERROR)}catch{}return}let r=0,n=()=>{clearTimeout(s),t.off("data",i),t.off("end",n),t.off("error",n)},o=()=>{n();let a=t.socket;a&&!a.destroyed&&a.destroySoon()},s=setTimeout(o,mE);s.unref?.();let i=a=>{r+=a.length,r>hE&&o()};t.on("data",i),t.on("end",n),t.on("error",n),t.resume()},gE=()=>new Response(null,{status:400}),Jy=t=>new Response(null,{status:t instanceof Error&&(t.name==="TimeoutError"||t.constructor.name==="TimeoutError")?504:500}),Zd=(t,e)=>{let r=t instanceof Error?t:new Error("unknown error",{cause:t});r.code==="ERR_STREAM_PREMATURE_CLOSE"?console.info("The user aborted a request."):(console.error(t),e.headersSent||e.writeHead(500,{"Content-Type":"text/plain"}),e.end(`Error: ${r.message}`),e.destroy(r))},Ky=t=>{"flushHeaders"in t&&t.writable&&t.flushHeaders()},Gy=async(t,e)=>{let[r,n,o]=t[qr],s=!1;if(!o)o={"content-type":"text/plain; charset=UTF-8"};else if(o instanceof Headers)s=o.has("content-length"),o=Cd(o);else if(Array.isArray(o)){let i=new Headers(o);s=i.has("content-length"),o=Cd(i)}else for(let i in o)if(i.length===14&&i.toLowerCase()==="content-length"){s=!0;break}s||(typeof n=="string"?o["Content-Length"]=Buffer.byteLength(n):n instanceof Uint8Array?o["Content-Length"]=n.byteLength:n instanceof Blob&&(o["Content-Length"]=n.size)),e.writeHead(r,o),typeof n=="string"||n instanceof Uint8Array?e.end(n):n instanceof Blob?e.end(new Uint8Array(await n.arrayBuffer())):(Ky(e),await dE(n,e)?.catch(i=>Zd(i,e))),e[jd]?.()},_E=t=>typeof t.then=="function",yE=async(t,e,r={})=>{if(_E(t))if(r.errorHandler)try{t=await t}catch(o){let s=await r.errorHandler(o);if(!s)return;t=s}else t=await t.catch(Jy);if(qr in t)return Gy(t,e);let n=Cd(t.headers);if(t.body){let o=t.body.getReader(),s=[],i=!1,a;if(n["transfer-encoding"]!=="chunked"){let c=2;for(let u=0;u<c;u++){a||=o.read();let l=await lE(a).catch(p=>{console.error(p),i=!0});if(!l){if(u===1){await new Promise(p=>setTimeout(p)),c=3;continue}break}if(a=void 0,l.value&&s.push(l.value),l.done){i=!0;break}}i&&!("content-length"in n)&&(n["content-length"]=s.reduce((u,l)=>u+l.length,0))}e.writeHead(t.status,n),s.forEach(c=>{e.write(c)}),i?e.end():(s.length===0&&Ky(e),await By(o,e,a))}else n[pE]||(e.writeHead(t.status,n),e.end());e[jd]?.()},Ad=(t,e={})=>{let r=e.autoCleanupIncoming??!0;return e.overrideGlobalObjects!==!1&&global.Request!==qo&&(Object.defineProperty(global,"Request",{value:qo}),Object.defineProperty(global,"Response",{value:Lo})),async(n,o)=>{let s,i;try{i=uE(n,e.hostname);let a=!r||n.method==="GET"||n.method==="HEAD";if(a||(n[Fy]=!0,n.on("end",()=>{a=!0}),n instanceof Vy&&(o[jd]=()=>{a||setTimeout(()=>{a||setTimeout(()=>{Rd(n)})})}),o.on("finish",()=>{a||Rd(n)})),o.on("close",()=>{i[In]&&(n.errored?i[In].abort(n.errored.toString()):o.writableFinished||i[In].abort("Client connection prematurely closed.")),a||setTimeout(()=>{a||setTimeout(()=>{Rd(n)})})}),s=t(i,{incoming:n,outgoing:o}),qr in s)return Gy(s,o)}catch(a){if(s)return Zd(a,o);if(e.errorHandler){if(s=await e.errorHandler(i?a:rE(a)),!s)return}else i?s=Jy(a):s=gE()}try{return await yE(s,o,e)}catch(a){return Zd(a,o)}}};d();var qi=class{constructor(e={}){this._started=!1,this._hasHandledRequest=!1,this._streamMapping=new Map,this._requestToStreamMapping=new Map,this._requestResponseMap=new Map,this._initialized=!1,this._enableJsonResponse=!1,this._standaloneSseStreamId="_GET_stream",this.sessionIdGenerator=e.sessionIdGenerator,this._enableJsonResponse=e.enableJsonResponse??!1,this._eventStore=e.eventStore,this._onsessioninitialized=e.onsessioninitialized,this._onsessionclosed=e.onsessionclosed,this._allowedHosts=e.allowedHosts,this._allowedOrigins=e.allowedOrigins,this._enableDnsRebindingProtection=e.enableDnsRebindingProtection??!1,this._retryInterval=e.retryInterval}async start(){if(this._started)throw new Error("Transport already started");this._started=!0}createJsonErrorResponse(e,r,n,o){let s={code:r,message:n};return o?.data!==void 0&&(s.data=o.data),new Response(JSON.stringify({jsonrpc:"2.0",error:s,id:null}),{status:e,headers:{"Content-Type":"application/json",...o?.headers}})}validateRequestHeaders(e){if(this._enableDnsRebindingProtection){if(this._allowedHosts&&this._allowedHosts.length>0){let r=e.headers.get("host");if(!r||!this._allowedHosts.includes(r)){let n=`Invalid Host header: ${r}`;return this.onerror?.(new Error(n)),this.createJsonErrorResponse(403,-32e3,n)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let r=e.headers.get("origin");if(r&&!this._allowedOrigins.includes(r)){let n=`Invalid Origin header: ${r}`;return this.onerror?.(new Error(n)),this.createJsonErrorResponse(403,-32e3,n)}}}}async handleRequest(e,r){if(!this.sessionIdGenerator&&this._hasHandledRequest)throw new Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let n=this.validateRequestHeaders(e);if(n)return n;switch(e.method){case"POST":return this.handlePostRequest(e,r);case"GET":return this.handleGetRequest(e);case"DELETE":return this.handleDeleteRequest(e);default:return this.handleUnsupportedRequest()}}async writePrimingEvent(e,r,n,o){if(!this._eventStore||o<"2025-11-25")return;let s=await this._eventStore.storeEvent(n,{}),i=`id: ${s}
|
|
509
509
|
data:
|
|
510
510
|
|
|
511
511
|
`;this._retryInterval!==void 0&&(i=`id: ${s}
|
|
@@ -516,7 +516,7 @@ data:
|
|
|
516
516
|
`;return o&&(s+=`id: ${o}
|
|
517
517
|
`),s+=`data: ${JSON.stringify(n)}
|
|
518
518
|
|
|
519
|
-
`,e.enqueue(r.encode(s)),!0}catch(s){return this.onerror?.(s),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,r){try{let n=e.headers.get("accept");if(!n?.includes("application/json")||!n.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let o=e.headers.get("content-type");if(!o||!o.includes("application/json"))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let s={headers:Object.fromEntries(e.headers.entries()),url:new URL(e.url)},i;if(r?.parsedBody!==void 0)i=r.parsedBody;else try{i=await e.json()}catch{return this.onerror?.(new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}let a;try{Array.isArray(i)?a=i.map(
|
|
519
|
+
`,e.enqueue(r.encode(s)),!0}catch(s){return this.onerror?.(s),!1}}handleUnsupportedRequest(){return this.onerror?.(new Error("Method not allowed.")),new Response(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}),{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(e,r){try{let n=e.headers.get("accept");if(!n?.includes("application/json")||!n.includes("text/event-stream"))return this.onerror?.(new Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32e3,"Not Acceptable: Client must accept both application/json and text/event-stream");let o=e.headers.get("content-type");if(!o||!o.includes("application/json"))return this.onerror?.(new Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32e3,"Unsupported Media Type: Content-Type must be application/json");let s={headers:Object.fromEntries(e.headers.entries()),url:new URL(e.url)},i;if(r?.parsedBody!==void 0)i=r.parsedBody;else try{i=await e.json()}catch{return this.onerror?.(new Error("Parse error: Invalid JSON")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}let a;try{Array.isArray(i)?a=i.map($=>Kn.parse($)):a=[Kn.parse(i)]}catch{return this.onerror?.(new Error("Parse error: Invalid JSON-RPC message")),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}let c=a.some(eu);if(c){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(new Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(a.length>1)return this.onerror?.(new Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized&&await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!c){let $=this.validateSession(e);if($)return $;let S=this.validateProtocolVersion(e);if(S)return S}if(!a.some(Ut)){for(let $ of a)this.onmessage?.($,{authInfo:r?.authInfo,requestInfo:s});return new Response(null,{status:202})}let l=crypto.randomUUID(),p=a.find($=>eu($)),m=p?p.params.protocolVersion:e.headers.get("mcp-protocol-version")??im;if(this._enableJsonResponse)return new Promise($=>{this._streamMapping.set(l,{resolveJson:$,cleanup:()=>{this._streamMapping.delete(l)}});for(let S of a)Ut(S)&&this._requestToStreamMapping.set(S.id,l);for(let S of a)this.onmessage?.(S,{authInfo:r?.authInfo,requestInfo:s})});let h=new TextEncoder,f,_=new ReadableStream({start:$=>{f=$},cancel:()=>{this._streamMapping.delete(l)}}),w={"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"};this.sessionId!==void 0&&(w["mcp-session-id"]=this.sessionId);for(let $ of a)Ut($)&&(this._streamMapping.set(l,{controller:f,encoder:h,cleanup:()=>{this._streamMapping.delete(l);try{f.close()}catch{}}}),this._requestToStreamMapping.set($.id,l));await this.writePrimingEvent(f,h,l,m);for(let $ of a){let S,T;Ut($)&&this._eventStore&&m>="2025-11-25"&&(S=()=>{this.closeSSEStream($.id)},T=()=>{this.closeStandaloneSSEStream()}),this.onmessage?.($,{authInfo:r?.authInfo,requestInfo:s,closeSSEStream:S,closeStandaloneSSEStream:T})}return new Response(_,{status:200,headers:w})}catch(n){return this.onerror?.(n),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(n)})}}async handleDeleteRequest(e){let r=this.validateSession(e);if(r)return r;let n=this.validateProtocolVersion(e);return n||(await Promise.resolve(this._onsessionclosed?.(this.sessionId)),await this.close(),new Response(null,{status:200}))}validateSession(e){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(new Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Server not initialized");let r=e.headers.get("mcp-session-id");if(!r)return this.onerror?.(new Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32e3,"Bad Request: Mcp-Session-Id header is required");if(r!==this.sessionId)return this.onerror?.(new Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(e){let r=e.headers.get("mcp-protocol-version");if(r!==null&&!Kr.includes(r))return this.onerror?.(new Error(`Bad Request: Unsupported protocol version: ${r} (supported versions: ${Kr.join(", ")})`)),this.createJsonErrorResponse(400,-32e3,`Bad Request: Unsupported protocol version: ${r} (supported versions: ${Kr.join(", ")})`)}async close(){this._streamMapping.forEach(({cleanup:e})=>{e()}),this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}closeSSEStream(e){let r=this._requestToStreamMapping.get(e);if(!r)return;let n=this._streamMapping.get(r);n&&n.cleanup()}closeStandaloneSSEStream(){let e=this._streamMapping.get(this._standaloneSseStreamId);e&&e.cleanup()}async send(e,r){let n=r?.relatedRequestId;if((Pt(e)||Gr(e))&&(n=e.id),n===void 0){if(Pt(e)||Gr(e))throw new Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let i;this._eventStore&&(i=await this._eventStore.storeEvent(this._standaloneSseStreamId,e));let a=this._streamMapping.get(this._standaloneSseStreamId);if(a===void 0)return;a.controller&&a.encoder&&this.writeSSEEvent(a.controller,a.encoder,e,i);return}let o=this._requestToStreamMapping.get(n);if(!o)throw new Error(`No connection established for request ID: ${String(n)}`);let s=this._streamMapping.get(o);if(!this._enableJsonResponse&&s?.controller&&s?.encoder){let i;this._eventStore&&(i=await this._eventStore.storeEvent(o,e)),this.writeSSEEvent(s.controller,s.encoder,e,i)}if(Pt(e)||Gr(e)){this._requestResponseMap.set(n,e);let i=Array.from(this._requestToStreamMapping.entries()).filter(([c,u])=>u===o).map(([c])=>c);if(i.every(c=>this._requestResponseMap.has(c))){if(!s)throw new Error(`No connection established for request ID: ${String(n)}`);if(this._enableJsonResponse&&s.resolveJson){let c={"Content-Type":"application/json"};this.sessionId!==void 0&&(c["mcp-session-id"]=this.sessionId);let u=i.map(l=>this._requestResponseMap.get(l));u.length===1?s.resolveJson(new Response(JSON.stringify(u[0]),{status:200,headers:c})):s.resolveJson(new Response(JSON.stringify(u),{status:200,headers:c}))}else s.cleanup();for(let c of i)this._requestResponseMap.delete(c),this._requestToStreamMapping.delete(c)}}}};var Li=class{constructor(e={}){this._requestContext=new WeakMap,this._webStandardTransport=new qi(e),this._requestListener=Ad(async r=>{let n=this._requestContext.get(r);return this._webStandardTransport.handleRequest(r,{authInfo:n?.authInfo,parsedBody:n?.parsedBody})},{overrideGlobalObjects:!1})}get sessionId(){return this._webStandardTransport.sessionId}set onclose(e){this._webStandardTransport.onclose=e}get onclose(){return this._webStandardTransport.onclose}set onerror(e){this._webStandardTransport.onerror=e}get onerror(){return this._webStandardTransport.onerror}set onmessage(e){this._webStandardTransport.onmessage=e}get onmessage(){return this._webStandardTransport.onmessage}async start(){return this._webStandardTransport.start()}async close(){return this._webStandardTransport.close()}async send(e,r){return this._webStandardTransport.send(e,r)}async handleRequest(e,r,n){let o=e.auth;await Ad(async i=>this._webStandardTransport.handleRequest(i,{authInfo:o,parsedBody:n}),{overrideGlobalObjects:!1})(e,r)}closeSSEStream(e){this._webStandardTransport.closeSSEStream(e)}closeStandaloneSSEStream(){this._webStandardTransport.closeStandaloneSSEStream()}};var vE=Me(Tn(),1);function Wy(){return process.env.MCP_TRANSPORT==="http"?new Li({sessionIdGenerator:()=>crypto.randomUUID()}):new Ai}process.env.TOOLPILOT_MODE="production";var Ne=(0,Md.createMcpLogger)({name:"@toolcairn/mcp-server"});async function bE(){await Iy();let t=await Tt(),e=t!==null&&Cn(t),r;if(e){Ne.info({user:t.user_email},"Authenticated \u2014 starting full server"),r=await Ny();let o=6e3;try{let s=zn({agent:"claude",onlyMissingConfig:!0,disableAutoSubmit:!0}).catch(a=>{Ne.warn({err:a},"Sync startup scan errored \u2014 refresh will retry in background")}),i=new Promise(a=>setTimeout(a,o));await Promise.race([s,i])}catch(s){Ne.warn({err:s},"Startup auto-init wrapper failed \u2014 server still starts")}}else{let o="https://toolcairn.neurynae.com/signup",s="";try{let a=await Fd();if(a)o=a.verification_uri,s=a.user_code,Ne.info({userCode:s},"Resuming pending sign-in");else{let c=await Bd(Nd.config.TOOLPILOT_API_URL);o=c.verification_uri,s=c.user_code,Ne.info({userCode:s},"New sign-in started")}}catch(a){Ne.error({err:a},"Could not reach ToolCairn API \u2014 check your connection")}let i=s?`# ToolCairn \u2014 Sign In Required
|
|
520
520
|
|
|
521
521
|
A browser window should have opened automatically.
|
|
522
522
|
|
|
@@ -527,4 +527,4 @@ Open the URL, sign in, and confirm the code shown. All 14 tools will appear auto
|
|
|
527
527
|
|
|
528
528
|
After sign-in the server will automatically provision .toolcairn/config.json for every project root under your working directory (scan + graph classification).`:`# ToolCairn \u2014 Sign In Required
|
|
529
529
|
|
|
530
|
-
Visit https://toolcairn.neurynae.com to create an account, then reconnect.`;r=new yn({name:"toolcairn",version:"0.1.0"},{instructions:i}),r.registerTool("toolcairn_auth",{description:"Check ToolCairn sign-in status.",inputSchema:Ur.object({action:Ur.enum(["status"])})},async()=>({content:[{type:"text",text:JSON.stringify({authenticated:!1,sign_in_url:o,code:s||null,message:s?`Open ${o} and confirm code "${s}". Tools will appear automatically when confirmed.`:"Visit toolcairn.neurynae.com to sign up."})}]})),Vo(Nd.config.TOOLPILOT_API_URL).then(async()=>{Ne.info("Sign-in complete \u2014 adding all tools to running server");try{await Id(r),Ne.info("All ToolCairn tools now available")}catch(a){Ne.error({err:a},"Failed to add tools after sign-in \u2014 please reconnect");return}try{let a=await zn({agent:"claude"});Ne.info({roots:a.roots_discovered.length,provisioned:a.projects.length,unknown_tools_total:a.unknown_tools_total},"Post-sign-in auto-init complete")}catch(a){Ne.warn({err:a},"Post-sign-in auto-init failed \u2014 call toolcairn_init manually")}}).catch(a=>{Ne.error({err:a},"Sign-in failed \u2014 please try again")})}let n=
|
|
530
|
+
Visit https://toolcairn.neurynae.com to create an account, then reconnect.`;r=new yn({name:"toolcairn",version:"0.1.0"},{instructions:i}),r.registerTool("toolcairn_auth",{description:"Check ToolCairn sign-in status.",inputSchema:Ur.object({action:Ur.enum(["status"])})},async()=>({content:[{type:"text",text:JSON.stringify({authenticated:!1,sign_in_url:o,code:s||null,message:s?`Open ${o} and confirm code "${s}". Tools will appear automatically when confirmed.`:"Visit toolcairn.neurynae.com to sign up."})}]})),Vo(Nd.config.TOOLPILOT_API_URL).then(async()=>{Ne.info("Sign-in complete \u2014 adding all tools to running server");try{await Id(r),Ne.info("All ToolCairn tools now available")}catch(a){Ne.error({err:a},"Failed to add tools after sign-in \u2014 please reconnect");return}try{let a=await zn({agent:"claude"});Ne.info({roots:a.roots_discovered.length,provisioned:a.projects.length,unknown_tools_total:a.unknown_tools_total},"Post-sign-in auto-init complete")}catch(a){Ne.warn({err:a},"Post-sign-in auto-init failed \u2014 call toolcairn_init manually")}}).catch(a=>{Ne.error({err:a},"Sign-in failed \u2014 please try again")})}let n=Wy();await r.connect(n),Ne.info(e?"ToolCairn MCP ready":"ToolCairn MCP ready (awaiting sign-in)"),e&&zn({agent:"claude"}).then(async o=>{Ne.info({roots:o.roots_discovered.length,provisioned:o.projects.length,unknown_tools_total:o.unknown_tools_total},"Background auto-refresh complete");for(let s of o.roots_discovered)await Do(s)}).catch(o=>{Ne.warn({err:o},"Background auto-refresh failed \u2014 config left as-is")})}bE().catch(t=>{(0,Md.createMcpLogger)({name:"@toolcairn/mcp-server"}).error({err:t},"Failed to start MCP server"),process.exit(1)});
|