lanhu-design-mcp 0.2.1 → 0.2.2
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/README.md +60 -426
- package/dist/index.js +24 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var P_=Object.create;var Hi=Object.defineProperty;var T_=Object.getOwnPropertyDescriptor;var E_=Object.getOwnPropertyNames;var I_=Object.getPrototypeOf,R_=Object.prototype.hasOwnProperty;var I=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Bi=(t,e)=>{for(var r in e)Hi(t,r,{get:e[r],enumerable:!0})},N_=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E_(e))!R_.call(t,o)&&o!==r&&Hi(t,o,{get:()=>e[o],enumerable:!(n=T_(e,o))||n.enumerable});return t};var Od=(t,e,r)=>(r=t!=null?P_(I_(t)):{},N_(e||!t||!t.__esModule?Hi(r,"default",{value:t,enumerable:!0}):r,t));var po=I(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.regexpCode=de.getEsmExportName=de.getProperty=de.safeStringify=de.stringify=de.strConcat=de.addCodeArg=de.str=de._=de.nil=de._Code=de.Name=de.IDENTIFIER=de._CodeOrName=void 0;var lo=class{};de._CodeOrName=lo;de.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var jr=class extends lo{constructor(e){if(super(),!de.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}}};de.Name=jr;var pt=class extends lo{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 jr&&(r[n.str]=(r[n.str]||0)+1),r),{})}};de._Code=pt;de.nil=new pt("");function Im(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Tu(r,e[n]),r.push(t[++n]);return new pt(r)}de._=Im;var Pu=new pt("+");function Rm(t,...e){let r=[fo(t[0])],n=0;for(;n<e.length;)r.push(Pu),Tu(r,e[n]),r.push(Pu,fo(t[++n]));return Iw(r),new pt(r)}de.str=Rm;function Tu(t,e){e instanceof pt?t.push(...e._items):e instanceof jr?t.push(e):t.push(Ow(e))}de.addCodeArg=Tu;function Iw(t){let e=1;for(;e<t.length-1;){if(t[e]===Pu){let r=Rw(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Rw(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof jr||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 jr))return`"${t}${e.slice(1)}`}function Nw(t,e){return e.emptyStr()?t:t.emptyStr()?e:Rm`${t}${e}`}de.strConcat=Nw;function Ow(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:fo(Array.isArray(t)?t.join(","):t)}function Cw(t){return new pt(fo(t))}de.stringify=Cw;function fo(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}de.safeStringify=fo;function jw(t){return typeof t=="string"&&de.IDENTIFIER.test(t)?new pt(`.${t}`):Im`[${t}]`}de.getProperty=jw;function Aw(t){if(typeof t=="string"&&de.IDENTIFIER.test(t))return new pt(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}de.getEsmExportName=Aw;function Mw(t){return new pt(t.toString())}de.regexpCode=Mw});var Ru=I(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.ValueScope=tt.ValueScopeName=tt.Scope=tt.varKinds=tt.UsedValueState=void 0;var et=po(),Eu=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Bs;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Bs||(tt.UsedValueState=Bs={}));tt.varKinds={const:new et.Name("const"),let:new et.Name("let"),var:new et.Name("var")};var Js=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof et.Name?e:this.name(e)}name(e){return new et.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}}};tt.Scope=Js;var Ks=class extends et.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,et._)`.${new et.Name(r)}[${n}]`}};tt.ValueScopeName=Ks;var Zw=(0,et._)`\n`,Iu=class extends Js{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Zw:et.nil}}get(){return this._scope}name(e){return new Ks(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,et._)`${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=et.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,Bs.Started);let l=r(u);if(l){let d=this.opts.es5?tt.varKinds.var:tt.varKinds.const;s=(0,et._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,et._)`${s}${l}${this.opts._n}`;else throw new Eu(u);c.set(u,Bs.Completed)})}return s}};tt.ValueScope=Iu});var X=I(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.or=Q.and=Q.not=Q.CodeGen=Q.operators=Q.varKinds=Q.ValueScopeName=Q.ValueScope=Q.Scope=Q.Name=Q.regexpCode=Q.stringify=Q.getProperty=Q.nil=Q.strConcat=Q.str=Q._=void 0;var ae=po(),xt=Ru(),rr=po();Object.defineProperty(Q,"_",{enumerable:!0,get:function(){return rr._}});Object.defineProperty(Q,"str",{enumerable:!0,get:function(){return rr.str}});Object.defineProperty(Q,"strConcat",{enumerable:!0,get:function(){return rr.strConcat}});Object.defineProperty(Q,"nil",{enumerable:!0,get:function(){return rr.nil}});Object.defineProperty(Q,"getProperty",{enumerable:!0,get:function(){return rr.getProperty}});Object.defineProperty(Q,"stringify",{enumerable:!0,get:function(){return rr.stringify}});Object.defineProperty(Q,"regexpCode",{enumerable:!0,get:function(){return rr.regexpCode}});Object.defineProperty(Q,"Name",{enumerable:!0,get:function(){return rr.Name}});var Xs=Ru();Object.defineProperty(Q,"Scope",{enumerable:!0,get:function(){return Xs.Scope}});Object.defineProperty(Q,"ValueScope",{enumerable:!0,get:function(){return Xs.ValueScope}});Object.defineProperty(Q,"ValueScopeName",{enumerable:!0,get:function(){return Xs.ValueScopeName}});Object.defineProperty(Q,"varKinds",{enumerable:!0,get:function(){return Xs.varKinds}});Q.operators={GT:new ae._Code(">"),GTE:new ae._Code(">="),LT:new ae._Code("<"),LTE:new ae._Code("<="),EQ:new ae._Code("==="),NEQ:new ae._Code("!=="),NOT:new ae._Code("!"),OR:new ae._Code("||"),AND:new ae._Code("&&"),ADD:new ae._Code("+")};var Ut=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Nu=class extends Ut{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?xt.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=gn(this.rhs,e,r)),this}get names(){return this.rhs instanceof ae._CodeOrName?this.rhs.names:{}}},Ws=class extends Ut{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 ae.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=gn(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ae.Name?{}:{...this.lhs.names};return Ys(e,this.rhs)}},Ou=class extends Ws{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Cu=class extends Ut{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},ju=class extends Ut{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Au=class extends Ut{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Mu=class extends Ut{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=gn(this.code,e,r),this}get names(){return this.code instanceof ae._CodeOrName?this.code.names:{}}},mo=class extends Ut{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)||(Dw(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Zr(e,r.names),{})}},Ft=class extends mo{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Zu=class extends mo{},hn=class extends Ft{};hn.kind="else";var Ar=class t extends Ft{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 hn(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Nm(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=gn(this.condition,e,r),this}get names(){let e=super.names;return Ys(e,this.condition),this.else&&Zr(e,this.else.names),e}};Ar.kind="if";var Mr=class extends Ft{};Mr.kind="for";var Du=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=gn(this.iteration,e,r),this}get names(){return Zr(super.names,this.iteration.names)}},Lu=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?xt.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=Ys(super.names,this.from);return Ys(e,this.to)}},Gs=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=gn(this.iterable,e,r),this}get names(){return Zr(super.names,this.iterable.names)}},ho=class extends Ft{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)}};ho.kind="func";var go=class extends mo{render(e){return"return "+super.render(e)}};go.kind="return";var qu=class extends Ft{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&&Zr(e,this.catch.names),this.finally&&Zr(e,this.finally.names),e}},yo=class extends Ft{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};yo.kind="catch";var _o=class extends Ft{render(e){return"finally"+super.render(e)}};_o.kind="finally";var Uu=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
-
`:""},this._extScope=e,this._scope=new xt.Scope({parent:e}),this._nodes=[new Zu]}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 Nu(e,s,n)),s}const(e,r,n){return this._def(xt.varKinds.const,e,r,n)}let(e,r,n){return this._def(xt.varKinds.let,e,r,n)}var(e,r,n){return this._def(xt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Ws(e,r,n))}add(e,r){return this._leafNode(new Ou(e,Q.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ae.nil&&this._leafNode(new Mu(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,ae.addCodeArg)(r,o));return r.push("}"),new ae._Code(r)}if(e,r,n){if(this._blockNode(new Ar(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 Ar(e))}else(){return this._elseNode(new hn)}endIf(){return this._endBlockNode(Ar,hn)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Du(e),r)}forRange(e,r,n,o,s=this.opts.es5?xt.varKinds.var:xt.varKinds.let){let i=this._scope.toName(e);return this._for(new Lu(s,i,r,n),()=>o(i))}forOf(e,r,n,o=xt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof ae.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ae._)`${i}.length`,a=>{this.var(s,(0,ae._)`${i}[${a}]`),n(s)})}return this._for(new Gs("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?xt.varKinds.var:xt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ae._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Gs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Mr)}label(e){return this._leafNode(new Cu(e))}break(e){return this._leafNode(new ju(e))}return(e){let r=new go;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(go)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new qu;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new yo(s),r(s)}return n&&(this._currNode=o.finally=new _o,this.code(n)),this._endBlockNode(yo,_o)}throw(e){return this._leafNode(new Au(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=ae.nil,n,o){return this._blockNode(new ho(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(ho)}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 Ar))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}};Q.CodeGen=Uu;function Zr(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Ys(t,e){return e instanceof ae._CodeOrName?Zr(t,e.names):t}function gn(t,e,r){if(t instanceof ae.Name)return n(t);if(!o(t))return t;return new ae._Code(t._items.reduce((s,i)=>(i instanceof ae.Name&&(i=n(i)),i instanceof ae._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 ae._Code&&s._items.some(i=>i instanceof ae.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Dw(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Nm(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ae._)`!${Fu(t)}`}Q.not=Nm;var Lw=Om(Q.operators.AND);function qw(...t){return t.reduce(Lw)}Q.and=qw;var Uw=Om(Q.operators.OR);function Fw(...t){return t.reduce(Uw)}Q.or=Fw;function Om(t){return(e,r)=>e===ae.nil?r:r===ae.nil?e:(0,ae._)`${Fu(e)} ${t} ${Fu(r)}`}function Fu(t){return t instanceof ae.Name?t:(0,ae._)`(${t})`}});var ue=I(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.checkStrictMode=ee.getErrorPath=ee.Type=ee.useFunc=ee.setEvaluated=ee.evaluatedPropsToName=ee.mergeEvaluated=ee.eachItem=ee.unescapeJsonPointer=ee.escapeJsonPointer=ee.escapeFragment=ee.unescapeFragment=ee.schemaRefOrVal=ee.schemaHasRulesButRef=ee.schemaHasRules=ee.checkUnknownRules=ee.alwaysValidSchema=ee.toHash=void 0;var ge=X(),Vw=po();function Hw(t){let e={};for(let r of t)e[r]=!0;return e}ee.toHash=Hw;function Bw(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Am(t,e),!Mm(e,t.self.RULES.all))}ee.alwaysValidSchema=Bw;function Am(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]||Lm(t,`unknown keyword: "${s}"`)}ee.checkUnknownRules=Am;function Mm(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}ee.schemaHasRules=Mm;function Jw(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}ee.schemaHasRulesButRef=Jw;function Kw({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ge._)`${r}`}return(0,ge._)`${t}${e}${(0,ge.getProperty)(n)}`}ee.schemaRefOrVal=Kw;function Ww(t){return Zm(decodeURIComponent(t))}ee.unescapeFragment=Ww;function Gw(t){return encodeURIComponent(Hu(t))}ee.escapeFragment=Gw;function Hu(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ee.escapeJsonPointer=Hu;function Zm(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ee.unescapeJsonPointer=Zm;function Yw(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}ee.eachItem=Yw;function Cm({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof ge.Name?(s instanceof ge.Name?t(o,s,i):e(o,s,i),i):s instanceof ge.Name?(e(o,i,s),s):r(s,i);return a===ge.Name&&!(c instanceof ge.Name)?n(o,c):c}}ee.mergeEvaluated={props:Cm({mergeNames:(t,e,r)=>t.if((0,ge._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ge._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ge._)`${r} || {}`).code((0,ge._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ge._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ge._)`${r} || {}`),Bu(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Dm}),items:Cm({mergeNames:(t,e,r)=>t.if((0,ge._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ge._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ge._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ge._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Dm(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ge._)`{}`);return e!==void 0&&Bu(t,r,e),r}ee.evaluatedPropsToName=Dm;function Bu(t,e,r){Object.keys(r).forEach(n=>t.assign((0,ge._)`${e}${(0,ge.getProperty)(n)}`,!0))}ee.setEvaluated=Bu;var jm={};function Xw(t,e){return t.scopeValue("func",{ref:e,code:jm[e.code]||(jm[e.code]=new Vw._Code(e.code))})}ee.useFunc=Xw;var Vu;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Vu||(ee.Type=Vu={}));function Qw(t,e,r){if(t instanceof ge.Name){let n=e===Vu.Num;return r?n?(0,ge._)`"[" + ${t} + "]"`:(0,ge._)`"['" + ${t} + "']"`:n?(0,ge._)`"/" + ${t}`:(0,ge._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ge.getProperty)(t).toString():"/"+Hu(t)}ee.getErrorPath=Qw;function Lm(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}ee.checkStrictMode=Lm});var Vt=I(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});var Le=X(),e$={data:new Le.Name("data"),valCxt:new Le.Name("valCxt"),instancePath:new Le.Name("instancePath"),parentData:new Le.Name("parentData"),parentDataProperty:new Le.Name("parentDataProperty"),rootData:new Le.Name("rootData"),dynamicAnchors:new Le.Name("dynamicAnchors"),vErrors:new Le.Name("vErrors"),errors:new Le.Name("errors"),this:new Le.Name("this"),self:new Le.Name("self"),scope:new Le.Name("scope"),json:new Le.Name("json"),jsonPos:new Le.Name("jsonPos"),jsonLen:new Le.Name("jsonLen"),jsonPart:new Le.Name("jsonPart")};Ju.default=e$});var vo=I(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.extendErrors=qe.resetErrorsCount=qe.reportExtraError=qe.reportError=qe.keyword$DataError=qe.keywordError=void 0;var le=X(),Qs=ue(),Ke=Vt();qe.keywordError={message:({keyword:t})=>(0,le.str)`must pass "${t}" keyword validation`};qe.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,le.str)`"${t}" keyword must be ${e} ($data)`:(0,le.str)`"${t}" keyword is invalid ($data)`};function t$(t,e=qe.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=Fm(t,e,r);n??(i||a)?qm(s,c):Um(o,(0,le._)`[${c}]`)}qe.reportError=t$;function r$(t,e=qe.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=Fm(t,e,r);qm(o,a),s||i||Um(n,Ke.default.vErrors)}qe.reportExtraError=r$;function n$(t,e){t.assign(Ke.default.errors,e),t.if((0,le._)`${Ke.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,le._)`${Ke.default.vErrors}.length`,e),()=>t.assign(Ke.default.vErrors,null)))}qe.resetErrorsCount=n$;function o$({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,Ke.default.errors,a=>{t.const(i,(0,le._)`${Ke.default.vErrors}[${a}]`),t.if((0,le._)`${i}.instancePath === undefined`,()=>t.assign((0,le._)`${i}.instancePath`,(0,le.strConcat)(Ke.default.instancePath,s.errorPath))),t.assign((0,le._)`${i}.schemaPath`,(0,le.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,le._)`${i}.schema`,r),t.assign((0,le._)`${i}.data`,n))})}qe.extendErrors=o$;function qm(t,e){let r=t.const("err",e);t.if((0,le._)`${Ke.default.vErrors} === null`,()=>t.assign(Ke.default.vErrors,(0,le._)`[${r}]`),(0,le._)`${Ke.default.vErrors}.push(${r})`),t.code((0,le._)`${Ke.default.errors}++`)}function Um(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,le._)`new ${t.ValidationError}(${e})`):(r.assign((0,le._)`${n}.errors`,e),r.return(!1))}var Dr={keyword:new le.Name("keyword"),schemaPath:new le.Name("schemaPath"),params:new le.Name("params"),propertyName:new le.Name("propertyName"),message:new le.Name("message"),schema:new le.Name("schema"),parentSchema:new le.Name("parentSchema")};function Fm(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,le._)`{}`:s$(t,e,r)}function s$(t,e,r={}){let{gen:n,it:o}=t,s=[i$(o,r),a$(t,r)];return c$(t,e,s),n.object(...s)}function i$({errorPath:t},{instancePath:e}){let r=e?(0,le.str)`${t}${(0,Qs.getErrorPath)(e,Qs.Type.Str)}`:t;return[Ke.default.instancePath,(0,le.strConcat)(Ke.default.instancePath,r)]}function a$({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,le.str)`${e}/${t}`;return r&&(o=(0,le.str)`${o}${(0,Qs.getErrorPath)(r,Qs.Type.Str)}`),[Dr.schemaPath,o]}function c$(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Dr.keyword,o],[Dr.params,typeof e=="function"?e(t):e||(0,le._)`{}`]),c.messages&&n.push([Dr.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Dr.schema,i],[Dr.parentSchema,(0,le._)`${l}${d}`],[Ke.default.data,s]),u&&n.push([Dr.propertyName,u])}});var Hm=I(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.boolOrEmptySchema=yn.topBoolOrEmptySchema=void 0;var u$=vo(),l$=X(),d$=Vt(),f$={message:"boolean schema is false"};function p$(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Vm(t,!1):typeof r=="object"&&r.$async===!0?e.return(d$.default.data):(e.assign((0,l$._)`${n}.errors`,null),e.return(!0))}yn.topBoolOrEmptySchema=p$;function m$(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Vm(t)):r.var(e,!0)}yn.boolOrEmptySchema=m$;function Vm(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,u$.reportError)(o,f$,void 0,e)}});var Ku=I(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.getRules=_n.isJSONType=void 0;var h$=["string","number","integer","boolean","null","object","array"],g$=new Set(h$);function y$(t){return typeof t=="string"&&g$.has(t)}_n.isJSONType=y$;function _$(){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:{}}}_n.getRules=_$});var Wu=I(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.shouldUseRule=nr.shouldUseGroup=nr.schemaHasRulesForType=void 0;function v$({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Bm(t,n)}nr.schemaHasRulesForType=v$;function Bm(t,e){return e.rules.some(r=>Jm(t,r))}nr.shouldUseGroup=Bm;function Jm(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))}nr.shouldUseRule=Jm});var bo=I(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.reportTypeError=Ue.checkDataTypes=Ue.checkDataType=Ue.coerceAndCheckDataType=Ue.getJSONTypes=Ue.getSchemaTypes=Ue.DataType=void 0;var b$=Ku(),x$=Wu(),w$=vo(),G=X(),Km=ue(),vn;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(vn||(Ue.DataType=vn={}));function $$(t){let e=Wm(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}Ue.getSchemaTypes=$$;function Wm(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(b$.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ue.getJSONTypes=Wm;function k$(t,e){let{gen:r,data:n,opts:o}=t,s=S$(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,x$.schemaHasRulesForType)(t,e[0]));if(i){let a=Yu(e,n,o.strictNumbers,vn.Wrong);r.if(a,()=>{s.length?z$(t,e,s):Xu(t)})}return i}Ue.coerceAndCheckDataType=k$;var Gm=new Set(["string","number","integer","boolean","null"]);function S$(t,e){return e?t.filter(r=>Gm.has(r)||e==="array"&&r==="array"):[]}function z$(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,G._)`typeof ${o}`),a=n.let("coerced",(0,G._)`undefined`);s.coerceTypes==="array"&&n.if((0,G._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,G._)`${o}[0]`).assign(i,(0,G._)`typeof ${o}`).if(Yu(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,G._)`${a} !== undefined`);for(let u of r)(Gm.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Xu(t),n.endIf(),n.if((0,G._)`${a} !== undefined`,()=>{n.assign(o,a),P$(t,a)});function c(u){switch(u){case"string":n.elseIf((0,G._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,G._)`"" + ${o}`).elseIf((0,G._)`${o} === null`).assign(a,(0,G._)`""`);return;case"number":n.elseIf((0,G._)`${i} == "boolean" || ${o} === null
|
|
2
|
+
var P_=Object.create;var Hi=Object.defineProperty;var T_=Object.getOwnPropertyDescriptor;var E_=Object.getOwnPropertyNames;var I_=Object.getPrototypeOf,R_=Object.prototype.hasOwnProperty;var I=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Bi=(t,e)=>{for(var r in e)Hi(t,r,{get:e[r],enumerable:!0})},N_=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of E_(e))!R_.call(t,o)&&o!==r&&Hi(t,o,{get:()=>e[o],enumerable:!(n=T_(e,o))||n.enumerable});return t};var Od=(t,e,r)=>(r=t!=null?P_(I_(t)):{},N_(e||!t||!t.__esModule?Hi(r,"default",{value:t,enumerable:!0}):r,t));var fo=I(de=>{"use strict";Object.defineProperty(de,"__esModule",{value:!0});de.regexpCode=de.getEsmExportName=de.getProperty=de.safeStringify=de.stringify=de.strConcat=de.addCodeArg=de.str=de._=de.nil=de._Code=de.Name=de.IDENTIFIER=de._CodeOrName=void 0;var lo=class{};de._CodeOrName=lo;de.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ar=class extends lo{constructor(e){if(super(),!de.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}}};de.Name=Ar;var ft=class extends lo{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 Ar&&(r[n.str]=(r[n.str]||0)+1),r),{})}};de._Code=ft;de.nil=new ft("");function Im(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Tu(r,e[n]),r.push(t[++n]);return new ft(r)}de._=Im;var Pu=new ft("+");function Rm(t,...e){let r=[po(t[0])],n=0;for(;n<e.length;)r.push(Pu),Tu(r,e[n]),r.push(Pu,po(t[++n]));return Iw(r),new ft(r)}de.str=Rm;function Tu(t,e){e instanceof ft?t.push(...e._items):e instanceof Ar?t.push(e):t.push(Ow(e))}de.addCodeArg=Tu;function Iw(t){let e=1;for(;e<t.length-1;){if(t[e]===Pu){let r=Rw(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Rw(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Ar||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 Ar))return`"${t}${e.slice(1)}`}function Nw(t,e){return e.emptyStr()?t:t.emptyStr()?e:Rm`${t}${e}`}de.strConcat=Nw;function Ow(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:po(Array.isArray(t)?t.join(","):t)}function Cw(t){return new ft(po(t))}de.stringify=Cw;function po(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}de.safeStringify=po;function Aw(t){return typeof t=="string"&&de.IDENTIFIER.test(t)?new ft(`.${t}`):Im`[${t}]`}de.getProperty=Aw;function jw(t){if(typeof t=="string"&&de.IDENTIFIER.test(t))return new ft(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}de.getEsmExportName=jw;function Mw(t){return new ft(t.toString())}de.regexpCode=Mw});var Ru=I(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.ValueScope=tt.ValueScopeName=tt.Scope=tt.varKinds=tt.UsedValueState=void 0;var et=fo(),Eu=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Bs;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Bs||(tt.UsedValueState=Bs={}));tt.varKinds={const:new et.Name("const"),let:new et.Name("let"),var:new et.Name("var")};var Js=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof et.Name?e:this.name(e)}name(e){return new et.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}}};tt.Scope=Js;var Ks=class extends et.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,et._)`.${new et.Name(r)}[${n}]`}};tt.ValueScopeName=Ks;var Zw=(0,et._)`\n`,Iu=class extends Js{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Zw:et.nil}}get(){return this._scope}name(e){return new Ks(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,et._)`${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=et.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,Bs.Started);let l=r(u);if(l){let d=this.opts.es5?tt.varKinds.var:tt.varKinds.const;s=(0,et._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,et._)`${s}${l}${this.opts._n}`;else throw new Eu(u);c.set(u,Bs.Completed)})}return s}};tt.ValueScope=Iu});var X=I(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.or=Q.and=Q.not=Q.CodeGen=Q.operators=Q.varKinds=Q.ValueScopeName=Q.ValueScope=Q.Scope=Q.Name=Q.regexpCode=Q.stringify=Q.getProperty=Q.nil=Q.strConcat=Q.str=Q._=void 0;var ae=fo(),xt=Ru(),rr=fo();Object.defineProperty(Q,"_",{enumerable:!0,get:function(){return rr._}});Object.defineProperty(Q,"str",{enumerable:!0,get:function(){return rr.str}});Object.defineProperty(Q,"strConcat",{enumerable:!0,get:function(){return rr.strConcat}});Object.defineProperty(Q,"nil",{enumerable:!0,get:function(){return rr.nil}});Object.defineProperty(Q,"getProperty",{enumerable:!0,get:function(){return rr.getProperty}});Object.defineProperty(Q,"stringify",{enumerable:!0,get:function(){return rr.stringify}});Object.defineProperty(Q,"regexpCode",{enumerable:!0,get:function(){return rr.regexpCode}});Object.defineProperty(Q,"Name",{enumerable:!0,get:function(){return rr.Name}});var Xs=Ru();Object.defineProperty(Q,"Scope",{enumerable:!0,get:function(){return Xs.Scope}});Object.defineProperty(Q,"ValueScope",{enumerable:!0,get:function(){return Xs.ValueScope}});Object.defineProperty(Q,"ValueScopeName",{enumerable:!0,get:function(){return Xs.ValueScopeName}});Object.defineProperty(Q,"varKinds",{enumerable:!0,get:function(){return Xs.varKinds}});Q.operators={GT:new ae._Code(">"),GTE:new ae._Code(">="),LT:new ae._Code("<"),LTE:new ae._Code("<="),EQ:new ae._Code("==="),NEQ:new ae._Code("!=="),NOT:new ae._Code("!"),OR:new ae._Code("||"),AND:new ae._Code("&&"),ADD:new ae._Code("+")};var Ut=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Nu=class extends Ut{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?xt.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=gn(this.rhs,e,r)),this}get names(){return this.rhs instanceof ae._CodeOrName?this.rhs.names:{}}},Ws=class extends Ut{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 ae.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=gn(this.rhs,e,r),this}get names(){let e=this.lhs instanceof ae.Name?{}:{...this.lhs.names};return Ys(e,this.rhs)}},Ou=class extends Ws{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Cu=class extends Ut{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Au=class extends Ut{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},ju=class extends Ut{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Mu=class extends Ut{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=gn(this.code,e,r),this}get names(){return this.code instanceof ae._CodeOrName?this.code.names:{}}},mo=class extends Ut{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)||(Dw(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Zr(e,r.names),{})}},Ft=class extends mo{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},Zu=class extends mo{},hn=class extends Ft{};hn.kind="else";var jr=class t extends Ft{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 hn(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Nm(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=gn(this.condition,e,r),this}get names(){let e=super.names;return Ys(e,this.condition),this.else&&Zr(e,this.else.names),e}};jr.kind="if";var Mr=class extends Ft{};Mr.kind="for";var Du=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=gn(this.iteration,e,r),this}get names(){return Zr(super.names,this.iteration.names)}},Lu=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?xt.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=Ys(super.names,this.from);return Ys(e,this.to)}},Gs=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=gn(this.iterable,e,r),this}get names(){return Zr(super.names,this.iterable.names)}},ho=class extends Ft{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)}};ho.kind="func";var go=class extends mo{render(e){return"return "+super.render(e)}};go.kind="return";var qu=class extends Ft{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&&Zr(e,this.catch.names),this.finally&&Zr(e,this.finally.names),e}},yo=class extends Ft{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};yo.kind="catch";var _o=class extends Ft{render(e){return"finally"+super.render(e)}};_o.kind="finally";var Uu=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
+
`:""},this._extScope=e,this._scope=new xt.Scope({parent:e}),this._nodes=[new Zu]}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 Nu(e,s,n)),s}const(e,r,n){return this._def(xt.varKinds.const,e,r,n)}let(e,r,n){return this._def(xt.varKinds.let,e,r,n)}var(e,r,n){return this._def(xt.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Ws(e,r,n))}add(e,r){return this._leafNode(new Ou(e,Q.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==ae.nil&&this._leafNode(new Mu(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,ae.addCodeArg)(r,o));return r.push("}"),new ae._Code(r)}if(e,r,n){if(this._blockNode(new jr(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 jr(e))}else(){return this._elseNode(new hn)}endIf(){return this._endBlockNode(jr,hn)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Du(e),r)}forRange(e,r,n,o,s=this.opts.es5?xt.varKinds.var:xt.varKinds.let){let i=this._scope.toName(e);return this._for(new Lu(s,i,r,n),()=>o(i))}forOf(e,r,n,o=xt.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof ae.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ae._)`${i}.length`,a=>{this.var(s,(0,ae._)`${i}[${a}]`),n(s)})}return this._for(new Gs("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?xt.varKinds.var:xt.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,ae._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Gs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Mr)}label(e){return this._leafNode(new Cu(e))}break(e){return this._leafNode(new Au(e))}return(e){let r=new go;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(go)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new qu;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new yo(s),r(s)}return n&&(this._currNode=o.finally=new _o,this.code(n)),this._endBlockNode(yo,_o)}throw(e){return this._leafNode(new ju(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=ae.nil,n,o){return this._blockNode(new ho(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(ho)}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 jr))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}};Q.CodeGen=Uu;function Zr(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Ys(t,e){return e instanceof ae._CodeOrName?Zr(t,e.names):t}function gn(t,e,r){if(t instanceof ae.Name)return n(t);if(!o(t))return t;return new ae._Code(t._items.reduce((s,i)=>(i instanceof ae.Name&&(i=n(i)),i instanceof ae._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 ae._Code&&s._items.some(i=>i instanceof ae.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Dw(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Nm(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,ae._)`!${Fu(t)}`}Q.not=Nm;var Lw=Om(Q.operators.AND);function qw(...t){return t.reduce(Lw)}Q.and=qw;var Uw=Om(Q.operators.OR);function Fw(...t){return t.reduce(Uw)}Q.or=Fw;function Om(t){return(e,r)=>e===ae.nil?r:r===ae.nil?e:(0,ae._)`${Fu(e)} ${t} ${Fu(r)}`}function Fu(t){return t instanceof ae.Name?t:(0,ae._)`(${t})`}});var ue=I(ee=>{"use strict";Object.defineProperty(ee,"__esModule",{value:!0});ee.checkStrictMode=ee.getErrorPath=ee.Type=ee.useFunc=ee.setEvaluated=ee.evaluatedPropsToName=ee.mergeEvaluated=ee.eachItem=ee.unescapeJsonPointer=ee.escapeJsonPointer=ee.escapeFragment=ee.unescapeFragment=ee.schemaRefOrVal=ee.schemaHasRulesButRef=ee.schemaHasRules=ee.checkUnknownRules=ee.alwaysValidSchema=ee.toHash=void 0;var ge=X(),Vw=fo();function Hw(t){let e={};for(let r of t)e[r]=!0;return e}ee.toHash=Hw;function Bw(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(jm(t,e),!Mm(e,t.self.RULES.all))}ee.alwaysValidSchema=Bw;function jm(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]||Lm(t,`unknown keyword: "${s}"`)}ee.checkUnknownRules=jm;function Mm(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}ee.schemaHasRules=Mm;function Jw(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}ee.schemaHasRulesButRef=Jw;function Kw({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,ge._)`${r}`}return(0,ge._)`${t}${e}${(0,ge.getProperty)(n)}`}ee.schemaRefOrVal=Kw;function Ww(t){return Zm(decodeURIComponent(t))}ee.unescapeFragment=Ww;function Gw(t){return encodeURIComponent(Hu(t))}ee.escapeFragment=Gw;function Hu(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}ee.escapeJsonPointer=Hu;function Zm(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}ee.unescapeJsonPointer=Zm;function Yw(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}ee.eachItem=Yw;function Cm({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof ge.Name?(s instanceof ge.Name?t(o,s,i):e(o,s,i),i):s instanceof ge.Name?(e(o,i,s),s):r(s,i);return a===ge.Name&&!(c instanceof ge.Name)?n(o,c):c}}ee.mergeEvaluated={props:Cm({mergeNames:(t,e,r)=>t.if((0,ge._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,ge._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,ge._)`${r} || {}`).code((0,ge._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,ge._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,ge._)`${r} || {}`),Bu(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Dm}),items:Cm({mergeNames:(t,e,r)=>t.if((0,ge._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,ge._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,ge._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,ge._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function Dm(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,ge._)`{}`);return e!==void 0&&Bu(t,r,e),r}ee.evaluatedPropsToName=Dm;function Bu(t,e,r){Object.keys(r).forEach(n=>t.assign((0,ge._)`${e}${(0,ge.getProperty)(n)}`,!0))}ee.setEvaluated=Bu;var Am={};function Xw(t,e){return t.scopeValue("func",{ref:e,code:Am[e.code]||(Am[e.code]=new Vw._Code(e.code))})}ee.useFunc=Xw;var Vu;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Vu||(ee.Type=Vu={}));function Qw(t,e,r){if(t instanceof ge.Name){let n=e===Vu.Num;return r?n?(0,ge._)`"[" + ${t} + "]"`:(0,ge._)`"['" + ${t} + "']"`:n?(0,ge._)`"/" + ${t}`:(0,ge._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,ge.getProperty)(t).toString():"/"+Hu(t)}ee.getErrorPath=Qw;function Lm(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}ee.checkStrictMode=Lm});var Vt=I(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});var Le=X(),e$={data:new Le.Name("data"),valCxt:new Le.Name("valCxt"),instancePath:new Le.Name("instancePath"),parentData:new Le.Name("parentData"),parentDataProperty:new Le.Name("parentDataProperty"),rootData:new Le.Name("rootData"),dynamicAnchors:new Le.Name("dynamicAnchors"),vErrors:new Le.Name("vErrors"),errors:new Le.Name("errors"),this:new Le.Name("this"),self:new Le.Name("self"),scope:new Le.Name("scope"),json:new Le.Name("json"),jsonPos:new Le.Name("jsonPos"),jsonLen:new Le.Name("jsonLen"),jsonPart:new Le.Name("jsonPart")};Ju.default=e$});var vo=I(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.extendErrors=qe.resetErrorsCount=qe.reportExtraError=qe.reportError=qe.keyword$DataError=qe.keywordError=void 0;var le=X(),Qs=ue(),Ke=Vt();qe.keywordError={message:({keyword:t})=>(0,le.str)`must pass "${t}" keyword validation`};qe.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,le.str)`"${t}" keyword must be ${e} ($data)`:(0,le.str)`"${t}" keyword is invalid ($data)`};function t$(t,e=qe.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=Fm(t,e,r);n??(i||a)?qm(s,c):Um(o,(0,le._)`[${c}]`)}qe.reportError=t$;function r$(t,e=qe.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=Fm(t,e,r);qm(o,a),s||i||Um(n,Ke.default.vErrors)}qe.reportExtraError=r$;function n$(t,e){t.assign(Ke.default.errors,e),t.if((0,le._)`${Ke.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,le._)`${Ke.default.vErrors}.length`,e),()=>t.assign(Ke.default.vErrors,null)))}qe.resetErrorsCount=n$;function o$({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,Ke.default.errors,a=>{t.const(i,(0,le._)`${Ke.default.vErrors}[${a}]`),t.if((0,le._)`${i}.instancePath === undefined`,()=>t.assign((0,le._)`${i}.instancePath`,(0,le.strConcat)(Ke.default.instancePath,s.errorPath))),t.assign((0,le._)`${i}.schemaPath`,(0,le.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,le._)`${i}.schema`,r),t.assign((0,le._)`${i}.data`,n))})}qe.extendErrors=o$;function qm(t,e){let r=t.const("err",e);t.if((0,le._)`${Ke.default.vErrors} === null`,()=>t.assign(Ke.default.vErrors,(0,le._)`[${r}]`),(0,le._)`${Ke.default.vErrors}.push(${r})`),t.code((0,le._)`${Ke.default.errors}++`)}function Um(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,le._)`new ${t.ValidationError}(${e})`):(r.assign((0,le._)`${n}.errors`,e),r.return(!1))}var Dr={keyword:new le.Name("keyword"),schemaPath:new le.Name("schemaPath"),params:new le.Name("params"),propertyName:new le.Name("propertyName"),message:new le.Name("message"),schema:new le.Name("schema"),parentSchema:new le.Name("parentSchema")};function Fm(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,le._)`{}`:s$(t,e,r)}function s$(t,e,r={}){let{gen:n,it:o}=t,s=[i$(o,r),a$(t,r)];return c$(t,e,s),n.object(...s)}function i$({errorPath:t},{instancePath:e}){let r=e?(0,le.str)`${t}${(0,Qs.getErrorPath)(e,Qs.Type.Str)}`:t;return[Ke.default.instancePath,(0,le.strConcat)(Ke.default.instancePath,r)]}function a$({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,le.str)`${e}/${t}`;return r&&(o=(0,le.str)`${o}${(0,Qs.getErrorPath)(r,Qs.Type.Str)}`),[Dr.schemaPath,o]}function c$(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Dr.keyword,o],[Dr.params,typeof e=="function"?e(t):e||(0,le._)`{}`]),c.messages&&n.push([Dr.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Dr.schema,i],[Dr.parentSchema,(0,le._)`${l}${d}`],[Ke.default.data,s]),u&&n.push([Dr.propertyName,u])}});var Hm=I(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});yn.boolOrEmptySchema=yn.topBoolOrEmptySchema=void 0;var u$=vo(),l$=X(),d$=Vt(),p$={message:"boolean schema is false"};function f$(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Vm(t,!1):typeof r=="object"&&r.$async===!0?e.return(d$.default.data):(e.assign((0,l$._)`${n}.errors`,null),e.return(!0))}yn.topBoolOrEmptySchema=f$;function m$(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Vm(t)):r.var(e,!0)}yn.boolOrEmptySchema=m$;function Vm(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,u$.reportError)(o,p$,void 0,e)}});var Ku=I(_n=>{"use strict";Object.defineProperty(_n,"__esModule",{value:!0});_n.getRules=_n.isJSONType=void 0;var h$=["string","number","integer","boolean","null","object","array"],g$=new Set(h$);function y$(t){return typeof t=="string"&&g$.has(t)}_n.isJSONType=y$;function _$(){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:{}}}_n.getRules=_$});var Wu=I(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});nr.shouldUseRule=nr.shouldUseGroup=nr.schemaHasRulesForType=void 0;function v$({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Bm(t,n)}nr.schemaHasRulesForType=v$;function Bm(t,e){return e.rules.some(r=>Jm(t,r))}nr.shouldUseGroup=Bm;function Jm(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))}nr.shouldUseRule=Jm});var bo=I(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.reportTypeError=Ue.checkDataTypes=Ue.checkDataType=Ue.coerceAndCheckDataType=Ue.getJSONTypes=Ue.getSchemaTypes=Ue.DataType=void 0;var b$=Ku(),x$=Wu(),w$=vo(),G=X(),Km=ue(),vn;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(vn||(Ue.DataType=vn={}));function $$(t){let e=Wm(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}Ue.getSchemaTypes=$$;function Wm(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(b$.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ue.getJSONTypes=Wm;function k$(t,e){let{gen:r,data:n,opts:o}=t,s=S$(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,x$.schemaHasRulesForType)(t,e[0]));if(i){let a=Yu(e,n,o.strictNumbers,vn.Wrong);r.if(a,()=>{s.length?z$(t,e,s):Xu(t)})}return i}Ue.coerceAndCheckDataType=k$;var Gm=new Set(["string","number","integer","boolean","null"]);function S$(t,e){return e?t.filter(r=>Gm.has(r)||e==="array"&&r==="array"):[]}function z$(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,G._)`typeof ${o}`),a=n.let("coerced",(0,G._)`undefined`);s.coerceTypes==="array"&&n.if((0,G._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,G._)`${o}[0]`).assign(i,(0,G._)`typeof ${o}`).if(Yu(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,G._)`${a} !== undefined`);for(let u of r)(Gm.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Xu(t),n.endIf(),n.if((0,G._)`${a} !== undefined`,()=>{n.assign(o,a),P$(t,a)});function c(u){switch(u){case"string":n.elseIf((0,G._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,G._)`"" + ${o}`).elseIf((0,G._)`${o} === null`).assign(a,(0,G._)`""`);return;case"number":n.elseIf((0,G._)`${i} == "boolean" || ${o} === null
|
|
4
4
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,G._)`+${o}`);return;case"integer":n.elseIf((0,G._)`${i} === "boolean" || ${o} === null
|
|
5
5
|
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,G._)`+${o}`);return;case"boolean":n.elseIf((0,G._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,G._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,G._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,G._)`${i} === "string" || ${i} === "number"
|
|
6
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,G._)`[${o}]`)}}}function P$({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,G._)`${e} !== undefined`,()=>t.assign((0,G._)`${e}[${r}]`,n))}function Gu(t,e,r,n=vn.Correct){let o=n===vn.Correct?G.operators.EQ:G.operators.NEQ,s;switch(t){case"null":return(0,G._)`${e} ${o} null`;case"array":s=(0,G._)`Array.isArray(${e})`;break;case"object":s=(0,G._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,G._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,G._)`typeof ${e} ${o} ${t}`}return n===vn.Correct?s:(0,G.not)(s);function i(a=G.nil){return(0,G.and)((0,G._)`typeof ${e} == "number"`,a,r?(0,G._)`isFinite(${e})`:G.nil)}}Ue.checkDataType=Gu;function Yu(t,e,r,n){if(t.length===1)return Gu(t[0],e,r,n);let o,s=(0,Km.toHash)(t);if(s.array&&s.object){let i=(0,G._)`typeof ${e} != "object"`;o=s.null?i:(0,G._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=G.nil;s.number&&delete s.integer;for(let i in s)o=(0,G.and)(o,Gu(i,e,r,n));return o}Ue.checkDataTypes=Yu;var T$={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,G._)`{type: ${t}}`:(0,G._)`{type: ${e}}`};function Xu(t){let e=E$(t);(0,w$.reportError)(e,T$)}Ue.reportTypeError=Xu;function E$(t){let{gen:e,data:r,schema:n}=t,o=(0,Km.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Xm=I(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.assignDefaults=void 0;var bn=X(),I$=ue();function R$(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)Ym(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Ym(t,s,o.default))}ei.assignDefaults=R$;function Ym(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,bn._)`${s}${(0,bn.getProperty)(e)}`;if(o){(0,I$.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,bn._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,bn._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,bn._)`${a} = ${(0,bn.stringify)(r)}`)}});var mt=I(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.validateUnion=he.validateArray=he.usePattern=he.callValidateCode=he.schemaProperties=he.allSchemaProperties=he.noPropertyInData=he.propertyInData=he.isOwnProperty=he.hasPropFunc=he.reportMissingProp=he.checkMissingProp=he.checkReportMissingProp=void 0;var xe=X(),Qu=ue(),or=Vt(),N$=ue();function O$(t,e){let{gen:r,data:n,it:o}=t;r.if(tl(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,xe._)`${e}`},!0),t.error()})}he.checkReportMissingProp=O$;function C$({gen:t,data:e,it:{opts:r}},n,o){return(0,xe.or)(...n.map(s=>(0,xe.and)(tl(t,e,s,r.ownProperties),(0,xe._)`${o} = ${s}`)))}he.checkMissingProp=C$;function j$(t,e){t.setParams({missingProperty:e},!0),t.error()}he.reportMissingProp=j$;function Qm(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,xe._)`Object.prototype.hasOwnProperty`})}he.hasPropFunc=Qm;function el(t,e,r){return(0,xe._)`${Qm(t)}.call(${e}, ${r})`}he.isOwnProperty=el;function A$(t,e,r,n){let o=(0,xe._)`${e}${(0,xe.getProperty)(r)} !== undefined`;return n?(0,xe._)`${o} && ${el(t,e,r)}`:o}he.propertyInData=A$;function tl(t,e,r,n){let o=(0,xe._)`${e}${(0,xe.getProperty)(r)} === undefined`;return n?(0,xe.or)(o,(0,xe.not)(el(t,e,r))):o}he.noPropertyInData=tl;function eh(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}he.allSchemaProperties=eh;function M$(t,e){return eh(e).filter(r=>!(0,Qu.alwaysValidSchema)(t,e[r]))}he.schemaProperties=M$;function Z$({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,xe._)`${t}, ${e}, ${n}${o}`:e,d=[[or.default.instancePath,(0,xe.strConcat)(or.default.instancePath,s)],[or.default.parentData,i.parentData],[or.default.parentDataProperty,i.parentDataProperty],[or.default.rootData,or.default.rootData]];i.opts.dynamicRef&&d.push([or.default.dynamicAnchors,or.default.dynamicAnchors]);let p=(0,xe._)`${l}, ${r.object(...d)}`;return c!==xe.nil?(0,xe._)`${a}.call(${c}, ${p})`:(0,xe._)`${a}(${p})`}he.callValidateCode=Z$;var D$=(0,xe._)`new RegExp`;function L$({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,xe._)`${o.code==="new RegExp"?D$:(0,N$.useFunc)(t,o)}(${r}, ${n})`})}he.usePattern=L$;function q$(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,xe._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:Qu.Type.Num},s),e.if((0,xe.not)(s),a)})}}he.validateArray=q$;function U$(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,Qu.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,xe._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,xe.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}he.validateUnion=U$});var nh=I(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.validateKeywordUsage=Nt.validSchemaType=Nt.funcKeywordCode=Nt.macroKeywordCode=void 0;var We=X(),Lr=Vt(),F$=mt(),V$=vo();function H$(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=rh(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:We.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}Nt.macroKeywordCode=H$;function B$(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;K$(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=rh(n,o,u),d=n.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)h(),e.modifying&&th(t),g(()=>t.error());else{let y=e.async?m():f();e.modifying&&th(t),g(()=>J$(t,y))}}function m(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,We._)`await `),_=>n.assign(d,!1).if((0,We._)`${_} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,We._)`${_}.errors`),()=>n.throw(_))),y}function f(){let y=(0,We._)`${l}.errors`;return n.assign(y,null),h(We.nil),y}function h(y=e.async?(0,We._)`await `:We.nil){let _=c.opts.passContext?Lr.default.this:Lr.default.self,w=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,We._)`${y}${(0,F$.callValidateCode)(t,l,_,w)}`,e.modifying)}function g(y){var _;n.if((0,We.not)((_=e.valid)!==null&&_!==void 0?_:d),y)}}Nt.funcKeywordCode=B$;function th(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,We._)`${n.parentData}[${n.parentDataProperty}]`))}function J$(t,e){let{gen:r}=t;r.if((0,We._)`Array.isArray(${e})`,()=>{r.assign(Lr.default.vErrors,(0,We._)`${Lr.default.vErrors} === null ? ${e} : ${Lr.default.vErrors}.concat(${e})`).assign(Lr.default.errors,(0,We._)`${Lr.default.vErrors}.length`),(0,V$.extendErrors)(t)},()=>t.error())}function K$({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function rh(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,We.stringify)(r)})}function W$(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")}Nt.validSchemaType=W$;function G$({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)}}Nt.validateKeywordUsage=G$});var sh=I(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.extendSubschemaMode=sr.extendSubschemaData=sr.getSubschema=void 0;var Ot=X(),oh=ue();function Y$(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,Ot._)`${t.schemaPath}${(0,Ot.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Ot._)`${t.schemaPath}${(0,Ot.getProperty)(e)}${(0,Ot.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,oh.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')}sr.getSubschema=Y$;function X$(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:d}=e,p=a.let("data",(0,Ot._)`${e.data}${(0,Ot.getProperty)(r)}`,!0);c(p),t.errorPath=(0,Ot.str)`${u}${(0,oh.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Ot._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof Ot.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]}}sr.extendSubschemaData=X$;function Q$(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}sr.extendSubschemaMode=Q$});var rl=I((_C,ih)=>{"use strict";ih.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 ch=I((vC,ah)=>{"use strict";var ir=ah.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(){};ti(e,n,o,t,"",t)};ir.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};ir.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};ir.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};ir.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 ti(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 d=n[l];if(Array.isArray(d)){if(l in ir.arrayKeywords)for(var p=0;p<d.length;p++)ti(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in ir.propsKeywords){if(d&&typeof d=="object")for(var m in d)ti(t,e,r,d[m],o+"/"+l+"/"+ek(m),s,o,l,n,m)}else(l in ir.keywords||t.allKeys&&!(l in ir.skipKeywords))&&ti(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function ek(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var xo=I(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.getSchemaRefs=rt.resolveUrl=rt.normalizeId=rt._getFullPath=rt.getFullPath=rt.inlineRef=void 0;var tk=ue(),rk=rl(),nk=ch(),ok=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function sk(t,e=!0){return typeof t=="boolean"?!0:e===!0?!nl(t):e?uh(t)<=e:!1}rt.inlineRef=sk;var ik=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function nl(t){for(let e in t){if(ik.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(nl)||typeof r=="object"&&nl(r))return!0}return!1}function uh(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!ok.has(r)&&(typeof t[r]=="object"&&(0,tk.eachItem)(t[r],n=>e+=uh(n)),e===1/0))return 1/0}return e}function lh(t,e="",r){r!==!1&&(e=xn(e));let n=t.parse(e);return dh(t,n)}rt.getFullPath=lh;function dh(t,e){return t.serialize(e).split("#")[0]+"#"}rt._getFullPath=dh;var ak=/#\/?$/;function xn(t){return t?t.replace(ak,""):""}rt.normalizeId=xn;function ck(t,e,r){return r=xn(r),t.resolve(e,r)}rt.resolveUrl=ck;var uk=/^[a-z_][-a-z0-9._]*$/i;function lk(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=xn(t[r]||e),s={"":o},i=lh(n,o,!1),a={},c=new Set;return nk(t,{allKeys:!0},(d,p,m,f)=>{if(f===void 0)return;let h=i+p,g=s[f];typeof d[r]=="string"&&(g=y.call(this,d[r])),_.call(this,d.$anchor),_.call(this,d.$dynamicAnchor),s[p]=g;function y(w){let x=this.opts.uriResolver.resolve;if(w=xn(g?x(g,w):w),c.has(w))throw l(w);c.add(w);let $=this.refs[w];return typeof $=="string"&&($=this.refs[$]),typeof $=="object"?u(d,$.schema,w):w!==xn(h)&&(w[0]==="#"?(u(d,a[w],w),a[w]=d):this.refs[w]=h),w}function _(w){if(typeof w=="string"){if(!uk.test(w))throw new Error(`invalid anchor "${w}"`);y.call(this,`#${w}`)}}}),a;function u(d,p,m){if(p!==void 0&&!rk(d,p))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}rt.getSchemaRefs=lk});var ko=I(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.getData=ar.KeywordCxt=ar.validateFunctionCode=void 0;var gh=Hm(),fh=bo(),sl=Wu(),ri=bo(),dk=Xm(),$o=nh(),ol=sh(),Z=X(),B=Vt(),fk=xo(),Ht=ue(),wo=vo();function pk(t){if(vh(t)&&(bh(t),_h(t))){gk(t);return}yh(t,()=>(0,gh.topBoolOrEmptySchema)(t))}ar.validateFunctionCode=pk;function yh({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,Z._)`${B.default.data}, ${B.default.valCxt}`,n.$async,()=>{t.code((0,Z._)`"use strict"; ${ph(r,o)}`),hk(t,o),t.code(s)}):t.func(e,(0,Z._)`${B.default.data}, ${mk(o)}`,n.$async,()=>t.code(ph(r,o)).code(s))}function mk(t){return(0,Z._)`{${B.default.instancePath}="", ${B.default.parentData}, ${B.default.parentDataProperty}, ${B.default.rootData}=${B.default.data}${t.dynamicRef?(0,Z._)`, ${B.default.dynamicAnchors}={}`:Z.nil}}={}`}function hk(t,e){t.if(B.default.valCxt,()=>{t.var(B.default.instancePath,(0,Z._)`${B.default.valCxt}.${B.default.instancePath}`),t.var(B.default.parentData,(0,Z._)`${B.default.valCxt}.${B.default.parentData}`),t.var(B.default.parentDataProperty,(0,Z._)`${B.default.valCxt}.${B.default.parentDataProperty}`),t.var(B.default.rootData,(0,Z._)`${B.default.valCxt}.${B.default.rootData}`),e.dynamicRef&&t.var(B.default.dynamicAnchors,(0,Z._)`${B.default.valCxt}.${B.default.dynamicAnchors}`)},()=>{t.var(B.default.instancePath,(0,Z._)`""`),t.var(B.default.parentData,(0,Z._)`undefined`),t.var(B.default.parentDataProperty,(0,Z._)`undefined`),t.var(B.default.rootData,B.default.data),e.dynamicRef&&t.var(B.default.dynamicAnchors,(0,Z._)`{}`)})}function gk(t){let{schema:e,opts:r,gen:n}=t;yh(t,()=>{r.$comment&&e.$comment&&wh(t),xk(t),n.let(B.default.vErrors,null),n.let(B.default.errors,0),r.unevaluated&&yk(t),xh(t),kk(t)})}function yk(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,Z._)`${r}.evaluated`),e.if((0,Z._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,Z._)`${t.evaluated}.props`,(0,Z._)`undefined`)),e.if((0,Z._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,Z._)`${t.evaluated}.items`,(0,Z._)`undefined`))}function ph(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,Z._)`/*# sourceURL=${r} */`:Z.nil}function _k(t,e){if(vh(t)&&(bh(t),_h(t))){vk(t,e);return}(0,gh.boolOrEmptySchema)(t,e)}function _h({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 vh(t){return typeof t.schema!="boolean"}function vk(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&wh(t),wk(t),$k(t);let s=n.const("_errs",B.default.errors);xh(t,s),n.var(e,(0,Z._)`${s} === ${B.default.errors}`)}function bh(t){(0,Ht.checkUnknownRules)(t),bk(t)}function xh(t,e){if(t.opts.jtd)return mh(t,[],!1,e);let r=(0,fh.getSchemaTypes)(t.schema),n=(0,fh.coerceAndCheckDataType)(t,r);mh(t,r,!n,e)}function bk(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Ht.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function xk(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ht.checkStrictMode)(t,"default is ignored in the schema root")}function wk(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,fk.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function $k(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function wh({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,Z._)`${B.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,Z.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,Z._)`${B.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function kk(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,Z._)`${B.default.errors} === 0`,()=>e.return(B.default.data),()=>e.throw((0,Z._)`new ${o}(${B.default.vErrors})`)):(e.assign((0,Z._)`${n}.errors`,B.default.vErrors),s.unevaluated&&Sk(t),e.return((0,Z._)`${B.default.errors} === 0`))}function Sk({gen:t,evaluated:e,props:r,items:n}){r instanceof Z.Name&&t.assign((0,Z._)`${e}.props`,r),n instanceof Z.Name&&t.assign((0,Z._)`${e}.items`,n)}function mh(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,Ht.schemaHasRulesButRef)(s,l))){o.block(()=>kh(t,"$ref",l.all.$ref.definition));return}c.jtd||zk(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,sl.shouldUseGroup)(s,p)&&(p.type?(o.if((0,ri.checkDataType)(p.type,i,c.strictNumbers)),hh(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,ri.reportTypeError)(t)),o.endIf()):hh(t,p),a||o.if((0,Z._)`${B.default.errors} === ${n||0}`))}}function hh(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,dk.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,sl.shouldUseRule)(n,s)&&kh(t,s.keyword,s.definition,e.type)})}function zk(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Pk(t,e),t.opts.allowUnionTypes||Tk(t,e),Ek(t,t.dataTypes))}function Pk(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{$h(t.dataTypes,r)||il(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Rk(t,e)}}function Tk(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&il(t,"use allowUnionTypes to allow union type keyword")}function Ek(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,sl.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Ik(e,i))&&il(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Ik(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function $h(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Rk(t,e){let r=[];for(let n of t.dataTypes)$h(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function il(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ht.checkStrictMode)(t,e,t.opts.strictTypes)}var ni=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,Ht.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",Sh(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",B.default.errors))}result(e,r,n){this.failResult((0,Z.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,Z.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,Z._)`${r} !== undefined && (${(0,Z.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?wo.reportExtraError:wo.reportError)(this,this.def.error,r)}$dataError(){(0,wo.reportError)(this,this.def.$dataError||wo.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,wo.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=Z.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=Z.nil,r=Z.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,Z.or)((0,Z._)`${o} === undefined`,r)),e!==Z.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==Z.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,Z.or)(i(),a());function i(){if(n.length){if(!(r instanceof Z.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,Z._)`${(0,ri.checkDataTypes)(c,r,s.opts.strictNumbers,ri.DataType.Wrong)}`}return Z.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,Z._)`!${c}(${r})`}return Z.nil}}subschema(e,r){let n=(0,ol.getSubschema)(this.it,e);(0,ol.extendSubschemaData)(n,this.it,e),(0,ol.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return _k(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Ht.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Ht.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,Z.Name)),!0}};ar.KeywordCxt=ni;function kh(t,e,r,n){let o=new ni(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 Nk=/^\/(?:[^~]|~0|~1)*$/,Ok=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Sh(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return B.default.rootData;if(t[0]==="/"){if(!Nk.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=B.default.rootData}else{let u=Ok.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,Z._)`${s}${(0,Z.getProperty)((0,Ht.unescapeJsonPointer)(u))}`,i=(0,Z._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}ar.getData=Sh});var oi=I(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});var al=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};cl.default=al});var So=I(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});var ul=xo(),ll=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,ul.resolveUrl)(e,r,n),this.missingSchema=(0,ul.normalizeId)((0,ul.getFullPath)(e,this.missingRef))}};dl.default=ll});var ii=I(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.resolveSchema=ht.getCompilingSchema=ht.resolveRef=ht.compileSchema=ht.SchemaEnv=void 0;var wt=X(),Ck=oi(),qr=Vt(),$t=xo(),zh=ue(),jk=ko(),wn=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,$t.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};ht.SchemaEnv=wn;function pl(t){let e=Ph.call(this,t);if(e)return e;let r=(0,$t.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new wt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:Ck.default,code:(0,wt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:qr.default.data,parentData:qr.default.parentData,parentDataProperty:qr.default.parentDataProperty,dataNames:[qr.default.data],dataPathArr:[wt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,wt.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:wt.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,wt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,jk.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(qr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${qr.default.self}`,`${qr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:f,items:h}=u;m.evaluated={props:f instanceof wt.Name?void 0:f,items:h instanceof wt.Name?void 0:h,dynamicProps:f instanceof wt.Name,dynamicItems:h instanceof wt.Name},m.source&&(m.source.evaluated=(0,wt.stringify)(m.evaluated))}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}ht.compileSchema=pl;function Ak(t,e,r){var n;r=(0,$t.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Dk.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 wn({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=Mk.call(this,s)}ht.resolveRef=Ak;function Mk(t){return(0,$t.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:pl.call(this,t)}function Ph(t){for(let e of this._compilations)if(Zk(e,t))return e}ht.getCompilingSchema=Ph;function Zk(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Dk(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||si.call(this,t,e)}function si(t,e){let r=this.opts.uriResolver.parse(e),n=(0,$t._getFullPath)(this.opts.uriResolver,r),o=(0,$t.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return fl.call(this,r,t);let s=(0,$t.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=si.call(this,t,i);return typeof a?.schema!="object"?void 0:fl.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||pl.call(this,i),s===(0,$t.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,$t.resolveUrl)(this.opts.uriResolver,o,u)),new wn({schema:a,schemaId:c,root:t,baseId:o})}return fl.call(this,r,i)}}ht.resolveSchema=si;var Lk=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function fl(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,zh.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Lk.has(a)&&u&&(e=(0,$t.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,zh.schemaHasRulesButRef)(r,this.RULES)){let a=(0,$t.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=si.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new wn({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var Th=I((SC,qk)=>{qk.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 vl=I((zC,jh)=>{"use strict";var Uk=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),hl=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),Ur=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),gl=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Ih=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),yl=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),Fk=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),nt=new Array(256);{let t="0123456789ABCDEF";for(let e=0;e<256;e++)nt[e]="%"+t[e>>4]+t[e&15]}function Fe(t){return t<2048?nt[192|t>>6]+nt[128|t&63]:t<65536?nt[224|t>>12]+nt[128|t>>6&63]+nt[128|t&63]:nt[240|t>>18]+nt[128|t>>12&63]+nt[128|t>>6&63]+nt[128|t&63]}function Vk(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 Hk=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),Bk=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),Jk=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),Kk=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Wk(t){if(t.length===0)return!1;for(let e=0;e<t.length;e++)if(!Jk(t[e])){if(t[e]==="%"&&e+2<t.length&&Ur(t.slice(e+1,e+3))){e+=2;continue}return!1}return!0}function Eh(t){let e=-1,r=0,n=-1,o=0;for(let a=0;a<t.length;a++)t[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,e=n)):(n=-1,o=0);if(r<2)return t.join(":");let s=t.slice(0,e).join(":"),i=t.slice(e+r).join(":");return s+"::"+i}function Gk(t){let e=t.indexOf("::");if(e!==-1&&t.indexOf("::",e+1)!==-1)return;let r=e===-1?t.split(":"):t.slice(0,e).split(":"),n=e===-1?[]:t.slice(e+2).split(":");e!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||e!==-1&&n.length===0||!hl(c))return;s+=2;continue}if(!Hk(c))return;o[a]=parseInt(c,16).toString(16),s++}if(e===-1)return s!==8?void 0:Eh(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return Eh(i)}function ml(t){let e=t[0]==="["&&t[t.length-1]==="]";if((t[0]==="["||t[t.length-1]==="]")&&!e)return{host:t,isIPV6:!1,error:!0};let n=e?t.slice(1,-1):t;if(e&&Bk(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(Yk(n,":")<2)return{host:t,isIPV6:!1,error:e};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!Wk(o))return{host:t,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=Gk(n);return i===void 0?{host:t,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function Yk(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function Xk(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("")}var Qk={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},eS=/[@/?#:]/g,tS=/[@/?#]/g;function Rh(t,e){let r=e?tS:eS;return r.lastIndex=0,t.replace(r,n=>Qk[n])}function Nh(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let o=t.slice(n+1,n+3);if(Ur(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));e&&gl(i)?r+=i:r+="%"+s,n+=2;continue}}r+=t[n]}return r}function rS(t){let e="";for(let r=0;r<t.length;r++){let n=t[r];if(n==="%"&&r+2<t.length){let o=t.slice(r+1,r+3);if(Ur(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&gl(i)?e+=i:e+="%"+s,r+=2;continue}}if(Ih(n))e+=n;else{let o=t.charCodeAt(r);if(o<128)e+=Ch(o)?n:nt[o];else if(o<55296||o>57343)e+=Fe(o);else if(o<=56319&&r+1<t.length){let s=t.charCodeAt(r+1);s>=56320&&s<=57343?(e+=Fe(65536+(o-55296<<10)+(s-56320)),r++):e+=Fe(65533)}else e+=Fe(65533)}}return e}function nS(t,e=!1){let r="",n=e&&t[0]!=="/";for(let o=0;o<t.length;o++){let s=t[o];if(s==="%"&&o+2<t.length){let i=t.slice(o+1,o+3);if(Ur(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),Ih(s)&&(s!==":"||!n))r+=s;else{let i=t.charCodeAt(o);if(i<128)r+=nt[i];else if(i<55296||i>57343)r+=Fe(i);else if(i<=56319&&o+1<t.length){let a=t.charCodeAt(o+1);a>=56320&&a<=57343?(r+=Fe(65536+(i-55296<<10)+(a-56320)),o++):r+=Fe(65533)}else r+=Fe(65533)}}return r}function _l(t,e){let r="";for(let n=0;n<t.length;n++){let o=t[n];if(o==="%"&&n+2<t.length){let s=t.slice(n+1,n+3);if(Ur(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(e(o))r+=o;else{let s=t.charCodeAt(n);if(s<128)r+=nt[s];else if(s<55296||s>57343)r+=Fe(s);else if(s<=56319&&n+1<t.length){let i=t.charCodeAt(n+1);i>=56320&&i<=57343?(r+=Fe(65536+(s-55296<<10)+(i-56320)),n++):r+=Fe(65533)}else r+=Fe(65533)}}return r}function Oh(t){return _l(t,Fk)}function oS(t){return _l(t,yl)}function sS(t){return _l(t,yl)}function Ch(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===42||t===43||t===45||t===46||t===47||t===64||t===95}function iS(t){let e="";for(let r=0;r<t.length;r++){let n=t[r];if(n==="%"&&r+2<t.length){let o=t.slice(r+1,r+3);if(Ur(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));gl(i)?e+=i:e+="%"+s,r+=2;continue}}if(yl(n))e+=n;else{let o=t.charCodeAt(r);if(o<128)e+=Ch(o)?n:nt[o];else if(o<55296||o>57343)e+=Fe(o);else if(o<=56319&&r+1<t.length){let s=t.charCodeAt(r+1);s>=56320&&s<=57343?(e+=Fe(65536+(o-55296<<10)+(s-56320)),r++):e+=Fe(65533)}else e+=Fe(65533)}}return e}function aS(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Ur(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function cS(t){let e=[];if(t.userinfo!==void 0&&(e.push(Oh(t.userinfo)),e.push("@")),t.host!==void 0){let r=t.host;if(!hl(r)){let n=ml(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=Nh(r,!0),n=ml(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=Rh(r,!1)}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}jh.exports={nonSimpleDomain:Kk,recomposeAuthority:cS,reescapeHostDelimiters:Rh,normalizePercentEncoding:Nh,normalizePathEncoding:rS,serializePathEncoding:nS,normalizeQueryFragmentEncoding:iS,encodeUserinfo:Oh,encodeQuery:oS,encodeFragment:sS,escapePreservingEscapes:aS,removeDotSegments:Xk,isIPv4:hl,isUUID:Uk,normalizeIPv6:ml,stringArrayToHexStripped:Vk}});var Lh=I((PC,Dh)=>{"use strict";var{isUUID:uS}=vl(),lS=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,dS=["http","https","ws","wss","urn","urn:uuid"];function fS(t){return dS.indexOf(t)!==-1}function bl(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 Ah(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Mh(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 pS(t){return t.secure=bl(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function mS(t){if((t.port===(bl(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=t.resourceName.indexOf("?"),r=e===-1?t.resourceName:t.resourceName.slice(0,e);t.path=r&&r!=="/"?r:void 0,t.query=e===-1?void 0:t.resourceName.slice(e+1),t.resourceName=void 0}return t.fragment=void 0,t}function hS(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(lS);if(r&&r[0]===t.path){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=xl(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function gS(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=xl(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 yS(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!uS(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function _S(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Zh={scheme:"http",domainHost:!0,parse:Ah,serialize:Mh},vS={scheme:"https",domainHost:Zh.domainHost,parse:Ah,serialize:Mh},ai={scheme:"ws",domainHost:!0,parse:pS,serialize:mS},bS={scheme:"wss",domainHost:ai.domainHost,parse:ai.parse,serialize:ai.serialize},xS={scheme:"urn",parse:hS,serialize:gS,skipNormalize:!0},wS={scheme:"urn:uuid",parse:yS,serialize:_S,skipNormalize:!0},ci={http:Zh,https:vS,ws:ai,wss:bS,urn:xS,"urn:uuid":wS};Object.setPrototypeOf(ci,null);function xl(t){return t&&(ci[t]||ci[t.toLowerCase()])||void 0}Dh.exports={wsIsSecure:bl,SCHEMES:ci,isValidSchemeName:fS,getSchemeHandler:xl}});var eg=I((TC,di)=>{"use strict";var{normalizeIPv6:Hh,removeDotSegments:Po,recomposeAuthority:$S,normalizePercentEncoding:Bh,normalizePathEncoding:kS,serializePathEncoding:qh,normalizeQueryFragmentEncoding:Uh,encodeQuery:SS,encodeFragment:zS,reescapeHostDelimiters:PS,isIPv4:Jh,nonSimpleDomain:TS}=vl(),{SCHEMES:Kh,getSchemeHandler:wl}=Lh(),Wh=/^[A-Za-z][A-Za-z0-9+.-]*$/u,Gh="URI scheme is malformed.";function Fh(t){let e=unescape(String(t));if(!Wh.test(e))throw new TypeError(Gh);return e}function ES(t,e){return typeof t=="string"?t=MS(t,e):typeof t=="object"&&(t=li(Fr(t,e),e)),t}function IS(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=ui(t,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:p,malformedSchemeSpecific:m,malformedHost:f,malformedScheme:h}=ui(e,n);if(s||d||i||p||a||m||c||f||u||h)throw new Error(o.error||l.error||"URI is malformed.");let g=Yh(o,l,n,!0),y=wl(r&&r.scheme||g.scheme),_=g.host,w=_!==void 0&&_!==""&&(Jh(_)||Hh(_).isIPV6);Xh(g,r||{},y,w);let x=_&&_.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(_);if(g.error&&!x)throw new Error(g.error);return n.skipEscape=!0,Fr(g,n)}function Yh(t,e,r,n){let o={};return n||(t=li(Fr(t,r),r),e=li(Fr(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=Po(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=Po(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=Po(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=Po(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 RS(t,e,r){let n=Vh(t,r),o=Vh(e,r);return n!==void 0&&o!==void 0&&n===o}function Fr(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=[];r.scheme&&(r.scheme=Fh(r.scheme));let s=wl(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!n.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(n.skipEscape?r.path=Bh(r.path):r.path=qh(r.path,a)),n.reference!=="suffix"&&r.scheme&&(r.scheme=Fh(r.scheme),o.push(r.scheme,":"));let c=$S(r);if(c!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(c),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=Po(u)),a&&(u=qh(u,!0)),c===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",SS(r.query)),r.fragment!==void 0&&o.push("#",zS(r.fragment)),o.join("")}var NS=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,OS=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,CS=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function jS(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function zo(t){if(t===void 0)return!1;let e=t.indexOf("%");for(;e!==-1;){if(e+2>=t.length||!/^[\da-f]{2}$/iu.test(t.slice(e+1,e+3)))return!0;e=t.indexOf("%",e+3)}return!1}function AS(t){let e=t[4];return zo(t[3])||e!==void 0&&!(e[0]==="["&&e[e.length-1]==="]")&&zo(e)||zo(t[6])||zo(t[7])||zo(t[8])}function Xh(t,e,r,n){if(!e.unicodeSupport&&(!r||!r.unicodeSupport)&&t.host&&t.host[0]!=="["&&(e.domainHost||r&&r.domainHost)&&n===!1&&TS(t.host))try{t.host=new URL("http://"+t.host).hostname}catch(o){return t.error=t.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function ui(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,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let d=t.match(OS);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let p=t.match(CS);if(p!==null){let f=p[1],h=f.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):f.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let m=t.match(NS);if(m){if(n.scheme=m[1],n.userinfo=m[3],n.host=m[4],n.port=parseInt(m[5],10),n.path=m[6]||"",n.query=m[7],n.fragment=m[8],n.scheme!==void 0){let g=unescape(n.scheme);Wh.test(g)?n.scheme=g.toLowerCase():(n.error=n.error||Gh,u=!0)}s=AS(m),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=m[5]);let f=jS(n,m);if(f!==void 0&&(n.error=n.error||f,o=!0),n.host)if(Jh(n.host)===!1){let y=n.host[0]==="["&&n.host[n.host.length-1]==="]",_=Hh(n.host);l=_.isIPV6||_.isIPVFuture===!0,c=y&&_.error===!0,n.host=l?_.host:_.host.toLowerCase(),c&&(n.error=n.error||"URI host is malformed.",o=!0)}else l=!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 h=wl(r.scheme||n.scheme);if(a=Xh(n,r,h,l),!h||h&&!h.skipNormalize){if(t.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:Bh(n.host,!0);n.host=PS(g,l)}n.path&&(n.path=kS(n.path)),n.query&&(n.query=Uh(n.query)),n.fragment&&(n.fragment=Uh(n.fragment))}h&&h.parse&&(h.parse(n,r),h===Kh.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function li(t,e){return ui(t,e).parsed}function MS(t,e){return Qh(t,e).normalized}function Qh(t,e){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=ui(t,e);return{normalized:n||o||s||i||a?t:Fr(r,e),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function Vh(t,e){if(typeof t!="string"&&typeof t!="object")return;let r;try{r=typeof t=="string"?t:Fr(t,e)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=Qh(r,e);return o||s||i||a||c?void 0:n}var $l={SCHEMES:Kh,normalize:ES,resolve:IS,resolveComponent:Yh,equal:RS,serialize:Fr,parse:li};di.exports=$l;di.exports.default=$l;di.exports.fastUri=$l});var rg=I(kl=>{"use strict";Object.defineProperty(kl,"__esModule",{value:!0});var tg=eg();tg.code='require("ajv/dist/runtime/uri").default';kl.default=tg});var lg=I(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.CodeGen=Me.Name=Me.nil=Me.stringify=Me.str=Me._=Me.KeywordCxt=void 0;var ZS=ko();Object.defineProperty(Me,"KeywordCxt",{enumerable:!0,get:function(){return ZS.KeywordCxt}});var $n=X();Object.defineProperty(Me,"_",{enumerable:!0,get:function(){return $n._}});Object.defineProperty(Me,"str",{enumerable:!0,get:function(){return $n.str}});Object.defineProperty(Me,"stringify",{enumerable:!0,get:function(){return $n.stringify}});Object.defineProperty(Me,"nil",{enumerable:!0,get:function(){return $n.nil}});Object.defineProperty(Me,"Name",{enumerable:!0,get:function(){return $n.Name}});Object.defineProperty(Me,"CodeGen",{enumerable:!0,get:function(){return $n.CodeGen}});var DS=oi(),ag=So(),LS=Ku(),To=ii(),qS=X(),Eo=xo(),fi=bo(),zl=ue(),ng=Th(),US=rg(),cg=(t,e)=>new RegExp(t,e);cg.code="new RegExp";var FS=["removeAdditional","useDefaults","coerceTypes"],VS=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),HS={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."},BS={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},og=200;function JS(t){var e,r,n,o,s,i,a,c,u,l,d,p,m,f,h,g,y,_,w,x,$,P,J,H,k;let O=t.strict,E=(e=t.code)===null||e===void 0?void 0:e.optimize,F=E===!0||E===void 0?1:E||0,re=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:cg,K=(o=t.uriResolver)!==null&&o!==void 0?o:US.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:O)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:O)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:O)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:O)!==null&&p!==void 0?p:"log",strictRequired:(f=(m=t.strictRequired)!==null&&m!==void 0?m:O)!==null&&f!==void 0?f:!1,code:t.code?{...t.code,optimize:F,regExp:re}:{optimize:F,regExp:re},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:og,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:og,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(_=t.messages)!==null&&_!==void 0?_:!0,inlineRefs:(w=t.inlineRefs)!==null&&w!==void 0?w:!0,schemaId:(x=t.schemaId)!==null&&x!==void 0?x:"$id",addUsedSchema:($=t.addUsedSchema)!==null&&$!==void 0?$:!0,validateSchema:(P=t.validateSchema)!==null&&P!==void 0?P:!0,validateFormats:(J=t.validateFormats)!==null&&J!==void 0?J:!0,unicodeRegExp:(H=t.unicodeRegExp)!==null&&H!==void 0?H:!0,int32range:(k=t.int32range)!==null&&k!==void 0?k:!0,uriResolver:K}}var Io=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...JS(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new qS.ValueScope({scope:{},prefixes:VS,es5:r,lines:n}),this.logger=QS(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,LS.getRules)(),sg.call(this,HS,e,"NOT SUPPORTED"),sg.call(this,BS,e,"DEPRECATED","warn"),this._metaOpts=YS.call(this),e.formats&&WS.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&GS.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),KS.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=ng;n==="id"&&(o={...ng},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,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}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(d){if(!(d instanceof ag.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;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,Eo.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=ig.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new To.SchemaEnv({schema:{},schemaId:n});if(r=To.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=ig.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,Eo.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(tz.call(this,n,r),!r)return(0,zl.eachItem)(n,s=>Sl.call(this,s)),this;nz.call(this,r);let o={...r,type:(0,fi.getJSONTypes)(r.type),schemaType:(0,fi.getJSONTypes)(r.schemaType)};return(0,zl.eachItem)(n,o.type.length===0?s=>Sl.call(this,s,o):s=>o.type.forEach(i=>Sl.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]=ug(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,Eo.normalizeId)(i||n);let u=Eo.getSchemaRefs.call(this,e,n);return c=new To.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):To.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{To.compileSchema.call(this,e)}finally{this.opts=r}}};Io.ValidationError=DS.default;Io.MissingRefError=ag.default;Me.default=Io;function sg(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 ig(t){return t=(0,Eo.normalizeId)(t),this.schemas[t]||this.refs[t]}function KS(){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 WS(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function GS(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 YS(){let t={...this.opts};for(let e of FS)delete t[e];return t}var XS={log(){},warn(){},error(){}};function QS(t){if(t===!1)return XS;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 ez=/^[a-z_$][a-z0-9_$:-]*$/i;function tz(t,e){let{RULES:r}=this;if((0,zl.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!ez.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 Sl(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,fi.getJSONTypes)(e.type),schemaType:(0,fi.getJSONTypes)(e.schemaType)}};e.before?rz.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 rz(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 nz(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=ug(e)),t.validateSchema=this.compile(e,!0))}var oz={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ug(t){return{anyOf:[t,oz]}}});var dg=I(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});var sz={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Pl.default=sz});var hg=I(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.callRef=Vr.getValidate=void 0;var iz=So(),fg=mt(),ot=X(),kn=Vt(),pg=ii(),pi=ue(),az={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 d();let l=pg.resolveRef.call(c,u,o,r);if(l===void 0)throw new iz.default(n.opts.uriResolver,o,r);if(l instanceof pg.SchemaEnv)return p(l);return m(l);function d(){if(s===u)return mi(t,i,s,s.$async);let f=e.scopeValue("root",{ref:u});return mi(t,(0,ot._)`${f}.validate`,u,u.$async)}function p(f){let h=mg(t,f);mi(t,h,f,f.$async)}function m(f){let h=e.scopeValue("schema",a.code.source===!0?{ref:f,code:(0,ot.stringify)(f)}:{ref:f}),g=e.name("valid"),y=t.subschema({schema:f,dataTypes:[],schemaPath:ot.nil,topSchemaRef:h,errSchemaPath:r},g);t.mergeEvaluated(y),t.ok(g)}}};function mg(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,ot._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Vr.getValidate=mg;function mi(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?kn.default.this:ot.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let f=o.let("valid");o.try(()=>{o.code((0,ot._)`await ${(0,fg.callValidateCode)(t,e,u)}`),m(e),i||o.assign(f,!0)},h=>{o.if((0,ot._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),p(h),i||o.assign(f,!1)}),t.ok(f)}function d(){t.result((0,fg.callValidateCode)(t,e,u),()=>m(e),()=>p(e))}function p(f){let h=(0,ot._)`${f}.errors`;o.assign(kn.default.vErrors,(0,ot._)`${kn.default.vErrors} === null ? ${h} : ${kn.default.vErrors}.concat(${h})`),o.assign(kn.default.errors,(0,ot._)`${kn.default.vErrors}.length`)}function m(f){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=pi.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,ot._)`${f}.evaluated.props`);s.props=pi.mergeEvaluated.props(o,y,s.props,ot.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=pi.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,ot._)`${f}.evaluated.items`);s.items=pi.mergeEvaluated.items(o,y,s.items,ot.Name)}}}Vr.callRef=mi;Vr.default=az});var gg=I(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});var cz=dg(),uz=hg(),lz=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",cz.default,uz.default];Tl.default=lz});var yg=I(El=>{"use strict";Object.defineProperty(El,"__esModule",{value:!0});var hi=X(),cr=hi.operators,gi={maximum:{okStr:"<=",ok:cr.LTE,fail:cr.GT},minimum:{okStr:">=",ok:cr.GTE,fail:cr.LT},exclusiveMaximum:{okStr:"<",ok:cr.LT,fail:cr.GTE},exclusiveMinimum:{okStr:">",ok:cr.GT,fail:cr.LTE}},dz={message:({keyword:t,schemaCode:e})=>(0,hi.str)`must be ${gi[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,hi._)`{comparison: ${gi[t].okStr}, limit: ${e}}`},fz={keyword:Object.keys(gi),type:"number",schemaType:"number",$data:!0,error:dz,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,hi._)`${r} ${gi[e].fail} ${n} || isNaN(${r})`)}};El.default=fz});var _g=I(Il=>{"use strict";Object.defineProperty(Il,"__esModule",{value:!0});var Ro=X(),pz={message:({schemaCode:t})=>(0,Ro.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Ro._)`{multipleOf: ${t}}`},mz={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:pz,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,Ro._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Ro._)`${i} !== parseInt(${i})`;t.fail$data((0,Ro._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Il.default=mz});var bg=I(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});function vg(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}Rl.default=vg;vg.code='require("ajv/dist/runtime/ucs2length").default'});var xg=I(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});var Hr=X(),hz=ue(),gz=bg(),yz={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Hr.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Hr._)`{limit: ${t}}`},_z={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:yz,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?Hr.operators.GT:Hr.operators.LT,i=o.opts.unicode===!1?(0,Hr._)`${r}.length`:(0,Hr._)`${(0,hz.useFunc)(t.gen,gz.default)}(${r})`;t.fail$data((0,Hr._)`${i} ${s} ${n}`)}};Nl.default=_z});var wg=I(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});var vz=mt(),bz=ue(),Sn=X(),xz={message:({schemaCode:t})=>(0,Sn.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Sn._)`{pattern: ${t}}`},wz={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:xz,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,Sn._)`new RegExp`:(0,bz.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,Sn._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,Sn._)`!${l}`)}else{let c=(0,vz.usePattern)(t,o);t.fail$data((0,Sn._)`!${c}.test(${r})`)}}};Ol.default=wz});var $g=I(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:!0});var No=X(),$z={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,No.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,No._)`{limit: ${t}}`},kz={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:$z,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?No.operators.GT:No.operators.LT;t.fail$data((0,No._)`Object.keys(${r}).length ${o} ${n}`)}};Cl.default=kz});var kg=I(jl=>{"use strict";Object.defineProperty(jl,"__esModule",{value:!0});var Oo=mt(),Co=X(),Sz=ue(),zz={message:({params:{missingProperty:t}})=>(0,Co.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Co._)`{missingProperty: ${t}}`},Pz={keyword:"required",type:"object",schemaType:"array",$data:!0,error:zz,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 m=t.parentSchema.properties,{definedProperties:f}=t.it;for(let h of r)if(m?.[h]===void 0&&!f.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,Sz.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(Co.nil,d);else for(let m of r)(0,Oo.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||s){let f=e.let("valid",!0);t.block$data(f,()=>p(m,f)),t.ok(f)}else e.if((0,Oo.checkMissingProp)(t,r,m)),(0,Oo.reportMissingProp)(t,m),e.else()}function d(){e.forOf("prop",n,m=>{t.setParams({missingProperty:m}),e.if((0,Oo.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function p(m,f){t.setParams({missingProperty:m}),e.forOf(m,n,()=>{e.assign(f,(0,Oo.propertyInData)(e,o,m,a.ownProperties)),e.if((0,Co.not)(f),()=>{t.error(),e.break()})},Co.nil)}}};jl.default=Pz});var Sg=I(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});var jo=X(),Tz={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,jo.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,jo._)`{limit: ${t}}`},Ez={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Tz,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?jo.operators.GT:jo.operators.LT;t.fail$data((0,jo._)`${r}.length ${o} ${n}`)}};Al.default=Ez});var yi=I(Ml=>{"use strict";Object.defineProperty(Ml,"__esModule",{value:!0});var zg=rl();zg.code='require("ajv/dist/runtime/equal").default';Ml.default=zg});var Pg=I(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0});var Zl=bo(),Ze=X(),Iz=ue(),Rz=yi(),Nz={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}}`},Oz={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Nz,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,Zl.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`),h=e.let("j");t.setParams({i:f,j:h}),e.assign(c,!0),e.if((0,Ze._)`${f} > 1`,()=>(d()?p:m)(f,h))}function d(){return u.length>0&&!u.some(f=>f==="object"||f==="array")}function p(f,h){let g=e.name("item"),y=(0,Zl.checkDataTypes)(u,g,a.opts.strictNumbers,Zl.DataType.Wrong),_=e.const("indices",(0,Ze._)`{}`);e.for((0,Ze._)`;${f}--;`,()=>{e.let(g,(0,Ze._)`${r}[${f}]`),e.if(y,(0,Ze._)`continue`),u.length>1&&e.if((0,Ze._)`typeof ${g} == "string"`,(0,Ze._)`${g} += "_"`),e.if((0,Ze._)`typeof ${_}[${g}] == "number"`,()=>{e.assign(h,(0,Ze._)`${_}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,Ze._)`${_}[${g}] = ${f}`)})}function m(f,h){let g=(0,Iz.useFunc)(e,Rz.default),y=e.name("outer");e.label(y).for((0,Ze._)`;${f}--;`,()=>e.for((0,Ze._)`${h} = ${f}; ${h}--;`,()=>e.if((0,Ze._)`${g}(${r}[${f}], ${r}[${h}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};Dl.default=Oz});var Tg=I(ql=>{"use strict";Object.defineProperty(ql,"__esModule",{value:!0});var Ll=X(),Cz=ue(),jz=yi(),Az={message:"must be equal to constant",params:({schemaCode:t})=>(0,Ll._)`{allowedValue: ${t}}`},Mz={keyword:"const",$data:!0,error:Az,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,Ll._)`!${(0,Cz.useFunc)(e,jz.default)}(${r}, ${o})`):t.fail((0,Ll._)`${s} !== ${r}`)}};ql.default=Mz});var Eg=I(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});var Ao=X(),Zz=ue(),Dz=yi(),Lz={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Ao._)`{allowedValues: ${t}}`},qz={keyword:"enum",schemaType:"array",$data:!0,error:Lz,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,Zz.useFunc)(e,Dz.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",s);l=(0,Ao.or)(...o.map((f,h)=>p(m,h)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,m=>e.if((0,Ao._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function p(m,f){let h=o[f];return typeof h=="object"&&h!==null?(0,Ao._)`${u()}(${r}, ${m}[${f}])`:(0,Ao._)`${r} === ${h}`}}};Ul.default=qz});var Ig=I(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});var Uz=yg(),Fz=_g(),Vz=xg(),Hz=wg(),Bz=$g(),Jz=kg(),Kz=Sg(),Wz=Pg(),Gz=Tg(),Yz=Eg(),Xz=[Uz.default,Fz.default,Vz.default,Hz.default,Bz.default,Jz.default,Kz.default,Wz.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Gz.default,Yz.default];Fl.default=Xz});var Hl=I(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.validateAdditionalItems=void 0;var Br=X(),Vl=ue(),Qz={message:({params:{len:t}})=>(0,Br.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Br._)`{limit: ${t}}`},eP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Qz,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Vl.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Rg(t,n)}};function Rg(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,Br._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Br._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Vl.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,Br._)`${a} <= ${e.length}`);r.if((0,Br.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:Vl.Type.Num},u),i.allErrors||r.if((0,Br.not)(u),()=>r.break())})}}Mo.validateAdditionalItems=Rg;Mo.default=eP});var Bl=I(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.validateTuple=void 0;var Ng=X(),_i=ue(),tP=mt(),rP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Og(t,"additionalItems",e);r.items=!0,!(0,_i.alwaysValidSchema)(r,e)&&t.ok((0,tP.validateArray)(t))}};function Og(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=_i.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Ng._)`${s}.length`);r.forEach((d,p)=>{(0,_i.alwaysValidSchema)(a,d)||(n.if((0,Ng._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(d){let{opts:p,errSchemaPath:m}=a,f=r.length,h=f===d.minItems&&(f===d.maxItems||d[e]===!1);if(p.strictTuples&&!h){let g=`"${i}" is ${f}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,_i.checkStrictMode)(a,g,p.strictTuples)}}}Zo.validateTuple=Og;Zo.default=rP});var Cg=I(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});var nP=Bl(),oP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,nP.validateTuple)(t,"items")};Jl.default=oP});var Ag=I(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});var jg=X(),sP=ue(),iP=mt(),aP=Hl(),cP={message:({params:{len:t}})=>(0,jg.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,jg._)`{limit: ${t}}`},uP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:cP,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,sP.alwaysValidSchema)(n,e)&&(o?(0,aP.validateAdditionalItems)(t,o):t.ok((0,iP.validateArray)(t)))}};Kl.default=uP});var Mg=I(Wl=>{"use strict";Object.defineProperty(Wl,"__esModule",{value:!0});var gt=X(),vi=ue(),lP={message:({params:{min:t,max:e}})=>e===void 0?(0,gt.str)`must contain at least ${t} valid item(s)`:(0,gt.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,gt._)`{minContains: ${t}}`:(0,gt._)`{minContains: ${t}, maxContains: ${e}}`},dP={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:lP,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,gt._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,vi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,vi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,vi.alwaysValidSchema)(s,r)){let h=(0,gt._)`${l} >= ${i}`;a!==void 0&&(h=(0,gt._)`${h} && ${l} <= ${a}`),t.pass(h);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?m(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,gt._)`${o}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let h=e.name("_valid"),g=e.let("count",0);m(h,()=>e.if(h,()=>f(g)))}function m(h,g){e.forRange("i",0,l,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:vi.Type.Num,compositeRule:!0},h),g()})}function f(h){e.code((0,gt._)`${h}++`),a===void 0?e.if((0,gt._)`${h} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,gt._)`${h} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,gt._)`${h} >= ${i}`,()=>e.assign(d,!0)))}}};Wl.default=dP});var Lg=I(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.validateSchemaDeps=Ct.validatePropertyDeps=Ct.error=void 0;var Gl=X(),fP=ue(),Do=mt();Ct.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Gl.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Gl._)`{property: ${t},
|
|
6
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,G._)`[${o}]`)}}}function P$({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,G._)`${e} !== undefined`,()=>t.assign((0,G._)`${e}[${r}]`,n))}function Gu(t,e,r,n=vn.Correct){let o=n===vn.Correct?G.operators.EQ:G.operators.NEQ,s;switch(t){case"null":return(0,G._)`${e} ${o} null`;case"array":s=(0,G._)`Array.isArray(${e})`;break;case"object":s=(0,G._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,G._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,G._)`typeof ${e} ${o} ${t}`}return n===vn.Correct?s:(0,G.not)(s);function i(a=G.nil){return(0,G.and)((0,G._)`typeof ${e} == "number"`,a,r?(0,G._)`isFinite(${e})`:G.nil)}}Ue.checkDataType=Gu;function Yu(t,e,r,n){if(t.length===1)return Gu(t[0],e,r,n);let o,s=(0,Km.toHash)(t);if(s.array&&s.object){let i=(0,G._)`typeof ${e} != "object"`;o=s.null?i:(0,G._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=G.nil;s.number&&delete s.integer;for(let i in s)o=(0,G.and)(o,Gu(i,e,r,n));return o}Ue.checkDataTypes=Yu;var T$={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,G._)`{type: ${t}}`:(0,G._)`{type: ${e}}`};function Xu(t){let e=E$(t);(0,w$.reportError)(e,T$)}Ue.reportTypeError=Xu;function E$(t){let{gen:e,data:r,schema:n}=t,o=(0,Km.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Xm=I(ei=>{"use strict";Object.defineProperty(ei,"__esModule",{value:!0});ei.assignDefaults=void 0;var bn=X(),I$=ue();function R$(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)Ym(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Ym(t,s,o.default))}ei.assignDefaults=R$;function Ym(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,bn._)`${s}${(0,bn.getProperty)(e)}`;if(o){(0,I$.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,bn._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,bn._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,bn._)`${a} = ${(0,bn.stringify)(r)}`)}});var mt=I(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.validateUnion=he.validateArray=he.usePattern=he.callValidateCode=he.schemaProperties=he.allSchemaProperties=he.noPropertyInData=he.propertyInData=he.isOwnProperty=he.hasPropFunc=he.reportMissingProp=he.checkMissingProp=he.checkReportMissingProp=void 0;var xe=X(),Qu=ue(),or=Vt(),N$=ue();function O$(t,e){let{gen:r,data:n,it:o}=t;r.if(tl(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,xe._)`${e}`},!0),t.error()})}he.checkReportMissingProp=O$;function C$({gen:t,data:e,it:{opts:r}},n,o){return(0,xe.or)(...n.map(s=>(0,xe.and)(tl(t,e,s,r.ownProperties),(0,xe._)`${o} = ${s}`)))}he.checkMissingProp=C$;function A$(t,e){t.setParams({missingProperty:e},!0),t.error()}he.reportMissingProp=A$;function Qm(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,xe._)`Object.prototype.hasOwnProperty`})}he.hasPropFunc=Qm;function el(t,e,r){return(0,xe._)`${Qm(t)}.call(${e}, ${r})`}he.isOwnProperty=el;function j$(t,e,r,n){let o=(0,xe._)`${e}${(0,xe.getProperty)(r)} !== undefined`;return n?(0,xe._)`${o} && ${el(t,e,r)}`:o}he.propertyInData=j$;function tl(t,e,r,n){let o=(0,xe._)`${e}${(0,xe.getProperty)(r)} === undefined`;return n?(0,xe.or)(o,(0,xe.not)(el(t,e,r))):o}he.noPropertyInData=tl;function eh(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}he.allSchemaProperties=eh;function M$(t,e){return eh(e).filter(r=>!(0,Qu.alwaysValidSchema)(t,e[r]))}he.schemaProperties=M$;function Z$({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,xe._)`${t}, ${e}, ${n}${o}`:e,d=[[or.default.instancePath,(0,xe.strConcat)(or.default.instancePath,s)],[or.default.parentData,i.parentData],[or.default.parentDataProperty,i.parentDataProperty],[or.default.rootData,or.default.rootData]];i.opts.dynamicRef&&d.push([or.default.dynamicAnchors,or.default.dynamicAnchors]);let f=(0,xe._)`${l}, ${r.object(...d)}`;return c!==xe.nil?(0,xe._)`${a}.call(${c}, ${f})`:(0,xe._)`${a}(${f})`}he.callValidateCode=Z$;var D$=(0,xe._)`new RegExp`;function L$({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,xe._)`${o.code==="new RegExp"?D$:(0,N$.useFunc)(t,o)}(${r}, ${n})`})}he.usePattern=L$;function q$(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,xe._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:Qu.Type.Num},s),e.if((0,xe.not)(s),a)})}}he.validateArray=q$;function U$(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,Qu.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,xe._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,xe.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}he.validateUnion=U$});var nh=I(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.validateKeywordUsage=Nt.validSchemaType=Nt.funcKeywordCode=Nt.macroKeywordCode=void 0;var We=X(),Lr=Vt(),F$=mt(),V$=vo();function H$(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=rh(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:We.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}Nt.macroKeywordCode=H$;function B$(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;K$(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=rh(n,o,u),d=n.let("valid");t.block$data(d,f),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function f(){if(e.errors===!1)h(),e.modifying&&th(t),g(()=>t.error());else{let y=e.async?m():p();e.modifying&&th(t),g(()=>J$(t,y))}}function m(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,We._)`await `),_=>n.assign(d,!1).if((0,We._)`${_} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,We._)`${_}.errors`),()=>n.throw(_))),y}function p(){let y=(0,We._)`${l}.errors`;return n.assign(y,null),h(We.nil),y}function h(y=e.async?(0,We._)`await `:We.nil){let _=c.opts.passContext?Lr.default.this:Lr.default.self,w=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,We._)`${y}${(0,F$.callValidateCode)(t,l,_,w)}`,e.modifying)}function g(y){var _;n.if((0,We.not)((_=e.valid)!==null&&_!==void 0?_:d),y)}}Nt.funcKeywordCode=B$;function th(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,We._)`${n.parentData}[${n.parentDataProperty}]`))}function J$(t,e){let{gen:r}=t;r.if((0,We._)`Array.isArray(${e})`,()=>{r.assign(Lr.default.vErrors,(0,We._)`${Lr.default.vErrors} === null ? ${e} : ${Lr.default.vErrors}.concat(${e})`).assign(Lr.default.errors,(0,We._)`${Lr.default.vErrors}.length`),(0,V$.extendErrors)(t)},()=>t.error())}function K$({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function rh(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,We.stringify)(r)})}function W$(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")}Nt.validSchemaType=W$;function G$({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)}}Nt.validateKeywordUsage=G$});var sh=I(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});sr.extendSubschemaMode=sr.extendSubschemaData=sr.getSubschema=void 0;var Ot=X(),oh=ue();function Y$(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,Ot._)`${t.schemaPath}${(0,Ot.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,Ot._)`${t.schemaPath}${(0,Ot.getProperty)(e)}${(0,Ot.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,oh.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')}sr.getSubschema=Y$;function X$(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:d}=e,f=a.let("data",(0,Ot._)`${e.data}${(0,Ot.getProperty)(r)}`,!0);c(f),t.errorPath=(0,Ot.str)`${u}${(0,oh.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,Ot._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof Ot.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]}}sr.extendSubschemaData=X$;function Q$(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}sr.extendSubschemaMode=Q$});var rl=I((_C,ih)=>{"use strict";ih.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 ch=I((vC,ah)=>{"use strict";var ir=ah.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(){};ti(e,n,o,t,"",t)};ir.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};ir.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};ir.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};ir.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 ti(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 d=n[l];if(Array.isArray(d)){if(l in ir.arrayKeywords)for(var f=0;f<d.length;f++)ti(t,e,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in ir.propsKeywords){if(d&&typeof d=="object")for(var m in d)ti(t,e,r,d[m],o+"/"+l+"/"+ek(m),s,o,l,n,m)}else(l in ir.keywords||t.allKeys&&!(l in ir.skipKeywords))&&ti(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function ek(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var xo=I(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.getSchemaRefs=rt.resolveUrl=rt.normalizeId=rt._getFullPath=rt.getFullPath=rt.inlineRef=void 0;var tk=ue(),rk=rl(),nk=ch(),ok=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function sk(t,e=!0){return typeof t=="boolean"?!0:e===!0?!nl(t):e?uh(t)<=e:!1}rt.inlineRef=sk;var ik=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function nl(t){for(let e in t){if(ik.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(nl)||typeof r=="object"&&nl(r))return!0}return!1}function uh(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!ok.has(r)&&(typeof t[r]=="object"&&(0,tk.eachItem)(t[r],n=>e+=uh(n)),e===1/0))return 1/0}return e}function lh(t,e="",r){r!==!1&&(e=xn(e));let n=t.parse(e);return dh(t,n)}rt.getFullPath=lh;function dh(t,e){return t.serialize(e).split("#")[0]+"#"}rt._getFullPath=dh;var ak=/#\/?$/;function xn(t){return t?t.replace(ak,""):""}rt.normalizeId=xn;function ck(t,e,r){return r=xn(r),t.resolve(e,r)}rt.resolveUrl=ck;var uk=/^[a-z_][-a-z0-9._]*$/i;function lk(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=xn(t[r]||e),s={"":o},i=lh(n,o,!1),a={},c=new Set;return nk(t,{allKeys:!0},(d,f,m,p)=>{if(p===void 0)return;let h=i+f,g=s[p];typeof d[r]=="string"&&(g=y.call(this,d[r])),_.call(this,d.$anchor),_.call(this,d.$dynamicAnchor),s[f]=g;function y(w){let x=this.opts.uriResolver.resolve;if(w=xn(g?x(g,w):w),c.has(w))throw l(w);c.add(w);let $=this.refs[w];return typeof $=="string"&&($=this.refs[$]),typeof $=="object"?u(d,$.schema,w):w!==xn(h)&&(w[0]==="#"?(u(d,a[w],w),a[w]=d):this.refs[w]=h),w}function _(w){if(typeof w=="string"){if(!uk.test(w))throw new Error(`invalid anchor "${w}"`);y.call(this,`#${w}`)}}}),a;function u(d,f,m){if(f!==void 0&&!rk(d,f))throw l(m)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}rt.getSchemaRefs=lk});var ko=I(ar=>{"use strict";Object.defineProperty(ar,"__esModule",{value:!0});ar.getData=ar.KeywordCxt=ar.validateFunctionCode=void 0;var gh=Hm(),ph=bo(),sl=Wu(),ri=bo(),dk=Xm(),$o=nh(),ol=sh(),Z=X(),B=Vt(),pk=xo(),Ht=ue(),wo=vo();function fk(t){if(vh(t)&&(bh(t),_h(t))){gk(t);return}yh(t,()=>(0,gh.topBoolOrEmptySchema)(t))}ar.validateFunctionCode=fk;function yh({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,Z._)`${B.default.data}, ${B.default.valCxt}`,n.$async,()=>{t.code((0,Z._)`"use strict"; ${fh(r,o)}`),hk(t,o),t.code(s)}):t.func(e,(0,Z._)`${B.default.data}, ${mk(o)}`,n.$async,()=>t.code(fh(r,o)).code(s))}function mk(t){return(0,Z._)`{${B.default.instancePath}="", ${B.default.parentData}, ${B.default.parentDataProperty}, ${B.default.rootData}=${B.default.data}${t.dynamicRef?(0,Z._)`, ${B.default.dynamicAnchors}={}`:Z.nil}}={}`}function hk(t,e){t.if(B.default.valCxt,()=>{t.var(B.default.instancePath,(0,Z._)`${B.default.valCxt}.${B.default.instancePath}`),t.var(B.default.parentData,(0,Z._)`${B.default.valCxt}.${B.default.parentData}`),t.var(B.default.parentDataProperty,(0,Z._)`${B.default.valCxt}.${B.default.parentDataProperty}`),t.var(B.default.rootData,(0,Z._)`${B.default.valCxt}.${B.default.rootData}`),e.dynamicRef&&t.var(B.default.dynamicAnchors,(0,Z._)`${B.default.valCxt}.${B.default.dynamicAnchors}`)},()=>{t.var(B.default.instancePath,(0,Z._)`""`),t.var(B.default.parentData,(0,Z._)`undefined`),t.var(B.default.parentDataProperty,(0,Z._)`undefined`),t.var(B.default.rootData,B.default.data),e.dynamicRef&&t.var(B.default.dynamicAnchors,(0,Z._)`{}`)})}function gk(t){let{schema:e,opts:r,gen:n}=t;yh(t,()=>{r.$comment&&e.$comment&&wh(t),xk(t),n.let(B.default.vErrors,null),n.let(B.default.errors,0),r.unevaluated&&yk(t),xh(t),kk(t)})}function yk(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,Z._)`${r}.evaluated`),e.if((0,Z._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,Z._)`${t.evaluated}.props`,(0,Z._)`undefined`)),e.if((0,Z._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,Z._)`${t.evaluated}.items`,(0,Z._)`undefined`))}function fh(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,Z._)`/*# sourceURL=${r} */`:Z.nil}function _k(t,e){if(vh(t)&&(bh(t),_h(t))){vk(t,e);return}(0,gh.boolOrEmptySchema)(t,e)}function _h({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 vh(t){return typeof t.schema!="boolean"}function vk(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&wh(t),wk(t),$k(t);let s=n.const("_errs",B.default.errors);xh(t,s),n.var(e,(0,Z._)`${s} === ${B.default.errors}`)}function bh(t){(0,Ht.checkUnknownRules)(t),bk(t)}function xh(t,e){if(t.opts.jtd)return mh(t,[],!1,e);let r=(0,ph.getSchemaTypes)(t.schema),n=(0,ph.coerceAndCheckDataType)(t,r);mh(t,r,!n,e)}function bk(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,Ht.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function xk(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Ht.checkStrictMode)(t,"default is ignored in the schema root")}function wk(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,pk.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function $k(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function wh({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,Z._)`${B.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,Z.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,Z._)`${B.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function kk(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,Z._)`${B.default.errors} === 0`,()=>e.return(B.default.data),()=>e.throw((0,Z._)`new ${o}(${B.default.vErrors})`)):(e.assign((0,Z._)`${n}.errors`,B.default.vErrors),s.unevaluated&&Sk(t),e.return((0,Z._)`${B.default.errors} === 0`))}function Sk({gen:t,evaluated:e,props:r,items:n}){r instanceof Z.Name&&t.assign((0,Z._)`${e}.props`,r),n instanceof Z.Name&&t.assign((0,Z._)`${e}.items`,n)}function mh(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,Ht.schemaHasRulesButRef)(s,l))){o.block(()=>kh(t,"$ref",l.all.$ref.definition));return}c.jtd||zk(t,e),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,sl.shouldUseGroup)(s,f)&&(f.type?(o.if((0,ri.checkDataType)(f.type,i,c.strictNumbers)),hh(t,f),e.length===1&&e[0]===f.type&&r&&(o.else(),(0,ri.reportTypeError)(t)),o.endIf()):hh(t,f),a||o.if((0,Z._)`${B.default.errors} === ${n||0}`))}}function hh(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,dk.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,sl.shouldUseRule)(n,s)&&kh(t,s.keyword,s.definition,e.type)})}function zk(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Pk(t,e),t.opts.allowUnionTypes||Tk(t,e),Ek(t,t.dataTypes))}function Pk(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{$h(t.dataTypes,r)||il(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Rk(t,e)}}function Tk(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&il(t,"use allowUnionTypes to allow union type keyword")}function Ek(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,sl.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Ik(e,i))&&il(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Ik(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function $h(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Rk(t,e){let r=[];for(let n of t.dataTypes)$h(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function il(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,Ht.checkStrictMode)(t,e,t.opts.strictTypes)}var ni=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,Ht.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",Sh(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",B.default.errors))}result(e,r,n){this.failResult((0,Z.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,Z.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,Z._)`${r} !== undefined && (${(0,Z.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?wo.reportExtraError:wo.reportError)(this,this.def.error,r)}$dataError(){(0,wo.reportError)(this,this.def.$dataError||wo.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,wo.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=Z.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=Z.nil,r=Z.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,Z.or)((0,Z._)`${o} === undefined`,r)),e!==Z.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==Z.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,Z.or)(i(),a());function i(){if(n.length){if(!(r instanceof Z.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,Z._)`${(0,ri.checkDataTypes)(c,r,s.opts.strictNumbers,ri.DataType.Wrong)}`}return Z.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,Z._)`!${c}(${r})`}return Z.nil}}subschema(e,r){let n=(0,ol.getSubschema)(this.it,e);(0,ol.extendSubschemaData)(n,this.it,e),(0,ol.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return _k(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=Ht.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=Ht.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,Z.Name)),!0}};ar.KeywordCxt=ni;function kh(t,e,r,n){let o=new ni(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 Nk=/^\/(?:[^~]|~0|~1)*$/,Ok=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Sh(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return B.default.rootData;if(t[0]==="/"){if(!Nk.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=B.default.rootData}else{let u=Ok.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,Z._)`${s}${(0,Z.getProperty)((0,Ht.unescapeJsonPointer)(u))}`,i=(0,Z._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}ar.getData=Sh});var oi=I(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});var al=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};cl.default=al});var So=I(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});var ul=xo(),ll=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,ul.resolveUrl)(e,r,n),this.missingSchema=(0,ul.normalizeId)((0,ul.getFullPath)(e,this.missingRef))}};dl.default=ll});var ii=I(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.resolveSchema=ht.getCompilingSchema=ht.resolveRef=ht.compileSchema=ht.SchemaEnv=void 0;var wt=X(),Ck=oi(),qr=Vt(),$t=xo(),zh=ue(),Ak=ko(),wn=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,$t.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};ht.SchemaEnv=wn;function fl(t){let e=Ph.call(this,t);if(e)return e;let r=(0,$t.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new wt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:Ck.default,code:(0,wt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:qr.default.data,parentData:qr.default.parentData,parentDataProperty:qr.default.parentDataProperty,dataNames:[qr.default.data],dataPathArr:[wt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,wt.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:wt.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,wt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,Ak.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(qr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let m=new Function(`${qr.default.self}`,`${qr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:m}),m.errors=null,m.schema=t.schema,m.schemaEnv=t,t.$async&&(m.$async=!0),this.opts.code.source===!0&&(m.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:p,items:h}=u;m.evaluated={props:p instanceof wt.Name?void 0:p,items:h instanceof wt.Name?void 0:h,dynamicProps:p instanceof wt.Name,dynamicItems:h instanceof wt.Name},m.source&&(m.source.evaluated=(0,wt.stringify)(m.evaluated))}return t.validate=m,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}ht.compileSchema=fl;function jk(t,e,r){var n;r=(0,$t.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Dk.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 wn({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=Mk.call(this,s)}ht.resolveRef=jk;function Mk(t){return(0,$t.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:fl.call(this,t)}function Ph(t){for(let e of this._compilations)if(Zk(e,t))return e}ht.getCompilingSchema=Ph;function Zk(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Dk(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||si.call(this,t,e)}function si(t,e){let r=this.opts.uriResolver.parse(e),n=(0,$t._getFullPath)(this.opts.uriResolver,r),o=(0,$t.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return pl.call(this,r,t);let s=(0,$t.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=si.call(this,t,i);return typeof a?.schema!="object"?void 0:pl.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||fl.call(this,i),s===(0,$t.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,$t.resolveUrl)(this.opts.uriResolver,o,u)),new wn({schema:a,schemaId:c,root:t,baseId:o})}return pl.call(this,r,i)}}ht.resolveSchema=si;var Lk=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function pl(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,zh.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Lk.has(a)&&u&&(e=(0,$t.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,zh.schemaHasRulesButRef)(r,this.RULES)){let a=(0,$t.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=si.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new wn({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var Th=I((SC,qk)=>{qk.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 vl=I((zC,Ah)=>{"use strict";var Uk=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),hl=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),Ur=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),gl=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Ih=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),yl=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),Fk=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),nt=new Array(256);{let t="0123456789ABCDEF";for(let e=0;e<256;e++)nt[e]="%"+t[e>>4]+t[e&15]}function Fe(t){return t<2048?nt[192|t>>6]+nt[128|t&63]:t<65536?nt[224|t>>12]+nt[128|t>>6&63]+nt[128|t&63]:nt[240|t>>18]+nt[128|t>>12&63]+nt[128|t>>6&63]+nt[128|t&63]}function Vk(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 Hk=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),Bk=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),Jk=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),Kk=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Wk(t){if(t.length===0)return!1;for(let e=0;e<t.length;e++)if(!Jk(t[e])){if(t[e]==="%"&&e+2<t.length&&Ur(t.slice(e+1,e+3))){e+=2;continue}return!1}return!0}function Eh(t){let e=-1,r=0,n=-1,o=0;for(let a=0;a<t.length;a++)t[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,e=n)):(n=-1,o=0);if(r<2)return t.join(":");let s=t.slice(0,e).join(":"),i=t.slice(e+r).join(":");return s+"::"+i}function Gk(t){let e=t.indexOf("::");if(e!==-1&&t.indexOf("::",e+1)!==-1)return;let r=e===-1?t.split(":"):t.slice(0,e).split(":"),n=e===-1?[]:t.slice(e+2).split(":");e!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||e!==-1&&n.length===0||!hl(c))return;s+=2;continue}if(!Hk(c))return;o[a]=parseInt(c,16).toString(16),s++}if(e===-1)return s!==8?void 0:Eh(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return Eh(i)}function ml(t){let e=t[0]==="["&&t[t.length-1]==="]";if((t[0]==="["||t[t.length-1]==="]")&&!e)return{host:t,isIPV6:!1,error:!0};let n=e?t.slice(1,-1):t;if(e&&Bk(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(Yk(n,":")<2)return{host:t,isIPV6:!1,error:e};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!Wk(o))return{host:t,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=Gk(n);return i===void 0?{host:t,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function Yk(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function Xk(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("")}var Qk={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},eS=/[@/?#:]/g,tS=/[@/?#]/g;function Rh(t,e){let r=e?tS:eS;return r.lastIndex=0,t.replace(r,n=>Qk[n])}function Nh(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let o=t.slice(n+1,n+3);if(Ur(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));e&&gl(i)?r+=i:r+="%"+s,n+=2;continue}}r+=t[n]}return r}function rS(t){let e="";for(let r=0;r<t.length;r++){let n=t[r];if(n==="%"&&r+2<t.length){let o=t.slice(r+1,r+3);if(Ur(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&gl(i)?e+=i:e+="%"+s,r+=2;continue}}if(Ih(n))e+=n;else{let o=t.charCodeAt(r);if(o<128)e+=Ch(o)?n:nt[o];else if(o<55296||o>57343)e+=Fe(o);else if(o<=56319&&r+1<t.length){let s=t.charCodeAt(r+1);s>=56320&&s<=57343?(e+=Fe(65536+(o-55296<<10)+(s-56320)),r++):e+=Fe(65533)}else e+=Fe(65533)}}return e}function nS(t,e=!1){let r="",n=e&&t[0]!=="/";for(let o=0;o<t.length;o++){let s=t[o];if(s==="%"&&o+2<t.length){let i=t.slice(o+1,o+3);if(Ur(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),Ih(s)&&(s!==":"||!n))r+=s;else{let i=t.charCodeAt(o);if(i<128)r+=nt[i];else if(i<55296||i>57343)r+=Fe(i);else if(i<=56319&&o+1<t.length){let a=t.charCodeAt(o+1);a>=56320&&a<=57343?(r+=Fe(65536+(i-55296<<10)+(a-56320)),o++):r+=Fe(65533)}else r+=Fe(65533)}}return r}function _l(t,e){let r="";for(let n=0;n<t.length;n++){let o=t[n];if(o==="%"&&n+2<t.length){let s=t.slice(n+1,n+3);if(Ur(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(e(o))r+=o;else{let s=t.charCodeAt(n);if(s<128)r+=nt[s];else if(s<55296||s>57343)r+=Fe(s);else if(s<=56319&&n+1<t.length){let i=t.charCodeAt(n+1);i>=56320&&i<=57343?(r+=Fe(65536+(s-55296<<10)+(i-56320)),n++):r+=Fe(65533)}else r+=Fe(65533)}}return r}function Oh(t){return _l(t,Fk)}function oS(t){return _l(t,yl)}function sS(t){return _l(t,yl)}function Ch(t){return t>=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||t===42||t===43||t===45||t===46||t===47||t===64||t===95}function iS(t){let e="";for(let r=0;r<t.length;r++){let n=t[r];if(n==="%"&&r+2<t.length){let o=t.slice(r+1,r+3);if(Ur(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));gl(i)?e+=i:e+="%"+s,r+=2;continue}}if(yl(n))e+=n;else{let o=t.charCodeAt(r);if(o<128)e+=Ch(o)?n:nt[o];else if(o<55296||o>57343)e+=Fe(o);else if(o<=56319&&r+1<t.length){let s=t.charCodeAt(r+1);s>=56320&&s<=57343?(e+=Fe(65536+(o-55296<<10)+(s-56320)),r++):e+=Fe(65533)}else e+=Fe(65533)}}return e}function aS(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Ur(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function cS(t){let e=[];if(t.userinfo!==void 0&&(e.push(Oh(t.userinfo)),e.push("@")),t.host!==void 0){let r=t.host;if(!hl(r)){let n=ml(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=Nh(r,!0),n=ml(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=Rh(r,!1)}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}Ah.exports={nonSimpleDomain:Kk,recomposeAuthority:cS,reescapeHostDelimiters:Rh,normalizePercentEncoding:Nh,normalizePathEncoding:rS,serializePathEncoding:nS,normalizeQueryFragmentEncoding:iS,encodeUserinfo:Oh,encodeQuery:oS,encodeFragment:sS,escapePreservingEscapes:aS,removeDotSegments:Xk,isIPv4:hl,isUUID:Uk,normalizeIPv6:ml,stringArrayToHexStripped:Vk}});var Lh=I((PC,Dh)=>{"use strict";var{isUUID:uS}=vl(),lS=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,dS=["http","https","ws","wss","urn","urn:uuid"];function pS(t){return dS.indexOf(t)!==-1}function bl(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 jh(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Mh(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 fS(t){return t.secure=bl(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function mS(t){if((t.port===(bl(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=t.resourceName.indexOf("?"),r=e===-1?t.resourceName:t.resourceName.slice(0,e);t.path=r&&r!=="/"?r:void 0,t.query=e===-1?void 0:t.resourceName.slice(e+1),t.resourceName=void 0}return t.fragment=void 0,t}function hS(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(lS);if(r&&r[0]===t.path){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=xl(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function gS(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=xl(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 yS(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!uS(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function _S(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Zh={scheme:"http",domainHost:!0,parse:jh,serialize:Mh},vS={scheme:"https",domainHost:Zh.domainHost,parse:jh,serialize:Mh},ai={scheme:"ws",domainHost:!0,parse:fS,serialize:mS},bS={scheme:"wss",domainHost:ai.domainHost,parse:ai.parse,serialize:ai.serialize},xS={scheme:"urn",parse:hS,serialize:gS,skipNormalize:!0},wS={scheme:"urn:uuid",parse:yS,serialize:_S,skipNormalize:!0},ci={http:Zh,https:vS,ws:ai,wss:bS,urn:xS,"urn:uuid":wS};Object.setPrototypeOf(ci,null);function xl(t){return t&&(ci[t]||ci[t.toLowerCase()])||void 0}Dh.exports={wsIsSecure:bl,SCHEMES:ci,isValidSchemeName:pS,getSchemeHandler:xl}});var eg=I((TC,di)=>{"use strict";var{normalizeIPv6:Hh,removeDotSegments:Po,recomposeAuthority:$S,normalizePercentEncoding:Bh,normalizePathEncoding:kS,serializePathEncoding:qh,normalizeQueryFragmentEncoding:Uh,encodeQuery:SS,encodeFragment:zS,reescapeHostDelimiters:PS,isIPv4:Jh,nonSimpleDomain:TS}=vl(),{SCHEMES:Kh,getSchemeHandler:wl}=Lh(),Wh=/^[A-Za-z][A-Za-z0-9+.-]*$/u,Gh="URI scheme is malformed.";function Fh(t){let e=unescape(String(t));if(!Wh.test(e))throw new TypeError(Gh);return e}function ES(t,e){return typeof t=="string"?t=MS(t,e):typeof t=="object"&&(t=li(Fr(t,e),e)),t}function IS(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=ui(t,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:f,malformedSchemeSpecific:m,malformedHost:p,malformedScheme:h}=ui(e,n);if(s||d||i||f||a||m||c||p||u||h)throw new Error(o.error||l.error||"URI is malformed.");let g=Yh(o,l,n,!0),y=wl(r&&r.scheme||g.scheme),_=g.host,w=_!==void 0&&_!==""&&(Jh(_)||Hh(_).isIPV6);Xh(g,r||{},y,w);let x=_&&_.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(_);if(g.error&&!x)throw new Error(g.error);return n.skipEscape=!0,Fr(g,n)}function Yh(t,e,r,n){let o={};return n||(t=li(Fr(t,r),r),e=li(Fr(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=Po(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=Po(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=Po(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=Po(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 RS(t,e,r){let n=Vh(t,r),o=Vh(e,r);return n!==void 0&&o!==void 0&&n===o}function Fr(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=[];r.scheme&&(r.scheme=Fh(r.scheme));let s=wl(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!n.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(n.skipEscape?r.path=Bh(r.path):r.path=qh(r.path,a)),n.reference!=="suffix"&&r.scheme&&(r.scheme=Fh(r.scheme),o.push(r.scheme,":"));let c=$S(r);if(c!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(c),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=Po(u)),a&&(u=qh(u,!0)),c===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",SS(r.query)),r.fragment!==void 0&&o.push("#",zS(r.fragment)),o.join("")}var NS=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,OS=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,CS=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function AS(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function zo(t){if(t===void 0)return!1;let e=t.indexOf("%");for(;e!==-1;){if(e+2>=t.length||!/^[\da-f]{2}$/iu.test(t.slice(e+1,e+3)))return!0;e=t.indexOf("%",e+3)}return!1}function jS(t){let e=t[4];return zo(t[3])||e!==void 0&&!(e[0]==="["&&e[e.length-1]==="]")&&zo(e)||zo(t[6])||zo(t[7])||zo(t[8])}function Xh(t,e,r,n){if(!e.unicodeSupport&&(!r||!r.unicodeSupport)&&t.host&&t.host[0]!=="["&&(e.domainHost||r&&r.domainHost)&&n===!1&&TS(t.host))try{t.host=new URL("http://"+t.host).hostname}catch(o){return t.error=t.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function ui(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,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let d=t.match(OS);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let f=t.match(CS);if(f!==null){let p=f[1],h=p.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):p.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let m=t.match(NS);if(m){if(n.scheme=m[1],n.userinfo=m[3],n.host=m[4],n.port=parseInt(m[5],10),n.path=m[6]||"",n.query=m[7],n.fragment=m[8],n.scheme!==void 0){let g=unescape(n.scheme);Wh.test(g)?n.scheme=g.toLowerCase():(n.error=n.error||Gh,u=!0)}s=jS(m),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=m[5]);let p=AS(n,m);if(p!==void 0&&(n.error=n.error||p,o=!0),n.host)if(Jh(n.host)===!1){let y=n.host[0]==="["&&n.host[n.host.length-1]==="]",_=Hh(n.host);l=_.isIPV6||_.isIPVFuture===!0,c=y&&_.error===!0,n.host=l?_.host:_.host.toLowerCase(),c&&(n.error=n.error||"URI host is malformed.",o=!0)}else l=!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 h=wl(r.scheme||n.scheme);if(a=Xh(n,r,h,l),!h||h&&!h.skipNormalize){if(t.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:Bh(n.host,!0);n.host=PS(g,l)}n.path&&(n.path=kS(n.path)),n.query&&(n.query=Uh(n.query)),n.fragment&&(n.fragment=Uh(n.fragment))}h&&h.parse&&(h.parse(n,r),h===Kh.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function li(t,e){return ui(t,e).parsed}function MS(t,e){return Qh(t,e).normalized}function Qh(t,e){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=ui(t,e);return{normalized:n||o||s||i||a?t:Fr(r,e),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function Vh(t,e){if(typeof t!="string"&&typeof t!="object")return;let r;try{r=typeof t=="string"?t:Fr(t,e)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=Qh(r,e);return o||s||i||a||c?void 0:n}var $l={SCHEMES:Kh,normalize:ES,resolve:IS,resolveComponent:Yh,equal:RS,serialize:Fr,parse:li};di.exports=$l;di.exports.default=$l;di.exports.fastUri=$l});var rg=I(kl=>{"use strict";Object.defineProperty(kl,"__esModule",{value:!0});var tg=eg();tg.code='require("ajv/dist/runtime/uri").default';kl.default=tg});var lg=I(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.CodeGen=Me.Name=Me.nil=Me.stringify=Me.str=Me._=Me.KeywordCxt=void 0;var ZS=ko();Object.defineProperty(Me,"KeywordCxt",{enumerable:!0,get:function(){return ZS.KeywordCxt}});var $n=X();Object.defineProperty(Me,"_",{enumerable:!0,get:function(){return $n._}});Object.defineProperty(Me,"str",{enumerable:!0,get:function(){return $n.str}});Object.defineProperty(Me,"stringify",{enumerable:!0,get:function(){return $n.stringify}});Object.defineProperty(Me,"nil",{enumerable:!0,get:function(){return $n.nil}});Object.defineProperty(Me,"Name",{enumerable:!0,get:function(){return $n.Name}});Object.defineProperty(Me,"CodeGen",{enumerable:!0,get:function(){return $n.CodeGen}});var DS=oi(),ag=So(),LS=Ku(),To=ii(),qS=X(),Eo=xo(),pi=bo(),zl=ue(),ng=Th(),US=rg(),cg=(t,e)=>new RegExp(t,e);cg.code="new RegExp";var FS=["removeAdditional","useDefaults","coerceTypes"],VS=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),HS={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."},BS={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},og=200;function JS(t){var e,r,n,o,s,i,a,c,u,l,d,f,m,p,h,g,y,_,w,x,$,P,J,H,k;let O=t.strict,E=(e=t.code)===null||e===void 0?void 0:e.optimize,F=E===!0||E===void 0?1:E||0,re=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:cg,K=(o=t.uriResolver)!==null&&o!==void 0?o:US.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:O)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:O)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:O)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=t.strictTuples)!==null&&d!==void 0?d:O)!==null&&f!==void 0?f:"log",strictRequired:(p=(m=t.strictRequired)!==null&&m!==void 0?m:O)!==null&&p!==void 0?p:!1,code:t.code?{...t.code,optimize:F,regExp:re}:{optimize:F,regExp:re},loopRequired:(h=t.loopRequired)!==null&&h!==void 0?h:og,loopEnum:(g=t.loopEnum)!==null&&g!==void 0?g:og,meta:(y=t.meta)!==null&&y!==void 0?y:!0,messages:(_=t.messages)!==null&&_!==void 0?_:!0,inlineRefs:(w=t.inlineRefs)!==null&&w!==void 0?w:!0,schemaId:(x=t.schemaId)!==null&&x!==void 0?x:"$id",addUsedSchema:($=t.addUsedSchema)!==null&&$!==void 0?$:!0,validateSchema:(P=t.validateSchema)!==null&&P!==void 0?P:!0,validateFormats:(J=t.validateFormats)!==null&&J!==void 0?J:!0,unicodeRegExp:(H=t.unicodeRegExp)!==null&&H!==void 0?H:!0,int32range:(k=t.int32range)!==null&&k!==void 0?k:!0,uriResolver:K}}var Io=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...JS(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new qS.ValueScope({scope:{},prefixes:VS,es5:r,lines:n}),this.logger=QS(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,LS.getRules)(),sg.call(this,HS,e,"NOT SUPPORTED"),sg.call(this,BS,e,"DEPRECATED","warn"),this._metaOpts=YS.call(this),e.formats&&WS.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&GS.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),KS.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=ng;n==="id"&&(o={...ng},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,d){await s.call(this,l.$schema);let f=this._addSchema(l,d);return f.validate||i.call(this,f)}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(d){if(!(d instanceof ag.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;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,Eo.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=ig.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new To.SchemaEnv({schema:{},schemaId:n});if(r=To.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=ig.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,Eo.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(tz.call(this,n,r),!r)return(0,zl.eachItem)(n,s=>Sl.call(this,s)),this;nz.call(this,r);let o={...r,type:(0,pi.getJSONTypes)(r.type),schemaType:(0,pi.getJSONTypes)(r.schemaType)};return(0,zl.eachItem)(n,o.type.length===0?s=>Sl.call(this,s,o):s=>o.type.forEach(i=>Sl.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]=ug(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,Eo.normalizeId)(i||n);let u=Eo.getSchemaRefs.call(this,e,n);return c=new To.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):To.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{To.compileSchema.call(this,e)}finally{this.opts=r}}};Io.ValidationError=DS.default;Io.MissingRefError=ag.default;Me.default=Io;function sg(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 ig(t){return t=(0,Eo.normalizeId)(t),this.schemas[t]||this.refs[t]}function KS(){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 WS(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function GS(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 YS(){let t={...this.opts};for(let e of FS)delete t[e];return t}var XS={log(){},warn(){},error(){}};function QS(t){if(t===!1)return XS;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 ez=/^[a-z_$][a-z0-9_$:-]*$/i;function tz(t,e){let{RULES:r}=this;if((0,zl.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!ez.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 Sl(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,pi.getJSONTypes)(e.type),schemaType:(0,pi.getJSONTypes)(e.schemaType)}};e.before?rz.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 rz(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 nz(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=ug(e)),t.validateSchema=this.compile(e,!0))}var oz={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ug(t){return{anyOf:[t,oz]}}});var dg=I(Pl=>{"use strict";Object.defineProperty(Pl,"__esModule",{value:!0});var sz={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Pl.default=sz});var hg=I(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Vr.callRef=Vr.getValidate=void 0;var iz=So(),pg=mt(),ot=X(),kn=Vt(),fg=ii(),fi=ue(),az={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 d();let l=fg.resolveRef.call(c,u,o,r);if(l===void 0)throw new iz.default(n.opts.uriResolver,o,r);if(l instanceof fg.SchemaEnv)return f(l);return m(l);function d(){if(s===u)return mi(t,i,s,s.$async);let p=e.scopeValue("root",{ref:u});return mi(t,(0,ot._)`${p}.validate`,u,u.$async)}function f(p){let h=mg(t,p);mi(t,h,p,p.$async)}function m(p){let h=e.scopeValue("schema",a.code.source===!0?{ref:p,code:(0,ot.stringify)(p)}:{ref:p}),g=e.name("valid"),y=t.subschema({schema:p,dataTypes:[],schemaPath:ot.nil,topSchemaRef:h,errSchemaPath:r},g);t.mergeEvaluated(y),t.ok(g)}}};function mg(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,ot._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Vr.getValidate=mg;function mi(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?kn.default.this:ot.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let p=o.let("valid");o.try(()=>{o.code((0,ot._)`await ${(0,pg.callValidateCode)(t,e,u)}`),m(e),i||o.assign(p,!0)},h=>{o.if((0,ot._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),f(h),i||o.assign(p,!1)}),t.ok(p)}function d(){t.result((0,pg.callValidateCode)(t,e,u),()=>m(e),()=>f(e))}function f(p){let h=(0,ot._)`${p}.errors`;o.assign(kn.default.vErrors,(0,ot._)`${kn.default.vErrors} === null ? ${h} : ${kn.default.vErrors}.concat(${h})`),o.assign(kn.default.errors,(0,ot._)`${kn.default.vErrors}.length`)}function m(p){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=fi.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,ot._)`${p}.evaluated.props`);s.props=fi.mergeEvaluated.props(o,y,s.props,ot.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=fi.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,ot._)`${p}.evaluated.items`);s.items=fi.mergeEvaluated.items(o,y,s.items,ot.Name)}}}Vr.callRef=mi;Vr.default=az});var gg=I(Tl=>{"use strict";Object.defineProperty(Tl,"__esModule",{value:!0});var cz=dg(),uz=hg(),lz=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",cz.default,uz.default];Tl.default=lz});var yg=I(El=>{"use strict";Object.defineProperty(El,"__esModule",{value:!0});var hi=X(),cr=hi.operators,gi={maximum:{okStr:"<=",ok:cr.LTE,fail:cr.GT},minimum:{okStr:">=",ok:cr.GTE,fail:cr.LT},exclusiveMaximum:{okStr:"<",ok:cr.LT,fail:cr.GTE},exclusiveMinimum:{okStr:">",ok:cr.GT,fail:cr.LTE}},dz={message:({keyword:t,schemaCode:e})=>(0,hi.str)`must be ${gi[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,hi._)`{comparison: ${gi[t].okStr}, limit: ${e}}`},pz={keyword:Object.keys(gi),type:"number",schemaType:"number",$data:!0,error:dz,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,hi._)`${r} ${gi[e].fail} ${n} || isNaN(${r})`)}};El.default=pz});var _g=I(Il=>{"use strict";Object.defineProperty(Il,"__esModule",{value:!0});var Ro=X(),fz={message:({schemaCode:t})=>(0,Ro.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Ro._)`{multipleOf: ${t}}`},mz={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:fz,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,Ro._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Ro._)`${i} !== parseInt(${i})`;t.fail$data((0,Ro._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Il.default=mz});var bg=I(Rl=>{"use strict";Object.defineProperty(Rl,"__esModule",{value:!0});function vg(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}Rl.default=vg;vg.code='require("ajv/dist/runtime/ucs2length").default'});var xg=I(Nl=>{"use strict";Object.defineProperty(Nl,"__esModule",{value:!0});var Hr=X(),hz=ue(),gz=bg(),yz={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Hr.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Hr._)`{limit: ${t}}`},_z={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:yz,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?Hr.operators.GT:Hr.operators.LT,i=o.opts.unicode===!1?(0,Hr._)`${r}.length`:(0,Hr._)`${(0,hz.useFunc)(t.gen,gz.default)}(${r})`;t.fail$data((0,Hr._)`${i} ${s} ${n}`)}};Nl.default=_z});var wg=I(Ol=>{"use strict";Object.defineProperty(Ol,"__esModule",{value:!0});var vz=mt(),bz=ue(),Sn=X(),xz={message:({schemaCode:t})=>(0,Sn.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,Sn._)`{pattern: ${t}}`},wz={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:xz,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,Sn._)`new RegExp`:(0,bz.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,Sn._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,Sn._)`!${l}`)}else{let c=(0,vz.usePattern)(t,o);t.fail$data((0,Sn._)`!${c}.test(${r})`)}}};Ol.default=wz});var $g=I(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:!0});var No=X(),$z={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,No.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,No._)`{limit: ${t}}`},kz={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:$z,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?No.operators.GT:No.operators.LT;t.fail$data((0,No._)`Object.keys(${r}).length ${o} ${n}`)}};Cl.default=kz});var kg=I(Al=>{"use strict";Object.defineProperty(Al,"__esModule",{value:!0});var Oo=mt(),Co=X(),Sz=ue(),zz={message:({params:{missingProperty:t}})=>(0,Co.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Co._)`{missingProperty: ${t}}`},Pz={keyword:"required",type:"object",schemaType:"array",$data:!0,error:zz,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 m=t.parentSchema.properties,{definedProperties:p}=t.it;for(let h of r)if(m?.[h]===void 0&&!p.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,Sz.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(Co.nil,d);else for(let m of r)(0,Oo.checkReportMissingProp)(t,m)}function l(){let m=e.let("missing");if(c||s){let p=e.let("valid",!0);t.block$data(p,()=>f(m,p)),t.ok(p)}else e.if((0,Oo.checkMissingProp)(t,r,m)),(0,Oo.reportMissingProp)(t,m),e.else()}function d(){e.forOf("prop",n,m=>{t.setParams({missingProperty:m}),e.if((0,Oo.noPropertyInData)(e,o,m,a.ownProperties),()=>t.error())})}function f(m,p){t.setParams({missingProperty:m}),e.forOf(m,n,()=>{e.assign(p,(0,Oo.propertyInData)(e,o,m,a.ownProperties)),e.if((0,Co.not)(p),()=>{t.error(),e.break()})},Co.nil)}}};Al.default=Pz});var Sg=I(jl=>{"use strict";Object.defineProperty(jl,"__esModule",{value:!0});var Ao=X(),Tz={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Ao.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Ao._)`{limit: ${t}}`},Ez={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Tz,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?Ao.operators.GT:Ao.operators.LT;t.fail$data((0,Ao._)`${r}.length ${o} ${n}`)}};jl.default=Ez});var yi=I(Ml=>{"use strict";Object.defineProperty(Ml,"__esModule",{value:!0});var zg=rl();zg.code='require("ajv/dist/runtime/equal").default';Ml.default=zg});var Pg=I(Dl=>{"use strict";Object.defineProperty(Dl,"__esModule",{value:!0});var Zl=bo(),Ze=X(),Iz=ue(),Rz=yi(),Nz={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}}`},Oz={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Nz,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,Zl.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,Ze._)`${i} === false`),t.ok(c);function l(){let p=e.let("i",(0,Ze._)`${r}.length`),h=e.let("j");t.setParams({i:p,j:h}),e.assign(c,!0),e.if((0,Ze._)`${p} > 1`,()=>(d()?f:m)(p,h))}function d(){return u.length>0&&!u.some(p=>p==="object"||p==="array")}function f(p,h){let g=e.name("item"),y=(0,Zl.checkDataTypes)(u,g,a.opts.strictNumbers,Zl.DataType.Wrong),_=e.const("indices",(0,Ze._)`{}`);e.for((0,Ze._)`;${p}--;`,()=>{e.let(g,(0,Ze._)`${r}[${p}]`),e.if(y,(0,Ze._)`continue`),u.length>1&&e.if((0,Ze._)`typeof ${g} == "string"`,(0,Ze._)`${g} += "_"`),e.if((0,Ze._)`typeof ${_}[${g}] == "number"`,()=>{e.assign(h,(0,Ze._)`${_}[${g}]`),t.error(),e.assign(c,!1).break()}).code((0,Ze._)`${_}[${g}] = ${p}`)})}function m(p,h){let g=(0,Iz.useFunc)(e,Rz.default),y=e.name("outer");e.label(y).for((0,Ze._)`;${p}--;`,()=>e.for((0,Ze._)`${h} = ${p}; ${h}--;`,()=>e.if((0,Ze._)`${g}(${r}[${p}], ${r}[${h}])`,()=>{t.error(),e.assign(c,!1).break(y)})))}}};Dl.default=Oz});var Tg=I(ql=>{"use strict";Object.defineProperty(ql,"__esModule",{value:!0});var Ll=X(),Cz=ue(),Az=yi(),jz={message:"must be equal to constant",params:({schemaCode:t})=>(0,Ll._)`{allowedValue: ${t}}`},Mz={keyword:"const",$data:!0,error:jz,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,Ll._)`!${(0,Cz.useFunc)(e,Az.default)}(${r}, ${o})`):t.fail((0,Ll._)`${s} !== ${r}`)}};ql.default=Mz});var Eg=I(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});var jo=X(),Zz=ue(),Dz=yi(),Lz={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,jo._)`{allowedValues: ${t}}`},qz={keyword:"enum",schemaType:"array",$data:!0,error:Lz,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,Zz.useFunc)(e,Dz.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let m=e.const("vSchema",s);l=(0,jo.or)(...o.map((p,h)=>f(m,h)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,m=>e.if((0,jo._)`${u()}(${r}, ${m})`,()=>e.assign(l,!0).break()))}function f(m,p){let h=o[p];return typeof h=="object"&&h!==null?(0,jo._)`${u()}(${r}, ${m}[${p}])`:(0,jo._)`${r} === ${h}`}}};Ul.default=qz});var Ig=I(Fl=>{"use strict";Object.defineProperty(Fl,"__esModule",{value:!0});var Uz=yg(),Fz=_g(),Vz=xg(),Hz=wg(),Bz=$g(),Jz=kg(),Kz=Sg(),Wz=Pg(),Gz=Tg(),Yz=Eg(),Xz=[Uz.default,Fz.default,Vz.default,Hz.default,Bz.default,Jz.default,Kz.default,Wz.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Gz.default,Yz.default];Fl.default=Xz});var Hl=I(Mo=>{"use strict";Object.defineProperty(Mo,"__esModule",{value:!0});Mo.validateAdditionalItems=void 0;var Br=X(),Vl=ue(),Qz={message:({params:{len:t}})=>(0,Br.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Br._)`{limit: ${t}}`},eP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Qz,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Vl.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Rg(t,n)}};function Rg(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,Br._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Br._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Vl.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,Br._)`${a} <= ${e.length}`);r.if((0,Br.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:Vl.Type.Num},u),i.allErrors||r.if((0,Br.not)(u),()=>r.break())})}}Mo.validateAdditionalItems=Rg;Mo.default=eP});var Bl=I(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.validateTuple=void 0;var Ng=X(),_i=ue(),tP=mt(),rP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Og(t,"additionalItems",e);r.items=!0,!(0,_i.alwaysValidSchema)(r,e)&&t.ok((0,tP.validateArray)(t))}};function Og(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=_i.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Ng._)`${s}.length`);r.forEach((d,f)=>{(0,_i.alwaysValidSchema)(a,d)||(n.if((0,Ng._)`${u} > ${f}`,()=>t.subschema({keyword:i,schemaProp:f,dataProp:f},c)),t.ok(c))});function l(d){let{opts:f,errSchemaPath:m}=a,p=r.length,h=p===d.minItems&&(p===d.maxItems||d[e]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${p}-tuple, but minItems or maxItems/${e} are not specified or different at path "${m}"`;(0,_i.checkStrictMode)(a,g,f.strictTuples)}}}Zo.validateTuple=Og;Zo.default=rP});var Cg=I(Jl=>{"use strict";Object.defineProperty(Jl,"__esModule",{value:!0});var nP=Bl(),oP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,nP.validateTuple)(t,"items")};Jl.default=oP});var jg=I(Kl=>{"use strict";Object.defineProperty(Kl,"__esModule",{value:!0});var Ag=X(),sP=ue(),iP=mt(),aP=Hl(),cP={message:({params:{len:t}})=>(0,Ag.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Ag._)`{limit: ${t}}`},uP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:cP,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,sP.alwaysValidSchema)(n,e)&&(o?(0,aP.validateAdditionalItems)(t,o):t.ok((0,iP.validateArray)(t)))}};Kl.default=uP});var Mg=I(Wl=>{"use strict";Object.defineProperty(Wl,"__esModule",{value:!0});var gt=X(),vi=ue(),lP={message:({params:{min:t,max:e}})=>e===void 0?(0,gt.str)`must contain at least ${t} valid item(s)`:(0,gt.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,gt._)`{minContains: ${t}}`:(0,gt._)`{minContains: ${t}, maxContains: ${e}}`},dP={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:lP,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,gt._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,vi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,vi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,vi.alwaysValidSchema)(s,r)){let h=(0,gt._)`${l} >= ${i}`;a!==void 0&&(h=(0,gt._)`${h} && ${l} <= ${a}`),t.pass(h);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?m(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,gt._)`${o}.length > 0`,f)):(e.let(d,!1),f()),t.result(d,()=>t.reset());function f(){let h=e.name("_valid"),g=e.let("count",0);m(h,()=>e.if(h,()=>p(g)))}function m(h,g){e.forRange("i",0,l,y=>{t.subschema({keyword:"contains",dataProp:y,dataPropType:vi.Type.Num,compositeRule:!0},h),g()})}function p(h){e.code((0,gt._)`${h}++`),a===void 0?e.if((0,gt._)`${h} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,gt._)`${h} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,gt._)`${h} >= ${i}`,()=>e.assign(d,!0)))}}};Wl.default=dP});var Lg=I(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.validateSchemaDeps=Ct.validatePropertyDeps=Ct.error=void 0;var Gl=X(),pP=ue(),Do=mt();Ct.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Gl.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Gl._)`{property: ${t},
|
|
7
7
|
missingProperty: ${n},
|
|
8
8
|
depsCount: ${e},
|
|
9
|
-
deps: ${r}}`};var pP={keyword:"dependencies",type:"object",schemaType:"object",error:Ct.error,code(t){let[e,r]=mP(t);Zg(t,e),Dg(t,r)}};function mP({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 Zg(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,Do.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,Do.checkReportMissingProp)(t,u)}):(r.if((0,Gl._)`${c} && (${(0,Do.checkMissingProp)(t,a,s)})`),(0,Do.reportMissingProp)(t,s),r.else())}}Ct.validatePropertyDeps=Zg;function Dg(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,fP.alwaysValidSchema)(s,e[a])||(r.if((0,Do.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))}Ct.validateSchemaDeps=Dg;Ct.default=pP});var Ug=I(Yl=>{"use strict";Object.defineProperty(Yl,"__esModule",{value:!0});var qg=X(),hP=ue(),gP={message:"property name must be valid",params:({params:t})=>(0,qg._)`{propertyName: ${t.propertyName}}`},yP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:gP,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,hP.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)}};Yl.default=yP});var Ql=I(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:!0});var bi=mt(),kt=X(),_P=Vt(),xi=ue(),vP={message:"must NOT have additional properties",params:({params:t})=>(0,kt._)`{additionalProperty: ${t.additionalProperty}}`},bP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:vP,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,xi.alwaysValidSchema)(i,r))return;let u=(0,bi.allSchemaProperties)(n.properties),l=(0,bi.allSchemaProperties)(n.patternProperties);d(),t.ok((0,kt._)`${s} === ${_P.default.errors}`);function d(){e.forIn("key",o,g=>{!u.length&&!l.length?f(g):e.if(p(g),()=>f(g))})}function p(g){let y;if(u.length>8){let _=(0,xi.schemaRefOrVal)(i,n.properties,"properties");y=(0,bi.isOwnProperty)(e,_,g)}else u.length?y=(0,kt.or)(...u.map(_=>(0,kt._)`${g} === ${_}`)):y=kt.nil;return l.length&&(y=(0,kt.or)(y,...l.map(_=>(0,kt._)`${(0,bi.usePattern)(t,_)}.test(${g})`))),(0,kt.not)(y)}function m(g){e.code((0,kt._)`delete ${o}[${g}]`)}function f(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,xi.alwaysValidSchema)(i,r)){let y=e.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),e.if((0,kt.not)(y),()=>{t.reset(),m(g)})):(h(g,y),a||e.if((0,kt.not)(y),()=>e.break()))}}function h(g,y,_){let w={keyword:"additionalProperties",dataProp:g,dataPropType:xi.Type.Str};_===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(w,y)}}};Xl.default=bP});var Hg=I(td=>{"use strict";Object.defineProperty(td,"__esModule",{value:!0});var xP=ko(),Fg=mt(),ed=ue(),Vg=Ql(),wP={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&&Vg.default.code(new xP.KeywordCxt(s,Vg.default,"additionalProperties"));let i=(0,Fg.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=ed.mergeEvaluated.props(e,(0,ed.toHash)(i),s.props));let a=i.filter(d=>!(0,ed.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,Fg.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};td.default=wP});var Wg=I(rd=>{"use strict";Object.defineProperty(rd,"__esModule",{value:!0});var Bg=mt(),wi=X(),Jg=ue(),Kg=ue(),$P={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,Bg.allSchemaProperties)(r),c=a.filter(h=>(0,Jg.alwaysValidSchema)(s,r[h]));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 wi.Name)&&(s.props=(0,Kg.evaluatedPropsToName)(e,s.props));let{props:d}=s;p();function p(){for(let h of a)u&&m(h),s.allErrors?f(h):(e.var(l,!0),f(h),e.if(l))}function m(h){for(let g in u)new RegExp(h).test(g)&&(0,Jg.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function f(h){e.forIn("key",n,g=>{e.if((0,wi._)`${(0,Bg.usePattern)(t,h)}.test(${g})`,()=>{let y=c.includes(h);y||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:Kg.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,wi._)`${d}[${g}]`,!0):!y&&!s.allErrors&&e.if((0,wi.not)(l),()=>e.break())})})}}};rd.default=$P});var Gg=I(nd=>{"use strict";Object.defineProperty(nd,"__esModule",{value:!0});var kP=ue(),SP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,kP.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"}};nd.default=SP});var Yg=I(od=>{"use strict";Object.defineProperty(od,"__esModule",{value:!0});var zP=mt(),PP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:zP.validateUnion,error:{message:"must match a schema in anyOf"}};od.default=PP});var Xg=I(sd=>{"use strict";Object.defineProperty(sd,"__esModule",{value:!0});var $i=X(),TP=ue(),EP={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,$i._)`{passingSchemas: ${t.passing}}`},IP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:EP,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,d)=>{let p;(0,TP.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,$i._)`${c} && ${i}`).assign(i,!1).assign(a,(0,$i._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,$i.Name)})})}}};sd.default=IP});var Qg=I(id=>{"use strict";Object.defineProperty(id,"__esModule",{value:!0});var RP=ue(),NP={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,RP.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};id.default=NP});var ry=I(ad=>{"use strict";Object.defineProperty(ad,"__esModule",{value:!0});var ki=X(),ty=ue(),OP={message:({params:t})=>(0,ki.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,ki._)`{failingKeyword: ${t.ifClause}}`},CP={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:OP,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,ty.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=ey(n,"then"),s=ey(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,ki.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,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,ki._)`${l}`):t.setParams({ifClause:l})}}}};function ey(t,e){let r=t.schema[e];return r!==void 0&&!(0,ty.alwaysValidSchema)(t,r)}ad.default=CP});var ny=I(cd=>{"use strict";Object.defineProperty(cd,"__esModule",{value:!0});var jP=ue(),AP={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,jP.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};cd.default=AP});var oy=I(ud=>{"use strict";Object.defineProperty(ud,"__esModule",{value:!0});var MP=Hl(),ZP=Cg(),DP=Bl(),LP=Ag(),qP=Mg(),UP=Lg(),FP=Ug(),VP=Ql(),HP=Hg(),BP=Wg(),JP=Gg(),KP=Yg(),WP=Xg(),GP=Qg(),YP=ry(),XP=ny();function QP(t=!1){let e=[JP.default,KP.default,WP.default,GP.default,YP.default,XP.default,FP.default,VP.default,UP.default,HP.default,BP.default];return t?e.push(ZP.default,LP.default):e.push(MP.default,DP.default),e.push(qP.default),e}ud.default=QP});var sy=I(ld=>{"use strict";Object.defineProperty(ld,"__esModule",{value:!0});var Te=X(),eT={message:({schemaCode:t})=>(0,Te.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Te._)`{format: ${t}}`},tT={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:eT,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():m();function p(){let f=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,Te._)`${f}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,Te._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,Te._)`${h}.type || "string"`).assign(y,(0,Te._)`${h}.validate`),()=>r.assign(g,(0,Te._)`"string"`).assign(y,h)),t.fail$data((0,Te.or)(_(),w()));function _(){return c.strictSchema===!1?Te.nil:(0,Te._)`${i} && !${y}`}function w(){let x=l.$async?(0,Te._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,Te._)`${y}(${n})`,$=(0,Te._)`(typeof ${y} == "function" ? ${x} : ${y}.test(${n}))`;return(0,Te._)`${y} && ${y} !== true && ${g} === ${e} && !${$}`}}function m(){let f=d.formats[s];if(!f){_();return}if(f===!0)return;let[h,g,y]=w(f);h===e&&t.pass(x());function _(){if(c.strictSchema===!1){d.logger.warn($());return}throw new Error($());function $(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function w($){let P=$ instanceof RegExp?(0,Te.regexpCode)($):c.code.formats?(0,Te._)`${c.code.formats}${(0,Te.getProperty)(s)}`:void 0,J=r.scopeValue("formats",{key:s,ref:$,code:P});return typeof $=="object"&&!($ instanceof RegExp)?[$.type||"string",$.validate,(0,Te._)`${J}.validate`]:["string",$,J]}function x(){if(typeof f=="object"&&!(f instanceof RegExp)&&f.async){if(!l.$async)throw new Error("async format in sync schema");return(0,Te._)`await ${y}(${n})`}return typeof g=="function"?(0,Te._)`${y}(${n})`:(0,Te._)`${y}.test(${n})`}}}};ld.default=tT});var iy=I(dd=>{"use strict";Object.defineProperty(dd,"__esModule",{value:!0});var rT=sy(),nT=[rT.default];dd.default=nT});var ay=I(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.contentVocabulary=zn.metadataVocabulary=void 0;zn.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];zn.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var uy=I(fd=>{"use strict";Object.defineProperty(fd,"__esModule",{value:!0});var oT=gg(),sT=Ig(),iT=oy(),aT=iy(),cy=ay(),cT=[oT.default,sT.default,(0,iT.default)(),aT.default,cy.metadataVocabulary,cy.contentVocabulary];fd.default=cT});var dy=I(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.DiscrError=void 0;var ly;(function(t){t.Tag="tag",t.Mapping="mapping"})(ly||(Si.DiscrError=ly={}))});var py=I(md=>{"use strict";Object.defineProperty(md,"__esModule",{value:!0});var Pn=X(),pd=dy(),fy=ii(),uT=So(),lT=ue(),dT={message:({params:{discrError:t,tagName:e}})=>t===pd.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Pn._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},fT={keyword:"discriminator",type:"object",schemaType:"object",error:dT,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,Pn._)`${r}${(0,Pn.getProperty)(a)}`);e.if((0,Pn._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:pd.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=p();e.if(!1);for(let f in m)e.elseIf((0,Pn._)`${u} === ${f}`),e.assign(c,d(m[f]));e.else(),t.error(!1,{discrError:pd.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let f=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:m},f);return t.mergeEvaluated(h,Pn.Name),f}function p(){var m;let f={},h=y(o),g=!0;for(let x=0;x<i.length;x++){let $=i[x];if($?.$ref&&!(0,lT.schemaHasRulesButRef)($,s.self.RULES)){let J=$.$ref;if($=fy.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,J),$ instanceof fy.SchemaEnv&&($=$.schema),$===void 0)throw new uT.default(s.opts.uriResolver,s.baseId,J)}let P=(m=$?.properties)===null||m===void 0?void 0:m[a];if(typeof P!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y($)),_(P,x)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return f;function y({required:x}){return Array.isArray(x)&&x.includes(a)}function _(x,$){if(x.const)w(x.const,$);else if(x.enum)for(let P of x.enum)w(P,$);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function w(x,$){if(typeof x!="string"||x in f)throw new Error(`discriminator: "${a}" values must be unique strings`);f[x]=$}}}};md.default=fT});var my=I((gj,pT)=>{pT.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 gd=I((we,hd)=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.MissingRefError=we.ValidationError=we.CodeGen=we.Name=we.nil=we.stringify=we.str=we._=we.KeywordCxt=we.Ajv=void 0;var mT=lg(),hT=uy(),gT=py(),hy=my(),yT=["/properties"],zi="http://json-schema.org/draft-07/schema",Tn=class extends mT.default{_addVocabularies(){super._addVocabularies(),hT.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(gT.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(hy,yT):hy;this.addMetaSchema(e,zi,!1),this.refs["http://json-schema.org/schema"]=zi}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(zi)?zi:void 0)}};we.Ajv=Tn;hd.exports=we=Tn;hd.exports.Ajv=Tn;Object.defineProperty(we,"__esModule",{value:!0});we.default=Tn;var _T=ko();Object.defineProperty(we,"KeywordCxt",{enumerable:!0,get:function(){return _T.KeywordCxt}});var En=X();Object.defineProperty(we,"_",{enumerable:!0,get:function(){return En._}});Object.defineProperty(we,"str",{enumerable:!0,get:function(){return En.str}});Object.defineProperty(we,"stringify",{enumerable:!0,get:function(){return En.stringify}});Object.defineProperty(we,"nil",{enumerable:!0,get:function(){return En.nil}});Object.defineProperty(we,"Name",{enumerable:!0,get:function(){return En.Name}});Object.defineProperty(we,"CodeGen",{enumerable:!0,get:function(){return En.CodeGen}});var vT=oi();Object.defineProperty(we,"ValidationError",{enumerable:!0,get:function(){return vT.default}});var bT=So();Object.defineProperty(we,"MissingRefError",{enumerable:!0,get:function(){return bT.default}})});var $y=I(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.formatNames=At.fastFormats=At.fullFormats=void 0;function jt(t,e){return{validate:t,compare:e}}At.fullFormats={date:jt(vy,bd),time:jt(_d(!0),xd),"date-time":jt(gy(!0),xy),"iso-time":jt(_d(),by),"iso-date-time":jt(gy(),wy),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:zT,"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:OT,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:PT,int32:{type:"number",validate:IT},int64:{type:"number",validate:RT},float:{type:"number",validate:_y},double:{type:"number",validate:_y},password:!0,binary:!0};At.fastFormats={...At.fullFormats,date:jt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,bd),time:jt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,xd),"date-time":jt(/^\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,xy),"iso-time":jt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,by),"iso-date-time":jt(/^\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,wy),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};At.formatNames=Object.keys(At.fullFormats);function xT(t){return t%4===0&&(t%100!==0||t%400===0)}var wT=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,$T=[0,31,28,31,30,31,30,31,31,30,31,30,31];function vy(t){let e=wT.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&&xT(r)?29:$T[n])}function bd(t,e){if(t&&e)return t>e?1:t<e?-1:0}var yd=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function _d(t){return function(r){let n=yd.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 d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function xd(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 by(t,e){if(!(t&&e))return;let r=yd.exec(t),n=yd.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 vd=/t|\s/i;function gy(t){let e=_d(t);return function(n){let o=n.split(vd);return o.length===2&&vy(o[0])&&e(o[1])}}function xy(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function wy(t,e){if(!(t&&e))return;let[r,n]=t.split(vd),[o,s]=e.split(vd),i=bd(r,o);if(i!==void 0)return i||xd(n,s)}var kT=/\/|:/,ST=/^(?:[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 zT(t){return kT.test(t)&&ST.test(t)}var yy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function PT(t){return yy.lastIndex=0,yy.test(t)}var TT=-(2**31),ET=2**31-1;function IT(t){return Number.isInteger(t)&&t<=ET&&t>=TT}function RT(t){return Number.isInteger(t)}function _y(){return!0}var NT=/[^\\]\\Z/;function OT(t){if(NT.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var ky=I(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.formatLimitDefinition=void 0;var CT=gd(),St=X(),ur=St.operators,Pi={formatMaximum:{okStr:"<=",ok:ur.LTE,fail:ur.GT},formatMinimum:{okStr:">=",ok:ur.GTE,fail:ur.LT},formatExclusiveMaximum:{okStr:"<",ok:ur.LT,fail:ur.GTE},formatExclusiveMinimum:{okStr:">",ok:ur.GT,fail:ur.LTE}},jT={message:({keyword:t,schemaCode:e})=>(0,St.str)`should be ${Pi[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,St._)`{comparison: ${Pi[t].okStr}, limit: ${e}}`};In.formatLimitDefinition={keyword:Object.keys(Pi),type:"string",schemaType:"string",$data:!0,error:jT,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 CT.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,St._)`${p}[${c.schemaCode}]`);t.fail$data((0,St.or)((0,St._)`typeof ${m} != "object"`,(0,St._)`${m} instanceof RegExp`,(0,St._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let p=c.schema,m=a.formats[p];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let f=e.scopeValue("formats",{key:p,ref:m,code:i.code.formats?(0,St._)`${i.code.formats}${(0,St.getProperty)(p)}`:void 0});t.fail$data(d(f))}function d(p){return(0,St._)`${p}.compare(${r}, ${n}) ${Pi[o].fail} 0`}},dependencies:["format"]};var AT=t=>(t.addKeyword(In.formatLimitDefinition),t);In.default=AT});var Ty=I((Lo,Py)=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});var Rn=$y(),MT=ky(),wd=X(),Sy=new wd.Name("fullFormats"),ZT=new wd.Name("fastFormats"),$d=(t,e={keywords:!0})=>{if(Array.isArray(e))return zy(t,e,Rn.fullFormats,Sy),t;let[r,n]=e.mode==="fast"?[Rn.fastFormats,ZT]:[Rn.fullFormats,Sy],o=e.formats||Rn.formatNames;return zy(t,o,r,n),e.keywords&&(0,MT.default)(t),t};$d.get=(t,e="full")=>{let n=(e==="fast"?Rn.fastFormats:Rn.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function zy(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,wd._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}Py.exports=Lo=$d;Object.defineProperty(Lo,"__esModule",{value:!0});Lo.default=$d});var q={};Bi(q,{BRAND:()=>ov,DIRTY:()=>fr,EMPTY_PATH:()=>A_,INVALID:()=>L,NEVER:()=>qv,OK:()=>De,ParseStatus:()=>Oe,Schema:()=>Y,ZodAny:()=>Kt,ZodArray:()=>Lt,ZodBigInt:()=>mr,ZodBoolean:()=>hr,ZodBranded:()=>Mn,ZodCatch:()=>zr,ZodDate:()=>gr,ZodDefault:()=>Sr,ZodDiscriminatedUnion:()=>Wo,ZodEffects:()=>lt,ZodEnum:()=>$r,ZodError:()=>Ge,ZodFirstPartyTypeKind:()=>z,ZodFunction:()=>Yo,ZodIntersection:()=>br,ZodIssueCode:()=>S,ZodLazy:()=>xr,ZodLiteral:()=>wr,ZodMap:()=>tn,ZodNaN:()=>nn,ZodNativeEnum:()=>kr,ZodNever:()=>yt,ZodNull:()=>_r,ZodNullable:()=>Et,ZodNumber:()=>pr,ZodObject:()=>Xe,ZodOptional:()=>Ye,ZodParsedType:()=>R,ZodPipeline:()=>Zn,ZodPromise:()=>Wt,ZodReadonly:()=>Pr,ZodRecord:()=>Go,ZodSchema:()=>Y,ZodSet:()=>rn,ZodString:()=>Jt,ZodSymbol:()=>Qr,ZodTransformer:()=>lt,ZodTuple:()=>Tt,ZodType:()=>Y,ZodUndefined:()=>yr,ZodUnion:()=>vr,ZodUnknown:()=>Dt,ZodVoid:()=>en,addIssueToContext:()=>T,any:()=>pv,array:()=>yv,bigint:()=>cv,boolean:()=>Vd,coerce:()=>Lv,custom:()=>qd,date:()=>uv,datetimeRegex:()=>Dd,defaultErrorMap:()=>Mt,discriminatedUnion:()=>bv,effect:()=>Nv,enum:()=>Ev,function:()=>zv,getErrorMap:()=>Gr,getParsedType:()=>Pt,instanceof:()=>iv,intersection:()=>xv,isAborted:()=>Jo,isAsync:()=>Yr,isDirty:()=>Ko,isValid:()=>Bt,late:()=>sv,lazy:()=>Pv,literal:()=>Tv,makeIssue:()=>An,map:()=>kv,nan:()=>av,nativeEnum:()=>Iv,never:()=>hv,null:()=>fv,nullable:()=>Cv,number:()=>Fd,object:()=>Gi,objectUtil:()=>Ji,oboolean:()=>Dv,onumber:()=>Zv,optional:()=>Ov,ostring:()=>Mv,pipeline:()=>Av,preprocess:()=>jv,promise:()=>Rv,quotelessJson:()=>O_,record:()=>$v,set:()=>Sv,setErrorMap:()=>j_,strictObject:()=>_v,string:()=>Ud,symbol:()=>lv,transformer:()=>Nv,tuple:()=>wv,undefined:()=>dv,union:()=>vv,unknown:()=>mv,util:()=>te,void:()=>gv});var te;(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})(te||(te={}));var Ji;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Ji||(Ji={}));var R=te.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pt=t=>{switch(typeof t){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN(t)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":return Array.isArray(t)?R.array:t===null?R.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?R.promise:typeof Map<"u"&&t instanceof Map?R.map:typeof Set<"u"&&t instanceof Set?R.set:typeof Date<"u"&&t instanceof Date?R.date:R.object;default:return R.unknown}};var S=te.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"]),O_=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ge=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,te.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()}};Ge.create=t=>new Ge(t);var C_=(t,e)=>{let r;switch(t.code){case S.invalid_type:t.received===R.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case S.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,te.jsonStringifyReplacer)}`;break;case S.unrecognized_keys:r=`Unrecognized key(s) in object: ${te.joinValues(t.keys,", ")}`;break;case S.invalid_union:r="Invalid input";break;case S.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${te.joinValues(t.options)}`;break;case S.invalid_enum_value:r=`Invalid enum value. Expected ${te.joinValues(t.options)}, received '${t.received}'`;break;case S.invalid_arguments:r="Invalid function arguments";break;case S.invalid_return_type:r="Invalid function return type";break;case S.invalid_date:r="Invalid date";break;case S.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}"`:te.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case S.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 S.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 S.custom:r="Invalid input";break;case S.invalid_intersection_types:r="Intersection results could not be merged";break;case S.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case S.not_finite:r="Number must be finite";break;default:r=e.defaultError,te.assertNever(t)}return{message:r}},Mt=C_;var Cd=Mt;function j_(t){Cd=t}function Gr(){return Cd}var An=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}},A_=[];function T(t,e){let r=Gr(),n=An({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Mt?void 0:Mt].filter(o=>!!o)});t.common.issues.push(n)}var Oe=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 L;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 L;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}}},L=Object.freeze({status:"aborted"}),fr=t=>({status:"dirty",value:t}),De=t=>({status:"valid",value:t}),Jo=t=>t.status==="aborted",Ko=t=>t.status==="dirty",Bt=t=>t.status==="valid",Yr=t=>typeof Promise<"u"&&t instanceof Promise;var C;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(C||(C={}));var ut=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}},jd=(t,e)=>{if(Bt(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 Ge(t.common.issues);return this._error=r,this._error}}};function W(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 Y=class{get description(){return this._def.description}_getType(e){return Pt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Oe,ctx:{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Yr(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:Pt(e)},o=this._parseSync({data:e,path:n.path,parent:n});return jd(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Bt(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=>Bt(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:Pt(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(Yr(o)?o:Promise.resolve(o));return jd(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:S.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 lt({schema:this,typeName:z.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 Ye.create(this,this._def)}nullable(){return Et.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Lt.create(this)}promise(){return Wt.create(this,this._def)}or(e){return vr.create([this,e],this._def)}and(e){return br.create(this,e,this._def)}transform(e){return new lt({...W(this._def),schema:this,typeName:z.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Sr({...W(this._def),innerType:this,defaultValue:r,typeName:z.ZodDefault})}brand(){return new Mn({typeName:z.ZodBranded,type:this,...W(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new zr({...W(this._def),innerType:this,catchValue:r,typeName:z.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Zn.create(this,e)}readonly(){return Pr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},M_=/^c[^\s-]{8,}$/i,Z_=/^[0-9a-z]+$/,D_=/^[0-9A-HJKMNP-TV-Z]{26}$/i,L_=/^[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,q_=/^[a-z0-9_-]{21}$/i,U_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,F_=/^[-+]?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)?)??$/,V_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,H_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ki,B_=/^(?:(?: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])$/,J_=/^(?:(?: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])$/,K_=/^(([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]))$/,W_=/^(([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])$/,G_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Y_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Md="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",X_=new RegExp(`^${Md}$`);function Zd(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 Q_(t){return new RegExp(`^${Zd(t)}$`)}function Dd(t){let e=`${Md}T${Zd(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 ev(t,e){return!!((e==="v4"||!e)&&B_.test(t)||(e==="v6"||!e)&&K_.test(t))}function tv(t,e){if(!U_.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 rv(t,e){return!!((e==="v4"||!e)&&J_.test(t)||(e==="v6"||!e)&&W_.test(t))}var Jt=class t extends Y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==R.string){let s=this._getOrReturnCtx(e);return T(s,{code:S.invalid_type,expected:R.string,received:s.parsedType}),L}let n=new Oe,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),T(o,{code:S.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),T(o,{code:S.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?T(o,{code:S.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&T(o,{code:S.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")V_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"email",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Ki||(Ki=new RegExp(H_,"u")),Ki.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"emoji",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")L_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"uuid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")q_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"nanoid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")M_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"cuid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Z_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"cuid2",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")D_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"ulid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),T(o,{validation:"url",code:S.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),T(o,{validation:"regex",code:S.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),T(o,{code:S.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),T(o,{code:S.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),T(o,{code:S.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Dd(s).test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{code:S.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?X_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{code:S.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Q_(s).test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{code:S.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?F_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"duration",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?ev(e.data,s.version)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"ip",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?tv(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"jwt",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?rv(e.data,s.version)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"cidr",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?G_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"base64",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?Y_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"base64url",code:S.invalid_string,message:s.message}),n.dirty()):te.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:S.invalid_string,...C.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...C.errToObj(e)})}url(e){return this._addCheck({kind:"url",...C.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...C.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...C.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...C.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...C.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...C.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...C.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...C.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...C.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...C.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...C.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...C.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,...C.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,...C.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...C.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...C.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...C.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...C.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...C.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...C.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...C.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...C.errToObj(r)})}nonempty(e){return this.min(1,C.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}};Jt.create=t=>new Jt({checks:[],typeName:z.ZodString,coerce:t?.coerce??!1,...W(t)});function nv(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 pr=class t extends Y{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)!==R.number){let s=this._getOrReturnCtx(e);return T(s,{code:S.invalid_type,expected:R.number,received:s.parsedType}),L}let n,o=new Oe;for(let s of this._def.checks)s.kind==="int"?te.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),T(n,{code:S.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),T(n,{code:S.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),T(n,{code:S.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?nv(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),T(n,{code:S.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),T(n,{code:S.not_finite,message:s.message}),o.dirty()):te.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,C.toString(r))}gt(e,r){return this.setLimit("min",e,!1,C.toString(r))}lte(e,r){return this.setLimit("max",e,!0,C.toString(r))}lt(e,r){return this.setLimit("max",e,!1,C.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:C.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:C.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:C.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:C.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:C.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:C.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:C.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"&&te.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)}};pr.create=t=>new pr({checks:[],typeName:z.ZodNumber,coerce:t?.coerce||!1,...W(t)});var mr=class t extends Y{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)!==R.bigint)return this._getInvalidInput(e);let n,o=new Oe;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),T(n,{code:S.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),T(n,{code:S.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),T(n,{code:S.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):te.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return T(r,{code:S.invalid_type,expected:R.bigint,received:r.parsedType}),L}gte(e,r){return this.setLimit("min",e,!0,C.toString(r))}gt(e,r){return this.setLimit("min",e,!1,C.toString(r))}lte(e,r){return this.setLimit("max",e,!0,C.toString(r))}lt(e,r){return this.setLimit("max",e,!1,C.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:C.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:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:C.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:C.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}};mr.create=t=>new mr({checks:[],typeName:z.ZodBigInt,coerce:t?.coerce??!1,...W(t)});var hr=class extends Y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==R.boolean){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.boolean,received:n.parsedType}),L}return De(e.data)}};hr.create=t=>new hr({typeName:z.ZodBoolean,coerce:t?.coerce||!1,...W(t)});var gr=class t extends Y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==R.date){let s=this._getOrReturnCtx(e);return T(s,{code:S.invalid_type,expected:R.date,received:s.parsedType}),L}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return T(s,{code:S.invalid_date}),L}let n=new Oe,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),T(o,{code:S.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),T(o,{code:S.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):te.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:C.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:C.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}};gr.create=t=>new gr({checks:[],coerce:t?.coerce||!1,typeName:z.ZodDate,...W(t)});var Qr=class extends Y{_parse(e){if(this._getType(e)!==R.symbol){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.symbol,received:n.parsedType}),L}return De(e.data)}};Qr.create=t=>new Qr({typeName:z.ZodSymbol,...W(t)});var yr=class extends Y{_parse(e){if(this._getType(e)!==R.undefined){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.undefined,received:n.parsedType}),L}return De(e.data)}};yr.create=t=>new yr({typeName:z.ZodUndefined,...W(t)});var _r=class extends Y{_parse(e){if(this._getType(e)!==R.null){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.null,received:n.parsedType}),L}return De(e.data)}};_r.create=t=>new _r({typeName:z.ZodNull,...W(t)});var Kt=class extends Y{constructor(){super(...arguments),this._any=!0}_parse(e){return De(e.data)}};Kt.create=t=>new Kt({typeName:z.ZodAny,...W(t)});var Dt=class extends Y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return De(e.data)}};Dt.create=t=>new Dt({typeName:z.ZodUnknown,...W(t)});var yt=class extends Y{_parse(e){let r=this._getOrReturnCtx(e);return T(r,{code:S.invalid_type,expected:R.never,received:r.parsedType}),L}};yt.create=t=>new yt({typeName:z.ZodNever,...W(t)});var en=class extends Y{_parse(e){if(this._getType(e)!==R.undefined){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.void,received:n.parsedType}),L}return De(e.data)}};en.create=t=>new en({typeName:z.ZodVoid,...W(t)});var Lt=class t extends Y{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==R.array)return T(r,{code:S.invalid_type,expected:R.array,received:r.parsedType}),L;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(i||a)&&(T(r,{code:i?S.too_big:S.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&&(T(r,{code:S.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&&(T(r,{code:S.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 ut(r,i,r.path,a)))).then(i=>Oe.mergeArray(n,i));let s=[...r.data].map((i,a)=>o.type._parseSync(new ut(r,i,r.path,a)));return Oe.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:C.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:C.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:C.toString(r)}})}nonempty(e){return this.min(1,e)}};Lt.create=(t,e)=>new Lt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:z.ZodArray,...W(e)});function Xr(t){if(t instanceof Xe){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Ye.create(Xr(n))}return new Xe({...t._def,shape:()=>e})}else return t instanceof Lt?new Lt({...t._def,type:Xr(t.element)}):t instanceof Ye?Ye.create(Xr(t.unwrap())):t instanceof Et?Et.create(Xr(t.unwrap())):t instanceof Tt?Tt.create(t.items.map(e=>Xr(e))):t}var Xe=class t extends Y{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=te.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==R.object){let u=this._getOrReturnCtx(e);return T(u,{code:S.invalid_type,expected:R.object,received:u.parsedType}),L}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof yt&&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],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ut(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof yt){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&&(T(o,{code:S.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 d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ut(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,p=await l.value;u.push({key:d,value:p,alwaysSet:l.alwaysSet})}return u}).then(u=>Oe.mergeObjectSync(n,u)):Oe.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return C.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:C.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:z.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 te.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 te.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Xr(this)}partial(e){let r={};for(let n of te.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 te.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Ye;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:()=>r})}keyof(){return Ld(te.objectKeys(this.shape))}};Xe.create=(t,e)=>new Xe({shape:()=>t,unknownKeys:"strip",catchall:yt.create(),typeName:z.ZodObject,...W(e)});Xe.strictCreate=(t,e)=>new Xe({shape:()=>t,unknownKeys:"strict",catchall:yt.create(),typeName:z.ZodObject,...W(e)});Xe.lazycreate=(t,e)=>new Xe({shape:t,unknownKeys:"strip",catchall:yt.create(),typeName:z.ZodObject,...W(e)});var vr=class extends Y{_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 Ge(a.ctx.common.issues));return T(r,{code:S.invalid_union,unionErrors:i}),L}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 Ge(c));return T(r,{code:S.invalid_union,unionErrors:a}),L}}get options(){return this._def.options}};vr.create=(t,e)=>new vr({options:t,typeName:z.ZodUnion,...W(e)});var Zt=t=>t instanceof xr?Zt(t.schema):t instanceof lt?Zt(t.innerType()):t instanceof wr?[t.value]:t instanceof $r?t.options:t instanceof kr?te.objectValues(t.enum):t instanceof Sr?Zt(t._def.innerType):t instanceof yr?[void 0]:t instanceof _r?[null]:t instanceof Ye?[void 0,...Zt(t.unwrap())]:t instanceof Et?[null,...Zt(t.unwrap())]:t instanceof Mn||t instanceof Pr?Zt(t.unwrap()):t instanceof zr?Zt(t._def.innerType):[],Wo=class t extends Y{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.object)return T(r,{code:S.invalid_type,expected:R.object,received:r.parsedType}),L;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}):(T(r,{code:S.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),L)}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=Zt(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:z.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...W(n)})}};function Wi(t,e){let r=Pt(t),n=Pt(e);if(t===e)return{valid:!0,data:t};if(r===R.object&&n===R.object){let o=te.objectKeys(e),s=te.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=Wi(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===R.array&&n===R.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=Wi(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===R.date&&n===R.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var br=class extends Y{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if(Jo(s)||Jo(i))return L;let a=Wi(s.value,i.value);return a.valid?((Ko(s)||Ko(i))&&r.dirty(),{status:r.value,value:a.data}):(T(n,{code:S.invalid_intersection_types}),L)};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}))}};br.create=(t,e,r)=>new br({left:t,right:e,typeName:z.ZodIntersection,...W(r)});var Tt=class t extends Y{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.array)return T(n,{code:S.invalid_type,expected:R.array,received:n.parsedType}),L;if(n.data.length<this._def.items.length)return T(n,{code:S.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;!this._def.rest&&n.data.length>this._def.items.length&&(T(n,{code:S.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 ut(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>Oe.mergeArray(r,i)):Oe.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Tt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Tt({items:t,typeName:z.ZodTuple,rest:null,...W(e)})};var Go=class t extends Y{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!==R.object)return T(n,{code:S.invalid_type,expected:R.object,received:n.parsedType}),L;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in n.data)o.push({key:s._parse(new ut(n,a,n.path,a)),value:i._parse(new ut(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Oe.mergeObjectAsync(r,o):Oe.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof Y?new t({keyType:e,valueType:r,typeName:z.ZodRecord,...W(n)}):new t({keyType:Jt.create(),valueType:e,typeName:z.ZodRecord,...W(r)})}},tn=class extends Y{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!==R.map)return T(n,{code:S.invalid_type,expected:R.map,received:n.parsedType}),L;let o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new ut(n,a,n.path,[u,"key"])),value:s._parse(new ut(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 L;(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 L;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};tn.create=(t,e,r)=>new tn({valueType:e,keyType:t,typeName:z.ZodMap,...W(r)});var rn=class t extends Y{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.set)return T(n,{code:S.invalid_type,expected:R.set,received:n.parsedType}),L;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(T(n,{code:S.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&&(T(n,{code:S.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 L;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 ut(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:C.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:C.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};rn.create=(t,e)=>new rn({valueType:t,minSize:null,maxSize:null,typeName:z.ZodSet,...W(e)});var Yo=class t extends Y{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.function)return T(r,{code:S.invalid_type,expected:R.function,received:r.parsedType}),L;function n(a,c){return An({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Gr(),Mt].filter(u=>!!u),issueData:{code:S.invalid_arguments,argumentsError:c}})}function o(a,c){return An({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Gr(),Mt].filter(u=>!!u),issueData:{code:S.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Wt){let a=this;return De(async function(...c){let u=new Ge([]),l=await a._def.args.parseAsync(c,s).catch(m=>{throw u.addIssue(n(c,m)),u}),d=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(d,s).catch(m=>{throw u.addIssue(o(d,m)),u})})}else{let a=this;return De(function(...c){let u=a._def.args.safeParse(c,s);if(!u.success)throw new Ge([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),d=a._def.returns.safeParse(l,s);if(!d.success)throw new Ge([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Tt.create(e).rest(Dt.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||Tt.create([]).rest(Dt.create()),returns:r||Dt.create(),typeName:z.ZodFunction,...W(n)})}},xr=class extends Y{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})}};xr.create=(t,e)=>new xr({getter:t,typeName:z.ZodLazy,...W(e)});var wr=class extends Y{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return T(r,{received:r.data,code:S.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:e.data}}get value(){return this._def.value}};wr.create=(t,e)=>new wr({value:t,typeName:z.ZodLiteral,...W(e)});function Ld(t,e){return new $r({values:t,typeName:z.ZodEnum,...W(e)})}var $r=class t extends Y{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return T(r,{expected:te.joinValues(n),received:r.parsedType,code:S.invalid_type}),L}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 T(r,{received:r.data,code:S.invalid_enum_value,options:n}),L}return De(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})}};$r.create=Ld;var kr=class extends Y{_parse(e){let r=te.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==R.string&&n.parsedType!==R.number){let o=te.objectValues(r);return T(n,{expected:te.joinValues(o),received:n.parsedType,code:S.invalid_type}),L}if(this._cache||(this._cache=new Set(te.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=te.objectValues(r);return T(n,{received:n.data,code:S.invalid_enum_value,options:o}),L}return De(e.data)}get enum(){return this._def.values}};kr.create=(t,e)=>new kr({values:t,typeName:z.ZodNativeEnum,...W(e)});var Wt=class extends Y{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.promise&&r.common.async===!1)return T(r,{code:S.invalid_type,expected:R.promise,received:r.parsedType}),L;let n=r.parsedType===R.promise?r.data:Promise.resolve(r.data);return De(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Wt.create=(t,e)=>new Wt({type:t,typeName:z.ZodPromise,...W(e)});var lt=class extends Y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z.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=>{T(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 L;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?L:c.status==="dirty"?fr(c.value):r.value==="dirty"?fr(c.value):c});{if(r.value==="aborted")return L;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?L:a.status==="dirty"?fr(a.value):r.value==="dirty"?fr(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"?L:(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"?L:(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(!Bt(i))return L;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=>Bt(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:r.value,value:a})):L);te.assertNever(o)}};lt.create=(t,e,r)=>new lt({schema:t,typeName:z.ZodEffects,effect:e,...W(r)});lt.createWithPreprocess=(t,e,r)=>new lt({schema:e,effect:{type:"preprocess",transform:t},typeName:z.ZodEffects,...W(r)});var Ye=class extends Y{_parse(e){return this._getType(e)===R.undefined?De(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ye.create=(t,e)=>new Ye({innerType:t,typeName:z.ZodOptional,...W(e)});var Et=class extends Y{_parse(e){return this._getType(e)===R.null?De(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Et.create=(t,e)=>new Et({innerType:t,typeName:z.ZodNullable,...W(e)});var Sr=class extends Y{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===R.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Sr.create=(t,e)=>new Sr({innerType:t,typeName:z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...W(e)});var zr=class extends Y{_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 Yr(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ge(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ge(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};zr.create=(t,e)=>new zr({innerType:t,typeName:z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...W(e)});var nn=class extends Y{_parse(e){if(this._getType(e)!==R.nan){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.nan,received:n.parsedType}),L}return{status:"valid",value:e.data}}};nn.create=t=>new nn({typeName:z.ZodNaN,...W(t)});var ov=Symbol("zod_brand"),Mn=class extends Y{_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}},Zn=class t extends Y{_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"?L:s.status==="dirty"?(r.dirty(),fr(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"?L: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:z.ZodPipeline})}},Pr=class extends Y{_parse(e){let r=this._def.innerType._parse(e),n=o=>(Bt(o)&&(o.value=Object.freeze(o.value)),o);return Yr(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};Pr.create=(t,e)=>new Pr({innerType:t,typeName:z.ZodReadonly,...W(e)});function Ad(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function qd(t,e={},r){return t?Kt.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(i=>{if(!i){let a=Ad(e,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=Ad(e,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}}):Kt.create()}var sv={object:Xe.lazycreate},z;(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"})(z||(z={}));var iv=(t,e={message:`Input not instance of ${t.name}`})=>qd(r=>r instanceof t,e),Ud=Jt.create,Fd=pr.create,av=nn.create,cv=mr.create,Vd=hr.create,uv=gr.create,lv=Qr.create,dv=yr.create,fv=_r.create,pv=Kt.create,mv=Dt.create,hv=yt.create,gv=en.create,yv=Lt.create,Gi=Xe.create,_v=Xe.strictCreate,vv=vr.create,bv=Wo.create,xv=br.create,wv=Tt.create,$v=Go.create,kv=tn.create,Sv=rn.create,zv=Yo.create,Pv=xr.create,Tv=wr.create,Ev=$r.create,Iv=kr.create,Rv=Wt.create,Nv=lt.create,Ov=Ye.create,Cv=Et.create,jv=lt.createWithPreprocess,Av=Zn.create,Mv=()=>Ud().optional(),Zv=()=>Fd().optional(),Dv=()=>Vd().optional(),Lv={string:(t=>Jt.create({...t,coerce:!0})),number:(t=>pr.create({...t,coerce:!0})),boolean:(t=>hr.create({...t,coerce:!0})),bigint:(t=>mr.create({...t,coerce:!0})),date:(t=>gr.create({...t,coerce:!0}))};var qv=L;var Uv=Object.freeze({status:"aborted"});function b(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 qt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Xo={};function it(t){return t&&Object.assign(Xo,t),Xo}var ne={};Bi(ne,{BIGINT_FORMAT_RANGES:()=>Bd,Class:()=>Xi,NUMBER_FORMAT_RANGES:()=>sa,aborted:()=>Er,allowsEval:()=>ra,assert:()=>Jv,assertEqual:()=>Fv,assertIs:()=>Hv,assertNever:()=>Bv,assertNotEqual:()=>Vv,assignProp:()=>ta,cached:()=>qn,captureStackTrace:()=>es,cleanEnum:()=>ib,cleanRegex:()=>Fn,clone:()=>at,createTransparentProxy:()=>Qv,defineLazy:()=>ye,esc:()=>Tr,escapeRegex:()=>Gt,extend:()=>rb,finalizeIssue:()=>_t,floatSafeRemainder:()=>ea,getElementAtPath:()=>Kv,getEnumValues:()=>Ln,getLengthableOrigin:()=>Vn,getParsedType:()=>Xv,getSizableOrigin:()=>Jd,isObject:()=>on,isPlainObject:()=>sn,issue:()=>ia,joinValues:()=>Qo,jsonStringifyReplacer:()=>Qi,merge:()=>nb,normalizeParams:()=>U,nullish:()=>Un,numKeys:()=>Yv,omit:()=>tb,optionalKeys:()=>oa,partial:()=>ob,pick:()=>eb,prefixIssues:()=>It,primitiveTypes:()=>Hd,promiseAllObject:()=>Wv,propertyKeyTypes:()=>na,randomString:()=>Gv,required:()=>sb,stringifyPrimitive:()=>ts,unwrapMessage:()=>Dn});function Fv(t){return t}function Vv(t){return t}function Hv(t){}function Bv(t){throw new Error}function Jv(t){}function Ln(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 Qo(t,e="|"){return t.map(r=>ts(r)).join(e)}function Qi(t,e){return typeof e=="bigint"?e.toString():e}function qn(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Un(t){return t==null}function Fn(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function ea(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 ye(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 ta(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Kv(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function Wv(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 Gv(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Tr(t){return JSON.stringify(t)}var es=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function on(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var ra=qn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function sn(t){if(on(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(on(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Yv(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var Xv=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}`)}},na=new Set(["string","number","symbol"]),Hd=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Gt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function at(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function U(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 Qv(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 ts(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function oa(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var sa={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]},Bd={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function eb(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 at(t,{...t._zod.def,shape:r,checks:[]})}function tb(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 at(t,{...t._zod.def,shape:r,checks:[]})}function rb(t,e){if(!sn(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 ta(this,"shape",n),n},checks:[]};return at(t,r)}function nb(t,e){return at(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return ta(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function ob(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 at(e,{...e._zod.def,shape:o,checks:[]})}function sb(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 at(e,{...e._zod.def,shape:o,checks:[]})}function Er(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function It(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Dn(t){return typeof t=="string"?t:t?.message}function _t(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let o=Dn(t.inst?._zod.def?.error?.(t))??Dn(e?.error?.(t))??Dn(r.customError?.(t))??Dn(r.localeError?.(t))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Jd(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Vn(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function ia(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function ib(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var Xi=class{constructor(...e){}};var Kd=(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,Qi,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},rs=b("$ZodError",Kd),Hn=b("$ZodError",Kd,{Parent:Error});function aa(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 ca(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 ua=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 qt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>_t(c,s,it())));throw es(a,o?.callee),a}return i.value},la=ua(Hn),da=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=>_t(c,s,it())));throw es(a,o?.callee),a}return i.value},fa=da(Hn),pa=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 qt;return s.issues.length?{success:!1,error:new(t??rs)(s.issues.map(i=>_t(i,o,it())))}:{success:!0,data:s.value}},Ir=pa(Hn),ma=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=>_t(i,o,it())))}:{success:!0,data:s.value}},Rr=ma(Hn);var Wd=/^[cC][^\s-]{8,}$/,Gd=/^[0-9a-z]+$/,Yd=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Xd=/^[0-9a-vA-V]{20}$/,Qd=/^[A-Za-z0-9]{27}$/,ef=/^[a-zA-Z0-9_-]{21}$/,tf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var rf=/^([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})$/,ha=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 nf=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var cb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function of(){return new RegExp(cb,"u")}var sf=/^(?:(?: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])$/,af=/^(([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})$/,cf=/^((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])$/,uf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ga=/^[A-Za-z0-9_-]*$/,df=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var ff=/^\+(?:[0-9]){6,14}[0-9]$/,pf="(?:(?:\\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])))",mf=new RegExp(`^${pf}$`);function hf(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 gf(t){return new RegExp(`^${hf(t)}$`)}function yf(t){let e=hf({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(`^${pf}T(?:${n})$`)}var _f=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var vf=/^\d+$/,bf=/^-?\d+(?:\.\d+)?/i,xf=/true|false/i,wf=/null/i;var $f=/^[^A-Z]*$/,kf=/^[^a-z]*$/;var Ce=b("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Sf={number:"number",bigint:"bigint",object:"date"},ya=b("$ZodCheckLessThan",(t,e)=>{Ce.init(t,e);let r=Sf[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})}}),_a=b("$ZodCheckGreaterThan",(t,e)=>{Ce.init(t,e);let r=Sf[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})}}),zf=b("$ZodCheckMultipleOf",(t,e)=>{Ce.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):ea(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})}}),Pf=b("$ZodCheckNumberFormat",(t,e)=>{Ce.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=sa[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=vf)}),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=b("$ZodCheckMaxLength",(t,e)=>{var r;Ce.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Un(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=Vn(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),Ef=b("$ZodCheckMinLength",(t,e)=>{var r;Ce.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Un(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=Vn(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),If=b("$ZodCheckLengthEquals",(t,e)=>{var r;Ce.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Un(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=Vn(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})}}),Bn=b("$ZodCheckStringFormat",(t,e)=>{var r,n;Ce.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=()=>{})}),Rf=b("$ZodCheckRegex",(t,e)=>{Bn.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),Nf=b("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=$f),Bn.init(t,e)}),Of=b("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=kf),Bn.init(t,e)}),Cf=b("$ZodCheckIncludes",(t,e)=>{Ce.init(t,e);let r=Gt(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})}}),jf=b("$ZodCheckStartsWith",(t,e)=>{Ce.init(t,e);let r=new RegExp(`^${Gt(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})}}),Af=b("$ZodCheckEndsWith",(t,e)=>{Ce.init(t,e);let r=new RegExp(`.*${Gt(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 Mf=b("$ZodCheckOverwrite",(t,e)=>{Ce.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var os=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 fP={keyword:"dependencies",type:"object",schemaType:"object",error:Ct.error,code(t){let[e,r]=mP(t);Zg(t,e),Dg(t,r)}};function mP({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 Zg(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,Do.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,Do.checkReportMissingProp)(t,u)}):(r.if((0,Gl._)`${c} && (${(0,Do.checkMissingProp)(t,a,s)})`),(0,Do.reportMissingProp)(t,s),r.else())}}Ct.validatePropertyDeps=Zg;function Dg(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,pP.alwaysValidSchema)(s,e[a])||(r.if((0,Do.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))}Ct.validateSchemaDeps=Dg;Ct.default=fP});var Ug=I(Yl=>{"use strict";Object.defineProperty(Yl,"__esModule",{value:!0});var qg=X(),hP=ue(),gP={message:"property name must be valid",params:({params:t})=>(0,qg._)`{propertyName: ${t.propertyName}}`},yP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:gP,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,hP.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)}};Yl.default=yP});var Ql=I(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:!0});var bi=mt(),kt=X(),_P=Vt(),xi=ue(),vP={message:"must NOT have additional properties",params:({params:t})=>(0,kt._)`{additionalProperty: ${t.additionalProperty}}`},bP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:vP,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,xi.alwaysValidSchema)(i,r))return;let u=(0,bi.allSchemaProperties)(n.properties),l=(0,bi.allSchemaProperties)(n.patternProperties);d(),t.ok((0,kt._)`${s} === ${_P.default.errors}`);function d(){e.forIn("key",o,g=>{!u.length&&!l.length?p(g):e.if(f(g),()=>p(g))})}function f(g){let y;if(u.length>8){let _=(0,xi.schemaRefOrVal)(i,n.properties,"properties");y=(0,bi.isOwnProperty)(e,_,g)}else u.length?y=(0,kt.or)(...u.map(_=>(0,kt._)`${g} === ${_}`)):y=kt.nil;return l.length&&(y=(0,kt.or)(y,...l.map(_=>(0,kt._)`${(0,bi.usePattern)(t,_)}.test(${g})`))),(0,kt.not)(y)}function m(g){e.code((0,kt._)`delete ${o}[${g}]`)}function p(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){m(g);return}if(r===!1){t.setParams({additionalProperty:g}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,xi.alwaysValidSchema)(i,r)){let y=e.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),e.if((0,kt.not)(y),()=>{t.reset(),m(g)})):(h(g,y),a||e.if((0,kt.not)(y),()=>e.break()))}}function h(g,y,_){let w={keyword:"additionalProperties",dataProp:g,dataPropType:xi.Type.Str};_===!1&&Object.assign(w,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(w,y)}}};Xl.default=bP});var Hg=I(td=>{"use strict";Object.defineProperty(td,"__esModule",{value:!0});var xP=ko(),Fg=mt(),ed=ue(),Vg=Ql(),wP={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&&Vg.default.code(new xP.KeywordCxt(s,Vg.default,"additionalProperties"));let i=(0,Fg.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=ed.mergeEvaluated.props(e,(0,ed.toHash)(i),s.props));let a=i.filter(d=>!(0,ed.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,Fg.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};td.default=wP});var Wg=I(rd=>{"use strict";Object.defineProperty(rd,"__esModule",{value:!0});var Bg=mt(),wi=X(),Jg=ue(),Kg=ue(),$P={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,Bg.allSchemaProperties)(r),c=a.filter(h=>(0,Jg.alwaysValidSchema)(s,r[h]));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 wi.Name)&&(s.props=(0,Kg.evaluatedPropsToName)(e,s.props));let{props:d}=s;f();function f(){for(let h of a)u&&m(h),s.allErrors?p(h):(e.var(l,!0),p(h),e.if(l))}function m(h){for(let g in u)new RegExp(h).test(g)&&(0,Jg.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function p(h){e.forIn("key",n,g=>{e.if((0,wi._)`${(0,Bg.usePattern)(t,h)}.test(${g})`,()=>{let y=c.includes(h);y||t.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:Kg.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,wi._)`${d}[${g}]`,!0):!y&&!s.allErrors&&e.if((0,wi.not)(l),()=>e.break())})})}}};rd.default=$P});var Gg=I(nd=>{"use strict";Object.defineProperty(nd,"__esModule",{value:!0});var kP=ue(),SP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,kP.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"}};nd.default=SP});var Yg=I(od=>{"use strict";Object.defineProperty(od,"__esModule",{value:!0});var zP=mt(),PP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:zP.validateUnion,error:{message:"must match a schema in anyOf"}};od.default=PP});var Xg=I(sd=>{"use strict";Object.defineProperty(sd,"__esModule",{value:!0});var $i=X(),TP=ue(),EP={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,$i._)`{passingSchemas: ${t.passing}}`},IP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:EP,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,d)=>{let f;(0,TP.alwaysValidSchema)(o,l)?e.var(c,!0):f=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,$i._)`${c} && ${i}`).assign(i,!1).assign(a,(0,$i._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),f&&t.mergeEvaluated(f,$i.Name)})})}}};sd.default=IP});var Qg=I(id=>{"use strict";Object.defineProperty(id,"__esModule",{value:!0});var RP=ue(),NP={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,RP.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};id.default=NP});var ry=I(ad=>{"use strict";Object.defineProperty(ad,"__esModule",{value:!0});var ki=X(),ty=ue(),OP={message:({params:t})=>(0,ki.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,ki._)`{failingKeyword: ${t.ifClause}}`},CP={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:OP,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,ty.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=ey(n,"then"),s=ey(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,ki.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,d){return()=>{let f=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(f,i),d?e.assign(d,(0,ki._)`${l}`):t.setParams({ifClause:l})}}}};function ey(t,e){let r=t.schema[e];return r!==void 0&&!(0,ty.alwaysValidSchema)(t,r)}ad.default=CP});var ny=I(cd=>{"use strict";Object.defineProperty(cd,"__esModule",{value:!0});var AP=ue(),jP={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,AP.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};cd.default=jP});var oy=I(ud=>{"use strict";Object.defineProperty(ud,"__esModule",{value:!0});var MP=Hl(),ZP=Cg(),DP=Bl(),LP=jg(),qP=Mg(),UP=Lg(),FP=Ug(),VP=Ql(),HP=Hg(),BP=Wg(),JP=Gg(),KP=Yg(),WP=Xg(),GP=Qg(),YP=ry(),XP=ny();function QP(t=!1){let e=[JP.default,KP.default,WP.default,GP.default,YP.default,XP.default,FP.default,VP.default,UP.default,HP.default,BP.default];return t?e.push(ZP.default,LP.default):e.push(MP.default,DP.default),e.push(qP.default),e}ud.default=QP});var sy=I(ld=>{"use strict";Object.defineProperty(ld,"__esModule",{value:!0});var Te=X(),eT={message:({schemaCode:t})=>(0,Te.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,Te._)`{format: ${t}}`},tT={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:eT,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?f():m();function f(){let p=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,Te._)`${p}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,Te._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,Te._)`${h}.type || "string"`).assign(y,(0,Te._)`${h}.validate`),()=>r.assign(g,(0,Te._)`"string"`).assign(y,h)),t.fail$data((0,Te.or)(_(),w()));function _(){return c.strictSchema===!1?Te.nil:(0,Te._)`${i} && !${y}`}function w(){let x=l.$async?(0,Te._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,Te._)`${y}(${n})`,$=(0,Te._)`(typeof ${y} == "function" ? ${x} : ${y}.test(${n}))`;return(0,Te._)`${y} && ${y} !== true && ${g} === ${e} && !${$}`}}function m(){let p=d.formats[s];if(!p){_();return}if(p===!0)return;let[h,g,y]=w(p);h===e&&t.pass(x());function _(){if(c.strictSchema===!1){d.logger.warn($());return}throw new Error($());function $(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function w($){let P=$ instanceof RegExp?(0,Te.regexpCode)($):c.code.formats?(0,Te._)`${c.code.formats}${(0,Te.getProperty)(s)}`:void 0,J=r.scopeValue("formats",{key:s,ref:$,code:P});return typeof $=="object"&&!($ instanceof RegExp)?[$.type||"string",$.validate,(0,Te._)`${J}.validate`]:["string",$,J]}function x(){if(typeof p=="object"&&!(p instanceof RegExp)&&p.async){if(!l.$async)throw new Error("async format in sync schema");return(0,Te._)`await ${y}(${n})`}return typeof g=="function"?(0,Te._)`${y}(${n})`:(0,Te._)`${y}.test(${n})`}}}};ld.default=tT});var iy=I(dd=>{"use strict";Object.defineProperty(dd,"__esModule",{value:!0});var rT=sy(),nT=[rT.default];dd.default=nT});var ay=I(zn=>{"use strict";Object.defineProperty(zn,"__esModule",{value:!0});zn.contentVocabulary=zn.metadataVocabulary=void 0;zn.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];zn.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var uy=I(pd=>{"use strict";Object.defineProperty(pd,"__esModule",{value:!0});var oT=gg(),sT=Ig(),iT=oy(),aT=iy(),cy=ay(),cT=[oT.default,sT.default,(0,iT.default)(),aT.default,cy.metadataVocabulary,cy.contentVocabulary];pd.default=cT});var dy=I(Si=>{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});Si.DiscrError=void 0;var ly;(function(t){t.Tag="tag",t.Mapping="mapping"})(ly||(Si.DiscrError=ly={}))});var fy=I(md=>{"use strict";Object.defineProperty(md,"__esModule",{value:!0});var Pn=X(),fd=dy(),py=ii(),uT=So(),lT=ue(),dT={message:({params:{discrError:t,tagName:e}})=>t===fd.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,Pn._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},pT={keyword:"discriminator",type:"object",schemaType:"object",error:dT,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,Pn._)`${r}${(0,Pn.getProperty)(a)}`);e.if((0,Pn._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:fd.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let m=f();e.if(!1);for(let p in m)e.elseIf((0,Pn._)`${u} === ${p}`),e.assign(c,d(m[p]));e.else(),t.error(!1,{discrError:fd.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(m){let p=e.name("valid"),h=t.subschema({keyword:"oneOf",schemaProp:m},p);return t.mergeEvaluated(h,Pn.Name),p}function f(){var m;let p={},h=y(o),g=!0;for(let x=0;x<i.length;x++){let $=i[x];if($?.$ref&&!(0,lT.schemaHasRulesButRef)($,s.self.RULES)){let J=$.$ref;if($=py.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,J),$ instanceof py.SchemaEnv&&($=$.schema),$===void 0)throw new uT.default(s.opts.uriResolver,s.baseId,J)}let P=(m=$?.properties)===null||m===void 0?void 0:m[a];if(typeof P!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y($)),_(P,x)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return p;function y({required:x}){return Array.isArray(x)&&x.includes(a)}function _(x,$){if(x.const)w(x.const,$);else if(x.enum)for(let P of x.enum)w(P,$);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function w(x,$){if(typeof x!="string"||x in p)throw new Error(`discriminator: "${a}" values must be unique strings`);p[x]=$}}}};md.default=pT});var my=I((gA,fT)=>{fT.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 gd=I((we,hd)=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.MissingRefError=we.ValidationError=we.CodeGen=we.Name=we.nil=we.stringify=we.str=we._=we.KeywordCxt=we.Ajv=void 0;var mT=lg(),hT=uy(),gT=fy(),hy=my(),yT=["/properties"],zi="http://json-schema.org/draft-07/schema",Tn=class extends mT.default{_addVocabularies(){super._addVocabularies(),hT.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(gT.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(hy,yT):hy;this.addMetaSchema(e,zi,!1),this.refs["http://json-schema.org/schema"]=zi}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(zi)?zi:void 0)}};we.Ajv=Tn;hd.exports=we=Tn;hd.exports.Ajv=Tn;Object.defineProperty(we,"__esModule",{value:!0});we.default=Tn;var _T=ko();Object.defineProperty(we,"KeywordCxt",{enumerable:!0,get:function(){return _T.KeywordCxt}});var En=X();Object.defineProperty(we,"_",{enumerable:!0,get:function(){return En._}});Object.defineProperty(we,"str",{enumerable:!0,get:function(){return En.str}});Object.defineProperty(we,"stringify",{enumerable:!0,get:function(){return En.stringify}});Object.defineProperty(we,"nil",{enumerable:!0,get:function(){return En.nil}});Object.defineProperty(we,"Name",{enumerable:!0,get:function(){return En.Name}});Object.defineProperty(we,"CodeGen",{enumerable:!0,get:function(){return En.CodeGen}});var vT=oi();Object.defineProperty(we,"ValidationError",{enumerable:!0,get:function(){return vT.default}});var bT=So();Object.defineProperty(we,"MissingRefError",{enumerable:!0,get:function(){return bT.default}})});var $y=I(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.formatNames=jt.fastFormats=jt.fullFormats=void 0;function At(t,e){return{validate:t,compare:e}}jt.fullFormats={date:At(vy,bd),time:At(_d(!0),xd),"date-time":At(gy(!0),xy),"iso-time":At(_d(),by),"iso-date-time":At(gy(),wy),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:zT,"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:OT,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:PT,int32:{type:"number",validate:IT},int64:{type:"number",validate:RT},float:{type:"number",validate:_y},double:{type:"number",validate:_y},password:!0,binary:!0};jt.fastFormats={...jt.fullFormats,date:At(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,bd),time:At(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,xd),"date-time":At(/^\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,xy),"iso-time":At(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,by),"iso-date-time":At(/^\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,wy),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};jt.formatNames=Object.keys(jt.fullFormats);function xT(t){return t%4===0&&(t%100!==0||t%400===0)}var wT=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,$T=[0,31,28,31,30,31,30,31,31,30,31,30,31];function vy(t){let e=wT.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&&xT(r)?29:$T[n])}function bd(t,e){if(t&&e)return t>e?1:t<e?-1:0}var yd=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function _d(t){return function(r){let n=yd.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 d=s-l*c,f=o-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function xd(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 by(t,e){if(!(t&&e))return;let r=yd.exec(t),n=yd.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 vd=/t|\s/i;function gy(t){let e=_d(t);return function(n){let o=n.split(vd);return o.length===2&&vy(o[0])&&e(o[1])}}function xy(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function wy(t,e){if(!(t&&e))return;let[r,n]=t.split(vd),[o,s]=e.split(vd),i=bd(r,o);if(i!==void 0)return i||xd(n,s)}var kT=/\/|:/,ST=/^(?:[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 zT(t){return kT.test(t)&&ST.test(t)}var yy=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function PT(t){return yy.lastIndex=0,yy.test(t)}var TT=-(2**31),ET=2**31-1;function IT(t){return Number.isInteger(t)&&t<=ET&&t>=TT}function RT(t){return Number.isInteger(t)}function _y(){return!0}var NT=/[^\\]\\Z/;function OT(t){if(NT.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var ky=I(In=>{"use strict";Object.defineProperty(In,"__esModule",{value:!0});In.formatLimitDefinition=void 0;var CT=gd(),St=X(),ur=St.operators,Pi={formatMaximum:{okStr:"<=",ok:ur.LTE,fail:ur.GT},formatMinimum:{okStr:">=",ok:ur.GTE,fail:ur.LT},formatExclusiveMaximum:{okStr:"<",ok:ur.LT,fail:ur.GTE},formatExclusiveMinimum:{okStr:">",ok:ur.GT,fail:ur.LTE}},AT={message:({keyword:t,schemaCode:e})=>(0,St.str)`should be ${Pi[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,St._)`{comparison: ${Pi[t].okStr}, limit: ${e}}`};In.formatLimitDefinition={keyword:Object.keys(Pi),type:"string",schemaType:"string",$data:!0,error:AT,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 CT.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),m=e.const("fmt",(0,St._)`${f}[${c.schemaCode}]`);t.fail$data((0,St.or)((0,St._)`typeof ${m} != "object"`,(0,St._)`${m} instanceof RegExp`,(0,St._)`typeof ${m}.compare != "function"`,d(m)))}function l(){let f=c.schema,m=a.formats[f];if(!m||m===!0)return;if(typeof m!="object"||m instanceof RegExp||typeof m.compare!="function")throw new Error(`"${o}": format "${f}" does not define "compare" function`);let p=e.scopeValue("formats",{key:f,ref:m,code:i.code.formats?(0,St._)`${i.code.formats}${(0,St.getProperty)(f)}`:void 0});t.fail$data(d(p))}function d(f){return(0,St._)`${f}.compare(${r}, ${n}) ${Pi[o].fail} 0`}},dependencies:["format"]};var jT=t=>(t.addKeyword(In.formatLimitDefinition),t);In.default=jT});var Ty=I((Lo,Py)=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});var Rn=$y(),MT=ky(),wd=X(),Sy=new wd.Name("fullFormats"),ZT=new wd.Name("fastFormats"),$d=(t,e={keywords:!0})=>{if(Array.isArray(e))return zy(t,e,Rn.fullFormats,Sy),t;let[r,n]=e.mode==="fast"?[Rn.fastFormats,ZT]:[Rn.fullFormats,Sy],o=e.formats||Rn.formatNames;return zy(t,o,r,n),e.keywords&&(0,MT.default)(t),t};$d.get=(t,e="full")=>{let n=(e==="fast"?Rn.fastFormats:Rn.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function zy(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,wd._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}Py.exports=Lo=$d;Object.defineProperty(Lo,"__esModule",{value:!0});Lo.default=$d});var q={};Bi(q,{BRAND:()=>ov,DIRTY:()=>pr,EMPTY_PATH:()=>j_,INVALID:()=>L,NEVER:()=>qv,OK:()=>De,ParseStatus:()=>Oe,Schema:()=>Y,ZodAny:()=>Kt,ZodArray:()=>Lt,ZodBigInt:()=>mr,ZodBoolean:()=>hr,ZodBranded:()=>Mn,ZodCatch:()=>zr,ZodDate:()=>gr,ZodDefault:()=>Sr,ZodDiscriminatedUnion:()=>Wo,ZodEffects:()=>lt,ZodEnum:()=>$r,ZodError:()=>Ge,ZodFirstPartyTypeKind:()=>z,ZodFunction:()=>Yo,ZodIntersection:()=>br,ZodIssueCode:()=>S,ZodLazy:()=>xr,ZodLiteral:()=>wr,ZodMap:()=>tn,ZodNaN:()=>nn,ZodNativeEnum:()=>kr,ZodNever:()=>yt,ZodNull:()=>_r,ZodNullable:()=>Et,ZodNumber:()=>fr,ZodObject:()=>Xe,ZodOptional:()=>Ye,ZodParsedType:()=>R,ZodPipeline:()=>Zn,ZodPromise:()=>Wt,ZodReadonly:()=>Pr,ZodRecord:()=>Go,ZodSchema:()=>Y,ZodSet:()=>rn,ZodString:()=>Jt,ZodSymbol:()=>Qr,ZodTransformer:()=>lt,ZodTuple:()=>Tt,ZodType:()=>Y,ZodUndefined:()=>yr,ZodUnion:()=>vr,ZodUnknown:()=>Dt,ZodVoid:()=>en,addIssueToContext:()=>T,any:()=>fv,array:()=>yv,bigint:()=>cv,boolean:()=>Vd,coerce:()=>Lv,custom:()=>qd,date:()=>uv,datetimeRegex:()=>Dd,defaultErrorMap:()=>Mt,discriminatedUnion:()=>bv,effect:()=>Nv,enum:()=>Ev,function:()=>zv,getErrorMap:()=>Gr,getParsedType:()=>Pt,instanceof:()=>iv,intersection:()=>xv,isAborted:()=>Jo,isAsync:()=>Yr,isDirty:()=>Ko,isValid:()=>Bt,late:()=>sv,lazy:()=>Pv,literal:()=>Tv,makeIssue:()=>jn,map:()=>kv,nan:()=>av,nativeEnum:()=>Iv,never:()=>hv,null:()=>pv,nullable:()=>Cv,number:()=>Fd,object:()=>Gi,objectUtil:()=>Ji,oboolean:()=>Dv,onumber:()=>Zv,optional:()=>Ov,ostring:()=>Mv,pipeline:()=>jv,preprocess:()=>Av,promise:()=>Rv,quotelessJson:()=>O_,record:()=>$v,set:()=>Sv,setErrorMap:()=>A_,strictObject:()=>_v,string:()=>Ud,symbol:()=>lv,transformer:()=>Nv,tuple:()=>wv,undefined:()=>dv,union:()=>vv,unknown:()=>mv,util:()=>te,void:()=>gv});var te;(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})(te||(te={}));var Ji;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Ji||(Ji={}));var R=te.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pt=t=>{switch(typeof t){case"undefined":return R.undefined;case"string":return R.string;case"number":return Number.isNaN(t)?R.nan:R.number;case"boolean":return R.boolean;case"function":return R.function;case"bigint":return R.bigint;case"symbol":return R.symbol;case"object":return Array.isArray(t)?R.array:t===null?R.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?R.promise:typeof Map<"u"&&t instanceof Map?R.map:typeof Set<"u"&&t instanceof Set?R.set:typeof Date<"u"&&t instanceof Date?R.date:R.object;default:return R.unknown}};var S=te.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"]),O_=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:"),Ge=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,te.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()}};Ge.create=t=>new Ge(t);var C_=(t,e)=>{let r;switch(t.code){case S.invalid_type:t.received===R.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case S.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,te.jsonStringifyReplacer)}`;break;case S.unrecognized_keys:r=`Unrecognized key(s) in object: ${te.joinValues(t.keys,", ")}`;break;case S.invalid_union:r="Invalid input";break;case S.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${te.joinValues(t.options)}`;break;case S.invalid_enum_value:r=`Invalid enum value. Expected ${te.joinValues(t.options)}, received '${t.received}'`;break;case S.invalid_arguments:r="Invalid function arguments";break;case S.invalid_return_type:r="Invalid function return type";break;case S.invalid_date:r="Invalid date";break;case S.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}"`:te.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case S.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 S.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 S.custom:r="Invalid input";break;case S.invalid_intersection_types:r="Intersection results could not be merged";break;case S.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case S.not_finite:r="Number must be finite";break;default:r=e.defaultError,te.assertNever(t)}return{message:r}},Mt=C_;var Cd=Mt;function A_(t){Cd=t}function Gr(){return Cd}var jn=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}},j_=[];function T(t,e){let r=Gr(),n=jn({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Mt?void 0:Mt].filter(o=>!!o)});t.common.issues.push(n)}var Oe=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 L;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 L;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}}},L=Object.freeze({status:"aborted"}),pr=t=>({status:"dirty",value:t}),De=t=>({status:"valid",value:t}),Jo=t=>t.status==="aborted",Ko=t=>t.status==="dirty",Bt=t=>t.status==="valid",Yr=t=>typeof Promise<"u"&&t instanceof Promise;var C;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(C||(C={}));var ut=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}},Ad=(t,e)=>{if(Bt(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 Ge(t.common.issues);return this._error=r,this._error}}};function W(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 Y=class{get description(){return this._def.description}_getType(e){return Pt(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Oe,ctx:{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let r=this._parse(e);if(Yr(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:Pt(e)},o=this._parseSync({data:e,path:n.path,parent:n});return Ad(n,o)}"~validate"(e){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:r});return Bt(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=>Bt(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:Pt(e)},o=this._parse({data:e,path:n.path,parent:n}),s=await(Yr(o)?o:Promise.resolve(o));return Ad(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:S.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 lt({schema:this,typeName:z.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 Ye.create(this,this._def)}nullable(){return Et.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Lt.create(this)}promise(){return Wt.create(this,this._def)}or(e){return vr.create([this,e],this._def)}and(e){return br.create(this,e,this._def)}transform(e){return new lt({...W(this._def),schema:this,typeName:z.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let r=typeof e=="function"?e:()=>e;return new Sr({...W(this._def),innerType:this,defaultValue:r,typeName:z.ZodDefault})}brand(){return new Mn({typeName:z.ZodBranded,type:this,...W(this._def)})}catch(e){let r=typeof e=="function"?e:()=>e;return new zr({...W(this._def),innerType:this,catchValue:r,typeName:z.ZodCatch})}describe(e){let r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Zn.create(this,e)}readonly(){return Pr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},M_=/^c[^\s-]{8,}$/i,Z_=/^[0-9a-z]+$/,D_=/^[0-9A-HJKMNP-TV-Z]{26}$/i,L_=/^[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,q_=/^[a-z0-9_-]{21}$/i,U_=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,F_=/^[-+]?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)?)??$/,V_=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,H_="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ki,B_=/^(?:(?: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])$/,J_=/^(?:(?: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])$/,K_=/^(([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]))$/,W_=/^(([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])$/,G_=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Y_=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Md="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",X_=new RegExp(`^${Md}$`);function Zd(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 Q_(t){return new RegExp(`^${Zd(t)}$`)}function Dd(t){let e=`${Md}T${Zd(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 ev(t,e){return!!((e==="v4"||!e)&&B_.test(t)||(e==="v6"||!e)&&K_.test(t))}function tv(t,e){if(!U_.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 rv(t,e){return!!((e==="v4"||!e)&&J_.test(t)||(e==="v6"||!e)&&W_.test(t))}var Jt=class t extends Y{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==R.string){let s=this._getOrReturnCtx(e);return T(s,{code:S.invalid_type,expected:R.string,received:s.parsedType}),L}let n=new Oe,o;for(let s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(o=this._getOrReturnCtx(e,o),T(o,{code:S.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),T(o,{code:S.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?T(o,{code:S.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):a&&T(o,{code:S.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),n.dirty())}else if(s.kind==="email")V_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"email",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="emoji")Ki||(Ki=new RegExp(H_,"u")),Ki.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"emoji",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="uuid")L_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"uuid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="nanoid")q_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"nanoid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid")M_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"cuid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="cuid2")Z_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"cuid2",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="ulid")D_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"ulid",code:S.invalid_string,message:s.message}),n.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{o=this._getOrReturnCtx(e,o),T(o,{validation:"url",code:S.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),T(o,{validation:"regex",code:S.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),T(o,{code:S.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),T(o,{code:S.invalid_string,validation:{startsWith:s.value},message:s.message}),n.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(o=this._getOrReturnCtx(e,o),T(o,{code:S.invalid_string,validation:{endsWith:s.value},message:s.message}),n.dirty()):s.kind==="datetime"?Dd(s).test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{code:S.invalid_string,validation:"datetime",message:s.message}),n.dirty()):s.kind==="date"?X_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{code:S.invalid_string,validation:"date",message:s.message}),n.dirty()):s.kind==="time"?Q_(s).test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{code:S.invalid_string,validation:"time",message:s.message}),n.dirty()):s.kind==="duration"?F_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"duration",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="ip"?ev(e.data,s.version)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"ip",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="jwt"?tv(e.data,s.alg)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"jwt",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="cidr"?rv(e.data,s.version)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"cidr",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="base64"?G_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"base64",code:S.invalid_string,message:s.message}),n.dirty()):s.kind==="base64url"?Y_.test(e.data)||(o=this._getOrReturnCtx(e,o),T(o,{validation:"base64url",code:S.invalid_string,message:s.message}),n.dirty()):te.assertNever(s);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(o=>e.test(o),{validation:r,code:S.invalid_string,...C.errToObj(n)})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...C.errToObj(e)})}url(e){return this._addCheck({kind:"url",...C.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...C.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...C.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...C.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...C.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...C.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...C.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...C.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...C.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...C.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...C.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...C.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,...C.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,...C.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...C.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...C.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r?.position,...C.errToObj(r?.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...C.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...C.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...C.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...C.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...C.errToObj(r)})}nonempty(e){return this.min(1,C.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}};Jt.create=t=>new Jt({checks:[],typeName:z.ZodString,coerce:t?.coerce??!1,...W(t)});function nv(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 fr=class t extends Y{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)!==R.number){let s=this._getOrReturnCtx(e);return T(s,{code:S.invalid_type,expected:R.number,received:s.parsedType}),L}let n,o=new Oe;for(let s of this._def.checks)s.kind==="int"?te.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),T(n,{code:S.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),T(n,{code:S.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),T(n,{code:S.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),o.dirty()):s.kind==="multipleOf"?nv(e.data,s.value)!==0&&(n=this._getOrReturnCtx(e,n),T(n,{code:S.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),T(n,{code:S.not_finite,message:s.message}),o.dirty()):te.assertNever(s);return{status:o.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,C.toString(r))}gt(e,r){return this.setLimit("min",e,!1,C.toString(r))}lte(e,r){return this.setLimit("max",e,!0,C.toString(r))}lt(e,r){return this.setLimit("max",e,!1,C.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:C.toString(o)}]})}_addCheck(e){return new t({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:C.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:C.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:C.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:C.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:C.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:C.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"&&te.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)}};fr.create=t=>new fr({checks:[],typeName:z.ZodNumber,coerce:t?.coerce||!1,...W(t)});var mr=class t extends Y{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)!==R.bigint)return this._getInvalidInput(e);let n,o=new Oe;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),T(n,{code:S.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),T(n,{code:S.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),T(n,{code:S.not_multiple_of,multipleOf:s.value,message:s.message}),o.dirty()):te.assertNever(s);return{status:o.value,value:e.data}}_getInvalidInput(e){let r=this._getOrReturnCtx(e);return T(r,{code:S.invalid_type,expected:R.bigint,received:r.parsedType}),L}gte(e,r){return this.setLimit("min",e,!0,C.toString(r))}gt(e,r){return this.setLimit("min",e,!1,C.toString(r))}lte(e,r){return this.setLimit("max",e,!0,C.toString(r))}lt(e,r){return this.setLimit("max",e,!1,C.toString(r))}setLimit(e,r,n,o){return new t({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:C.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:C.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:C.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:C.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:C.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:C.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}};mr.create=t=>new mr({checks:[],typeName:z.ZodBigInt,coerce:t?.coerce??!1,...W(t)});var hr=class extends Y{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==R.boolean){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.boolean,received:n.parsedType}),L}return De(e.data)}};hr.create=t=>new hr({typeName:z.ZodBoolean,coerce:t?.coerce||!1,...W(t)});var gr=class t extends Y{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==R.date){let s=this._getOrReturnCtx(e);return T(s,{code:S.invalid_type,expected:R.date,received:s.parsedType}),L}if(Number.isNaN(e.data.getTime())){let s=this._getOrReturnCtx(e);return T(s,{code:S.invalid_date}),L}let n=new Oe,o;for(let s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(o=this._getOrReturnCtx(e,o),T(o,{code:S.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),T(o,{code:S.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),n.dirty()):te.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:C.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:C.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}};gr.create=t=>new gr({checks:[],coerce:t?.coerce||!1,typeName:z.ZodDate,...W(t)});var Qr=class extends Y{_parse(e){if(this._getType(e)!==R.symbol){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.symbol,received:n.parsedType}),L}return De(e.data)}};Qr.create=t=>new Qr({typeName:z.ZodSymbol,...W(t)});var yr=class extends Y{_parse(e){if(this._getType(e)!==R.undefined){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.undefined,received:n.parsedType}),L}return De(e.data)}};yr.create=t=>new yr({typeName:z.ZodUndefined,...W(t)});var _r=class extends Y{_parse(e){if(this._getType(e)!==R.null){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.null,received:n.parsedType}),L}return De(e.data)}};_r.create=t=>new _r({typeName:z.ZodNull,...W(t)});var Kt=class extends Y{constructor(){super(...arguments),this._any=!0}_parse(e){return De(e.data)}};Kt.create=t=>new Kt({typeName:z.ZodAny,...W(t)});var Dt=class extends Y{constructor(){super(...arguments),this._unknown=!0}_parse(e){return De(e.data)}};Dt.create=t=>new Dt({typeName:z.ZodUnknown,...W(t)});var yt=class extends Y{_parse(e){let r=this._getOrReturnCtx(e);return T(r,{code:S.invalid_type,expected:R.never,received:r.parsedType}),L}};yt.create=t=>new yt({typeName:z.ZodNever,...W(t)});var en=class extends Y{_parse(e){if(this._getType(e)!==R.undefined){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.void,received:n.parsedType}),L}return De(e.data)}};en.create=t=>new en({typeName:z.ZodVoid,...W(t)});var Lt=class t extends Y{_parse(e){let{ctx:r,status:n}=this._processInputParams(e),o=this._def;if(r.parsedType!==R.array)return T(r,{code:S.invalid_type,expected:R.array,received:r.parsedType}),L;if(o.exactLength!==null){let i=r.data.length>o.exactLength.value,a=r.data.length<o.exactLength.value;(i||a)&&(T(r,{code:i?S.too_big:S.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&&(T(r,{code:S.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&&(T(r,{code:S.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 ut(r,i,r.path,a)))).then(i=>Oe.mergeArray(n,i));let s=[...r.data].map((i,a)=>o.type._parseSync(new ut(r,i,r.path,a)));return Oe.mergeArray(n,s)}get element(){return this._def.type}min(e,r){return new t({...this._def,minLength:{value:e,message:C.toString(r)}})}max(e,r){return new t({...this._def,maxLength:{value:e,message:C.toString(r)}})}length(e,r){return new t({...this._def,exactLength:{value:e,message:C.toString(r)}})}nonempty(e){return this.min(1,e)}};Lt.create=(t,e)=>new Lt({type:t,minLength:null,maxLength:null,exactLength:null,typeName:z.ZodArray,...W(e)});function Xr(t){if(t instanceof Xe){let e={};for(let r in t.shape){let n=t.shape[r];e[r]=Ye.create(Xr(n))}return new Xe({...t._def,shape:()=>e})}else return t instanceof Lt?new Lt({...t._def,type:Xr(t.element)}):t instanceof Ye?Ye.create(Xr(t.unwrap())):t instanceof Et?Et.create(Xr(t.unwrap())):t instanceof Tt?Tt.create(t.items.map(e=>Xr(e))):t}var Xe=class t extends Y{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=te.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==R.object){let u=this._getOrReturnCtx(e);return T(u,{code:S.invalid_type,expected:R.object,received:u.parsedType}),L}let{status:n,ctx:o}=this._processInputParams(e),{shape:s,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof yt&&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],d=o.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new ut(o,d,o.path,u)),alwaysSet:u in o.data})}if(this._def.catchall instanceof yt){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&&(T(o,{code:S.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 d=o.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new ut(o,d,o.path,l)),alwaysSet:l in o.data})}}return o.common.async?Promise.resolve().then(async()=>{let u=[];for(let l of c){let d=await l.key,f=await l.value;u.push({key:d,value:f,alwaysSet:l.alwaysSet})}return u}).then(u=>Oe.mergeObjectSync(n,u)):Oe.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return C.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:C.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:z.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 te.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 te.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new t({...this._def,shape:()=>r})}deepPartial(){return Xr(this)}partial(e){let r={};for(let n of te.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 te.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Ye;)s=s._def.innerType;r[n]=s}return new t({...this._def,shape:()=>r})}keyof(){return Ld(te.objectKeys(this.shape))}};Xe.create=(t,e)=>new Xe({shape:()=>t,unknownKeys:"strip",catchall:yt.create(),typeName:z.ZodObject,...W(e)});Xe.strictCreate=(t,e)=>new Xe({shape:()=>t,unknownKeys:"strict",catchall:yt.create(),typeName:z.ZodObject,...W(e)});Xe.lazycreate=(t,e)=>new Xe({shape:t,unknownKeys:"strip",catchall:yt.create(),typeName:z.ZodObject,...W(e)});var vr=class extends Y{_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 Ge(a.ctx.common.issues));return T(r,{code:S.invalid_union,unionErrors:i}),L}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 Ge(c));return T(r,{code:S.invalid_union,unionErrors:a}),L}}get options(){return this._def.options}};vr.create=(t,e)=>new vr({options:t,typeName:z.ZodUnion,...W(e)});var Zt=t=>t instanceof xr?Zt(t.schema):t instanceof lt?Zt(t.innerType()):t instanceof wr?[t.value]:t instanceof $r?t.options:t instanceof kr?te.objectValues(t.enum):t instanceof Sr?Zt(t._def.innerType):t instanceof yr?[void 0]:t instanceof _r?[null]:t instanceof Ye?[void 0,...Zt(t.unwrap())]:t instanceof Et?[null,...Zt(t.unwrap())]:t instanceof Mn||t instanceof Pr?Zt(t.unwrap()):t instanceof zr?Zt(t._def.innerType):[],Wo=class t extends Y{_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.object)return T(r,{code:S.invalid_type,expected:R.object,received:r.parsedType}),L;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}):(T(r,{code:S.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),L)}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=Zt(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:z.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:o,...W(n)})}};function Wi(t,e){let r=Pt(t),n=Pt(e);if(t===e)return{valid:!0,data:t};if(r===R.object&&n===R.object){let o=te.objectKeys(e),s=te.objectKeys(t).filter(a=>o.indexOf(a)!==-1),i={...t,...e};for(let a of s){let c=Wi(t[a],e[a]);if(!c.valid)return{valid:!1};i[a]=c.data}return{valid:!0,data:i}}else if(r===R.array&&n===R.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=Wi(i,a);if(!c.valid)return{valid:!1};o.push(c.data)}return{valid:!0,data:o}}else return r===R.date&&n===R.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}var br=class extends Y{_parse(e){let{status:r,ctx:n}=this._processInputParams(e),o=(s,i)=>{if(Jo(s)||Jo(i))return L;let a=Wi(s.value,i.value);return a.valid?((Ko(s)||Ko(i))&&r.dirty(),{status:r.value,value:a.data}):(T(n,{code:S.invalid_intersection_types}),L)};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}))}};br.create=(t,e,r)=>new br({left:t,right:e,typeName:z.ZodIntersection,...W(r)});var Tt=class t extends Y{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.array)return T(n,{code:S.invalid_type,expected:R.array,received:n.parsedType}),L;if(n.data.length<this._def.items.length)return T(n,{code:S.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;!this._def.rest&&n.data.length>this._def.items.length&&(T(n,{code:S.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 ut(n,i,n.path,a)):null}).filter(i=>!!i);return n.common.async?Promise.all(s).then(i=>Oe.mergeArray(r,i)):Oe.mergeArray(r,s)}get items(){return this._def.items}rest(e){return new t({...this._def,rest:e})}};Tt.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Tt({items:t,typeName:z.ZodTuple,rest:null,...W(e)})};var Go=class t extends Y{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!==R.object)return T(n,{code:S.invalid_type,expected:R.object,received:n.parsedType}),L;let o=[],s=this._def.keyType,i=this._def.valueType;for(let a in n.data)o.push({key:s._parse(new ut(n,a,n.path,a)),value:i._parse(new ut(n,n.data[a],n.path,a)),alwaysSet:a in n.data});return n.common.async?Oe.mergeObjectAsync(r,o):Oe.mergeObjectSync(r,o)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof Y?new t({keyType:e,valueType:r,typeName:z.ZodRecord,...W(n)}):new t({keyType:Jt.create(),valueType:e,typeName:z.ZodRecord,...W(r)})}},tn=class extends Y{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!==R.map)return T(n,{code:S.invalid_type,expected:R.map,received:n.parsedType}),L;let o=this._def.keyType,s=this._def.valueType,i=[...n.data.entries()].map(([a,c],u)=>({key:o._parse(new ut(n,a,n.path,[u,"key"])),value:s._parse(new ut(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 L;(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 L;(u.status==="dirty"||l.status==="dirty")&&r.dirty(),a.set(u.value,l.value)}return{status:r.value,value:a}}}};tn.create=(t,e,r)=>new tn({valueType:e,keyType:t,typeName:z.ZodMap,...W(r)});var rn=class t extends Y{_parse(e){let{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==R.set)return T(n,{code:S.invalid_type,expected:R.set,received:n.parsedType}),L;let o=this._def;o.minSize!==null&&n.data.size<o.minSize.value&&(T(n,{code:S.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&&(T(n,{code:S.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 L;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 ut(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:C.toString(r)}})}max(e,r){return new t({...this._def,maxSize:{value:e,message:C.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}};rn.create=(t,e)=>new rn({valueType:t,minSize:null,maxSize:null,typeName:z.ZodSet,...W(e)});var Yo=class t extends Y{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.function)return T(r,{code:S.invalid_type,expected:R.function,received:r.parsedType}),L;function n(a,c){return jn({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Gr(),Mt].filter(u=>!!u),issueData:{code:S.invalid_arguments,argumentsError:c}})}function o(a,c){return jn({data:a,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Gr(),Mt].filter(u=>!!u),issueData:{code:S.invalid_return_type,returnTypeError:c}})}let s={errorMap:r.common.contextualErrorMap},i=r.data;if(this._def.returns instanceof Wt){let a=this;return De(async function(...c){let u=new Ge([]),l=await a._def.args.parseAsync(c,s).catch(m=>{throw u.addIssue(n(c,m)),u}),d=await Reflect.apply(i,this,l);return await a._def.returns._def.type.parseAsync(d,s).catch(m=>{throw u.addIssue(o(d,m)),u})})}else{let a=this;return De(function(...c){let u=a._def.args.safeParse(c,s);if(!u.success)throw new Ge([n(c,u.error)]);let l=Reflect.apply(i,this,u.data),d=a._def.returns.safeParse(l,s);if(!d.success)throw new Ge([o(l,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new t({...this._def,args:Tt.create(e).rest(Dt.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||Tt.create([]).rest(Dt.create()),returns:r||Dt.create(),typeName:z.ZodFunction,...W(n)})}},xr=class extends Y{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})}};xr.create=(t,e)=>new xr({getter:t,typeName:z.ZodLazy,...W(e)});var wr=class extends Y{_parse(e){if(e.data!==this._def.value){let r=this._getOrReturnCtx(e);return T(r,{received:r.data,code:S.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:e.data}}get value(){return this._def.value}};wr.create=(t,e)=>new wr({value:t,typeName:z.ZodLiteral,...W(e)});function Ld(t,e){return new $r({values:t,typeName:z.ZodEnum,...W(e)})}var $r=class t extends Y{_parse(e){if(typeof e.data!="string"){let r=this._getOrReturnCtx(e),n=this._def.values;return T(r,{expected:te.joinValues(n),received:r.parsedType,code:S.invalid_type}),L}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 T(r,{received:r.data,code:S.invalid_enum_value,options:n}),L}return De(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})}};$r.create=Ld;var kr=class extends Y{_parse(e){let r=te.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==R.string&&n.parsedType!==R.number){let o=te.objectValues(r);return T(n,{expected:te.joinValues(o),received:n.parsedType,code:S.invalid_type}),L}if(this._cache||(this._cache=new Set(te.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let o=te.objectValues(r);return T(n,{received:n.data,code:S.invalid_enum_value,options:o}),L}return De(e.data)}get enum(){return this._def.values}};kr.create=(t,e)=>new kr({values:t,typeName:z.ZodNativeEnum,...W(e)});var Wt=class extends Y{unwrap(){return this._def.type}_parse(e){let{ctx:r}=this._processInputParams(e);if(r.parsedType!==R.promise&&r.common.async===!1)return T(r,{code:S.invalid_type,expected:R.promise,received:r.parsedType}),L;let n=r.parsedType===R.promise?r.data:Promise.resolve(r.data);return De(n.then(o=>this._def.type.parseAsync(o,{path:r.path,errorMap:r.common.contextualErrorMap})))}};Wt.create=(t,e)=>new Wt({type:t,typeName:z.ZodPromise,...W(e)});var lt=class extends Y{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z.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=>{T(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 L;let c=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});return c.status==="aborted"?L:c.status==="dirty"?pr(c.value):r.value==="dirty"?pr(c.value):c});{if(r.value==="aborted")return L;let a=this._def.schema._parseSync({data:i,path:n.path,parent:n});return a.status==="aborted"?L:a.status==="dirty"?pr(a.value):r.value==="dirty"?pr(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"?L:(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"?L:(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(!Bt(i))return L;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=>Bt(i)?Promise.resolve(o.transform(i.value,s)).then(a=>({status:r.value,value:a})):L);te.assertNever(o)}};lt.create=(t,e,r)=>new lt({schema:t,typeName:z.ZodEffects,effect:e,...W(r)});lt.createWithPreprocess=(t,e,r)=>new lt({schema:e,effect:{type:"preprocess",transform:t},typeName:z.ZodEffects,...W(r)});var Ye=class extends Y{_parse(e){return this._getType(e)===R.undefined?De(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ye.create=(t,e)=>new Ye({innerType:t,typeName:z.ZodOptional,...W(e)});var Et=class extends Y{_parse(e){return this._getType(e)===R.null?De(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Et.create=(t,e)=>new Et({innerType:t,typeName:z.ZodNullable,...W(e)});var Sr=class extends Y{_parse(e){let{ctx:r}=this._processInputParams(e),n=r.data;return r.parsedType===R.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Sr.create=(t,e)=>new Sr({innerType:t,typeName:z.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...W(e)});var zr=class extends Y{_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 Yr(o)?o.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ge(n.common.issues)},input:n.data})})):{status:"valid",value:o.status==="valid"?o.value:this._def.catchValue({get error(){return new Ge(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};zr.create=(t,e)=>new zr({innerType:t,typeName:z.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...W(e)});var nn=class extends Y{_parse(e){if(this._getType(e)!==R.nan){let n=this._getOrReturnCtx(e);return T(n,{code:S.invalid_type,expected:R.nan,received:n.parsedType}),L}return{status:"valid",value:e.data}}};nn.create=t=>new nn({typeName:z.ZodNaN,...W(t)});var ov=Symbol("zod_brand"),Mn=class extends Y{_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}},Zn=class t extends Y{_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"?L:s.status==="dirty"?(r.dirty(),pr(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"?L: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:z.ZodPipeline})}},Pr=class extends Y{_parse(e){let r=this._def.innerType._parse(e),n=o=>(Bt(o)&&(o.value=Object.freeze(o.value)),o);return Yr(r)?r.then(o=>n(o)):n(r)}unwrap(){return this._def.innerType}};Pr.create=(t,e)=>new Pr({innerType:t,typeName:z.ZodReadonly,...W(e)});function jd(t,e){let r=typeof t=="function"?t(e):typeof t=="string"?{message:t}:t;return typeof r=="string"?{message:r}:r}function qd(t,e={},r){return t?Kt.create().superRefine((n,o)=>{let s=t(n);if(s instanceof Promise)return s.then(i=>{if(!i){let a=jd(e,n),c=a.fatal??r??!0;o.addIssue({code:"custom",...a,fatal:c})}});if(!s){let i=jd(e,n),a=i.fatal??r??!0;o.addIssue({code:"custom",...i,fatal:a})}}):Kt.create()}var sv={object:Xe.lazycreate},z;(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"})(z||(z={}));var iv=(t,e={message:`Input not instance of ${t.name}`})=>qd(r=>r instanceof t,e),Ud=Jt.create,Fd=fr.create,av=nn.create,cv=mr.create,Vd=hr.create,uv=gr.create,lv=Qr.create,dv=yr.create,pv=_r.create,fv=Kt.create,mv=Dt.create,hv=yt.create,gv=en.create,yv=Lt.create,Gi=Xe.create,_v=Xe.strictCreate,vv=vr.create,bv=Wo.create,xv=br.create,wv=Tt.create,$v=Go.create,kv=tn.create,Sv=rn.create,zv=Yo.create,Pv=xr.create,Tv=wr.create,Ev=$r.create,Iv=kr.create,Rv=Wt.create,Nv=lt.create,Ov=Ye.create,Cv=Et.create,Av=lt.createWithPreprocess,jv=Zn.create,Mv=()=>Ud().optional(),Zv=()=>Fd().optional(),Dv=()=>Vd().optional(),Lv={string:(t=>Jt.create({...t,coerce:!0})),number:(t=>fr.create({...t,coerce:!0})),boolean:(t=>hr.create({...t,coerce:!0})),bigint:(t=>mr.create({...t,coerce:!0})),date:(t=>gr.create({...t,coerce:!0}))};var qv=L;var Uv=Object.freeze({status:"aborted"});function b(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 qt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Xo={};function it(t){return t&&Object.assign(Xo,t),Xo}var ne={};Bi(ne,{BIGINT_FORMAT_RANGES:()=>Bd,Class:()=>Xi,NUMBER_FORMAT_RANGES:()=>sa,aborted:()=>Er,allowsEval:()=>ra,assert:()=>Jv,assertEqual:()=>Fv,assertIs:()=>Hv,assertNever:()=>Bv,assertNotEqual:()=>Vv,assignProp:()=>ta,cached:()=>qn,captureStackTrace:()=>es,cleanEnum:()=>ib,cleanRegex:()=>Fn,clone:()=>at,createTransparentProxy:()=>Qv,defineLazy:()=>ye,esc:()=>Tr,escapeRegex:()=>Gt,extend:()=>rb,finalizeIssue:()=>_t,floatSafeRemainder:()=>ea,getElementAtPath:()=>Kv,getEnumValues:()=>Ln,getLengthableOrigin:()=>Vn,getParsedType:()=>Xv,getSizableOrigin:()=>Jd,isObject:()=>on,isPlainObject:()=>sn,issue:()=>ia,joinValues:()=>Qo,jsonStringifyReplacer:()=>Qi,merge:()=>nb,normalizeParams:()=>U,nullish:()=>Un,numKeys:()=>Yv,omit:()=>tb,optionalKeys:()=>oa,partial:()=>ob,pick:()=>eb,prefixIssues:()=>It,primitiveTypes:()=>Hd,promiseAllObject:()=>Wv,propertyKeyTypes:()=>na,randomString:()=>Gv,required:()=>sb,stringifyPrimitive:()=>ts,unwrapMessage:()=>Dn});function Fv(t){return t}function Vv(t){return t}function Hv(t){}function Bv(t){throw new Error}function Jv(t){}function Ln(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 Qo(t,e="|"){return t.map(r=>ts(r)).join(e)}function Qi(t,e){return typeof e=="bigint"?e.toString():e}function qn(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Un(t){return t==null}function Fn(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function ea(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 ye(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 ta(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Kv(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function Wv(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 Gv(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Tr(t){return JSON.stringify(t)}var es=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function on(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var ra=qn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function sn(t){if(on(t)===!1)return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(on(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Yv(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var Xv=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}`)}},na=new Set(["string","number","symbol"]),Hd=new Set(["string","number","bigint","boolean","symbol","undefined"]);function Gt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function at(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function U(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 Qv(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 ts(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function oa(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var sa={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]},Bd={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function eb(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 at(t,{...t._zod.def,shape:r,checks:[]})}function tb(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 at(t,{...t._zod.def,shape:r,checks:[]})}function rb(t,e){if(!sn(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 ta(this,"shape",n),n},checks:[]};return at(t,r)}function nb(t,e){return at(t,{...t._zod.def,get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return ta(this,"shape",r),r},catchall:e._zod.def.catchall,checks:[]})}function ob(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 at(e,{...e._zod.def,shape:o,checks:[]})}function sb(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 at(e,{...e._zod.def,shape:o,checks:[]})}function Er(t,e=0){for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function It(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Dn(t){return typeof t=="string"?t:t?.message}function _t(t,e,r){let n={...t,path:t.path??[]};if(!t.message){let o=Dn(t.inst?._zod.def?.error?.(t))??Dn(e?.error?.(t))??Dn(r.customError?.(t))??Dn(r.localeError?.(t))??"Invalid input";n.message=o}return delete n.inst,delete n.continue,e?.reportInput||delete n.input,n}function Jd(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Vn(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function ia(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function ib(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}var Xi=class{constructor(...e){}};var Kd=(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,Qi,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},rs=b("$ZodError",Kd),Hn=b("$ZodError",Kd,{Parent:Error});function aa(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 ca(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 ua=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 qt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>_t(c,s,it())));throw es(a,o?.callee),a}return i.value},la=ua(Hn),da=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=>_t(c,s,it())));throw es(a,o?.callee),a}return i.value},pa=da(Hn),fa=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 qt;return s.issues.length?{success:!1,error:new(t??rs)(s.issues.map(i=>_t(i,o,it())))}:{success:!0,data:s.value}},Ir=fa(Hn),ma=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=>_t(i,o,it())))}:{success:!0,data:s.value}},Rr=ma(Hn);var Wd=/^[cC][^\s-]{8,}$/,Gd=/^[0-9a-z]+$/,Yd=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Xd=/^[0-9a-vA-V]{20}$/,Qd=/^[A-Za-z0-9]{27}$/,ep=/^[a-zA-Z0-9_-]{21}$/,tp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var rp=/^([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})$/,ha=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 np=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var cb="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function op(){return new RegExp(cb,"u")}var 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=/^(([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})$/,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])\/([0-9]|[1-2][0-9]|3[0-2])$/,cp=/^(([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])$/,up=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ga=/^[A-Za-z0-9_-]*$/,lp=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/;var dp=/^\+(?:[0-9]){6,14}[0-9]$/,pp="(?:(?:\\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])))",fp=new RegExp(`^${pp}$`);function mp(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 hp(t){return new RegExp(`^${mp(t)}$`)}function gp(t){let e=mp({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(`^${pp}T(?:${n})$`)}var yp=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var _p=/^\d+$/,vp=/^-?\d+(?:\.\d+)?/i,bp=/true|false/i,xp=/null/i;var wp=/^[^A-Z]*$/,$p=/^[^a-z]*$/;var Ce=b("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),kp={number:"number",bigint:"bigint",object:"date"},ya=b("$ZodCheckLessThan",(t,e)=>{Ce.init(t,e);let r=kp[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})}}),_a=b("$ZodCheckGreaterThan",(t,e)=>{Ce.init(t,e);let r=kp[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})}}),Sp=b("$ZodCheckMultipleOf",(t,e)=>{Ce.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):ea(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})}}),zp=b("$ZodCheckNumberFormat",(t,e)=>{Ce.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=sa[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=_p)}),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 Pp=b("$ZodCheckMaxLength",(t,e)=>{var r;Ce.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Un(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=Vn(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),Tp=b("$ZodCheckMinLength",(t,e)=>{var r;Ce.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Un(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=Vn(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),Ep=b("$ZodCheckLengthEquals",(t,e)=>{var r;Ce.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Un(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=Vn(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})}}),Bn=b("$ZodCheckStringFormat",(t,e)=>{var r,n;Ce.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=()=>{})}),Ip=b("$ZodCheckRegex",(t,e)=>{Bn.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),Rp=b("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=wp),Bn.init(t,e)}),Np=b("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=$p),Bn.init(t,e)}),Op=b("$ZodCheckIncludes",(t,e)=>{Ce.init(t,e);let r=Gt(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})}}),Cp=b("$ZodCheckStartsWith",(t,e)=>{Ce.init(t,e);let r=new RegExp(`^${Gt(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})}}),Ap=b("$ZodCheckEndsWith",(t,e)=>{Ce.init(t,e);let r=new RegExp(`.*${Gt(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 jp=b("$ZodCheckOverwrite",(t,e)=>{Ce.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var os=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
|
-
`))}};var
|
|
11
|
+
`))}};var Zp={major:4,minor:0,patch:0};var me=b("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Zp;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=Er(s),u;for(let l of i){if(l._zod.def.when){if(!l._zod.def.when(s))continue}else if(c)continue;let d=s.issues.length,f=l._zod.check(s);if(f instanceof Promise&&a?.async===!1)throw new qt;if(u||f instanceof Promise)u=(u??Promise.resolve()).then(async()=>{await f,s.issues.length!==d&&(c||(c=Er(s,d)))});else{if(s.issues.length===d)continue;c||(c=Er(s,d))}}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 qt;return a.then(c=>o(c,n,i))}return o(a,n,i)}}t["~standard"]={validate:o=>{try{let s=Ir(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return Rr(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}}),Jn=b("$ZodString",(t,e)=>{me.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??yp(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),_e=b("$ZodStringFormat",(t,e)=>{Bn.init(t,e),Jn.init(t,e)}),ba=b("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=rp),_e.init(t,e)}),xa=b("$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=ha(n))}else e.pattern??(e.pattern=ha());_e.init(t,e)}),wa=b("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=np),_e.init(t,e)}),$a=b("$ZodURL",(t,e)=>{_e.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:lp.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})}}}),ka=b("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=op()),_e.init(t,e)}),Sa=b("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=ep),_e.init(t,e)}),za=b("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Wd),_e.init(t,e)}),Pa=b("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Gd),_e.init(t,e)}),Ta=b("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Yd),_e.init(t,e)}),Ea=b("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Xd),_e.init(t,e)}),Ia=b("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Qd),_e.init(t,e)}),Kp=b("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=gp(e)),_e.init(t,e)}),Wp=b("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=fp),_e.init(t,e)}),Gp=b("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=hp(e)),_e.init(t,e)}),Yp=b("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=tp),_e.init(t,e)}),Ra=b("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=sp),_e.init(t,e),t._zod.onattach.push(r=>{let n=r._zod.bag;n.format="ipv4"})}),Na=b("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=ip),_e.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})}}}),Oa=b("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=ap),_e.init(t,e)}),Ca=b("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=cp),_e.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 Xp(t){if(t==="")return!0;if(t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var Aa=b("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=up),_e.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64"}),t._zod.check=r=>{Xp(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function ub(t){if(!ga.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return Xp(r)}var ja=b("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=ga),_e.init(t,e),t._zod.onattach.push(r=>{r._zod.bag.contentEncoding="base64url"}),t._zod.check=r=>{ub(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Ma=b("$ZodE164",(t,e)=>{e.pattern??(e.pattern=dp),_e.init(t,e)});function lb(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 Za=b("$ZodJWT",(t,e)=>{_e.init(t,e),t._zod.check=r=>{lb(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var is=b("$ZodNumber",(t,e)=>{me.init(t,e),t._zod.pattern=t._zod.bag.pattern??vp,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}}),Da=b("$ZodNumber",(t,e)=>{zp.init(t,e),is.init(t,e)}),La=b("$ZodBoolean",(t,e)=>{me.init(t,e),t._zod.pattern=bp,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 qa=b("$ZodNull",(t,e)=>{me.init(t,e),t._zod.pattern=xp,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 Ua=b("$ZodUnknown",(t,e)=>{me.init(t,e),t._zod.parse=r=>r}),Fa=b("$ZodNever",(t,e)=>{me.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Dp(t,e,r){t.issues.length&&e.issues.push(...It(r,t.issues)),e.value[r]=t.value}var Va=b("$ZodArray",(t,e)=>{me.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=>Dp(u,r,i))):Dp(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function ss(t,e,r){t.issues.length&&e.issues.push(...It(r,t.issues)),e.value[r]=t.value}function Lp(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(...It(r,t.issues)):t.value===void 0?r in n&&(e.value[r]=void 0):e.value[r]=t.value}var as=b("$ZodObject",(t,e)=>{me.init(t,e);let r=qn(()=>{let d=Object.keys(e.shape);for(let m of d)if(!(e.shape[m]instanceof me))throw new Error(`Invalid element at key "${m}": expected a Zod schema`);let f=oa(e.shape);return{shape:e.shape,keys:d,keySet:new Set(d),numKeys:d.length,optionalKeys:new Set(f)}});ye(t._zod,"propValues",()=>{let d=e.shape,f={};for(let m in d){let p=d[m]._zod;if(p.values){f[m]??(f[m]=new Set);for(let h of p.values)f[m].add(h)}}return f});let n=d=>{let f=new os(["shape","payload","ctx"]),m=r.value,p=_=>{let w=Tr(_);return`shape[${w}]._zod.run({ value: input[${w}], issues: [] }, ctx)`};f.write("const input = payload.value;");let h=Object.create(null),g=0;for(let _ of m.keys)h[_]=`key_${g++}`;f.write("const newResult = {}");for(let _ of m.keys)if(m.optionalKeys.has(_)){let w=h[_];f.write(`const ${w} = ${p(_)};`);let x=Tr(_);f.write(`
|
|
12
12
|
if (${w}.issues.length) {
|
|
13
13
|
if (input[${x}] === undefined) {
|
|
14
14
|
if (${x} in input) {
|
|
@@ -27,32 +27,37 @@ var P_=Object.create;var Hi=Object.defineProperty;var T_=Object.getOwnPropertyDe
|
|
|
27
27
|
} else {
|
|
28
28
|
newResult[${x}] = ${w}.value;
|
|
29
29
|
}
|
|
30
|
-
`)}else{let w=h[_];
|
|
30
|
+
`)}else{let w=h[_];f.write(`const ${w} = ${p(_)};`),f.write(`
|
|
31
31
|
if (${w}.issues.length) payload.issues = payload.issues.concat(${w}.issues.map(iss => ({
|
|
32
32
|
...iss,
|
|
33
33
|
path: iss.path ? [${Tr(_)}, ...iss.path] : [${Tr(_)}]
|
|
34
|
-
})));`),p.write(`newResult[${Tr(_)}] = ${w}.value`)}p.write("payload.value = newResult;"),p.write("return payload;");let y=p.compile();return(_,w)=>y(d,_,w)},o,s=on,i=!Xo.jitless,c=i&&ra.value,u=e.catchall,l;t._zod.parse=(d,p)=>{l??(l=r.value);let m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),d;let f=[];if(i&&c&&p?.async===!1&&p.jitless!==!0)o||(o=n(e.shape)),d=o(d,p);else{d.value={};let w=l.shape;for(let x of l.keys){let $=w[x],P=$._zod.run({value:m[x],issues:[]},p),J=$._zod.optin==="optional"&&$._zod.optout==="optional";P instanceof Promise?f.push(P.then(H=>J?qf(H,d,x,m):ss(H,d,x))):J?qf(P,d,x,m):ss(P,d,x)}}if(!u)return f.length?Promise.all(f).then(()=>d):d;let h=[],g=l.keySet,y=u._zod,_=y.def.type;for(let w of Object.keys(m)){if(g.has(w))continue;if(_==="never"){h.push(w);continue}let x=y.run({value:m[w],issues:[]},p);x instanceof Promise?f.push(x.then($=>ss($,d,w))):ss(x,d,w)}return h.length&&d.issues.push({code:"unrecognized_keys",keys:h,input:m,inst:t}),f.length?Promise.all(f).then(()=>d):d}});function Uf(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=>_t(s,n,it())))}),e}var cs=b("$ZodUnion",(t,e)=>{me.init(t,e),ye(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ye(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ye(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),ye(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=>Fn(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=>Uf(i,r,t,n)):Uf(s,r,t,n)}}),Ha=b("$ZodDiscriminatedUnion",(t,e)=>{cs.init(t,e);let r=t._zod.parse;ye(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=qn(()=>{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(!on(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)}}),Ba=b("$ZodIntersection",(t,e)=>{me.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])=>Ff(r,c,u)):Ff(r,s,i)}});function va(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(sn(t)&&sn(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=va(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=va(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 Ff(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Er(t))return t;let n=va(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 Ja=b("$ZodRecord",(t,e)=>{me.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!sn(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(...It(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...It(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=>_t(u,n,it())),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(...It(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...It(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var Ka=b("$ZodEnum",(t,e)=>{me.init(t,e);let r=Ln(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>na.has(typeof n)).map(n=>typeof n=="string"?Gt(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}}),Wa=b("$ZodLiteral",(t,e)=>{me.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Gt(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 Ga=b("$ZodTransform",(t,e)=>{me.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 qt;return r.value=o,r}}),Ya=b("$ZodOptional",(t,e)=>{me.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ye(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ye(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Fn(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)}),Xa=b("$ZodNullable",(t,e)=>{me.init(t,e),ye(t._zod,"optin",()=>e.innerType._zod.optin),ye(t._zod,"optout",()=>e.innerType._zod.optout),ye(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Fn(r.source)}|null)$`):void 0}),ye(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)}),Qa=b("$ZodDefault",(t,e)=>{me.init(t,e),t._zod.optin="optional",ye(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=>Vf(s,e)):Vf(o,e)}});function Vf(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var ec=b("$ZodPrefault",(t,e)=>{me.init(t,e),t._zod.optin="optional",ye(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))}),tc=b("$ZodNonOptional",(t,e)=>{me.init(t,e),ye(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=>Hf(s,t)):Hf(o,t)}});function Hf(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 rc=b("$ZodCatch",(t,e)=>{me.init(t,e),t._zod.optin="optional",ye(t._zod,"optout",()=>e.innerType._zod.optout),ye(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=>_t(i,n,it()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>_t(s,n,it()))},input:r.value}),r.issues=[]),r)}});var nc=b("$ZodPipe",(t,e)=>{me.init(t,e),ye(t._zod,"values",()=>e.in._zod.values),ye(t._zod,"optin",()=>e.in._zod.optin),ye(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 Er(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var oc=b("$ZodReadonly",(t,e)=>{me.init(t,e),ye(t._zod,"propValues",()=>e.innerType._zod.propValues),ye(t._zod,"values",()=>e.innerType._zod.values),ye(t._zod,"optin",()=>e.innerType._zod.optin),ye(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(Jf):Jf(o)}});function Jf(t){return t.value=Object.freeze(t.value),t}var sc=b("$ZodCustom",(t,e)=>{Ce.init(t,e),me.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=>Kf(s,r,n,t));Kf(o,r,n,t)}});function Kf(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(ia(o))}}var db=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},fb=()=>{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 ${db(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${ts(n.values[0])}`:`Invalid option: expected one of ${Qo(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":""}: ${Qo(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 ep(){return{localeError:fb()}}var Kn=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 tp(){return new Kn}var Yt=tp();function ic(t,e){return new t({type:"string",...U(e)})}function ac(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...U(e)})}function us(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...U(e)})}function cc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...U(e)})}function uc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...U(e)})}function lc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...U(e)})}function dc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...U(e)})}function fc(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...U(e)})}function pc(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...U(e)})}function mc(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...U(e)})}function hc(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...U(e)})}function gc(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...U(e)})}function yc(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...U(e)})}function _c(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...U(e)})}function vc(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...U(e)})}function bc(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...U(e)})}function xc(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...U(e)})}function wc(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...U(e)})}function $c(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...U(e)})}function kc(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...U(e)})}function Sc(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...U(e)})}function zc(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...U(e)})}function Pc(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...U(e)})}function rp(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...U(e)})}function np(t,e){return new t({type:"string",format:"date",check:"string_format",...U(e)})}function op(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...U(e)})}function sp(t,e){return new t({type:"string",format:"duration",check:"string_format",...U(e)})}function Tc(t,e){return new t({type:"number",checks:[],...U(e)})}function Ec(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...U(e)})}function Ic(t,e){return new t({type:"boolean",...U(e)})}function Rc(t,e){return new t({type:"null",...U(e)})}function Nc(t){return new t({type:"unknown"})}function Oc(t,e){return new t({type:"never",...U(e)})}function ls(t,e){return new ya({check:"less_than",...U(e),value:t,inclusive:!1})}function Wn(t,e){return new ya({check:"less_than",...U(e),value:t,inclusive:!0})}function ds(t,e){return new _a({check:"greater_than",...U(e),value:t,inclusive:!1})}function Gn(t,e){return new _a({check:"greater_than",...U(e),value:t,inclusive:!0})}function fs(t,e){return new zf({check:"multiple_of",...U(e),value:t})}function ps(t,e){return new Tf({check:"max_length",...U(e),maximum:t})}function an(t,e){return new Ef({check:"min_length",...U(e),minimum:t})}function ms(t,e){return new If({check:"length_equals",...U(e),length:t})}function Cc(t,e){return new Rf({check:"string_format",format:"regex",...U(e),pattern:t})}function jc(t){return new Nf({check:"string_format",format:"lowercase",...U(t)})}function Ac(t){return new Of({check:"string_format",format:"uppercase",...U(t)})}function Mc(t,e){return new Cf({check:"string_format",format:"includes",...U(e),includes:t})}function Zc(t,e){return new jf({check:"string_format",format:"starts_with",...U(e),prefix:t})}function Dc(t,e){return new Af({check:"string_format",format:"ends_with",...U(e),suffix:t})}function Nr(t){return new Mf({check:"overwrite",tx:t})}function Lc(t){return Nr(e=>e.normalize(t))}function qc(){return Nr(t=>t.trim())}function Uc(){return Nr(t=>t.toLowerCase())}function Fc(){return Nr(t=>t.toUpperCase())}function ip(t,e,r){return new t({type:"array",element:e,...U(r)})}function Vc(t,e,r){let n=U(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Hc(t,e,r){return new t({type:"custom",check:"custom",fn:e,...U(r)})}var hs=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Yt,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 d={...r,schemaPath:[...r.schemaPath,e],path:r.path},p=e._zod.parent;if(p)a.ref=p,this.process(p,d),this.seen.get(p).isParent=!0;else{let m=a.schema;switch(o.type){case"string":{let f=m;f.type="string";let{minimum:h,maximum:g,format:y,patterns:_,contentEncoding:w}=e._zod.bag;if(typeof h=="number"&&(f.minLength=h),typeof g=="number"&&(f.maxLength=g),y&&(f.format=s[y]??y,f.format===""&&delete f.format),w&&(f.contentEncoding=w),_&&_.size>0){let x=[..._];x.length===1?f.pattern=x[0].source:x.length>1&&(a.schema.allOf=[...x.map($=>({...this.target==="draft-7"?{type:"string"}:{},pattern:$.source}))])}break}case"number":{let f=m,{minimum:h,maximum:g,format:y,multipleOf:_,exclusiveMaximum:w,exclusiveMinimum:x}=e._zod.bag;typeof y=="string"&&y.includes("int")?f.type="integer":f.type="number",typeof x=="number"&&(f.exclusiveMinimum=x),typeof h=="number"&&(f.minimum=h,typeof x=="number"&&(x>=h?delete f.minimum:delete f.exclusiveMinimum)),typeof w=="number"&&(f.exclusiveMaximum=w),typeof g=="number"&&(f.maximum=g,typeof w=="number"&&(w<=g?delete f.maximum:delete f.exclusiveMaximum)),typeof _=="number"&&(f.multipleOf=_);break}case"boolean":{let f=m;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":{m.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":{m.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let f=m,{minimum:h,maximum:g}=e._zod.bag;typeof h=="number"&&(f.minItems=h),typeof g=="number"&&(f.maxItems=g),f.type="array",f.items=this.process(o.element,{...d,path:[...d.path,"items"]});break}case"object":{let f=m;f.type="object",f.properties={};let h=o.shape;for(let _ in h)f.properties[_]=this.process(h[_],{...d,path:[...d.path,"properties",_]});let g=new Set(Object.keys(h)),y=new Set([...g].filter(_=>{let w=o.shape[_]._zod;return this.io==="input"?w.optin===void 0:w.optout===void 0}));y.size>0&&(f.required=Array.from(y)),o.catchall?._zod.def.type==="never"?f.additionalProperties=!1:o.catchall?o.catchall&&(f.additionalProperties=this.process(o.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(f.additionalProperties=!1);break}case"union":{let f=m;f.anyOf=o.options.map((h,g)=>this.process(h,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let f=m,h=this.process(o.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(o.right,{...d,path:[...d.path,"allOf",1]}),y=w=>"allOf"in w&&Object.keys(w).length===1,_=[...y(h)?h.allOf:[h],...y(g)?g.allOf:[g]];f.allOf=_;break}case"tuple":{let f=m;f.type="array";let h=o.items.map((_,w)=>this.process(_,{...d,path:[...d.path,"prefixItems",w]}));if(this.target==="draft-2020-12"?f.prefixItems=h:f.items=h,o.rest){let _=this.process(o.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?f.items=_:f.additionalItems=_}o.rest&&(f.items=this.process(o.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:y}=e._zod.bag;typeof g=="number"&&(f.minItems=g),typeof y=="number"&&(f.maxItems=y);break}case"record":{let f=m;f.type="object",f.propertyNames=this.process(o.keyType,{...d,path:[...d.path,"propertyNames"]}),f.additionalProperties=this.process(o.valueType,{...d,path:[...d.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let f=m,h=Ln(o.entries);h.every(g=>typeof g=="number")&&(f.type="number"),h.every(g=>typeof g=="string")&&(f.type="string"),f.enum=h;break}case"literal":{let f=m,h=[];for(let g of o.values)if(g===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof g=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");h.push(Number(g))}else h.push(g);if(h.length!==0)if(h.length===1){let g=h[0];f.type=g===null?"null":typeof g,f.const=g}else h.every(g=>typeof g=="number")&&(f.type="number"),h.every(g=>typeof g=="string")&&(f.type="string"),h.every(g=>typeof g=="boolean")&&(f.type="string"),h.every(g=>g===null)&&(f.type="null"),f.enum=h;break}case"file":{let f=m,h={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:y,mime:_}=e._zod.bag;g!==void 0&&(h.minLength=g),y!==void 0&&(h.maxLength=y),_?_.length===1?(h.contentMediaType=_[0],Object.assign(f,h)):f.anyOf=_.map(w=>({...h,contentMediaType:w})):Object.assign(f,h);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,d);m.anyOf=[f,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"success":{let f=m;f.type="boolean";break}case"default":{this.process(o.innerType,d),a.ref=o.innerType,m.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,d),a.ref=o.innerType,this.io==="input"&&(m._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,d),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")}m.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=m,h=e._zod.pattern;if(!h)throw new Error("Pattern not found in template literal");f.type="string",f.pattern=h.source;break}case"pipe":{let f=this.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(f,d),a.ref=f;break}case"readonly":{this.process(o.innerType,d),a.ref=o.innerType,m.readOnly=!0;break}case"promise":{this.process(o.innerType,d),a.ref=o.innerType;break}case"optional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"lazy":{let f=e._zod.innerType;this.process(f,d),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"&&Ie(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 d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let h=n.external.registry.get(l[0])?.id,g=n.external.uri??(_=>_);if(h)return{ref:g(h)};let y=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=y,{defId:y,ref:`${g("__shared")}#/${d}/${y}`}}if(l[1]===o)return{ref:"#"};let m=`#/${d}/`,f=l[1].schema.id??`__schema${this.counter++}`;return{defId:f,ref:m+f}},i=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:p,defId:m}=s(l);d.def={...d.schema},m&&(d.defId=m);let f=d.schema;for(let h in f)delete f[h];f.$ref=p};if(n.cycles==="throw")for(let l of this.seen.entries()){let d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.cycle?.join("/")}/<root>
|
|
34
|
+
})));`),f.write(`newResult[${Tr(_)}] = ${w}.value`)}f.write("payload.value = newResult;"),f.write("return payload;");let y=f.compile();return(_,w)=>y(d,_,w)},o,s=on,i=!Xo.jitless,c=i&&ra.value,u=e.catchall,l;t._zod.parse=(d,f)=>{l??(l=r.value);let m=d.value;if(!s(m))return d.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),d;let p=[];if(i&&c&&f?.async===!1&&f.jitless!==!0)o||(o=n(e.shape)),d=o(d,f);else{d.value={};let w=l.shape;for(let x of l.keys){let $=w[x],P=$._zod.run({value:m[x],issues:[]},f),J=$._zod.optin==="optional"&&$._zod.optout==="optional";P instanceof Promise?p.push(P.then(H=>J?Lp(H,d,x,m):ss(H,d,x))):J?Lp(P,d,x,m):ss(P,d,x)}}if(!u)return p.length?Promise.all(p).then(()=>d):d;let h=[],g=l.keySet,y=u._zod,_=y.def.type;for(let w of Object.keys(m)){if(g.has(w))continue;if(_==="never"){h.push(w);continue}let x=y.run({value:m[w],issues:[]},f);x instanceof Promise?p.push(x.then($=>ss($,d,w))):ss(x,d,w)}return h.length&&d.issues.push({code:"unrecognized_keys",keys:h,input:m,inst:t}),p.length?Promise.all(p).then(()=>d):d}});function qp(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=>_t(s,n,it())))}),e}var cs=b("$ZodUnion",(t,e)=>{me.init(t,e),ye(t._zod,"optin",()=>e.options.some(r=>r._zod.optin==="optional")?"optional":void 0),ye(t._zod,"optout",()=>e.options.some(r=>r._zod.optout==="optional")?"optional":void 0),ye(t._zod,"values",()=>{if(e.options.every(r=>r._zod.values))return new Set(e.options.flatMap(r=>Array.from(r._zod.values)))}),ye(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=>Fn(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=>qp(i,r,t,n)):qp(s,r,t,n)}}),Ha=b("$ZodDiscriminatedUnion",(t,e)=>{cs.init(t,e);let r=t._zod.parse;ye(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=qn(()=>{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(!on(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)}}),Ba=b("$ZodIntersection",(t,e)=>{me.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])=>Up(r,c,u)):Up(r,s,i)}});function va(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(sn(t)&&sn(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=va(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=va(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 Up(t,e,r){if(e.issues.length&&t.issues.push(...e.issues),r.issues.length&&t.issues.push(...r.issues),Er(t))return t;let n=va(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 Ja=b("$ZodRecord",(t,e)=>{me.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!sn(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(...It(c,l.issues)),r.value[c]=l.value})):(u.issues.length&&r.issues.push(...It(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=>_t(u,n,it())),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(...It(i,u.issues)),r.value[a.value]=u.value})):(c.issues.length&&r.issues.push(...It(i,c.issues)),r.value[a.value]=c.value)}}return s.length?Promise.all(s).then(()=>r):r}});var Ka=b("$ZodEnum",(t,e)=>{me.init(t,e);let r=Ln(e.entries);t._zod.values=new Set(r),t._zod.pattern=new RegExp(`^(${r.filter(n=>na.has(typeof n)).map(n=>typeof n=="string"?Gt(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}}),Wa=b("$ZodLiteral",(t,e)=>{me.init(t,e),t._zod.values=new Set(e.values),t._zod.pattern=new RegExp(`^(${e.values.map(r=>typeof r=="string"?Gt(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 Ga=b("$ZodTransform",(t,e)=>{me.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 qt;return r.value=o,r}}),Ya=b("$ZodOptional",(t,e)=>{me.init(t,e),t._zod.optin="optional",t._zod.optout="optional",ye(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),ye(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Fn(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)}),Xa=b("$ZodNullable",(t,e)=>{me.init(t,e),ye(t._zod,"optin",()=>e.innerType._zod.optin),ye(t._zod,"optout",()=>e.innerType._zod.optout),ye(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Fn(r.source)}|null)$`):void 0}),ye(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)}),Qa=b("$ZodDefault",(t,e)=>{me.init(t,e),t._zod.optin="optional",ye(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=>Fp(s,e)):Fp(o,e)}});function Fp(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var ec=b("$ZodPrefault",(t,e)=>{me.init(t,e),t._zod.optin="optional",ye(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))}),tc=b("$ZodNonOptional",(t,e)=>{me.init(t,e),ye(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=>Vp(s,t)):Vp(o,t)}});function Vp(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 rc=b("$ZodCatch",(t,e)=>{me.init(t,e),t._zod.optin="optional",ye(t._zod,"optout",()=>e.innerType._zod.optout),ye(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=>_t(i,n,it()))},input:r.value}),r.issues=[]),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>_t(s,n,it()))},input:r.value}),r.issues=[]),r)}});var nc=b("$ZodPipe",(t,e)=>{me.init(t,e),ye(t._zod,"values",()=>e.in._zod.values),ye(t._zod,"optin",()=>e.in._zod.optin),ye(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=>Hp(s,e,n)):Hp(o,e,n)}});function Hp(t,e,r){return Er(t)?t:e.out._zod.run({value:t.value,issues:t.issues},r)}var oc=b("$ZodReadonly",(t,e)=>{me.init(t,e),ye(t._zod,"propValues",()=>e.innerType._zod.propValues),ye(t._zod,"values",()=>e.innerType._zod.values),ye(t._zod,"optin",()=>e.innerType._zod.optin),ye(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(Bp):Bp(o)}});function Bp(t){return t.value=Object.freeze(t.value),t}var sc=b("$ZodCustom",(t,e)=>{Ce.init(t,e),me.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=>Jp(s,r,n,t));Jp(o,r,n,t)}});function Jp(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(ia(o))}}var db=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},pb=()=>{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 ${db(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${ts(n.values[0])}`:`Invalid option: expected one of ${Qo(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":""}: ${Qo(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 Qp(){return{localeError:pb()}}var Kn=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 ef(){return new Kn}var Yt=ef();function ic(t,e){return new t({type:"string",...U(e)})}function ac(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...U(e)})}function us(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...U(e)})}function cc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...U(e)})}function uc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...U(e)})}function lc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...U(e)})}function dc(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...U(e)})}function pc(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...U(e)})}function fc(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...U(e)})}function mc(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...U(e)})}function hc(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...U(e)})}function gc(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...U(e)})}function yc(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...U(e)})}function _c(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...U(e)})}function vc(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...U(e)})}function bc(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...U(e)})}function xc(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...U(e)})}function wc(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...U(e)})}function $c(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...U(e)})}function kc(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...U(e)})}function Sc(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...U(e)})}function zc(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...U(e)})}function Pc(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...U(e)})}function tf(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...U(e)})}function rf(t,e){return new t({type:"string",format:"date",check:"string_format",...U(e)})}function nf(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...U(e)})}function of(t,e){return new t({type:"string",format:"duration",check:"string_format",...U(e)})}function Tc(t,e){return new t({type:"number",checks:[],...U(e)})}function Ec(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...U(e)})}function Ic(t,e){return new t({type:"boolean",...U(e)})}function Rc(t,e){return new t({type:"null",...U(e)})}function Nc(t){return new t({type:"unknown"})}function Oc(t,e){return new t({type:"never",...U(e)})}function ls(t,e){return new ya({check:"less_than",...U(e),value:t,inclusive:!1})}function Wn(t,e){return new ya({check:"less_than",...U(e),value:t,inclusive:!0})}function ds(t,e){return new _a({check:"greater_than",...U(e),value:t,inclusive:!1})}function Gn(t,e){return new _a({check:"greater_than",...U(e),value:t,inclusive:!0})}function ps(t,e){return new Sp({check:"multiple_of",...U(e),value:t})}function fs(t,e){return new Pp({check:"max_length",...U(e),maximum:t})}function an(t,e){return new Tp({check:"min_length",...U(e),minimum:t})}function ms(t,e){return new Ep({check:"length_equals",...U(e),length:t})}function Cc(t,e){return new Ip({check:"string_format",format:"regex",...U(e),pattern:t})}function Ac(t){return new Rp({check:"string_format",format:"lowercase",...U(t)})}function jc(t){return new Np({check:"string_format",format:"uppercase",...U(t)})}function Mc(t,e){return new Op({check:"string_format",format:"includes",...U(e),includes:t})}function Zc(t,e){return new Cp({check:"string_format",format:"starts_with",...U(e),prefix:t})}function Dc(t,e){return new Ap({check:"string_format",format:"ends_with",...U(e),suffix:t})}function Nr(t){return new jp({check:"overwrite",tx:t})}function Lc(t){return Nr(e=>e.normalize(t))}function qc(){return Nr(t=>t.trim())}function Uc(){return Nr(t=>t.toLowerCase())}function Fc(){return Nr(t=>t.toUpperCase())}function sf(t,e,r){return new t({type:"array",element:e,...U(r)})}function Vc(t,e,r){let n=U(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Hc(t,e,r){return new t({type:"custom",check:"custom",fn:e,...U(r)})}var hs=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??Yt,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 d={...r,schemaPath:[...r.schemaPath,e],path:r.path},f=e._zod.parent;if(f)a.ref=f,this.process(f,d),this.seen.get(f).isParent=!0;else{let m=a.schema;switch(o.type){case"string":{let p=m;p.type="string";let{minimum:h,maximum:g,format:y,patterns:_,contentEncoding:w}=e._zod.bag;if(typeof h=="number"&&(p.minLength=h),typeof g=="number"&&(p.maxLength=g),y&&(p.format=s[y]??y,p.format===""&&delete p.format),w&&(p.contentEncoding=w),_&&_.size>0){let x=[..._];x.length===1?p.pattern=x[0].source:x.length>1&&(a.schema.allOf=[...x.map($=>({...this.target==="draft-7"?{type:"string"}:{},pattern:$.source}))])}break}case"number":{let p=m,{minimum:h,maximum:g,format:y,multipleOf:_,exclusiveMaximum:w,exclusiveMinimum:x}=e._zod.bag;typeof y=="string"&&y.includes("int")?p.type="integer":p.type="number",typeof x=="number"&&(p.exclusiveMinimum=x),typeof h=="number"&&(p.minimum=h,typeof x=="number"&&(x>=h?delete p.minimum:delete p.exclusiveMinimum)),typeof w=="number"&&(p.exclusiveMaximum=w),typeof g=="number"&&(p.maximum=g,typeof w=="number"&&(w<=g?delete p.maximum:delete p.exclusiveMaximum)),typeof _=="number"&&(p.multipleOf=_);break}case"boolean":{let p=m;p.type="boolean";break}case"bigint":{if(this.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema");break}case"symbol":{if(this.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema");break}case"null":{m.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":{m.not={};break}case"date":{if(this.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema");break}case"array":{let p=m,{minimum:h,maximum:g}=e._zod.bag;typeof h=="number"&&(p.minItems=h),typeof g=="number"&&(p.maxItems=g),p.type="array",p.items=this.process(o.element,{...d,path:[...d.path,"items"]});break}case"object":{let p=m;p.type="object",p.properties={};let h=o.shape;for(let _ in h)p.properties[_]=this.process(h[_],{...d,path:[...d.path,"properties",_]});let g=new Set(Object.keys(h)),y=new Set([...g].filter(_=>{let w=o.shape[_]._zod;return this.io==="input"?w.optin===void 0:w.optout===void 0}));y.size>0&&(p.required=Array.from(y)),o.catchall?._zod.def.type==="never"?p.additionalProperties=!1:o.catchall?o.catchall&&(p.additionalProperties=this.process(o.catchall,{...d,path:[...d.path,"additionalProperties"]})):this.io==="output"&&(p.additionalProperties=!1);break}case"union":{let p=m;p.anyOf=o.options.map((h,g)=>this.process(h,{...d,path:[...d.path,"anyOf",g]}));break}case"intersection":{let p=m,h=this.process(o.left,{...d,path:[...d.path,"allOf",0]}),g=this.process(o.right,{...d,path:[...d.path,"allOf",1]}),y=w=>"allOf"in w&&Object.keys(w).length===1,_=[...y(h)?h.allOf:[h],...y(g)?g.allOf:[g]];p.allOf=_;break}case"tuple":{let p=m;p.type="array";let h=o.items.map((_,w)=>this.process(_,{...d,path:[...d.path,"prefixItems",w]}));if(this.target==="draft-2020-12"?p.prefixItems=h:p.items=h,o.rest){let _=this.process(o.rest,{...d,path:[...d.path,"items"]});this.target==="draft-2020-12"?p.items=_:p.additionalItems=_}o.rest&&(p.items=this.process(o.rest,{...d,path:[...d.path,"items"]}));let{minimum:g,maximum:y}=e._zod.bag;typeof g=="number"&&(p.minItems=g),typeof y=="number"&&(p.maxItems=y);break}case"record":{let p=m;p.type="object",p.propertyNames=this.process(o.keyType,{...d,path:[...d.path,"propertyNames"]}),p.additionalProperties=this.process(o.valueType,{...d,path:[...d.path,"additionalProperties"]});break}case"map":{if(this.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema");break}case"set":{if(this.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema");break}case"enum":{let p=m,h=Ln(o.entries);h.every(g=>typeof g=="number")&&(p.type="number"),h.every(g=>typeof g=="string")&&(p.type="string"),p.enum=h;break}case"literal":{let p=m,h=[];for(let g of o.values)if(g===void 0){if(this.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof g=="bigint"){if(this.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");h.push(Number(g))}else h.push(g);if(h.length!==0)if(h.length===1){let g=h[0];p.type=g===null?"null":typeof g,p.const=g}else h.every(g=>typeof g=="number")&&(p.type="number"),h.every(g=>typeof g=="string")&&(p.type="string"),h.every(g=>typeof g=="boolean")&&(p.type="string"),h.every(g=>g===null)&&(p.type="null"),p.enum=h;break}case"file":{let p=m,h={type:"string",format:"binary",contentEncoding:"binary"},{minimum:g,maximum:y,mime:_}=e._zod.bag;g!==void 0&&(h.minLength=g),y!==void 0&&(h.maxLength=y),_?_.length===1?(h.contentMediaType=_[0],Object.assign(p,h)):p.anyOf=_.map(w=>({...h,contentMediaType:w})):Object.assign(p,h);break}case"transform":{if(this.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema");break}case"nullable":{let p=this.process(o.innerType,d);m.anyOf=[p,{type:"null"}];break}case"nonoptional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"success":{let p=m;p.type="boolean";break}case"default":{this.process(o.innerType,d),a.ref=o.innerType,m.default=JSON.parse(JSON.stringify(o.defaultValue));break}case"prefault":{this.process(o.innerType,d),a.ref=o.innerType,this.io==="input"&&(m._prefault=JSON.parse(JSON.stringify(o.defaultValue)));break}case"catch":{this.process(o.innerType,d),a.ref=o.innerType;let p;try{p=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}m.default=p;break}case"nan":{if(this.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema");break}case"template_literal":{let p=m,h=e._zod.pattern;if(!h)throw new Error("Pattern not found in template literal");p.type="string",p.pattern=h.source;break}case"pipe":{let p=this.io==="input"?o.in._zod.def.type==="transform"?o.out:o.in:o.out;this.process(p,d),a.ref=p;break}case"readonly":{this.process(o.innerType,d),a.ref=o.innerType,m.readOnly=!0;break}case"promise":{this.process(o.innerType,d),a.ref=o.innerType;break}case"optional":{this.process(o.innerType,d),a.ref=o.innerType;break}case"lazy":{let p=e._zod.innerType;this.process(p,d),a.ref=p;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"&&Ie(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 d=this.target==="draft-2020-12"?"$defs":"definitions";if(n.external){let h=n.external.registry.get(l[0])?.id,g=n.external.uri??(_=>_);if(h)return{ref:g(h)};let y=l[1].defId??l[1].schema.id??`schema${this.counter++}`;return l[1].defId=y,{defId:y,ref:`${g("__shared")}#/${d}/${y}`}}if(l[1]===o)return{ref:"#"};let m=`#/${d}/`,p=l[1].schema.id??`__schema${this.counter++}`;return{defId:p,ref:m+p}},i=l=>{if(l[1].schema.$ref)return;let d=l[1],{ref:f,defId:m}=s(l);d.def={...d.schema},m&&(d.defId=m);let p=d.schema;for(let h in p)delete p[h];p.$ref=f};if(n.cycles==="throw")for(let l of this.seen.entries()){let d=l[1];if(d.cycle)throw new Error(`Cycle detected: #/${d.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 d=l[1];if(e===l[0]){i(l);continue}if(n.external){let m=n.external.registry.get(l[0])?.id;if(e!==l[0]&&m){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(d.cycle){i(l);continue}if(d.count>1&&n.reused==="ref"){i(l);continue}}let a=(l,d)=>{let
|
|
37
|
-
`);if("message"in t&&typeof t.message=="string")return t.message;try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function cp(t){return t.description}function up(t){if(Rt(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function un(t){if(Rt(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}var Yn={};Bi(Yn,{ZodISODate:()=>dp,ZodISODateTime:()=>lp,ZodISODuration:()=>pp,ZodISOTime:()=>fp,date:()=>Wc,datetime:()=>Kc,duration:()=>Yc,time:()=>Gc});var lp=b("ZodISODateTime",(t,e)=>{Wf.init(t,e),$e.init(t,e)});function Kc(t){return rp(lp,t)}var dp=b("ZodISODate",(t,e)=>{Gf.init(t,e),$e.init(t,e)});function Wc(t){return np(dp,t)}var fp=b("ZodISOTime",(t,e)=>{Yf.init(t,e),$e.init(t,e)});function Gc(t){return op(fp,t)}var pp=b("ZodISODuration",(t,e)=>{Xf.init(t,e),$e.init(t,e)});function Yc(t){return sp(pp,t)}var mp=(t,e)=>{rs.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>ca(t,r)},flatten:{value:r=>aa(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},N1=b("ZodError",mp),Xn=b("ZodError",mp,{Parent:Error});var hp=ua(Xn),gp=da(Xn),yp=pa(Xn),_p=ma(Xn);var Pe=b("ZodType",(t,e)=>(me.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)=>at(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>hp(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>yp(t,r,n),t.parseAsync=async(r,n)=>gp(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>_p(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(Bx(r,n)),t.superRefine=r=>t.check(Jx(r)),t.overwrite=r=>t.check(Nr(r)),t.optional=()=>Se(t),t.nullable=()=>xp(t),t.nullish=()=>Se(xp(t)),t.nonoptional=r=>Dx(t,r),t.array=()=>se(t),t.or=r=>be([t,r]),t.and=r=>vs(t,r),t.transform=r=>Qc(t,Pp(r)),t.default=r=>Ax(t,r),t.prefault=r=>Zx(t,r),t.catch=r=>qx(t,r),t.pipe=r=>Qc(t,r),t.readonly=()=>Vx(t),t.describe=r=>{let n=t.clone();return Yt.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Yt.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Yt.get(t);let n=t.clone();return Yt.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),wp=b("_ZodString",(t,e)=>{Jn.init(t,e),Pe.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(Cc(...n)),t.includes=(...n)=>t.check(Mc(...n)),t.startsWith=(...n)=>t.check(Zc(...n)),t.endsWith=(...n)=>t.check(Dc(...n)),t.min=(...n)=>t.check(an(...n)),t.max=(...n)=>t.check(ps(...n)),t.length=(...n)=>t.check(ms(...n)),t.nonempty=(...n)=>t.check(an(1,...n)),t.lowercase=n=>t.check(jc(n)),t.uppercase=n=>t.check(Ac(n)),t.trim=()=>t.check(qc()),t.normalize=(...n)=>t.check(Lc(...n)),t.toLowerCase=()=>t.check(Uc()),t.toUpperCase=()=>t.check(Fc())}),ox=b("ZodString",(t,e)=>{Jn.init(t,e),wp.init(t,e),t.email=r=>t.check(ac(sx,r)),t.url=r=>t.check(fc(ix,r)),t.jwt=r=>t.check(Pc(xx,r)),t.emoji=r=>t.check(pc(ax,r)),t.guid=r=>t.check(us(vp,r)),t.uuid=r=>t.check(cc(_s,r)),t.uuidv4=r=>t.check(uc(_s,r)),t.uuidv6=r=>t.check(lc(_s,r)),t.uuidv7=r=>t.check(dc(_s,r)),t.nanoid=r=>t.check(mc(cx,r)),t.guid=r=>t.check(us(vp,r)),t.cuid=r=>t.check(hc(ux,r)),t.cuid2=r=>t.check(gc(lx,r)),t.ulid=r=>t.check(yc(dx,r)),t.base64=r=>t.check(kc(_x,r)),t.base64url=r=>t.check(Sc(vx,r)),t.xid=r=>t.check(_c(fx,r)),t.ksuid=r=>t.check(vc(px,r)),t.ipv4=r=>t.check(bc(mx,r)),t.ipv6=r=>t.check(xc(hx,r)),t.cidrv4=r=>t.check(wc(gx,r)),t.cidrv6=r=>t.check($c(yx,r)),t.e164=r=>t.check(zc(bx,r)),t.datetime=r=>t.check(Kc(r)),t.date=r=>t.check(Wc(r)),t.time=r=>t.check(Gc(r)),t.duration=r=>t.check(Yc(r))});function v(t){return ic(ox,t)}var $e=b("ZodStringFormat",(t,e)=>{_e.init(t,e),wp.init(t,e)}),sx=b("ZodEmail",(t,e)=>{wa.init(t,e),$e.init(t,e)});var vp=b("ZodGUID",(t,e)=>{ba.init(t,e),$e.init(t,e)});var _s=b("ZodUUID",(t,e)=>{xa.init(t,e),$e.init(t,e)});var ix=b("ZodURL",(t,e)=>{$a.init(t,e),$e.init(t,e)});var ax=b("ZodEmoji",(t,e)=>{ka.init(t,e),$e.init(t,e)});var cx=b("ZodNanoID",(t,e)=>{Sa.init(t,e),$e.init(t,e)});var ux=b("ZodCUID",(t,e)=>{za.init(t,e),$e.init(t,e)});var lx=b("ZodCUID2",(t,e)=>{Pa.init(t,e),$e.init(t,e)});var dx=b("ZodULID",(t,e)=>{Ta.init(t,e),$e.init(t,e)});var fx=b("ZodXID",(t,e)=>{Ea.init(t,e),$e.init(t,e)});var px=b("ZodKSUID",(t,e)=>{Ia.init(t,e),$e.init(t,e)});var mx=b("ZodIPv4",(t,e)=>{Ra.init(t,e),$e.init(t,e)});var hx=b("ZodIPv6",(t,e)=>{Na.init(t,e),$e.init(t,e)});var gx=b("ZodCIDRv4",(t,e)=>{Oa.init(t,e),$e.init(t,e)});var yx=b("ZodCIDRv6",(t,e)=>{Ca.init(t,e),$e.init(t,e)});var _x=b("ZodBase64",(t,e)=>{ja.init(t,e),$e.init(t,e)});var vx=b("ZodBase64URL",(t,e)=>{Aa.init(t,e),$e.init(t,e)});var bx=b("ZodE164",(t,e)=>{Ma.init(t,e),$e.init(t,e)});var xx=b("ZodJWT",(t,e)=>{Za.init(t,e),$e.init(t,e)});var $p=b("ZodNumber",(t,e)=>{is.init(t,e),Pe.init(t,e),t.gt=(n,o)=>t.check(ds(n,o)),t.gte=(n,o)=>t.check(Gn(n,o)),t.min=(n,o)=>t.check(Gn(n,o)),t.lt=(n,o)=>t.check(ls(n,o)),t.lte=(n,o)=>t.check(Wn(n,o)),t.max=(n,o)=>t.check(Wn(n,o)),t.int=n=>t.check(bp(n)),t.safe=n=>t.check(bp(n)),t.positive=n=>t.check(ds(0,n)),t.nonnegative=n=>t.check(Gn(0,n)),t.negative=n=>t.check(ls(0,n)),t.nonpositive=n=>t.check(Wn(0,n)),t.multipleOf=(n,o)=>t.check(fs(n,o)),t.step=(n,o)=>t.check(fs(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 fe(t){return Tc($p,t)}var wx=b("ZodNumberFormat",(t,e)=>{Da.init(t,e),$p.init(t,e)});function bp(t){return Ec(wx,t)}var $x=b("ZodBoolean",(t,e)=>{La.init(t,e),Pe.init(t,e)});function Ne(t){return Ic($x,t)}var kx=b("ZodNull",(t,e)=>{qa.init(t,e),Pe.init(t,e)});function kp(t){return Rc(kx,t)}var Sx=b("ZodUnknown",(t,e)=>{Ua.init(t,e),Pe.init(t,e)});function ke(){return Nc(Sx)}var zx=b("ZodNever",(t,e)=>{Fa.init(t,e),Pe.init(t,e)});function Px(t){return Oc(zx,t)}var Tx=b("ZodArray",(t,e)=>{Va.init(t,e),Pe.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(an(r,n)),t.nonempty=r=>t.check(an(1,r)),t.max=(r,n)=>t.check(ps(r,n)),t.length=(r,n)=>t.check(ms(r,n)),t.unwrap=()=>t.element});function se(t,e){return ip(Tx,t,e)}var Sp=b("ZodObject",(t,e)=>{as.init(t,e),Pe.init(t,e),ne.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>Qe(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:ke()}),t.loose=()=>t.clone({...t._zod.def,catchall:ke()}),t.strict=()=>t.clone({...t._zod.def,catchall:Px()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>ne.extend(t,r),t.merge=r=>ne.merge(t,r),t.pick=r=>ne.pick(t,r),t.omit=r=>ne.omit(t,r),t.partial=(...r)=>ne.partial(Tp,t,r[0]),t.required=(...r)=>ne.required(Ep,t,r[0])});function N(t,e){let r={type:"object",get shape(){return ne.assignProp(this,"shape",{...t}),this.shape},...ne.normalizeParams(e)};return new Sp(r)}function Be(t,e){return new Sp({type:"object",get shape(){return ne.assignProp(this,"shape",{...t}),this.shape},catchall:ke(),...ne.normalizeParams(e)})}var zp=b("ZodUnion",(t,e)=>{cs.init(t,e),Pe.init(t,e),t.options=e.options});function be(t,e){return new zp({type:"union",options:t,...ne.normalizeParams(e)})}var Ex=b("ZodDiscriminatedUnion",(t,e)=>{zp.init(t,e),Ha.init(t,e)});function eu(t,e,r){return new Ex({type:"union",options:e,discriminator:t,...ne.normalizeParams(r)})}var Ix=b("ZodIntersection",(t,e)=>{Ba.init(t,e),Pe.init(t,e)});function vs(t,e){return new Ix({type:"intersection",left:t,right:e})}var Rx=b("ZodRecord",(t,e)=>{Ja.init(t,e),Pe.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function ve(t,e,r){return new Rx({type:"record",keyType:t,valueType:e,...ne.normalizeParams(r)})}var Xc=b("ZodEnum",(t,e)=>{Ka.init(t,e),Pe.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 Xc({...e,checks:[],...ne.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 Xc({...e,checks:[],...ne.normalizeParams(o),entries:s})}});function Qe(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Xc({type:"enum",entries:r,...ne.normalizeParams(e)})}var Nx=b("ZodLiteral",(t,e)=>{Wa.init(t,e),Pe.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 M(t,e){return new Nx({type:"literal",values:Array.isArray(t)?t:[t],...ne.normalizeParams(e)})}var Ox=b("ZodTransform",(t,e)=>{Ga.init(t,e),Pe.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(ne.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(ne.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 Pp(t){return new Ox({type:"transform",transform:t})}var Tp=b("ZodOptional",(t,e)=>{Ya.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Se(t){return new Tp({type:"optional",innerType:t})}var Cx=b("ZodNullable",(t,e)=>{Xa.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function xp(t){return new Cx({type:"nullable",innerType:t})}var jx=b("ZodDefault",(t,e)=>{Qa.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function Ax(t,e){return new jx({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var Mx=b("ZodPrefault",(t,e)=>{ec.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Zx(t,e){return new Mx({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var Ep=b("ZodNonOptional",(t,e)=>{tc.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Dx(t,e){return new Ep({type:"nonoptional",innerType:t,...ne.normalizeParams(e)})}var Lx=b("ZodCatch",(t,e)=>{rc.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function qx(t,e){return new Lx({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Ux=b("ZodPipe",(t,e)=>{nc.init(t,e),Pe.init(t,e),t.in=e.in,t.out=e.out});function Qc(t,e){return new Ux({type:"pipe",in:t,out:e})}var Fx=b("ZodReadonly",(t,e)=>{oc.init(t,e),Pe.init(t,e)});function Vx(t){return new Fx({type:"readonly",innerType:t})}var Ip=b("ZodCustom",(t,e)=>{sc.init(t,e),Pe.init(t,e)});function Hx(t){let e=new Ce({check:"custom"});return e._zod.check=t,e}function Rp(t,e){return Vc(Ip,t??(()=>!0),e)}function Bx(t,e={}){return Hc(Ip,t,e)}function Jx(t){let e=Hx(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ne.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(ne.issue(o))}},t(r.value,r)));return e}function tu(t,e){return Qc(Pp(t),e)}it(ep());var nu="2025-11-25";var Np=[nu,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],er="io.modelcontextprotocol/related-task",xs="2.0",Re=Rp(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Op=be([v(),fe().int()]),Cp=v(),B1=Be({ttl:fe().optional(),pollInterval:fe().optional()}),Kx=N({ttl:fe().optional()}),Wx=N({taskId:v()}),ou=Be({progressToken:Op.optional(),[er]:Wx.optional()}),ct=N({_meta:ou.optional()}),Qn=ct.extend({task:Kx.optional()}),jp=t=>Qn.safeParse(t).success,je=N({method:v(),params:ct.loose().optional()}),dt=N({_meta:ou.optional()}),ft=N({method:v(),params:dt.loose().optional()}),Ae=Be({_meta:ou.optional()}),ws=be([v(),fe().int()]),Ap=N({jsonrpc:M(xs),id:ws,...je.shape}).strict(),su=t=>Ap.safeParse(t).success,Mp=N({jsonrpc:M(xs),...ft.shape}).strict(),Zp=t=>Mp.safeParse(t).success,iu=N({jsonrpc:M(xs),id:ws,result:Ae}).strict(),eo=t=>iu.safeParse(t).success;var D;(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"})(D||(D={}));var au=N({jsonrpc:M(xs),id:ws.optional(),error:N({code:fe().int(),message:v(),data:ke().optional()})}).strict();var Dp=t=>au.safeParse(t).success;var Lp=be([Ap,Mp,iu,au]),J1=be([iu,au]),$s=Ae.strict(),Gx=dt.extend({requestId:ws.optional(),reason:v().optional()}),ks=ft.extend({method:M("notifications/cancelled"),params:Gx}),Yx=N({src:v(),mimeType:v().optional(),sizes:se(v()).optional(),theme:Qe(["light","dark"]).optional()}),to=N({icons:se(Yx).optional()}),ln=N({name:v(),title:v().optional()}),qp=ln.extend({...ln.shape,...to.shape,version:v(),websiteUrl:v().optional(),description:v().optional()}),Xx=vs(N({applyDefaults:Ne().optional()}),ve(v(),ke())),Qx=tu(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,vs(N({form:Xx.optional(),url:Re.optional()}),ve(v(),ke()).optional())),e0=Be({list:Re.optional(),cancel:Re.optional(),requests:Be({sampling:Be({createMessage:Re.optional()}).optional(),elicitation:Be({create:Re.optional()}).optional()}).optional()}),t0=Be({list:Re.optional(),cancel:Re.optional(),requests:Be({tools:Be({call:Re.optional()}).optional()}).optional()}),r0=N({experimental:ve(v(),Re).optional(),sampling:N({context:Re.optional(),tools:Re.optional()}).optional(),elicitation:Qx.optional(),roots:N({listChanged:Ne().optional()}).optional(),tasks:e0.optional(),extensions:ve(v(),Re).optional()}),n0=ct.extend({protocolVersion:v(),capabilities:r0,clientInfo:qp}),cu=je.extend({method:M("initialize"),params:n0});var o0=N({experimental:ve(v(),Re).optional(),logging:Re.optional(),completions:Re.optional(),prompts:N({listChanged:Ne().optional()}).optional(),resources:N({subscribe:Ne().optional(),listChanged:Ne().optional()}).optional(),tools:N({listChanged:Ne().optional()}).optional(),tasks:t0.optional(),extensions:ve(v(),Re).optional()}),s0=Ae.extend({protocolVersion:v(),capabilities:o0,serverInfo:qp,instructions:v().optional()}),uu=ft.extend({method:M("notifications/initialized"),params:dt.optional()});var Ss=je.extend({method:M("ping"),params:ct.optional()}),i0=N({progress:fe(),total:Se(fe()),message:Se(v())}),a0=N({...dt.shape,...i0.shape,progressToken:Op}),zs=ft.extend({method:M("notifications/progress"),params:a0}),c0=ct.extend({cursor:Cp.optional()}),ro=je.extend({params:c0.optional()}),no=Ae.extend({nextCursor:Cp.optional()}),u0=Qe(["working","input_required","completed","failed","cancelled"]),oo=N({taskId:v(),status:u0,ttl:be([fe(),kp()]),createdAt:v(),lastUpdatedAt:v(),pollInterval:Se(fe()),statusMessage:Se(v())}),dn=Ae.extend({task:oo}),l0=dt.merge(oo),so=ft.extend({method:M("notifications/tasks/status"),params:l0}),Ps=je.extend({method:M("tasks/get"),params:ct.extend({taskId:v()})}),Ts=Ae.merge(oo),Es=je.extend({method:M("tasks/result"),params:ct.extend({taskId:v()})}),K1=Ae.loose(),Is=ro.extend({method:M("tasks/list")}),Rs=no.extend({tasks:se(oo)}),Ns=je.extend({method:M("tasks/cancel"),params:ct.extend({taskId:v()})}),Up=Ae.merge(oo),Fp=N({uri:v(),mimeType:Se(v()),_meta:ve(v(),ke()).optional()}),Vp=Fp.extend({text:v()}),lu=v().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Hp=Fp.extend({blob:lu}),io=Qe(["user","assistant"]),fn=N({audience:se(io).optional(),priority:fe().min(0).max(1).optional(),lastModified:Yn.datetime({offset:!0}).optional()}),Bp=N({...ln.shape,...to.shape,uri:v(),description:Se(v()),mimeType:Se(v()),size:Se(fe()),annotations:fn.optional(),_meta:Se(Be({}))}),d0=N({...ln.shape,...to.shape,uriTemplate:v(),description:Se(v()),mimeType:Se(v()),annotations:fn.optional(),_meta:Se(Be({}))}),Os=ro.extend({method:M("resources/list")}),f0=no.extend({resources:se(Bp)}),Cs=ro.extend({method:M("resources/templates/list")}),p0=no.extend({resourceTemplates:se(d0)}),du=ct.extend({uri:v()}),m0=du,js=je.extend({method:M("resources/read"),params:m0}),h0=Ae.extend({contents:se(be([Vp,Hp]))}),g0=ft.extend({method:M("notifications/resources/list_changed"),params:dt.optional()}),y0=du,_0=je.extend({method:M("resources/subscribe"),params:y0}),v0=du,b0=je.extend({method:M("resources/unsubscribe"),params:v0}),x0=dt.extend({uri:v()}),w0=ft.extend({method:M("notifications/resources/updated"),params:x0}),$0=N({name:v(),description:Se(v()),required:Se(Ne())}),k0=N({...ln.shape,...to.shape,description:Se(v()),arguments:Se(se($0)),_meta:Se(Be({}))}),As=ro.extend({method:M("prompts/list")}),S0=no.extend({prompts:se(k0)}),z0=ct.extend({name:v(),arguments:ve(v(),v()).optional()}),Ms=je.extend({method:M("prompts/get"),params:z0}),fu=N({type:M("text"),text:v(),annotations:fn.optional(),_meta:ve(v(),ke()).optional()}),pu=N({type:M("image"),data:lu,mimeType:v(),annotations:fn.optional(),_meta:ve(v(),ke()).optional()}),mu=N({type:M("audio"),data:lu,mimeType:v(),annotations:fn.optional(),_meta:ve(v(),ke()).optional()}),P0=N({type:M("tool_use"),name:v(),id:v(),input:ve(v(),ke()),_meta:ve(v(),ke()).optional()}),T0=N({type:M("resource"),resource:be([Vp,Hp]),annotations:fn.optional(),_meta:ve(v(),ke()).optional()}),E0=Bp.extend({type:M("resource_link")}),hu=be([fu,pu,mu,E0,T0]),I0=N({role:io,content:hu}),R0=Ae.extend({description:v().optional(),messages:se(I0)}),N0=ft.extend({method:M("notifications/prompts/list_changed"),params:dt.optional()}),O0=N({title:v().optional(),readOnlyHint:Ne().optional(),destructiveHint:Ne().optional(),idempotentHint:Ne().optional(),openWorldHint:Ne().optional()}),C0=N({taskSupport:Qe(["required","optional","forbidden"]).optional()}),Jp=N({...ln.shape,...to.shape,description:v().optional(),inputSchema:N({type:M("object"),properties:ve(v(),Re).optional(),required:se(v()).optional()}).catchall(ke()),outputSchema:N({type:M("object"),properties:ve(v(),Re).optional(),required:se(v()).optional()}).catchall(ke()).optional(),annotations:O0.optional(),execution:C0.optional(),_meta:ve(v(),ke()).optional()}),Zs=ro.extend({method:M("tools/list")}),j0=no.extend({tools:se(Jp)}),Ds=Ae.extend({content:se(hu).default([]),structuredContent:ve(v(),ke()).optional(),isError:Ne().optional()}),W1=Ds.or(Ae.extend({toolResult:ke()})),A0=Qn.extend({name:v(),arguments:ve(v(),ke()).optional()}),pn=je.extend({method:M("tools/call"),params:A0}),M0=ft.extend({method:M("notifications/tools/list_changed"),params:dt.optional()}),G1=N({autoRefresh:Ne().default(!0),debounceMs:fe().int().nonnegative().default(300)}),ao=Qe(["debug","info","notice","warning","error","critical","alert","emergency"]),Z0=ct.extend({level:ao}),gu=je.extend({method:M("logging/setLevel"),params:Z0}),D0=dt.extend({level:ao,logger:v().optional(),data:ke()}),L0=ft.extend({method:M("notifications/message"),params:D0}),q0=N({name:v().optional()}),U0=N({hints:se(q0).optional(),costPriority:fe().min(0).max(1).optional(),speedPriority:fe().min(0).max(1).optional(),intelligencePriority:fe().min(0).max(1).optional()}),F0=N({mode:Qe(["auto","required","none"]).optional()}),V0=N({type:M("tool_result"),toolUseId:v().describe("The unique identifier for the corresponding tool call."),content:se(hu).default([]),structuredContent:N({}).loose().optional(),isError:Ne().optional(),_meta:ve(v(),ke()).optional()}),H0=eu("type",[fu,pu,mu]),bs=eu("type",[fu,pu,mu,P0,V0]),B0=N({role:io,content:be([bs,se(bs)]),_meta:ve(v(),ke()).optional()}),J0=Qn.extend({messages:se(B0),modelPreferences:U0.optional(),systemPrompt:v().optional(),includeContext:Qe(["none","thisServer","allServers"]).optional(),temperature:fe().optional(),maxTokens:fe().int(),stopSequences:se(v()).optional(),metadata:Re.optional(),tools:se(Jp).optional(),toolChoice:F0.optional()}),K0=je.extend({method:M("sampling/createMessage"),params:J0}),co=Ae.extend({model:v(),stopReason:Se(Qe(["endTurn","stopSequence","maxTokens"]).or(v())),role:io,content:H0}),yu=Ae.extend({model:v(),stopReason:Se(Qe(["endTurn","stopSequence","maxTokens","toolUse"]).or(v())),role:io,content:be([bs,se(bs)])}),W0=N({type:M("boolean"),title:v().optional(),description:v().optional(),default:Ne().optional()}),G0=N({type:M("string"),title:v().optional(),description:v().optional(),minLength:fe().optional(),maxLength:fe().optional(),format:Qe(["email","uri","date","date-time"]).optional(),default:v().optional()}),Y0=N({type:Qe(["number","integer"]),title:v().optional(),description:v().optional(),minimum:fe().optional(),maximum:fe().optional(),default:fe().optional()}),X0=N({type:M("string"),title:v().optional(),description:v().optional(),enum:se(v()),default:v().optional()}),Q0=N({type:M("string"),title:v().optional(),description:v().optional(),oneOf:se(N({const:v(),title:v()})),default:v().optional()}),ew=N({type:M("string"),title:v().optional(),description:v().optional(),enum:se(v()),enumNames:se(v()).optional(),default:v().optional()}),tw=be([X0,Q0]),rw=N({type:M("array"),title:v().optional(),description:v().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:N({type:M("string"),enum:se(v())}),default:se(v()).optional()}),nw=N({type:M("array"),title:v().optional(),description:v().optional(),minItems:fe().optional(),maxItems:fe().optional(),items:N({anyOf:se(N({const:v(),title:v()}))}),default:se(v()).optional()}),ow=be([rw,nw]),sw=be([ew,tw,ow]),iw=be([sw,W0,G0,Y0]),aw=Qn.extend({mode:M("form").optional(),message:v(),requestedSchema:N({type:M("object"),properties:ve(v(),iw),required:se(v()).optional()})}),cw=Qn.extend({mode:M("url"),message:v(),elicitationId:v(),url:v().url()}),uw=be([aw,cw]),lw=je.extend({method:M("elicitation/create"),params:uw}),dw=dt.extend({elicitationId:v()}),fw=ft.extend({method:M("notifications/elicitation/complete"),params:dw}),mn=Ae.extend({action:Qe(["accept","decline","cancel"]),content:tu(t=>t===null?void 0:t,ve(v(),be([v(),fe(),Ne(),se(v())])).optional())}),pw=N({type:M("ref/resource"),uri:v()});var mw=N({type:M("ref/prompt"),name:v()}),hw=ct.extend({ref:be([mw,pw]),argument:N({name:v(),value:v()}),context:N({arguments:ve(v(),v()).optional()}).optional()}),Ls=je.extend({method:M("completion/complete"),params:hw});function Kp(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Wp(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var gw=Ae.extend({completion:Be({values:se(v()).max(100),total:Se(fe().int()),hasMore:Se(Ne())})}),yw=N({uri:v().startsWith("file://"),name:v().optional(),_meta:ve(v(),ke()).optional()}),_w=je.extend({method:M("roots/list"),params:ct.optional()}),_u=Ae.extend({roots:se(yw)}),vw=ft.extend({method:M("notifications/roots/list_changed"),params:dt.optional()}),Y1=be([Ss,cu,Ls,gu,Ms,As,Os,Cs,js,_0,b0,pn,Zs,Ps,Es,Is,Ns]),X1=be([ks,zs,uu,vw,so]),Q1=be([$s,co,yu,mn,_u,Ts,Rs,dn]),eR=be([Ss,K0,lw,_w,Ps,Es,Is,Ns]),tR=be([ks,zs,L0,w0,g0,M0,N0,so,fw]),rR=be([$s,s0,gw,R0,S0,f0,p0,h0,Ds,j0,Ts,Rs,dn]),A=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===D.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new ru(o.elicitations,r)}return new t(e,r,n)}},ru=class extends A{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(D.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function tr(t){return t==="completed"||t==="failed"||t==="cancelled"}var Yp=Symbol("Let zodToJsonSchema decide on which parser to use");var Gp={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"},Xp=t=>typeof t=="string"?{...Gp,name:t}:{...Gp,...t};var Qp=t=>{let e=Xp(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}]))}};function vu(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ie(t,e,r,n,o){t[e]=r,vu(t,e,n,o)}var qs=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function ze(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?qs(e,t.currentPath):e.join("/")}}function em(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==z.ZodAny&&(r.items=V(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ie(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ie(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ie(r,"minItems",t.exactLength.value,t.exactLength.message,e),ie(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}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?ie(r,"minimum",n.value,n.message,e):ie(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ie(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ie(r,"maximum",n.value,n.message,e):ie(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ie(r,"maximum",n.value,n.message,e));break;case"multipleOf":ie(r,"multipleOf",n.value,n.message,e);break}return r}function rm(){return{type:"boolean"}}function Us(t,e){return V(t.type._def,e)}var nm=(t,e)=>V(t.innerType._def,e);function bu(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>bu(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 bw(t,e)}}var bw=(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":ie(r,"minimum",n.value,n.message,e);break;case"max":ie(r,"maximum",n.value,n.message,e);break}return r};function om(t,e){return{...V(t.innerType._def,e),default:t.defaultValue()}}function sm(t,e){return e.effectStrategy==="input"?V(t.schema._def,e):ze(e)}function im(t){return{type:"string",enum:Array.from(t.values)}}var xw=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function am(t,e){let r=[V(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),V(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(xw(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}function cm(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}}var xu,vt={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:()=>(xu===void 0&&(xu=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),xu),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 Fs(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":ie(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ie(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":bt(r,"email",n.message,e);break;case"format:idn-email":bt(r,"idn-email",n.message,e);break;case"pattern:zod":Je(r,vt.email,n.message,e);break}break;case"url":bt(r,"uri",n.message,e);break;case"uuid":bt(r,"uuid",n.message,e);break;case"regex":Je(r,n.regex,n.message,e);break;case"cuid":Je(r,vt.cuid,n.message,e);break;case"cuid2":Je(r,vt.cuid2,n.message,e);break;case"startsWith":Je(r,RegExp(`^${wu(n.value,e)}`),n.message,e);break;case"endsWith":Je(r,RegExp(`${wu(n.value,e)}$`),n.message,e);break;case"datetime":bt(r,"date-time",n.message,e);break;case"date":bt(r,"date",n.message,e);break;case"time":bt(r,"time",n.message,e);break;case"duration":bt(r,"duration",n.message,e);break;case"length":ie(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ie(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Je(r,RegExp(wu(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&bt(r,"ipv4",n.message,e),n.version!=="v4"&&bt(r,"ipv6",n.message,e);break}case"base64url":Je(r,vt.base64url,n.message,e);break;case"jwt":Je(r,vt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Je(r,vt.ipv4Cidr,n.message,e),n.version!=="v4"&&Je(r,vt.ipv6Cidr,n.message,e);break}case"emoji":Je(r,vt.emoji(),n.message,e);break;case"ulid":{Je(r,vt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{bt(r,"binary",n.message,e);break}case"contentEncoding:base64":{ie(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Je(r,vt.base64,n.message,e);break}}break}case"nanoid":Je(r,vt.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function wu(t,e){return e.patternStrategy==="escape"?$w(t):t}var ww=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function $w(t){let e="";for(let r=0;r<t.length;r++)ww.has(t[r])||(e+="\\"),e+=t[r];return e}function bt(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}}})):ie(t,"format",e,r,n)}function Je(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:um(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ie(t,"pattern",um(e,n),r,n)}function um(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 d=l[1];if(e===l[0]){i(l);continue}if(n.external){let m=n.external.registry.get(l[0])?.id;if(e!==l[0]&&m){i(l);continue}}if(this.metadataRegistry.get(l[0])?.id){i(l);continue}if(d.cycle){i(l);continue}if(d.count>1&&n.reused==="ref"){i(l);continue}}let a=(l,d)=>{let f=this.seen.get(l),m=f.def??f.schema,p={...m};if(f.ref===null)return;let h=f.ref;if(f.ref=null,h){a(h,d);let g=this.seen.get(h).schema;g.$ref&&d.target==="draft-7"?(m.allOf=m.allOf??[],m.allOf.push(g)):(Object.assign(m,g),Object.assign(m,p))}f.isParent||this.override({zodSchema:l,jsonSchema:m,path:f.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 d=l[1];d.def&&d.defId&&(u[d.defId]=d.def)}n.external||Object.keys(u).length>0&&(this.target==="draft-2020-12"?c.$defs=u:c.definitions=u);try{return JSON.parse(JSON.stringify(c))}catch{throw new Error("Error converting schema to JSON.")}}};function Bc(t,e){if(t instanceof Kn){let n=new hs(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 hs(e);return r.process(t),r.emit(t,e)}function Ie(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 Ie(o.element,r);case"object":{for(let s in o.shape)if(Ie(o.shape[s],r))return!0;return!1}case"union":{for(let s of o.options)if(Ie(s,r))return!0;return!1}case"intersection":return Ie(o.left,r)||Ie(o.right,r);case"tuple":{for(let s of o.items)if(Ie(s,r))return!0;return!!(o.rest&&Ie(o.rest,r))}case"record":return Ie(o.keyType,r)||Ie(o.valueType,r);case"map":return Ie(o.keyType,r)||Ie(o.valueType,r);case"set":return Ie(o.valueType,r);case"promise":case"optional":case"nonoptional":case"nullable":case"readonly":return Ie(o.innerType,r);case"lazy":return Ie(o.getter(),r);case"default":return Ie(o.innerType,r);case"prefault":return Ie(o.innerType,r);case"custom":return!1;case"transform":return!0;case"pipe":return Ie(o.in,r)||Ie(o.out,r);case"success":return!1;case"catch":return!1;default:}throw new Error(`Unknown schema type: ${o.type}`)}var Jb=b("ZodMiniType",(t,e)=>{if(!t._zod)throw new Error("Uninitialized schema in ZodMiniType.");me.init(t,e),t.def=e,t.parse=(r,n)=>la(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Ir(t,r,n),t.parseAsync=async(r,n)=>pa(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Rr(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)=>at(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t))});var Kb=b("ZodMiniObject",(t,e)=>{as.init(t,e),Jb.init(t,e),ne.defineLazy(t,"shape",()=>e.shape)});function Jc(t,e){let r={type:"object",get shape(){return ne.assignProp(this,"shape",{...t}),this.shape},...ne.normalizeParams(e)};return new Kb(r)}function Rt(t){return!!t._zod}function Cr(t){let e=Object.values(t);if(e.length===0)return Jc({});let r=e.every(Rt),n=e.every(o=>!Rt(o));if(r)return Jc(t);if(n)return Gi(t);throw new Error("Mixed Zod versions detected in object shape.")}function Xt(t,e){return Rt(t)?Ir(t,e):t.safeParse(e)}async function gs(t,e){return Rt(t)?await Rr(t,e):await t.safeParseAsync(e)}function Qt(t){if(!t)return;let e;if(Rt(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function cn(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 Cr(t)}}if(Rt(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 Gb(t){return t.length===0?"object root":t.reduce((e,r,n)=>n===0?String(r):typeof r=="number"?`${e}[${r}]`:`${e}.${r}`,"")}function ys(t){if(t&&typeof t=="object"){if("issues"in t&&Array.isArray(t.issues)&&t.issues.length>0)return t.issues.map(e=>e.path?.length?`${e.message} at ${Gb(e.path)}`:e.message).join(`
|
|
37
|
+
`);if("message"in t&&typeof t.message=="string")return t.message;try{return JSON.stringify(t)}catch{return String(t)}}return String(t)}function cf(t){return t.description}function uf(t){if(Rt(t))return t._zod?.def?.type==="optional";let e=t;return typeof t.isOptional=="function"?t.isOptional():e._def?.typeName==="ZodOptional"}function un(t){if(Rt(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}var Yn={};Bi(Yn,{ZodISODate:()=>df,ZodISODateTime:()=>lf,ZodISODuration:()=>ff,ZodISOTime:()=>pf,date:()=>Wc,datetime:()=>Kc,duration:()=>Yc,time:()=>Gc});var lf=b("ZodISODateTime",(t,e)=>{Kp.init(t,e),$e.init(t,e)});function Kc(t){return tf(lf,t)}var df=b("ZodISODate",(t,e)=>{Wp.init(t,e),$e.init(t,e)});function Wc(t){return rf(df,t)}var pf=b("ZodISOTime",(t,e)=>{Gp.init(t,e),$e.init(t,e)});function Gc(t){return nf(pf,t)}var ff=b("ZodISODuration",(t,e)=>{Yp.init(t,e),$e.init(t,e)});function Yc(t){return of(ff,t)}var mf=(t,e)=>{rs.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>ca(t,r)},flatten:{value:r=>aa(t,r)},addIssue:{value:r=>t.issues.push(r)},addIssues:{value:r=>t.issues.push(...r)},isEmpty:{get(){return t.issues.length===0}}})},N1=b("ZodError",mf),Xn=b("ZodError",mf,{Parent:Error});var hf=ua(Xn),gf=da(Xn),yf=fa(Xn),_f=ma(Xn);var Pe=b("ZodType",(t,e)=>(me.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)=>at(t,r,n),t.brand=()=>t,t.register=((r,n)=>(r.add(t,n),t)),t.parse=(r,n)=>hf(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>yf(t,r,n),t.parseAsync=async(r,n)=>gf(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>_f(t,r,n),t.spa=t.safeParseAsync,t.refine=(r,n)=>t.check(Bx(r,n)),t.superRefine=r=>t.check(Jx(r)),t.overwrite=r=>t.check(Nr(r)),t.optional=()=>Se(t),t.nullable=()=>xf(t),t.nullish=()=>Se(xf(t)),t.nonoptional=r=>Dx(t,r),t.array=()=>se(t),t.or=r=>be([t,r]),t.and=r=>vs(t,r),t.transform=r=>Qc(t,Pf(r)),t.default=r=>jx(t,r),t.prefault=r=>Zx(t,r),t.catch=r=>qx(t,r),t.pipe=r=>Qc(t,r),t.readonly=()=>Vx(t),t.describe=r=>{let n=t.clone();return Yt.add(n,{description:r}),n},Object.defineProperty(t,"description",{get(){return Yt.get(t)?.description},configurable:!0}),t.meta=(...r)=>{if(r.length===0)return Yt.get(t);let n=t.clone();return Yt.add(n,r[0]),n},t.isOptional=()=>t.safeParse(void 0).success,t.isNullable=()=>t.safeParse(null).success,t)),wf=b("_ZodString",(t,e)=>{Jn.init(t,e),Pe.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(Cc(...n)),t.includes=(...n)=>t.check(Mc(...n)),t.startsWith=(...n)=>t.check(Zc(...n)),t.endsWith=(...n)=>t.check(Dc(...n)),t.min=(...n)=>t.check(an(...n)),t.max=(...n)=>t.check(fs(...n)),t.length=(...n)=>t.check(ms(...n)),t.nonempty=(...n)=>t.check(an(1,...n)),t.lowercase=n=>t.check(Ac(n)),t.uppercase=n=>t.check(jc(n)),t.trim=()=>t.check(qc()),t.normalize=(...n)=>t.check(Lc(...n)),t.toLowerCase=()=>t.check(Uc()),t.toUpperCase=()=>t.check(Fc())}),ox=b("ZodString",(t,e)=>{Jn.init(t,e),wf.init(t,e),t.email=r=>t.check(ac(sx,r)),t.url=r=>t.check(pc(ix,r)),t.jwt=r=>t.check(Pc(xx,r)),t.emoji=r=>t.check(fc(ax,r)),t.guid=r=>t.check(us(vf,r)),t.uuid=r=>t.check(cc(_s,r)),t.uuidv4=r=>t.check(uc(_s,r)),t.uuidv6=r=>t.check(lc(_s,r)),t.uuidv7=r=>t.check(dc(_s,r)),t.nanoid=r=>t.check(mc(cx,r)),t.guid=r=>t.check(us(vf,r)),t.cuid=r=>t.check(hc(ux,r)),t.cuid2=r=>t.check(gc(lx,r)),t.ulid=r=>t.check(yc(dx,r)),t.base64=r=>t.check(kc(_x,r)),t.base64url=r=>t.check(Sc(vx,r)),t.xid=r=>t.check(_c(px,r)),t.ksuid=r=>t.check(vc(fx,r)),t.ipv4=r=>t.check(bc(mx,r)),t.ipv6=r=>t.check(xc(hx,r)),t.cidrv4=r=>t.check(wc(gx,r)),t.cidrv6=r=>t.check($c(yx,r)),t.e164=r=>t.check(zc(bx,r)),t.datetime=r=>t.check(Kc(r)),t.date=r=>t.check(Wc(r)),t.time=r=>t.check(Gc(r)),t.duration=r=>t.check(Yc(r))});function v(t){return ic(ox,t)}var $e=b("ZodStringFormat",(t,e)=>{_e.init(t,e),wf.init(t,e)}),sx=b("ZodEmail",(t,e)=>{wa.init(t,e),$e.init(t,e)});var vf=b("ZodGUID",(t,e)=>{ba.init(t,e),$e.init(t,e)});var _s=b("ZodUUID",(t,e)=>{xa.init(t,e),$e.init(t,e)});var ix=b("ZodURL",(t,e)=>{$a.init(t,e),$e.init(t,e)});var ax=b("ZodEmoji",(t,e)=>{ka.init(t,e),$e.init(t,e)});var cx=b("ZodNanoID",(t,e)=>{Sa.init(t,e),$e.init(t,e)});var ux=b("ZodCUID",(t,e)=>{za.init(t,e),$e.init(t,e)});var lx=b("ZodCUID2",(t,e)=>{Pa.init(t,e),$e.init(t,e)});var dx=b("ZodULID",(t,e)=>{Ta.init(t,e),$e.init(t,e)});var px=b("ZodXID",(t,e)=>{Ea.init(t,e),$e.init(t,e)});var fx=b("ZodKSUID",(t,e)=>{Ia.init(t,e),$e.init(t,e)});var mx=b("ZodIPv4",(t,e)=>{Ra.init(t,e),$e.init(t,e)});var hx=b("ZodIPv6",(t,e)=>{Na.init(t,e),$e.init(t,e)});var gx=b("ZodCIDRv4",(t,e)=>{Oa.init(t,e),$e.init(t,e)});var yx=b("ZodCIDRv6",(t,e)=>{Ca.init(t,e),$e.init(t,e)});var _x=b("ZodBase64",(t,e)=>{Aa.init(t,e),$e.init(t,e)});var vx=b("ZodBase64URL",(t,e)=>{ja.init(t,e),$e.init(t,e)});var bx=b("ZodE164",(t,e)=>{Ma.init(t,e),$e.init(t,e)});var xx=b("ZodJWT",(t,e)=>{Za.init(t,e),$e.init(t,e)});var $f=b("ZodNumber",(t,e)=>{is.init(t,e),Pe.init(t,e),t.gt=(n,o)=>t.check(ds(n,o)),t.gte=(n,o)=>t.check(Gn(n,o)),t.min=(n,o)=>t.check(Gn(n,o)),t.lt=(n,o)=>t.check(ls(n,o)),t.lte=(n,o)=>t.check(Wn(n,o)),t.max=(n,o)=>t.check(Wn(n,o)),t.int=n=>t.check(bf(n)),t.safe=n=>t.check(bf(n)),t.positive=n=>t.check(ds(0,n)),t.nonnegative=n=>t.check(Gn(0,n)),t.negative=n=>t.check(ls(0,n)),t.nonpositive=n=>t.check(Wn(0,n)),t.multipleOf=(n,o)=>t.check(ps(n,o)),t.step=(n,o)=>t.check(ps(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 pe(t){return Tc($f,t)}var wx=b("ZodNumberFormat",(t,e)=>{Da.init(t,e),$f.init(t,e)});function bf(t){return Ec(wx,t)}var $x=b("ZodBoolean",(t,e)=>{La.init(t,e),Pe.init(t,e)});function Ne(t){return Ic($x,t)}var kx=b("ZodNull",(t,e)=>{qa.init(t,e),Pe.init(t,e)});function kf(t){return Rc(kx,t)}var Sx=b("ZodUnknown",(t,e)=>{Ua.init(t,e),Pe.init(t,e)});function ke(){return Nc(Sx)}var zx=b("ZodNever",(t,e)=>{Fa.init(t,e),Pe.init(t,e)});function Px(t){return Oc(zx,t)}var Tx=b("ZodArray",(t,e)=>{Va.init(t,e),Pe.init(t,e),t.element=e.element,t.min=(r,n)=>t.check(an(r,n)),t.nonempty=r=>t.check(an(1,r)),t.max=(r,n)=>t.check(fs(r,n)),t.length=(r,n)=>t.check(ms(r,n)),t.unwrap=()=>t.element});function se(t,e){return sf(Tx,t,e)}var Sf=b("ZodObject",(t,e)=>{as.init(t,e),Pe.init(t,e),ne.defineLazy(t,"shape",()=>e.shape),t.keyof=()=>Qe(Object.keys(t._zod.def.shape)),t.catchall=r=>t.clone({...t._zod.def,catchall:r}),t.passthrough=()=>t.clone({...t._zod.def,catchall:ke()}),t.loose=()=>t.clone({...t._zod.def,catchall:ke()}),t.strict=()=>t.clone({...t._zod.def,catchall:Px()}),t.strip=()=>t.clone({...t._zod.def,catchall:void 0}),t.extend=r=>ne.extend(t,r),t.merge=r=>ne.merge(t,r),t.pick=r=>ne.pick(t,r),t.omit=r=>ne.omit(t,r),t.partial=(...r)=>ne.partial(Tf,t,r[0]),t.required=(...r)=>ne.required(Ef,t,r[0])});function N(t,e){let r={type:"object",get shape(){return ne.assignProp(this,"shape",{...t}),this.shape},...ne.normalizeParams(e)};return new Sf(r)}function Be(t,e){return new Sf({type:"object",get shape(){return ne.assignProp(this,"shape",{...t}),this.shape},catchall:ke(),...ne.normalizeParams(e)})}var zf=b("ZodUnion",(t,e)=>{cs.init(t,e),Pe.init(t,e),t.options=e.options});function be(t,e){return new zf({type:"union",options:t,...ne.normalizeParams(e)})}var Ex=b("ZodDiscriminatedUnion",(t,e)=>{zf.init(t,e),Ha.init(t,e)});function eu(t,e,r){return new Ex({type:"union",options:e,discriminator:t,...ne.normalizeParams(r)})}var Ix=b("ZodIntersection",(t,e)=>{Ba.init(t,e),Pe.init(t,e)});function vs(t,e){return new Ix({type:"intersection",left:t,right:e})}var Rx=b("ZodRecord",(t,e)=>{Ja.init(t,e),Pe.init(t,e),t.keyType=e.keyType,t.valueType=e.valueType});function ve(t,e,r){return new Rx({type:"record",keyType:t,valueType:e,...ne.normalizeParams(r)})}var Xc=b("ZodEnum",(t,e)=>{Ka.init(t,e),Pe.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 Xc({...e,checks:[],...ne.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 Xc({...e,checks:[],...ne.normalizeParams(o),entries:s})}});function Qe(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Xc({type:"enum",entries:r,...ne.normalizeParams(e)})}var Nx=b("ZodLiteral",(t,e)=>{Wa.init(t,e),Pe.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 M(t,e){return new Nx({type:"literal",values:Array.isArray(t)?t:[t],...ne.normalizeParams(e)})}var Ox=b("ZodTransform",(t,e)=>{Ga.init(t,e),Pe.init(t,e),t._zod.parse=(r,n)=>{r.addIssue=s=>{if(typeof s=="string")r.issues.push(ne.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(ne.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 Pf(t){return new Ox({type:"transform",transform:t})}var Tf=b("ZodOptional",(t,e)=>{Ya.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Se(t){return new Tf({type:"optional",innerType:t})}var Cx=b("ZodNullable",(t,e)=>{Xa.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function xf(t){return new Cx({type:"nullable",innerType:t})}var Ax=b("ZodDefault",(t,e)=>{Qa.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function jx(t,e){return new Ax({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var Mx=b("ZodPrefault",(t,e)=>{ec.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Zx(t,e){return new Mx({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():e}})}var Ef=b("ZodNonOptional",(t,e)=>{tc.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType});function Dx(t,e){return new Ef({type:"nonoptional",innerType:t,...ne.normalizeParams(e)})}var Lx=b("ZodCatch",(t,e)=>{rc.init(t,e),Pe.init(t,e),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function qx(t,e){return new Lx({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Ux=b("ZodPipe",(t,e)=>{nc.init(t,e),Pe.init(t,e),t.in=e.in,t.out=e.out});function Qc(t,e){return new Ux({type:"pipe",in:t,out:e})}var Fx=b("ZodReadonly",(t,e)=>{oc.init(t,e),Pe.init(t,e)});function Vx(t){return new Fx({type:"readonly",innerType:t})}var If=b("ZodCustom",(t,e)=>{sc.init(t,e),Pe.init(t,e)});function Hx(t){let e=new Ce({check:"custom"});return e._zod.check=t,e}function Rf(t,e){return Vc(If,t??(()=>!0),e)}function Bx(t,e={}){return Hc(If,t,e)}function Jx(t){let e=Hx(r=>(r.addIssue=n=>{if(typeof n=="string")r.issues.push(ne.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(ne.issue(o))}},t(r.value,r)));return e}function tu(t,e){return Qc(Pf(t),e)}it(Qp());var nu="2025-11-25";var Nf=[nu,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],er="io.modelcontextprotocol/related-task",xs="2.0",Re=Rf(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Of=be([v(),pe().int()]),Cf=v(),B1=Be({ttl:pe().optional(),pollInterval:pe().optional()}),Kx=N({ttl:pe().optional()}),Wx=N({taskId:v()}),ou=Be({progressToken:Of.optional(),[er]:Wx.optional()}),ct=N({_meta:ou.optional()}),Qn=ct.extend({task:Kx.optional()}),Af=t=>Qn.safeParse(t).success,Ae=N({method:v(),params:ct.loose().optional()}),dt=N({_meta:ou.optional()}),pt=N({method:v(),params:dt.loose().optional()}),je=Be({_meta:ou.optional()}),ws=be([v(),pe().int()]),jf=N({jsonrpc:M(xs),id:ws,...Ae.shape}).strict(),su=t=>jf.safeParse(t).success,Mf=N({jsonrpc:M(xs),...pt.shape}).strict(),Zf=t=>Mf.safeParse(t).success,iu=N({jsonrpc:M(xs),id:ws,result:je}).strict(),eo=t=>iu.safeParse(t).success;var D;(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"})(D||(D={}));var au=N({jsonrpc:M(xs),id:ws.optional(),error:N({code:pe().int(),message:v(),data:ke().optional()})}).strict();var Df=t=>au.safeParse(t).success;var Lf=be([jf,Mf,iu,au]),J1=be([iu,au]),$s=je.strict(),Gx=dt.extend({requestId:ws.optional(),reason:v().optional()}),ks=pt.extend({method:M("notifications/cancelled"),params:Gx}),Yx=N({src:v(),mimeType:v().optional(),sizes:se(v()).optional(),theme:Qe(["light","dark"]).optional()}),to=N({icons:se(Yx).optional()}),ln=N({name:v(),title:v().optional()}),qf=ln.extend({...ln.shape,...to.shape,version:v(),websiteUrl:v().optional(),description:v().optional()}),Xx=vs(N({applyDefaults:Ne().optional()}),ve(v(),ke())),Qx=tu(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,vs(N({form:Xx.optional(),url:Re.optional()}),ve(v(),ke()).optional())),e0=Be({list:Re.optional(),cancel:Re.optional(),requests:Be({sampling:Be({createMessage:Re.optional()}).optional(),elicitation:Be({create:Re.optional()}).optional()}).optional()}),t0=Be({list:Re.optional(),cancel:Re.optional(),requests:Be({tools:Be({call:Re.optional()}).optional()}).optional()}),r0=N({experimental:ve(v(),Re).optional(),sampling:N({context:Re.optional(),tools:Re.optional()}).optional(),elicitation:Qx.optional(),roots:N({listChanged:Ne().optional()}).optional(),tasks:e0.optional(),extensions:ve(v(),Re).optional()}),n0=ct.extend({protocolVersion:v(),capabilities:r0,clientInfo:qf}),cu=Ae.extend({method:M("initialize"),params:n0});var o0=N({experimental:ve(v(),Re).optional(),logging:Re.optional(),completions:Re.optional(),prompts:N({listChanged:Ne().optional()}).optional(),resources:N({subscribe:Ne().optional(),listChanged:Ne().optional()}).optional(),tools:N({listChanged:Ne().optional()}).optional(),tasks:t0.optional(),extensions:ve(v(),Re).optional()}),s0=je.extend({protocolVersion:v(),capabilities:o0,serverInfo:qf,instructions:v().optional()}),uu=pt.extend({method:M("notifications/initialized"),params:dt.optional()});var Ss=Ae.extend({method:M("ping"),params:ct.optional()}),i0=N({progress:pe(),total:Se(pe()),message:Se(v())}),a0=N({...dt.shape,...i0.shape,progressToken:Of}),zs=pt.extend({method:M("notifications/progress"),params:a0}),c0=ct.extend({cursor:Cf.optional()}),ro=Ae.extend({params:c0.optional()}),no=je.extend({nextCursor:Cf.optional()}),u0=Qe(["working","input_required","completed","failed","cancelled"]),oo=N({taskId:v(),status:u0,ttl:be([pe(),kf()]),createdAt:v(),lastUpdatedAt:v(),pollInterval:Se(pe()),statusMessage:Se(v())}),dn=je.extend({task:oo}),l0=dt.merge(oo),so=pt.extend({method:M("notifications/tasks/status"),params:l0}),Ps=Ae.extend({method:M("tasks/get"),params:ct.extend({taskId:v()})}),Ts=je.merge(oo),Es=Ae.extend({method:M("tasks/result"),params:ct.extend({taskId:v()})}),K1=je.loose(),Is=ro.extend({method:M("tasks/list")}),Rs=no.extend({tasks:se(oo)}),Ns=Ae.extend({method:M("tasks/cancel"),params:ct.extend({taskId:v()})}),Uf=je.merge(oo),Ff=N({uri:v(),mimeType:Se(v()),_meta:ve(v(),ke()).optional()}),Vf=Ff.extend({text:v()}),lu=v().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Hf=Ff.extend({blob:lu}),io=Qe(["user","assistant"]),pn=N({audience:se(io).optional(),priority:pe().min(0).max(1).optional(),lastModified:Yn.datetime({offset:!0}).optional()}),Bf=N({...ln.shape,...to.shape,uri:v(),description:Se(v()),mimeType:Se(v()),size:Se(pe()),annotations:pn.optional(),_meta:Se(Be({}))}),d0=N({...ln.shape,...to.shape,uriTemplate:v(),description:Se(v()),mimeType:Se(v()),annotations:pn.optional(),_meta:Se(Be({}))}),Os=ro.extend({method:M("resources/list")}),p0=no.extend({resources:se(Bf)}),Cs=ro.extend({method:M("resources/templates/list")}),f0=no.extend({resourceTemplates:se(d0)}),du=ct.extend({uri:v()}),m0=du,As=Ae.extend({method:M("resources/read"),params:m0}),h0=je.extend({contents:se(be([Vf,Hf]))}),g0=pt.extend({method:M("notifications/resources/list_changed"),params:dt.optional()}),y0=du,_0=Ae.extend({method:M("resources/subscribe"),params:y0}),v0=du,b0=Ae.extend({method:M("resources/unsubscribe"),params:v0}),x0=dt.extend({uri:v()}),w0=pt.extend({method:M("notifications/resources/updated"),params:x0}),$0=N({name:v(),description:Se(v()),required:Se(Ne())}),k0=N({...ln.shape,...to.shape,description:Se(v()),arguments:Se(se($0)),_meta:Se(Be({}))}),js=ro.extend({method:M("prompts/list")}),S0=no.extend({prompts:se(k0)}),z0=ct.extend({name:v(),arguments:ve(v(),v()).optional()}),Ms=Ae.extend({method:M("prompts/get"),params:z0}),pu=N({type:M("text"),text:v(),annotations:pn.optional(),_meta:ve(v(),ke()).optional()}),fu=N({type:M("image"),data:lu,mimeType:v(),annotations:pn.optional(),_meta:ve(v(),ke()).optional()}),mu=N({type:M("audio"),data:lu,mimeType:v(),annotations:pn.optional(),_meta:ve(v(),ke()).optional()}),P0=N({type:M("tool_use"),name:v(),id:v(),input:ve(v(),ke()),_meta:ve(v(),ke()).optional()}),T0=N({type:M("resource"),resource:be([Vf,Hf]),annotations:pn.optional(),_meta:ve(v(),ke()).optional()}),E0=Bf.extend({type:M("resource_link")}),hu=be([pu,fu,mu,E0,T0]),I0=N({role:io,content:hu}),R0=je.extend({description:v().optional(),messages:se(I0)}),N0=pt.extend({method:M("notifications/prompts/list_changed"),params:dt.optional()}),O0=N({title:v().optional(),readOnlyHint:Ne().optional(),destructiveHint:Ne().optional(),idempotentHint:Ne().optional(),openWorldHint:Ne().optional()}),C0=N({taskSupport:Qe(["required","optional","forbidden"]).optional()}),Jf=N({...ln.shape,...to.shape,description:v().optional(),inputSchema:N({type:M("object"),properties:ve(v(),Re).optional(),required:se(v()).optional()}).catchall(ke()),outputSchema:N({type:M("object"),properties:ve(v(),Re).optional(),required:se(v()).optional()}).catchall(ke()).optional(),annotations:O0.optional(),execution:C0.optional(),_meta:ve(v(),ke()).optional()}),Zs=ro.extend({method:M("tools/list")}),A0=no.extend({tools:se(Jf)}),Ds=je.extend({content:se(hu).default([]),structuredContent:ve(v(),ke()).optional(),isError:Ne().optional()}),W1=Ds.or(je.extend({toolResult:ke()})),j0=Qn.extend({name:v(),arguments:ve(v(),ke()).optional()}),fn=Ae.extend({method:M("tools/call"),params:j0}),M0=pt.extend({method:M("notifications/tools/list_changed"),params:dt.optional()}),G1=N({autoRefresh:Ne().default(!0),debounceMs:pe().int().nonnegative().default(300)}),ao=Qe(["debug","info","notice","warning","error","critical","alert","emergency"]),Z0=ct.extend({level:ao}),gu=Ae.extend({method:M("logging/setLevel"),params:Z0}),D0=dt.extend({level:ao,logger:v().optional(),data:ke()}),L0=pt.extend({method:M("notifications/message"),params:D0}),q0=N({name:v().optional()}),U0=N({hints:se(q0).optional(),costPriority:pe().min(0).max(1).optional(),speedPriority:pe().min(0).max(1).optional(),intelligencePriority:pe().min(0).max(1).optional()}),F0=N({mode:Qe(["auto","required","none"]).optional()}),V0=N({type:M("tool_result"),toolUseId:v().describe("The unique identifier for the corresponding tool call."),content:se(hu).default([]),structuredContent:N({}).loose().optional(),isError:Ne().optional(),_meta:ve(v(),ke()).optional()}),H0=eu("type",[pu,fu,mu]),bs=eu("type",[pu,fu,mu,P0,V0]),B0=N({role:io,content:be([bs,se(bs)]),_meta:ve(v(),ke()).optional()}),J0=Qn.extend({messages:se(B0),modelPreferences:U0.optional(),systemPrompt:v().optional(),includeContext:Qe(["none","thisServer","allServers"]).optional(),temperature:pe().optional(),maxTokens:pe().int(),stopSequences:se(v()).optional(),metadata:Re.optional(),tools:se(Jf).optional(),toolChoice:F0.optional()}),K0=Ae.extend({method:M("sampling/createMessage"),params:J0}),co=je.extend({model:v(),stopReason:Se(Qe(["endTurn","stopSequence","maxTokens"]).or(v())),role:io,content:H0}),yu=je.extend({model:v(),stopReason:Se(Qe(["endTurn","stopSequence","maxTokens","toolUse"]).or(v())),role:io,content:be([bs,se(bs)])}),W0=N({type:M("boolean"),title:v().optional(),description:v().optional(),default:Ne().optional()}),G0=N({type:M("string"),title:v().optional(),description:v().optional(),minLength:pe().optional(),maxLength:pe().optional(),format:Qe(["email","uri","date","date-time"]).optional(),default:v().optional()}),Y0=N({type:Qe(["number","integer"]),title:v().optional(),description:v().optional(),minimum:pe().optional(),maximum:pe().optional(),default:pe().optional()}),X0=N({type:M("string"),title:v().optional(),description:v().optional(),enum:se(v()),default:v().optional()}),Q0=N({type:M("string"),title:v().optional(),description:v().optional(),oneOf:se(N({const:v(),title:v()})),default:v().optional()}),ew=N({type:M("string"),title:v().optional(),description:v().optional(),enum:se(v()),enumNames:se(v()).optional(),default:v().optional()}),tw=be([X0,Q0]),rw=N({type:M("array"),title:v().optional(),description:v().optional(),minItems:pe().optional(),maxItems:pe().optional(),items:N({type:M("string"),enum:se(v())}),default:se(v()).optional()}),nw=N({type:M("array"),title:v().optional(),description:v().optional(),minItems:pe().optional(),maxItems:pe().optional(),items:N({anyOf:se(N({const:v(),title:v()}))}),default:se(v()).optional()}),ow=be([rw,nw]),sw=be([ew,tw,ow]),iw=be([sw,W0,G0,Y0]),aw=Qn.extend({mode:M("form").optional(),message:v(),requestedSchema:N({type:M("object"),properties:ve(v(),iw),required:se(v()).optional()})}),cw=Qn.extend({mode:M("url"),message:v(),elicitationId:v(),url:v().url()}),uw=be([aw,cw]),lw=Ae.extend({method:M("elicitation/create"),params:uw}),dw=dt.extend({elicitationId:v()}),pw=pt.extend({method:M("notifications/elicitation/complete"),params:dw}),mn=je.extend({action:Qe(["accept","decline","cancel"]),content:tu(t=>t===null?void 0:t,ve(v(),be([v(),pe(),Ne(),se(v())])).optional())}),fw=N({type:M("ref/resource"),uri:v()});var mw=N({type:M("ref/prompt"),name:v()}),hw=ct.extend({ref:be([mw,fw]),argument:N({name:v(),value:v()}),context:N({arguments:ve(v(),v()).optional()}).optional()}),Ls=Ae.extend({method:M("completion/complete"),params:hw});function Kf(t){if(t.params.ref.type!=="ref/prompt")throw new TypeError(`Expected CompleteRequestPrompt, but got ${t.params.ref.type}`)}function Wf(t){if(t.params.ref.type!=="ref/resource")throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${t.params.ref.type}`)}var gw=je.extend({completion:Be({values:se(v()).max(100),total:Se(pe().int()),hasMore:Se(Ne())})}),yw=N({uri:v().startsWith("file://"),name:v().optional(),_meta:ve(v(),ke()).optional()}),_w=Ae.extend({method:M("roots/list"),params:ct.optional()}),_u=je.extend({roots:se(yw)}),vw=pt.extend({method:M("notifications/roots/list_changed"),params:dt.optional()}),Y1=be([Ss,cu,Ls,gu,Ms,js,Os,Cs,As,_0,b0,fn,Zs,Ps,Es,Is,Ns]),X1=be([ks,zs,uu,vw,so]),Q1=be([$s,co,yu,mn,_u,Ts,Rs,dn]),eR=be([Ss,K0,lw,_w,Ps,Es,Is,Ns]),tR=be([ks,zs,L0,w0,g0,M0,N0,so,pw]),rR=be([$s,s0,gw,R0,S0,p0,f0,h0,Ds,A0,Ts,Rs,dn]),j=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===D.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new ru(o.elicitations,r)}return new t(e,r,n)}},ru=class extends j{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(D.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function tr(t){return t==="completed"||t==="failed"||t==="cancelled"}var Yf=Symbol("Let zodToJsonSchema decide on which parser to use");var Gf={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"},Xf=t=>typeof t=="string"?{...Gf,name:t}:{...Gf,...t};var Qf=t=>{let e=Xf(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}]))}};function vu(t,e,r,n){n?.errorMessages&&r&&(t.errorMessage={...t.errorMessage,[e]:r})}function ie(t,e,r,n,o){t[e]=r,vu(t,e,n,o)}var qs=(t,e)=>{let r=0;for(;r<t.length&&r<e.length&&t[r]===e[r];r++);return[(t.length-r).toString(),...e.slice(r)].join("/")};function ze(t){if(t.target!=="openAi")return{};let e=[...t.basePath,t.definitionPath,t.openAiAnyTypeName];return t.flags.hasReferencedOpenAiAnyType=!0,{$ref:t.$refStrategy==="relative"?qs(e,t.currentPath):e.join("/")}}function em(t,e){let r={type:"array"};return t.type?._def&&t.type?._def?.typeName!==z.ZodAny&&(r.items=V(t.type._def,{...e,currentPath:[...e.currentPath,"items"]})),t.minLength&&ie(r,"minItems",t.minLength.value,t.minLength.message,e),t.maxLength&&ie(r,"maxItems",t.maxLength.value,t.maxLength.message,e),t.exactLength&&(ie(r,"minItems",t.exactLength.value,t.exactLength.message,e),ie(r,"maxItems",t.exactLength.value,t.exactLength.message,e)),r}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?ie(r,"minimum",n.value,n.message,e):ie(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ie(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ie(r,"maximum",n.value,n.message,e):ie(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ie(r,"maximum",n.value,n.message,e));break;case"multipleOf":ie(r,"multipleOf",n.value,n.message,e);break}return r}function rm(){return{type:"boolean"}}function Us(t,e){return V(t.type._def,e)}var nm=(t,e)=>V(t.innerType._def,e);function bu(t,e,r){let n=r??e.dateStrategy;if(Array.isArray(n))return{anyOf:n.map((o,s)=>bu(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 bw(t,e)}}var bw=(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":ie(r,"minimum",n.value,n.message,e);break;case"max":ie(r,"maximum",n.value,n.message,e);break}return r};function om(t,e){return{...V(t.innerType._def,e),default:t.defaultValue()}}function sm(t,e){return e.effectStrategy==="input"?V(t.schema._def,e):ze(e)}function im(t){return{type:"string",enum:Array.from(t.values)}}var xw=t=>"type"in t&&t.type==="string"?!1:"allOf"in t;function am(t,e){let r=[V(t.left._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),V(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(xw(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}function cm(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}}var xu,vt={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:()=>(xu===void 0&&(xu=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),xu),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 Fs(t,e){let r={type:"string"};if(t.checks)for(let n of t.checks)switch(n.kind){case"min":ie(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e);break;case"max":ie(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":bt(r,"email",n.message,e);break;case"format:idn-email":bt(r,"idn-email",n.message,e);break;case"pattern:zod":Je(r,vt.email,n.message,e);break}break;case"url":bt(r,"uri",n.message,e);break;case"uuid":bt(r,"uuid",n.message,e);break;case"regex":Je(r,n.regex,n.message,e);break;case"cuid":Je(r,vt.cuid,n.message,e);break;case"cuid2":Je(r,vt.cuid2,n.message,e);break;case"startsWith":Je(r,RegExp(`^${wu(n.value,e)}`),n.message,e);break;case"endsWith":Je(r,RegExp(`${wu(n.value,e)}$`),n.message,e);break;case"datetime":bt(r,"date-time",n.message,e);break;case"date":bt(r,"date",n.message,e);break;case"time":bt(r,"time",n.message,e);break;case"duration":bt(r,"duration",n.message,e);break;case"length":ie(r,"minLength",typeof r.minLength=="number"?Math.max(r.minLength,n.value):n.value,n.message,e),ie(r,"maxLength",typeof r.maxLength=="number"?Math.min(r.maxLength,n.value):n.value,n.message,e);break;case"includes":{Je(r,RegExp(wu(n.value,e)),n.message,e);break}case"ip":{n.version!=="v6"&&bt(r,"ipv4",n.message,e),n.version!=="v4"&&bt(r,"ipv6",n.message,e);break}case"base64url":Je(r,vt.base64url,n.message,e);break;case"jwt":Je(r,vt.jwt,n.message,e);break;case"cidr":{n.version!=="v6"&&Je(r,vt.ipv4Cidr,n.message,e),n.version!=="v4"&&Je(r,vt.ipv6Cidr,n.message,e);break}case"emoji":Je(r,vt.emoji(),n.message,e);break;case"ulid":{Je(r,vt.ulid,n.message,e);break}case"base64":{switch(e.base64Strategy){case"format:binary":{bt(r,"binary",n.message,e);break}case"contentEncoding:base64":{ie(r,"contentEncoding","base64",n.message,e);break}case"pattern:zod":{Je(r,vt.base64,n.message,e);break}}break}case"nanoid":Je(r,vt.nanoid,n.message,e);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return r}function wu(t,e){return e.patternStrategy==="escape"?$w(t):t}var ww=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function $w(t){let e="";for(let r=0;r<t.length;r++)ww.has(t[r])||(e+="\\"),e+=t[r];return e}function bt(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}}})):ie(t,"format",e,r,n)}function Je(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:um(e,n),...r&&n.errorMessages&&{errorMessage:{pattern:r}}})):ie(t,"pattern",um(e,n),r,n)}function um(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
|
|
38
38
|
]))`;continue}else if(n[c]==="$"){o+=`($|(?=[\r
|
|
39
39
|
]))`;continue}}if(r.s&&n[c]==="."){o+=i?`${n[c]}\r
|
|
40
40
|
`:`[${n[c]}\r
|
|
41
|
-
]`;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 Vs(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===z.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,o)=>({...n,[o]:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",o]})??ze(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===z.ZodString&&t.keyType._def.checks?.length){let{type:n,...o}=Fs(t.keyType._def,e);return{...r,propertyNames:o}}else{if(t.keyType?._def.typeName===z.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===z.ZodBranded&&t.keyType._def.type._def.typeName===z.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...o}=Us(t.keyType._def,e);return{...r,propertyNames:o}}}return r}function lm(t,e){if(e.mapStrategy==="record")return Vs(t,e);let r=V(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||ze(e),n=V(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||ze(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function dm(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}}function fm(t){return t.target==="openAi"?void 0:{not:ze({...t,currentPath:[...t.currentPath,"not"]})}}function pm(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var uo={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function hm(t,e){if(e.target==="openApi3")return mm(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in uo&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,s)=>{let i=uo[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 mm(t,e)}var mm=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,o)=>V(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 gm(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:uo[t.innerType._def.typeName],nullable:!0}:{type:[uo[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=V(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=V(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function ym(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",vu(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?ie(r,"minimum",n.value,n.message,e):ie(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ie(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ie(r,"maximum",n.value,n.message,e):ie(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ie(r,"maximum",n.value,n.message,e));break;case"multipleOf":ie(r,"multipleOf",n.value,n.message,e);break}return r}function _m(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=Sw(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=V(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=kw(t,e);return i!==void 0&&(n.additionalProperties=i),n}function kw(t,e){if(t.catchall._def.typeName!=="ZodNever")return V(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 Sw(t){try{return t.isOptional()}catch{return!0}}var vm=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return V(t.innerType._def,e);let r=V(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:ze(e)},r]}:ze(e)};var bm=(t,e)=>{if(e.pipeStrategy==="input")return V(t.in._def,e);if(e.pipeStrategy==="output")return V(t.out._def,e);let r=V(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=V(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}};function xm(t,e){return V(t.type._def,e)}function wm(t,e){let n={type:"array",uniqueItems:!0,items:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&ie(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&ie(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function $m(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>V(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:V(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>V(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function km(t){return{not:ze(t)}}function Sm(t){return ze(t)}var zm=(t,e)=>V(t.innerType._def,e);var Pm=(t,e,r)=>{switch(e){case z.ZodString:return Fs(t,r);case z.ZodNumber:return ym(t,r);case z.ZodObject:return _m(t,r);case z.ZodBigInt:return tm(t,r);case z.ZodBoolean:return rm();case z.ZodDate:return bu(t,r);case z.ZodUndefined:return km(r);case z.ZodNull:return pm(r);case z.ZodArray:return em(t,r);case z.ZodUnion:case z.ZodDiscriminatedUnion:return hm(t,r);case z.ZodIntersection:return am(t,r);case z.ZodTuple:return $m(t,r);case z.ZodRecord:return Vs(t,r);case z.ZodLiteral:return cm(t,r);case z.ZodEnum:return im(t);case z.ZodNativeEnum:return dm(t);case z.ZodNullable:return gm(t,r);case z.ZodOptional:return vm(t,r);case z.ZodMap:return lm(t,r);case z.ZodSet:return wm(t,r);case z.ZodLazy:return()=>t.getter()._def;case z.ZodPromise:return xm(t,r);case z.ZodNaN:case z.ZodNever:return fm(r);case z.ZodEffects:return sm(t,r);case z.ZodAny:return ze(r);case z.ZodUnknown:return Sm(r);case z.ZodDefault:return om(t,r);case z.ZodBranded:return Us(t,r);case z.ZodReadonly:return zm(t,r);case z.ZodCatch:return nm(t,r);case z.ZodPipeline:return bm(t,r);case z.ZodFunction:case z.ZodVoid:case z.ZodSymbol:return;default:return(n=>{})(e)}};function V(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==Yp)return a}if(n&&!r){let a=zw(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=Pm(t,t.typeName,e),i=typeof s=="function"?V(s(),e):s;if(i&&Pw(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return o.jsonSchema=i,a}return o.jsonSchema=i,i}var zw=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:qs(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`),ze(e)):e.$refStrategy==="seen"?ze(e):void 0}},Pw=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var $u=(t,e)=>{let r=Qp(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:V(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??ze(r)}),{}):void 0,o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=V(t._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??ze(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 Tw(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function ku(t,e){return Rt(t)?Bc(t,{target:Tw(e?.target),io:e?.pipeStrategy??"input"}):$u(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function Su(t){let r=Qt(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=un(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function zu(t,e){let r=Xt(t,e);if(!r.success)throw r.error;return r.data}var Ew=6e4,Hs=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(ks,r=>{this._oncancel(r)}),this.setNotificationHandler(zs,r=>{this._onprogress(r)}),this.setRequestHandler(Ss,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ps,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(D.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Es,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 d=c,p=new A(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new A(D.InvalidParams,`Task not found: ${s}`);if(!tr(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(tr(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[er]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Is,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 A(D.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ns,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(D.InvalidParams,`Task not found: ${r.params.taskId}`);if(tr(o.status))throw new A(D.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 A(D.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof A?o:new A(D.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),A.fromError(D.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),eo(s)||Dp(s)?this._onresponse(s):su(s)?this._onrequest(s,i):Zp(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=A.fromError(D.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?.[er]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:D.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=jp(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 d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new A(D.ConnectionClosed,"Request was cancelled");let m={...p,relatedRequestId:e.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let f=m.relatedTask?.taskId??s;return f&&c&&await c.updateTaskStatus(f,"input_required"),await this.request(l,d,m)},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 d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:D.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).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),eo(e))n(e);else{let i=new A(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(eo(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),eo(e))o(e);else{let i=A.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 A?i:new A(D.InternalError,String(i))}}return}let s;try{let i=await this.request(e,dn,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new A(D.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},tr(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new A(D.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new A(D.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 A?i:new A(D.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 d=_=>{l(_)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(_){d(_);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[er]:c}});let f=_=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(_)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));let w=_ instanceof A?_:new A(D.RequestTimeout,String(_));l(w)};this._responseHandlers.set(p,_=>{if(!n?.signal?.aborted){if(_ instanceof Error)return l(_);try{let w=Xt(r,_.result);w.success?u(w.data):l(w.error)}catch(w){l(w)}}}),n?.signal?.addEventListener("abort",()=>{f(n?.signal?.reason)});let h=n?.timeout??Ew,g=()=>f(A.fromError(D.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(p,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let _=w=>{let x=this._responseHandlers.get(p);x?x(w):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,_),this._enqueueTaskMessage(y,{type:"request",message:m,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(p),l(w)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(_=>{this._cleanupTimeout(p),l(_)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Ts,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},Rs,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Up,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||{},[er]: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||{},[er]: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||{},[er]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=Su(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=zu(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=Su(e);this._notificationHandlers.set(n,o=>{let s=zu(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"&&su(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new A(D.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 A(D.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new A(D.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 A(D.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=so.parse({method:"notifications/tasks/status",params:a});await this.notification(c),tr(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 A(D.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(tr(a.status))throw new A(D.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=so.parse({method:"notifications/tasks/status",params:c});await this.notification(u),tr(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Tm(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Em(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];Tm(i)&&Tm(s)?r[o]={...i,...s}:r[o]=s}return r}var Ey=Od(gd(),1),Iy=Od(Ty(),1);function DT(){let t=new Ey.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Iy.default)(t),t}var Ti=class{constructor(e){this._ajv=e??DT()}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)}}};var Ei=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(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))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},co,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},mn,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)}};function Ry(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 Ny(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 Ii=class extends Hs{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ao.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 Ti,this.setRequestHandler(cu,n=>this._oninitialize(n)),this.setNotificationHandler(uu,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(gu,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=ao.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Ei(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Em(this._capabilities,e)}setRequestHandler(e,r){let o=Qt(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=un(o);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=Xt(pn,c);if(!l.success){let f=l.error instanceof Error?l.error.message:String(l.error);throw new A(D.InvalidParams,`Invalid tools/call request: ${f}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let f=Xt(dn,p);if(!f.success){let h=f.error instanceof Error?f.error.message:String(f.error);throw new A(D.InvalidParams,`Invalid task creation result: ${h}`)}return f.data}let m=Xt(Ds,p);if(!m.success){let f=m.error instanceof Error?m.error.message:String(m.error);throw new A(D.InvalidParams,`Invalid tools/call result: ${f}`)}return m.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){Ny(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&Ry(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:Np.includes(r)?r:nu,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"},$s)}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(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))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},yu,r):this.request({method:"sampling/createMessage",params:e},co,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},mn,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},mn,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new A(D.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof A?i:new A(D.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},_u,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"})}};var Cy=Symbol.for("mcp.completable");function kd(t){return!!t&&typeof t=="object"&&Cy in t}function jy(t){return t[Cy]?.complete}var Oy;(function(t){t.Completable="McpCompletable"})(Oy||(Oy={}));var LT=/^[A-Za-z0-9._-]{1,128}$/;function qT(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"),!LT.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 UT(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 Sd(t){let e=qT(t);return UT(t,e.warnings),e.isValid}var Ri=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 Ni=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 Ii(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Ri(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(lr(Zs)),this.server.assertCanSetRequestHandler(lr(pn)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Zs,()=>({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=cn(r.inputSchema);return o?ku(o,{strictUnions:!0,pipeStrategy:"input"}):FT})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=cn(r.outputSchema);o&&(n.outputSchema=ku(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(pn,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new A(D.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new A(D.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 A(D.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if(s==="required"&&!o)throw new A(D.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 A&&n.code===D.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=cn(e.inputSchema)??e.inputSchema,i=await gs(s,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=ys(a);throw new A(D.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 A(D.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=cn(e.outputSchema),s=await gs(o,r.structuredContent);if(!s.success){let i="error"in s?s.error:"Unknown error",a=ys(i);throw new A(D.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(p=>setTimeout(p,l));let d=await n.taskStore.getTask(c);if(!d)throw new A(D.InternalError,`Task ${c} not found during polling`);u=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(lr(Ls)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Ls,async e=>{switch(e.params.ref.type){case"ref/prompt":return Kp(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Wp(e),this.handleResourceCompletion(e,e.params.ref);default:throw new A(D.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new A(D.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new A(D.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return qo;let s=Qt(n.argsSchema)?.[e.params.argument.name];if(!kd(s))return qo;let i=jy(s);if(!i)return qo;let a=await i(e.params.argument.value,e.params.context);return My(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 qo;throw new A(D.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(e.params.argument.name);if(!o)return qo;let s=await o(e.params.argument.value,e.params.context);return My(s)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(lr(Os)),this.server.assertCanSetRequestHandler(lr(Cs)),this.server.assertCanSetRequestHandler(lr(js)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Os,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(Cs,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(js,async(e,r)=>{let n=new URL(e.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new A(D.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 A(D.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(lr(As)),this.server.assertCanSetRequestHandler(lr(Ms)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(As,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?VT(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ms,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new A(D.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new A(D.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let o=cn(n.argsSchema),s=await gs(o,e.params.arguments);if(!s.success){let c="error"in s?s.error:"Unknown error",u=ys(c);throw new A(D.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:Cr(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=Cr(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 Ye?c._def?.innerType:c;return kd(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,o,s,i,a,c,u){Sd(e);let l={title:r,description:n,inputSchema:Ay(o),outputSchema:Ay(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:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&Sd(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=Cr(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=Cr(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.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(zd(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!zd(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 FT={type:"object",properties:{}};function Zy(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Dy(t){return"_def"in t||"_zod"in t||Zy(t)}function zd(t){return typeof t!="object"||t===null||Dy(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(Zy)}function Ay(t){if(t){if(zd(t))return Cr(t);if(!Dy(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function VT(t){let e=Qt(t);return e?Object.entries(e).map(([r,n])=>{let o=cp(n),s=up(n);return{name:r,description:o,required:!s}}):[]}function lr(t){let r=Qt(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=un(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function My(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var qo={completion:{values:[],hasMore:!1}};import qy from"node:process";var HT=10*1024*1024,Oi=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??HT}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
42
|
-
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),BT(r)}clear(){this._buffer=void 0}};function BT(t){return
|
|
43
|
-
`}var Ci=class{constructor(e=qy.stdin,r=qy.stdout,n){this._stdin=e,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new Oi({maxBufferSize:n?.maxBufferSize})}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=Ly(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{readFileSync as KE}from"node:fs";import{readFile as WE}from"node:fs/promises";import{writeFileSync as lE,mkdirSync as dE,existsSync as t_}from"node:fs";import{createHash as fE}from"node:crypto";import ji from"node:path";function Fy(t,e=0){if(!t||typeof t!="object"||e>6)return null;let r=t;for(let n of["layers","shapes","children","artboards","widgets","nodes"]){let o=r[n];if(Array.isArray(o)&&o.length)return o}for(let n of Object.values(r))if(n&&typeof n=="object"){let o=Fy(n,e+1);if(o)return o}return null}var Vy=/^(frame|group|编组|矩形|椭圆|形状|切片|蒙版|layer|rect|image|vector|line|subtract|union|intersect|difference)[\s_-]?\d*$/i,JT=/^(蒙版|mask|切片|slice)/i,KT=t=>Vy.test(t.trim())&&!JT.test(t.trim()),WT=/^(subtract|union|intersect|difference)([\s_-]?\d*)?$/i,Pd=t=>1+(Array.isArray(t?.layers)?t.layers.reduce((e,r)=>e+Pd(r),0):0);function Nn(t){if(!t||typeof t!="object"||typeof t.value!="string")return t;let e=/rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/.exec(t.value);if(!e)return t;let r=Number(e[1]),n=Number(t.a);if(Number.isFinite(n)&&Math.abs(n-r)>.001){let{a:o,...s}=t;return s}return t}function Hy(t){let e=t.ddsOriginFrame;return e&&Number(e.width)>0&&Number(e.height)>0?{x:Math.round(Number(e.x)||0),y:Math.round(Number(e.y)||0),width:Math.round(Number(e.width)||0),height:Math.round(Number(e.height)||0)}:{x:Math.round(Number(t.left??0)),y:Math.round(Number(t.top??0)),width:Math.round(Number(t.width??0)),height:Math.round(Number(t.height??0))}}function GT(t){let e=Array.isArray(t.points)&&t.points.length?t.points.map(n=>Number(n?.cornerRadius??0)||0):Array.isArray(t.radius)?t.radius.map(n=>Number(n)||0):null;if(!e||!e.some(Boolean))return null;let r=n=>e[n]??e[0]??0;return{topLeft:r(0),topRight:r(1),bottomRight:r(2),bottomLeft:r(3)}}function YT(t){let e=t.font;if(!e||typeof e!="object")return null;let r=String(e.font||e.displayName||""),n=Array.isArray(e.styles)?e.styles[0]:null,o=String(n?.decorationLine||""),s={0:"top",1:"middle",2:"bottom"},i={size:Number(e.size??n?.size??0)||void 0,name:e.displayName||void 0,postScriptName:e.font||void 0,fontWeight:/bold|heavy|black/i.test(r)?700:void 0,lineHeight:e.line!=null?{unit:"PIXELS",value:Number(e.line)||0}:void 0,letterSpacing:{value:Number(t.characterSpacing??e.kerning??0)||0},align:typeof e.align=="string"?e.align:void 0,verticalAlignment:s[Number(e.verticalAlignment)]||"top",italic:/italic|oblique/i.test(r)||void 0,underline:o==="underline"||void 0,linethrough:o==="line-through"||void 0},a=Nn(e.color)??Nn(n?.color);return{value:String(e.content??n?.content??""),style:{content:String(e.content??n?.content??""),color:a,font:i}}}function By(t,e){let r={id:t.id,name:t.name,type:t.type,frame:Hy(t),visible:t.isVisible!==!1};typeof t.opacity=="number"&&(r.opacity=t.opacity/100);let n=t.ddsImage?.imageUrl;n&&(t.exportable===!0||t.type==="bitmap")?(r.image={imageUrl:n},t.exportable===!0&&(r.hasExportImage=!0)):t.exportable===!0?r.hasExportImage=!0:t.image?.svgUrl&&(r.image=t.image);let o={};Array.isArray(t.fills)&&t.fills.length&&(o.fills=t.fills.filter(a=>a.isEnabled!==!1).map(a=>{let c={...a};return c.gradient?.colorStops&&(c.gradient={...c.gradient,stops:c.gradient.colorStops.map(u=>({position:u.position,color:Nn(u.color)}))}),c.color=Nn(c.color),c})),Array.isArray(t.borders)&&t.borders.length&&(o.borders=t.borders.filter(a=>a.isEnabled!==!1).map(a=>({...a,width:a.thickness??a.width,lineAlignment:a.position==="\u5916\u8FB9\u6846"?"outside":a.position==="\u5185\u8FB9\u6846"?"inside":"center",color:Nn(a.color)}))),Array.isArray(t.shadows)&&t.shadows.length&&(o.shadows=t.shadows.filter(a=>a.isEnabled!==!1).map(a=>({...a,color:Nn(a.color)}))),Object.keys(o).length&&(r.style=o);let s=GT(t);if(s&&(r.radius=s),t.type==="text"){let a=YT(t);a&&(r.text=a)}let i=e.get(t.id);return i?.length&&(r.layers=i.map(a=>By(a,e))),r}function Td(t){if(!t||typeof t!="object"||t.artboard)return t;let e=t.info;if(!Array.isArray(e)||!e.length)return t;let r=new Map;for(let l of e)l?.id!=null&&r.set(l.id,l);let n=new Map,o=[];for(let l of e)if(!(!l||typeof l!="object"))if(l.parentID==null||!r.has(l.parentID))o.push(l);else{let d=n.get(l.parentID);d?d.push(l):n.set(l.parentID,[l])}if(!o.length)return t;let[s,...i]=o;i.length&&n.set(s.id,[...n.get(s.id)??[],...i]);let a=By(s,n),{info:c,...u}=t;return{...u,artboard:{name:s.name,frame:Hy(s),layers:a?.layers||[]}}}var Uy=t=>{let e=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*1\)$/.exec(t.trim());return e?"#"+[e[1],e[2],e[3]].map(r=>(+r).toString(16).padStart(2,"0")).join(""):t};function XT(t){let e=t.frame||t.rect||t.boundingBox||t,r=Math.round(Number(e.x??e.left??0)),n=Math.round(Number(e.y??e.top??0)),o=Math.round(Number(e.width??e.w??0)),s=Math.round(Number(e.height??e.h??0)),i=t.style||t.css||{},a=String(t.type??t.shapeType??(t.text!=null?"text":"rect")).toLowerCase(),c=t.text&&typeof t.text=="object"?t.text.style:null,u={type:/text|label|font/i.test(a)?"text":/image|bitmap|img/i.test(a)?"image":"rect",x:r,y:n,w:o,h:s};t.name&&(t.hasExportImage||!KT(String(t.name)))&&(u.name=t.name),t.hasExportImage?u.hasExportImage=!0:t.image?.imageUrl&&(u.imageUrl=t.image.imageUrl);let l=t.opacity==null?1:Number(t.opacity),d=Number.isFinite(l)?l:1,p=x=>Number(x?.opacity??1)||0,m=x=>{if(x==null)return 1;let $=x.color?.a??x.a;return Number($??1)||0},f=(x,$)=>{if(typeof x!="string")return;let P=m($),J=p($),H=P*d*(Math.abs(J-P)>.001?J:1);if(H>=1)return Uy(x);let k=Number(H.toFixed(4)),O=/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)$/.exec(x.trim());if(O)return`rgba(${O[1]},${O[2]},${O[3]},${k})`;let E=/^rgba?\((\d+(?:\.\d+)?)%,\s*(\d+(?:\.\d+)?)%,\s*(\d+(?:\.\d+)?)%(?:,\s*([\d.]+))?\)$/.exec(x.trim());if(E){let re=K=>Math.min(255,Math.max(0,Math.round(parseFloat(K)*2.55)));return`rgba(${re(E[1])},${re(E[2])},${re(E[3])},${k})`}let F=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(x.trim());if(F){let re=F[1];return re.length===3&&(re=re.split("").map(K=>K+K).join("")),`rgba(${parseInt(re.slice(0,2),16)},${parseInt(re.slice(2,4),16)},${parseInt(re.slice(4,6),16)},${k})`}return console.error(`[normalize] applyAlpha \u65E0\u6CD5\u89E3\u6790\u989C\u8272\uFF1A${x}\uFF0C\u900F\u660E\u5EA6 alpha=${k} \u672A\u53E0\u5165`),x};if(u.type==="text"){let x=t.text;u.text=(typeof x=="string"?x:c?.content??x?.value??"")||void 0;let $=c?.font??{};u.fontSize=Math.round(Number($.size??$.fontSize??0))||void 0,u.fontWeight=Number($.fontWeight??$.weight??0)||void 0,u.fontFamily=$.name??$.fontFamily??$.postScriptName??void 0,$.lineHeight&&(u.lineHeight=$.lineHeight.unit==="AUTO"?"auto":Math.round(Number($.lineHeight.value))||void 0),$.letterSpacing&&Number($.letterSpacing.value)&&(u.letterSpacing=Math.round(Number($.letterSpacing.value)*10)/10);let P=$.align?String($.align).toLowerCase():"";P&&P!=="left"&&(u.align=P);let J=$.verticalAlignment?String($.verticalAlignment).toLowerCase():"";J&&J!=="top"&&(u.verticalAlign=J),$.italic&&(u.italic=!0),$.underline&&(u.underline=!0),$.linethrough&&(u.linethrough=!0);let H=c?.color?.value??i.fills?.[0]?.color?.value,k=f(H,c?.color??i.fills?.[0]);k&&(u.color=k)}else{let x=i.fills?.[0];if(x?.type==="gradient"&&x.gradient?.stops){let H=x.gradient.stops.map(k=>({color:f(k.color?.value,{...k.color,opacity:x.opacity}),position:Math.round(Number(k.position)*1e3)/1e3})).filter(k=>k.color);H.length&&(u.gradient={stops:H})}else{let H=f(x?.color?.value,x);H&&(u.fill=H)}let $=H=>{if(H==null)return null;let k=Math.round(Number(H.topLeft??0)||0),O=Math.round(Number(H.topRight??0)||0),E=Math.round(Number(H.bottomLeft??0)||0),F=Math.round(Number(H.bottomRight??0)||0);return k||O||E||F?{tl:k,tr:O,bl:E,br:F}:null},P=(t.paths||[]).map(H=>$(H?.radius)).filter(Boolean);if(P.length||(P=[$(t.radius)].filter(Boolean)),P.length){let H=P.every(E=>E.tl===P[0].tl&&E.tr===P[0].tr&&E.bl===P[0].bl&&E.br===P[0].br),k=P[0],O={topLeft:k.tl,topRight:k.tr,bottomLeft:k.bl,bottomRight:k.br};H&&k.tl===k.tr&&k.tr===k.bl&&k.bl===k.br?u.radius=k.tl:(u.borderRadius=O,H||(u.radius=Math.max(k.tl,k.tr,k.bl,k.br)))}let J=(i.borders||[]).find(H=>H.isEnabled!==!1);if(J){let H=f(J.color?.value,{...J.color,opacity:J.opacity});H&&(u.border={color:H,width:Math.round(Number(J.width??0)*100)/100,alignment:J.lineAlignment==="outside"?"outside":J.lineAlignment==="center"?"center":"inside"})}}let h=(i.shadows||[]).filter(x=>x&&x.isEnabled!==!1&&x.color?.value),g=x=>({color:Uy(String(x.color.value)),x:Math.round(Number(x.x??0)),y:Math.round(Number(x.y??0)),blur:Math.round(Number(x.blur??0)),spread:Math.round(Number(x.spread??0))}),y=h.find(x=>!x.inset),_=h.find(x=>x.inset);y&&(u.shadow=g(y)),_&&(u.innerShadow=g(_));let w=!!(u.fill||u.gradient||u.color);return d<1&&!w&&(u.opacity=Number(d.toFixed(4))),u}function Jy(t){let e=Td(t),r=Fy(e)||[],n=[],o=0,s=0,i=0,a=0,c=k=>!!(k.fill||k.gradient||k.color||k.text||k.imageUrl||k.hasExportImage||k.border||k.shadow||k.innerShadow),u=k=>!Vy.test(k.trim()),l=(k,O)=>{for(let E of k){if(!E||typeof E!="object")continue;s++;let F=E;if(F.visible===!1)continue;let re=String(F.name||"");if(/备份|backup/i.test(re)){i+=Pd(F);continue}let K=re&&u(re)?[...O,re]:O,Ve=XT(F);Ve.w>0&&Ve.h>0&&(c(Ve)?(O.length&&(Ve.parentPath=O.join("/")),n.push(Ve)):o++);let ce=F.layers;if(!(!Array.isArray(ce)||!ce.length)){if(WT.test(re.trim())){a+=ce.reduce((j,oe)=>j+Pd(oe),0);continue}l(ce,K)}}};l(r,[]);let d=n,p=0,m=e?.artboard?.frame,f=Math.round(Number(m?.width??0)),h=Math.round(Number(m?.height??0));f>0&&h>0&&(d=d.filter(k=>{let O=k.x+k.w<=0||k.y+k.h<=0||k.x>=f||k.y>=h;return O&&p++,!O}));let g=k=>k.hasExportImage?JSON.stringify(["slice",k.x,k.y,k.w,k.h]):JSON.stringify({...k,name:void 0}),y=new Map;d.forEach((k,O)=>{let E=g(k),F=y.get(E);F?F.push(O):y.set(E,[O])});let _=new Map;for(let[k,O]of y){let E=O.filter(F=>d[F].type==="image");_.set(k,E.length?E[E.length-1]:O[O.length-1])}let w=0;d=d.filter((k,O)=>{let E=_.get(g(k))===O;return E||w++,E});let x=0;if(process.env.LANHU_PRUNE_OCCLUDED!=="0"){let k=E=>typeof E=="string"&&(/^#[0-9a-f]{6}$/i.test(E)||/^rgba\(\d+,\s*\d+,\s*\d+,\s*1\)$/.test(E)),O=new Array(d.length).fill(!1);d.forEach((E,F)=>{if(!(E.type==="text"||E.hasExportImage||E.imageUrl))for(let re=F+1;re<d.length;re++){let K=d[re];if(!(K.type==="text"||!k(K.fill))&&K.x<=E.x&&K.y<=E.y&&K.x+K.w>=E.x+E.w&&K.y+K.h>=E.y+E.h){O[F]=!0;break}}}),d=d.filter((E,F)=>O[F]?(x++,!1):!0)}let $=Number(process.env.LANHU_MIN_VISIBLE_FRACTION??.25),P=0;$>0&&f>0&&h>0&&(d=d.filter(k=>{if(k.type==="text"||k.hasExportImage||k.imageUrl)return!0;let O=Math.min(k.x+k.w,f)-Math.max(k.x,0),E=Math.min(k.y+k.h,h)-Math.max(k.y,0);return Math.max(0,O)*Math.max(0,E)/(k.w*k.h)>=$?!0:(P++,!1)}));let J=0;if(process.env.LANHU_PRUNE_FRAGMENTS!=="0"){let k=new Map;d.forEach((E,F)=>{if(E.type==="text"||E.hasExportImage||E.imageUrl||E.w>24||E.h>8||!E.parentPath)return;let re=k.get(E.parentPath);re?re.push(F):k.set(E.parentPath,[F])});let O=new Set;for(let E of k.values()){E.sort((K,Ve)=>d[K].y-d[Ve].y||d[K].x-d[Ve].x);let F=[E[0]],re=()=>{if(F.length>=4){F.sort((ce,j)=>d[ce].x-d[j].x);let K=[F[0]],Ve=()=>{if(K.length>=4){let ce=K.map(j=>d[j].w);Math.max(...ce)/Math.min(...ce)>=1.3&&(K.forEach(j=>O.add(j)),J+=K.length)}K=[]};for(let ce=1;ce<F.length;ce++){let j=d[K[K.length-1]],Ee=d[F[ce]].x-(j.x+j.w);Ee<=6&&Ee>=-6?K.push(F[ce]):(Ve(),K=[F[ce]])}Ve()}F=[]};for(let K=1;K<E.length;K++)Math.abs(d[E[K]].y-d[F[0]].y)<=2?F.push(E[K]):(re(),F=[E[K]]);re()}O.size&&(d=d.filter((E,F)=>!O.has(F)))}let H={rawLayerCount:s,totalLayerCount:d.length,droppedLayerCount:o,dedupedLayerCount:w,outsideCanvasLayerCount:p,occludedLayerCount:x,sliverLayerCount:P,fragmentLayerCount:J,backupLayerCount:i,booleanOperandLayerCount:a,payloadBytes:Buffer.byteLength(JSON.stringify(d)),docName:e?.artboard?.name??e?.document?.name??e?.name??e?.title??void 0};return{layers:d,meta:H}}import Ky from"sharp";async function Wy(t,e,r){let n=Ky(t);return e>0&&r>0?n=n.resize(Math.round(e),Math.round(r),{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}):n=n.resize({width:1024,height:1024,fit:"inside",withoutEnlargement:!0}),n.flatten({background:"#ffffff"}).jpeg({quality:80}).toBuffer()}var QT=Number(process.env.LANHU_VISION_MAX_EDGE)||1568;async function Ed(t,e=QT){return Ky(t).resize({width:e,height:e,fit:"inside",withoutEnlargement:!0}).flatten({background:"#ffffff"}).jpeg({quality:85}).toBuffer()}import{createHash as eE}from"node:crypto";import tE from"sharp";var On=64*1024*1024,Gy=5,Yy=3,rE=["lanhuapp.com","aliyuncs.com"],nE=new Set(["png","jpeg","jpg","webp","gif","avif","tiff","ico"]),pe=class extends Error{constructor(r,n){super(n);this.code=r;this.name="AssetGuardError"}code};function oE(t){let e=t.toLowerCase(),r=(process.env.LANHU_ALLOWED_ASSET_HOSTS||"").split(",").map(n=>n.trim()).filter(Boolean);for(let n of[...rE,...r])if(e===n||e.endsWith(`.${n}`))return!0;return!1}function sE(t,e){let r=new URL(t).hostname.endsWith("lanhuapp.com"),n={Referer:"https://lanhuapp.com/","User-Agent":"lanhu-design-mcp/1"};return r&&e&&(n.Cookie=e),n}async function Xy(t,e={}){let r;for(let n=1;n<=Yy;n++)try{return await iE(t,e)}catch(o){let s=o instanceof pe?o:new pe("download_failed",String(o)),i=s.code==="network_error"||s.code==="http_429"||/^http_5/.test(s.code);if(r=s,!i||n>=Yy)throw s;await new Promise(a=>setTimeout(a,100*n))}throw r}async function iE(t,e){let r=t;for(let n=0;n<=Gy;n++){let o=new URL(r);if(o.protocol!=="https:")throw new pe("insecure_url",`\u5207\u56FE\u8D44\u6E90\u5FC5\u987B\u8D70 https\uFF1A${r}`);if(o.username||o.password)throw new pe("credentials_in_url",`\u8D44\u6E90 URL \u643A\u5E26\u51ED\u636E\uFF0C\u5DF2\u62D2\u7EDD\uFF1A${o.hostname}`);if(!oE(o.hostname))throw new pe("host_not_allowed",`\u8D44\u6E90\u4E3B\u673A\u4E0D\u5728\u767D\u540D\u5355\u5185\uFF1A${o.hostname}`);let s;try{s=await fetch(r,{headers:sE(r,e.cookie),redirect:"manual"})}catch(l){throw new pe("network_error",`\u8BF7\u6C42\u5931\u8D25\uFF1A${l?.message||l}`)}if(s.status>=300&&s.status<400){let l=s.headers.get("location");if(!l)throw new pe("redirect_no_location",`\u91CD\u5B9A\u5411\u7F3A\u5C11 Location\uFF08HTTP ${s.status}\uFF09`);r=new URL(l,r).toString();continue}if(s.status===401||s.status===403)throw new pe("access_denied",`\u8D44\u6E90\u88AB\u62D2\u7EDD\uFF08HTTP ${s.status}\uFF09\uFF1A\u767B\u5F55\u6001\u6216\u9879\u76EE\u6743\u9650\u4E0D\u8DB3`);if(s.status===429||s.status>=500)throw new pe(`http_${s.status}`,`\u8D44\u6E90\u7AEF\u6682\u4E0D\u53EF\u7528\uFF08HTTP ${s.status}\uFF09`);if(!s.ok)throw new pe(`http_${s.status}`,`\u8D44\u6E90\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${s.status}\uFF09`);if(Number(s.headers.get("content-length")||0)>On)throw new pe("too_large",`\u8D44\u6E90\u8D85\u8FC7 ${Math.round(On/1024/1024)}MiB \u4E0A\u9650`);let a=[],c=0,u=s.body?.getReader();if(!u)throw new pe("network_error","\u54CD\u5E94\u65E0\u53EF\u8BFB\u6B63\u6587");for(;;){let{done:l,value:d}=await u.read();if(l)break;if(c+=d.byteLength,c>On)throw await u.cancel(),new pe("too_large",`\u8D44\u6E90\u8D85\u8FC7 ${Math.round(On/1024/1024)}MiB \u4E0A\u9650`);a.push(Buffer.from(d))}return{bytes:Buffer.concat(a),contentType:s.headers.get("content-type")||"",finalUrl:r}}throw new pe("too_many_redirects",`\u91CD\u5B9A\u5411\u8D85\u8FC7 ${Gy} \u6B21`)}async function Qy(t){if(!t||t.length===0)throw new pe("empty_asset","\u5207\u56FE\u5185\u5BB9\u4E3A\u7A7A");if(t.length>On)throw new pe("too_large",`\u5207\u56FE\u8D85\u8FC7 ${Math.round(On/1024/1024)}MiB \u4E0A\u9650`);let e=t.subarray(0,1024).toString("latin1").trimStart().toLowerCase();if(e.startsWith("<!doctype html")||e.startsWith("<html"))throw new pe("html_response","\u670D\u52A1\u5668\u8FD4\u56DE\u4E86\u7F51\u9875\u800C\u975E\u56FE\u7247");let r=eE("sha256").update(t).digest("hex");return e.startsWith("<?xml")||e.startsWith("<svg")||e.startsWith("<!--")||e.charCodeAt(0)===65279?{...cE(t),sha256:r,bytes:t.length}:{...await aE(t),sha256:r,bytes:t.length}}async function aE(t){let e;try{e=await tE(t).metadata()}catch{throw new pe("invalid_image","\u5185\u5BB9\u4E0D\u662F\u5B8C\u6574\u7684\u53D7\u652F\u6301\u56FE\u7247")}let r=String(e.format||"").toLowerCase();if(!nE.has(r))throw new pe("unsupported_format",`\u89E3\u7801\u51FA\u7684\u683C\u5F0F\u4E0D\u652F\u6301\u843D\u76D8\uFF1A${r||"\u672A\u77E5"}`);return{format:r==="jpg"?"jpeg":r,width:e.width,height:e.height,isVector:!1,hasAlpha:e.hasAlpha}}function cE(t){let e=t.toString("utf8");if(/<!\s*(?:DOCTYPE|ENTITY)|<\?xml-stylesheet/i.test(e))throw new pe("unsafe_svg","SVG \u542B DTD/ENTITY/\u5916\u90E8\u6837\u5F0F\u8868\uFF0C\u5DF2\u62D2\u7EDD");if(!/<svg[\s>]/i.exec(e))throw new pe("invalid_image","\u5185\u5BB9\u4E0D\u662F SVG \u56FE\u7247");if(/<\s*(script|foreignObject|iframe|object|embed|audio|video|animate|animateMotion|animateTransform|set)\b/i.test(e))throw new pe("unsafe_svg","SVG \u542B\u811A\u672C\u6216\u4E3B\u52A8\u5185\u5BB9\u5143\u7D20\uFF0C\u5DF2\u62D2\u7EDD");if(/\son[a-z]+\s*=/i.test(e))throw new pe("unsafe_svg","SVG \u542B\u4E8B\u4EF6\u5C5E\u6027\uFF0C\u5DF2\u62D2\u7EDD");let n=/(?:xlink:)?href\s*=\s*["'](?!#)([^"']*)/ig;for(let i of e.matchAll(n)){let a=i[1].trim();if(!a.startsWith("#"))throw new pe("unsafe_svg",`SVG \u542B\u5916\u90E8\u5F15\u7528\uFF1A${a.slice(0,80)}`)}if(/@import|expression\s*\(|javascript\s*:/i.test(e))throw new pe("unsafe_svg","SVG \u542B\u4E3B\u52A8\u6837\u5F0F\uFF0C\u5DF2\u62D2\u7EDD");for(let i of e.matchAll(/url\s*\(\s*['"]?([^)'"]+)/gi)){let a=i[1].trim();if(!a.startsWith("#"))throw new pe("unsafe_svg",`SVG \u542B\u5916\u90E8 paint \u5F15\u7528\uFF1A${a.slice(0,80)}`)}let{width:o,height:s}=uE(e);return{format:"svg",width:o,height:s,isVector:!0}}function uE(t){let e=o=>{let s=new RegExp(`<svg[^>]*\\b${o}=["']\\s*(\\d+(?:\\.\\d+)?)px?["']`,"i").exec(t),i=s?Number(s[1]):NaN;return Number.isFinite(i)&&i>0?i:void 0},r=e("width"),n=e("height");if(!r||!n){let o=/viewBox=["']\s*[\d.eE+-]+[\s,]+[\d.eE+-]+[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)["']/i.exec(t);o&&(r=r||Number(o[1]),n=n||Number(o[2]))}return{width:r,height:n}}function e_(t,e,r,n=4,o="png"){if(!t||!e||!r)return{};let s=Math.max(1,Math.round(e)),i=Math.max(1,Math.round(r)),a=s*n,c=i*n,u=(p,m)=>{p=Math.max(1,Math.round(p)),m=Math.max(1,Math.round(m));let f=p===a&&m===c?"":`resize,w_${p},h_${m}/`,h=o==="png"?"format,png":`format,${o}`;return`${t}?x-oss-process=image/${f}${h}`},l=p=>Math.floor(p+.5),d=a/4;return{original:o==="png"?t:`${t}?x-oss-process=image/format,${o}`,"1x":u(s*1,i*1),"2x":u(s*2,i*2),"3x":u(s*3,i*3),ios_1x:u(l(d*1),l(c/4*1)),ios_2x:u(l(d*2),l(c/4*2)),ios_3x:u(l(d*3),l(c/4*3)),android_mdpi:u(l(a/4*1),l(c/4*1)),android_hdpi:u(l(a/4*1.5),l(c/4*1.5)),android_xhdpi:u(l(a/4*2),l(c/4*2)),android_xxhdpi:u(l(a/4*3),l(c/4*3)),android_xxxhdpi:u(a,c)}}var Cn="https://lanhuapp.com",Ai="\u65B9\u5F0F1\uFF1A\u6D4F\u89C8\u5668\u767B\u5F55\u84DD\u6E56\u540E\u6309 F12 \u2192 Network \u2192 \u70B9\u4EFB\u610F\u8BF7\u6C42 \u2192 \u590D\u5236 Cookie \u5934\u6574\u4E32\uFF0C\u5199\u5165 .mcp-local/lanhu.cookie\uFF08\u6216\u8BBE LANHU_COOKIE \u73AF\u5883\u53D8\u91CF\uFF09\uFF1B\u65B9\u5F0F2\uFF1A\u53CC\u51FB lanhu-login.bat\uFF08\u6216\u8FD0\u884C npm run login\uFF09\uFF0C\u6D4F\u89C8\u5668\u767B\u5F55\u540E\u6309 Enter \u81EA\u52A8\u5199\u5165 cookie\u3002\u5B8C\u6210\u540E\u8BA9 AI \u91CD\u8BD5\u3002";function pE(t){if(t.teamId)return t.teamId;if(t.url){let{teamId:e}=Di(t.url);if(e&&e!=="0")return e}throw new Error("\u65E0\u6CD5\u5B9A\u4F4D\u56E2\u961F\uFF1A\u8BF7\u4F20 teamId\uFF08\u6765\u81EA lanhu_list_teams\uFF09\u6216 url\uFF08\u84DD\u6E56\u94FE\u63A5\u63D0 tid\uFF09\uFF1B\u7EAF cookie \u4E0D\u5E26 teamId/url \u65F6\u65E0\u6CD5\u5217\u76EE\u5F55")}async function n_(t){let e=await fetch(`${Cn}/api/account/user_teams?need_open_related=true`,{headers:Fo(t)});if(!e.ok)return{status:e.status,teams:[]};let r=await e.json();return{status:e.status,teams:r?.result||r?.data||[]}}async function o_(t){let e=dr(t),{status:r,teams:n}=await n_(e);return i_(r,"auth","\u56E2\u961F\u5217\u8868"),{teamCount:n.length,teams:n.map(o=>({teamId:o.id,name:o.name,role:o.role?.display||o.role?.name||"",isOwner:!!o.is_team_owner,memberNum:Number(o.member_num)||0}))}}function Di(t){let e=r=>{let n=new RegExp(`[?&]${r}=([a-f0-9-]+)`,"i").exec(t);return n?n[1]:null};return{projectId:e("project_id")||e("pid"),imageId:e("image_id"),teamId:e("tid")||"0"}}function dr(t){if(!t.cookie)throw new Error(`\u9700\u8981\u84DD\u6E56\u767B\u5F55\u51ED\u8BC1\uFF08\u4E8C\u9009\u4E00\uFF09\uFF1A${Ai}`);return t.cookie}function s_(t){if(!t)throw new Error("\u9700\u8981\u84DD\u6E56 URL \u6216\u9879\u76EE UUID");if(/[/?]/.test(t)){let{projectId:e}=Di(t);if(e)return e}if(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(t))return t;throw new Error(`\u65E0\u6CD5\u8BC6\u522B\u7684\u9879\u76EE\u6807\u8BC6\uFF1A${t}\uFF08\u5E94\u4E3A\u84DD\u6E56 URL \u6216\u9879\u76EE UUID\uFF09`)}function Fo(t){return{Cookie:t,Accept:"application/json, text/plain, */*",Referer:"https://lanhuapp.com/web/"}}function r_(t,e){let r=new URL(t).hostname;return r==="lanhuapp.com"||r.endsWith(".lanhuapp.com")?Fo(e):{Referer:"https://lanhuapp.com/"}}var Mi=class extends Error{constructor(r,n,o){super(o);this.status=r;this.scope=n;this.hint=o;this.name="LanhuHttpError"}status;scope;hint};function i_(t,e,r){if(!(t>=200&&t<300))throw t===401?e==="auth"?new Mi(401,"auth",`\u84DD\u6E56\u9274\u6743\u5931\u8D25\uFF08HTTP 401\uFF09\uFF1Acookie \u5DF2\u8FC7\u671F\u6216\u7F3A\u5931\u5173\u952E\u5B57\u6BB5\u3002${Ai}`):new Mi(401,"resource",`\u65E0\u6743\u8BBF\u95EE${r}\uFF08HTTP 401\uFF09\uFF1Acookie \u4ECD\u53EF\u80FD\u6709\u6548\uFF0C\u4F46\u8BE5\u8D44\u6E90\u672A\u5BF9\u4F60\u5206\u4EAB\u3002\u91CD\u65B0\u767B\u5F55\u65E0\u6548\uFF0C\u8BF7\u8054\u7CFB\u8BBE\u8BA1\u8005\u5F00\u901A\u6743\u9650\uFF0C\u6216\u6362\u4E00\u4E2A\u6709\u6743\u9650\u7684${r}\u3002`):new Error(`\u8BF7\u6C42${r}\u5931\u8D25\uFF1AHTTP ${t}`)}function Zi(t,e,r){i_(t.status,e,r)}async function a_(t){if(!t.cookie)return{ok:!1,status:0,reason:"no_cookie",hint:`\u672A\u914D\u7F6E\u84DD\u6E56 cookie\u3002${Ai}`};try{let{status:e,teams:r}=await n_(t.cookie);return e>=200&&e<300?{ok:!0,teamCount:r.length,teams:r.map(n=>({teamId:n.id,name:n.name}))}:{ok:!1,status:e,reason:e===401?"cookie_expired":`http_${e}`,hint:e===401?`cookie \u5DF2\u8FC7\u671F\u6216\u65E0\u6548\u3002${Ai}`:`\u84DD\u6E56\u8FD4\u56DE HTTP ${e}\uFF0C\u7A0D\u540E\u91CD\u8BD5\u6216\u68C0\u67E5\u7F51\u7EDC\u3002`}}catch(e){return{ok:!1,status:0,reason:"network_error",hint:`\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25\uFF1A${e?.message||e}`}}}function mE(t,e){let n=/charset=([\w-]+)/i.exec(e||"")?.[1]?.toLowerCase(),o=a=>{try{let c=new TextDecoder(a,{fatal:!0}).decode(t);return JSON.parse(c)}catch{return null}};if(n&&n!=="iso-8859-1"){let a=o(n);if(a!=null)return a}let s=o("utf-8");if(s!=null)return s;let i=new TextDecoder("iso-8859-1").decode(t);if(/[-ÿ]/.test(i)&&!/[一-鿿]/.test(i)){let a=o("gbk");if(a!=null)return a}return JSON.parse(i)}async function Uo(t,e,r,n){let o=Fo(r),s=await fetch(`${Cn}/api/project/image?pid=${e}&image_id=${t}`,{headers:o});Zi(s,"resource","\u8BBE\u8BA1\u7A3F");let i=await s.json(),a=i?.result||i?.data||{},c=a.versions||[],u=c[0]?.json_url,l=[],d={rawLayerCount:0,totalLayerCount:0},p=a.width||0,m=a.height||0,f=[];if(u){let g=await fetch(u,{headers:r_(u,r)});if(!g.ok)throw new Error(`\u4E0B\u8F7D\u8BBE\u8BA1\u7A3F\u6807\u6CE8\u6570\u636E\u5931\u8D25\uFF1AHTTP ${g.status}\uFF08${u}\uFF09`);let y=mE(await g.arrayBuffer(),g.headers.get("content-type")||""),_=Td(y),w=Jy(_);l=w.layers,d=w.meta;let x=_?.artboard;x?.frame&&(p=Math.round(Number(x.frame.width||0))||p,m=Math.round(Number(x.frame.height||0))||m),f=hE(x)}let h;if(n.needCover){let g=a.url||c[0]?.url;if(g){let y=await fetch(g,{headers:r_(g,r)});if(y.ok){let _=Buffer.from(await y.arrayBuffer());h=(await Wy(_,p,m)).toString("base64")}}}return{source:"api",name:a.name,viewport:{width:p,height:m},layers:l,meta:{...d,docName:a.name??d.docName},...f.length?{slices:f}:{},...h?{coverImageBase64:h}:{}}}function hE(t){let e=[],r=n=>{if(!(!n||typeof n!="object")){if(n.hasExportImage&&n.image?.imageUrl){let o=n.frame||{};e.push({name:String(n.name||"slice"),imageUrl:n.image.imageUrl,x:Math.round(Number(o.x??o.left??0)),y:Math.round(Number(o.y??o.top??0)),w:Math.round(Number(o.width??0)),h:Math.round(Number(o.height??0))})}for(let o of n.layers||[])r(o)}};return r(t),e}function gE(t){return fE("md5").update(t).digest("hex").slice(0,8)}async function Li(t,e){let{projectId:r,imageId:n}=Di(t);if(!r)throw new Error("\u65E0\u6CD5\u4ECE URL \u63D0\u53D6 project_id/pid");if(!n)throw new Error("\u65E0\u6CD5\u4ECE URL \u63D0\u53D6 image_id");let o=dr(e);return{...await Uo(n,r,o,e),url:t}}async function c_(t,e,r){let n=dr(r),o=await Uo(t,e,n,r);return{...o,name:o.name||t}}async function u_(t){let e=dr(t),r={...Fo(e),"Content-Type":"application/json"},n=pE(t),o=await fetch(`${Cn}/workbench/api/workbench/abstractfile/list`,{method:"POST",headers:r,body:JSON.stringify({tenantId:n,parentId:0})});Zi(o,"auth","\u56E2\u961F\u76EE\u5F55");let s=await o.json(),i=Array.isArray(s.data)?s.data:[],a=i.filter(h=>h.sourceType==="folder"),c=i.filter(h=>h.sourceType!=="folder"),u=[],l=await Promise.all(a.map(async h=>{try{let g=await fetch(`${Cn}/workbench/api/workbench/abstractfile/list`,{method:"POST",headers:r,body:JSON.stringify({tenantId:n,parentId:h.id})});if(!g.ok)return u.push(String(h.name||h.id)),[];let y=await g.json();return Array.isArray(y.data)?y.data:[]}catch{return u.push(String(h.name||h.id)),[]}})),d=[...c,...l.flat()],p=[],m=(await Promise.all(d.map(h=>Id(h.sourceId,t).then(g=>({ok:!0,value:{project:h.sourceName,projectId:h.sourceId,sectors:g.sectors.map(y=>({name:y.name,designCount:y.designCount}))}})).catch(g=>(p.push({project:h.sourceName,projectId:h.sourceId,error:g?.message||String(g)}),{ok:!1}))))).filter(h=>h.ok).map(h=>h.value),f=m.reduce((h,g)=>h+g.sectors.length,0);return{teamId:n,projectCount:m.length,sectorCount:f,directory:m,...p.length?{failedProjects:p}:{},...u.length?{failedFolders:u}:{}}}async function Id(t,e){let r=dr(e),n=Fo(r),o="0",s=await fetch(`${Cn}/api/project/project_sectors?project_id=${t}`,{headers:n});Zi(s,"resource","\u9879\u76EE\u5206\u7EC4");let i=await s.json(),a=i?.data?.sectors||i?.result?.sectors||[],c=await fetch(`${Cn}/api/project/images?project_id=${t}&team_id=${o}&dds_status=1`,{headers:n});Zi(c,"resource","\u9879\u76EE\u8BBE\u8BA1\u7A3F\u5217\u8868");let u=await c.json(),l=u?.data?.images||u?.data?.list||u?.data||[],d=new Map;for(let p of l){let m=p.image_id||p.id;m&&d.set(m,p.name||p.image_name||m)}return{projectId:t,sectorCount:a.length,sectors:a.map(p=>({id:p.id,name:p.name,designCount:(p.images||[]).length,designs:(p.images||[]).map(m=>({image_id:m,name:d.get(m)||m}))}))}}async function l_(t,e,r){let n=s_(t),o=await Id(n,r),s=o.sectors.find(u=>u.name===e||u.id===e);if(!s)throw new Error(`\u672A\u627E\u5230\u5206\u7EC4\u300C${e}\u300D\uFF0C\u53EF\u7528\u5206\u7EC4\uFF1A${o.sectors.map(u=>u.name).join("\u3001")}`);let i=dr(r),a=[],c=(await Promise.all(s.designs.map(u=>Uo(u.image_id,n,i,{}).then(l=>({ok:!0,value:{image_id:u.image_id,name:u.name,viewport:l.viewport,layerCount:l.layers.length}})).catch(l=>(a.push({image_id:u.image_id,name:u.name,error:l?.message||String(l)}),{ok:!1}))))).filter(u=>u.ok).map(u=>u.value);return{sector:s.name,designCount:c.length,designs:c,...a.length?{failed:a}:{}}}async function d_(t,e,r){let n=r.skipExisting!==!1,o=r.sliceNames?.length?new Set(r.sliceNames):null,s,i,a;if(r.sector){let $=s_(t),P=dr(r),J=await Id($,r),H=J.sectors.find(O=>O.name===r.sector||O.id===r.sector);if(!H)throw new Error(`\u672A\u627E\u5230\u5206\u7EC4\u300C${r.sector}\u300D\uFF0C\u53EF\u7528\u5206\u7EC4\uFF1A${J.sectors.map(O=>O.name).join("\u3001")}`);i=[];let k=[];await Promise.all(H.designs.map(O=>Uo(O.image_id,$,P,{}).then(E=>i.push(...E.slices||[])).catch(E=>k.push(`${O.name}: ${E?.message||E}`)))),k.length&&(a=k),s=H.name}else{let $=null,P=r.projectId||"";if(/[/?]/.test(t)){let k=Di(t);$=k.imageId,P=k.projectId||P}else $=t;if(!$)throw new Error("\u65E0\u6CD5\u4ECE\u8F93\u5165\u89E3\u6790 image_id\uFF0C\u8BF7\u4F20\u8BBE\u8BA1\u7A3F URL \u6216 image_id");if(!P)throw new Error("\u4E0B\u8F7D\u5207\u56FE\u9700\u8981 projectId\uFF1A\u4F20 URL \u81EA\u52A8\u63D0\u53D6\uFF0C\u6216\u663E\u5F0F\u4F20 projectId");let J=dr(r),H=await Uo($,P,J,{});i=H.slices||[],s=H.name||$}if(!i.length)return{scope:s,outputDir:ji.resolve(e),downloaded:0,skipped:{dup:0,exist:0},failed:[],slices:[]};let c=ji.resolve(e);dE(c,{recursive:!0});let u=new Set,l=[],d=0;for(let $ of i){let P=$.imageUrl;if(P&&!(o&&!o.has($.name))){if(u.has(P)){d++;continue}u.add(P),l.push({...$,imageUrl:P})}}let p=[],m=[],f=0,h=r.scale||"2x",g=h==="original"?0:Number(h.replace("x","")),y=Number(process.env.LANHU_SLICE_CONCURRENCY)||6,_=0,w=async()=>{for(;_<l.length;){let $=_++,P=l[$],J=P.imageUrl,H=String(P.name).replace(/[/\\:*?"<>|]/g,"_").replace(/\s+/g,"_"),k=gE(J),O=r.format||"png",E=e_(J,P.w,P.h,4,O),F=E[h]||J,re=h==="2x"?"":`@${h}`,K=g?Math.round(P.w*g):0,Ve=g?Math.round(P.h*g):0,ce=h==="original"?null:ji.join(c,`${H}_${k}${re}.${O}`);if(ce&&n&&t_(ce)){f++,p[$]={name:P.name,file:ce,bytes:0,w:P.w,h:P.h,x:P.x,y:P.y,scale:h,format:O,pixelW:K,pixelH:Ve,sha256:""};continue}let j,oe;try{let zt=await Xy(F,{cookie:r.cookie});oe=await Qy(zt.bytes),j=zt.bytes}catch(zt){let Fi=zt instanceof pe?zt.code:"download_failed",Vi=/^http_(\d+)$/.exec(Fi);m.push({name:P.name,url:J,status:Vi?Number(Vi[1]):0,reason:Fi});continue}let Ee=oe.format==="jpeg"?"jpg":oe.format,He=ce||ji.join(c,`${H}_${k}${re}.${Ee}`);if(He!==ce&&n&&t_(He)){f++,p[$]={name:P.name,file:He,bytes:0,w:P.w,h:P.h,x:P.x,y:P.y,scale:h,format:oe.format,pixelW:oe.width||0,pixelH:oe.height||0,sha256:oe.sha256};continue}lE(He,j),p[$]={name:P.name,file:He,bytes:j.length,w:P.w,h:P.h,x:P.x,y:P.y,scale:h,format:oe.format,pixelW:oe.width||0,pixelH:oe.height||0,sha256:oe.sha256,...r.withScaleUrls?{scaleUrls:E}:{}}}},x=Array.from({length:Math.min(y,l.length||1)},()=>w());return await Promise.all(x),{scope:s,outputDir:c,downloaded:p.filter($=>$&&$.bytes>0).length,skipped:{dup:d,exist:f},failed:m,slices:p.filter(Boolean),...a?{designErrors:a}:{}}}import{request as yE}from"node:https";import{request as _E}from"node:http";import{createHash as f_}from"node:crypto";import{existsSync as vE,mkdirSync as bE,readFileSync as xE,writeFileSync as wE}from"node:fs";import h_ from"node:path";import{fileURLToPath as $E}from"node:url";var Ho=process.env.VLM_MODEL||"deepseek-v4-flash-vision-exp",g_=process.env.VLM_API_KEY||"",y_=(process.env.VLM_BASE_URL||"https://api.deepseek.com").replace(/\/+$/,"").replace(/\/v1$/,""),kE=process.env.VISION_USE_V1!=="0",SE=Number(process.env.LANHU_VISION_MAX_TOKENS)||4096,zE=32*1024*1024,PE=48*1024*1024,Vo=3;function p_(t){return`${y_}${t?"/v1":""}/chat/completions`}function TE(t){let e=t.includes(",")?t.slice(t.indexOf(",")+1):t,r=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.max(0,Math.floor(e.length*3/4)-r)}function EE(t){let e=0;if(t.forEach((r,n)=>{let o=TE(r);if(e+=o,o>zE)throw new Error(`\u7B2C ${n+1} \u5F20\u56FE\u7EA6 ${(o/1024/1024).toFixed(1)} MiB\uFF0C\u8D85\u8FC7\u5355\u56FE 32 MiB \u4E0A\u9650\uFF0C\u8BF7\u5148\u538B\u7F29\u518D\u8C03\u7528`)}),e>PE)throw new Error(`${t.length} \u5F20\u56FE\u5408\u8BA1\u7EA6 ${(e/1024/1024).toFixed(1)} MiB\uFF0C\u8D85\u8FC7\u8BF7\u6C42\u4F53 48 MiB \u4E0A\u9650`)}function IE(t){return t.includes("json")?t:`${t}
|
|
41
|
+
]`;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 Vs(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===z.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((n,o)=>({...n,[o]:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",o]})??ze(e)}),{}),additionalProperties:e.rejectedAdditionalProperties};let r={type:"object",additionalProperties:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??e.allowedAdditionalProperties};if(e.target==="openApi3")return r;if(t.keyType?._def.typeName===z.ZodString&&t.keyType._def.checks?.length){let{type:n,...o}=Fs(t.keyType._def,e);return{...r,propertyNames:o}}else{if(t.keyType?._def.typeName===z.ZodEnum)return{...r,propertyNames:{enum:t.keyType._def.values}};if(t.keyType?._def.typeName===z.ZodBranded&&t.keyType._def.type._def.typeName===z.ZodString&&t.keyType._def.type._def.checks?.length){let{type:n,...o}=Us(t.keyType._def,e);return{...r,propertyNames:o}}}return r}function lm(t,e){if(e.mapStrategy==="record")return Vs(t,e);let r=V(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||ze(e),n=V(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||ze(e);return{type:"array",maxItems:125,items:{type:"array",items:[r,n],minItems:2,maxItems:2}}}function dm(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}}function pm(t){return t.target==="openAi"?void 0:{not:ze({...t,currentPath:[...t.currentPath,"not"]})}}function fm(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var uo={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function hm(t,e){if(e.target==="openApi3")return mm(t,e);let r=t.options instanceof Map?Array.from(t.options.values()):t.options;if(r.every(n=>n._def.typeName in uo&&(!n._def.checks||!n._def.checks.length))){let n=r.reduce((o,s)=>{let i=uo[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 mm(t,e)}var mm=(t,e)=>{let r=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((n,o)=>V(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 gm(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:uo[t.innerType._def.typeName],nullable:!0}:{type:[uo[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){let n=V(t.innerType._def,{...e,currentPath:[...e.currentPath]});return n&&"$ref"in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let r=V(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function ym(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",vu(r,"type",n.message,e);break;case"min":e.target==="jsonSchema7"?n.inclusive?ie(r,"minimum",n.value,n.message,e):ie(r,"exclusiveMinimum",n.value,n.message,e):(n.inclusive||(r.exclusiveMinimum=!0),ie(r,"minimum",n.value,n.message,e));break;case"max":e.target==="jsonSchema7"?n.inclusive?ie(r,"maximum",n.value,n.message,e):ie(r,"exclusiveMaximum",n.value,n.message,e):(n.inclusive||(r.exclusiveMaximum=!0),ie(r,"maximum",n.value,n.message,e));break;case"multipleOf":ie(r,"multipleOf",n.value,n.message,e);break}return r}function _m(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=Sw(c);u&&r&&(c._def.typeName==="ZodOptional"&&(c=c._def.innerType),c.isNullable()||(c=c.nullable()),u=!1);let l=V(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=kw(t,e);return i!==void 0&&(n.additionalProperties=i),n}function kw(t,e){if(t.catchall._def.typeName!=="ZodNever")return V(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 Sw(t){try{return t.isOptional()}catch{return!0}}var vm=(t,e)=>{if(e.currentPath.toString()===e.propertyPath?.toString())return V(t.innerType._def,e);let r=V(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return r?{anyOf:[{not:ze(e)},r]}:ze(e)};var bm=(t,e)=>{if(e.pipeStrategy==="input")return V(t.in._def,e);if(e.pipeStrategy==="output")return V(t.out._def,e);let r=V(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),n=V(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,n].filter(o=>o!==void 0)}};function xm(t,e){return V(t.type._def,e)}function wm(t,e){let n={type:"array",uniqueItems:!0,items:V(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&ie(n,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&ie(n,"maxItems",t.maxSize.value,t.maxSize.message,e),n}function $m(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((r,n)=>V(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[]),additionalItems:V(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((r,n)=>V(r._def,{...e,currentPath:[...e.currentPath,"items",`${n}`]})).reduce((r,n)=>n===void 0?r:[...r,n],[])}}function km(t){return{not:ze(t)}}function Sm(t){return ze(t)}var zm=(t,e)=>V(t.innerType._def,e);var Pm=(t,e,r)=>{switch(e){case z.ZodString:return Fs(t,r);case z.ZodNumber:return ym(t,r);case z.ZodObject:return _m(t,r);case z.ZodBigInt:return tm(t,r);case z.ZodBoolean:return rm();case z.ZodDate:return bu(t,r);case z.ZodUndefined:return km(r);case z.ZodNull:return fm(r);case z.ZodArray:return em(t,r);case z.ZodUnion:case z.ZodDiscriminatedUnion:return hm(t,r);case z.ZodIntersection:return am(t,r);case z.ZodTuple:return $m(t,r);case z.ZodRecord:return Vs(t,r);case z.ZodLiteral:return cm(t,r);case z.ZodEnum:return im(t);case z.ZodNativeEnum:return dm(t);case z.ZodNullable:return gm(t,r);case z.ZodOptional:return vm(t,r);case z.ZodMap:return lm(t,r);case z.ZodSet:return wm(t,r);case z.ZodLazy:return()=>t.getter()._def;case z.ZodPromise:return xm(t,r);case z.ZodNaN:case z.ZodNever:return pm(r);case z.ZodEffects:return sm(t,r);case z.ZodAny:return ze(r);case z.ZodUnknown:return Sm(r);case z.ZodDefault:return om(t,r);case z.ZodBranded:return Us(t,r);case z.ZodReadonly:return zm(t,r);case z.ZodCatch:return nm(t,r);case z.ZodPipeline:return bm(t,r);case z.ZodFunction:case z.ZodVoid:case z.ZodSymbol:return;default:return(n=>{})(e)}};function V(t,e,r=!1){let n=e.seen.get(t);if(e.override){let a=e.override?.(t,e,n,r);if(a!==Yf)return a}if(n&&!r){let a=zw(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=Pm(t,t.typeName,e),i=typeof s=="function"?V(s(),e):s;if(i&&Pw(t,e,i),e.postProcess){let a=e.postProcess(i,t,e);return o.jsonSchema=i,a}return o.jsonSchema=i,i}var zw=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:qs(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`),ze(e)):e.$refStrategy==="seen"?ze(e):void 0}},Pw=(t,e,r)=>(t.description&&(r.description=t.description,e.markdownDescription&&(r.markdownDescription=t.description)),r);var $u=(t,e)=>{let r=Qf(e),n=typeof e=="object"&&e.definitions?Object.entries(e.definitions).reduce((c,[u,l])=>({...c,[u]:V(l._def,{...r,currentPath:[...r.basePath,r.definitionPath,u]},!0)??ze(r)}),{}):void 0,o=typeof e=="string"?e:e?.nameStrategy==="title"?void 0:e?.name,s=V(t._def,o===void 0?r:{...r,currentPath:[...r.basePath,r.definitionPath,o]},!1)??ze(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 Tw(t){return!t||t==="jsonSchema7"||t==="draft-7"?"draft-7":t==="jsonSchema2019-09"||t==="draft-2020-12"?"draft-2020-12":"draft-7"}function ku(t,e){return Rt(t)?Bc(t,{target:Tw(e?.target),io:e?.pipeStrategy??"input"}):$u(t,{strictUnions:e?.strictUnions??!0,pipeStrategy:e?.pipeStrategy??"input"})}function Su(t){let r=Qt(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=un(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function zu(t,e){let r=Xt(t,e);if(!r.success)throw r.error;return r.data}var Ew=6e4,Hs=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(ks,r=>{this._oncancel(r)}),this.setNotificationHandler(zs,r=>{this._onprogress(r)}),this.setRequestHandler(Ss,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ps,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new j(D.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Es,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 d=c,f=new j(d.error.code,d.error.message,d.error.data);l(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new j(D.InvalidParams,`Task not found: ${s}`);if(!tr(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(tr(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[er]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Is,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 j(D.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ns,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new j(D.InvalidParams,`Task not found: ${r.params.taskId}`);if(tr(o.status))throw new j(D.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 j(D.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof j?o:new j(D.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),j.fromError(D.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),eo(s)||Df(s)?this._onresponse(s):su(s)?this._onrequest(s,i):Zf(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=j.fromError(D.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?.[er]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:D.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=Af(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 d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(i.signal.aborted)throw new j(D.ConnectionClosed,"Request was cancelled");let m={...f,relatedRequestId:e.id};s&&!m.relatedTask&&(m.relatedTask={taskId:s});let p=m.relatedTask?.taskId??s;return p&&c&&await c.updateTaskStatus(p,"input_required"),await this.request(l,d,m)},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 d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:D.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).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),eo(e))n(e);else{let i=new j(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(eo(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),eo(e))o(e);else{let i=j.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 j?i:new j(D.InternalError,String(i))}}return}let s;try{let i=await this.request(e,dn,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new j(D.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},tr(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new j(D.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new j(D.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 j?i:new j(D.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 d=_=>{l(_)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(_){d(_);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:f}}),a&&(m.params={...m.params,task:a}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[er]:c}});let p=_=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(_)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));let w=_ instanceof j?_:new j(D.RequestTimeout,String(_));l(w)};this._responseHandlers.set(f,_=>{if(!n?.signal?.aborted){if(_ instanceof Error)return l(_);try{let w=Xt(r,_.result);w.success?u(w.data):l(w.error)}catch(w){l(w)}}}),n?.signal?.addEventListener("abort",()=>{p(n?.signal?.reason)});let h=n?.timeout??Ew,g=()=>p(j.fromError(D.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let _=w=>{let x=this._responseHandlers.get(f);x?x(w):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,_),this._enqueueTaskMessage(y,{type:"request",message:m,timestamp:Date.now()}).catch(w=>{this._cleanupTimeout(f),l(w)})}else this._transport.send(m,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(_=>{this._cleanupTimeout(f),l(_)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Ts,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},Rs,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Uf,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||{},[er]: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||{},[er]: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||{},[er]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=Su(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=zu(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=Su(e);this._notificationHandlers.set(n,o=>{let s=zu(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"&&su(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new j(D.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 j(D.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new j(D.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 j(D.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=so.parse({method:"notifications/tasks/status",params:a});await this.notification(c),tr(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 j(D.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(tr(a.status))throw new j(D.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=so.parse({method:"notifications/tasks/status",params:c});await this.notification(u),tr(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Tm(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Em(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];Tm(i)&&Tm(s)?r[o]={...i,...s}:r[o]=s}return r}var Ey=Od(gd(),1),Iy=Od(Ty(),1);function DT(){let t=new Ey.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Iy.default)(t),t}var Ti=class{constructor(e){this._ajv=e??DT()}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)}}};var Ei=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(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(s.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==d.size||![...l].every(f=>d.has(f)))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},co,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},mn,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)}};function Ry(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 Ny(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 Ii=class extends Hs{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ao.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 Ti,this.setRequestHandler(cu,n=>this._oninitialize(n)),this.setNotificationHandler(uu,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(gu,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=ao.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Ei(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Em(this._capabilities,e)}setRequestHandler(e,r){let o=Qt(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=un(o);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=Xt(fn,c);if(!l.success){let p=l.error instanceof Error?l.error.message:String(l.error);throw new j(D.InvalidParams,`Invalid tools/call request: ${p}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let p=Xt(dn,f);if(!p.success){let h=p.error instanceof Error?p.error.message:String(p.error);throw new j(D.InvalidParams,`Invalid task creation result: ${h}`)}return p.data}let m=Xt(Ds,f);if(!m.success){let p=m.error instanceof Error?m.error.message:String(m.error);throw new j(D.InvalidParams,`Invalid tools/call result: ${p}`)}return m.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){Ny(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&Ry(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:Nf.includes(r)?r:nu,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"},$s)}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(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))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},yu,r):this.request({method:"sampling/createMessage",params:e},co,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},mn,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},mn,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new j(D.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof j?i:new j(D.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},_u,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"})}};var Cy=Symbol.for("mcp.completable");function kd(t){return!!t&&typeof t=="object"&&Cy in t}function Ay(t){return t[Cy]?.complete}var Oy;(function(t){t.Completable="McpCompletable"})(Oy||(Oy={}));var LT=/^[A-Za-z0-9._-]{1,128}$/;function qT(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"),!LT.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 UT(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 Sd(t){let e=qT(t);return UT(t,e.warnings),e.isValid}var Ri=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 Ni=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 Ii(e,r)}get experimental(){return this._experimental||(this._experimental={tasks:new Ri(this)}),this._experimental}async connect(e){return await this.server.connect(e)}async close(){await this.server.close()}setToolRequestHandlers(){this._toolHandlersInitialized||(this.server.assertCanSetRequestHandler(lr(Zs)),this.server.assertCanSetRequestHandler(lr(fn)),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(Zs,()=>({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=cn(r.inputSchema);return o?ku(o,{strictUnions:!0,pipeStrategy:"input"}):FT})(),annotations:r.annotations,execution:r.execution,_meta:r._meta};if(r.outputSchema){let o=cn(r.outputSchema);o&&(n.outputSchema=ku(o,{strictUnions:!0,pipeStrategy:"output"}))}return n})})),this.server.setRequestHandler(fn,async(e,r)=>{try{let n=this._registeredTools[e.params.name];if(!n)throw new j(D.InvalidParams,`Tool ${e.params.name} not found`);if(!n.enabled)throw new j(D.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 j(D.InternalError,`Tool ${e.params.name} has taskSupport '${s}' but was not registered with registerToolTask`);if(s==="required"&&!o)throw new j(D.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 j&&n.code===D.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=cn(e.inputSchema)??e.inputSchema,i=await gs(s,r);if(!i.success){let a="error"in i?i.error:"Unknown error",c=ys(a);throw new j(D.InvalidParams,`Input validation error: Invalid arguments for tool ${n}: ${c}`)}return i.data}async validateToolOutput(e,r,n){if(!e.outputSchema||!("content"in r)||r.isError)return;if(!r.structuredContent)throw new j(D.InvalidParams,`Output validation error: Tool ${n} has an output schema but no structured content was provided`);let o=cn(e.outputSchema),s=await gs(o,r.structuredContent);if(!s.success){let i="error"in s?s.error:"Unknown error",a=ys(i);throw new j(D.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(f=>setTimeout(f,l));let d=await n.taskStore.getTask(c);if(!d)throw new j(D.InternalError,`Task ${c} not found during polling`);u=d}return await n.taskStore.getTaskResult(c)}setCompletionRequestHandler(){this._completionHandlerInitialized||(this.server.assertCanSetRequestHandler(lr(Ls)),this.server.registerCapabilities({completions:{}}),this.server.setRequestHandler(Ls,async e=>{switch(e.params.ref.type){case"ref/prompt":return Kf(e),this.handlePromptCompletion(e,e.params.ref);case"ref/resource":return Wf(e),this.handleResourceCompletion(e,e.params.ref);default:throw new j(D.InvalidParams,`Invalid completion reference: ${e.params.ref}`)}}),this._completionHandlerInitialized=!0)}async handlePromptCompletion(e,r){let n=this._registeredPrompts[r.name];if(!n)throw new j(D.InvalidParams,`Prompt ${r.name} not found`);if(!n.enabled)throw new j(D.InvalidParams,`Prompt ${r.name} disabled`);if(!n.argsSchema)return qo;let s=Qt(n.argsSchema)?.[e.params.argument.name];if(!kd(s))return qo;let i=Ay(s);if(!i)return qo;let a=await i(e.params.argument.value,e.params.context);return My(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 qo;throw new j(D.InvalidParams,`Resource template ${e.params.ref.uri} not found`)}let o=n.resourceTemplate.completeCallback(e.params.argument.name);if(!o)return qo;let s=await o(e.params.argument.value,e.params.context);return My(s)}setResourceRequestHandlers(){this._resourceHandlersInitialized||(this.server.assertCanSetRequestHandler(lr(Os)),this.server.assertCanSetRequestHandler(lr(Cs)),this.server.assertCanSetRequestHandler(lr(As)),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(Os,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(Cs,async()=>({resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([r,n])=>({name:r,uriTemplate:n.resourceTemplate.uriTemplate.toString(),...n.metadata}))})),this.server.setRequestHandler(As,async(e,r)=>{let n=new URL(e.params.uri),o=this._registeredResources[n.toString()];if(o){if(!o.enabled)throw new j(D.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 j(D.InvalidParams,`Resource ${n} not found`)}),this._resourceHandlersInitialized=!0)}setPromptRequestHandlers(){this._promptHandlersInitialized||(this.server.assertCanSetRequestHandler(lr(js)),this.server.assertCanSetRequestHandler(lr(Ms)),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(js,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,e])=>e.enabled).map(([e,r])=>({name:e,title:r.title,description:r.description,arguments:r.argsSchema?VT(r.argsSchema):void 0}))})),this.server.setRequestHandler(Ms,async(e,r)=>{let n=this._registeredPrompts[e.params.name];if(!n)throw new j(D.InvalidParams,`Prompt ${e.params.name} not found`);if(!n.enabled)throw new j(D.InvalidParams,`Prompt ${e.params.name} disabled`);if(n.argsSchema){let o=cn(n.argsSchema),s=await gs(o,e.params.arguments);if(!s.success){let c="error"in s?s.error:"Unknown error",u=ys(c);throw new j(D.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:Cr(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=Cr(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 Ye?c._def?.innerType:c;return kd(u)})&&this.setCompletionRequestHandler(),i}_createRegisteredTool(e,r,n,o,s,i,a,c,u){Sd(e);let l={title:r,description:n,inputSchema:jy(o),outputSchema:jy(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:d=>{typeof d.name<"u"&&d.name!==e&&(typeof d.name=="string"&&Sd(d.name),delete this._registeredTools[e],d.name&&(this._registeredTools[d.name]=l)),typeof d.title<"u"&&(l.title=d.title),typeof d.description<"u"&&(l.description=d.description),typeof d.paramsSchema<"u"&&(l.inputSchema=Cr(d.paramsSchema)),typeof d.outputSchema<"u"&&(l.outputSchema=Cr(d.outputSchema)),typeof d.callback<"u"&&(l.handler=d.callback),typeof d.annotations<"u"&&(l.annotations=d.annotations),typeof d._meta<"u"&&(l._meta=d._meta),typeof d.enabled<"u"&&(l.enabled=d.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(zd(c))o=r.shift(),r.length>1&&typeof r[0]=="object"&&r[0]!==null&&!zd(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 FT={type:"object",properties:{}};function Zy(t){return t!==null&&typeof t=="object"&&"parse"in t&&typeof t.parse=="function"&&"safeParse"in t&&typeof t.safeParse=="function"}function Dy(t){return"_def"in t||"_zod"in t||Zy(t)}function zd(t){return typeof t!="object"||t===null||Dy(t)?!1:Object.keys(t).length===0?!0:Object.values(t).some(Zy)}function jy(t){if(t){if(zd(t))return Cr(t);if(!Dy(t))throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");return t}}function VT(t){let e=Qt(t);return e?Object.entries(e).map(([r,n])=>{let o=cf(n),s=uf(n);return{name:r,description:o,required:!s}}):[]}function lr(t){let r=Qt(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=un(r);if(typeof n=="string")return n;throw new Error("Schema method literal must be a string")}function My(t){return{completion:{values:t.slice(0,100),total:t.length,hasMore:t.length>100}}}var qo={completion:{values:[],hasMore:!1}};import qy from"node:process";var HT=10*1024*1024,Oi=class{constructor(e){this._maxBufferSize=e?.maxBufferSize??HT}append(e){if((this._buffer?.length??0)+e.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
42
|
+
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),BT(r)}clear(){this._buffer=void 0}};function BT(t){return Lf.parse(JSON.parse(t))}function Ly(t){return JSON.stringify(t)+`
|
|
43
|
+
`}var Ci=class{constructor(e=qy.stdin,r=qy.stdout,n){this._stdin=e,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new Oi({maxBufferSize:n?.maxBufferSize})}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=Ly(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};import{readFileSync as KE}from"node:fs";import{readFile as WE}from"node:fs/promises";import{writeFileSync as lE,mkdirSync as dE,existsSync as t_}from"node:fs";import{createHash as pE}from"node:crypto";import Ai from"node:path";function Fy(t,e=0){if(!t||typeof t!="object"||e>6)return null;let r=t;for(let n of["layers","shapes","children","artboards","widgets","nodes"]){let o=r[n];if(Array.isArray(o)&&o.length)return o}for(let n of Object.values(r))if(n&&typeof n=="object"){let o=Fy(n,e+1);if(o)return o}return null}var Vy=/^(frame|group|编组|矩形|椭圆|形状|切片|蒙版|layer|rect|image|vector|line|subtract|union|intersect|difference)[\s_-]?\d*$/i,JT=/^(蒙版|mask|切片|slice)/i,KT=t=>Vy.test(t.trim())&&!JT.test(t.trim()),WT=/^(subtract|union|intersect|difference)([\s_-]?\d*)?$/i,Pd=t=>1+(Array.isArray(t?.layers)?t.layers.reduce((e,r)=>e+Pd(r),0):0);function Nn(t){if(!t||typeof t!="object"||typeof t.value!="string")return t;let e=/rgba\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*,\s*([\d.]+)\s*\)/.exec(t.value);if(!e)return t;let r=Number(e[1]),n=Number(t.a);if(Number.isFinite(n)&&Math.abs(n-r)>.001){let{a:o,...s}=t;return s}return t}function Hy(t){let e=t.ddsOriginFrame;return e&&Number(e.width)>0&&Number(e.height)>0?{x:Math.round(Number(e.x)||0),y:Math.round(Number(e.y)||0),width:Math.round(Number(e.width)||0),height:Math.round(Number(e.height)||0)}:{x:Math.round(Number(t.left??0)),y:Math.round(Number(t.top??0)),width:Math.round(Number(t.width??0)),height:Math.round(Number(t.height??0))}}function GT(t){let e=Array.isArray(t.points)&&t.points.length?t.points.map(n=>Number(n?.cornerRadius??0)||0):Array.isArray(t.radius)?t.radius.map(n=>Number(n)||0):null;if(!e||!e.some(Boolean))return null;let r=n=>e[n]??e[0]??0;return{topLeft:r(0),topRight:r(1),bottomRight:r(2),bottomLeft:r(3)}}function YT(t){let e=t.font;if(!e||typeof e!="object")return null;let r=String(e.font||e.displayName||""),n=Array.isArray(e.styles)?e.styles[0]:null,o=String(n?.decorationLine||""),s={0:"top",1:"middle",2:"bottom"},i={size:Number(e.size??n?.size??0)||void 0,name:e.displayName||void 0,postScriptName:e.font||void 0,fontWeight:/bold|heavy|black/i.test(r)?700:void 0,lineHeight:e.line!=null?{unit:"PIXELS",value:Number(e.line)||0}:void 0,letterSpacing:{value:Number(t.characterSpacing??e.kerning??0)||0},align:typeof e.align=="string"?e.align:void 0,verticalAlignment:s[Number(e.verticalAlignment)]||"top",italic:/italic|oblique/i.test(r)||void 0,underline:o==="underline"||void 0,linethrough:o==="line-through"||void 0},a=Nn(e.color)??Nn(n?.color);return{value:String(e.content??n?.content??""),style:{content:String(e.content??n?.content??""),color:a,font:i}}}function By(t,e){let r={id:t.id,name:t.name,type:t.type,frame:Hy(t),visible:t.isVisible!==!1};typeof t.opacity=="number"&&(r.opacity=t.opacity/100);let n=t.ddsImage?.imageUrl;n&&(t.exportable===!0||t.type==="bitmap")?(r.image={imageUrl:n},t.exportable===!0&&(r.hasExportImage=!0)):t.exportable===!0?r.hasExportImage=!0:t.image?.svgUrl&&(r.image=t.image);let o={};Array.isArray(t.fills)&&t.fills.length&&(o.fills=t.fills.filter(a=>a.isEnabled!==!1).map(a=>{let c={...a};return c.gradient?.colorStops&&(c.gradient={...c.gradient,stops:c.gradient.colorStops.map(u=>({position:u.position,color:Nn(u.color)}))}),c.color=Nn(c.color),c})),Array.isArray(t.borders)&&t.borders.length&&(o.borders=t.borders.filter(a=>a.isEnabled!==!1).map(a=>({...a,width:a.thickness??a.width,lineAlignment:a.position==="\u5916\u8FB9\u6846"?"outside":a.position==="\u5185\u8FB9\u6846"?"inside":"center",color:Nn(a.color)}))),Array.isArray(t.shadows)&&t.shadows.length&&(o.shadows=t.shadows.filter(a=>a.isEnabled!==!1).map(a=>({...a,color:Nn(a.color)}))),Object.keys(o).length&&(r.style=o);let s=GT(t);if(s&&(r.radius=s),t.type==="text"){let a=YT(t);a&&(r.text=a)}let i=e.get(t.id);return i?.length&&(r.layers=i.map(a=>By(a,e))),r}function Td(t){if(!t||typeof t!="object"||t.artboard)return t;let e=t.info;if(!Array.isArray(e)||!e.length)return t;let r=new Map;for(let l of e)l?.id!=null&&r.set(l.id,l);let n=new Map,o=[];for(let l of e)if(!(!l||typeof l!="object"))if(l.parentID==null||!r.has(l.parentID))o.push(l);else{let d=n.get(l.parentID);d?d.push(l):n.set(l.parentID,[l])}if(!o.length)return t;let[s,...i]=o;i.length&&n.set(s.id,[...n.get(s.id)??[],...i]);let a=By(s,n),{info:c,...u}=t;return{...u,artboard:{name:s.name,frame:Hy(s),layers:a?.layers||[]}}}var Uy=t=>{let e=/^rgba\((\d+),\s*(\d+),\s*(\d+),\s*1\)$/.exec(t.trim());return e?"#"+[e[1],e[2],e[3]].map(r=>(+r).toString(16).padStart(2,"0")).join(""):t};function XT(t){let e=t.frame||t.rect||t.boundingBox||t,r=Math.round(Number(e.x??e.left??0)),n=Math.round(Number(e.y??e.top??0)),o=Math.round(Number(e.width??e.w??0)),s=Math.round(Number(e.height??e.h??0)),i=t.style||t.css||{},a=String(t.type??t.shapeType??(t.text!=null?"text":"rect")).toLowerCase(),c=t.text&&typeof t.text=="object"?t.text.style:null,u={type:/text|label|font/i.test(a)?"text":/image|bitmap|img/i.test(a)?"image":"rect",x:r,y:n,w:o,h:s};t.name&&(t.hasExportImage||!KT(String(t.name)))&&(u.name=t.name),t.hasExportImage?u.hasExportImage=!0:t.image?.imageUrl&&(u.imageUrl=t.image.imageUrl);let l=t.opacity==null?1:Number(t.opacity),d=Number.isFinite(l)?l:1,f=x=>Number(x?.opacity??1)||0,m=x=>{if(x==null)return 1;let $=x.color?.a??x.a;return Number($??1)||0},p=(x,$)=>{if(typeof x!="string")return;let P=m($),J=f($),H=P*d*(Math.abs(J-P)>.001?J:1);if(H>=1)return Uy(x);let k=Number(H.toFixed(4)),O=/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?\)$/.exec(x.trim());if(O)return`rgba(${O[1]},${O[2]},${O[3]},${k})`;let E=/^rgba?\((\d+(?:\.\d+)?)%,\s*(\d+(?:\.\d+)?)%,\s*(\d+(?:\.\d+)?)%(?:,\s*([\d.]+))?\)$/.exec(x.trim());if(E){let re=K=>Math.min(255,Math.max(0,Math.round(parseFloat(K)*2.55)));return`rgba(${re(E[1])},${re(E[2])},${re(E[3])},${k})`}let F=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(x.trim());if(F){let re=F[1];return re.length===3&&(re=re.split("").map(K=>K+K).join("")),`rgba(${parseInt(re.slice(0,2),16)},${parseInt(re.slice(2,4),16)},${parseInt(re.slice(4,6),16)},${k})`}return console.error(`[normalize] applyAlpha \u65E0\u6CD5\u89E3\u6790\u989C\u8272\uFF1A${x}\uFF0C\u900F\u660E\u5EA6 alpha=${k} \u672A\u53E0\u5165`),x};if(u.type==="text"){let x=t.text;u.text=(typeof x=="string"?x:c?.content??x?.value??"")||void 0;let $=c?.font??{};u.fontSize=Math.round(Number($.size??$.fontSize??0))||void 0,u.fontWeight=Number($.fontWeight??$.weight??0)||void 0,u.fontFamily=$.name??$.fontFamily??$.postScriptName??void 0,$.lineHeight&&(u.lineHeight=$.lineHeight.unit==="AUTO"?"auto":Math.round(Number($.lineHeight.value))||void 0),$.letterSpacing&&Number($.letterSpacing.value)&&(u.letterSpacing=Math.round(Number($.letterSpacing.value)*10)/10);let P=$.align?String($.align).toLowerCase():"";P&&P!=="left"&&(u.align=P);let J=$.verticalAlignment?String($.verticalAlignment).toLowerCase():"";J&&J!=="top"&&(u.verticalAlign=J),$.italic&&(u.italic=!0),$.underline&&(u.underline=!0),$.linethrough&&(u.linethrough=!0);let H=c?.color?.value??i.fills?.[0]?.color?.value,k=p(H,c?.color??i.fills?.[0]);k&&(u.color=k)}else{let x=i.fills?.[0];if(x?.type==="gradient"&&x.gradient?.stops){let H=x.gradient.stops.map(k=>({color:p(k.color?.value,{...k.color,opacity:x.opacity}),position:Math.round(Number(k.position)*1e3)/1e3})).filter(k=>k.color);H.length&&(u.gradient={stops:H})}else{let H=p(x?.color?.value,x);H&&(u.fill=H)}let $=H=>{if(H==null)return null;let k=Math.round(Number(H.topLeft??0)||0),O=Math.round(Number(H.topRight??0)||0),E=Math.round(Number(H.bottomLeft??0)||0),F=Math.round(Number(H.bottomRight??0)||0);return k||O||E||F?{tl:k,tr:O,bl:E,br:F}:null},P=(t.paths||[]).map(H=>$(H?.radius)).filter(Boolean);if(P.length||(P=[$(t.radius)].filter(Boolean)),P.length){let H=P.every(E=>E.tl===P[0].tl&&E.tr===P[0].tr&&E.bl===P[0].bl&&E.br===P[0].br),k=P[0],O={topLeft:k.tl,topRight:k.tr,bottomLeft:k.bl,bottomRight:k.br};H&&k.tl===k.tr&&k.tr===k.bl&&k.bl===k.br?u.radius=k.tl:(u.borderRadius=O,H||(u.radius=Math.max(k.tl,k.tr,k.bl,k.br)))}let J=(i.borders||[]).find(H=>H.isEnabled!==!1);if(J){let H=p(J.color?.value,{...J.color,opacity:J.opacity});H&&(u.border={color:H,width:Math.round(Number(J.width??0)*100)/100,alignment:J.lineAlignment==="outside"?"outside":J.lineAlignment==="center"?"center":"inside"})}}let h=(i.shadows||[]).filter(x=>x&&x.isEnabled!==!1&&x.color?.value),g=x=>({color:Uy(String(x.color.value)),x:Math.round(Number(x.x??0)),y:Math.round(Number(x.y??0)),blur:Math.round(Number(x.blur??0)),spread:Math.round(Number(x.spread??0))}),y=h.find(x=>!x.inset),_=h.find(x=>x.inset);y&&(u.shadow=g(y)),_&&(u.innerShadow=g(_));let w=!!(u.fill||u.gradient||u.color);return d<1&&!w&&(u.opacity=Number(d.toFixed(4))),u}function Jy(t){let e=Td(t),r=Fy(e)||[],n=[],o=0,s=0,i=0,a=0,c=k=>!!(k.fill||k.gradient||k.color||k.text||k.imageUrl||k.hasExportImage||k.border||k.shadow||k.innerShadow),u=k=>!Vy.test(k.trim()),l=(k,O)=>{for(let E of k){if(!E||typeof E!="object")continue;s++;let F=E;if(F.visible===!1)continue;let re=String(F.name||"");if(/备份|backup/i.test(re)){i+=Pd(F);continue}let K=re&&u(re)?[...O,re]:O,Ve=XT(F);Ve.w>0&&Ve.h>0&&(c(Ve)?(O.length&&(Ve.parentPath=O.join("/")),n.push(Ve)):o++);let ce=F.layers;if(!(!Array.isArray(ce)||!ce.length)){if(WT.test(re.trim())){a+=ce.reduce((A,oe)=>A+Pd(oe),0);continue}l(ce,K)}}};l(r,[]);let d=n,f=0,m=e?.artboard?.frame,p=Math.round(Number(m?.width??0)),h=Math.round(Number(m?.height??0));p>0&&h>0&&(d=d.filter(k=>{let O=k.x+k.w<=0||k.y+k.h<=0||k.x>=p||k.y>=h;return O&&f++,!O}));let g=k=>k.hasExportImage?JSON.stringify(["slice",k.x,k.y,k.w,k.h]):JSON.stringify({...k,name:void 0}),y=new Map;d.forEach((k,O)=>{let E=g(k),F=y.get(E);F?F.push(O):y.set(E,[O])});let _=new Map;for(let[k,O]of y){let E=O.filter(F=>d[F].type==="image");_.set(k,E.length?E[E.length-1]:O[O.length-1])}let w=0;d=d.filter((k,O)=>{let E=_.get(g(k))===O;return E||w++,E});let x=0;if(process.env.LANHU_PRUNE_OCCLUDED!=="0"){let k=E=>typeof E=="string"&&(/^#[0-9a-f]{6}$/i.test(E)||/^rgba\(\d+,\s*\d+,\s*\d+,\s*1\)$/.test(E)),O=new Array(d.length).fill(!1);d.forEach((E,F)=>{if(!(E.type==="text"||E.hasExportImage||E.imageUrl))for(let re=F+1;re<d.length;re++){let K=d[re];if(!(K.type==="text"||!k(K.fill))&&K.x<=E.x&&K.y<=E.y&&K.x+K.w>=E.x+E.w&&K.y+K.h>=E.y+E.h){O[F]=!0;break}}}),d=d.filter((E,F)=>O[F]?(x++,!1):!0)}let $=Number(process.env.LANHU_MIN_VISIBLE_FRACTION??.25),P=0;$>0&&p>0&&h>0&&(d=d.filter(k=>{if(k.type==="text"||k.hasExportImage||k.imageUrl)return!0;let O=Math.min(k.x+k.w,p)-Math.max(k.x,0),E=Math.min(k.y+k.h,h)-Math.max(k.y,0);return Math.max(0,O)*Math.max(0,E)/(k.w*k.h)>=$?!0:(P++,!1)}));let J=0;if(process.env.LANHU_PRUNE_FRAGMENTS!=="0"){let k=new Map;d.forEach((E,F)=>{if(E.type==="text"||E.hasExportImage||E.imageUrl||E.w>24||E.h>8||!E.parentPath)return;let re=k.get(E.parentPath);re?re.push(F):k.set(E.parentPath,[F])});let O=new Set;for(let E of k.values()){E.sort((K,Ve)=>d[K].y-d[Ve].y||d[K].x-d[Ve].x);let F=[E[0]],re=()=>{if(F.length>=4){F.sort((ce,A)=>d[ce].x-d[A].x);let K=[F[0]],Ve=()=>{if(K.length>=4){let ce=K.map(A=>d[A].w);Math.max(...ce)/Math.min(...ce)>=1.3&&(K.forEach(A=>O.add(A)),J+=K.length)}K=[]};for(let ce=1;ce<F.length;ce++){let A=d[K[K.length-1]],Ee=d[F[ce]].x-(A.x+A.w);Ee<=6&&Ee>=-6?K.push(F[ce]):(Ve(),K=[F[ce]])}Ve()}F=[]};for(let K=1;K<E.length;K++)Math.abs(d[E[K]].y-d[F[0]].y)<=2?F.push(E[K]):(re(),F=[E[K]]);re()}O.size&&(d=d.filter((E,F)=>!O.has(F)))}let H={rawLayerCount:s,totalLayerCount:d.length,droppedLayerCount:o,dedupedLayerCount:w,outsideCanvasLayerCount:f,occludedLayerCount:x,sliverLayerCount:P,fragmentLayerCount:J,backupLayerCount:i,booleanOperandLayerCount:a,payloadBytes:Buffer.byteLength(JSON.stringify(d)),docName:e?.artboard?.name??e?.document?.name??e?.name??e?.title??void 0};return{layers:d,meta:H}}import Ky from"sharp";async function Wy(t,e,r){let n=Ky(t);return e>0&&r>0?n=n.resize(Math.round(e),Math.round(r),{fit:"contain",background:{r:255,g:255,b:255,alpha:1}}):n=n.resize({width:1024,height:1024,fit:"inside",withoutEnlargement:!0}),n.flatten({background:"#ffffff"}).jpeg({quality:80}).toBuffer()}var QT=Number(process.env.LANHU_VISION_MAX_EDGE)||1568;async function Ed(t,e=QT){return Ky(t).resize({width:e,height:e,fit:"inside",withoutEnlargement:!0}).flatten({background:"#ffffff"}).jpeg({quality:85}).toBuffer()}import{createHash as eE}from"node:crypto";import tE from"sharp";var On=64*1024*1024,Gy=5,Yy=3,rE=["lanhuapp.com","aliyuncs.com"],nE=new Set(["png","jpeg","jpg","webp","gif","avif","tiff","ico"]),fe=class extends Error{constructor(r,n){super(n);this.code=r;this.name="AssetGuardError"}code};function oE(t){let e=t.toLowerCase(),r=(process.env.LANHU_ALLOWED_ASSET_HOSTS||"").split(",").map(n=>n.trim()).filter(Boolean);for(let n of[...rE,...r])if(e===n||e.endsWith(`.${n}`))return!0;return!1}function sE(t,e){let r=new URL(t).hostname.endsWith("lanhuapp.com"),n={Referer:"https://lanhuapp.com/","User-Agent":"lanhu-design-mcp/1"};return r&&e&&(n.Cookie=e),n}async function Xy(t,e={}){let r;for(let n=1;n<=Yy;n++)try{return await iE(t,e)}catch(o){let s=o instanceof fe?o:new fe("download_failed",String(o)),i=s.code==="network_error"||s.code==="http_429"||/^http_5/.test(s.code);if(r=s,!i||n>=Yy)throw s;await new Promise(a=>setTimeout(a,100*n))}throw r}async function iE(t,e){let r=t;for(let n=0;n<=Gy;n++){let o=new URL(r);if(o.protocol!=="https:")throw new fe("insecure_url",`\u5207\u56FE\u8D44\u6E90\u5FC5\u987B\u8D70 https\uFF1A${r}`);if(o.username||o.password)throw new fe("credentials_in_url",`\u8D44\u6E90 URL \u643A\u5E26\u51ED\u636E\uFF0C\u5DF2\u62D2\u7EDD\uFF1A${o.hostname}`);if(!oE(o.hostname))throw new fe("host_not_allowed",`\u8D44\u6E90\u4E3B\u673A\u4E0D\u5728\u767D\u540D\u5355\u5185\uFF1A${o.hostname}`);let s;try{s=await fetch(r,{headers:sE(r,e.cookie),redirect:"manual"})}catch(l){throw new fe("network_error",`\u8BF7\u6C42\u5931\u8D25\uFF1A${l?.message||l}`)}if(s.status>=300&&s.status<400){let l=s.headers.get("location");if(!l)throw new fe("redirect_no_location",`\u91CD\u5B9A\u5411\u7F3A\u5C11 Location\uFF08HTTP ${s.status}\uFF09`);r=new URL(l,r).toString();continue}if(s.status===401||s.status===403)throw new fe("access_denied",`\u8D44\u6E90\u88AB\u62D2\u7EDD\uFF08HTTP ${s.status}\uFF09\uFF1A\u767B\u5F55\u6001\u6216\u9879\u76EE\u6743\u9650\u4E0D\u8DB3`);if(s.status===429||s.status>=500)throw new fe(`http_${s.status}`,`\u8D44\u6E90\u7AEF\u6682\u4E0D\u53EF\u7528\uFF08HTTP ${s.status}\uFF09`);if(!s.ok)throw new fe(`http_${s.status}`,`\u8D44\u6E90\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${s.status}\uFF09`);if(Number(s.headers.get("content-length")||0)>On)throw new fe("too_large",`\u8D44\u6E90\u8D85\u8FC7 ${Math.round(On/1024/1024)}MiB \u4E0A\u9650`);let a=[],c=0,u=s.body?.getReader();if(!u)throw new fe("network_error","\u54CD\u5E94\u65E0\u53EF\u8BFB\u6B63\u6587");for(;;){let{done:l,value:d}=await u.read();if(l)break;if(c+=d.byteLength,c>On)throw await u.cancel(),new fe("too_large",`\u8D44\u6E90\u8D85\u8FC7 ${Math.round(On/1024/1024)}MiB \u4E0A\u9650`);a.push(Buffer.from(d))}return{bytes:Buffer.concat(a),contentType:s.headers.get("content-type")||"",finalUrl:r}}throw new fe("too_many_redirects",`\u91CD\u5B9A\u5411\u8D85\u8FC7 ${Gy} \u6B21`)}async function Qy(t){if(!t||t.length===0)throw new fe("empty_asset","\u5207\u56FE\u5185\u5BB9\u4E3A\u7A7A");if(t.length>On)throw new fe("too_large",`\u5207\u56FE\u8D85\u8FC7 ${Math.round(On/1024/1024)}MiB \u4E0A\u9650`);let e=t.subarray(0,1024).toString("latin1").trimStart().toLowerCase();if(e.startsWith("<!doctype html")||e.startsWith("<html"))throw new fe("html_response","\u670D\u52A1\u5668\u8FD4\u56DE\u4E86\u7F51\u9875\u800C\u975E\u56FE\u7247");let r=eE("sha256").update(t).digest("hex");return e.startsWith("<?xml")||e.startsWith("<svg")||e.startsWith("<!--")||e.charCodeAt(0)===65279?{...cE(t),sha256:r,bytes:t.length}:{...await aE(t),sha256:r,bytes:t.length}}async function aE(t){let e;try{e=await tE(t).metadata()}catch{throw new fe("invalid_image","\u5185\u5BB9\u4E0D\u662F\u5B8C\u6574\u7684\u53D7\u652F\u6301\u56FE\u7247")}let r=String(e.format||"").toLowerCase();if(!nE.has(r))throw new fe("unsupported_format",`\u89E3\u7801\u51FA\u7684\u683C\u5F0F\u4E0D\u652F\u6301\u843D\u76D8\uFF1A${r||"\u672A\u77E5"}`);return{format:r==="jpg"?"jpeg":r,width:e.width,height:e.height,isVector:!1,hasAlpha:e.hasAlpha}}function cE(t){let e=t.toString("utf8");if(/<!\s*(?:DOCTYPE|ENTITY)|<\?xml-stylesheet/i.test(e))throw new fe("unsafe_svg","SVG \u542B DTD/ENTITY/\u5916\u90E8\u6837\u5F0F\u8868\uFF0C\u5DF2\u62D2\u7EDD");if(!/<svg[\s>]/i.exec(e))throw new fe("invalid_image","\u5185\u5BB9\u4E0D\u662F SVG \u56FE\u7247");if(/<\s*(script|foreignObject|iframe|object|embed|audio|video|animate|animateMotion|animateTransform|set)\b/i.test(e))throw new fe("unsafe_svg","SVG \u542B\u811A\u672C\u6216\u4E3B\u52A8\u5185\u5BB9\u5143\u7D20\uFF0C\u5DF2\u62D2\u7EDD");if(/\son[a-z]+\s*=/i.test(e))throw new fe("unsafe_svg","SVG \u542B\u4E8B\u4EF6\u5C5E\u6027\uFF0C\u5DF2\u62D2\u7EDD");let n=/(?:xlink:)?href\s*=\s*["'](?!#)([^"']*)/ig;for(let i of e.matchAll(n)){let a=i[1].trim();if(!a.startsWith("#"))throw new fe("unsafe_svg",`SVG \u542B\u5916\u90E8\u5F15\u7528\uFF1A${a.slice(0,80)}`)}if(/@import|expression\s*\(|javascript\s*:/i.test(e))throw new fe("unsafe_svg","SVG \u542B\u4E3B\u52A8\u6837\u5F0F\uFF0C\u5DF2\u62D2\u7EDD");for(let i of e.matchAll(/url\s*\(\s*['"]?([^)'"]+)/gi)){let a=i[1].trim();if(!a.startsWith("#"))throw new fe("unsafe_svg",`SVG \u542B\u5916\u90E8 paint \u5F15\u7528\uFF1A${a.slice(0,80)}`)}let{width:o,height:s}=uE(e);return{format:"svg",width:o,height:s,isVector:!0}}function uE(t){let e=o=>{let s=new RegExp(`<svg[^>]*\\b${o}=["']\\s*(\\d+(?:\\.\\d+)?)px?["']`,"i").exec(t),i=s?Number(s[1]):NaN;return Number.isFinite(i)&&i>0?i:void 0},r=e("width"),n=e("height");if(!r||!n){let o=/viewBox=["']\s*[\d.eE+-]+[\s,]+[\d.eE+-]+[\s,]+(\d+(?:\.\d+)?)[\s,]+(\d+(?:\.\d+)?)["']/i.exec(t);o&&(r=r||Number(o[1]),n=n||Number(o[2]))}return{width:r,height:n}}function e_(t,e,r,n=4,o="png"){if(!t||!e||!r)return{};let s=Math.max(1,Math.round(e)),i=Math.max(1,Math.round(r)),a=s*n,c=i*n,u=(f,m)=>{f=Math.max(1,Math.round(f)),m=Math.max(1,Math.round(m));let p=f===a&&m===c?"":`resize,w_${f},h_${m}/`,h=o==="png"?"format,png":`format,${o}`;return`${t}?x-oss-process=image/${p}${h}`},l=f=>Math.floor(f+.5),d=a/4;return{original:o==="png"?t:`${t}?x-oss-process=image/format,${o}`,"1x":u(s*1,i*1),"2x":u(s*2,i*2),"3x":u(s*3,i*3),ios_1x:u(l(d*1),l(c/4*1)),ios_2x:u(l(d*2),l(c/4*2)),ios_3x:u(l(d*3),l(c/4*3)),android_mdpi:u(l(a/4*1),l(c/4*1)),android_hdpi:u(l(a/4*1.5),l(c/4*1.5)),android_xhdpi:u(l(a/4*2),l(c/4*2)),android_xxhdpi:u(l(a/4*3),l(c/4*3)),android_xxxhdpi:u(a,c)}}var Cn="https://lanhuapp.com",ji="\u65B9\u5F0F1\uFF1A\u6D4F\u89C8\u5668\u767B\u5F55\u84DD\u6E56\u540E\u6309 F12 \u2192 Network \u2192 \u70B9\u4EFB\u610F\u8BF7\u6C42 \u2192 \u590D\u5236 Cookie \u5934\u6574\u4E32\uFF0C\u5199\u5165 .mcp-local/lanhu.cookie\uFF08\u6216\u8BBE LANHU_COOKIE \u73AF\u5883\u53D8\u91CF\uFF09\uFF1B\u65B9\u5F0F2\uFF1A\u53CC\u51FB lanhu-login.bat\uFF08\u6216\u8FD0\u884C npm run login\uFF09\uFF0C\u6D4F\u89C8\u5668\u767B\u5F55\u540E\u6309 Enter \u81EA\u52A8\u5199\u5165 cookie\u3002\u5B8C\u6210\u540E\u8BA9 AI \u91CD\u8BD5\u3002";function fE(t){if(t.teamId)return t.teamId;if(t.url){let{teamId:e}=Di(t.url);if(e&&e!=="0")return e}throw new Error("\u65E0\u6CD5\u5B9A\u4F4D\u56E2\u961F\uFF1A\u8BF7\u4F20 teamId\uFF08\u6765\u81EA lanhu_list_teams\uFF09\u6216 url\uFF08\u84DD\u6E56\u94FE\u63A5\u63D0 tid\uFF09\uFF1B\u7EAF cookie \u4E0D\u5E26 teamId/url \u65F6\u65E0\u6CD5\u5217\u76EE\u5F55")}async function n_(t){let e=await fetch(`${Cn}/api/account/user_teams?need_open_related=true`,{headers:Fo(t)});if(!e.ok)return{status:e.status,teams:[]};let r=await e.json();return{status:e.status,teams:r?.result||r?.data||[]}}async function o_(t){let e=dr(t),{status:r,teams:n}=await n_(e);return i_(r,"auth","\u56E2\u961F\u5217\u8868"),{teamCount:n.length,teams:n.map(o=>({teamId:o.id,name:o.name,role:o.role?.display||o.role?.name||"",isOwner:!!o.is_team_owner,memberNum:Number(o.member_num)||0}))}}function Di(t){let e=r=>{let n=new RegExp(`[?&]${r}=([a-f0-9-]+)`,"i").exec(t);return n?n[1]:null};return{projectId:e("project_id")||e("pid"),imageId:e("image_id"),teamId:e("tid")||"0"}}function dr(t){if(!t.cookie)throw new Error(`\u9700\u8981\u84DD\u6E56\u767B\u5F55\u51ED\u8BC1\uFF08\u4E8C\u9009\u4E00\uFF09\uFF1A${ji}`);return t.cookie}function s_(t){if(!t)throw new Error("\u9700\u8981\u84DD\u6E56 URL \u6216\u9879\u76EE UUID");if(/[/?]/.test(t)){let{projectId:e}=Di(t);if(e)return e}if(/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i.test(t))return t;throw new Error(`\u65E0\u6CD5\u8BC6\u522B\u7684\u9879\u76EE\u6807\u8BC6\uFF1A${t}\uFF08\u5E94\u4E3A\u84DD\u6E56 URL \u6216\u9879\u76EE UUID\uFF09`)}function Fo(t){return{Cookie:t,Accept:"application/json, text/plain, */*",Referer:"https://lanhuapp.com/web/"}}function r_(t,e){let r=new URL(t).hostname;return r==="lanhuapp.com"||r.endsWith(".lanhuapp.com")?Fo(e):{Referer:"https://lanhuapp.com/"}}var Mi=class extends Error{constructor(r,n,o){super(o);this.status=r;this.scope=n;this.hint=o;this.name="LanhuHttpError"}status;scope;hint};function i_(t,e,r){if(!(t>=200&&t<300))throw t===401?e==="auth"?new Mi(401,"auth",`\u84DD\u6E56\u9274\u6743\u5931\u8D25\uFF08HTTP 401\uFF09\uFF1Acookie \u5DF2\u8FC7\u671F\u6216\u7F3A\u5931\u5173\u952E\u5B57\u6BB5\u3002${ji}`):new Mi(401,"resource",`\u65E0\u6743\u8BBF\u95EE${r}\uFF08HTTP 401\uFF09\uFF1Acookie \u4ECD\u53EF\u80FD\u6709\u6548\uFF0C\u4F46\u8BE5\u8D44\u6E90\u672A\u5BF9\u4F60\u5206\u4EAB\u3002\u91CD\u65B0\u767B\u5F55\u65E0\u6548\uFF0C\u8BF7\u8054\u7CFB\u8BBE\u8BA1\u8005\u5F00\u901A\u6743\u9650\uFF0C\u6216\u6362\u4E00\u4E2A\u6709\u6743\u9650\u7684${r}\u3002`):new Error(`\u8BF7\u6C42${r}\u5931\u8D25\uFF1AHTTP ${t}`)}function Zi(t,e,r){i_(t.status,e,r)}async function a_(t){if(!t.cookie)return{ok:!1,status:0,reason:"no_cookie",hint:`\u672A\u914D\u7F6E\u84DD\u6E56 cookie\u3002${ji}`};try{let{status:e,teams:r}=await n_(t.cookie);return e>=200&&e<300?{ok:!0,teamCount:r.length,teams:r.map(n=>({teamId:n.id,name:n.name}))}:{ok:!1,status:e,reason:e===401?"cookie_expired":`http_${e}`,hint:e===401?`cookie \u5DF2\u8FC7\u671F\u6216\u65E0\u6548\u3002${ji}`:`\u84DD\u6E56\u8FD4\u56DE HTTP ${e}\uFF0C\u7A0D\u540E\u91CD\u8BD5\u6216\u68C0\u67E5\u7F51\u7EDC\u3002`}}catch(e){return{ok:!1,status:0,reason:"network_error",hint:`\u7F51\u7EDC\u8BF7\u6C42\u5931\u8D25\uFF1A${e?.message||e}`}}}function mE(t,e){let n=/charset=([\w-]+)/i.exec(e||"")?.[1]?.toLowerCase(),o=a=>{try{let c=new TextDecoder(a,{fatal:!0}).decode(t);return JSON.parse(c)}catch{return null}};if(n&&n!=="iso-8859-1"){let a=o(n);if(a!=null)return a}let s=o("utf-8");if(s!=null)return s;let i=new TextDecoder("iso-8859-1").decode(t);if(/[-ÿ]/.test(i)&&!/[一-鿿]/.test(i)){let a=o("gbk");if(a!=null)return a}return JSON.parse(i)}async function Uo(t,e,r,n){let o=Fo(r),s=await fetch(`${Cn}/api/project/image?pid=${e}&image_id=${t}`,{headers:o});Zi(s,"resource","\u8BBE\u8BA1\u7A3F");let i=await s.json(),a=i?.result||i?.data||{},c=a.versions||[],u=c[0]?.json_url,l=[],d={rawLayerCount:0,totalLayerCount:0},f=a.width||0,m=a.height||0,p=[];if(u){let g=await fetch(u,{headers:r_(u,r)});if(!g.ok)throw new Error(`\u4E0B\u8F7D\u8BBE\u8BA1\u7A3F\u6807\u6CE8\u6570\u636E\u5931\u8D25\uFF1AHTTP ${g.status}\uFF08${u}\uFF09`);let y=mE(await g.arrayBuffer(),g.headers.get("content-type")||""),_=Td(y),w=Jy(_);l=w.layers,d=w.meta;let x=_?.artboard;x?.frame&&(f=Math.round(Number(x.frame.width||0))||f,m=Math.round(Number(x.frame.height||0))||m),p=hE(x)}let h;if(n.needCover){let g=a.url||c[0]?.url;if(g){let y=await fetch(g,{headers:r_(g,r)});if(y.ok){let _=Buffer.from(await y.arrayBuffer());h=(await Wy(_,f,m)).toString("base64")}}}return{source:"api",name:a.name,viewport:{width:f,height:m},layers:l,meta:{...d,docName:a.name??d.docName},...p.length?{slices:p}:{},...h?{coverImageBase64:h}:{}}}function hE(t){let e=[],r=n=>{if(!(!n||typeof n!="object")){if(n.hasExportImage&&n.image?.imageUrl){let o=n.frame||{};e.push({name:String(n.name||"slice"),imageUrl:n.image.imageUrl,x:Math.round(Number(o.x??o.left??0)),y:Math.round(Number(o.y??o.top??0)),w:Math.round(Number(o.width??0)),h:Math.round(Number(o.height??0))})}for(let o of n.layers||[])r(o)}};return r(t),e}function gE(t){return pE("md5").update(t).digest("hex").slice(0,8)}async function Li(t,e){let{projectId:r,imageId:n}=Di(t);if(!r)throw new Error("\u65E0\u6CD5\u4ECE URL \u63D0\u53D6 project_id/pid");if(!n)throw new Error("\u65E0\u6CD5\u4ECE URL \u63D0\u53D6 image_id");let o=dr(e);return{...await Uo(n,r,o,e),url:t}}async function c_(t,e,r){let n=dr(r),o=await Uo(t,e,n,r);return{...o,name:o.name||t}}async function u_(t){let e=dr(t),r={...Fo(e),"Content-Type":"application/json"},n=fE(t),o=await fetch(`${Cn}/workbench/api/workbench/abstractfile/list`,{method:"POST",headers:r,body:JSON.stringify({tenantId:n,parentId:0})});Zi(o,"auth","\u56E2\u961F\u76EE\u5F55");let s=await o.json(),i=Array.isArray(s.data)?s.data:[],a=i.filter(h=>h.sourceType==="folder"),c=i.filter(h=>h.sourceType!=="folder"),u=[],l=await Promise.all(a.map(async h=>{try{let g=await fetch(`${Cn}/workbench/api/workbench/abstractfile/list`,{method:"POST",headers:r,body:JSON.stringify({tenantId:n,parentId:h.id})});if(!g.ok)return u.push(String(h.name||h.id)),[];let y=await g.json();return Array.isArray(y.data)?y.data:[]}catch{return u.push(String(h.name||h.id)),[]}})),d=[...c,...l.flat()],f=[],m=(await Promise.all(d.map(h=>Id(h.sourceId,t).then(g=>({ok:!0,value:{project:h.sourceName,projectId:h.sourceId,sectors:g.sectors.map(y=>({name:y.name,designCount:y.designCount}))}})).catch(g=>(f.push({project:h.sourceName,projectId:h.sourceId,error:g?.message||String(g)}),{ok:!1}))))).filter(h=>h.ok).map(h=>h.value),p=m.reduce((h,g)=>h+g.sectors.length,0);return{teamId:n,projectCount:m.length,sectorCount:p,directory:m,...f.length?{failedProjects:f}:{},...u.length?{failedFolders:u}:{}}}async function Id(t,e){let r=dr(e),n=Fo(r),o="0",s=await fetch(`${Cn}/api/project/project_sectors?project_id=${t}`,{headers:n});Zi(s,"resource","\u9879\u76EE\u5206\u7EC4");let i=await s.json(),a=i?.data?.sectors||i?.result?.sectors||[],c=await fetch(`${Cn}/api/project/images?project_id=${t}&team_id=${o}&dds_status=1`,{headers:n});Zi(c,"resource","\u9879\u76EE\u8BBE\u8BA1\u7A3F\u5217\u8868");let u=await c.json(),l=u?.data?.images||u?.data?.list||u?.data||[],d=new Map;for(let f of l){let m=f.image_id||f.id;m&&d.set(m,f.name||f.image_name||m)}return{projectId:t,sectorCount:a.length,sectors:a.map(f=>({id:f.id,name:f.name,designCount:(f.images||[]).length,designs:(f.images||[]).map(m=>({image_id:m,name:d.get(m)||m}))}))}}async function l_(t,e,r){let n=s_(t),o=await Id(n,r),s=o.sectors.find(u=>u.name===e||u.id===e);if(!s)throw new Error(`\u672A\u627E\u5230\u5206\u7EC4\u300C${e}\u300D\uFF0C\u53EF\u7528\u5206\u7EC4\uFF1A${o.sectors.map(u=>u.name).join("\u3001")}`);let i=dr(r),a=[],c=(await Promise.all(s.designs.map(u=>Uo(u.image_id,n,i,{}).then(l=>({ok:!0,value:{image_id:u.image_id,name:u.name,viewport:l.viewport,layerCount:l.layers.length}})).catch(l=>(a.push({image_id:u.image_id,name:u.name,error:l?.message||String(l)}),{ok:!1}))))).filter(u=>u.ok).map(u=>u.value);return{sector:s.name,designCount:c.length,designs:c,...a.length?{failed:a}:{}}}async function d_(t,e,r){let n=r.skipExisting!==!1,o=r.sliceNames?.length?new Set(r.sliceNames):null,s,i,a;if(r.sector){let $=s_(t),P=dr(r),J=await Id($,r),H=J.sectors.find(O=>O.name===r.sector||O.id===r.sector);if(!H)throw new Error(`\u672A\u627E\u5230\u5206\u7EC4\u300C${r.sector}\u300D\uFF0C\u53EF\u7528\u5206\u7EC4\uFF1A${J.sectors.map(O=>O.name).join("\u3001")}`);i=[];let k=[];await Promise.all(H.designs.map(O=>Uo(O.image_id,$,P,{}).then(E=>i.push(...E.slices||[])).catch(E=>k.push(`${O.name}: ${E?.message||E}`)))),k.length&&(a=k),s=H.name}else{let $=null,P=r.projectId||"";if(/[/?]/.test(t)){let k=Di(t);$=k.imageId,P=k.projectId||P}else $=t;if(!$)throw new Error("\u65E0\u6CD5\u4ECE\u8F93\u5165\u89E3\u6790 image_id\uFF0C\u8BF7\u4F20\u8BBE\u8BA1\u7A3F URL \u6216 image_id");if(!P)throw new Error("\u4E0B\u8F7D\u5207\u56FE\u9700\u8981 projectId\uFF1A\u4F20 URL \u81EA\u52A8\u63D0\u53D6\uFF0C\u6216\u663E\u5F0F\u4F20 projectId");let J=dr(r),H=await Uo($,P,J,{});i=H.slices||[],s=H.name||$}if(!i.length)return{scope:s,outputDir:Ai.resolve(e),downloaded:0,skipped:{dup:0,exist:0},failed:[],slices:[]};let c=Ai.resolve(e);dE(c,{recursive:!0});let u=new Set,l=[],d=0;for(let $ of i){let P=$.imageUrl;if(P&&!(o&&!o.has($.name))){if(u.has(P)){d++;continue}u.add(P),l.push({...$,imageUrl:P})}}let f=[],m=[],p=0,h=r.scale||"2x",g=h==="original"?0:Number(h.replace("x","")),y=Number(process.env.LANHU_SLICE_CONCURRENCY)||6,_=0,w=async()=>{for(;_<l.length;){let $=_++,P=l[$],J=P.imageUrl,H=String(P.name).replace(/[/\\:*?"<>|]/g,"_").replace(/\s+/g,"_"),k=gE(J),O=r.format||"png",E=e_(J,P.w,P.h,4,O),F=E[h]||J,re=h==="2x"?"":`@${h}`,K=g?Math.round(P.w*g):0,Ve=g?Math.round(P.h*g):0,ce=h==="original"?null:Ai.join(c,`${H}_${k}${re}.${O}`);if(ce&&n&&t_(ce)){p++,f[$]={name:P.name,file:ce,bytes:0,w:P.w,h:P.h,x:P.x,y:P.y,scale:h,format:O,pixelW:K,pixelH:Ve,sha256:""};continue}let A,oe;try{let zt=await Xy(F,{cookie:r.cookie});oe=await Qy(zt.bytes),A=zt.bytes}catch(zt){let Fi=zt instanceof fe?zt.code:"download_failed",Vi=/^http_(\d+)$/.exec(Fi);m.push({name:P.name,url:J,status:Vi?Number(Vi[1]):0,reason:Fi});continue}let Ee=oe.format==="jpeg"?"jpg":oe.format,He=ce||Ai.join(c,`${H}_${k}${re}.${Ee}`);if(He!==ce&&n&&t_(He)){p++,f[$]={name:P.name,file:He,bytes:0,w:P.w,h:P.h,x:P.x,y:P.y,scale:h,format:oe.format,pixelW:oe.width||0,pixelH:oe.height||0,sha256:oe.sha256};continue}lE(He,A),f[$]={name:P.name,file:He,bytes:A.length,w:P.w,h:P.h,x:P.x,y:P.y,scale:h,format:oe.format,pixelW:oe.width||0,pixelH:oe.height||0,sha256:oe.sha256,...r.withScaleUrls?{scaleUrls:E}:{}}}},x=Array.from({length:Math.min(y,l.length||1)},()=>w());return await Promise.all(x),{scope:s,outputDir:c,downloaded:f.filter($=>$&&$.bytes>0).length,skipped:{dup:d,exist:p},failed:m,slices:f.filter(Boolean),...a?{designErrors:a}:{}}}import{request as yE}from"node:https";import{request as _E}from"node:http";import{createHash as p_}from"node:crypto";import{existsSync as vE,mkdirSync as bE,readFileSync as xE,writeFileSync as wE}from"node:fs";import h_ from"node:path";import{fileURLToPath as $E}from"node:url";var Ho=process.env.VLM_MODEL||"deepseek-v4-flash-vision-exp",g_=process.env.VLM_API_KEY||"",y_=(process.env.VLM_BASE_URL||"https://api.deepseek.com").replace(/\/+$/,"").replace(/\/v1$/,""),kE=process.env.VISION_USE_V1!=="0",SE=Number(process.env.LANHU_VISION_MAX_TOKENS)||8192,zE=32*1024*1024,PE=48*1024*1024,Vo=3;function f_(t){return`${y_}${t?"/v1":""}/chat/completions`}function TE(t){let e=t.includes(",")?t.slice(t.indexOf(",")+1):t,r=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.max(0,Math.floor(e.length*3/4)-r)}function EE(t){let e=0;if(t.forEach((r,n)=>{let o=TE(r);if(e+=o,o>zE)throw new Error(`\u7B2C ${n+1} \u5F20\u56FE\u7EA6 ${(o/1024/1024).toFixed(1)} MiB\uFF0C\u8D85\u8FC7\u5355\u56FE 32 MiB \u4E0A\u9650\uFF0C\u8BF7\u5148\u538B\u7F29\u518D\u8C03\u7528`)}),e>PE)throw new Error(`${t.length} \u5F20\u56FE\u5408\u8BA1\u7EA6 ${(e/1024/1024).toFixed(1)} MiB\uFF0C\u8D85\u8FC7\u8BF7\u6C42\u4F53 48 MiB \u4E0A\u9650`)}function IE(t){return t.includes("json")?t:`${t}
|
|
44
44
|
|
|
45
|
-
Output strictly valid json, no extra text.`}function
|
|
46
|
-
|
|
47
|
-
Output
|
|
45
|
+
Output strictly valid json, no extra text.`}function An(){return!!Ho&&!!g_}function __(){return An()&&process.env.LANHU_AUTO_ANALYZE!=="0"}var Nd=process.env.LANHU_VISION_CACHE_DIR||$E(new URL("../.mcp-local/vision-cache/",import.meta.url)),v_=process.env.LANHU_VISION_CACHE!=="0";function RE(t,e,r){let n=p_("sha1").update(t.join("\0")).digest("hex").slice(0,16);return p_("sha1").update(`${e}\0${n}\0${r}\0${Ho}\0${y_}`).digest("hex")}function NE(t){if(!v_)return null;try{let e=h_.join(Nd,`${t}.json`);if(!vE(e))return null;let r=JSON.parse(xE(e,"utf8"));return console.error(`[vision] \u7F13\u5B58\u547D\u4E2D ${t.slice(0,8)}\uFF08\u8DF3\u8FC7\u6A21\u578B\u8C03\u7528\uFF09`),r}catch{return null}}function OE(t,e){if(v_)try{bE(Nd,{recursive:!0});let r=JSON.stringify(e);if(r.length>512*1024)return;wE(h_.join(Nd,`${t}.json`),r)}catch(r){console.error(`[vision] \u7F13\u5B58\u5199\u5165\u5931\u8D25: ${r.message}`)}}var CE=`You are a senior UI/frontend engineer. Precise geometry (x/y/width/height/font sizes/hex colors) is provided separately in a layers field \u2014 do NOT estimate or output any numeric sizes or colors from the image. Your job is ONLY the semantic understanding that data cannot express.
|
|
46
|
+
SCOPE: the image may show content beyond the main artboard (e.g. a full page visible behind a modal). Analyze the FOREGROUND artboard/screen as the subject; surrounding content is context only \u2014 mention it only in notes.
|
|
47
|
+
Output JSON:
|
|
48
|
+
{"page_type": EXACTLY one of "login|onboarding|list|detail|dashboard|profile|settings|form|search|landing|popup|bottom_sheet|other","layout":"top-down sections chained by \u2192, each as name: short role; names are snake_case identifiers reused by components.section","components":[interactive/structural elements of the FOREGROUND artboard ONLY (buttons, inputs, cards, list items, tabs, nav bars, banners, toggles, tables) \u2014 NEVER plain text labels or icons, the layers field already enumerates them with exact geometry; elements belonging to background/context content stay out of this list (notes only); at most 20, most important first; an element repeating identically is listed ONCE with a repeat count like "card \xD77"; if some must be dropped, keep interactive over decorative and name the dropped ones in notes. Each:{"name":"snake_case identifier","type":"button|input|card|list_item|tab|nav|banner|toggle|table|other","section":"exact layout section name it belongs to","interaction":"static|clickable|input|toggle|swipe|scrollable"}],"states":["visible state variations and their meaning, e.g. \\"selected card: gold border = checked-in today; other cards: idle\\"; [] if single-state"],"imagery":"for EVERY image and overlay (mask/scrim/gradient): 1) what it depicts or does 2) relation to adjacent text (text-on-image needs a dark scrim / text-on-gradient / standalone no overlay) 3) real asset or placeholder-to-be-replaced; reference sections/components by name","style_atmosphere":"color mood + font character + spacing rhythm (compact/airy), plus reusable style groups you can spot (e.g. one primary-button style, one card style shared by all cards) \u2014 natural language, NO hex values","notes":"what data cannot express: implied motion, implied truncation, icon metaphors; AND anomalies \u2014 duplicate/mislabelled text, copy-paste leftovers, placeholder copy, assets visible in the image but seemingly missing from the data; whether content exists beyond the artboard"}
|
|
49
|
+
FORMAT EXAMPLES \u2014 they demonstrate format & level of detail ONLY; never copy their content, names, or theme into your output:
|
|
50
|
+
Mobile app screen: {"page_type":"detail","layout":"player_header: cover art & back \u2192 track_info: title & artist \u2192 controls: transport controls \u2192 up_next: queued tracks","components":[{"name":"play_button","type":"button","section":"controls","interaction":"clickable"},{"name":"seek_bar","type":"input","section":"controls","interaction":"input"},{"name":"queue_item \xD712","type":"list_item","section":"up_next","interaction":"clickable"}],"states":["play_button shows a pause icon = track currently playing; no queue row highlighted"],"imagery":"full-bleed cover art sits behind track_info, its title text needs a dark scrim; artist avatar is a real asset; queue rows use small thumbnails","style_atmosphere":"dark theme, neon accent, compact rhythm","notes":"implied motion: equalizer bars animate on the playing row; anomaly: track title ends in an ellipsis, likely truncated"}
|
|
51
|
+
Desktop web page: {"page_type":"dashboard","layout":"sidebar: section nav \u2192 topbar: search & account \u2192 kpi_row: metric cards \u2192 chart_area: trend charts","components":[{"name":"nav_item \xD76","type":"tab","section":"sidebar","interaction":"clickable"},{"name":"search_field","type":"input","section":"topbar","interaction":"input"},{"name":"metric_card \xD74","type":"card","section":"kpi_row","interaction":"static"},{"name":"export_button","type":"button","section":"chart_area","interaction":"clickable"}],"states":["nav_item: filled background = active section; export_button disabled until a chart is selected"],"imagery":"sparkline glyphs inside metric cards are decorative real assets; no text-on-image","style_atmosphere":"light theme, single blue accent, dense data rhythm","notes":"sidebar chevron implies it collapses; scrollbar implies more rows below the fold; no anomalies"}
|
|
52
|
+
Discipline: each description \u226430 words; everything in English except verbatim UI text quotes; Only output JSON.`;function b_(t,e){let r=t?.trim(),n=r?`
|
|
48
53
|
|
|
49
|
-
Context: the design file is named "${r}" (from the design tool). Use it as background context only
|
|
54
|
+
Context: the design file is named "${r}" (from the design tool). Use it as background context only \u2014 do not invent components to match the name, and keep the analysis scoped to the foreground artboard even when more content is visible.`:"",o=e?.trim()?`
|
|
50
55
|
|
|
51
56
|
Additional focus from the caller (business context / priorities \u2014 reflect them in your analysis, but keep the SAME JSON structure and describe only what is visible):
|
|
52
|
-
"${e.trim()}"`:"";return CE+n+o}var m_=null;async function jE(t,e,r){return new Promise((n,o)=>{let s=new URL(t),i=s.protocol==="https:"?yE:_E,a=JSON.stringify(e),c=i({hostname:s.hostname,port:s.port||(s.protocol==="https:"?443:80),path:s.pathname+s.search,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(a),...r?{Authorization:`Bearer ${r}`}:{}}},l=>{let d=[];l.on("data",p=>d.push(p)),l.on("end",()=>{let p=Buffer.concat(d).toString("utf8");try{n({status:l.statusCode||0,json:JSON.parse(p)})}catch{o(new Error(`\u89C6\u89C9\u6A21\u578B API \u8FD4\u56DE HTTP ${l.statusCode}\uFF0C\u54CD\u5E94\u975E JSON\uFF1A${p.slice(0,120)}`))}})}),u=Number(process.env.LANHU_VISION_TIMEOUT_MS)||12e4;c.setTimeout(u,()=>{c.destroy(new Error(`\u89C6\u89C9\u6A21\u578B API \u8BF7\u6C42\u8D85\u65F6\uFF08${u}ms\uFF09\uFF0C\u53EF\u8BBE LANHU_VISION_TIMEOUT_MS \u8C03\u6574`))}),c.on("error",o),c.write(a),c.end()})}var Rd=new Map;async function Jr({images:t=[],text:e,detail:r="auto"}){EE(t);let n=RE(t,e,r),o=NE(n);if(o)return o;let s=Rd.get(n);if(s)return console.error("[vision] \u76F8\u540C\u8BF7\u6C42\u5728\u9014\uFF0C\u590D\u7528\u5176\u7ED3\u679C"),s;let i=AE({images:t,text:e,detail:r},n).finally(()=>Rd.delete(n));return Rd.set(n,i),i}async function AE({images:t=[],text:e,detail:r="auto"},n){let o=[{type:"text",text:IE(e)},...t.map(l=>({type:"image_url",image_url:{url:l.startsWith("data:")?l:`data:image/png;base64,${l}`,detail:r}}))],s={model:Ho,messages:[{role:"user",content:o}],response_format:{type:"json_object"},max_tokens:SE,temperature:0,top_p:.95};/glm/i.test(Ho)&&(s.thinking={type:"enabled",clear_thinking:!1},s.reasoning_effort="max");let i=null,a=m_??kE,c=!1,u=!1;for(let l=1;l<=Vo;l++){let d=Date.now(),p=0,m=null;try{let y=await jE(p_(a),s,g_);p=y.status,m=y.json}catch(y){p=0,i=y instanceof Error?y:new Error(String(y))}if(p===404&&!c){c=!0,a=!a,m_=a,l--,console.error(`[vision] HTTP 404 \u2192 \u5207\u6362\u7AEF\u70B9\u4E3A ${p_(a)}`);continue}if(p===400&&s.response_format&&!u&&/response_format|json_object/i.test(JSON.stringify(m?.error||""))){u=!0,delete s.response_format,l--,console.error("[vision] \u6A21\u578B\u62D2\u7EDD response_format \u2192 \u964D\u7EA7\u4E3A\u63D0\u793A\u8BCD\u7EA6\u675F\u91CD\u8BD5");continue}if((p===0||p===429||p>=500)&&l<Vo){let y=1e3*l,_=p===0?"\u7F51\u7EDC/\u8D85\u65F6":`HTTP ${p}`;i==null&&(i=new Error(`\u89C6\u89C9\u6A21\u578B API HTTP ${p}\uFF1A${m?.error?.message||m?.message||JSON.stringify(m).slice(0,150)}`)),console.error(`[vision] ${_}\uFF0C${y}ms \u540E\u91CD\u8BD5\uFF08attempt=${l}/${Vo}\uFF09\uFF1A${i.message}`),await new Promise(w=>setTimeout(w,y));continue}if(p<200||p>=300){let y=m?.error?.message||m?.message||JSON.stringify(m).slice(0,150);throw new Error(`\u89C6\u89C9\u6A21\u578B API HTTP ${p}\uFF1A${y}`)}let h=m?.choices?.[0],g=h?.message?.content||"";if(console.error(`[vision] ${Ho} ${t.length}\u56FE detail=${r} attempt=${l} \u2192 HTTP ${p} \u8017\u65F6${Date.now()-d}ms finish=${h?.finish_reason} tokens=${m?.usage?.total_tokens} contentLen=${g.length}`),g.trim()){let y=g.replace(/^```(?:json)?\s*/i,"").replace(/\s*```$/,"");try{let _=JSON.parse(y);return OE(n,_),_}catch{return{_raw:g}}}i=new Error(`\u89C6\u89C9\u6A21\u578B\u8FD4\u56DE\u7A7A content\uFF08HTTP ${p}\uFF0Cfinish_reason=${h?.finish_reason??"\u65E0choices\u5B57\u6BB5"}\uFF0C\u54CD\u5E94\u4F53=${JSON.stringify(m).slice(0,120)}\uFF09`),l<Vo&&(console.error(`[vision] \u7A7A\u54CD\u5E94\uFF0C${l}s \u540E\u91CD\u8BD5\u2026`),await new Promise(y=>setTimeout(y,1e3*l)))}throw new Error(`${i.message}\u3002\u91CD\u8BD5 ${Vo} \u6B21\u4ECD\u4E3A\u7A7A\uFF0C\u591A\u4E3A\u6A21\u578B\u7AEF/\u4EE3\u7406\u5F02\u5E38\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002`)}function ME(){let t=r=>{let n=[],o=r;for(;o&&o!==document.body;){let s=o.tagName.toLowerCase(),i=o.getAttribute("id");if(i)s+=`#${i}`;else{let a=(o.getAttribute("class")||"").trim().split(/\s+/).filter(Boolean)[0];a&&(s+=`.${a}`)}n.unshift(s),o=o.parentElement}return n.join(" > ")||r.tagName.toLowerCase()},e=[];for(let r of Array.from(document.querySelectorAll("body *"))){let n=r.getBoundingClientRect();if(n.width<=0||n.height<=0||r.tagName==="SVG")continue;let o=getComputedStyle(r);if(o.display==="none"||o.visibility==="hidden"||Number(o.opacity)===0)continue;let s=Array.from(r.childNodes).filter(u=>u.nodeType===3).map(u=>(u.textContent||"").trim()).join(" ").trim();if(r.children.length>0&&!s)continue;let i=parseFloat(o.lineHeight),a="",c=r.parentElement;for(let u=0;u<3&&c;u++){let l=getComputedStyle(c).backgroundColor;if(l&&l!=="rgba(0, 0, 0, 0)"&&l!=="transparent"){a=l;break}c=c.parentElement}e.push({selector:t(r),text:s,x:Math.round((n.x+window.scrollX)*100)/100,y:Math.round((n.y+window.scrollY)*100)/100,width:Math.round(n.width*100)/100,height:Math.round(n.height*100)/100,color:o.color,backgroundColor:o.backgroundColor,bgAncestor:a,fontSize:parseFloat(o.fontSize)||0,fontWeight:Number(o.fontWeight)||0,lineHeight:Number.isFinite(i)?Math.round(i*100)/100:null})}return e}function Bo(t){let e=String(t||"").trim(),r=/^#([0-9a-f]{3})$/i.exec(e);if(r){let n=r[1].split("").map(o=>parseInt(o+o,16));return{r:n[0],g:n[1],b:n[2],a:1}}if(r=/^#([0-9a-f]{6})$/i.exec(e),r)return{r:parseInt(r[1].slice(0,2),16),g:parseInt(r[1].slice(2,4),16),b:parseInt(r[1].slice(4,6),16),a:1};if(r=/^rgba?\(([^)]+)\)$/i.exec(e),r){let n=r[1].split(",").map(o=>parseFloat(o));return n.length<3||n.some(o=>!Number.isFinite(o))?null:{r:n[0],g:n[1],b:n[2],a:n.length>3?n[3]:1}}return null}function ZE(t,e){return t<=e[0]?null:t<=e[1]?"minor":t<=e[2]?"major":"critical"}var Kr={geometry:[1,3,8],fontSize:[.5,1,2],lineHeight:[1,2,4]};function DE(t,e,r,n){let o=[],s={layer:t.name||"(\u672A\u547D\u540D\u56FE\u5C42)",path:t.parentPath||"",selector:e.selector,matchBy:r},i=t.type==="text",a=(d,p,m,f)=>{let h=Math.abs(p-m),g=ZE(h,f);g&&o.push({...s,field:d,expected:p,actual:m,delta:Math.round(h*100)/100,severity:g})},c=(d,p,m)=>{let f=Bo(p),h=Bo(m);if(!f||!h||f.a<.01&&h.a<.01)return;let g=Math.max(Math.abs(f.r-h.r),Math.abs(f.g-h.g),Math.abs(f.b-h.b)),y=Math.abs(f.a-h.a);if(g<=2&&y<=.02)return;let _=y>.02||g>30?"critical":g>10?"major":"minor";h.a<.01&&_==="critical"&&(_="major"),o.push({...s,field:d,expected:p,actual:m,delta:Math.round(g*100)/100,severity:_})};if(a("x",t.x+n.dx,e.x,Kr.geometry),i){let d=Math.abs(t.w-e.width);d>Kr.geometry[0]&&o.push({...s,field:"width",expected:t.w,actual:e.width,delta:Math.round(d*100)/100,severity:"minor"})}else a("width",t.w,e.width,Kr.geometry);let u=Math.abs(t.y+n.dy-e.y);u>Kr.geometry[0]&&o.push({...s,field:"y",expected:Math.round((t.y+n.dy)*100)/100,actual:e.y,delta:Math.round(u*100)/100,severity:"minor"});let l=Math.abs(t.h-e.height);if(l>Kr.geometry[0]&&o.push({...s,field:"height",expected:t.h,actual:e.height,delta:Math.round(l*100)/100,severity:"minor"}),t.color&&c("color",t.color,e.color),t.fill){let d=Bo(t.fill);if(e.backgroundColor==="rgba(0, 0, 0, 0)"&&e.bgAncestor&&d){let p=Bo(e.bgAncestor);p&&Math.max(Math.abs(p.r-d.r),Math.abs(p.g-d.g),Math.abs(p.b-d.b))<=30&&Math.abs(p.a-d.a)<=.02||c("fill",t.fill,e.backgroundColor)}else c("fill",t.fill,e.backgroundColor)}if(t.fontSize&&a("fontSize",t.fontSize,e.fontSize,Kr.fontSize),t.fontWeight&&e.fontWeight&&t.fontWeight!==e.fontWeight){let d=t.fontWeight>=600&&e.fontWeight===700;o.push({...s,field:"fontWeight",expected:t.fontWeight,actual:e.fontWeight,delta:Math.abs(t.fontWeight-e.fontWeight),severity:d?"minor":"major"})}return typeof t.lineHeight=="number"&&e.lineHeight!=null&&a("lineHeight",t.lineHeight,e.lineHeight,Kr.lineHeight),t.text&&t.text.trim()&&e.text&&e.text.trim()&&t.text.trim()!==e.text.trim()&&o.push({...s,field:"text",expected:t.text.trim(),actual:e.text.trim(),delta:0,severity:"minor"}),o}function $_(t,e){let r=Math.max(t.x,e.x),n=Math.max(t.y,e.y),o=Math.min(t.x+t.w,e.x+e.width),s=Math.min(t.y+t.h,e.y+e.height),i=o-r,a=s-n;if(i<=0||a<=0)return 0;let c=i*a,u=t.w*t.h+e.width*e.height-c;return u>0?c/u:0}function qi(t){if(!t.length)return 0;let e=[...t].sort((n,o)=>n-o),r=e.length>>1;return e.length%2?e[r]:(e[r-1]+e[r])/2}var LE=/(状态栏|status\s*bar|system\s*bar|safe\s*area|刘海|notch|蒙版|mask|guide|标注|备份|backup|副本|copy|_old|占位|placeholder|草稿|draft|切图|slice|导出|export|temp|tmp|ref\b)/i;function qE(t,e){let r={},n=s=>{r[s]=(r[s]||0)+1},o=[];for(let s of t){if(s.opacity===0){n("opacity0");continue}if(s.w<=0||s.h<=0){n("zeroSize");continue}let i=s.name||"";if(LE.test(i)){n("noiseName");continue}if(s.y<=1&&s.x<=1&&s.w>=e*.9&&s.h>=18&&s.h<=80){n("statusBar(geom)");continue}o.push(s)}return{kept:o,skipped:t.length-o.length,reasons:r}}function UE(t,e){let r=i=>{let a=new Map;return i.forEach((c,u)=>{let l=c.text?.trim();l&&(a.has(l)||a.set(l,[]),a.get(l).push(u))}),a},n=r(t),o=r(e),s=[];for(let[i,a]of n){let c=o.get(i);!c||a.length!==1||c.length!==1||s.push({layer:t[a[0]],sample:e[c[0]],matchBy:"text"})}return s}function FE(t,e,r){let n=[];t.forEach((a,c)=>{let u=a.text?.trim()||"",l={x:a.x+r.dx,y:a.y+r.dy,w:a.w,h:a.h};e.forEach((d,p)=>{if(u&&d.text===u){let m=Math.hypot(d.x-l.x,d.y-l.y);n.push({li:c,si:p,score:10-m/1e3+$_(l,d),matchBy:"text"})}})}),n.sort((a,c)=>c.score-a.score);let o=new Set,s=new Set,i=[];for(let a of n)o.has(a.li)||s.has(a.si)||(o.add(a.li),s.add(a.si),i.push({layer:t[a.li],sample:e[a.si],matchBy:a.matchBy}));return{pairs:i,rest:t.filter((a,c)=>!o.has(c)),usedSample:s}}function VE(t){if(t.length<3)return{off:{dx:0,dy:0},inliers:t,outliers:[]};let e=t.map(i=>({dx:i.sample.x-i.layer.x,dy:i.sample.y-i.layer.y,pair:i})),r=[],n=1/0;for(let i of e){let a=e.filter(u=>Math.abs(u.dx-i.dx)<=3&&Math.abs(u.dy-i.dy)<=3),c=Math.hypot(i.dx,i.dy);(a.length>r.length||r.length>0&&a.length===r.length&&c<n)&&(r=a,n=c)}let o={dx:qi(r.map(i=>i.dx)),dy:qi(r.map(i=>i.dy))},s=new Set(r.map(i=>i.pair));return{off:o,inliers:[...s],outliers:t.filter(i=>!s.has(i))}}function x_(t,e,r,n){let o=[];t.forEach((a,c)=>{let u={x:a.x+n.dx,y:a.y+n.dy,w:a.w,h:a.h};e.forEach((l,d)=>{if(r.has(d))return;let p=$_(u,l);p>=.5&&o.push({li:c,si:d,v:p})})}),o.sort((a,c)=>c.v-a.v);let s=new Set,i=[];for(let a of o)s.has(a.li)||r.has(a.si)||(s.add(a.li),r.add(a.si),i.push({layer:t[a.li],sample:e[a.si],matchBy:"position"}));return{pairs:i,unmatched:t.filter((a,c)=>!s.has(c))}}var HE=['You are a design acceptance assistant. For each pair of "design copy" vs "actual page copy", judge whether they are semantically equivalent.',"","Rules (by priority):","1. Dynamic-value exemption: both sides are pure numbers/points/dates/counters (e.g. *30D, Lv.5, \xA529.9, 08:30), same unit and magnitude difference <2x \u2192 same=true","2. Cross-language translation equivalence \u2192 same=true","3. Synonymous paraphrase / abbreviation \u2192 same=true","4. Otherwise \u2192 same=false","","Samples (8 pairs; copy strings stay in their original languages):","\u2705 \u7ACB\u5373\u62A2\u8D2D | Buy Now (translation)","\u2705 *30D | *30\u5929 (dynamic_value_format)","\u2705 \xA529.90 | 29.9\u5143 (dynamic_value_format)","\u2705 Lv.5 | \u7B49\u7EA75 (dynamic_value_format)","\u2705 \u786E\u8BA4 | OK (abbreviation)","\u274C \u652F\u4ED8 | \u7ACB\u5373\u8D2D\u4E70 (different_meaning)","\u274C \u5DF2\u7ED3\u675F | \u8FDB\u884C\u4E2D (different_meaning)","\u274C \u514D\u8D39 | \xA59.9 (different_meaning)","",'Output JSON only: {"result":[{"same":true,"equivalence_class":"translation|synonym|abbreviation|dynamic_value_format|different_meaning","reason":"<=15 words, cite the rule number"}]}, strictly valid json for program parsing.'].join(`
|
|
53
|
-
`);async function BE(t){if(!t.length)return[];if(!
|
|
57
|
+
"${e.trim()}"`:"";return CE+n+o}var m_=null;async function AE(t,e,r){return new Promise((n,o)=>{let s=new URL(t),i=s.protocol==="https:"?yE:_E,a=JSON.stringify(e),c=i({hostname:s.hostname,port:s.port||(s.protocol==="https:"?443:80),path:s.pathname+s.search,method:"POST",headers:{"Content-Type":"application/json","Content-Length":Buffer.byteLength(a),...r?{Authorization:`Bearer ${r}`}:{}}},l=>{let d=[];l.on("data",f=>d.push(f)),l.on("end",()=>{let f=Buffer.concat(d).toString("utf8");try{n({status:l.statusCode||0,json:JSON.parse(f)})}catch{o(new Error(`\u89C6\u89C9\u6A21\u578B API \u8FD4\u56DE HTTP ${l.statusCode}\uFF0C\u54CD\u5E94\u975E JSON\uFF1A${f.slice(0,120)}`))}})}),u=Number(process.env.LANHU_VISION_TIMEOUT_MS)||12e4;c.setTimeout(u,()=>{c.destroy(new Error(`\u89C6\u89C9\u6A21\u578B API \u8BF7\u6C42\u8D85\u65F6\uFF08${u}ms\uFF09\uFF0C\u53EF\u8BBE LANHU_VISION_TIMEOUT_MS \u8C03\u6574`))}),c.on("error",o),c.write(a),c.end()})}var Rd=new Map;async function Jr({images:t=[],text:e,detail:r="auto"}){EE(t);let n=RE(t,e,r),o=NE(n);if(o)return o;let s=Rd.get(n);if(s)return console.error("[vision] \u76F8\u540C\u8BF7\u6C42\u5728\u9014\uFF0C\u590D\u7528\u5176\u7ED3\u679C"),s;let i=jE({images:t,text:e,detail:r},n).finally(()=>Rd.delete(n));return Rd.set(n,i),i}async function jE({images:t=[],text:e,detail:r="auto"},n){let o=[{type:"text",text:IE(e)},...t.map(l=>({type:"image_url",image_url:{url:l.startsWith("data:")?l:`data:image/png;base64,${l}`,detail:r}}))],s={model:Ho,messages:[{role:"user",content:o}],response_format:{type:"json_object"},max_tokens:SE,temperature:0,top_p:.95};/glm/i.test(Ho)&&(s.max_tokens=Number(process.env.LANHU_VISION_MAX_TOKENS)||16384,s.thinking={type:"enabled",clear_thinking:!1},s.reasoning_effort="max");let i=null,a=m_??kE,c=!1,u=!1;for(let l=1;l<=Vo;l++){let d=Date.now(),f=0,m=null;try{let y=await AE(f_(a),s,g_);f=y.status,m=y.json}catch(y){f=0,i=y instanceof Error?y:new Error(String(y))}if(f===404&&!c){c=!0,a=!a,m_=a,l--,console.error(`[vision] HTTP 404 \u2192 \u5207\u6362\u7AEF\u70B9\u4E3A ${f_(a)}`);continue}if(f===400&&s.response_format&&!u&&/response_format|json_object/i.test(JSON.stringify(m?.error||""))){u=!0,delete s.response_format,l--,console.error("[vision] \u6A21\u578B\u62D2\u7EDD response_format \u2192 \u964D\u7EA7\u4E3A\u63D0\u793A\u8BCD\u7EA6\u675F\u91CD\u8BD5");continue}if((f===0||f===429||f>=500)&&l<Vo){let y=1e3*l,_=f===0?"\u7F51\u7EDC/\u8D85\u65F6":`HTTP ${f}`;i==null&&(i=new Error(`\u89C6\u89C9\u6A21\u578B API HTTP ${f}\uFF1A${m?.error?.message||m?.message||JSON.stringify(m).slice(0,150)}`)),console.error(`[vision] ${_}\uFF0C${y}ms \u540E\u91CD\u8BD5\uFF08attempt=${l}/${Vo}\uFF09\uFF1A${i.message}`),await new Promise(w=>setTimeout(w,y));continue}if(f<200||f>=300){let y=m?.error?.message||m?.message||JSON.stringify(m).slice(0,150);throw new Error(`\u89C6\u89C9\u6A21\u578B API HTTP ${f}\uFF1A${y}`)}let h=m?.choices?.[0],g=h?.message?.content||"";if(console.error(`[vision] ${Ho} ${t.length}\u56FE detail=${r} attempt=${l} \u2192 HTTP ${f} \u8017\u65F6${Date.now()-d}ms finish=${h?.finish_reason} tokens=${m?.usage?.total_tokens} contentLen=${g.length}`),g.trim()){let y=g.replace(/^```(?:json)?\s*/i,"").replace(/\s*```$/,"");try{let _=JSON.parse(y);return OE(n,_),_}catch{return{_raw:g}}}i=new Error(`\u89C6\u89C9\u6A21\u578B\u8FD4\u56DE\u7A7A content\uFF08HTTP ${f}\uFF0Cfinish_reason=${h?.finish_reason??"\u65E0choices\u5B57\u6BB5"}\uFF0C\u54CD\u5E94\u4F53=${JSON.stringify(m).slice(0,120)}\uFF09`),l<Vo&&(console.error(`[vision] \u7A7A\u54CD\u5E94\uFF0C${l}s \u540E\u91CD\u8BD5\u2026`),await new Promise(y=>setTimeout(y,1e3*l)))}throw new Error(`${i.message}\u3002\u91CD\u8BD5 ${Vo} \u6B21\u4ECD\u4E3A\u7A7A\uFF0C\u591A\u4E3A\u6A21\u578B\u7AEF/\u4EE3\u7406\u5F02\u5E38\uFF0C\u8BF7\u7A0D\u540E\u518D\u8BD5\u3002`)}function ME(){let t=r=>{let n=[],o=r;for(;o&&o!==document.body;){let s=o.tagName.toLowerCase(),i=o.getAttribute("id");if(i)s+=`#${i}`;else{let a=(o.getAttribute("class")||"").trim().split(/\s+/).filter(Boolean)[0];a&&(s+=`.${a}`)}n.unshift(s),o=o.parentElement}return n.join(" > ")||r.tagName.toLowerCase()},e=[];for(let r of Array.from(document.querySelectorAll("body *"))){let n=r.getBoundingClientRect();if(n.width<=0||n.height<=0||r.tagName==="SVG")continue;let o=getComputedStyle(r);if(o.display==="none"||o.visibility==="hidden"||Number(o.opacity)===0)continue;let s=Array.from(r.childNodes).filter(u=>u.nodeType===3).map(u=>(u.textContent||"").trim()).join(" ").trim();if(r.children.length>0&&!s)continue;let i=parseFloat(o.lineHeight),a="",c=r.parentElement;for(let u=0;u<3&&c;u++){let l=getComputedStyle(c).backgroundColor;if(l&&l!=="rgba(0, 0, 0, 0)"&&l!=="transparent"){a=l;break}c=c.parentElement}e.push({selector:t(r),text:s,x:Math.round((n.x+window.scrollX)*100)/100,y:Math.round((n.y+window.scrollY)*100)/100,width:Math.round(n.width*100)/100,height:Math.round(n.height*100)/100,color:o.color,backgroundColor:o.backgroundColor,bgAncestor:a,fontSize:parseFloat(o.fontSize)||0,fontWeight:Number(o.fontWeight)||0,lineHeight:Number.isFinite(i)?Math.round(i*100)/100:null})}return e}function Bo(t){let e=String(t||"").trim(),r=/^#([0-9a-f]{3})$/i.exec(e);if(r){let n=r[1].split("").map(o=>parseInt(o+o,16));return{r:n[0],g:n[1],b:n[2],a:1}}if(r=/^#([0-9a-f]{6})$/i.exec(e),r)return{r:parseInt(r[1].slice(0,2),16),g:parseInt(r[1].slice(2,4),16),b:parseInt(r[1].slice(4,6),16),a:1};if(r=/^rgba?\(([^)]+)\)$/i.exec(e),r){let n=r[1].split(",").map(o=>parseFloat(o));return n.length<3||n.some(o=>!Number.isFinite(o))?null:{r:n[0],g:n[1],b:n[2],a:n.length>3?n[3]:1}}return null}function ZE(t,e){return t<=e[0]?null:t<=e[1]?"minor":t<=e[2]?"major":"critical"}var Kr={geometry:[1,3,8],fontSize:[.5,1,2],lineHeight:[1,2,4]};function DE(t,e,r,n){let o=[],s={layer:t.name||"(\u672A\u547D\u540D\u56FE\u5C42)",path:t.parentPath||"",selector:e.selector,matchBy:r},i=t.type==="text",a=(d,f,m,p)=>{let h=Math.abs(f-m),g=ZE(h,p);g&&o.push({...s,field:d,expected:f,actual:m,delta:Math.round(h*100)/100,severity:g})},c=(d,f,m)=>{let p=Bo(f),h=Bo(m);if(!p||!h||p.a<.01&&h.a<.01)return;let g=Math.max(Math.abs(p.r-h.r),Math.abs(p.g-h.g),Math.abs(p.b-h.b)),y=Math.abs(p.a-h.a);if(g<=2&&y<=.02)return;let _=y>.02||g>30?"critical":g>10?"major":"minor";h.a<.01&&_==="critical"&&(_="major"),o.push({...s,field:d,expected:f,actual:m,delta:Math.round(g*100)/100,severity:_})};if(a("x",t.x+n.dx,e.x,Kr.geometry),i){let d=Math.abs(t.w-e.width);d>Kr.geometry[0]&&o.push({...s,field:"width",expected:t.w,actual:e.width,delta:Math.round(d*100)/100,severity:"minor"})}else a("width",t.w,e.width,Kr.geometry);let u=Math.abs(t.y+n.dy-e.y);u>Kr.geometry[0]&&o.push({...s,field:"y",expected:Math.round((t.y+n.dy)*100)/100,actual:e.y,delta:Math.round(u*100)/100,severity:"minor"});let l=Math.abs(t.h-e.height);if(l>Kr.geometry[0]&&o.push({...s,field:"height",expected:t.h,actual:e.height,delta:Math.round(l*100)/100,severity:"minor"}),t.color&&c("color",t.color,e.color),t.fill){let d=Bo(t.fill);if(e.backgroundColor==="rgba(0, 0, 0, 0)"&&e.bgAncestor&&d){let f=Bo(e.bgAncestor);f&&Math.max(Math.abs(f.r-d.r),Math.abs(f.g-d.g),Math.abs(f.b-d.b))<=30&&Math.abs(f.a-d.a)<=.02||c("fill",t.fill,e.backgroundColor)}else c("fill",t.fill,e.backgroundColor)}if(t.fontSize&&a("fontSize",t.fontSize,e.fontSize,Kr.fontSize),t.fontWeight&&e.fontWeight&&t.fontWeight!==e.fontWeight){let d=t.fontWeight>=600&&e.fontWeight===700;o.push({...s,field:"fontWeight",expected:t.fontWeight,actual:e.fontWeight,delta:Math.abs(t.fontWeight-e.fontWeight),severity:d?"minor":"major"})}return typeof t.lineHeight=="number"&&e.lineHeight!=null&&a("lineHeight",t.lineHeight,e.lineHeight,Kr.lineHeight),t.text&&t.text.trim()&&e.text&&e.text.trim()&&t.text.trim()!==e.text.trim()&&o.push({...s,field:"text",expected:t.text.trim(),actual:e.text.trim(),delta:0,severity:"minor"}),o}function $_(t,e){let r=Math.max(t.x,e.x),n=Math.max(t.y,e.y),o=Math.min(t.x+t.w,e.x+e.width),s=Math.min(t.y+t.h,e.y+e.height),i=o-r,a=s-n;if(i<=0||a<=0)return 0;let c=i*a,u=t.w*t.h+e.width*e.height-c;return u>0?c/u:0}function qi(t){if(!t.length)return 0;let e=[...t].sort((n,o)=>n-o),r=e.length>>1;return e.length%2?e[r]:(e[r-1]+e[r])/2}var LE=/(状态栏|status\s*bar|system\s*bar|safe\s*area|刘海|notch|蒙版|mask|guide|标注|备份|backup|副本|copy|_old|占位|placeholder|草稿|draft|切图|slice|导出|export|temp|tmp|ref\b)/i;function qE(t,e){let r={},n=s=>{r[s]=(r[s]||0)+1},o=[];for(let s of t){if(s.opacity===0){n("opacity0");continue}if(s.w<=0||s.h<=0){n("zeroSize");continue}let i=s.name||"";if(LE.test(i)){n("noiseName");continue}if(s.y<=1&&s.x<=1&&s.w>=e*.9&&s.h>=18&&s.h<=80){n("statusBar(geom)");continue}o.push(s)}return{kept:o,skipped:t.length-o.length,reasons:r}}function UE(t,e){let r=i=>{let a=new Map;return i.forEach((c,u)=>{let l=c.text?.trim();l&&(a.has(l)||a.set(l,[]),a.get(l).push(u))}),a},n=r(t),o=r(e),s=[];for(let[i,a]of n){let c=o.get(i);!c||a.length!==1||c.length!==1||s.push({layer:t[a[0]],sample:e[c[0]],matchBy:"text"})}return s}function FE(t,e,r){let n=[];t.forEach((a,c)=>{let u=a.text?.trim()||"",l={x:a.x+r.dx,y:a.y+r.dy,w:a.w,h:a.h};e.forEach((d,f)=>{if(u&&d.text===u){let m=Math.hypot(d.x-l.x,d.y-l.y);n.push({li:c,si:f,score:10-m/1e3+$_(l,d),matchBy:"text"})}})}),n.sort((a,c)=>c.score-a.score);let o=new Set,s=new Set,i=[];for(let a of n)o.has(a.li)||s.has(a.si)||(o.add(a.li),s.add(a.si),i.push({layer:t[a.li],sample:e[a.si],matchBy:a.matchBy}));return{pairs:i,rest:t.filter((a,c)=>!o.has(c)),usedSample:s}}function VE(t){if(t.length<3)return{off:{dx:0,dy:0},inliers:t,outliers:[]};let e=t.map(i=>({dx:i.sample.x-i.layer.x,dy:i.sample.y-i.layer.y,pair:i})),r=[],n=1/0;for(let i of e){let a=e.filter(u=>Math.abs(u.dx-i.dx)<=3&&Math.abs(u.dy-i.dy)<=3),c=Math.hypot(i.dx,i.dy);(a.length>r.length||r.length>0&&a.length===r.length&&c<n)&&(r=a,n=c)}let o={dx:qi(r.map(i=>i.dx)),dy:qi(r.map(i=>i.dy))},s=new Set(r.map(i=>i.pair));return{off:o,inliers:[...s],outliers:t.filter(i=>!s.has(i))}}function x_(t,e,r,n){let o=[];t.forEach((a,c)=>{let u={x:a.x+n.dx,y:a.y+n.dy,w:a.w,h:a.h};e.forEach((l,d)=>{if(r.has(d))return;let f=$_(u,l);f>=.5&&o.push({li:c,si:d,v:f})})}),o.sort((a,c)=>c.v-a.v);let s=new Set,i=[];for(let a of o)s.has(a.li)||r.has(a.si)||(s.add(a.li),r.add(a.si),i.push({layer:t[a.li],sample:e[a.si],matchBy:"position"}));return{pairs:i,unmatched:t.filter((a,c)=>!s.has(c))}}var HE=['You are a design acceptance assistant. For each pair of "design copy" vs "actual page copy", judge whether they are semantically equivalent.',"","Rules (by priority):","1. Dynamic-value exemption: both sides are pure numbers/points/dates/counters (e.g. *30D, Lv.5, \xA529.9, 08:30), same unit and magnitude difference <2x \u2192 same=true","2. Cross-language translation equivalence \u2192 same=true","3. Synonymous paraphrase / abbreviation \u2192 same=true","4. Otherwise \u2192 same=false","","Samples (8 pairs; copy strings stay in their original languages):","\u2705 \u7ACB\u5373\u62A2\u8D2D | Buy Now (translation)","\u2705 *30D | *30\u5929 (dynamic_value_format)","\u2705 \xA529.90 | 29.9\u5143 (dynamic_value_format)","\u2705 Lv.5 | \u7B49\u7EA75 (dynamic_value_format)","\u2705 \u786E\u8BA4 | OK (abbreviation)","\u274C \u652F\u4ED8 | \u7ACB\u5373\u8D2D\u4E70 (different_meaning)","\u274C \u5DF2\u7ED3\u675F | \u8FDB\u884C\u4E2D (different_meaning)","\u274C \u514D\u8D39 | \xA59.9 (different_meaning)","",'Output JSON only: {"result":[{"same":true,"equivalence_class":"translation|synonym|abbreviation|dynamic_value_format|different_meaning","reason":"<=15 words, cite the rule number"}]}, strictly valid json for program parsing.'].join(`
|
|
58
|
+
`);async function BE(t){if(!t.length)return[];if(!An())return t.map(()=>({same:!0,cls:"",reason:"vision \u672A\u914D\u7F6E\uFF0C\u6309\u8BED\u4E49\u63A5\u8FD1\u9ED8\u8BA4\u653E\u884C"}));let e=t.map((n,o)=>`[${o}] \u8BBE\u8BA1:${n.expected} | \u9875\u9762:${n.actual}`).join(`
|
|
54
59
|
`),r=new Set(["translation","synonym","abbreviation","dynamic_value_format","different_meaning"]);try{let n=await Jr({text:HE+`
|
|
55
|
-
`+e}),o=Array.isArray(n?.result)?n.result:[];return t.map((s,i)=>{let a=o[i];if(!a||typeof a.same!="boolean")return{same:!0,cls:"",reason:"vision \u89E3\u6790\u5931\u8D25\uFF0C\u6309\u8BED\u4E49\u63A5\u8FD1\u9ED8\u8BA4\u653E\u884C"};let c=r.has(a.equivalence_class)?a.equivalence_class:"";return{same:a.same,cls:c,reason:String(a.reason||"")}})}catch{return t.map(()=>({same:!0,cls:"",reason:"vision \u8C03\u7528\u5931\u8D25\uFF0C\u6309\u8BED\u4E49\u63A5\u8FD1\u9ED8\u8BA4\u653E\u884C"}))}}function w_(t,e,r){let n=Math.round(t*2)/2;if(n<=0)return null;let o=(Number(e)||0)>=900?700:Number(e)||0,s=Bo(r);return s?{key:`${n}|${o}|rgb(${s.r},${s.g},${s.b})`,fontSize:n,fontWeight:o,color:`rgb(${s.r},${s.g},${s.b})`}:null}function JE(t,e){let r=()=>({fontSize:0,fontWeight:0,color:"",count:0,designLayers:[],samples:[],selectors:[]}),n=(c,u,l)=>{let d=c.get(u.key);d||(d=r(),d.fontSize=u.fontSize,d.fontWeight=u.fontWeight,d.color=u.color,c.set(u.key,d)),d.count++,l(d)},o=new Map;for(let c of t){if(c.type!=="text"||!c.fontSize||(c.y??0)<44)continue;let u=w_(c.fontSize,c.fontWeight||0,c.color||"");u&&n(o,u,l=>{l.designLayers.length<4&&c.name&&l.designLayers.push(c.name),l.samples.length<3&&c.text&&l.samples.push(String(c.text).slice(0,18))})}let s=new Map;for(let c of e){if(!c.text||!c.fontSize)continue;let u=w_(c.fontSize,c.fontWeight||0,c.color);u&&n(s,u,l=>{l.selectors.length<4&&c.selector&&l.selectors.push(c.selector),l.samples.length<3&&c.text&&l.samples.push(c.text.slice(0,18))})}let i=[...o.entries()].filter(([c])=>!s.has(c)).map(([,c])=>c).sort((c,u)=>u.count-c.count),a=[...s.entries()].filter(([c])=>!o.has(c)).map(([,c])=>c).sort((c,u)=>u.count-c.count);return{designStyleCount:o.size,pageStyleCount:s.size,missingOnPage:i,notInDesign:a,missingOnPageTotal:i.length,notInDesignTotal:a.length}}async function k_(t){let e=await Li(t.designUrl,{...t.credentials,needCover:!1}),r;try{r=await import("playwright")}catch{throw new Error("\u7F3A\u5C11 playwright\uFF1A\u8BF7\u5728 mcp/lanhu-design-mcp \u4E0B\u6267\u884C npm i playwright && npx playwright install chromium")}let n=await r.chromium.launch({headless:!0});try{let o={width:e.viewport.width||375,height:e.viewport.height||812},s=await n.newPage({viewport:o,deviceScaleFactor:1});await s.goto(t.pageUrl,{waitUntil:"load",timeout:3e4}),t.waitFor&&await s.waitForSelector(t.waitFor,{timeout:1e4}).catch(()=>{}),await new Promise(j=>setTimeout(j,500));let i=await s.evaluate(ME),a=qE(e.layers,o.width),c=a.kept,u=UE(c,i),l=u.length>=3?{dx:qi(u.map(j=>j.sample.x-j.layer.x)),dy:qi(u.map(j=>j.sample.y-j.layer.y))}:null,d=l??{dx:0,dy:0},p=FE(c,i,d),m=p.pairs.filter(j=>Math.abs(j.sample.x-j.layer.x-d.dx)<=8&&Math.abs(j.sample.y-j.layer.y-d.dy)<=8),f=p.pairs.filter(j=>!m.includes(j)).map(j=>j.layer),h=new Set(m.map(j=>i.indexOf(j.sample))),g=x_([...p.rest,...f],i,h,d),y=VE([...m,...g.pairs]),_=y.inliers.length>=3?y.off:l??{dx:0,dy:0},w=new Set(m.map(j=>i.indexOf(j.sample))),x=x_([...p.rest,...f],i,w,_),$=[...m,...x.pairs],P=[],J=[];for(let{layer:j,sample:oe,matchBy:Ee}of $)for(let He of DE(j,oe,Ee,_))He.field==="text"&&J.push(P.length),P.push(He);let H=!1;J.length&&jn()&&(H=!0,(await BE(J.map(oe=>({expected:String(P[oe].expected),actual:String(P[oe].actual)})))).forEach((oe,Ee)=>{let He=P[J[Ee]];oe.cls&&(He.equivalenceClass=oe.cls),oe.reason&&(He.textReason=oe.reason),oe.same||(He.severity="major")}));let k=t.maxDiffs??50,O=[];if(a.skipped){let j=Object.entries(a.reasons).map(([oe,Ee])=>`${oe}\xD7${Ee}`).join("\uFF0C");O.push(`\u6BD4\u5BF9\u524D\u5254\u9664 ${a.skipped} \u4E2A\u65E0\u6548/\u72B6\u6001\u680F\u56FE\u5C42\uFF08${j}\uFF09\uFF1B\u8FD9\u4E9B\u5C42\u5728 webview \u4E2D\u4E0D\u6E32\u67D3\uFF0C\u4E0D\u53C2\u4E0E\u9A8C\u6536`)}(Math.abs(_.dx)>=2||Math.abs(_.dy)>=2)&&O.push(`\u68C0\u6D4B\u5230\u9875\u9762\u6574\u4F53\u504F\u79FB (dx=${Math.round(_.dx)}, dy=${Math.round(_.dy)})\uFF0C\u4F4D\u7F6E\u5B57\u6BB5\u5DF2\u6309\u6B64\u6821\u6B63\u540E\u6BD4\u5BF9\uFF1B\u5E38\u89C1\u539F\u56E0\u662F\u8BBE\u8BA1\u7A3F\u542B\u72B6\u6001\u680F\u5360\u4F4D\u800C\u9875\u9762\u7528\u539F\u751F\u5B89\u5168\u533A`),f.length&&O.push(`${f.length} \u4E2A\u6587\u6848\u951A\u70B9\u4E0E\u6574\u4F53\u504F\u79FB\u4E0D\u4E00\u81F4\uFF08\u591A\u4E3A *30D/x5/Lv.5 \u8FD9\u7C7B\u91CD\u590D\u77ED\u4E32\u4E32\u4F4D\uFF09\uFF0C\u5DF2\u5254\u9664\u5E76\u9000\u56DE\u51E0\u4F55\u91CD\u914D`);let E=x.unmatched.filter(j=>j.text).length;x.unmatched.length&&O.push(`${x.unmatched.length} \u4E2A\u56FE\u5C42\u672A\u5339\u914D\u5230\u9875\u9762\u5143\u7D20\uFF08\u5176\u4E2D ${E} \u4E2A\u542B\u6587\u6848\uFF09\uFF1B\u88C5\u9970\u5C42\u7528 CSS/\u80CC\u666F\u5B9E\u73B0\u4E0D\u4EA7\u751F DOM \u5143\u7D20\u5C5E\u6B63\u5E38\uFF0C\u4F46\u542B\u6587\u6848\u7684\u672A\u5339\u914D\u9700\u4EBA\u5DE5\u786E\u8BA4\u662F\u5426\u6F0F\u505A`),P.length>0&&O.push(`\u5B57\u6BB5\u504F\u5DEE\u5171 ${P.length} \u6761\uFF08\u6309\u56FE\u5C42\u5206\u7EC4\u89C1 diffs\uFF0Ccritical \u7EC4\u5728\u524D\uFF09\uFF1B\u6587\u6848\u5DEE\u5F02\u9ED8\u8BA4 minor\uFF0C\u7ECF\u89C6\u89C9\u6A21\u578B\u5224\u4E3A\u4E0D\u540C\u542B\u4E49\u624D\u5347 major`);let F={critical:0,major:1,minor:2},re=new Map;for(let j of P){let oe=`${j.layer}\0${j.path}\0${j.selector}\0${j.matchBy}`,Ee=re.get(oe);Ee||(Ee={layer:j.layer,path:j.path,selector:j.selector,matchBy:j.matchBy,diffs:[]},re.set(oe,Ee));let{layer:He,path:zt,selector:Fi,matchBy:Vi,...z_}=j;Ee.diffs.push(z_)}let K=[...re.values()].map(j=>({...j,diffs:[...j.diffs].sort((oe,Ee)=>F[oe.severity]-F[Ee.severity])})).sort((j,oe)=>{let Ee=Math.min(...j.diffs.map(zt=>F[zt.severity])),He=Math.min(...oe.diffs.map(zt=>F[zt.severity]));return Ee-He||oe.diffs.length-j.diffs.length}),Ve=K.slice(0,k);K.length>k&&O.push(`\u504F\u5DEE\u5171 ${K.length} \u7EC4 / ${P.length} \u6761\u5B57\u6BB5\u504F\u5DEE\uFF0C\u5DF2\u8FBE\u4E0A\u9650 ${k} \u7EC4\uFF0C\u5EFA\u8BAE\u5148\u4FEE critical \u518D\u590D\u68C0`);let ce=JE(c,i);return(ce.missingOnPage.length||ce.notInDesign.length)&&O.push(`\u6837\u5F0F\u6E05\u5355\u6BD4\u5BF9\uFF08\u96F6\u6807\u6CE8\u3001\u4E0D\u6BD4\u6587\u6848\uFF09\uFF1A\u8BBE\u8BA1\u7A3F ${ce.designStyleCount} \u79CD / \u9875\u9762 ${ce.pageStyleCount} \u79CD\u6587\u5B57\u6837\u5F0F\uFF1B\u8BBE\u8BA1\u6709\u9875\u9762\u65E0 ${ce.missingOnPage.length} \u79CD\u3001\u9875\u9762\u6709\u8BBE\u8BA1\u65E0 ${ce.notInDesign.length} \u79CD \u2192 \u89C1 inventory \u5B57\u6BB5`),{design:{name:e.name||"(\u672A\u547D\u540D\u8BBE\u8BA1\u7A3F)",viewport:e.viewport,layerCount:e.layers.length},page:{url:t.pageUrl,viewport:o,sampled:i.length},matched:$.length,offset:{dx:Math.round(_.dx*100)/100,dy:Math.round(_.dy*100)/100,anchors:m.length,rejected:f.length},denoised:a,diffs:Ve,diffCount:P.length,diffGroupCount:K.length,diffsTruncated:K.length>k,unmatchedLayers:x.unmatched.slice(0,50).map(j=>j.name||"(\u672A\u547D\u540D\u56FE\u5C42)"),notes:O,textCheckedByVision:H,inventory:{...ce,missingOnPage:ce.missingOnPage.slice(0,20),notInDesign:ce.notInDesign.slice(0,20),missingOnPageTotal:ce.missingOnPage.length,notInDesignTotal:ce.notInDesign.length}}}finally{await n.close()}}var GE={source:"mock",viewport:{width:390,height:844},layers:[{id:"bg",type:"rect",x:0,y:0,w:390,h:844,fill:"#0E0B1A"},{id:"title",type:"text",x:24,y:64,w:342,h:32,text:"Masked Ball",fontSize:24,fontWeight:700,color:"#F5F1FF",fontFamily:"Inter"},{id:"cta",type:"rect",x:24,y:720,w:342,h:48,fill:"#7C5CFF",radius:12},{id:"card",type:"rect",x:24,y:120,w:342,h:200,fill:"#1A1530",radius:16},{id:"badge",type:"rect",x:24,y:340,w:61,h:16,fill:"#771E00",borderRadius:{topLeft:8,topRight:12,bottomLeft:0,bottomRight:12},border:{color:"rgba(239,216,185,1)",width:1,alignment:"inside"}}],meta:{rawLayerCount:4,totalLayerCount:4}};function st(t){return{content:[{type:"text",text:JSON.stringify(t)}]}}function YE(t){if(t)try{return KE(t,"utf8").trim()||void 0}catch{return}}function Wr(t){return{cookie:t.cookie||process.env.LANHU_COOKIE||YE(process.env.LANHU_COOKIE_FILE)}}async function XE(t){try{return`data:image/jpeg;base64,${(await Ed(Buffer.from(t,"base64"))).toString("base64")}`}catch{return t}}async function Ui(t){if(t.path)try{return`data:image/jpeg;base64,${(await Ed(await WE(t.path))).toString("base64")}`}catch(e){throw new Error(`\u8BFB\u53D6\u56FE\u7247\u5931\u8D25\uFF08${t.path}\uFF09\uFF1A${e.message}`)}if(t.b64)return XE(t.b64);throw new Error(`${t.what}\uFF1A\u8BF7\u4F20 imagePath\uFF08\u672C\u5730\u622A\u56FE\u6587\u4EF6\u8DEF\u5F84\uFF0C\u63A8\u8350\uFF09\u6216 imageBase64 \u4E4B\u4E00`)}function S_(t){t.registerTool("lanhu_fetch_design",{description:"\u8BFB\u53D6\u84DD\u6E56\u8BBE\u8BA1\u7A3F\u7684\u7ED3\u6784\u5316\u56FE\u5C42\u6811\uFF08\u7CBE\u786E x/y/\u5BBD\u9AD8/\u8272\u503C/\u5B57\u53F7/\u5706\u89D2/\u63CF\u8FB9/\u6587\u672C\uFF09\u3002mode\uFF1Aapi=\u5B98\u65B9Cookie\u63A5\u53E3(\u9ED8\u8BA4,\u65E0\u9700\u6D4F\u89C8\u5668) / mock=\u5185\u7F6E\u793A\u4F8B\u3002analyze=true \u65F6\u7528\u914D\u7F6E\u7684\u89C6\u89C9\u6A21\u578B\u7406\u89E3\u8BBE\u8BA1\u7A3F\u5C01\u9762\u56FE\u3002analyze \u9ED8\u8BA4\u503C\uFF1A\u5DF2\u914D\u7F6E\u89C6\u89C9\u6A21\u578B\uFF08VLM_MODEL + VLM_API_KEY\uFF09\u65F6\u9ED8\u8BA4 true\uFF0C\u672A\u914D\u7F6E\u5219\u9ED8\u8BA4 false\uFF1B\u663E\u5F0F\u4F20 true/false \u59CB\u7EC8\u4F18\u5148\u3002\u4F7F\u7528\u7EAA\u5F8B\uFF1A\u4E00\u6B21\u53EA\u8BFB\u5F53\u524D\u8981\u5B9E\u73B0\u7684\u90A3 1 \u5F20\u7A3F\uFF1B\u4E0D\u8981\u4E3A\u300C\u4E86\u89E3\u5168\u8C8C\u300D\u6279\u91CF\u8BFB\u7A3F\u2014\u2014\u5206\u7EC4\u7A3F\u76EE\u5F55\u7528 lanhu_read_sector\uFF0C\u5B83\u8DB3\u591F\u5B9A\u4F4D\uFF1B\u8FD4\u56DE\u7684 layers \u542B\u7CBE\u786E\u6570\u503C\uFF0C\u8272\u503C/\u5B57\u53F7\u4ECE\u6570\u636E\u53D6\uFF0C\u7981\u6B62\u9760\u89C6\u89C9\u6A21\u578B OCR \u5C0F\u5B57\u3002",inputSchema:{mode:q.enum(["api","mock"]).default("api").describe("\u62BD\u53D6\u540E\u7AEF"),url:q.string().optional().describe("\u84DD\u6E56\u8BBE\u8BA1\u7A3F\u94FE\u63A5\uFF0C\u5982 https://lanhuapp.com/web/#/item/project/detailDetach?pid=xxx&image_id=yyy"),imageId:q.string().optional().describe("\u8BBE\u8BA1\u7A3F id\uFF08\u6765\u81EA lanhu_read_sector\uFF09\uFF0C\u4E0E projectId \u642D\u914D\uFF1Burl \u4E0E imageId \u4E8C\u9009\u4E00\uFF0C\u514D\u62FC URL"),projectId:q.string().optional().describe("\u9879\u76EE UUID\uFF08imageId \u6A21\u5F0F\u5FC5\u586B\uFF1Burl \u6A21\u5F0F\u4E0D\u9700\u8981\uFF09"),cookie:q.string().optional().describe("\u767B\u5F55 cookie \u4E32\uFF08\u4E5F\u53EF\u7528 LANHU_COOKIE / LANHU_COOKIE_FILE\uFF09"),analyze:q.boolean().optional().describe("\u7528\u89C6\u89C9\u6A21\u578B\u7406\u89E3\u5C01\u9762\u56FE\uFF0C\u8FD4\u56DE visionAnalysis\uFF1B\u4E0D\u4F20\u65F6\u6309\u662F\u5426\u914D\u7F6E\u4E86\u89C6\u89C9\u6A21\u578B\u81EA\u52A8\u51B3\u5B9A\uFF08\u914D\u4E86\u5C31 true\uFF09"),analyzeFocus:q.string().optional().describe("\u6CE8\u5165\u89C6\u89C9\u6A21\u578B\u7684\u989D\u5916\u5173\u6CE8\u70B9/\u4E1A\u52A1\u80CC\u666F\uFF08\u5982\u300C\u91CD\u70B9\u5206\u6790\u7B7E\u5230\u5956\u52B1\u9886\u53D6\u89C4\u5219\u300D\u300C\u5173\u6CE8\u6309\u94AE\u7684\u7981\u7528\u6001\u300D\uFF09\uFF0C\u8BA9\u5206\u6790\u66F4\u8D34\u5408\u5F53\u524D\u4EFB\u52A1\uFF1B\u4E0D\u5F71\u54CD\u8FD4\u56DE JSON \u7ED3\u6784\uFF0C\u4EC5 analyze \u6267\u884C\u65F6\u751F\u6548")}},async e=>{if(process.env.LANHU_MOCK==="1"||e.mode==="mock")return st(GE);if(!e.url&&!e.imageId)throw new Error("api \u6A21\u5F0F\u9700\u8981 url \u6216 imageId+projectId");if(e.imageId&&!e.projectId&&!e.url)throw new Error("imageId \u6A21\u5F0F\u9700\u8981\u540C\u65F6\u4F20 projectId");let r=e.analyze??__();e.analyze===void 0&&r&&console.error(`[fetch_design] analyze \u672A\u6307\u5B9A\u4E14\u89C6\u89C9\u6A21\u578B\u5DF2\u914D\u7F6E \u2192 \u81EA\u52A8\u5F00\u542F\uFF08${process.env.VLM_MODEL||"\u9ED8\u8BA4\u6A21\u578B"}\uFF09`);let n={...Wr(e),needCover:r},o=e.url?await Li(e.url,n):await c_(e.imageId,e.projectId,n);if(o.slices&&(o.slices=o.slices.map(({imageUrl:a,...c})=>c)),!r)return st(o);let{coverImageBase64:s,...i}=o;if(!s)return st({...i,visionError:"\u8BBE\u8BA1\u7A3F\u65E0\u5C01\u9762\u56FE\uFF08coverImageBase64 \u4E3A\u7A7A\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u89C6\u89C9\u5206\u6790"});try{let a=await Jr({images:[`data:image/jpeg;base64,${s}`],text:b_(i.meta?.docName??i.name,e.analyzeFocus),detail:"high"});return st({...i,visionAnalysis:a})}catch(a){console.error(`[fetch_design] \u89C6\u89C9\u5206\u6790\u5931\u8D25\uFF0C\u964D\u7EA7\u8FD4\u56DE\u56FE\u5C42\u6811\uFF1A${a?.message}`);let c=jn()?"":"\u672A\u68C0\u6D4B\u5230\u89C6\u89C9\u6A21\u578B\u914D\u7F6E\uFF1A\u9700\u540C\u65F6\u8BBE\u7F6E VLM_MODEL \u4E0E VLM_API_KEY\u3002";return st({...i,visionError:`${a?.message||String(a)}${c}`})}}),t.registerTool("lanhu_verify_render",{description:"\u628A\u6E32\u67D3\u9875\u622A\u56FE\uFF08\u53EF\u9009\uFF1A\u8BBE\u8BA1\u7A3F\u622A\u56FE\uFF09\u8C03\u89C6\u89C9\u6A21\u578B\u505A\u8BED\u4E49\u5BF9\u6BD4\uFF0C\u8FD4\u56DE matchScore / verdict / diffs\u3002\u622A\u56FE\u4F20 imagePath\uFF08\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF0C\u63A8\u8350\uFF09\u6216 imageBase64 \u515C\u5E95\u3002\u4F20 context \u53EF\u58F0\u660E\u5DF2\u77E5\u523B\u610F\u5DEE\u5F02\uFF0C\u6A21\u578B\u5C06\u8DF3\u8FC7\u8FD9\u4E9B\u533A\u57DF\u3002\u7ED3\u8BBA\u4EC5\u662F\u89C6\u89C9\u7EBF\u7D22\uFF0C\u4E0E lanhu_verify_spec \u6570\u636E\u6BD4\u5BF9\u51B2\u7A81\u65F6\u4EE5\u6570\u636E\u6BD4\u5BF9\u4E3A\u51C6\u3002",inputSchema:{actualImagePath:q.string().optional().describe("\u6E32\u67D3\u9875\u622A\u56FE\u7684\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF08\u63A8\u8350\uFF0C\u907F\u514D base64 \u8FDB\u4E0A\u4E0B\u6587\uFF09"),actualImageBase64:q.string().optional().describe("\u6E32\u67D3\u9875\u622A\u56FE base64\uFF08\u515C\u5E95\uFF1B\u4E0E actualImagePath \u4E8C\u9009\u4E00\uFF09"),designImagePath:q.string().optional().describe("\u8BBE\u8BA1\u7A3F\u622A\u56FE\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF0C\u53CC\u56FE\u5BF9\u6BD4\u7528\uFF09"),designImageBase64:q.string().optional().describe("\u8BBE\u8BA1\u7A3F\u622A\u56FE base64\uFF08\u515C\u5E95\uFF09"),context:q.string().optional().describe("\u5DF2\u77E5\u523B\u610F\u5DEE\u5F02\u8BF4\u660E\uFF0C\u6A21\u578B\u5C06\u8DF3\u8FC7\u8FD9\u4E9B\u533A\u57DF\u7684\u62A5\u9519\u3002\u5982\u300C\u9876\u90E844px\u662F\u7CFB\u7EDF\u72B6\u6001\u680F\uFF0C\u9875\u9762\u7531\u539F\u751F\u6E32\u67D3\u300D\u300C\u5E95\u90E8\u6309\u94AE\u523B\u610F\u52A0\u9AD8\u523056px\u300D"),detail:q.enum(["auto","low","high"]).optional()}},async e=>{let r=!!(e.designImagePath||e.designImageBase64),n=r?`You are a senior frontend reviewer. Compare the RENDERED screenshot (first image) against the DESIGN reference (second image). Output a JSON: {"matchScore":<0-100>,"verdict":"pass|need_fix|fail","diffs":[{"location":"","issue":"","severity":"minor|major|critical"}],"suggestions":["..."]}. Ignore: JPEG compression noise, font anti-aliasing differences, resolution differences between the two images (compare by relative proportions, do not misreport size due to pixel density). Counter-rule: structural problems (misalignment/truncation/color deviation/missing elements) MUST be reported even if the image looks blurry. Known intentional differences (do NOT report these): ${e.context||"none"}. Arbitration: your verdict is a visual hint only; if it conflicts with the lanhu_verify_spec data comparison, the data comparison wins. Output discipline: at most 15 diffs, most important first. Only output JSON.`:`You are a senior frontend reviewer. No design reference provided \u2014 inspect this rendered screenshot for internal consistency only: layout sanity, alignment, contrast, truncation, overlap. Output JSON: {"matchScore":<0-100>,"verdict":"pass|need_fix|fail","diffs":[{"location":"","issue":"","severity":"minor|major|critical"}],"suggestions":["..."]}. Known intentional differences (do NOT report these): ${e.context||"none"}. Output discipline: at most 15 diffs, most important first. Only output JSON.`,o=[await Ui({b64:e.actualImageBase64,path:e.actualImagePath,what:"\u6E32\u67D3\u9875\u622A\u56FE"})];return r&&o.push(await Ui({b64:e.designImageBase64,path:e.designImagePath,what:"\u8BBE\u8BA1\u7A3F\u622A\u56FE"})),st(await Jr({images:o,text:n,detail:e.detail||"high"}))}),t.registerTool("vision_defect_check",{description:"\u6574\u9875/\u5C40\u90E8 UI \u7F3A\u9677\u68C0\u6D4B\uFF1A\u91CD\u53E0\u3001\u6EA2\u51FA\u3001\u7F3A\u56FE\u3001\u5BF9\u6BD4\u5EA6\u3001\u9519\u4F4D\u3001\u622A\u65AD\u3001\u7834\u56FE\u3001\u5360\u4F4D\u6B8B\u7559\u7B49 12 \u7C7B\u3002\u622A\u56FE\u4F20 imagePath\uFF08\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF0C\u63A8\u8350\uFF09\u6216 imageBase64 \u515C\u5E95\u3002\u8FD4\u56DE defects \u6570\u7EC4\u4E0E pass\u3002\u4F20 context \u53EF\u58F0\u660E\u5DF2\u77E5\u523B\u610F\u5DEE\u5F02\uFF0C\u6A21\u578B\u5C06\u8DF3\u8FC7\u8FD9\u4E9B\u533A\u57DF\u3002",inputSchema:{imagePath:q.string().optional().describe("\u622A\u5C4F\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF08\u63A8\u8350\uFF0C\u907F\u514D base64 \u8FDB\u4E0A\u4E0B\u6587\uFF09"),imageBase64:q.string().optional().describe("\u622A\u5C4F base64\uFF08\u515C\u5E95\uFF1B\u4E0E imagePath \u4E8C\u9009\u4E00\uFF09"),context:q.string().optional().describe("\u5DF2\u77E5\u523B\u610F\u5DEE\u5F02\u8BF4\u660E\uFF0C\u6A21\u578B\u5C06\u8DF3\u8FC7\u8FD9\u4E9B\u533A\u57DF\u7684\u62A5\u9519\u3002\u5982\u300C\u9876\u90E844px\u662F\u7CFB\u7EDF\u72B6\u6001\u680F\uFF0C\u9875\u9762\u7531\u539F\u751F\u6E32\u67D3\u300D"),language:q.string().optional().describe("\u8BED\u8A00\uFF0C\u9ED8\u8BA4 zh-CN"),detail:q.enum(["auto","low","high"]).optional()}},async e=>{let n=`Inspect this UI screenshot for visual defects; write all descriptions in ${e.language||"zh-CN"}. Output JSON: {"defects":[{"type":"overlap|overflow|missing_asset|contrast|misalign|truncation|broken_image|placeholder|stale_state|typo|alignment|other","severity":"minor|major|critical","location":"","description":""}],"summary":"","pass":<true|false>}. type guide: overlap / overflow / missing_asset / contrast(insufficient) / misalign / truncation / broken_image / placeholder(unreplaced, e.g. lorem or test images) / stale_state(e.g. loading never dismissed) / typo / alignment / other. severity (qualitative): critical = unreadable content / non-clickable element / blocked interaction; major = clearly visible, hurts consistency; minor = nitpick level. For contrast defects, always include the estimated ratio in description as "ratio:x.x". Known intentional differences (do NOT report these): ${e.context||"none"}. Output discipline: at most 15 defects, most severe first. Only output JSON.`;return st(await Jr({images:[await Ui({b64:e.imageBase64,path:e.imagePath,what:"\u622A\u5C4F"})],text:n,detail:e.detail||"auto"}))}),t.registerTool("vision_e2e_triage",{description:"E2E \u6D4B\u8BD5\u5931\u8D25\u65F6\uFF0C\u5206\u6790\u622A\u56FE+DOM \u5FEB\u7167+\u9519\u8BEF\u6587\u672C\uFF0C\u7ED9\u51FA\u6839\u56E0\u3001\u7C7B\u522B\u3001\u7F6E\u4FE1\u5EA6\u4E0E\u4E0B\u4E00\u6B65\u52A8\u4F5C\u5EFA\u8BAE\u3002\u622A\u56FE\u4F20 screenshotPath\uFF08\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF0C\u63A8\u8350\uFF09\u6216 screenshotBase64 \u515C\u5E95\u3002\u5F3A\u70C8\u5EFA\u8BAE\u4F20 expectedBehavior\uFF08\u6D4B\u8BD5\u9884\u671F\u884C\u4E3A\uFF09\u2014\u2014\u5F52\u56E0\u8D28\u91CF\u53D6\u51B3\u4E8E\u300C\u9884\u671F vs \u5B9E\u9645\u300D\u7684\u5DEE\u5F02\u5206\u6790\uFF0C\u53EA\u7ED9\u5931\u8D25\u73B0\u573A\u6A21\u578B\u53EA\u80FD\u731C\u3002",inputSchema:{expectedBehavior:q.string().optional().describe("\u6D4B\u8BD5\u7684\u9884\u671F\u884C\u4E3A\uFF0C\u5982\u300C\u70B9\u51FB\u63D0\u4EA4\u6309\u94AE\u540E 2s \u5185\u51FA\u73B0\u652F\u4ED8\u6210\u529F\u5F39\u7A97\u300D\u2014\u2014\u5F52\u56E0\u7684\u57FA\u51C6\u7EBF\uFF0C\u5F3A\u70C8\u5EFA\u8BAE\u4F20\u5165"),testSteps:q.string().optional().describe("\u5931\u8D25\u524D\u7684\u64CD\u4F5C\u6B65\u9AA4\u5E8F\u5217\uFF0C\u5982\u300C\u6253\u5F00\u9875\u9762 \u2192 \u586B\u5199\u8868\u5355 \u2192 \u70B9\u51FB\u63D0\u4EA4\u300D"),screenshotPath:q.string().optional().describe("\u5931\u8D25\u622A\u5C4F\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF08\u63A8\u8350\uFF0C\u907F\u514D base64 \u8FDB\u4E0A\u4E0B\u6587\uFF09"),screenshotBase64:q.string().optional().describe("\u5931\u8D25\u622A\u5C4F base64\uFF08\u515C\u5E95\uFF1B\u4E0E screenshotPath \u4E8C\u9009\u4E00\uFF09"),domSnapshot:q.string().optional().describe("\u5931\u8D25\u65F6\u7684 DOM \u5FEB\u7167\u6587\u672C"),errorText:q.string().optional().describe("\u9519\u8BEF\u6D88\u606F/\u6808")}},async e=>{let r=`You are an E2E test triage assistant. You are given: the EXPECTED behavior, (optional) steps taken before failure, and failure artifacts (screenshot/DOM/error). Judge the root cause by comparing expected vs actual. Output JSON: {"rootCause":"<=30 words","evidence":"cite concrete evidence: DOM snippet / error text / screenshot phenomenon, <=60 words","category":"selector_not_found|selector_changed|timing|layout_css|data|auth|environment|other","confidence":<0-1>,"next_action":"wait_and_retry|check_selector|refresh|fix_data|report_bug","fixSuggestion":"<=30 words"}. category guide: selector_not_found = target element never rendered; selector_changed = DOM structure changed but function still exists; timing = sequencing / dynamic rendering not finished; layout_css = style-caused anomaly; data = missing or wrong data; auth = auth/login-state problem; environment = network/timeout/proxy issues. confidence must be backed by evidence; confidence without evidence is meaningless. Expected behavior: ${e.expectedBehavior||"(not provided, base your analysis on the failure artifacts only)"}`+(e.testSteps?`
|
|
60
|
+
`+e}),o=Array.isArray(n?.result)?n.result:[];return t.map((s,i)=>{let a=o[i];if(!a||typeof a.same!="boolean")return{same:!0,cls:"",reason:"vision \u89E3\u6790\u5931\u8D25\uFF0C\u6309\u8BED\u4E49\u63A5\u8FD1\u9ED8\u8BA4\u653E\u884C"};let c=r.has(a.equivalence_class)?a.equivalence_class:"";return{same:a.same,cls:c,reason:String(a.reason||"")}})}catch{return t.map(()=>({same:!0,cls:"",reason:"vision \u8C03\u7528\u5931\u8D25\uFF0C\u6309\u8BED\u4E49\u63A5\u8FD1\u9ED8\u8BA4\u653E\u884C"}))}}function w_(t,e,r){let n=Math.round(t*2)/2;if(n<=0)return null;let o=(Number(e)||0)>=900?700:Number(e)||0,s=Bo(r);return s?{key:`${n}|${o}|rgb(${s.r},${s.g},${s.b})`,fontSize:n,fontWeight:o,color:`rgb(${s.r},${s.g},${s.b})`}:null}function JE(t,e){let r=()=>({fontSize:0,fontWeight:0,color:"",count:0,designLayers:[],samples:[],selectors:[]}),n=(c,u,l)=>{let d=c.get(u.key);d||(d=r(),d.fontSize=u.fontSize,d.fontWeight=u.fontWeight,d.color=u.color,c.set(u.key,d)),d.count++,l(d)},o=new Map;for(let c of t){if(c.type!=="text"||!c.fontSize||(c.y??0)<44)continue;let u=w_(c.fontSize,c.fontWeight||0,c.color||"");u&&n(o,u,l=>{l.designLayers.length<4&&c.name&&l.designLayers.push(c.name),l.samples.length<3&&c.text&&l.samples.push(String(c.text).slice(0,18))})}let s=new Map;for(let c of e){if(!c.text||!c.fontSize)continue;let u=w_(c.fontSize,c.fontWeight||0,c.color);u&&n(s,u,l=>{l.selectors.length<4&&c.selector&&l.selectors.push(c.selector),l.samples.length<3&&c.text&&l.samples.push(c.text.slice(0,18))})}let i=[...o.entries()].filter(([c])=>!s.has(c)).map(([,c])=>c).sort((c,u)=>u.count-c.count),a=[...s.entries()].filter(([c])=>!o.has(c)).map(([,c])=>c).sort((c,u)=>u.count-c.count);return{designStyleCount:o.size,pageStyleCount:s.size,missingOnPage:i,notInDesign:a,missingOnPageTotal:i.length,notInDesignTotal:a.length}}async function k_(t){let e=await Li(t.designUrl,{...t.credentials,needCover:!1}),r;try{r=await import("playwright")}catch{throw new Error("\u7F3A\u5C11 playwright\uFF1A\u8BF7\u5728 mcp/lanhu-design-mcp \u4E0B\u6267\u884C npm i playwright && npx playwright install chromium")}let n=await r.chromium.launch({headless:!0});try{let o={width:e.viewport.width||375,height:e.viewport.height||812},s=await n.newPage({viewport:o,deviceScaleFactor:1});await s.goto(t.pageUrl,{waitUntil:"load",timeout:3e4}),t.waitFor&&await s.waitForSelector(t.waitFor,{timeout:1e4}).catch(()=>{}),await new Promise(A=>setTimeout(A,500));let i=await s.evaluate(ME),a=qE(e.layers,o.width),c=a.kept,u=UE(c,i),l=u.length>=3?{dx:qi(u.map(A=>A.sample.x-A.layer.x)),dy:qi(u.map(A=>A.sample.y-A.layer.y))}:null,d=l??{dx:0,dy:0},f=FE(c,i,d),m=f.pairs.filter(A=>Math.abs(A.sample.x-A.layer.x-d.dx)<=8&&Math.abs(A.sample.y-A.layer.y-d.dy)<=8),p=f.pairs.filter(A=>!m.includes(A)).map(A=>A.layer),h=new Set(m.map(A=>i.indexOf(A.sample))),g=x_([...f.rest,...p],i,h,d),y=VE([...m,...g.pairs]),_=y.inliers.length>=3?y.off:l??{dx:0,dy:0},w=new Set(m.map(A=>i.indexOf(A.sample))),x=x_([...f.rest,...p],i,w,_),$=[...m,...x.pairs],P=[],J=[];for(let{layer:A,sample:oe,matchBy:Ee}of $)for(let He of DE(A,oe,Ee,_))He.field==="text"&&J.push(P.length),P.push(He);let H=!1;J.length&&An()&&(H=!0,(await BE(J.map(oe=>({expected:String(P[oe].expected),actual:String(P[oe].actual)})))).forEach((oe,Ee)=>{let He=P[J[Ee]];oe.cls&&(He.equivalenceClass=oe.cls),oe.reason&&(He.textReason=oe.reason),oe.same||(He.severity="major")}));let k=t.maxDiffs??50,O=[];if(a.skipped){let A=Object.entries(a.reasons).map(([oe,Ee])=>`${oe}\xD7${Ee}`).join("\uFF0C");O.push(`\u6BD4\u5BF9\u524D\u5254\u9664 ${a.skipped} \u4E2A\u65E0\u6548/\u72B6\u6001\u680F\u56FE\u5C42\uFF08${A}\uFF09\uFF1B\u8FD9\u4E9B\u5C42\u5728 webview \u4E2D\u4E0D\u6E32\u67D3\uFF0C\u4E0D\u53C2\u4E0E\u9A8C\u6536`)}(Math.abs(_.dx)>=2||Math.abs(_.dy)>=2)&&O.push(`\u68C0\u6D4B\u5230\u9875\u9762\u6574\u4F53\u504F\u79FB (dx=${Math.round(_.dx)}, dy=${Math.round(_.dy)})\uFF0C\u4F4D\u7F6E\u5B57\u6BB5\u5DF2\u6309\u6B64\u6821\u6B63\u540E\u6BD4\u5BF9\uFF1B\u5E38\u89C1\u539F\u56E0\u662F\u8BBE\u8BA1\u7A3F\u542B\u72B6\u6001\u680F\u5360\u4F4D\u800C\u9875\u9762\u7528\u539F\u751F\u5B89\u5168\u533A`),p.length&&O.push(`${p.length} \u4E2A\u6587\u6848\u951A\u70B9\u4E0E\u6574\u4F53\u504F\u79FB\u4E0D\u4E00\u81F4\uFF08\u591A\u4E3A *30D/x5/Lv.5 \u8FD9\u7C7B\u91CD\u590D\u77ED\u4E32\u4E32\u4F4D\uFF09\uFF0C\u5DF2\u5254\u9664\u5E76\u9000\u56DE\u51E0\u4F55\u91CD\u914D`);let E=x.unmatched.filter(A=>A.text).length;x.unmatched.length&&O.push(`${x.unmatched.length} \u4E2A\u56FE\u5C42\u672A\u5339\u914D\u5230\u9875\u9762\u5143\u7D20\uFF08\u5176\u4E2D ${E} \u4E2A\u542B\u6587\u6848\uFF09\uFF1B\u88C5\u9970\u5C42\u7528 CSS/\u80CC\u666F\u5B9E\u73B0\u4E0D\u4EA7\u751F DOM \u5143\u7D20\u5C5E\u6B63\u5E38\uFF0C\u4F46\u542B\u6587\u6848\u7684\u672A\u5339\u914D\u9700\u4EBA\u5DE5\u786E\u8BA4\u662F\u5426\u6F0F\u505A`),P.length>0&&O.push(`\u5B57\u6BB5\u504F\u5DEE\u5171 ${P.length} \u6761\uFF08\u6309\u56FE\u5C42\u5206\u7EC4\u89C1 diffs\uFF0Ccritical \u7EC4\u5728\u524D\uFF09\uFF1B\u6587\u6848\u5DEE\u5F02\u9ED8\u8BA4 minor\uFF0C\u7ECF\u89C6\u89C9\u6A21\u578B\u5224\u4E3A\u4E0D\u540C\u542B\u4E49\u624D\u5347 major`);let F={critical:0,major:1,minor:2},re=new Map;for(let A of P){let oe=`${A.layer}\0${A.path}\0${A.selector}\0${A.matchBy}`,Ee=re.get(oe);Ee||(Ee={layer:A.layer,path:A.path,selector:A.selector,matchBy:A.matchBy,diffs:[]},re.set(oe,Ee));let{layer:He,path:zt,selector:Fi,matchBy:Vi,...z_}=A;Ee.diffs.push(z_)}let K=[...re.values()].map(A=>({...A,diffs:[...A.diffs].sort((oe,Ee)=>F[oe.severity]-F[Ee.severity])})).sort((A,oe)=>{let Ee=Math.min(...A.diffs.map(zt=>F[zt.severity])),He=Math.min(...oe.diffs.map(zt=>F[zt.severity]));return Ee-He||oe.diffs.length-A.diffs.length}),Ve=K.slice(0,k);K.length>k&&O.push(`\u504F\u5DEE\u5171 ${K.length} \u7EC4 / ${P.length} \u6761\u5B57\u6BB5\u504F\u5DEE\uFF0C\u5DF2\u8FBE\u4E0A\u9650 ${k} \u7EC4\uFF0C\u5EFA\u8BAE\u5148\u4FEE critical \u518D\u590D\u68C0`);let ce=JE(c,i);return(ce.missingOnPage.length||ce.notInDesign.length)&&O.push(`\u6837\u5F0F\u6E05\u5355\u6BD4\u5BF9\uFF08\u96F6\u6807\u6CE8\u3001\u4E0D\u6BD4\u6587\u6848\uFF09\uFF1A\u8BBE\u8BA1\u7A3F ${ce.designStyleCount} \u79CD / \u9875\u9762 ${ce.pageStyleCount} \u79CD\u6587\u5B57\u6837\u5F0F\uFF1B\u8BBE\u8BA1\u6709\u9875\u9762\u65E0 ${ce.missingOnPage.length} \u79CD\u3001\u9875\u9762\u6709\u8BBE\u8BA1\u65E0 ${ce.notInDesign.length} \u79CD \u2192 \u89C1 inventory \u5B57\u6BB5`),{design:{name:e.name||"(\u672A\u547D\u540D\u8BBE\u8BA1\u7A3F)",viewport:e.viewport,layerCount:e.layers.length},page:{url:t.pageUrl,viewport:o,sampled:i.length},matched:$.length,offset:{dx:Math.round(_.dx*100)/100,dy:Math.round(_.dy*100)/100,anchors:m.length,rejected:p.length},denoised:a,diffs:Ve,diffCount:P.length,diffGroupCount:K.length,diffsTruncated:K.length>k,unmatchedLayers:x.unmatched.slice(0,50).map(A=>A.name||"(\u672A\u547D\u540D\u56FE\u5C42)"),notes:O,textCheckedByVision:H,inventory:{...ce,missingOnPage:ce.missingOnPage.slice(0,20),notInDesign:ce.notInDesign.slice(0,20),missingOnPageTotal:ce.missingOnPage.length,notInDesignTotal:ce.notInDesign.length}}}finally{await n.close()}}var GE={source:"mock",viewport:{width:390,height:844},layers:[{id:"bg",type:"rect",x:0,y:0,w:390,h:844,fill:"#0E0B1A"},{id:"title",type:"text",x:24,y:64,w:342,h:32,text:"Masked Ball",fontSize:24,fontWeight:700,color:"#F5F1FF",fontFamily:"Inter"},{id:"cta",type:"rect",x:24,y:720,w:342,h:48,fill:"#7C5CFF",radius:12},{id:"card",type:"rect",x:24,y:120,w:342,h:200,fill:"#1A1530",radius:16},{id:"badge",type:"rect",x:24,y:340,w:61,h:16,fill:"#771E00",borderRadius:{topLeft:8,topRight:12,bottomLeft:0,bottomRight:12},border:{color:"rgba(239,216,185,1)",width:1,alignment:"inside"}}],meta:{rawLayerCount:4,totalLayerCount:4}};function st(t){return{content:[{type:"text",text:JSON.stringify(t)}]}}function YE(t){if(t)try{return KE(t,"utf8").trim()||void 0}catch{return}}function Wr(t){return{cookie:t.cookie||process.env.LANHU_COOKIE||YE(process.env.LANHU_COOKIE_FILE)}}async function XE(t){try{return`data:image/jpeg;base64,${(await Ed(Buffer.from(t,"base64"))).toString("base64")}`}catch{return t}}async function Ui(t){if(t.path)try{return`data:image/jpeg;base64,${(await Ed(await WE(t.path))).toString("base64")}`}catch(e){throw new Error(`\u8BFB\u53D6\u56FE\u7247\u5931\u8D25\uFF08${t.path}\uFF09\uFF1A${e.message}`)}if(t.b64)return XE(t.b64);throw new Error(`${t.what}\uFF1A\u8BF7\u4F20 imagePath\uFF08\u672C\u5730\u622A\u56FE\u6587\u4EF6\u8DEF\u5F84\uFF0C\u63A8\u8350\uFF09\u6216 imageBase64 \u4E4B\u4E00`)}function S_(t){t.registerTool("lanhu_fetch_design",{description:"\u8BFB\u53D6\u84DD\u6E56\u8BBE\u8BA1\u7A3F\u7684\u7ED3\u6784\u5316\u56FE\u5C42\u6811\uFF08\u7CBE\u786E x/y/\u5BBD\u9AD8/\u8272\u503C/\u5B57\u53F7/\u5706\u89D2/\u63CF\u8FB9/\u6587\u672C\uFF09\u3002mode\uFF1Aapi=\u5B98\u65B9Cookie\u63A5\u53E3(\u9ED8\u8BA4,\u65E0\u9700\u6D4F\u89C8\u5668) / mock=\u5185\u7F6E\u793A\u4F8B\u3002analyze=true \u65F6\u7528\u914D\u7F6E\u7684\u89C6\u89C9\u6A21\u578B\u7406\u89E3\u8BBE\u8BA1\u7A3F\u5C01\u9762\u56FE\u3002analyze \u9ED8\u8BA4\u503C\uFF1A\u5DF2\u914D\u7F6E\u89C6\u89C9\u6A21\u578B\uFF08VLM_MODEL + VLM_API_KEY\uFF09\u65F6\u9ED8\u8BA4 true\uFF0C\u672A\u914D\u7F6E\u5219\u9ED8\u8BA4 false\uFF1B\u663E\u5F0F\u4F20 true/false \u59CB\u7EC8\u4F18\u5148\u3002\u4F7F\u7528\u7EAA\u5F8B\uFF1A\u4E00\u6B21\u53EA\u8BFB\u5F53\u524D\u8981\u5B9E\u73B0\u7684\u90A3 1 \u5F20\u7A3F\uFF1B\u4E0D\u8981\u4E3A\u300C\u4E86\u89E3\u5168\u8C8C\u300D\u6279\u91CF\u8BFB\u7A3F\u2014\u2014\u5206\u7EC4\u7A3F\u76EE\u5F55\u7528 lanhu_read_sector\uFF0C\u5B83\u8DB3\u591F\u5B9A\u4F4D\uFF1B\u8FD4\u56DE\u7684 layers \u542B\u7CBE\u786E\u6570\u503C\uFF0C\u8272\u503C/\u5B57\u53F7\u4ECE\u6570\u636E\u53D6\uFF0C\u7981\u6B62\u9760\u89C6\u89C9\u6A21\u578B OCR \u5C0F\u5B57\u3002",inputSchema:{mode:q.enum(["api","mock"]).default("api").describe("\u62BD\u53D6\u540E\u7AEF"),url:q.string().optional().describe("\u84DD\u6E56\u8BBE\u8BA1\u7A3F\u94FE\u63A5\uFF0C\u5982 https://lanhuapp.com/web/#/item/project/detailDetach?pid=xxx&image_id=yyy"),imageId:q.string().optional().describe("\u8BBE\u8BA1\u7A3F id\uFF08\u6765\u81EA lanhu_read_sector\uFF09\uFF0C\u4E0E projectId \u642D\u914D\uFF1Burl \u4E0E imageId \u4E8C\u9009\u4E00\uFF0C\u514D\u62FC URL"),projectId:q.string().optional().describe("\u9879\u76EE UUID\uFF08imageId \u6A21\u5F0F\u5FC5\u586B\uFF1Burl \u6A21\u5F0F\u4E0D\u9700\u8981\uFF09"),cookie:q.string().optional().describe("\u767B\u5F55 cookie \u4E32\uFF08\u4E5F\u53EF\u7528 LANHU_COOKIE / LANHU_COOKIE_FILE\uFF09"),analyze:q.boolean().optional().describe("\u7528\u89C6\u89C9\u6A21\u578B\u7406\u89E3\u5C01\u9762\u56FE\uFF0C\u8FD4\u56DE visionAnalysis\uFF1B\u4E0D\u4F20\u65F6\u6309\u662F\u5426\u914D\u7F6E\u4E86\u89C6\u89C9\u6A21\u578B\u81EA\u52A8\u51B3\u5B9A\uFF08\u914D\u4E86\u5C31 true\uFF09"),analyzeFocus:q.string().optional().describe("\u6CE8\u5165\u89C6\u89C9\u6A21\u578B\u7684\u989D\u5916\u5173\u6CE8\u70B9/\u4E1A\u52A1\u80CC\u666F\uFF08\u5982\u300C\u91CD\u70B9\u5206\u6790\u7B7E\u5230\u5F39\u7A97\uFF0C\u5FFD\u7565\u906E\u7F69\u5C42\u5E95\u4E0B\u7684\u5185\u5BB9\u300D\u300C\u5173\u6CE8\u6309\u94AE\u7684\u7981\u7528\u6001\u300D\uFF09\uFF0C\u8BA9\u5206\u6790\u66F4\u8D34\u5408\u5F53\u524D\u4EFB\u52A1\uFF1B\u4E0D\u5F71\u54CD\u8FD4\u56DE JSON \u7ED3\u6784\uFF0C\u4EC5 analyze \u6267\u884C\u65F6\u751F\u6548")}},async e=>{if(process.env.LANHU_MOCK==="1"||e.mode==="mock")return st(GE);if(!e.url&&!e.imageId)throw new Error("api \u6A21\u5F0F\u9700\u8981 url \u6216 imageId+projectId");if(e.imageId&&!e.projectId&&!e.url)throw new Error("imageId \u6A21\u5F0F\u9700\u8981\u540C\u65F6\u4F20 projectId");let r=e.analyze??__();e.analyze===void 0&&r&&console.error(`[fetch_design] analyze \u672A\u6307\u5B9A\u4E14\u89C6\u89C9\u6A21\u578B\u5DF2\u914D\u7F6E \u2192 \u81EA\u52A8\u5F00\u542F\uFF08${process.env.VLM_MODEL||"\u9ED8\u8BA4\u6A21\u578B"}\uFF09`);let n={...Wr(e),needCover:r},o=e.url?await Li(e.url,n):await c_(e.imageId,e.projectId,n);if(o.slices&&(o.slices=o.slices.map(({imageUrl:a,...c})=>c)),!r)return st(o);let{coverImageBase64:s,...i}=o;if(!s)return st({...i,visionError:"\u8BBE\u8BA1\u7A3F\u65E0\u5C01\u9762\u56FE\uFF08coverImageBase64 \u4E3A\u7A7A\uFF09\uFF0C\u5DF2\u8DF3\u8FC7\u89C6\u89C9\u5206\u6790"});try{let a=await Jr({images:[`data:image/jpeg;base64,${s}`],text:b_(i.meta?.docName??i.name,e.analyzeFocus),detail:"high"});return st({...i,visionAnalysis:a})}catch(a){console.error(`[fetch_design] \u89C6\u89C9\u5206\u6790\u5931\u8D25\uFF0C\u964D\u7EA7\u8FD4\u56DE\u56FE\u5C42\u6811\uFF1A${a?.message}`);let c=An()?"":"\u672A\u68C0\u6D4B\u5230\u89C6\u89C9\u6A21\u578B\u914D\u7F6E\uFF1A\u9700\u540C\u65F6\u8BBE\u7F6E VLM_MODEL \u4E0E VLM_API_KEY\u3002";return st({...i,visionError:`${a?.message||String(a)}${c}`})}}),t.registerTool("lanhu_verify_render",{description:"\u628A\u6E32\u67D3\u9875\u622A\u56FE\uFF08\u53EF\u9009\uFF1A\u8BBE\u8BA1\u7A3F\u622A\u56FE\uFF09\u8C03\u89C6\u89C9\u6A21\u578B\u505A\u8BED\u4E49\u5BF9\u6BD4\uFF0C\u8FD4\u56DE matchScore / verdict / diffs\u3002\u622A\u56FE\u4F20 imagePath\uFF08\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF0C\u63A8\u8350\uFF09\u6216 imageBase64 \u515C\u5E95\u3002\u4F20 context \u53EF\u58F0\u660E\u5DF2\u77E5\u523B\u610F\u5DEE\u5F02\uFF0C\u6A21\u578B\u5C06\u8DF3\u8FC7\u8FD9\u4E9B\u533A\u57DF\u3002\u7ED3\u8BBA\u4EC5\u662F\u89C6\u89C9\u7EBF\u7D22\uFF0C\u4E0E lanhu_verify_spec \u6570\u636E\u6BD4\u5BF9\u51B2\u7A81\u65F6\u4EE5\u6570\u636E\u6BD4\u5BF9\u4E3A\u51C6\u3002",inputSchema:{actualImagePath:q.string().optional().describe("\u6E32\u67D3\u9875\u622A\u56FE\u7684\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF08\u63A8\u8350\uFF0C\u907F\u514D base64 \u8FDB\u4E0A\u4E0B\u6587\uFF09"),actualImageBase64:q.string().optional().describe("\u6E32\u67D3\u9875\u622A\u56FE base64\uFF08\u515C\u5E95\uFF1B\u4E0E actualImagePath \u4E8C\u9009\u4E00\uFF09"),designImagePath:q.string().optional().describe("\u8BBE\u8BA1\u7A3F\u622A\u56FE\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009\uFF0C\u53CC\u56FE\u5BF9\u6BD4\u7528\uFF09"),designImageBase64:q.string().optional().describe("\u8BBE\u8BA1\u7A3F\u622A\u56FE base64\uFF08\u515C\u5E95\uFF09"),context:q.string().optional().describe("\u5DF2\u77E5\u523B\u610F\u5DEE\u5F02\u8BF4\u660E\uFF0C\u6A21\u578B\u5C06\u8DF3\u8FC7\u8FD9\u4E9B\u533A\u57DF\u7684\u62A5\u9519\u3002\u5982\u300C\u9876\u90E844px\u662F\u7CFB\u7EDF\u72B6\u6001\u680F\uFF0C\u9875\u9762\u7531\u539F\u751F\u6E32\u67D3\u300D\u300C\u5E95\u90E8\u6309\u94AE\u523B\u610F\u52A0\u9AD8\u523056px\u300D"),detail:q.enum(["auto","low","high"]).optional()}},async e=>{let r=!!(e.designImagePath||e.designImageBase64),n=r?`You are a senior frontend reviewer. Compare the RENDERED screenshot (first image) against the DESIGN reference (second image). Output a JSON: {"matchScore":<0-100>,"verdict":"pass|need_fix|fail","diffs":[{"location":"","issue":"","severity":"minor|major|critical"}],"suggestions":["..."]}. Ignore: JPEG compression noise, font anti-aliasing differences, resolution differences between the two images (compare by relative proportions, do not misreport size due to pixel density). Counter-rule: structural problems (misalignment/truncation/color deviation/missing elements) MUST be reported even if the image looks blurry. Known intentional differences (do NOT report these): ${e.context||"none"}. Arbitration: your verdict is a visual hint only; if it conflicts with the lanhu_verify_spec data comparison, the data comparison wins. Output discipline: at most 15 diffs, most important first. Only output JSON.`:`You are a senior frontend reviewer. No design reference provided \u2014 inspect this rendered screenshot for internal consistency only: layout sanity, alignment, contrast, truncation, overlap. Output JSON: {"matchScore":<0-100>,"verdict":"pass|need_fix|fail","diffs":[{"location":"","issue":"","severity":"minor|major|critical"}],"suggestions":["..."]}. Known intentional differences (do NOT report these): ${e.context||"none"}. Output discipline: at most 15 diffs, most important first. Only output JSON.`,o=[await Ui({b64:e.actualImageBase64,path:e.actualImagePath,what:"\u6E32\u67D3\u9875\u622A\u56FE"})];return r&&o.push(await Ui({b64:e.designImageBase64,path:e.designImagePath,what:"\u8BBE\u8BA1\u7A3F\u622A\u56FE"})),st(await Jr({images:o,text:n,detail:e.detail||"high"}))}),t.registerTool("vision_defect_check",{description:"\u6574\u9875/\u5C40\u90E8 UI \u7F3A\u9677\u68C0\u6D4B\uFF1A\u91CD\u53E0\u3001\u6EA2\u51FA\u3001\u7F3A\u56FE\u3001\u5BF9\u6BD4\u5EA6\u3001\u9519\u4F4D\u3001\u622A\u65AD\u3001\u7834\u56FE\u3001\u5360\u4F4D\u6B8B\u7559\u7B49 12 \u7C7B\u3002\u622A\u56FE\u4F20 imagePath\uFF08\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF0C\u63A8\u8350\uFF09\u6216 imageBase64 \u515C\u5E95\u3002\u8FD4\u56DE defects \u6570\u7EC4\u4E0E pass\u3002\u4F20 context \u53EF\u58F0\u660E\u5DF2\u77E5\u523B\u610F\u5DEE\u5F02\uFF0C\u6A21\u578B\u5C06\u8DF3\u8FC7\u8FD9\u4E9B\u533A\u57DF\u3002",inputSchema:{imagePath:q.string().optional().describe("\u622A\u5C4F\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF08\u63A8\u8350\uFF0C\u907F\u514D base64 \u8FDB\u4E0A\u4E0B\u6587\uFF09"),imageBase64:q.string().optional().describe("\u622A\u5C4F base64\uFF08\u515C\u5E95\uFF1B\u4E0E imagePath \u4E8C\u9009\u4E00\uFF09"),context:q.string().optional().describe("\u5DF2\u77E5\u523B\u610F\u5DEE\u5F02\u8BF4\u660E\uFF0C\u6A21\u578B\u5C06\u8DF3\u8FC7\u8FD9\u4E9B\u533A\u57DF\u7684\u62A5\u9519\u3002\u5982\u300C\u9876\u90E844px\u662F\u7CFB\u7EDF\u72B6\u6001\u680F\uFF0C\u9875\u9762\u7531\u539F\u751F\u6E32\u67D3\u300D"),language:q.string().optional().describe("\u8BED\u8A00\uFF0C\u9ED8\u8BA4 zh-CN"),detail:q.enum(["auto","low","high"]).optional()}},async e=>{let n=`Inspect this UI screenshot for visual defects; write all descriptions in ${e.language||"zh-CN"}. Output JSON: {"defects":[{"type":"overlap|overflow|missing_asset|contrast|misalign|truncation|broken_image|placeholder|stale_state|typo|alignment|other","severity":"minor|major|critical","location":"","description":""}],"summary":"","pass":<true|false>}. type guide: overlap / overflow / missing_asset / contrast(insufficient) / misalign / truncation / broken_image / placeholder(unreplaced, e.g. lorem or test images) / stale_state(e.g. loading never dismissed) / typo / alignment / other. severity (qualitative): critical = unreadable content / non-clickable element / blocked interaction; major = clearly visible, hurts consistency; minor = nitpick level. For contrast defects, always include the estimated ratio in description as "ratio:x.x". Known intentional differences (do NOT report these): ${e.context||"none"}. Output discipline: at most 15 defects, most severe first. Only output JSON.`;return st(await Jr({images:[await Ui({b64:e.imageBase64,path:e.imagePath,what:"\u622A\u5C4F"})],text:n,detail:e.detail||"auto"}))}),t.registerTool("vision_e2e_triage",{description:"E2E \u6D4B\u8BD5\u5931\u8D25\u65F6\uFF0C\u5206\u6790\u622A\u56FE+DOM \u5FEB\u7167+\u9519\u8BEF\u6587\u672C\uFF0C\u7ED9\u51FA\u6839\u56E0\u3001\u7C7B\u522B\u3001\u7F6E\u4FE1\u5EA6\u4E0E\u4E0B\u4E00\u6B65\u52A8\u4F5C\u5EFA\u8BAE\u3002\u622A\u56FE\u4F20 screenshotPath\uFF08\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF0C\u63A8\u8350\uFF09\u6216 screenshotBase64 \u515C\u5E95\u3002\u5F3A\u70C8\u5EFA\u8BAE\u4F20 expectedBehavior\uFF08\u6D4B\u8BD5\u9884\u671F\u884C\u4E3A\uFF09\u2014\u2014\u5F52\u56E0\u8D28\u91CF\u53D6\u51B3\u4E8E\u300C\u9884\u671F vs \u5B9E\u9645\u300D\u7684\u5DEE\u5F02\u5206\u6790\uFF0C\u53EA\u7ED9\u5931\u8D25\u73B0\u573A\u6A21\u578B\u53EA\u80FD\u731C\u3002",inputSchema:{expectedBehavior:q.string().optional().describe("\u6D4B\u8BD5\u7684\u9884\u671F\u884C\u4E3A\uFF0C\u5982\u300C\u70B9\u51FB\u63D0\u4EA4\u6309\u94AE\u540E 2s \u5185\u51FA\u73B0\u652F\u4ED8\u6210\u529F\u5F39\u7A97\u300D\u2014\u2014\u5F52\u56E0\u7684\u57FA\u51C6\u7EBF\uFF0C\u5F3A\u70C8\u5EFA\u8BAE\u4F20\u5165"),testSteps:q.string().optional().describe("\u5931\u8D25\u524D\u7684\u64CD\u4F5C\u6B65\u9AA4\u5E8F\u5217\uFF0C\u5982\u300C\u6253\u5F00\u9875\u9762 \u2192 \u586B\u5199\u8868\u5355 \u2192 \u70B9\u51FB\u63D0\u4EA4\u300D"),screenshotPath:q.string().optional().describe("\u5931\u8D25\u622A\u5C4F\u672C\u5730\u6587\u4EF6\u8DEF\u5F84\uFF08\u63A8\u8350\uFF0C\u907F\u514D base64 \u8FDB\u4E0A\u4E0B\u6587\uFF09"),screenshotBase64:q.string().optional().describe("\u5931\u8D25\u622A\u5C4F base64\uFF08\u515C\u5E95\uFF1B\u4E0E screenshotPath \u4E8C\u9009\u4E00\uFF09"),domSnapshot:q.string().optional().describe("\u5931\u8D25\u65F6\u7684 DOM \u5FEB\u7167\u6587\u672C"),errorText:q.string().optional().describe("\u9519\u8BEF\u6D88\u606F/\u6808")}},async e=>{let r=`You are an E2E test triage assistant. You are given: the EXPECTED behavior, (optional) steps taken before failure, and failure artifacts (screenshot/DOM/error). Judge the root cause by comparing expected vs actual. Output JSON: {"rootCause":"<=30 words","evidence":"cite concrete evidence: DOM snippet / error text / screenshot phenomenon, <=60 words","category":"selector_not_found|selector_changed|timing|layout_css|data|auth|environment|other","confidence":<0-1>,"next_action":"wait_and_retry|check_selector|refresh|fix_data|report_bug","fixSuggestion":"<=30 words"}. category guide: selector_not_found = target element never rendered; selector_changed = DOM structure changed but function still exists; timing = sequencing / dynamic rendering not finished; layout_css = style-caused anomaly; data = missing or wrong data; auth = auth/login-state problem; environment = network/timeout/proxy issues. confidence must be backed by evidence; confidence without evidence is meaningless. Expected behavior: ${e.expectedBehavior||"(not provided, base your analysis on the failure artifacts only)"}`+(e.testSteps?`
|
|
56
61
|
Steps before failure: ${e.testSteps}`:""),n=e.screenshotPath||e.screenshotBase64?[await Ui({b64:e.screenshotBase64,path:e.screenshotPath,what:"\u5931\u8D25\u622A\u5C4F"})]:[],o=n.length?r:`No screenshot provided. Base your analysis on DOM + error text only.
|
|
57
62
|
`+r,s=e.domSnapshot?`
|
|
58
63
|
|