dsh-palace 1.3.0 → 1.3.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 +17 -2
- package/client/client.js +28 -20
- package/lib/index.js +705 -61
- package/lib/mcp.js +69 -65
- package/lib/palace-web.js +33 -25
- package/package.json +1 -1
package/lib/mcp.js
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire } from "node:module"; const require = createRequire(import.meta.url);
|
|
3
|
-
var xw=Object.create;var $i=Object.defineProperty;var Sw=Object.getOwnPropertyDescriptor;var kw=Object.getOwnPropertyNames;var zw=Object.getPrototypeOf,Pw=Object.prototype.hasOwnProperty;var x=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},ul=(e,t)=>{for(var r in t)$i(e,r,{get:t[r],enumerable:!0})},Ew=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of kw(t))!Pw.call(e,o)&&o!==r&&$i(e,o,{get:()=>t[o],enumerable:!(n=Sw(t,o))||n.enumerable});return e};var ll=(e,t,r)=>(r=e!=null?xw(zw(e)):{},Ew(t||!e||!e.__esModule?$i(r,"default",{value:e,enumerable:!0}):r,e));var Pn=x(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.regexpCode=V.getEsmExportName=V.getProperty=V.safeStringify=V.stringify=V.strConcat=V.addCodeArg=V.str=V._=V.nil=V._Code=V.Name=V.IDENTIFIER=V._CodeOrName=void 0;var kn=class{};V._CodeOrName=kn;V.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ht=class extends kn{constructor(t){if(super(),!V.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};V.Name=Ht;var Le=class extends kn{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof Ht&&(r[n.str]=(r[n.str]||0)+1),r),{})}};V._Code=Le;V.nil=new Le("");function Ih(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Qa(r,t[n]),r.push(e[++n]);return new Le(r)}V._=Ih;var Xa=new Le("+");function Th(e,...t){let r=[zn(e[0])],n=0;for(;n<t.length;)r.push(Xa),Qa(r,t[n]),r.push(Xa,zn(e[++n]));return W$(r),new Le(r)}V.str=Th;function Qa(e,t){t instanceof Le?e.push(...t._items):t instanceof Ht?e.push(t):e.push(Q$(t))}V.addCodeArg=Qa;function W$(e){let t=1;for(;t<e.length-1;){if(e[t]===Xa){let r=Y$(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function Y$(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Ht||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof Ht))return`"${e}${t.slice(1)}`}function X$(e,t){return t.emptyStr()?e:e.emptyStr()?t:Th`${e}${t}`}V.strConcat=X$;function Q$(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:zn(Array.isArray(e)?e.join(","):e)}function ex(e){return new Le(zn(e))}V.stringify=ex;function zn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}V.safeStringify=zn;function tx(e){return typeof e=="string"&&V.IDENTIFIER.test(e)?new Le(`.${e}`):Ih`[${e}]`}V.getProperty=tx;function rx(e){if(typeof e=="string"&&V.IDENTIFIER.test(e))return new Le(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}V.getEsmExportName=rx;function nx(e){return new Le(e.toString())}V.regexpCode=nx});var rc=x(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.ValueScope=Ee.ValueScopeName=Ee.Scope=Ee.varKinds=Ee.UsedValueState=void 0;var Pe=Pn(),ec=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Ts;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Ts||(Ee.UsedValueState=Ts={}));Ee.varKinds={const:new Pe.Name("const"),let:new Pe.Name("let"),var:new Pe.Name("var")};var Os=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Pe.Name?t:this.name(t)}name(t){return new Pe.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Ee.Scope=Os;var Rs=class extends Pe.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Pe._)`.${new Pe.Name(r)}[${n}]`}};Ee.ValueScopeName=Rs;var ox=(0,Pe._)`\n`,tc=class extends Os{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?ox:Pe.nil}}get(){return this._scope}name(t){return new Rs(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{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(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Pe._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Pe.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Ts.Started);let l=r(u);if(l){let d=this.opts.es5?Ee.varKinds.var:Ee.varKinds.const;s=(0,Pe._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Pe._)`${s}${l}${this.opts._n}`;else throw new ec(u);c.set(u,Ts.Completed)})}return s}};Ee.ValueScope=tc});var j=x(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.or=D.and=D.not=D.CodeGen=D.operators=D.varKinds=D.ValueScopeName=D.ValueScope=D.Scope=D.Name=D.regexpCode=D.stringify=D.getProperty=D.nil=D.strConcat=D.str=D._=void 0;var q=Pn(),Ye=rc(),It=Pn();Object.defineProperty(D,"_",{enumerable:!0,get:function(){return It._}});Object.defineProperty(D,"str",{enumerable:!0,get:function(){return It.str}});Object.defineProperty(D,"strConcat",{enumerable:!0,get:function(){return It.strConcat}});Object.defineProperty(D,"nil",{enumerable:!0,get:function(){return It.nil}});Object.defineProperty(D,"getProperty",{enumerable:!0,get:function(){return It.getProperty}});Object.defineProperty(D,"stringify",{enumerable:!0,get:function(){return It.stringify}});Object.defineProperty(D,"regexpCode",{enumerable:!0,get:function(){return It.regexpCode}});Object.defineProperty(D,"Name",{enumerable:!0,get:function(){return It.Name}});var js=rc();Object.defineProperty(D,"Scope",{enumerable:!0,get:function(){return js.Scope}});Object.defineProperty(D,"ValueScope",{enumerable:!0,get:function(){return js.ValueScope}});Object.defineProperty(D,"ValueScopeName",{enumerable:!0,get:function(){return js.ValueScopeName}});Object.defineProperty(D,"varKinds",{enumerable:!0,get:function(){return js.varKinds}});D.operators={GT:new q._Code(">"),GTE:new q._Code(">="),LT:new q._Code("<"),LTE:new q._Code("<="),EQ:new q._Code("==="),NEQ:new q._Code("!=="),NOT:new q._Code("!"),OR:new q._Code("||"),AND:new q._Code("&&"),ADD:new q._Code("+")};var mt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},nc=class extends mt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?Ye.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=xr(this.rhs,t,r)),this}get names(){return this.rhs instanceof q._CodeOrName?this.rhs.names:{}}},As=class extends mt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof q.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=xr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof q.Name?{}:{...this.lhs.names};return Ns(t,this.rhs)}},oc=class extends As{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},sc=class extends mt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},ic=class extends mt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},ac=class extends mt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},cc=class extends mt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=xr(this.code,t,r),this}get names(){return this.code instanceof q._CodeOrName?this.code.names:{}}},En=class extends mt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(sx(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>Kt(t,r.names),{})}},ht=class extends En{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},uc=class extends En{},$r=class extends ht{};$r.kind="else";var Bt=class e extends ht{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new $r(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Oh(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=xr(this.condition,t,r),this}get names(){let t=super.names;return Ns(t,this.condition),this.else&&Kt(t,this.else.names),t}};Bt.kind="if";var Jt=class extends ht{};Jt.kind="for";var lc=class extends Jt{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=xr(this.iteration,t,r),this}get names(){return Kt(super.names,this.iteration.names)}},dc=class extends Jt{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?Ye.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Ns(super.names,this.from);return Ns(t,this.to)}},Cs=class extends Jt{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=xr(this.iterable,t,r),this}get names(){return Kt(super.names,this.iterable.names)}},In=class extends ht{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};In.kind="func";var Tn=class extends En{render(t){return"return "+super.render(t)}};Tn.kind="return";var fc=class extends ht{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&Kt(t,this.catch.names),this.finally&&Kt(t,this.finally.names),t}},On=class extends ht{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};On.kind="catch";var Rn=class extends ht{render(t){return"finally"+super.render(t)}};Rn.kind="finally";var pc=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
|
-
`:""},this._extScope=t,this._scope=new Ye.Scope({parent:t}),this._nodes=[new uc]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new nc(t,s,n)),s}const(t,r,n){return this._def(Ye.varKinds.const,t,r,n)}let(t,r,n){return this._def(Ye.varKinds.let,t,r,n)}var(t,r,n){return this._def(Ye.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new As(t,r,n))}add(t,r){return this._leafNode(new oc(t,D.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==q.nil&&this._leafNode(new cc(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,q.addCodeArg)(r,o));return r.push("}"),new q._Code(r)}if(t,r,n){if(this._blockNode(new Bt(t)),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(t){return this._elseNode(new Bt(t))}else(){return this._elseNode(new $r)}endIf(){return this._endBlockNode(Bt,$r)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new lc(t),r)}forRange(t,r,n,o,s=this.opts.es5?Ye.varKinds.var:Ye.varKinds.let){let i=this._scope.toName(t);return this._for(new dc(s,i,r,n),()=>o(i))}forOf(t,r,n,o=Ye.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof q.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,q._)`${i}.length`,a=>{this.var(s,(0,q._)`${i}[${a}]`),n(s)})}return this._for(new Cs("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?Ye.varKinds.var:Ye.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,q._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Cs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Jt)}label(t){return this._leafNode(new sc(t))}break(t){return this._leafNode(new ic(t))}return(t){let r=new Tn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Tn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new fc;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new On(s),r(s)}return n&&(this._currNode=o.finally=new Rn,this.code(n)),this._endBlockNode(On,Rn)}throw(t){return this._leafNode(new ac(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){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||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=q.nil,n,o){return this._blockNode(new In(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(In)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof Bt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};D.CodeGen=pc;function Kt(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Ns(e,t){return t instanceof q._CodeOrName?Kt(e,t.names):e}function xr(e,t,r){if(e instanceof q.Name)return n(e);if(!o(e))return e;return new q._Code(e._items.reduce((s,i)=>(i instanceof q.Name&&(i=n(i)),i instanceof q._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof q._Code&&s._items.some(i=>i instanceof q.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function sx(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Oh(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,q._)`!${mc(e)}`}D.not=Oh;var ix=Rh(D.operators.AND);function ax(...e){return e.reduce(ix)}D.and=ax;var cx=Rh(D.operators.OR);function ux(...e){return e.reduce(cx)}D.or=ux;function Rh(e){return(t,r)=>t===q.nil?r:r===q.nil?t:(0,q._)`${mc(t)} ${e} ${mc(r)}`}function mc(e){return e instanceof q.Name?e:(0,q._)`(${e})`}});var F=x(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.checkStrictMode=Z.getErrorPath=Z.Type=Z.useFunc=Z.setEvaluated=Z.evaluatedPropsToName=Z.mergeEvaluated=Z.eachItem=Z.unescapeJsonPointer=Z.escapeJsonPointer=Z.escapeFragment=Z.unescapeFragment=Z.schemaRefOrVal=Z.schemaHasRulesButRef=Z.schemaHasRules=Z.checkUnknownRules=Z.alwaysValidSchema=Z.toHash=void 0;var J=j(),lx=Pn();function dx(e){let t={};for(let r of e)t[r]=!0;return t}Z.toHash=dx;function fx(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Nh(e,t),!jh(t,e.self.RULES.all))}Z.alwaysValidSchema=fx;function Nh(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||Mh(e,`unknown keyword: "${s}"`)}Z.checkUnknownRules=Nh;function jh(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}Z.schemaHasRules=jh;function px(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}Z.schemaHasRulesButRef=px;function mx({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,J._)`${r}`}return(0,J._)`${e}${t}${(0,J.getProperty)(n)}`}Z.schemaRefOrVal=mx;function hx(e){return Dh(decodeURIComponent(e))}Z.unescapeFragment=hx;function gx(e){return encodeURIComponent(gc(e))}Z.escapeFragment=gx;function gc(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}Z.escapeJsonPointer=gc;function Dh(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}Z.unescapeJsonPointer=Dh;function yx(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}Z.eachItem=yx;function Ah({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof J.Name?(s instanceof J.Name?e(o,s,i):t(o,s,i),i):s instanceof J.Name?(t(o,i,s),s):r(s,i);return a===J.Name&&!(c instanceof J.Name)?n(o,c):c}}Z.mergeEvaluated={props:Ah({mergeNames:(e,t,r)=>e.if((0,J._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,J._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,J._)`${r} || {}`).code((0,J._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,J._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,J._)`${r} || {}`),yc(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Zh}),items:Ah({mergeNames:(e,t,r)=>e.if((0,J._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,J._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,J._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,J._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Zh(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,J._)`{}`);return t!==void 0&&yc(e,r,t),r}Z.evaluatedPropsToName=Zh;function yc(e,t,r){Object.keys(r).forEach(n=>e.assign((0,J._)`${t}${(0,J.getProperty)(n)}`,!0))}Z.setEvaluated=yc;var Ch={};function _x(e,t){return e.scopeValue("func",{ref:t,code:Ch[t.code]||(Ch[t.code]=new lx._Code(t.code))})}Z.useFunc=_x;var hc;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(hc||(Z.Type=hc={}));function wx(e,t,r){if(e instanceof J.Name){let n=t===hc.Num;return r?n?(0,J._)`"[" + ${e} + "]"`:(0,J._)`"['" + ${e} + "']"`:n?(0,J._)`"/" + ${e}`:(0,J._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,J.getProperty)(e).toString():"/"+gc(e)}Z.getErrorPath=wx;function Mh(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}Z.checkStrictMode=Mh});var gt=x(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var ge=j(),bx={data:new ge.Name("data"),valCxt:new ge.Name("valCxt"),instancePath:new ge.Name("instancePath"),parentData:new ge.Name("parentData"),parentDataProperty:new ge.Name("parentDataProperty"),rootData:new ge.Name("rootData"),dynamicAnchors:new ge.Name("dynamicAnchors"),vErrors:new ge.Name("vErrors"),errors:new ge.Name("errors"),this:new ge.Name("this"),self:new ge.Name("self"),scope:new ge.Name("scope"),json:new ge.Name("json"),jsonPos:new ge.Name("jsonPos"),jsonLen:new ge.Name("jsonLen"),jsonPart:new ge.Name("jsonPart")};_c.default=bx});var An=x(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.extendErrors=ye.resetErrorsCount=ye.reportExtraError=ye.reportError=ye.keyword$DataError=ye.keywordError=void 0;var L=j(),Ds=F(),$e=gt();ye.keywordError={message:({keyword:e})=>(0,L.str)`must pass "${e}" keyword validation`};ye.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,L.str)`"${e}" keyword must be ${t} ($data)`:(0,L.str)`"${e}" keyword is invalid ($data)`};function vx(e,t=ye.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Lh(e,t,r);n??(i||a)?qh(s,c):Fh(o,(0,L._)`[${c}]`)}ye.reportError=vx;function $x(e,t=ye.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Lh(e,t,r);qh(o,a),s||i||Fh(n,$e.default.vErrors)}ye.reportExtraError=$x;function xx(e,t){e.assign($e.default.errors,t),e.if((0,L._)`${$e.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,L._)`${$e.default.vErrors}.length`,t),()=>e.assign($e.default.vErrors,null)))}ye.resetErrorsCount=xx;function Sx({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,$e.default.errors,a=>{e.const(i,(0,L._)`${$e.default.vErrors}[${a}]`),e.if((0,L._)`${i}.instancePath === undefined`,()=>e.assign((0,L._)`${i}.instancePath`,(0,L.strConcat)($e.default.instancePath,s.errorPath))),e.assign((0,L._)`${i}.schemaPath`,(0,L.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,L._)`${i}.schema`,r),e.assign((0,L._)`${i}.data`,n))})}ye.extendErrors=Sx;function qh(e,t){let r=e.const("err",t);e.if((0,L._)`${$e.default.vErrors} === null`,()=>e.assign($e.default.vErrors,(0,L._)`[${r}]`),(0,L._)`${$e.default.vErrors}.push(${r})`),e.code((0,L._)`${$e.default.errors}++`)}function Fh(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,L._)`new ${e.ValidationError}(${t})`):(r.assign((0,L._)`${n}.errors`,t),r.return(!1))}var Gt={keyword:new L.Name("keyword"),schemaPath:new L.Name("schemaPath"),params:new L.Name("params"),propertyName:new L.Name("propertyName"),message:new L.Name("message"),schema:new L.Name("schema"),parentSchema:new L.Name("parentSchema")};function Lh(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,L._)`{}`:kx(e,t,r)}function kx(e,t,r={}){let{gen:n,it:o}=e,s=[zx(o,r),Px(e,r)];return Ex(e,t,s),n.object(...s)}function zx({errorPath:e},{instancePath:t}){let r=t?(0,L.str)`${e}${(0,Ds.getErrorPath)(t,Ds.Type.Str)}`:e;return[$e.default.instancePath,(0,L.strConcat)($e.default.instancePath,r)]}function Px({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,L.str)`${t}/${e}`;return r&&(o=(0,L.str)`${o}${(0,Ds.getErrorPath)(r,Ds.Type.Str)}`),[Gt.schemaPath,o]}function Ex(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Gt.keyword,o],[Gt.params,typeof t=="function"?t(e):t||(0,L._)`{}`]),c.messages&&n.push([Gt.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([Gt.schema,i],[Gt.parentSchema,(0,L._)`${l}${d}`],[$e.default.data,s]),u&&n.push([Gt.propertyName,u])}});var Vh=x(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});Sr.boolOrEmptySchema=Sr.topBoolOrEmptySchema=void 0;var Ix=An(),Tx=j(),Ox=gt(),Rx={message:"boolean schema is false"};function Ax(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Uh(e,!1):typeof r=="object"&&r.$async===!0?t.return(Ox.default.data):(t.assign((0,Tx._)`${n}.errors`,null),t.return(!0))}Sr.topBoolOrEmptySchema=Ax;function Cx(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Uh(e)):r.var(t,!0)}Sr.boolOrEmptySchema=Cx;function Uh(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,Ix.reportError)(o,Rx,void 0,t)}});var wc=x(kr=>{"use strict";Object.defineProperty(kr,"__esModule",{value:!0});kr.getRules=kr.isJSONType=void 0;var Nx=["string","number","integer","boolean","null","object","array"],jx=new Set(Nx);function Dx(e){return typeof e=="string"&&jx.has(e)}kr.isJSONType=Dx;function Zx(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}kr.getRules=Zx});var bc=x(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.shouldUseRule=Tt.shouldUseGroup=Tt.schemaHasRulesForType=void 0;function Mx({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&Hh(e,n)}Tt.schemaHasRulesForType=Mx;function Hh(e,t){return t.rules.some(r=>Bh(e,r))}Tt.shouldUseGroup=Hh;function Bh(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Tt.shouldUseRule=Bh});var Cn=x(_e=>{"use strict";Object.defineProperty(_e,"__esModule",{value:!0});_e.reportTypeError=_e.checkDataTypes=_e.checkDataType=_e.coerceAndCheckDataType=_e.getJSONTypes=_e.getSchemaTypes=_e.DataType=void 0;var qx=wc(),Fx=bc(),Lx=An(),C=j(),Jh=F(),zr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(zr||(_e.DataType=zr={}));function Ux(e){let t=Kh(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}_e.getSchemaTypes=Ux;function Kh(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(qx.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}_e.getJSONTypes=Kh;function Vx(e,t){let{gen:r,data:n,opts:o}=e,s=Hx(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,Fx.schemaHasRulesForType)(e,t[0]));if(i){let a=$c(t,n,o.strictNumbers,zr.Wrong);r.if(a,()=>{s.length?Bx(e,t,s):xc(e)})}return i}_e.coerceAndCheckDataType=Vx;var Gh=new Set(["string","number","integer","boolean","null"]);function Hx(e,t){return t?e.filter(r=>Gh.has(r)||t==="array"&&r==="array"):[]}function Bx(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,C._)`typeof ${o}`),a=n.let("coerced",(0,C._)`undefined`);s.coerceTypes==="array"&&n.if((0,C._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,C._)`${o}[0]`).assign(i,(0,C._)`typeof ${o}`).if($c(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,C._)`${a} !== undefined`);for(let u of r)(Gh.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),xc(e),n.endIf(),n.if((0,C._)`${a} !== undefined`,()=>{n.assign(o,a),Jx(e,a)});function c(u){switch(u){case"string":n.elseIf((0,C._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,C._)`"" + ${o}`).elseIf((0,C._)`${o} === null`).assign(a,(0,C._)`""`);return;case"number":n.elseIf((0,C._)`${i} == "boolean" || ${o} === null
|
|
5
|
-
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,
|
|
6
|
-
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,
|
|
7
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,C._)`[${o}]`)}}}function Jx({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,C._)`${t} !== undefined`,()=>e.assign((0,C._)`${t}[${r}]`,n))}function vc(e,t,r,n=zr.Correct){let o=n===zr.Correct?C.operators.EQ:C.operators.NEQ,s;switch(e){case"null":return(0,C._)`${t} ${o} null`;case"array":s=(0,C._)`Array.isArray(${t})`;break;case"object":s=(0,C._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,C._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,C._)`typeof ${t} ${o} ${e}`}return n===zr.Correct?s:(0,C.not)(s);function i(a=C.nil){return(0,C.and)((0,C._)`typeof ${t} == "number"`,a,r?(0,C._)`isFinite(${t})`:C.nil)}}_e.checkDataType=vc;function $c(e,t,r,n){if(e.length===1)return vc(e[0],t,r,n);let o,s=(0,Jh.toHash)(e);if(s.array&&s.object){let i=(0,C._)`typeof ${t} != "object"`;o=s.null?i:(0,C._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=C.nil;s.number&&delete s.integer;for(let i in s)o=(0,C.and)(o,vc(i,t,r,n));return o}_e.checkDataTypes=$c;var Kx={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,C._)`{type: ${e}}`:(0,C._)`{type: ${t}}`};function xc(e){let t=Gx(e);(0,Lx.reportError)(t,Kx)}_e.reportTypeError=xc;function Gx(e){let{gen:t,data:r,schema:n}=e,o=(0,Jh.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Yh=x(Zs=>{"use strict";Object.defineProperty(Zs,"__esModule",{value:!0});Zs.assignDefaults=void 0;var Pr=j(),Wx=F();function Yx(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Wh(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Wh(e,s,o.default))}Zs.assignDefaults=Yx;function Wh(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Pr._)`${s}${(0,Pr.getProperty)(t)}`;if(o){(0,Wx.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Pr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Pr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Pr._)`${a} = ${(0,Pr.stringify)(r)}`)}});var Ue=x(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.validateUnion=B.validateArray=B.usePattern=B.callValidateCode=B.schemaProperties=B.allSchemaProperties=B.noPropertyInData=B.propertyInData=B.isOwnProperty=B.hasPropFunc=B.reportMissingProp=B.checkMissingProp=B.checkReportMissingProp=void 0;var X=j(),Sc=F(),Ot=gt(),Xx=F();function Qx(e,t){let{gen:r,data:n,it:o}=e;r.if(zc(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,X._)`${t}`},!0),e.error()})}B.checkReportMissingProp=Qx;function eS({gen:e,data:t,it:{opts:r}},n,o){return(0,X.or)(...n.map(s=>(0,X.and)(zc(e,t,s,r.ownProperties),(0,X._)`${o} = ${s}`)))}B.checkMissingProp=eS;function tS(e,t){e.setParams({missingProperty:t},!0),e.error()}B.reportMissingProp=tS;function Xh(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,X._)`Object.prototype.hasOwnProperty`})}B.hasPropFunc=Xh;function kc(e,t,r){return(0,X._)`${Xh(e)}.call(${t}, ${r})`}B.isOwnProperty=kc;function rS(e,t,r,n){let o=(0,X._)`${t}${(0,X.getProperty)(r)} !== undefined`;return n?(0,X._)`${o} && ${kc(e,t,r)}`:o}B.propertyInData=rS;function zc(e,t,r,n){let o=(0,X._)`${t}${(0,X.getProperty)(r)} === undefined`;return n?(0,X.or)(o,(0,X.not)(kc(e,t,r))):o}B.noPropertyInData=zc;function Qh(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}B.allSchemaProperties=Qh;function nS(e,t){return Qh(t).filter(r=>!(0,Sc.alwaysValidSchema)(e,t[r]))}B.schemaProperties=nS;function oS({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,X._)`${e}, ${t}, ${n}${o}`:t,d=[[Ot.default.instancePath,(0,X.strConcat)(Ot.default.instancePath,s)],[Ot.default.parentData,i.parentData],[Ot.default.parentDataProperty,i.parentDataProperty],[Ot.default.rootData,Ot.default.rootData]];i.opts.dynamicRef&&d.push([Ot.default.dynamicAnchors,Ot.default.dynamicAnchors]);let f=(0,X._)`${l}, ${r.object(...d)}`;return c!==X.nil?(0,X._)`${a}.call(${c}, ${f})`:(0,X._)`${a}(${f})`}B.callValidateCode=oS;var sS=(0,X._)`new RegExp`;function iS({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,X._)`${o.code==="new RegExp"?sS:(0,Xx.useFunc)(e,o)}(${r}, ${n})`})}B.usePattern=iS;function aS(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,X._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:Sc.Type.Num},s),t.if((0,X.not)(s),a)})}}B.validateArray=aS;function cS(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Sc.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,X._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,X.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}B.validateUnion=cS});var rg=x(rt=>{"use strict";Object.defineProperty(rt,"__esModule",{value:!0});rt.validateKeywordUsage=rt.validSchemaType=rt.funcKeywordCode=rt.macroKeywordCode=void 0;var xe=j(),Wt=gt(),uS=Ue(),lS=An();function dS(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=tg(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:xe.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}rt.macroKeywordCode=dS;function fS(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;mS(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=tg(n,o,u),d=n.let("valid");e.block$data(d,f),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function f(){if(t.errors===!1)h(),t.modifying&&eg(e),g(()=>e.error());else{let w=t.async?p():m();t.modifying&&eg(e),g(()=>pS(e,w))}}function p(){let w=n.let("ruleErrs",null);return n.try(()=>h((0,xe._)`await `),v=>n.assign(d,!1).if((0,xe._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(w,(0,xe._)`${v}.errors`),()=>n.throw(v))),w}function m(){let w=(0,xe._)`${l}.errors`;return n.assign(w,null),h(xe.nil),w}function h(w=t.async?(0,xe._)`await `:xe.nil){let v=c.opts.passContext?Wt.default.this:Wt.default.self,$=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,xe._)`${w}${(0,uS.callValidateCode)(e,l,v,$)}`,t.modifying)}function g(w){var v;n.if((0,xe.not)((v=t.valid)!==null&&v!==void 0?v:d),w)}}rt.funcKeywordCode=fS;function eg(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,xe._)`${n.parentData}[${n.parentDataProperty}]`))}function pS(e,t){let{gen:r}=e;r.if((0,xe._)`Array.isArray(${t})`,()=>{r.assign(Wt.default.vErrors,(0,xe._)`${Wt.default.vErrors} === null ? ${t} : ${Wt.default.vErrors}.concat(${t})`).assign(Wt.default.errors,(0,xe._)`${Wt.default.vErrors}.length`),(0,lS.extendErrors)(e)},()=>e.error())}function mS({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function tg(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,xe.stringify)(r)})}function hS(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}rt.validSchemaType=hS;function gS({schema:e,opts:t,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(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}rt.validateKeywordUsage=gS});var og=x(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.extendSubschemaMode=Rt.extendSubschemaData=Rt.getSubschema=void 0;var nt=j(),ng=F();function yS(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,nt._)`${e.schemaPath}${(0,nt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,nt._)`${e.schemaPath}${(0,nt.getProperty)(t)}${(0,nt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,ng.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')}Rt.getSubschema=yS;function _S(e,t,{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}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,f=a.let("data",(0,nt._)`${t.data}${(0,nt.getProperty)(r)}`,!0);c(f),e.errorPath=(0,nt.str)`${u}${(0,ng.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,nt._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof nt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Rt.extendSubschemaData=_S;function wS(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Rt.extendSubschemaMode=wS});var Pc=x((yj,sg)=>{"use strict";sg.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),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(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var ag=x((_j,ig)=>{"use strict";var At=ig.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Ms(t,n,o,e,"",e)};At.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};At.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};At.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};At.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 Ms(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in At.arrayKeywords)for(var f=0;f<d.length;f++)Ms(e,t,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in At.propsKeywords){if(d&&typeof d=="object")for(var p in d)Ms(e,t,r,d[p],o+"/"+l+"/"+bS(p),s,o,l,n,p)}else(l in At.keywords||e.allKeys&&!(l in At.skipKeywords))&&Ms(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function bS(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Nn=x(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.getSchemaRefs=Ie.resolveUrl=Ie.normalizeId=Ie._getFullPath=Ie.getFullPath=Ie.inlineRef=void 0;var vS=F(),$S=Pc(),xS=ag(),SS=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function kS(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Ec(e):t?cg(e)<=t:!1}Ie.inlineRef=kS;var zS=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Ec(e){for(let t in e){if(zS.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Ec)||typeof r=="object"&&Ec(r))return!0}return!1}function cg(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!SS.has(r)&&(typeof e[r]=="object"&&(0,vS.eachItem)(e[r],n=>t+=cg(n)),t===1/0))return 1/0}return t}function ug(e,t="",r){r!==!1&&(t=Er(t));let n=e.parse(t);return lg(e,n)}Ie.getFullPath=ug;function lg(e,t){return e.serialize(t).split("#")[0]+"#"}Ie._getFullPath=lg;var PS=/#\/?$/;function Er(e){return e?e.replace(PS,""):""}Ie.normalizeId=Er;function ES(e,t,r){return r=Er(r),e.resolve(t,r)}Ie.resolveUrl=ES;var IS=/^[a-z_][-a-z0-9._]*$/i;function TS(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Er(e[r]||t),s={"":o},i=ug(n,o,!1),a={},c=new Set;return xS(e,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=i+f,g=s[m];typeof d[r]=="string"&&(g=w.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),s[f]=g;function w($){let O=this.opts.uriResolver.resolve;if($=Er(g?O(g,$):$),c.has($))throw l($);c.add($);let k=this.refs[$];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?u(d,k.schema,$):$!==Er(h)&&($[0]==="#"?(u(d,a[$],$),a[$]=d):this.refs[$]=h),$}function v($){if(typeof $=="string"){if(!IS.test($))throw new Error(`invalid anchor "${$}"`);w.call(this,`#${$}`)}}}),a;function u(d,f,p){if(f!==void 0&&!$S(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ie.getSchemaRefs=TS});var Zn=x(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:!0});Ct.getData=Ct.KeywordCxt=Ct.validateFunctionCode=void 0;var hg=Vh(),dg=Cn(),Tc=bc(),qs=Cn(),OS=Yh(),Dn=rg(),Ic=og(),P=j(),R=gt(),RS=Nn(),yt=F(),jn=An();function AS(e){if(_g(e)&&(wg(e),yg(e))){jS(e);return}gg(e,()=>(0,hg.topBoolOrEmptySchema)(e))}Ct.validateFunctionCode=AS;function gg({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,P._)`${R.default.data}, ${R.default.valCxt}`,n.$async,()=>{e.code((0,P._)`"use strict"; ${fg(r,o)}`),NS(e,o),e.code(s)}):e.func(t,(0,P._)`${R.default.data}, ${CS(o)}`,n.$async,()=>e.code(fg(r,o)).code(s))}function CS(e){return(0,P._)`{${R.default.instancePath}="", ${R.default.parentData}, ${R.default.parentDataProperty}, ${R.default.rootData}=${R.default.data}${e.dynamicRef?(0,P._)`, ${R.default.dynamicAnchors}={}`:P.nil}}={}`}function NS(e,t){e.if(R.default.valCxt,()=>{e.var(R.default.instancePath,(0,P._)`${R.default.valCxt}.${R.default.instancePath}`),e.var(R.default.parentData,(0,P._)`${R.default.valCxt}.${R.default.parentData}`),e.var(R.default.parentDataProperty,(0,P._)`${R.default.valCxt}.${R.default.parentDataProperty}`),e.var(R.default.rootData,(0,P._)`${R.default.valCxt}.${R.default.rootData}`),t.dynamicRef&&e.var(R.default.dynamicAnchors,(0,P._)`${R.default.valCxt}.${R.default.dynamicAnchors}`)},()=>{e.var(R.default.instancePath,(0,P._)`""`),e.var(R.default.parentData,(0,P._)`undefined`),e.var(R.default.parentDataProperty,(0,P._)`undefined`),e.var(R.default.rootData,R.default.data),t.dynamicRef&&e.var(R.default.dynamicAnchors,(0,P._)`{}`)})}function jS(e){let{schema:t,opts:r,gen:n}=e;gg(e,()=>{r.$comment&&t.$comment&&vg(e),FS(e),n.let(R.default.vErrors,null),n.let(R.default.errors,0),r.unevaluated&&DS(e),bg(e),VS(e)})}function DS(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,P._)`${r}.evaluated`),t.if((0,P._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,P._)`${e.evaluated}.props`,(0,P._)`undefined`)),t.if((0,P._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,P._)`${e.evaluated}.items`,(0,P._)`undefined`))}function fg(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,P._)`/*# sourceURL=${r} */`:P.nil}function ZS(e,t){if(_g(e)&&(wg(e),yg(e))){MS(e,t);return}(0,hg.boolOrEmptySchema)(e,t)}function yg({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function _g(e){return typeof e.schema!="boolean"}function MS(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&vg(e),LS(e),US(e);let s=n.const("_errs",R.default.errors);bg(e,s),n.var(t,(0,P._)`${s} === ${R.default.errors}`)}function wg(e){(0,yt.checkUnknownRules)(e),qS(e)}function bg(e,t){if(e.opts.jtd)return pg(e,[],!1,t);let r=(0,dg.getSchemaTypes)(e.schema),n=(0,dg.coerceAndCheckDataType)(e,r);pg(e,r,!n,t)}function qS(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,yt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function FS(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,yt.checkStrictMode)(e,"default is ignored in the schema root")}function LS(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,RS.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function US(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function vg({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,P._)`${R.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,P.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,P._)`${R.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function VS(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,P._)`${R.default.errors} === 0`,()=>t.return(R.default.data),()=>t.throw((0,P._)`new ${o}(${R.default.vErrors})`)):(t.assign((0,P._)`${n}.errors`,R.default.vErrors),s.unevaluated&&HS(e),t.return((0,P._)`${R.default.errors} === 0`))}function HS({gen:e,evaluated:t,props:r,items:n}){r instanceof P.Name&&e.assign((0,P._)`${t}.props`,r),n instanceof P.Name&&e.assign((0,P._)`${t}.items`,n)}function pg(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,yt.schemaHasRulesButRef)(s,l))){o.block(()=>xg(e,"$ref",l.all.$ref.definition));return}c.jtd||BS(e,t),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,Tc.shouldUseGroup)(s,f)&&(f.type?(o.if((0,qs.checkDataType)(f.type,i,c.strictNumbers)),mg(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,qs.reportTypeError)(e)),o.endIf()):mg(e,f),a||o.if((0,P._)`${R.default.errors} === ${n||0}`))}}function mg(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,OS.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,Tc.shouldUseRule)(n,s)&&xg(e,s.keyword,s.definition,t.type)})}function BS(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(JS(e,t),e.opts.allowUnionTypes||KS(e,t),GS(e,e.dataTypes))}function JS(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{$g(e.dataTypes,r)||Oc(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),YS(e,t)}}function KS(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Oc(e,"use allowUnionTypes to allow union type keyword")}function GS(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Tc.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>WS(t,i))&&Oc(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function WS(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function $g(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function YS(e,t){let r=[];for(let n of e.dataTypes)$g(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Oc(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,yt.checkStrictMode)(e,t,e.opts.strictTypes)}var Fs=class{constructor(t,r,n){if((0,Dn.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,yt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Sg(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Dn.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=t.gen.const("_errs",R.default.errors))}result(t,r,n){this.failResult((0,P.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,P.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,P._)`${r} !== undefined && (${(0,P.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?jn.reportExtraError:jn.reportError)(this,this.def.error,r)}$dataError(){(0,jn.reportError)(this,this.def.$dataError||jn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,jn.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=P.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=P.nil,r=P.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,P.or)((0,P._)`${o} === undefined`,r)),t!==P.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==P.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,P.or)(i(),a());function i(){if(n.length){if(!(r instanceof P.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,P._)`${(0,qs.checkDataTypes)(c,r,s.opts.strictNumbers,qs.DataType.Wrong)}`}return P.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,P._)`!${c}(${r})`}return P.nil}}subschema(t,r){let n=(0,Ic.getSubschema)(this.it,t);(0,Ic.extendSubschemaData)(n,this.it,t),(0,Ic.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return ZS(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=yt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=yt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,P.Name)),!0}};Ct.KeywordCxt=Fs;function xg(e,t,r,n){let o=new Fs(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Dn.funcKeywordCode)(o,r):"macro"in r?(0,Dn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Dn.funcKeywordCode)(o,r)}var XS=/^\/(?:[^~]|~0|~1)*$/,QS=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Sg(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return R.default.rootData;if(e[0]==="/"){if(!XS.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=R.default.rootData}else{let u=QS.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,P._)`${s}${(0,P.getProperty)((0,yt.unescapeJsonPointer)(u))}`,i=(0,P._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Ct.getData=Sg});var Ls=x(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var Rc=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Ac.default=Rc});var Mn=x(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});var Cc=Nn(),Nc=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Cc.resolveUrl)(t,r,n),this.missingSchema=(0,Cc.normalizeId)((0,Cc.getFullPath)(t,this.missingRef))}};jc.default=Nc});var Vs=x(Ve=>{"use strict";Object.defineProperty(Ve,"__esModule",{value:!0});Ve.resolveSchema=Ve.getCompilingSchema=Ve.resolveRef=Ve.compileSchema=Ve.SchemaEnv=void 0;var Xe=j(),ek=Ls(),Yt=gt(),Qe=Nn(),kg=F(),tk=Zn(),Ir=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,Qe.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};Ve.SchemaEnv=Ir;function Zc(e){let t=zg.call(this,e);if(t)return t;let r=(0,Qe.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new Xe.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:ek.default,code:(0,Xe._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Yt.default.data,parentData:Yt.default.parentData,parentDataProperty:Yt.default.parentDataProperty,dataNames:[Yt.default.data],dataPathArr:[Xe.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,Xe.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:Xe.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Xe._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,tk.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(Yt.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let p=new Function(`${Yt.default.self}`,`${Yt.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=u;p.evaluated={props:m instanceof Xe.Name?void 0:m,items:h instanceof Xe.Name?void 0:h,dynamicProps:m instanceof Xe.Name,dynamicItems:h instanceof Xe.Name},p.source&&(p.source.evaluated=(0,Xe.stringify)(p.evaluated))}return e.validate=p,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}Ve.compileSchema=Zc;function rk(e,t,r){var n;r=(0,Qe.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=sk.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Ir({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=nk.call(this,s)}Ve.resolveRef=rk;function nk(e){return(0,Qe.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Zc.call(this,e)}function zg(e){for(let t of this._compilations)if(ok(t,e))return t}Ve.getCompilingSchema=zg;function ok(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function sk(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Us.call(this,e,t)}function Us(e,t){let r=this.opts.uriResolver.parse(t),n=(0,Qe._getFullPath)(this.opts.uriResolver,r),o=(0,Qe.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Dc.call(this,r,e);let s=(0,Qe.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Us.call(this,e,i);return typeof a?.schema!="object"?void 0:Dc.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Zc.call(this,i),s===(0,Qe.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Qe.resolveUrl)(this.opts.uriResolver,o,u)),new Ir({schema:a,schemaId:c,root:e,baseId:o})}return Dc.call(this,r,i)}}Ve.resolveSchema=Us;var ik=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Dc(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,kg.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!ik.has(a)&&u&&(t=(0,Qe.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,kg.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Qe.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Us.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Ir({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var Pg=x((Sj,ak)=>{ak.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 Vc=x((kj,Ng)=>{"use strict";var ck=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),qc=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),uk=RegExp.prototype.test.bind(/^\d*$/u),Xt=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Fc=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Ig=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Lc=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),lk=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Te=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Te[t]="%"+e[t>>4]+e[t&15]}function we(e){return e<2048?Te[192|e>>6]+Te[128|e&63]:e<65536?Te[224|e>>12]+Te[128|e>>6&63]+Te[128|e&63]:Te[240|e>>18]+Te[128|e>>12&63]+Te[128|e>>6&63]+Te[128|e&63]}function dk(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var fk=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),pk=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),mk=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),hk=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function gk(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!mk(e[t])){if(e[t]==="%"&&t+2<e.length&&Xt(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function Eg(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function yk(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-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||t!==-1&&n.length===0||!qc(c))return;s+=2;continue}if(!fk(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:Eg(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 Eg(i)}function Mc(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&pk(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(_k(n,":")<2)return{host:e,isIPV6:!1,error:t};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),!gk(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=yk(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function _k(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function Tg(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}function wk(e){if(e===""||e[0]==="/")return Tg(e);let t=e.split("/"),r=t.length-1,n=[],o=!1;for(let s=0;s<=r;s++){let i=t[s];i==="."||i===".."?(i===".."&&(n.length!==0&&n[n.length-1]!==".."?n.pop():n.push("..")),o=s===r):n.push(i)}return o&&n[n.length-1]!==".."&&n.push(""),(n.length===0||n[0]===""||n[0].includes(":"))&&n.unshift("."),n.join("/")}var bk={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},vk=/[@/?#:]/g,$k=/[@/?#]/g;function Og(e,t){let r=t?$k:vk;return r.lastIndex=0,e.replace(r,n=>bk[n])}function Rg(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(Xt(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&Fc(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function xk(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(Xt(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&Fc(i)?t+=i:t+="%"+s,r+=2;continue}}if(Ig(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Cg(o)?n:Te[o];else if(o<55296||o>57343)t+=we(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=we(65536+(o-55296<<10)+(s-56320)),r++):t+=we(65533)}else t+=we(65533)}}return t}function Sk(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(Xt(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),Ig(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Te[i];else if(i<55296||i>57343)r+=we(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=we(65536+(i-55296<<10)+(a-56320)),o++):r+=we(65533)}else r+=we(65533)}}return r}function Uc(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(Xt(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Te[s];else if(s<55296||s>57343)r+=we(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=we(65536+(s-55296<<10)+(i-56320)),n++):r+=we(65533)}else r+=we(65533)}}return r}function Ag(e){return Uc(e,lk)}function kk(e){return Uc(e,Lc)}function zk(e){return Uc(e,Lc)}function Cg(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function Pk(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(Xt(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));Fc(i)?t+=i:t+="%"+s,r+=2;continue}}if(Lc(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Cg(o)?n:Te[o];else if(o<55296||o>57343)t+=we(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=we(65536+(o-55296<<10)+(s-56320)),r++):t+=we(65533)}else t+=we(65533)}}return t}function Ek(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(Xt(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function Ik(e){let t=[];if(e.userinfo!==void 0&&(t.push(Ag(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!qc(r)){let n=Mc(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=Rg(r,!0),n=Mc(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=Og(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!uk(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}Ng.exports={nonSimpleDomain:hk,recomposeAuthority:Ik,reescapeHostDelimiters:Og,normalizePercentEncoding:Rg,normalizePathEncoding:xk,serializePathEncoding:Sk,normalizeQueryFragmentEncoding:Pk,encodeUserinfo:Ag,encodeQuery:kk,encodeFragment:zk,escapePreservingEscapes:Ek,removeDotSegments:Tg,removeDotSegmentsRelative:wk,isIPv4:qc,isUUID:ck,normalizeIPv6:Mc,stringArrayToHexStripped:dk}});var qg=x((zj,Mg)=>{"use strict";var{isUUID:Tk}=Vc(),Ok=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,Rk=["http","https","ws","wss","urn","urn:uuid"];function Ak(e){return Rk.indexOf(e)!==-1}function Hc(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function jg(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Dg(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function Ck(e){return e.secure=Hc(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function Nk(e){if((e.port===(Hc(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function jk(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(Ok);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=Bc(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function Dk(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=Bc(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function Zk(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!Tk(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Mk(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Zg={scheme:"http",domainHost:!0,parse:jg,serialize:Dg},qk={scheme:"https",domainHost:Zg.domainHost,parse:jg,serialize:Dg},Hs={scheme:"ws",domainHost:!0,parse:Ck,serialize:Nk},Fk={scheme:"wss",domainHost:Hs.domainHost,parse:Hs.parse,serialize:Hs.serialize},Lk={scheme:"urn",parse:jk,serialize:Dk,skipNormalize:!0},Uk={scheme:"urn:uuid",parse:Zk,serialize:Mk,skipNormalize:!0},Bs={http:Zg,https:qk,ws:Hs,wss:Fk,urn:Lk,"urn:uuid":Uk};Object.setPrototypeOf(Bs,null);function Bc(e){return e&&(Bs[e]||Bs[e.toLowerCase()])||void 0}Mg.exports={wsIsSecure:Hc,SCHEMES:Bs,isValidSchemeName:Ak,getSchemeHandler:Bc}});var ty=x((Pj,Ys)=>{"use strict";var{normalizeIPv6:Hg,removeDotSegments:Fn,removeDotSegmentsRelative:Bg,recomposeAuthority:Vk,normalizePercentEncoding:Jc,normalizePathEncoding:Hk,serializePathEncoding:Fg,normalizeQueryFragmentEncoding:Lg,encodeQuery:Bk,encodeFragment:Jk,reescapeHostDelimiters:Kk,isIPv4:Jg,nonSimpleDomain:Gk}=Vc(),{SCHEMES:Kg,getSchemeHandler:Kc}=qg(),Gg=/^[A-Za-z][A-Za-z0-9+.-]*$/u,Wg="URI scheme is malformed.",Js="URI host is malformed.",Wk=/[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;function Ug(e){let t=String(e);if(!Gg.test(t))throw new TypeError(Wg);return t}function Yk(e,t){return typeof e=="string"?e=iz(e,t):typeof e=="object"&&(e=Gs(Qt(e,t),t)),e}function Xk(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=Ks(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:f,malformedSchemeSpecific:p,malformedHost:m,malformedScheme:h}=Ks(t,n);if(s||d||i||f||a||p||c||m||u||h)throw new Error(o.error||l.error||"URI is malformed.");let g=Yg(o,l,n,!0),w=Kc(r&&r.scheme||g.scheme),v=g.host,$=v!==void 0&&v!==""&&(Jg(v)||Hg(v).isIPV6);if(Qg(g,r||{},w,$))throw new Error(Js);Xg(g,r||{},w,$);let O=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(g.error&&!O)throw new Error(g.error);return n.skipEscape=!0,Qt(g,n)}function Yg(e,t,r,n){let o={};if(n||(e=Gs(Qt(e,r),r),t=Gs(Qt(t,r),r)),r=r||{},!r.tolerant&&t.scheme)o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=Fn(t.path||""),o.query=t.query;else{if(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=Fn(t.path||""),o.query=t.query;else{if(!t.path)o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query;else{if(t.path[0]==="/")o.path=Fn(t.path);else{let s=e.userinfo!==void 0||e.host!==void 0||e.port!==void 0;s&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=e.scheme===void 0&&!s&&o.path[0]!=="/"?Bg(o.path):Fn(o.path)}o.query=t.query}o.userinfo=e.userinfo,o.host=e.host,o.port=e.port}o.scheme=e.scheme}return o.fragment=t.fragment,o}function Qk(e,t,r){let n=Vg(e,r),o=Vg(t,r);return n!==void 0&&o!==void 0&&n===o}function Qt(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=Ug(r.scheme));let s=Kc(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=(r.scheme===void 0||n.reference==="suffix")&&!i,c=!n.skipEscape&&a;r.path!==void 0&&(n.skipEscape?r.path=Jc(r.path):r.path=Fg(r.path,c)),n.reference!=="suffix"&&r.scheme&&(r.scheme=Ug(r.scheme),o.push(r.scheme,":"));let u=Vk(r);if(u!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(u),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let l=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(l=a&&l[0]!=="/"?Bg(l):Fn(l)),a&&(l=Fg(l,!0)),u===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),o.push(l)}return r.query!==void 0&&o.push("?",Bk(r.query)),r.fragment!==void 0&&o.push("#",Jk(r.fragment)),o.join("")}var ez=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,tz=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,rz=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function nz(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function qn(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function Ws(e){return e[0]==="["&&e[e.length-1]==="]"}function oz(e){let t=e[4];return qn(e[3])||t!==void 0&&!Ws(t)&&qn(t)||qn(e[6])||qn(e[7])||qn(e[8])}function Xg(e,t,r,n){if(Qg(e,t,r,n))return e.error=e.error||Js,!0;if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!Ws(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&Gk(e.host)){let o;try{o=new URL("http://"+e.host)}catch(s){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+s,!0}if(!sz(o))return e.error=e.error||Js,!0;e.host=o.hostname}return!1}function Qg(e,t,r,n){return!!(e.host&&n===!1&&!Ws(e.host)&&(t.domainHost||r&&r.domainHost)&&Wk.test(e.host))}function sz(e){return e.username===""&&e.password===""&&e.port===""&&e.pathname==="/"&&e.search===""&&e.hash===""&&e.hostname!==""}function Ks(e,t){let r=Object.assign({},t),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?e=r.scheme+":"+e:e="//"+e);let d=e.match(tz);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let f=e.match(rz);if(f!==null){let m=f[1],h=m.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):m.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let p=e.match(ez);if(p){n.scheme=p[1],n.userinfo=p[3],n.host=p[4],n.port=parseInt(p[5],10),n.path=p[6]||"",n.query=p[7],n.fragment=p[8],n.scheme!==void 0&&(Gg.test(n.scheme)?n.scheme=n.scheme.toLowerCase():(n.error=n.error||Wg,u=!0)),s=oz(p),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=p[5]);let m=nz(n,p);if(m!==void 0&&(n.error=n.error||m,o=!0),n.host)if(Jg(n.host)===!1){let w=Ws(n.host),v=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,$=Hg(n.host);l=$.isIPV6||$.isIPVFuture===!0,c=v&&(!w||$.error===!0),n.host=l?$.host:$.host.toLowerCase(),c&&(n.error=n.error||Js,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=Kc(r.scheme||n.scheme);if(c||(a=Xg(n,r,h,l)),e.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:Jc(n.host,!0);l||(g=Jc(g.toLowerCase())),n.host=l||r.scheme!=="null"?Kk(g,l):g}(!h||h&&!h.skipNormalize)&&(n.path&&(n.path=Hk(n.path)),n.query&&(n.query=Lg(n.query)),n.fragment&&(n.fragment=Lg(n.fragment))),h&&h.parse&&(h.parse(n,r),h===Kg.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 Gs(e,t){return Ks(e,t).parsed}function iz(e,t){return ey(e,t).normalized}function ey(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=Ks(e,t);return{normalized:n||o||s||i||a?e:Qt(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function Vg(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:Qt(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=ey(r,t);return o||s||i||a||c?void 0:n}var Gc={SCHEMES:Kg,normalize:Yk,resolve:Xk,resolveComponent:Yg,equal:Qk,serialize:Qt,parse:Gs};Ys.exports=Gc;Ys.exports.default=Gc;Ys.exports.fastUri=Gc});var ny=x(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});var ry=ty();ry.code='require("ajv/dist/runtime/uri").default';Wc.default=ry});var dy=x(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 az=Zn();Object.defineProperty(me,"KeywordCxt",{enumerable:!0,get:function(){return az.KeywordCxt}});var Tr=j();Object.defineProperty(me,"_",{enumerable:!0,get:function(){return Tr._}});Object.defineProperty(me,"str",{enumerable:!0,get:function(){return Tr.str}});Object.defineProperty(me,"stringify",{enumerable:!0,get:function(){return Tr.stringify}});Object.defineProperty(me,"nil",{enumerable:!0,get:function(){return Tr.nil}});Object.defineProperty(me,"Name",{enumerable:!0,get:function(){return Tr.Name}});Object.defineProperty(me,"CodeGen",{enumerable:!0,get:function(){return Tr.CodeGen}});var cz=Ls(),cy=Mn(),uz=wc(),Ln=Vs(),lz=j(),Un=Nn(),Xs=Cn(),Xc=F(),oy=Pg(),dz=ny(),uy=(e,t)=>new RegExp(e,t);uy.code="new RegExp";var fz=["removeAdditional","useDefaults","coerceTypes"],pz=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),mz={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."},hz={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},sy=200;function gz(e){var t,r,n,o,s,i,a,c,u,l,d,f,p,m,h,g,w,v,$,O,k,N,se,Dt,sr;let at=e.strict,ir=(t=e.code)===null||t===void 0?void 0:t.optimize,co=ir===!0||ir===void 0?1:ir||0,uo=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:uy,$w=(o=e.uriResolver)!==null&&o!==void 0?o:dz.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:at)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:at)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:at)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:at)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=e.strictRequired)!==null&&p!==void 0?p:at)!==null&&m!==void 0?m:!1,code:e.code?{...e.code,optimize:co,regExp:uo}:{optimize:co,regExp:uo},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:sy,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:sy,meta:(w=e.meta)!==null&&w!==void 0?w:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:($=e.inlineRefs)!==null&&$!==void 0?$:!0,schemaId:(O=e.schemaId)!==null&&O!==void 0?O:"$id",addUsedSchema:(k=e.addUsedSchema)!==null&&k!==void 0?k:!0,validateSchema:(N=e.validateSchema)!==null&&N!==void 0?N:!0,validateFormats:(se=e.validateFormats)!==null&&se!==void 0?se:!0,unicodeRegExp:(Dt=e.unicodeRegExp)!==null&&Dt!==void 0?Dt:!0,int32range:(sr=e.int32range)!==null&&sr!==void 0?sr:!0,uriResolver:$w}}var Vn=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...gz(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new lz.ValueScope({scope:{},prefixes:pz,es5:r,lines:n}),this.logger=$z(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,uz.getRules)(),iy.call(this,mz,t,"NOT SUPPORTED"),iy.call(this,hz,t,"DEPRECATED","warn"),this._metaOpts=bz.call(this),t.formats&&_z.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&wz.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),yz.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=oy;n==="id"&&(o={...oy},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,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,t,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 cy.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(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,Un.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$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,t);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(t){let r;for(;typeof(r=ay.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Ln.SchemaEnv({schema:{},schemaId:n});if(r=Ln.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=ay.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,Un.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,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(Sz.call(this,n,r),!r)return(0,Xc.eachItem)(n,s=>Yc.call(this,s)),this;zz.call(this,r);let o={...r,type:(0,Xs.getJSONTypes)(r.type),schemaType:(0,Xs.getJSONTypes)(r.schemaType)};return(0,Xc.eachItem)(n,o.type.length===0?s=>Yc.call(this,s,o):s=>o.type.forEach(i=>Yc.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;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]=ly(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,Un.normalizeId)(i||n);let u=Un.getSchemaRefs.call(this,t,n);return c=new Ln.SchemaEnv({schema:t,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(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):Ln.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{Ln.compileSchema.call(this,t)}finally{this.opts=r}}};Vn.ValidationError=cz.default;Vn.MissingRefError=cy.default;me.default=Vn;function iy(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function ay(e){return e=(0,Un.normalizeId)(e),this.schemas[e]||this.refs[e]}function yz(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function _z(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function wz(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function bz(){let e={...this.opts};for(let t of fz)delete e[t];return e}var vz={log(){},warn(){},error(){}};function $z(e){if(e===!1)return vz;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var xz=/^[a-z_$][a-z0-9_$:-]*$/i;function Sz(e,t){let{RULES:r}=this;if((0,Xc.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!xz.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function Yc(e,t,r){var n;let o=t?.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[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,Xs.getJSONTypes)(t.type),schemaType:(0,Xs.getJSONTypes)(t.schemaType)}};t.before?kz.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function kz(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function zz(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=ly(t)),e.validateSchema=this.compile(t,!0))}var Pz={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function ly(e){return{anyOf:[e,Pz]}}});var fy=x(Qc=>{"use strict";Object.defineProperty(Qc,"__esModule",{value:!0});var Ez={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Qc.default=Ez});var gy=x(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});er.callRef=er.getValidate=void 0;var Iz=Mn(),py=Ue(),Oe=j(),Or=gt(),my=Vs(),Qs=F(),Tz={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=my.resolveRef.call(c,u,o,r);if(l===void 0)throw new Iz.default(n.opts.uriResolver,o,r);if(l instanceof my.SchemaEnv)return f(l);return p(l);function d(){if(s===u)return ei(e,i,s,s.$async);let m=t.scopeValue("root",{ref:u});return ei(e,(0,Oe._)`${m}.validate`,u,u.$async)}function f(m){let h=hy(e,m);ei(e,h,m,m.$async)}function p(m){let h=t.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Oe.stringify)(m)}:{ref:m}),g=t.name("valid"),w=e.subschema({schema:m,dataTypes:[],schemaPath:Oe.nil,topSchemaRef:h,errSchemaPath:r},g);e.mergeEvaluated(w),e.ok(g)}}};function hy(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Oe._)`${r.scopeValue("wrapper",{ref:t})}.validate`}er.getValidate=hy;function ei(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Or.default.this:Oe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Oe._)`await ${(0,py.callValidateCode)(e,t,u)}`),p(t),i||o.assign(m,!0)},h=>{o.if((0,Oe._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),f(h),i||o.assign(m,!1)}),e.ok(m)}function d(){e.result((0,py.callValidateCode)(e,t,u),()=>p(t),()=>f(t))}function f(m){let h=(0,Oe._)`${m}.errors`;o.assign(Or.default.vErrors,(0,Oe._)`${Or.default.vErrors} === null ? ${h} : ${Or.default.vErrors}.concat(${h})`),o.assign(Or.default.errors,(0,Oe._)`${Or.default.vErrors}.length`)}function p(m){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=Qs.mergeEvaluated.props(o,g.props,s.props));else{let w=o.var("props",(0,Oe._)`${m}.evaluated.props`);s.props=Qs.mergeEvaluated.props(o,w,s.props,Oe.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=Qs.mergeEvaluated.items(o,g.items,s.items));else{let w=o.var("items",(0,Oe._)`${m}.evaluated.items`);s.items=Qs.mergeEvaluated.items(o,w,s.items,Oe.Name)}}}er.callRef=ei;er.default=Tz});var yy=x(eu=>{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});var Oz=fy(),Rz=gy(),Az=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Oz.default,Rz.default];eu.default=Az});var _y=x(tu=>{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});var ti=j(),Nt=ti.operators,ri={maximum:{okStr:"<=",ok:Nt.LTE,fail:Nt.GT},minimum:{okStr:">=",ok:Nt.GTE,fail:Nt.LT},exclusiveMaximum:{okStr:"<",ok:Nt.LT,fail:Nt.GTE},exclusiveMinimum:{okStr:">",ok:Nt.GT,fail:Nt.LTE}},Cz={message:({keyword:e,schemaCode:t})=>(0,ti.str)`must be ${ri[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ti._)`{comparison: ${ri[e].okStr}, limit: ${t}}`},Nz={keyword:Object.keys(ri),type:"number",schemaType:"number",$data:!0,error:Cz,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ti._)`${r} ${ri[t].fail} ${n} || isNaN(${r})`)}};tu.default=Nz});var wy=x(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});var Hn=j(),jz={message:({schemaCode:e})=>(0,Hn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,Hn._)`{multipleOf: ${e}}`},Dz={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:jz,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,Hn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Hn._)`${i} !== parseInt(${i})`;e.fail$data((0,Hn._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};ru.default=Dz});var vy=x(nu=>{"use strict";Object.defineProperty(nu,"__esModule",{value:!0});function by(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}nu.default=by;by.code='require("ajv/dist/runtime/ucs2length").default'});var $y=x(ou=>{"use strict";Object.defineProperty(ou,"__esModule",{value:!0});var tr=j(),Zz=F(),Mz=vy(),qz={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,tr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,tr._)`{limit: ${e}}`},Fz={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:qz,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?tr.operators.GT:tr.operators.LT,i=o.opts.unicode===!1?(0,tr._)`${r}.length`:(0,tr._)`${(0,Zz.useFunc)(e.gen,Mz.default)}(${r})`;e.fail$data((0,tr._)`${i} ${s} ${n}`)}};ou.default=Fz});var xy=x(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});var Lz=Ue(),Uz=F(),Rr=j(),Vz={message:({schemaCode:e})=>(0,Rr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Rr._)`{pattern: ${e}}`},Hz={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:Vz,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Rr._)`new RegExp`:(0,Uz.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Rr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Rr._)`!${l}`)}else{let c=(0,Lz.usePattern)(e,o);e.fail$data((0,Rr._)`!${c}.test(${r})`)}}};su.default=Hz});var Sy=x(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});var Bn=j(),Bz={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Bn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Bn._)`{limit: ${e}}`},Jz={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:Bz,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Bn.operators.GT:Bn.operators.LT;e.fail$data((0,Bn._)`Object.keys(${r}).length ${o} ${n}`)}};iu.default=Jz});var ky=x(au=>{"use strict";Object.defineProperty(au,"__esModule",{value:!0});var Jn=Ue(),Kn=j(),Kz=F(),Gz={message:({params:{missingProperty:e}})=>(0,Kn.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Kn._)`{missingProperty: ${e}}`},Wz={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Gz,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let p=e.parentSchema.properties,{definedProperties:m}=e.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,w=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,Kz.checkStrictMode)(i,w,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(Kn.nil,d);else for(let p of r)(0,Jn.checkReportMissingProp)(e,p)}function l(){let p=t.let("missing");if(c||s){let m=t.let("valid",!0);e.block$data(m,()=>f(p,m)),e.ok(m)}else t.if((0,Jn.checkMissingProp)(e,r,p)),(0,Jn.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",n,p=>{e.setParams({missingProperty:p}),t.if((0,Jn.noPropertyInData)(t,o,p,a.ownProperties),()=>e.error())})}function f(p,m){e.setParams({missingProperty:p}),t.forOf(p,n,()=>{t.assign(m,(0,Jn.propertyInData)(t,o,p,a.ownProperties)),t.if((0,Kn.not)(m),()=>{e.error(),t.break()})},Kn.nil)}}};au.default=Wz});var zy=x(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});var Gn=j(),Yz={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,Gn.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,Gn._)`{limit: ${e}}`},Xz={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:Yz,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?Gn.operators.GT:Gn.operators.LT;e.fail$data((0,Gn._)`${r}.length ${o} ${n}`)}};cu.default=Xz});var ni=x(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});var Py=Pc();Py.code='require("ajv/dist/runtime/equal").default';uu.default=Py});var Ey=x(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var lu=Cn(),he=j(),Qz=F(),eP=ni(),tP={message:({params:{i:e,j:t}})=>(0,he.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,he._)`{i: ${e}, j: ${t}}`},rP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:tP,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,lu.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,he._)`${i} === false`),e.ok(c);function l(){let m=t.let("i",(0,he._)`${r}.length`),h=t.let("j");e.setParams({i:m,j:h}),t.assign(c,!0),t.if((0,he._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function f(m,h){let g=t.name("item"),w=(0,lu.checkDataTypes)(u,g,a.opts.strictNumbers,lu.DataType.Wrong),v=t.const("indices",(0,he._)`{}`);t.for((0,he._)`;${m}--;`,()=>{t.let(g,(0,he._)`${r}[${m}]`),t.if(w,(0,he._)`continue`),u.length>1&&t.if((0,he._)`typeof ${g} == "string"`,(0,he._)`${g} += "_"`),t.if((0,he._)`typeof ${v}[${g}] == "number"`,()=>{t.assign(h,(0,he._)`${v}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,he._)`${v}[${g}] = ${m}`)})}function p(m,h){let g=(0,Qz.useFunc)(t,eP.default),w=t.name("outer");t.label(w).for((0,he._)`;${m}--;`,()=>t.for((0,he._)`${h} = ${m}; ${h}--;`,()=>t.if((0,he._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{e.error(),t.assign(c,!1).break(w)})))}}};du.default=rP});var Iy=x(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});var fu=j(),nP=F(),oP=ni(),sP={message:"must be equal to constant",params:({schemaCode:e})=>(0,fu._)`{allowedValue: ${e}}`},iP={keyword:"const",$data:!0,error:sP,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,fu._)`!${(0,nP.useFunc)(t,oP.default)}(${r}, ${o})`):e.fail((0,fu._)`${s} !== ${r}`)}};pu.default=iP});var Ty=x(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});var Wn=j(),aP=F(),cP=ni(),uP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,Wn._)`{allowedValues: ${e}}`},lP={keyword:"enum",schemaType:"array",$data:!0,error:uP,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;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,aP.useFunc)(t,cP.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let p=t.const("vSchema",s);l=(0,Wn.or)(...o.map((m,h)=>f(p,h)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,p=>t.if((0,Wn._)`${u()}(${r}, ${p})`,()=>t.assign(l,!0).break()))}function f(p,m){let h=o[m];return typeof h=="object"&&h!==null?(0,Wn._)`${u()}(${r}, ${p}[${m}])`:(0,Wn._)`${r} === ${h}`}}};mu.default=lP});var Oy=x(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});var dP=_y(),fP=wy(),pP=$y(),mP=xy(),hP=Sy(),gP=ky(),yP=zy(),_P=Ey(),wP=Iy(),bP=Ty(),vP=[dP.default,fP.default,pP.default,mP.default,hP.default,gP.default,yP.default,_P.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},wP.default,bP.default];hu.default=vP});var yu=x(Yn=>{"use strict";Object.defineProperty(Yn,"__esModule",{value:!0});Yn.validateAdditionalItems=void 0;var rr=j(),gu=F(),$P={message:({params:{len:e}})=>(0,rr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,rr._)`{limit: ${e}}`},xP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:$P,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,gu.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Ry(e,n)}};function Ry(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,rr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,rr._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,gu.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,rr._)`${a} <= ${t.length}`);r.if((0,rr.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:gu.Type.Num},u),i.allErrors||r.if((0,rr.not)(u),()=>r.break())})}}Yn.validateAdditionalItems=Ry;Yn.default=xP});var _u=x(Xn=>{"use strict";Object.defineProperty(Xn,"__esModule",{value:!0});Xn.validateTuple=void 0;var Ay=j(),oi=F(),SP=Ue(),kP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Cy(e,"additionalItems",t);r.items=!0,!(0,oi.alwaysValidSchema)(r,t)&&e.ok((0,SP.validateArray)(e))}};function Cy(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=oi.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Ay._)`${s}.length`);r.forEach((d,f)=>{(0,oi.alwaysValidSchema)(a,d)||(n.if((0,Ay._)`${u} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function l(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[t]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,oi.checkStrictMode)(a,g,f.strictTuples)}}}Xn.validateTuple=Cy;Xn.default=kP});var Ny=x(wu=>{"use strict";Object.defineProperty(wu,"__esModule",{value:!0});var zP=_u(),PP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,zP.validateTuple)(e,"items")};wu.default=PP});var Dy=x(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});var jy=j(),EP=F(),IP=Ue(),TP=yu(),OP={message:({params:{len:e}})=>(0,jy.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,jy._)`{limit: ${e}}`},RP={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:OP,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,EP.alwaysValidSchema)(n,t)&&(o?(0,TP.validateAdditionalItems)(e,o):e.ok((0,IP.validateArray)(e)))}};bu.default=RP});var Zy=x(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});var He=j(),si=F(),AP={message:({params:{min:e,max:t}})=>t===void 0?(0,He.str)`must contain at least ${e} valid item(s)`:(0,He.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,He._)`{minContains: ${e}}`:(0,He._)`{minContains: ${e}, maxContains: ${t}}`},CP={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:AP,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,He._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,si.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,si.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,si.alwaysValidSchema)(s,r)){let h=(0,He._)`${l} >= ${i}`;a!==void 0&&(h=(0,He._)`${h} && ${l} <= ${a}`),e.pass(h);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?p(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,He._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let h=t.name("_valid"),g=t.let("count",0);p(h,()=>t.if(h,()=>m(g)))}function p(h,g){t.forRange("i",0,l,w=>{e.subschema({keyword:"contains",dataProp:w,dataPropType:si.Type.Num,compositeRule:!0},h),g()})}function m(h){t.code((0,He._)`${h}++`),a===void 0?t.if((0,He._)`${h} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,He._)`${h} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,He._)`${h} >= ${i}`,()=>t.assign(d,!0)))}}};vu.default=CP});var Fy=x(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.validateSchemaDeps=ot.validatePropertyDeps=ot.error=void 0;var $u=j(),NP=F(),Qn=Ue();ot.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,$u.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,$u._)`{property: ${e},
|
|
3
|
+
var Yw=Object.create;var Ni=Object.defineProperty;var Xw=Object.getOwnPropertyDescriptor;var Qw=Object.getOwnPropertyNames;var eb=Object.getPrototypeOf,tb=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Sl=(e,t)=>{for(var r in t)Ni(e,r,{get:t[r],enumerable:!0})},rb=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Qw(t))!tb.call(e,o)&&o!==r&&Ni(e,o,{get:()=>t[o],enumerable:!(n=Xw(t,o))||n.enumerable});return e};var zl=(e,t,r)=>(r=e!=null?Yw(eb(e)):{},rb(t||!e||!e.__esModule?Ni(r,"default",{value:e,enumerable:!0}):r,e));var Zn=S(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.regexpCode=W.getEsmExportName=W.getProperty=W.safeStringify=W.stringify=W.strConcat=W.addCodeArg=W.str=W._=W.nil=W._Code=W.Name=W.IDENTIFIER=W._CodeOrName=void 0;var jn=class{};W._CodeOrName=jn;W.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var or=class extends jn{constructor(t){if(super(),!W.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};W.Name=or;var rt=class extends jn{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof or&&(r[n.str]=(r[n.str]||0)+1),r),{})}};W._Code=rt;W.nil=new rt("");function Vh(e,...t){let r=[e[0]],n=0;for(;n<t.length;)fc(r,t[n]),r.push(e[++n]);return new rt(r)}W._=Vh;var dc=new rt("+");function Bh(e,...t){let r=[Dn(e[0])],n=0;for(;n<t.length;)r.push(dc),fc(r,t[n]),r.push(dc,Dn(e[++n]));return xk(r),new rt(r)}W.str=Bh;function fc(e,t){t instanceof rt?e.push(...t._items):t instanceof or?e.push(t):e.push(Pk(t))}W.addCodeArg=fc;function xk(e){let t=1;for(;t<e.length-1;){if(e[t]===dc){let r=Sk(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function Sk(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof or||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof or))return`"${e}${t.slice(1)}`}function zk(e,t){return t.emptyStr()?e:e.emptyStr()?t:Bh`${e}${t}`}W.strConcat=zk;function Pk(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Dn(Array.isArray(e)?e.join(","):e)}function Ik(e){return new rt(Dn(e))}W.stringify=Ik;function Dn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}W.safeStringify=Dn;function Ek(e){return typeof e=="string"&&W.IDENTIFIER.test(e)?new rt(`.${e}`):Vh`[${e}]`}W.getProperty=Ek;function Tk(e){if(typeof e=="string"&&W.IDENTIFIER.test(e))return new rt(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}W.getEsmExportName=Tk;function Ok(e){return new rt(e.toString())}W.regexpCode=Ok});var hc=S(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.ValueScope=Le.ValueScopeName=Le.Scope=Le.varKinds=Le.UsedValueState=void 0;var Fe=Zn(),pc=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Fs;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Fs||(Le.UsedValueState=Fs={}));Le.varKinds={const:new Fe.Name("const"),let:new Fe.Name("let"),var:new Fe.Name("var")};var Ls=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Fe.Name?t:this.name(t)}name(t){return new Fe.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Le.Scope=Ls;var Us=class extends Fe.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Fe._)`.${new Fe.Name(r)}[${n}]`}};Le.ValueScopeName=Us;var Rk=(0,Fe._)`\n`,mc=class extends Ls{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?Rk:Fe.nil}}get(){return this._scope}name(t){return new Us(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{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(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Fe._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Fe.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Fs.Started);let l=r(u);if(l){let d=this.opts.es5?Le.varKinds.var:Le.varKinds.const;s=(0,Fe._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Fe._)`${s}${l}${this.opts._n}`;else throw new pc(u);c.set(u,Fs.Completed)})}return s}};Le.ValueScope=mc});var q=S(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.or=F.and=F.not=F.CodeGen=F.operators=F.varKinds=F.ValueScopeName=F.ValueScope=F.Scope=F.Name=F.regexpCode=F.stringify=F.getProperty=F.nil=F.strConcat=F.str=F._=void 0;var H=Zn(),lt=hc(),Ut=Zn();Object.defineProperty(F,"_",{enumerable:!0,get:function(){return Ut._}});Object.defineProperty(F,"str",{enumerable:!0,get:function(){return Ut.str}});Object.defineProperty(F,"strConcat",{enumerable:!0,get:function(){return Ut.strConcat}});Object.defineProperty(F,"nil",{enumerable:!0,get:function(){return Ut.nil}});Object.defineProperty(F,"getProperty",{enumerable:!0,get:function(){return Ut.getProperty}});Object.defineProperty(F,"stringify",{enumerable:!0,get:function(){return Ut.stringify}});Object.defineProperty(F,"regexpCode",{enumerable:!0,get:function(){return Ut.regexpCode}});Object.defineProperty(F,"Name",{enumerable:!0,get:function(){return Ut.Name}});var Ks=hc();Object.defineProperty(F,"Scope",{enumerable:!0,get:function(){return Ks.Scope}});Object.defineProperty(F,"ValueScope",{enumerable:!0,get:function(){return Ks.ValueScope}});Object.defineProperty(F,"ValueScopeName",{enumerable:!0,get:function(){return Ks.ValueScopeName}});Object.defineProperty(F,"varKinds",{enumerable:!0,get:function(){return Ks.varKinds}});F.operators={GT:new H._Code(">"),GTE:new H._Code(">="),LT:new H._Code("<"),LTE:new H._Code("<="),EQ:new H._Code("==="),NEQ:new H._Code("!=="),NOT:new H._Code("!"),OR:new H._Code("||"),AND:new H._Code("&&"),ADD:new H._Code("+")};var Pt=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},gc=class extends Pt{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?lt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=Ar(this.rhs,t,r)),this}get names(){return this.rhs instanceof H._CodeOrName?this.rhs.names:{}}},Vs=class extends Pt{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof H.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Ar(this.rhs,t,r),this}get names(){let t=this.lhs instanceof H.Name?{}:{...this.lhs.names};return Hs(t,this.rhs)}},yc=class extends Vs{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},_c=class extends Pt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},wc=class extends Pt{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},bc=class extends Pt{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},vc=class extends Pt{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=Ar(this.code,t,r),this}get names(){return this.code instanceof H._CodeOrName?this.code.names:{}}},Mn=class extends Pt{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(Ak(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>ar(t,r.names),{})}},It=class extends Mn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},$c=class extends Mn{},Rr=class extends It{};Rr.kind="else";var sr=class e extends It{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Rr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(Hh(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=Ar(this.condition,t,r),this}get names(){let t=super.names;return Hs(t,this.condition),this.else&&ar(t,this.else.names),t}};sr.kind="if";var ir=class extends It{};ir.kind="for";var kc=class extends ir{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=Ar(this.iteration,t,r),this}get names(){return ar(super.names,this.iteration.names)}},xc=class extends ir{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?lt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Hs(super.names,this.from);return Hs(t,this.to)}},Bs=class extends ir{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=Ar(this.iterable,t,r),this}get names(){return ar(super.names,this.iterable.names)}},qn=class extends It{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};qn.kind="func";var Fn=class extends Mn{render(t){return"return "+super.render(t)}};Fn.kind="return";var Sc=class extends It{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&ar(t,this.catch.names),this.finally&&ar(t,this.finally.names),t}},Ln=class extends It{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Ln.kind="catch";var Un=class extends It{render(t){return"finally"+super.render(t)}};Un.kind="finally";var zc=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
4
|
+
`:""},this._extScope=t,this._scope=new lt.Scope({parent:t}),this._nodes=[new $c]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new gc(t,s,n)),s}const(t,r,n){return this._def(lt.varKinds.const,t,r,n)}let(t,r,n){return this._def(lt.varKinds.let,t,r,n)}var(t,r,n){return this._def(lt.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Vs(t,r,n))}add(t,r){return this._leafNode(new yc(t,F.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==H.nil&&this._leafNode(new vc(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,H.addCodeArg)(r,o));return r.push("}"),new H._Code(r)}if(t,r,n){if(this._blockNode(new sr(t)),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(t){return this._elseNode(new sr(t))}else(){return this._elseNode(new Rr)}endIf(){return this._endBlockNode(sr,Rr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new kc(t),r)}forRange(t,r,n,o,s=this.opts.es5?lt.varKinds.var:lt.varKinds.let){let i=this._scope.toName(t);return this._for(new xc(s,i,r,n),()=>o(i))}forOf(t,r,n,o=lt.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof H.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,H._)`${i}.length`,a=>{this.var(s,(0,H._)`${i}[${a}]`),n(s)})}return this._for(new Bs("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?lt.varKinds.var:lt.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,H._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new Bs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(ir)}label(t){return this._leafNode(new _c(t))}break(t){return this._leafNode(new wc(t))}return(t){let r=new Fn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Fn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new Sc;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Ln(s),r(s)}return n&&(this._currNode=o.finally=new Un,this.code(n)),this._endBlockNode(Ln,Un)}throw(t){return this._leafNode(new bc(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){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||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=H.nil,n,o){return this._blockNode(new qn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(qn)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof sr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};F.CodeGen=zc;function ar(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Hs(e,t){return t instanceof H._CodeOrName?ar(e,t.names):e}function Ar(e,t,r){if(e instanceof H.Name)return n(e);if(!o(e))return e;return new H._Code(e._items.reduce((s,i)=>(i instanceof H.Name&&(i=n(i)),i instanceof H._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof H._Code&&s._items.some(i=>i instanceof H.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function Ak(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function Hh(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,H._)`!${Pc(e)}`}F.not=Hh;var Ck=Kh(F.operators.AND);function Nk(...e){return e.reduce(Ck)}F.and=Nk;var jk=Kh(F.operators.OR);function Dk(...e){return e.reduce(jk)}F.or=Dk;function Kh(e){return(t,r)=>t===H.nil?r:r===H.nil?t:(0,H._)`${Pc(t)} ${e} ${Pc(r)}`}function Pc(e){return e instanceof H.Name?e:(0,H._)`(${e})`}});var K=S(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.checkStrictMode=L.getErrorPath=L.Type=L.useFunc=L.setEvaluated=L.evaluatedPropsToName=L.mergeEvaluated=L.eachItem=L.unescapeJsonPointer=L.escapeJsonPointer=L.escapeFragment=L.unescapeFragment=L.schemaRefOrVal=L.schemaHasRulesButRef=L.schemaHasRules=L.checkUnknownRules=L.alwaysValidSchema=L.toHash=void 0;var Q=q(),Zk=Zn();function Mk(e){let t={};for(let r of e)t[r]=!0;return t}L.toHash=Mk;function qk(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Wh(e,t),!Yh(t,e.self.RULES.all))}L.alwaysValidSchema=qk;function Wh(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||eg(e,`unknown keyword: "${s}"`)}L.checkUnknownRules=Wh;function Yh(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}L.schemaHasRules=Yh;function Fk(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}L.schemaHasRulesButRef=Fk;function Lk({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Q._)`${r}`}return(0,Q._)`${e}${t}${(0,Q.getProperty)(n)}`}L.schemaRefOrVal=Lk;function Uk(e){return Xh(decodeURIComponent(e))}L.unescapeFragment=Uk;function Vk(e){return encodeURIComponent(Ec(e))}L.escapeFragment=Vk;function Ec(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}L.escapeJsonPointer=Ec;function Xh(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}L.unescapeJsonPointer=Xh;function Bk(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}L.eachItem=Bk;function Jh({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof Q.Name?(s instanceof Q.Name?e(o,s,i):t(o,s,i),i):s instanceof Q.Name?(t(o,i,s),s):r(s,i);return a===Q.Name&&!(c instanceof Q.Name)?n(o,c):c}}L.mergeEvaluated={props:Jh({mergeNames:(e,t,r)=>e.if((0,Q._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,Q._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,Q._)`${r} || {}`).code((0,Q._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,Q._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,Q._)`${r} || {}`),Tc(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Qh}),items:Jh({mergeNames:(e,t,r)=>e.if((0,Q._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,Q._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,Q._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,Q._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Qh(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,Q._)`{}`);return t!==void 0&&Tc(e,r,t),r}L.evaluatedPropsToName=Qh;function Tc(e,t,r){Object.keys(r).forEach(n=>e.assign((0,Q._)`${t}${(0,Q.getProperty)(n)}`,!0))}L.setEvaluated=Tc;var Gh={};function Hk(e,t){return e.scopeValue("func",{ref:t,code:Gh[t.code]||(Gh[t.code]=new Zk._Code(t.code))})}L.useFunc=Hk;var Ic;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Ic||(L.Type=Ic={}));function Kk(e,t,r){if(e instanceof Q.Name){let n=t===Ic.Num;return r?n?(0,Q._)`"[" + ${e} + "]"`:(0,Q._)`"['" + ${e} + "']"`:n?(0,Q._)`"/" + ${e}`:(0,Q._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Q.getProperty)(e).toString():"/"+Ec(e)}L.getErrorPath=Kk;function eg(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}L.checkStrictMode=eg});var Et=S(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});var Se=q(),Jk={data:new Se.Name("data"),valCxt:new Se.Name("valCxt"),instancePath:new Se.Name("instancePath"),parentData:new Se.Name("parentData"),parentDataProperty:new Se.Name("parentDataProperty"),rootData:new Se.Name("rootData"),dynamicAnchors:new Se.Name("dynamicAnchors"),vErrors:new Se.Name("vErrors"),errors:new Se.Name("errors"),this:new Se.Name("this"),self:new Se.Name("self"),scope:new Se.Name("scope"),json:new Se.Name("json"),jsonPos:new Se.Name("jsonPos"),jsonLen:new Se.Name("jsonLen"),jsonPart:new Se.Name("jsonPart")};Oc.default=Jk});var Vn=S(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.extendErrors=ze.resetErrorsCount=ze.reportExtraError=ze.reportError=ze.keyword$DataError=ze.keywordError=void 0;var J=q(),Js=K(),je=Et();ze.keywordError={message:({keyword:e})=>(0,J.str)`must pass "${e}" keyword validation`};ze.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,J.str)`"${e}" keyword must be ${t} ($data)`:(0,J.str)`"${e}" keyword is invalid ($data)`};function Gk(e,t=ze.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=ng(e,t,r);n??(i||a)?tg(s,c):rg(o,(0,J._)`[${c}]`)}ze.reportError=Gk;function Wk(e,t=ze.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=ng(e,t,r);tg(o,a),s||i||rg(n,je.default.vErrors)}ze.reportExtraError=Wk;function Yk(e,t){e.assign(je.default.errors,t),e.if((0,J._)`${je.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,J._)`${je.default.vErrors}.length`,t),()=>e.assign(je.default.vErrors,null)))}ze.resetErrorsCount=Yk;function Xk({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,je.default.errors,a=>{e.const(i,(0,J._)`${je.default.vErrors}[${a}]`),e.if((0,J._)`${i}.instancePath === undefined`,()=>e.assign((0,J._)`${i}.instancePath`,(0,J.strConcat)(je.default.instancePath,s.errorPath))),e.assign((0,J._)`${i}.schemaPath`,(0,J.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,J._)`${i}.schema`,r),e.assign((0,J._)`${i}.data`,n))})}ze.extendErrors=Xk;function tg(e,t){let r=e.const("err",t);e.if((0,J._)`${je.default.vErrors} === null`,()=>e.assign(je.default.vErrors,(0,J._)`[${r}]`),(0,J._)`${je.default.vErrors}.push(${r})`),e.code((0,J._)`${je.default.errors}++`)}function rg(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,J._)`new ${e.ValidationError}(${t})`):(r.assign((0,J._)`${n}.errors`,t),r.return(!1))}var cr={keyword:new J.Name("keyword"),schemaPath:new J.Name("schemaPath"),params:new J.Name("params"),propertyName:new J.Name("propertyName"),message:new J.Name("message"),schema:new J.Name("schema"),parentSchema:new J.Name("parentSchema")};function ng(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,J._)`{}`:Qk(e,t,r)}function Qk(e,t,r={}){let{gen:n,it:o}=e,s=[ex(o,r),tx(e,r)];return rx(e,t,s),n.object(...s)}function ex({errorPath:e},{instancePath:t}){let r=t?(0,J.str)`${e}${(0,Js.getErrorPath)(t,Js.Type.Str)}`:e;return[je.default.instancePath,(0,J.strConcat)(je.default.instancePath,r)]}function tx({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,J.str)`${t}/${e}`;return r&&(o=(0,J.str)`${o}${(0,Js.getErrorPath)(r,Js.Type.Str)}`),[cr.schemaPath,o]}function rx(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([cr.keyword,o],[cr.params,typeof t=="function"?t(e):t||(0,J._)`{}`]),c.messages&&n.push([cr.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([cr.schema,i],[cr.parentSchema,(0,J._)`${l}${d}`],[je.default.data,s]),u&&n.push([cr.propertyName,u])}});var sg=S(Cr=>{"use strict";Object.defineProperty(Cr,"__esModule",{value:!0});Cr.boolOrEmptySchema=Cr.topBoolOrEmptySchema=void 0;var nx=Vn(),ox=q(),sx=Et(),ix={message:"boolean schema is false"};function ax(e){let{gen:t,schema:r,validateName:n}=e;r===!1?og(e,!1):typeof r=="object"&&r.$async===!0?t.return(sx.default.data):(t.assign((0,ox._)`${n}.errors`,null),t.return(!0))}Cr.topBoolOrEmptySchema=ax;function cx(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),og(e)):r.var(t,!0)}Cr.boolOrEmptySchema=cx;function og(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,nx.reportError)(o,ix,void 0,t)}});var Rc=S(Nr=>{"use strict";Object.defineProperty(Nr,"__esModule",{value:!0});Nr.getRules=Nr.isJSONType=void 0;var ux=["string","number","integer","boolean","null","object","array"],lx=new Set(ux);function dx(e){return typeof e=="string"&&lx.has(e)}Nr.isJSONType=dx;function fx(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Nr.getRules=fx});var Ac=S(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.shouldUseRule=Vt.shouldUseGroup=Vt.schemaHasRulesForType=void 0;function px({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&ig(e,n)}Vt.schemaHasRulesForType=px;function ig(e,t){return t.rules.some(r=>ag(e,r))}Vt.shouldUseGroup=ig;function ag(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Vt.shouldUseRule=ag});var Bn=S(Pe=>{"use strict";Object.defineProperty(Pe,"__esModule",{value:!0});Pe.reportTypeError=Pe.checkDataTypes=Pe.checkDataType=Pe.coerceAndCheckDataType=Pe.getJSONTypes=Pe.getSchemaTypes=Pe.DataType=void 0;var mx=Rc(),hx=Ac(),gx=Vn(),Z=q(),cg=K(),jr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(jr||(Pe.DataType=jr={}));function yx(e){let t=ug(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}Pe.getSchemaTypes=yx;function ug(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(mx.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Pe.getJSONTypes=ug;function _x(e,t){let{gen:r,data:n,opts:o}=e,s=wx(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,hx.schemaHasRulesForType)(e,t[0]));if(i){let a=Nc(t,n,o.strictNumbers,jr.Wrong);r.if(a,()=>{s.length?bx(e,t,s):jc(e)})}return i}Pe.coerceAndCheckDataType=_x;var lg=new Set(["string","number","integer","boolean","null"]);function wx(e,t){return t?e.filter(r=>lg.has(r)||t==="array"&&r==="array"):[]}function bx(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,Z._)`typeof ${o}`),a=n.let("coerced",(0,Z._)`undefined`);s.coerceTypes==="array"&&n.if((0,Z._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,Z._)`${o}[0]`).assign(i,(0,Z._)`typeof ${o}`).if(Nc(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,Z._)`${a} !== undefined`);for(let u of r)(lg.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),jc(e),n.endIf(),n.if((0,Z._)`${a} !== undefined`,()=>{n.assign(o,a),vx(e,a)});function c(u){switch(u){case"string":n.elseIf((0,Z._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,Z._)`"" + ${o}`).elseIf((0,Z._)`${o} === null`).assign(a,(0,Z._)`""`);return;case"number":n.elseIf((0,Z._)`${i} == "boolean" || ${o} === null
|
|
5
|
+
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,Z._)`+${o}`);return;case"integer":n.elseIf((0,Z._)`${i} === "boolean" || ${o} === null
|
|
6
|
+
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,Z._)`+${o}`);return;case"boolean":n.elseIf((0,Z._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,Z._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,Z._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,Z._)`${i} === "string" || ${i} === "number"
|
|
7
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,Z._)`[${o}]`)}}}function vx({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,Z._)`${t} !== undefined`,()=>e.assign((0,Z._)`${t}[${r}]`,n))}function Cc(e,t,r,n=jr.Correct){let o=n===jr.Correct?Z.operators.EQ:Z.operators.NEQ,s;switch(e){case"null":return(0,Z._)`${t} ${o} null`;case"array":s=(0,Z._)`Array.isArray(${t})`;break;case"object":s=(0,Z._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,Z._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,Z._)`typeof ${t} ${o} ${e}`}return n===jr.Correct?s:(0,Z.not)(s);function i(a=Z.nil){return(0,Z.and)((0,Z._)`typeof ${t} == "number"`,a,r?(0,Z._)`isFinite(${t})`:Z.nil)}}Pe.checkDataType=Cc;function Nc(e,t,r,n){if(e.length===1)return Cc(e[0],t,r,n);let o,s=(0,cg.toHash)(e);if(s.array&&s.object){let i=(0,Z._)`typeof ${t} != "object"`;o=s.null?i:(0,Z._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=Z.nil;s.number&&delete s.integer;for(let i in s)o=(0,Z.and)(o,Cc(i,t,r,n));return o}Pe.checkDataTypes=Nc;var $x={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,Z._)`{type: ${e}}`:(0,Z._)`{type: ${t}}`};function jc(e){let t=kx(e);(0,gx.reportError)(t,$x)}Pe.reportTypeError=jc;function kx(e){let{gen:t,data:r,schema:n}=e,o=(0,cg.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var fg=S(Gs=>{"use strict";Object.defineProperty(Gs,"__esModule",{value:!0});Gs.assignDefaults=void 0;var Dr=q(),xx=K();function Sx(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)dg(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>dg(e,s,o.default))}Gs.assignDefaults=Sx;function dg(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Dr._)`${s}${(0,Dr.getProperty)(t)}`;if(o){(0,xx.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Dr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Dr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Dr._)`${a} = ${(0,Dr.stringify)(r)}`)}});var nt=S(X=>{"use strict";Object.defineProperty(X,"__esModule",{value:!0});X.validateUnion=X.validateArray=X.usePattern=X.callValidateCode=X.schemaProperties=X.allSchemaProperties=X.noPropertyInData=X.propertyInData=X.isOwnProperty=X.hasPropFunc=X.reportMissingProp=X.checkMissingProp=X.checkReportMissingProp=void 0;var se=q(),Dc=K(),Bt=Et(),zx=K();function Px(e,t){let{gen:r,data:n,it:o}=e;r.if(Mc(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,se._)`${t}`},!0),e.error()})}X.checkReportMissingProp=Px;function Ix({gen:e,data:t,it:{opts:r}},n,o){return(0,se.or)(...n.map(s=>(0,se.and)(Mc(e,t,s,r.ownProperties),(0,se._)`${o} = ${s}`)))}X.checkMissingProp=Ix;function Ex(e,t){e.setParams({missingProperty:t},!0),e.error()}X.reportMissingProp=Ex;function pg(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,se._)`Object.prototype.hasOwnProperty`})}X.hasPropFunc=pg;function Zc(e,t,r){return(0,se._)`${pg(e)}.call(${t}, ${r})`}X.isOwnProperty=Zc;function Tx(e,t,r,n){let o=(0,se._)`${t}${(0,se.getProperty)(r)} !== undefined`;return n?(0,se._)`${o} && ${Zc(e,t,r)}`:o}X.propertyInData=Tx;function Mc(e,t,r,n){let o=(0,se._)`${t}${(0,se.getProperty)(r)} === undefined`;return n?(0,se.or)(o,(0,se.not)(Zc(e,t,r))):o}X.noPropertyInData=Mc;function mg(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}X.allSchemaProperties=mg;function Ox(e,t){return mg(t).filter(r=>!(0,Dc.alwaysValidSchema)(e,t[r]))}X.schemaProperties=Ox;function Rx({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,se._)`${e}, ${t}, ${n}${o}`:t,d=[[Bt.default.instancePath,(0,se.strConcat)(Bt.default.instancePath,s)],[Bt.default.parentData,i.parentData],[Bt.default.parentDataProperty,i.parentDataProperty],[Bt.default.rootData,Bt.default.rootData]];i.opts.dynamicRef&&d.push([Bt.default.dynamicAnchors,Bt.default.dynamicAnchors]);let f=(0,se._)`${l}, ${r.object(...d)}`;return c!==se.nil?(0,se._)`${a}.call(${c}, ${f})`:(0,se._)`${a}(${f})`}X.callValidateCode=Rx;var Ax=(0,se._)`new RegExp`;function Cx({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,se._)`${o.code==="new RegExp"?Ax:(0,zx.useFunc)(e,o)}(${r}, ${n})`})}X.usePattern=Cx;function Nx(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,se._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:Dc.Type.Num},s),t.if((0,se.not)(s),a)})}}X.validateArray=Nx;function jx(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Dc.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,se._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,se.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}X.validateUnion=jx});var yg=S(ht=>{"use strict";Object.defineProperty(ht,"__esModule",{value:!0});ht.validateKeywordUsage=ht.validSchemaType=ht.funcKeywordCode=ht.macroKeywordCode=void 0;var De=q(),ur=Et(),Dx=nt(),Zx=Vn();function Mx(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=gg(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:De.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}ht.macroKeywordCode=Mx;function qx(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;Lx(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=gg(n,o,u),d=n.let("valid");e.block$data(d,f),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function f(){if(t.errors===!1)h(),t.modifying&&hg(e),g(()=>e.error());else{let y=t.async?p():m();t.modifying&&hg(e),g(()=>Fx(e,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,De._)`await `),v=>n.assign(d,!1).if((0,De._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,De._)`${v}.errors`),()=>n.throw(v))),y}function m(){let y=(0,De._)`${l}.errors`;return n.assign(y,null),h(De.nil),y}function h(y=t.async?(0,De._)`await `:De.nil){let v=c.opts.passContext?ur.default.this:ur.default.self,$=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,De._)`${y}${(0,Dx.callValidateCode)(e,l,v,$)}`,t.modifying)}function g(y){var v;n.if((0,De.not)((v=t.valid)!==null&&v!==void 0?v:d),y)}}ht.funcKeywordCode=qx;function hg(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,De._)`${n.parentData}[${n.parentDataProperty}]`))}function Fx(e,t){let{gen:r}=e;r.if((0,De._)`Array.isArray(${t})`,()=>{r.assign(ur.default.vErrors,(0,De._)`${ur.default.vErrors} === null ? ${t} : ${ur.default.vErrors}.concat(${t})`).assign(ur.default.errors,(0,De._)`${ur.default.vErrors}.length`),(0,Zx.extendErrors)(e)},()=>e.error())}function Lx({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function gg(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,De.stringify)(r)})}function Ux(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}ht.validSchemaType=Ux;function Vx({schema:e,opts:t,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(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}ht.validateKeywordUsage=Vx});var wg=S(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Ht.extendSubschemaMode=Ht.extendSubschemaData=Ht.getSubschema=void 0;var gt=q(),_g=K();function Bx(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,gt._)`${e.schemaPath}${(0,gt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,gt._)`${e.schemaPath}${(0,gt.getProperty)(t)}${(0,gt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,_g.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')}Ht.getSubschema=Bx;function Hx(e,t,{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}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,f=a.let("data",(0,gt._)`${t.data}${(0,gt.getProperty)(r)}`,!0);c(f),e.errorPath=(0,gt.str)`${u}${(0,_g.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,gt._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof gt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Ht.extendSubschemaData=Hx;function Kx(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Ht.extendSubschemaMode=Kx});var qc=S((yD,bg)=>{"use strict";bg.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),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(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var $g=S((_D,vg)=>{"use strict";var Kt=vg.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Ws(t,n,o,e,"",e)};Kt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Kt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Kt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Kt.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Ws(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Kt.arrayKeywords)for(var f=0;f<d.length;f++)Ws(e,t,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in Kt.propsKeywords){if(d&&typeof d=="object")for(var p in d)Ws(e,t,r,d[p],o+"/"+l+"/"+Jx(p),s,o,l,n,p)}else(l in Kt.keywords||e.allKeys&&!(l in Kt.skipKeywords))&&Ws(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function Jx(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Hn=S(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});Ue.getSchemaRefs=Ue.resolveUrl=Ue.normalizeId=Ue._getFullPath=Ue.getFullPath=Ue.inlineRef=void 0;var Gx=K(),Wx=qc(),Yx=$g(),Xx=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Qx(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Fc(e):t?kg(e)<=t:!1}Ue.inlineRef=Qx;var eS=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Fc(e){for(let t in e){if(eS.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Fc)||typeof r=="object"&&Fc(r))return!0}return!1}function kg(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!Xx.has(r)&&(typeof e[r]=="object"&&(0,Gx.eachItem)(e[r],n=>t+=kg(n)),t===1/0))return 1/0}return t}function xg(e,t="",r){r!==!1&&(t=Zr(t));let n=e.parse(t);return Sg(e,n)}Ue.getFullPath=xg;function Sg(e,t){return e.serialize(t).split("#")[0]+"#"}Ue._getFullPath=Sg;var tS=/#\/?$/;function Zr(e){return e?e.replace(tS,""):""}Ue.normalizeId=Zr;function rS(e,t,r){return r=Zr(r),e.resolve(t,r)}Ue.resolveUrl=rS;var nS=/^[a-z_][-a-z0-9._]*$/i;function oS(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Zr(e[r]||t),s={"":o},i=xg(n,o,!1),a={},c=new Set;return Yx(e,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=i+f,g=s[m];typeof d[r]=="string"&&(g=y.call(this,d[r])),v.call(this,d.$anchor),v.call(this,d.$dynamicAnchor),s[f]=g;function y($){let I=this.opts.uriResolver.resolve;if($=Zr(g?I(g,$):$),c.has($))throw l($);c.add($);let x=this.refs[$];return typeof x=="string"&&(x=this.refs[x]),typeof x=="object"?u(d,x.schema,$):$!==Zr(h)&&($[0]==="#"?(u(d,a[$],$),a[$]=d):this.refs[$]=h),$}function v($){if(typeof $=="string"){if(!nS.test($))throw new Error(`invalid anchor "${$}"`);y.call(this,`#${$}`)}}}),a;function u(d,f,p){if(f!==void 0&&!Wx(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ue.getSchemaRefs=oS});var Gn=S(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Jt.getData=Jt.KeywordCxt=Jt.validateFunctionCode=void 0;var Tg=sg(),zg=Bn(),Uc=Ac(),Ys=Bn(),sS=fg(),Jn=yg(),Lc=wg(),O=q(),j=Et(),iS=Hn(),Tt=K(),Kn=Vn();function aS(e){if(Ag(e)&&(Cg(e),Rg(e))){lS(e);return}Og(e,()=>(0,Tg.topBoolOrEmptySchema)(e))}Jt.validateFunctionCode=aS;function Og({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,O._)`${j.default.data}, ${j.default.valCxt}`,n.$async,()=>{e.code((0,O._)`"use strict"; ${Pg(r,o)}`),uS(e,o),e.code(s)}):e.func(t,(0,O._)`${j.default.data}, ${cS(o)}`,n.$async,()=>e.code(Pg(r,o)).code(s))}function cS(e){return(0,O._)`{${j.default.instancePath}="", ${j.default.parentData}, ${j.default.parentDataProperty}, ${j.default.rootData}=${j.default.data}${e.dynamicRef?(0,O._)`, ${j.default.dynamicAnchors}={}`:O.nil}}={}`}function uS(e,t){e.if(j.default.valCxt,()=>{e.var(j.default.instancePath,(0,O._)`${j.default.valCxt}.${j.default.instancePath}`),e.var(j.default.parentData,(0,O._)`${j.default.valCxt}.${j.default.parentData}`),e.var(j.default.parentDataProperty,(0,O._)`${j.default.valCxt}.${j.default.parentDataProperty}`),e.var(j.default.rootData,(0,O._)`${j.default.valCxt}.${j.default.rootData}`),t.dynamicRef&&e.var(j.default.dynamicAnchors,(0,O._)`${j.default.valCxt}.${j.default.dynamicAnchors}`)},()=>{e.var(j.default.instancePath,(0,O._)`""`),e.var(j.default.parentData,(0,O._)`undefined`),e.var(j.default.parentDataProperty,(0,O._)`undefined`),e.var(j.default.rootData,j.default.data),t.dynamicRef&&e.var(j.default.dynamicAnchors,(0,O._)`{}`)})}function lS(e){let{schema:t,opts:r,gen:n}=e;Og(e,()=>{r.$comment&&t.$comment&&jg(e),hS(e),n.let(j.default.vErrors,null),n.let(j.default.errors,0),r.unevaluated&&dS(e),Ng(e),_S(e)})}function dS(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,O._)`${r}.evaluated`),t.if((0,O._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,O._)`${e.evaluated}.props`,(0,O._)`undefined`)),t.if((0,O._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,O._)`${e.evaluated}.items`,(0,O._)`undefined`))}function Pg(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,O._)`/*# sourceURL=${r} */`:O.nil}function fS(e,t){if(Ag(e)&&(Cg(e),Rg(e))){pS(e,t);return}(0,Tg.boolOrEmptySchema)(e,t)}function Rg({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function Ag(e){return typeof e.schema!="boolean"}function pS(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&jg(e),gS(e),yS(e);let s=n.const("_errs",j.default.errors);Ng(e,s),n.var(t,(0,O._)`${s} === ${j.default.errors}`)}function Cg(e){(0,Tt.checkUnknownRules)(e),mS(e)}function Ng(e,t){if(e.opts.jtd)return Ig(e,[],!1,t);let r=(0,zg.getSchemaTypes)(e.schema),n=(0,zg.coerceAndCheckDataType)(e,r);Ig(e,r,!n,t)}function mS(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Tt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function hS(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Tt.checkStrictMode)(e,"default is ignored in the schema root")}function gS(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,iS.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function yS(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function jg({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,O._)`${j.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,O.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,O._)`${j.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function _S(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,O._)`${j.default.errors} === 0`,()=>t.return(j.default.data),()=>t.throw((0,O._)`new ${o}(${j.default.vErrors})`)):(t.assign((0,O._)`${n}.errors`,j.default.vErrors),s.unevaluated&&wS(e),t.return((0,O._)`${j.default.errors} === 0`))}function wS({gen:e,evaluated:t,props:r,items:n}){r instanceof O.Name&&e.assign((0,O._)`${t}.props`,r),n instanceof O.Name&&e.assign((0,O._)`${t}.items`,n)}function Ig(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Tt.schemaHasRulesButRef)(s,l))){o.block(()=>Zg(e,"$ref",l.all.$ref.definition));return}c.jtd||bS(e,t),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,Uc.shouldUseGroup)(s,f)&&(f.type?(o.if((0,Ys.checkDataType)(f.type,i,c.strictNumbers)),Eg(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,Ys.reportTypeError)(e)),o.endIf()):Eg(e,f),a||o.if((0,O._)`${j.default.errors} === ${n||0}`))}}function Eg(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,sS.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,Uc.shouldUseRule)(n,s)&&Zg(e,s.keyword,s.definition,t.type)})}function bS(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(vS(e,t),e.opts.allowUnionTypes||$S(e,t),kS(e,e.dataTypes))}function vS(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Dg(e.dataTypes,r)||Vc(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),SS(e,t)}}function $S(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Vc(e,"use allowUnionTypes to allow union type keyword")}function kS(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Uc.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>xS(t,i))&&Vc(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function xS(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Dg(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function SS(e,t){let r=[];for(let n of e.dataTypes)Dg(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Vc(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Tt.checkStrictMode)(e,t,e.opts.strictTypes)}var Xs=class{constructor(t,r,n){if((0,Jn.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Tt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",Mg(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Jn.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=t.gen.const("_errs",j.default.errors))}result(t,r,n){this.failResult((0,O.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,O.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,O._)`${r} !== undefined && (${(0,O.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?Kn.reportExtraError:Kn.reportError)(this,this.def.error,r)}$dataError(){(0,Kn.reportError)(this,this.def.$dataError||Kn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Kn.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=O.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=O.nil,r=O.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,O.or)((0,O._)`${o} === undefined`,r)),t!==O.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==O.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,O.or)(i(),a());function i(){if(n.length){if(!(r instanceof O.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,O._)`${(0,Ys.checkDataTypes)(c,r,s.opts.strictNumbers,Ys.DataType.Wrong)}`}return O.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,O._)`!${c}(${r})`}return O.nil}}subschema(t,r){let n=(0,Lc.getSubschema)(this.it,t);(0,Lc.extendSubschemaData)(n,this.it,t),(0,Lc.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return fS(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Tt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Tt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,O.Name)),!0}};Jt.KeywordCxt=Xs;function Zg(e,t,r,n){let o=new Xs(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Jn.funcKeywordCode)(o,r):"macro"in r?(0,Jn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Jn.funcKeywordCode)(o,r)}var zS=/^\/(?:[^~]|~0|~1)*$/,PS=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Mg(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return j.default.rootData;if(e[0]==="/"){if(!zS.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=j.default.rootData}else{let u=PS.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,O._)`${s}${(0,O.getProperty)((0,Tt.unescapeJsonPointer)(u))}`,i=(0,O._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Jt.getData=Mg});var Qs=S(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});var Bc=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Hc.default=Bc});var Wn=S(Gc=>{"use strict";Object.defineProperty(Gc,"__esModule",{value:!0});var Kc=Hn(),Jc=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Kc.resolveUrl)(t,r,n),this.missingSchema=(0,Kc.normalizeId)((0,Kc.getFullPath)(t,this.missingRef))}};Gc.default=Jc});var ti=S(ot=>{"use strict";Object.defineProperty(ot,"__esModule",{value:!0});ot.resolveSchema=ot.getCompilingSchema=ot.resolveRef=ot.compileSchema=ot.SchemaEnv=void 0;var dt=q(),IS=Qs(),lr=Et(),ft=Hn(),qg=K(),ES=Gn(),Mr=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,ft.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};ot.SchemaEnv=Mr;function Yc(e){let t=Fg.call(this,e);if(t)return t;let r=(0,ft.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new dt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:IS.default,code:(0,dt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:lr.default.data,parentData:lr.default.parentData,parentDataProperty:lr.default.parentDataProperty,dataNames:[lr.default.data],dataPathArr:[dt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,dt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:dt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,dt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,ES.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(lr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let p=new Function(`${lr.default.self}`,`${lr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=u;p.evaluated={props:m instanceof dt.Name?void 0:m,items:h instanceof dt.Name?void 0:h,dynamicProps:m instanceof dt.Name,dynamicItems:h instanceof dt.Name},p.source&&(p.source.evaluated=(0,dt.stringify)(p.evaluated))}return e.validate=p,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}ot.compileSchema=Yc;function TS(e,t,r){var n;r=(0,ft.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=AS.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Mr({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=OS.call(this,s)}ot.resolveRef=TS;function OS(e){return(0,ft.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Yc.call(this,e)}function Fg(e){for(let t of this._compilations)if(RS(t,e))return t}ot.getCompilingSchema=Fg;function RS(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function AS(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||ei.call(this,e,t)}function ei(e,t){let r=this.opts.uriResolver.parse(t),n=(0,ft._getFullPath)(this.opts.uriResolver,r),o=(0,ft.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Wc.call(this,r,e);let s=(0,ft.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=ei.call(this,e,i);return typeof a?.schema!="object"?void 0:Wc.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Yc.call(this,i),s===(0,ft.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,ft.resolveUrl)(this.opts.uriResolver,o,u)),new Mr({schema:a,schemaId:c,root:e,baseId:o})}return Wc.call(this,r,i)}}ot.resolveSchema=ei;var CS=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Wc(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,qg.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!CS.has(a)&&u&&(t=(0,ft.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,qg.schemaHasRulesButRef)(r,this.RULES)){let a=(0,ft.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=ei.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Mr({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var Lg=S((xD,NS)=>{NS.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 nu=S((SD,Wg)=>{"use strict";var jS=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Qc=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),DS=RegExp.prototype.test.bind(/^\d*$/u),dr=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),eu=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Vg=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),tu=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),ZS=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Ve=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Ve[t]="%"+e[t>>4]+e[t&15]}function Ie(e){return e<2048?Ve[192|e>>6]+Ve[128|e&63]:e<65536?Ve[224|e>>12]+Ve[128|e>>6&63]+Ve[128|e&63]:Ve[240|e>>18]+Ve[128|e>>12&63]+Ve[128|e>>6&63]+Ve[128|e&63]}function MS(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var qS=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),FS=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),LS=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),US=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function VS(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!LS(e[t])){if(e[t]==="%"&&t+2<e.length&&dr(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function Ug(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function BS(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-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||t!==-1&&n.length===0||!Qc(c))return;s+=2;continue}if(!qS(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:Ug(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 Ug(i)}function Xc(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&FS(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(HS(n,":")<2)return{host:e,isIPV6:!1,error:t};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),!VS(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=BS(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function HS(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function Bg(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}function KS(e){if(e===""||e[0]==="/")return Bg(e);let t=e.split("/"),r=t.length-1,n=[],o=!1;for(let s=0;s<=r;s++){let i=t[s];i==="."||i===".."?(i===".."&&(n.length!==0&&n[n.length-1]!==".."?n.pop():n.push("..")),o=s===r):n.push(i)}return o&&n[n.length-1]!==".."&&n.push(""),(n.length===0||n[0]===""||n[0].includes(":"))&&n.unshift("."),n.join("/")}var JS={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},GS=/[@/?#:]/g,WS=/[@/?#]/g;function Hg(e,t){let r=t?WS:GS;return r.lastIndex=0,e.replace(r,n=>JS[n])}function Kg(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(dr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&eu(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function YS(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(dr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&eu(i)?t+=i:t+="%"+s,r+=2;continue}}if(Vg(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Gg(o)?n:Ve[o];else if(o<55296||o>57343)t+=Ie(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=Ie(65536+(o-55296<<10)+(s-56320)),r++):t+=Ie(65533)}else t+=Ie(65533)}}return t}function XS(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(dr(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),Vg(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Ve[i];else if(i<55296||i>57343)r+=Ie(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=Ie(65536+(i-55296<<10)+(a-56320)),o++):r+=Ie(65533)}else r+=Ie(65533)}}return r}function ru(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(dr(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Ve[s];else if(s<55296||s>57343)r+=Ie(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=Ie(65536+(s-55296<<10)+(i-56320)),n++):r+=Ie(65533)}else r+=Ie(65533)}}return r}function Jg(e){return ru(e,ZS)}function QS(e){return ru(e,tu)}function ez(e){return ru(e,tu)}function Gg(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function tz(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(dr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));eu(i)?t+=i:t+="%"+s,r+=2;continue}}if(tu(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Gg(o)?n:Ve[o];else if(o<55296||o>57343)t+=Ie(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=Ie(65536+(o-55296<<10)+(s-56320)),r++):t+=Ie(65533)}else t+=Ie(65533)}}return t}function rz(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(dr(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function nz(e){let t=[];if(e.userinfo!==void 0&&(t.push(Jg(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!Qc(r)){let n=Xc(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=Kg(r,!0),n=Xc(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=Hg(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!DS(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}Wg.exports={nonSimpleDomain:US,recomposeAuthority:nz,reescapeHostDelimiters:Hg,normalizePercentEncoding:Kg,normalizePathEncoding:YS,serializePathEncoding:XS,normalizeQueryFragmentEncoding:tz,encodeUserinfo:Jg,encodeQuery:QS,encodeFragment:ez,escapePreservingEscapes:rz,removeDotSegments:Bg,removeDotSegmentsRelative:KS,isIPv4:Qc,isUUID:jS,normalizeIPv6:Xc,stringArrayToHexStripped:MS}});var ty=S((zD,ey)=>{"use strict";var{isUUID:oz}=nu(),sz=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,iz=["http","https","ws","wss","urn","urn:uuid"];function az(e){return iz.indexOf(e)!==-1}function ou(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function Yg(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Xg(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function cz(e){return e.secure=ou(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function uz(e){if((e.port===(ou(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function lz(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(sz);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=su(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function dz(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=su(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function fz(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!oz(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function pz(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Qg={scheme:"http",domainHost:!0,parse:Yg,serialize:Xg},mz={scheme:"https",domainHost:Qg.domainHost,parse:Yg,serialize:Xg},ri={scheme:"ws",domainHost:!0,parse:cz,serialize:uz},hz={scheme:"wss",domainHost:ri.domainHost,parse:ri.parse,serialize:ri.serialize},gz={scheme:"urn",parse:lz,serialize:dz,skipNormalize:!0},yz={scheme:"urn:uuid",parse:fz,serialize:pz,skipNormalize:!0},ni={http:Qg,https:mz,ws:ri,wss:hz,urn:gz,"urn:uuid":yz};Object.setPrototypeOf(ni,null);function su(e){return e&&(ni[e]||ni[e.toLowerCase()])||void 0}ey.exports={wsIsSecure:ou,SCHEMES:ni,isValidSchemeName:az,getSchemeHandler:su}});var gy=S((PD,ci)=>{"use strict";var{normalizeIPv6:iy,removeDotSegments:Xn,removeDotSegmentsRelative:ay,recomposeAuthority:_z,normalizePercentEncoding:iu,normalizePathEncoding:wz,serializePathEncoding:ry,normalizeQueryFragmentEncoding:ny,encodeQuery:bz,encodeFragment:vz,reescapeHostDelimiters:$z,isIPv4:cy,nonSimpleDomain:kz}=nu(),{SCHEMES:uy,getSchemeHandler:au}=ty(),ly=/^[A-Za-z][A-Za-z0-9+.-]*$/u,dy="URI scheme is malformed.",oi="URI host is malformed.",xz=/[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;function oy(e){let t=String(e);if(!ly.test(t))throw new TypeError(dy);return t}function Sz(e,t){return typeof e=="string"?e=Cz(e,t):typeof e=="object"&&(e=ii(fr(e,t),t)),e}function zz(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=si(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:f,malformedSchemeSpecific:p,malformedHost:m,malformedScheme:h}=si(t,n);if(s||d||i||f||a||p||c||m||u||h)throw new Error(o.error||l.error||"URI is malformed.");let g=fy(o,l,n,!0),y=au(r&&r.scheme||g.scheme),v=g.host,$=v!==void 0&&v!==""&&(cy(v)||iy(v).isIPV6);if(my(g,r||{},y,$))throw new Error(oi);py(g,r||{},y,$);let I=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(g.error&&!I)throw new Error(g.error);return n.skipEscape=!0,fr(g,n)}function fy(e,t,r,n){let o={};if(n||(e=ii(fr(e,r),r),t=ii(fr(t,r),r)),r=r||{},!r.tolerant&&t.scheme)o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=Xn(t.path||""),o.query=t.query;else{if(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=Xn(t.path||""),o.query=t.query;else{if(!t.path)o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query;else{if(t.path[0]==="/")o.path=Xn(t.path);else{let s=e.userinfo!==void 0||e.host!==void 0||e.port!==void 0;s&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=e.scheme===void 0&&!s&&o.path[0]!=="/"?ay(o.path):Xn(o.path)}o.query=t.query}o.userinfo=e.userinfo,o.host=e.host,o.port=e.port}o.scheme=e.scheme}return o.fragment=t.fragment,o}function Pz(e,t,r){let n=sy(e,r),o=sy(t,r);return n!==void 0&&o!==void 0&&n===o}function fr(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=oy(r.scheme));let s=au(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=(r.scheme===void 0||n.reference==="suffix")&&!i,c=!n.skipEscape&&a;r.path!==void 0&&(n.skipEscape?r.path=iu(r.path):r.path=ry(r.path,c)),n.reference!=="suffix"&&r.scheme&&(r.scheme=oy(r.scheme),o.push(r.scheme,":"));let u=_z(r);if(u!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(u),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let l=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(l=a&&l[0]!=="/"?ay(l):Xn(l)),a&&(l=ry(l,!0)),u===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),o.push(l)}return r.query!==void 0&&o.push("?",bz(r.query)),r.fragment!==void 0&&o.push("#",vz(r.fragment)),o.join("")}var Iz=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,Ez=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,Tz=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function Oz(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function Yn(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function ai(e){return e[0]==="["&&e[e.length-1]==="]"}function Rz(e){let t=e[4];return Yn(e[3])||t!==void 0&&!ai(t)&&Yn(t)||Yn(e[6])||Yn(e[7])||Yn(e[8])}function py(e,t,r,n){if(my(e,t,r,n))return e.error=e.error||oi,!0;if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!ai(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&kz(e.host)){let o;try{o=new URL("http://"+e.host)}catch(s){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+s,!0}if(!Az(o))return e.error=e.error||oi,!0;e.host=o.hostname}return!1}function my(e,t,r,n){return!!(e.host&&n===!1&&!ai(e.host)&&(t.domainHost||r&&r.domainHost)&&xz.test(e.host))}function Az(e){return e.username===""&&e.password===""&&e.port===""&&e.pathname==="/"&&e.search===""&&e.hash===""&&e.hostname!==""}function si(e,t){let r=Object.assign({},t),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?e=r.scheme+":"+e:e="//"+e);let d=e.match(Ez);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let f=e.match(Tz);if(f!==null){let m=f[1],h=m.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):m.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let p=e.match(Iz);if(p){n.scheme=p[1],n.userinfo=p[3],n.host=p[4],n.port=parseInt(p[5],10),n.path=p[6]||"",n.query=p[7],n.fragment=p[8],n.scheme!==void 0&&(ly.test(n.scheme)?n.scheme=n.scheme.toLowerCase():(n.error=n.error||dy,u=!0)),s=Rz(p),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=p[5]);let m=Oz(n,p);if(m!==void 0&&(n.error=n.error||m,o=!0),n.host)if(cy(n.host)===!1){let y=ai(n.host),v=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,$=iy(n.host);l=$.isIPV6||$.isIPVFuture===!0,c=v&&(!y||$.error===!0),n.host=l?$.host:$.host.toLowerCase(),c&&(n.error=n.error||oi,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=au(r.scheme||n.scheme);if(c||(a=py(n,r,h,l)),e.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:iu(n.host,!0);l||(g=iu(g.toLowerCase())),n.host=l||r.scheme!=="null"?$z(g,l):g}(!h||h&&!h.skipNormalize)&&(n.path&&(n.path=wz(n.path)),n.query&&(n.query=ny(n.query)),n.fragment&&(n.fragment=ny(n.fragment))),h&&h.parse&&(h.parse(n,r),h===uy.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 ii(e,t){return si(e,t).parsed}function Cz(e,t){return hy(e,t).normalized}function hy(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=si(e,t);return{normalized:n||o||s||i||a?e:fr(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function sy(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:fr(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=hy(r,t);return o||s||i||a||c?void 0:n}var cu={SCHEMES:uy,normalize:Sz,resolve:zz,resolveComponent:fy,equal:Pz,serialize:fr,parse:ii};ci.exports=cu;ci.exports.default=cu;ci.exports.fastUri=cu});var _y=S(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});var yy=gy();yy.code='require("ajv/dist/runtime/uri").default';uu.default=yy});var zy=S($e=>{"use strict";Object.defineProperty($e,"__esModule",{value:!0});$e.CodeGen=$e.Name=$e.nil=$e.stringify=$e.str=$e._=$e.KeywordCxt=void 0;var Nz=Gn();Object.defineProperty($e,"KeywordCxt",{enumerable:!0,get:function(){return Nz.KeywordCxt}});var qr=q();Object.defineProperty($e,"_",{enumerable:!0,get:function(){return qr._}});Object.defineProperty($e,"str",{enumerable:!0,get:function(){return qr.str}});Object.defineProperty($e,"stringify",{enumerable:!0,get:function(){return qr.stringify}});Object.defineProperty($e,"nil",{enumerable:!0,get:function(){return qr.nil}});Object.defineProperty($e,"Name",{enumerable:!0,get:function(){return qr.Name}});Object.defineProperty($e,"CodeGen",{enumerable:!0,get:function(){return qr.CodeGen}});var jz=Qs(),ky=Wn(),Dz=Rc(),Qn=ti(),Zz=q(),eo=Hn(),ui=Bn(),du=K(),wy=Lg(),Mz=_y(),xy=(e,t)=>new RegExp(e,t);xy.code="new RegExp";var qz=["removeAdditional","useDefaults","coerceTypes"],Fz=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Lz={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."},Uz={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},by=200;function Vz(e){var t,r,n,o,s,i,a,c,u,l,d,f,p,m,h,g,y,v,$,I,x,R,k,E,M;let P=e.strict,U=(t=e.code)===null||t===void 0?void 0:t.optimize,te=U===!0||U===void 0?1:U||0,ae=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:xy,xe=(o=e.uriResolver)!==null&&o!==void 0?o:Mz.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:P)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:P)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:P)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:P)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=e.strictRequired)!==null&&p!==void 0?p:P)!==null&&m!==void 0?m:!1,code:e.code?{...e.code,optimize:te,regExp:ae}:{optimize:te,regExp:ae},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:by,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:by,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:($=e.inlineRefs)!==null&&$!==void 0?$:!0,schemaId:(I=e.schemaId)!==null&&I!==void 0?I:"$id",addUsedSchema:(x=e.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(R=e.validateSchema)!==null&&R!==void 0?R:!0,validateFormats:(k=e.validateFormats)!==null&&k!==void 0?k:!0,unicodeRegExp:(E=e.unicodeRegExp)!==null&&E!==void 0?E:!0,int32range:(M=e.int32range)!==null&&M!==void 0?M:!0,uriResolver:xe}}var to=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...Vz(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new Zz.ValueScope({scope:{},prefixes:Fz,es5:r,lines:n}),this.logger=Wz(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,Dz.getRules)(),vy.call(this,Lz,t,"NOT SUPPORTED"),vy.call(this,Uz,t,"DEPRECATED","warn"),this._metaOpts=Jz.call(this),t.formats&&Hz.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&Kz.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Bz.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=wy;n==="id"&&(o={...wy},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,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,t,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 ky.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(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[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(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$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,t);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(t){let r;for(;typeof(r=$y.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Qn.SchemaEnv({schema:{},schemaId:n});if(r=Qn.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=$y.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[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(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,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(Xz.call(this,n,r),!r)return(0,du.eachItem)(n,s=>lu.call(this,s)),this;eP.call(this,r);let o={...r,type:(0,ui.getJSONTypes)(r.type),schemaType:(0,ui.getJSONTypes)(r.schemaType)};return(0,du.eachItem)(n,o.type.length===0?s=>lu.call(this,s,o):s=>o.type.forEach(i=>lu.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;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]=Sy(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,eo.normalizeId)(i||n);let u=eo.getSchemaRefs.call(this,t,n);return c=new Qn.SchemaEnv({schema:t,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(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):Qn.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{Qn.compileSchema.call(this,t)}finally{this.opts=r}}};to.ValidationError=jz.default;to.MissingRefError=ky.default;$e.default=to;function vy(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function $y(e){return e=(0,eo.normalizeId)(e),this.schemas[e]||this.refs[e]}function Bz(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function Hz(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function Kz(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function Jz(){let e={...this.opts};for(let t of qz)delete e[t];return e}var Gz={log(){},warn(){},error(){}};function Wz(e){if(e===!1)return Gz;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var Yz=/^[a-z_$][a-z0-9_$:-]*$/i;function Xz(e,t){let{RULES:r}=this;if((0,du.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Yz.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function lu(e,t,r){var n;let o=t?.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[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,ui.getJSONTypes)(t.type),schemaType:(0,ui.getJSONTypes)(t.schemaType)}};t.before?Qz.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function Qz(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function eP(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=Sy(t)),e.validateSchema=this.compile(t,!0))}var tP={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Sy(e){return{anyOf:[e,tP]}}});var Py=S(fu=>{"use strict";Object.defineProperty(fu,"__esModule",{value:!0});var rP={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};fu.default=rP});var Oy=S(pr=>{"use strict";Object.defineProperty(pr,"__esModule",{value:!0});pr.callRef=pr.getValidate=void 0;var nP=Wn(),Iy=nt(),Be=q(),Fr=Et(),Ey=ti(),li=K(),oP={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=Ey.resolveRef.call(c,u,o,r);if(l===void 0)throw new nP.default(n.opts.uriResolver,o,r);if(l instanceof Ey.SchemaEnv)return f(l);return p(l);function d(){if(s===u)return di(e,i,s,s.$async);let m=t.scopeValue("root",{ref:u});return di(e,(0,Be._)`${m}.validate`,u,u.$async)}function f(m){let h=Ty(e,m);di(e,h,m,m.$async)}function p(m){let h=t.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Be.stringify)(m)}:{ref:m}),g=t.name("valid"),y=e.subschema({schema:m,dataTypes:[],schemaPath:Be.nil,topSchemaRef:h,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function Ty(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Be._)`${r.scopeValue("wrapper",{ref:t})}.validate`}pr.getValidate=Ty;function di(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Fr.default.this:Be.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Be._)`await ${(0,Iy.callValidateCode)(e,t,u)}`),p(t),i||o.assign(m,!0)},h=>{o.if((0,Be._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),f(h),i||o.assign(m,!1)}),e.ok(m)}function d(){e.result((0,Iy.callValidateCode)(e,t,u),()=>p(t),()=>f(t))}function f(m){let h=(0,Be._)`${m}.errors`;o.assign(Fr.default.vErrors,(0,Be._)`${Fr.default.vErrors} === null ? ${h} : ${Fr.default.vErrors}.concat(${h})`),o.assign(Fr.default.errors,(0,Be._)`${Fr.default.vErrors}.length`)}function p(m){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=li.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,Be._)`${m}.evaluated.props`);s.props=li.mergeEvaluated.props(o,y,s.props,Be.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=li.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,Be._)`${m}.evaluated.items`);s.items=li.mergeEvaluated.items(o,y,s.items,Be.Name)}}}pr.callRef=di;pr.default=oP});var Ry=S(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});var sP=Py(),iP=Oy(),aP=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",sP.default,iP.default];pu.default=aP});var Ay=S(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});var fi=q(),Gt=fi.operators,pi={maximum:{okStr:"<=",ok:Gt.LTE,fail:Gt.GT},minimum:{okStr:">=",ok:Gt.GTE,fail:Gt.LT},exclusiveMaximum:{okStr:"<",ok:Gt.LT,fail:Gt.GTE},exclusiveMinimum:{okStr:">",ok:Gt.GT,fail:Gt.LTE}},cP={message:({keyword:e,schemaCode:t})=>(0,fi.str)`must be ${pi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,fi._)`{comparison: ${pi[e].okStr}, limit: ${t}}`},uP={keyword:Object.keys(pi),type:"number",schemaType:"number",$data:!0,error:cP,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,fi._)`${r} ${pi[t].fail} ${n} || isNaN(${r})`)}};mu.default=uP});var Cy=S(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});var ro=q(),lP={message:({schemaCode:e})=>(0,ro.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,ro._)`{multipleOf: ${e}}`},dP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:lP,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,ro._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,ro._)`${i} !== parseInt(${i})`;e.fail$data((0,ro._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};hu.default=dP});var jy=S(gu=>{"use strict";Object.defineProperty(gu,"__esModule",{value:!0});function Ny(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}gu.default=Ny;Ny.code='require("ajv/dist/runtime/ucs2length").default'});var Dy=S(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});var mr=q(),fP=K(),pP=jy(),mP={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,mr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,mr._)`{limit: ${e}}`},hP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:mP,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?mr.operators.GT:mr.operators.LT,i=o.opts.unicode===!1?(0,mr._)`${r}.length`:(0,mr._)`${(0,fP.useFunc)(e.gen,pP.default)}(${r})`;e.fail$data((0,mr._)`${i} ${s} ${n}`)}};yu.default=hP});var Zy=S(_u=>{"use strict";Object.defineProperty(_u,"__esModule",{value:!0});var gP=nt(),yP=K(),Lr=q(),_P={message:({schemaCode:e})=>(0,Lr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Lr._)`{pattern: ${e}}`},wP={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:_P,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Lr._)`new RegExp`:(0,yP.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Lr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Lr._)`!${l}`)}else{let c=(0,gP.usePattern)(e,o);e.fail$data((0,Lr._)`!${c}.test(${r})`)}}};_u.default=wP});var My=S(wu=>{"use strict";Object.defineProperty(wu,"__esModule",{value:!0});var no=q(),bP={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,no.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,no._)`{limit: ${e}}`},vP={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:bP,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?no.operators.GT:no.operators.LT;e.fail$data((0,no._)`Object.keys(${r}).length ${o} ${n}`)}};wu.default=vP});var qy=S(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});var oo=nt(),so=q(),$P=K(),kP={message:({params:{missingProperty:e}})=>(0,so.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,so._)`{missingProperty: ${e}}`},xP={keyword:"required",type:"object",schemaType:"array",$data:!0,error:kP,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let p=e.parentSchema.properties,{definedProperties:m}=e.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,$P.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(so.nil,d);else for(let p of r)(0,oo.checkReportMissingProp)(e,p)}function l(){let p=t.let("missing");if(c||s){let m=t.let("valid",!0);e.block$data(m,()=>f(p,m)),e.ok(m)}else t.if((0,oo.checkMissingProp)(e,r,p)),(0,oo.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",n,p=>{e.setParams({missingProperty:p}),t.if((0,oo.noPropertyInData)(t,o,p,a.ownProperties),()=>e.error())})}function f(p,m){e.setParams({missingProperty:p}),t.forOf(p,n,()=>{t.assign(m,(0,oo.propertyInData)(t,o,p,a.ownProperties)),t.if((0,so.not)(m),()=>{e.error(),t.break()})},so.nil)}}};bu.default=xP});var Fy=S(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});var io=q(),SP={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,io.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,io._)`{limit: ${e}}`},zP={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:SP,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?io.operators.GT:io.operators.LT;e.fail$data((0,io._)`${r}.length ${o} ${n}`)}};vu.default=zP});var mi=S($u=>{"use strict";Object.defineProperty($u,"__esModule",{value:!0});var Ly=qc();Ly.code='require("ajv/dist/runtime/equal").default';$u.default=Ly});var Uy=S(xu=>{"use strict";Object.defineProperty(xu,"__esModule",{value:!0});var ku=Bn(),ke=q(),PP=K(),IP=mi(),EP={message:({params:{i:e,j:t}})=>(0,ke.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,ke._)`{i: ${e}, j: ${t}}`},TP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:EP,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,ku.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,ke._)`${i} === false`),e.ok(c);function l(){let m=t.let("i",(0,ke._)`${r}.length`),h=t.let("j");e.setParams({i:m,j:h}),t.assign(c,!0),t.if((0,ke._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function f(m,h){let g=t.name("item"),y=(0,ku.checkDataTypes)(u,g,a.opts.strictNumbers,ku.DataType.Wrong),v=t.const("indices",(0,ke._)`{}`);t.for((0,ke._)`;${m}--;`,()=>{t.let(g,(0,ke._)`${r}[${m}]`),t.if(y,(0,ke._)`continue`),u.length>1&&t.if((0,ke._)`typeof ${g} == "string"`,(0,ke._)`${g} += "_"`),t.if((0,ke._)`typeof ${v}[${g}] == "number"`,()=>{t.assign(h,(0,ke._)`${v}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,ke._)`${v}[${g}] = ${m}`)})}function p(m,h){let g=(0,PP.useFunc)(t,IP.default),y=t.name("outer");t.label(y).for((0,ke._)`;${m}--;`,()=>t.for((0,ke._)`${h} = ${m}; ${h}--;`,()=>t.if((0,ke._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{e.error(),t.assign(c,!1).break(y)})))}}};xu.default=TP});var Vy=S(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});var Su=q(),OP=K(),RP=mi(),AP={message:"must be equal to constant",params:({schemaCode:e})=>(0,Su._)`{allowedValue: ${e}}`},CP={keyword:"const",$data:!0,error:AP,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,Su._)`!${(0,OP.useFunc)(t,RP.default)}(${r}, ${o})`):e.fail((0,Su._)`${s} !== ${r}`)}};zu.default=CP});var By=S(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});var ao=q(),NP=K(),jP=mi(),DP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,ao._)`{allowedValues: ${e}}`},ZP={keyword:"enum",schemaType:"array",$data:!0,error:DP,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;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,NP.useFunc)(t,jP.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let p=t.const("vSchema",s);l=(0,ao.or)(...o.map((m,h)=>f(p,h)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,p=>t.if((0,ao._)`${u()}(${r}, ${p})`,()=>t.assign(l,!0).break()))}function f(p,m){let h=o[m];return typeof h=="object"&&h!==null?(0,ao._)`${u()}(${r}, ${p}[${m}])`:(0,ao._)`${r} === ${h}`}}};Pu.default=ZP});var Hy=S(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});var MP=Ay(),qP=Cy(),FP=Dy(),LP=Zy(),UP=My(),VP=qy(),BP=Fy(),HP=Uy(),KP=Vy(),JP=By(),GP=[MP.default,qP.default,FP.default,LP.default,UP.default,VP.default,BP.default,HP.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},KP.default,JP.default];Iu.default=GP});var Tu=S(co=>{"use strict";Object.defineProperty(co,"__esModule",{value:!0});co.validateAdditionalItems=void 0;var hr=q(),Eu=K(),WP={message:({params:{len:e}})=>(0,hr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,hr._)`{limit: ${e}}`},YP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:WP,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Eu.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Ky(e,n)}};function Ky(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,hr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,hr._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Eu.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,hr._)`${a} <= ${t.length}`);r.if((0,hr.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:Eu.Type.Num},u),i.allErrors||r.if((0,hr.not)(u),()=>r.break())})}}co.validateAdditionalItems=Ky;co.default=YP});var Ou=S(uo=>{"use strict";Object.defineProperty(uo,"__esModule",{value:!0});uo.validateTuple=void 0;var Jy=q(),hi=K(),XP=nt(),QP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Gy(e,"additionalItems",t);r.items=!0,!(0,hi.alwaysValidSchema)(r,t)&&e.ok((0,XP.validateArray)(e))}};function Gy(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=hi.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Jy._)`${s}.length`);r.forEach((d,f)=>{(0,hi.alwaysValidSchema)(a,d)||(n.if((0,Jy._)`${u} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function l(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[t]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,hi.checkStrictMode)(a,g,f.strictTuples)}}}uo.validateTuple=Gy;uo.default=QP});var Wy=S(Ru=>{"use strict";Object.defineProperty(Ru,"__esModule",{value:!0});var eI=Ou(),tI={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,eI.validateTuple)(e,"items")};Ru.default=tI});var Xy=S(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});var Yy=q(),rI=K(),nI=nt(),oI=Tu(),sI={message:({params:{len:e}})=>(0,Yy.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,Yy._)`{limit: ${e}}`},iI={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:sI,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,rI.alwaysValidSchema)(n,t)&&(o?(0,oI.validateAdditionalItems)(e,o):e.ok((0,nI.validateArray)(e)))}};Au.default=iI});var Qy=S(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});var st=q(),gi=K(),aI={message:({params:{min:e,max:t}})=>t===void 0?(0,st.str)`must contain at least ${e} valid item(s)`:(0,st.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,st._)`{minContains: ${e}}`:(0,st._)`{minContains: ${e}, maxContains: ${t}}`},cI={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:aI,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,st._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,gi.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,gi.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,gi.alwaysValidSchema)(s,r)){let h=(0,st._)`${l} >= ${i}`;a!==void 0&&(h=(0,st._)`${h} && ${l} <= ${a}`),e.pass(h);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?p(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,st._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let h=t.name("_valid"),g=t.let("count",0);p(h,()=>t.if(h,()=>m(g)))}function p(h,g){t.forRange("i",0,l,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:gi.Type.Num,compositeRule:!0},h),g()})}function m(h){t.code((0,st._)`${h}++`),a===void 0?t.if((0,st._)`${h} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,st._)`${h} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,st._)`${h} >= ${i}`,()=>t.assign(d,!0)))}}};Cu.default=cI});var r_=S(yt=>{"use strict";Object.defineProperty(yt,"__esModule",{value:!0});yt.validateSchemaDeps=yt.validatePropertyDeps=yt.error=void 0;var Nu=q(),uI=K(),lo=nt();yt.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Nu.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Nu._)`{property: ${e},
|
|
8
8
|
missingProperty: ${n},
|
|
9
9
|
depsCount: ${t},
|
|
10
|
-
deps: ${r}}`};var jP={keyword:"dependencies",type:"object",schemaType:"object",error:ot.error,code(e){let[t,r]=DP(e);My(e,t),qy(e,r)}};function DP({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function My(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,Qn.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,Qn.checkReportMissingProp)(e,u)}):(r.if((0,$u._)`${c} && (${(0,Qn.checkMissingProp)(e,a,s)})`),(0,Qn.reportMissingProp)(e,s),r.else())}}ot.validatePropertyDeps=My;function qy(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,NP.alwaysValidSchema)(s,t[a])||(r.if((0,Qn.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}ot.validateSchemaDeps=qy;ot.default=jP});var Uy=x(xu=>{"use strict";Object.defineProperty(xu,"__esModule",{value:!0});var Ly=j(),ZP=F(),MP={message:"property name must be valid",params:({params:e})=>(0,Ly._)`{propertyName: ${e.propertyName}}`},qP={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:MP,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,ZP.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,Ly.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};xu.default=qP});var ku=x(Su=>{"use strict";Object.defineProperty(Su,"__esModule",{value:!0});var ii=Ue(),et=j(),FP=gt(),ai=F(),LP={message:"must NOT have additional properties",params:({params:e})=>(0,et._)`{additionalProperty: ${e.additionalProperty}}`},UP={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:LP,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,ai.alwaysValidSchema)(i,r))return;let u=(0,ii.allSchemaProperties)(n.properties),l=(0,ii.allSchemaProperties)(n.patternProperties);d(),e.ok((0,et._)`${s} === ${FP.default.errors}`);function d(){t.forIn("key",o,g=>{!u.length&&!l.length?m(g):t.if(f(g),()=>m(g))})}function f(g){let w;if(u.length>8){let v=(0,ai.schemaRefOrVal)(i,n.properties,"properties");w=(0,ii.isOwnProperty)(t,v,g)}else u.length?w=(0,et.or)(...u.map(v=>(0,et._)`${g} === ${v}`)):w=et.nil;return l.length&&(w=(0,et.or)(w,...l.map(v=>(0,et._)`${(0,ii.usePattern)(e,v)}.test(${g})`))),(0,et.not)(w)}function p(g){t.code((0,et._)`delete ${o}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,ai.alwaysValidSchema)(i,r)){let w=t.name("valid");c.removeAdditional==="failing"?(h(g,w,!1),t.if((0,et.not)(w),()=>{e.reset(),p(g)})):(h(g,w),a||t.if((0,et.not)(w),()=>t.break()))}}function h(g,w,v){let $={keyword:"additionalProperties",dataProp:g,dataPropType:ai.Type.Str};v===!1&&Object.assign($,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema($,w)}}};Su.default=UP});var By=x(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});var VP=Zn(),Vy=Ue(),zu=F(),Hy=ku(),HP={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Hy.default.code(new VP.KeywordCxt(s,Hy.default,"additionalProperties"));let i=(0,Vy.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=zu.mergeEvaluated.props(t,(0,zu.toHash)(i),s.props));let a=i.filter(d=>!(0,zu.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,Vy.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Pu.default=HP});var Wy=x(Eu=>{"use strict";Object.defineProperty(Eu,"__esModule",{value:!0});var Jy=Ue(),ci=j(),Ky=F(),Gy=F(),BP={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,Jy.allSchemaProperties)(r),c=a.filter(h=>(0,Ky.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=t.name("valid");s.props!==!0&&!(s.props instanceof ci.Name)&&(s.props=(0,Gy.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let h of a)u&&p(h),s.allErrors?m(h):(t.var(l,!0),m(h),t.if(l))}function p(h){for(let g in u)new RegExp(h).test(g)&&(0,Ky.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){t.forIn("key",n,g=>{t.if((0,ci._)`${(0,Jy.usePattern)(e,h)}.test(${g})`,()=>{let w=c.includes(h);w||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:Gy.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,ci._)`${d}[${g}]`,!0):!w&&!s.allErrors&&t.if((0,ci.not)(l),()=>t.break())})})}}};Eu.default=BP});var Yy=x(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});var JP=F(),KP={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,JP.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Iu.default=KP});var Xy=x(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});var GP=Ue(),WP={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:GP.validateUnion,error:{message:"must match a schema in anyOf"}};Tu.default=WP});var Qy=x(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});var ui=j(),YP=F(),XP={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,ui._)`{passingSchemas: ${e.passing}}`},QP={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:XP,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let f;(0,YP.alwaysValidSchema)(o,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,ui._)`${c} && ${i}`).assign(i,!1).assign(a,(0,ui._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,ui.Name)})})}}};Ou.default=QP});var e_=x(Ru=>{"use strict";Object.defineProperty(Ru,"__esModule",{value:!0});var eE=F(),tE={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,eE.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};Ru.default=tE});var n_=x(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});var li=j(),r_=F(),rE={message:({params:e})=>(0,li.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,li._)`{failingKeyword: ${e.ifClause}}`},nE={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:rE,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,r_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=t_(n,"then"),s=t_(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,li.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let f=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,li._)`${l}`):e.setParams({ifClause:l})}}}};function t_(e,t){let r=e.schema[t];return r!==void 0&&!(0,r_.alwaysValidSchema)(e,r)}Au.default=nE});var o_=x(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});var oE=F(),sE={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,oE.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Cu.default=sE});var s_=x(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});var iE=yu(),aE=Ny(),cE=_u(),uE=Dy(),lE=Zy(),dE=Fy(),fE=Uy(),pE=ku(),mE=By(),hE=Wy(),gE=Yy(),yE=Xy(),_E=Qy(),wE=e_(),bE=n_(),vE=o_();function $E(e=!1){let t=[gE.default,yE.default,_E.default,wE.default,bE.default,vE.default,fE.default,pE.default,dE.default,mE.default,hE.default];return e?t.push(aE.default,uE.default):t.push(iE.default,cE.default),t.push(lE.default),t}Nu.default=$E});var i_=x(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var ae=j(),xE={message:({schemaCode:e})=>(0,ae.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,ae._)`{format: ${e}}`},SE={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:xE,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,ae._)`${m}[${i}]`),g=r.let("fType"),w=r.let("format");r.if((0,ae._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,ae._)`${h}.type || "string"`).assign(w,(0,ae._)`${h}.validate`),()=>r.assign(g,(0,ae._)`"string"`).assign(w,h)),e.fail$data((0,ae.or)(v(),$()));function v(){return c.strictSchema===!1?ae.nil:(0,ae._)`${i} && !${w}`}function $(){let O=l.$async?(0,ae._)`(${h}.async ? await ${w}(${n}) : ${w}(${n}))`:(0,ae._)`${w}(${n})`,k=(0,ae._)`(typeof ${w} == "function" ? ${O} : ${w}.test(${n}))`;return(0,ae._)`${w} && ${w} !== true && ${g} === ${t} && !${k}`}}function p(){let m=d.formats[s];if(!m){v();return}if(m===!0)return;let[h,g,w]=$(m);h===t&&e.pass(O());function v(){if(c.strictSchema===!1){d.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function $(k){let N=k instanceof RegExp?(0,ae.regexpCode)(k):c.code.formats?(0,ae._)`${c.code.formats}${(0,ae.getProperty)(s)}`:void 0,se=r.scopeValue("formats",{key:s,ref:k,code:N});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,ae._)`${se}.validate`]:["string",k,se]}function O(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ae._)`await ${w}(${n})`}return typeof g=="function"?(0,ae._)`${w}(${n})`:(0,ae._)`${w}.test(${n})`}}}};ju.default=SE});var a_=x(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var kE=i_(),zE=[kE.default];Du.default=zE});var c_=x(Ar=>{"use strict";Object.defineProperty(Ar,"__esModule",{value:!0});Ar.contentVocabulary=Ar.metadataVocabulary=void 0;Ar.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ar.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var l_=x(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});var PE=yy(),EE=Oy(),IE=s_(),TE=a_(),u_=c_(),OE=[PE.default,EE.default,(0,IE.default)(),TE.default,u_.metadataVocabulary,u_.contentVocabulary];Zu.default=OE});var f_=x(di=>{"use strict";Object.defineProperty(di,"__esModule",{value:!0});di.DiscrError=void 0;var d_;(function(e){e.Tag="tag",e.Mapping="mapping"})(d_||(di.DiscrError=d_={}))});var m_=x(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});var Cr=j(),Mu=f_(),p_=Vs(),RE=Mn(),AE=F(),CE={message:({params:{discrError:e,tagName:t}})=>e===Mu.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Cr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},NE={keyword:"discriminator",type:"object",schemaType:"object",error:CE,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{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=t.let("valid",!1),u=t.const("tag",(0,Cr._)`${r}${(0,Cr.getProperty)(a)}`);t.if((0,Cr._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Mu.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let p=f();t.if(!1);for(let m in p)t.elseIf((0,Cr._)`${u} === ${m}`),t.assign(c,d(p[m]));t.else(),e.error(!1,{discrError:Mu.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(p){let m=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:p},m);return e.mergeEvaluated(h,Cr.Name),m}function f(){var p;let m={},h=w(o),g=!0;for(let O=0;O<i.length;O++){let k=i[O];if(k?.$ref&&!(0,AE.schemaHasRulesButRef)(k,s.self.RULES)){let se=k.$ref;if(k=p_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,se),k instanceof p_.SchemaEnv&&(k=k.schema),k===void 0)throw new RE.default(s.opts.uriResolver,s.baseId,se)}let N=(p=k?.properties)===null||p===void 0?void 0:p[a];if(typeof N!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||w(k)),v(N,O)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function w({required:O}){return Array.isArray(O)&&O.includes(a)}function v(O,k){if(O.const)$(O.const,k);else if(O.enum)for(let N of O.enum)$(N,k);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function $(O,k){if(typeof O!="string"||O in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[O]=k}}}};qu.default=NE});var h_=x((hD,jE)=>{jE.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 Lu=x((Q,Fu)=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.MissingRefError=Q.ValidationError=Q.CodeGen=Q.Name=Q.nil=Q.stringify=Q.str=Q._=Q.KeywordCxt=Q.Ajv=void 0;var DE=dy(),ZE=l_(),ME=m_(),g_=h_(),qE=["/properties"],fi="http://json-schema.org/draft-07/schema",Nr=class extends DE.default{_addVocabularies(){super._addVocabularies(),ZE.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(ME.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(g_,qE):g_;this.addMetaSchema(t,fi,!1),this.refs["http://json-schema.org/schema"]=fi}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(fi)?fi:void 0)}};Q.Ajv=Nr;Fu.exports=Q=Nr;Fu.exports.Ajv=Nr;Object.defineProperty(Q,"__esModule",{value:!0});Q.default=Nr;var FE=Zn();Object.defineProperty(Q,"KeywordCxt",{enumerable:!0,get:function(){return FE.KeywordCxt}});var jr=j();Object.defineProperty(Q,"_",{enumerable:!0,get:function(){return jr._}});Object.defineProperty(Q,"str",{enumerable:!0,get:function(){return jr.str}});Object.defineProperty(Q,"stringify",{enumerable:!0,get:function(){return jr.stringify}});Object.defineProperty(Q,"nil",{enumerable:!0,get:function(){return jr.nil}});Object.defineProperty(Q,"Name",{enumerable:!0,get:function(){return jr.Name}});Object.defineProperty(Q,"CodeGen",{enumerable:!0,get:function(){return jr.CodeGen}});var LE=Ls();Object.defineProperty(Q,"ValidationError",{enumerable:!0,get:function(){return LE.default}});var UE=Mn();Object.defineProperty(Q,"MissingRefError",{enumerable:!0,get:function(){return UE.default}})});var S_=x(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.formatNames=it.fastFormats=it.fullFormats=void 0;function st(e,t){return{validate:e,compare:t}}it.fullFormats={date:st(b_,Bu),time:st(Vu(!0),Ju),"date-time":st(y_(!0),$_),"iso-time":st(Vu(),v_),"iso-date-time":st(y_(),x_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:GE,"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:rI,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:WE,int32:{type:"number",validate:QE},int64:{type:"number",validate:eI},float:{type:"number",validate:w_},double:{type:"number",validate:w_},password:!0,binary:!0};it.fastFormats={...it.fullFormats,date:st(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Bu),time:st(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Ju),"date-time":st(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,$_),"iso-time":st(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,v_),"iso-date-time":st(/^\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,x_),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};it.formatNames=Object.keys(it.fullFormats);function VE(e){return e%4===0&&(e%100!==0||e%400===0)}var HE=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,BE=[0,31,28,31,30,31,30,31,31,30,31,30,31];function b_(e){let t=HE.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&VE(r)?29:BE[n])}function Bu(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Uu=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Vu(e){return function(r){let n=Uu.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||e&&!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 Ju(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function v_(e,t){if(!(e&&t))return;let r=Uu.exec(e),n=Uu.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var Hu=/t|\s/i;function y_(e){let t=Vu(e);return function(n){let o=n.split(Hu);return o.length===2&&b_(o[0])&&t(o[1])}}function $_(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function x_(e,t){if(!(e&&t))return;let[r,n]=e.split(Hu),[o,s]=t.split(Hu),i=Bu(r,o);if(i!==void 0)return i||Ju(n,s)}var JE=/\/|:/,KE=/^(?:[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 GE(e){return JE.test(e)&&KE.test(e)}var __=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function WE(e){return __.lastIndex=0,__.test(e)}var YE=-(2**31),XE=2**31-1;function QE(e){return Number.isInteger(e)&&e<=XE&&e>=YE}function eI(e){return Number.isInteger(e)}function w_(){return!0}var tI=/[^\\]\\Z/;function rI(e){if(tI.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var k_=x(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Dr.formatLimitDefinition=void 0;var nI=Lu(),tt=j(),jt=tt.operators,pi={formatMaximum:{okStr:"<=",ok:jt.LTE,fail:jt.GT},formatMinimum:{okStr:">=",ok:jt.GTE,fail:jt.LT},formatExclusiveMaximum:{okStr:"<",ok:jt.LT,fail:jt.GTE},formatExclusiveMinimum:{okStr:">",ok:jt.GT,fail:jt.LTE}},oI={message:({keyword:e,schemaCode:t})=>(0,tt.str)`should be ${pi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,tt._)`{comparison: ${pi[e].okStr}, limit: ${t}}`};Dr.formatLimitDefinition={keyword:Object.keys(pi),type:"string",schemaType:"string",$data:!0,error:oI,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new nI.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=t.const("fmt",(0,tt._)`${f}[${c.schemaCode}]`);e.fail$data((0,tt.or)((0,tt._)`typeof ${p} != "object"`,(0,tt._)`${p} instanceof RegExp`,(0,tt._)`typeof ${p}.compare != "function"`,d(p)))}function l(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${o}": format "${f}" does not define "compare" function`);let m=t.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,tt._)`${i.code.formats}${(0,tt.getProperty)(f)}`:void 0});e.fail$data(d(m))}function d(f){return(0,tt._)`${f}.compare(${r}, ${n}) ${pi[o].fail} 0`}},dependencies:["format"]};var sI=e=>(e.addKeyword(Dr.formatLimitDefinition),e);Dr.default=sI});var I_=x((eo,E_)=>{"use strict";Object.defineProperty(eo,"__esModule",{value:!0});var Zr=S_(),iI=k_(),Ku=j(),z_=new Ku.Name("fullFormats"),aI=new Ku.Name("fastFormats"),Gu=(e,t={keywords:!0})=>{if(Array.isArray(t))return P_(e,t,Zr.fullFormats,z_),e;let[r,n]=t.mode==="fast"?[Zr.fastFormats,aI]:[Zr.fullFormats,z_],o=t.formats||Zr.formatNames;return P_(e,o,r,n),t.keywords&&(0,iI.default)(e),e};Gu.get=(e,t="full")=>{let n=(t==="fast"?Zr.fastFormats:Zr.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function P_(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,Ku._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}E_.exports=eo=Gu;Object.defineProperty(eo,"__esModule",{value:!0});eo.default=Gu});import{existsSync as pT}from"node:fs";import{homedir as vw}from"node:os";import{isAbsolute as mT,join as vi,sep as hT}from"node:path";import{fileURLToPath as gT}from"node:url";import Qm from"node:process";var I={};ul(I,{BIGINT_FORMAT_RANGES:()=>mo,CONSTANT_CATCH:()=>vl,Class:()=>ki,NUMBER_FORMAT_RANGES:()=>Vr,aborted:()=>Ke,allowsEval:()=>Ti,assert:()=>Cw,assertEqual:()=>Iw,assertIs:()=>Rw,assertNever:()=>Aw,assertNotEqual:()=>Tw,assignProp:()=>Re,attachSchema:()=>Hr,base64ToUint8Array:()=>wl,base64urlToUint8Array:()=>Qw,cached:()=>lr,captureStackTrace:()=>fo,cleanEnum:()=>Xw,cleanRegex:()=>Ur,clone:()=>Je,cloneDef:()=>Dw,codePointLength:()=>Br,constantCatch:()=>$l,createTransparentProxy:()=>Uw,defineLazy:()=>fl,defineLazyInternal:()=>U,derived:()=>nb,esc:()=>Ei,escapeRegex:()=>lt,explicitlyAborted:()=>Ai,extend:()=>Bw,finalizeIssue:()=>Ge,floatSafeRemainder:()=>Pi,getElementAtPath:()=>Zw,getEnumValues:()=>cr,getLengthableOrigin:()=>Jr,getParsedType:()=>Lw,getSizableOrigin:()=>_l,hexToUint8Array:()=>tb,hide:()=>yo,installLazyProp:()=>ab,isObject:()=>Mt,isPlainObject:()=>bt,issue:()=>fr,joinValues:()=>lo,jsonStringifyReplacer:()=>ur,members:()=>Ni,merge:()=>Kw,mergeDefs:()=>ut,normalizeParams:()=>E,nullish:()=>zi,numKeys:()=>Fw,objectClone:()=>Nw,omit:()=>Hw,optionalKeys:()=>Ri,own:()=>wt,parsedType:()=>Ci,partial:()=>Gw,pick:()=>Vw,prefixIssues:()=>dt,primitiveTypes:()=>gl,promiseAllObject:()=>Mw,propertyKeyTypes:()=>Oi,randomString:()=>qw,rawShape:()=>dr,required:()=>Ww,safeExtend:()=>Jw,shallowClone:()=>hl,sizeCaps:()=>go,slugify:()=>Ii,stringifyPrimitive:()=>po,toZod:()=>Ow,uint8ArrayToBase64:()=>bl,uint8ArrayToBase64url:()=>eb,uint8ArrayToHex:()=>rb,unwrapMessage:()=>ar});function Iw(e){return e}function Tw(e){return e}function Ow(){return e=>e}function Rw(e){}function Aw(e){throw new Error("Unexpected value in exhaustive check")}function Cw(e){}function cr(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function lo(e,t="|"){return e.map(r=>po(r)).join(t)}function ur(e,t){return typeof t=="bigint"?t.toString():t}var Si=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function lr(e){return new Si(e)}function zi(e){return e==null}function Ur(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Pi(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var dl=Symbol("evaluating");function fl(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==dl)return n===void 0&&(n=dl,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Nw(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Re(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function dr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ct(e){return dr(e._zod.def)??e._zod.def.shape}function pl(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return Re(this,t,n),n},enumerable:!0,configurable:!0})}function ml(e,t,r){t in e?Re(e,t,r):e[t]=r}function Zt(e,t,r,n){let o=ct(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?pl(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):ml(e,s,n?n(i.value,s):i.value))}}function jw(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?pl(e,r,()=>t[r]):ml(e,r,n.value))}}function ut(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Dw(e){return ut(e._zod.def)}function Zw(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Mw(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function qw(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ei(e){return JSON.stringify(e)}function Ii(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var fo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Mt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ti=lr(()=>{if(Se.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function bt(e){if(Mt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Mt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function hl(e){return bt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function Fw(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var Lw=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Oi=new Set(["string","number","symbol"]),gl=new Set(["string","number","bigint","boolean","symbol","undefined"]);function lt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Je(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function E(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function Uw(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function po(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Ri(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Vr={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]},mo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Vw(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return Zt(s,e,ho(e,t)),Je(e,ut(r,{shape:s,checks:[]}))}function ho(e,t){let r=ct(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function Hw(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(ho(e,t)),i={};return Zt(i,e,Reflect.ownKeys(ct(e)).filter(a=>!s.has(a))),Je(e,ut(r,{shape:i,checks:[]}))}function Bw(e,t){if(!bt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=ct(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Je(e,ut(e._zod.def,{shape:yl(e,t)}))}function yl(e,t){let r={};return Zt(r,e,Reflect.ownKeys(ct(e))),jw(r,t),r}function Jw(e,t){if(!bt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return Je(e,ut(e._zod.def,{shape:yl(e,t)}))}function Kw(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Zt(r,e,Reflect.ownKeys(ct(e))),Zt(r,t,Reflect.ownKeys(ct(t)));let n=ut(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return Je(e,n)}function Gw(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(ho(t,r)):void 0,c={};return Zt(c,t,Reflect.ownKeys(ct(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),Je(t,ut(t._zod.def,{shape:c,checks:[]}))}function Ww(e,t,r){let n=r?new Set(ho(t,r)):void 0,o={};return Zt(o,t,Reflect.ownKeys(ct(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),Je(t,ut(t._zod.def,{shape:o}))}function Ke(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Ai(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function dt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function ar(e){return typeof e=="string"?e:e?.message}function go(e){let t=[];for(let r of e??[]){let n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;let o=n.maximum??n.length??n.size;o>=0&&t.push([o,r])}return t}function Hr(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function Ge(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:ar(e.inst?._zod.def?.error?.(e))??ar(s?.(e))??ar(t?.error?.(e))??ar(r.customError?.(e))??ar(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function _l(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var Yw=/[\uD800-\uDBFF]/;function Br(e){let t=e.length;if(!Yw.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function Jr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ci(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function fr(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function Xw(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function wl(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function bl(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Qw(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return wl(t+r)}function eb(e){return bl(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function tb(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function rb(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var ki=class{constructor(...t){}};function Ni(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):ob(e,r,n.value)}}function wt(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function yo(e,t,r){return wt(e,t,r,!1)}function nb(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return wt(this,r,n(this))},set(o){wt(this,r,o)}})}return t}function ob(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:wt(this,t,r.bind(this))},set(n){wt(this,t,n)}})}function sb(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var xi,_t=!1,ib={configurable:!0,get(){_t=!0}};function U(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&xi!==e._zod){xi=void 0;return}xi=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,ib);let o=_t;_t=!1;try{let s=r(this);return _t?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),_t=_t||o,s}catch(s){throw delete this[t],_t=_t||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function ab(e,t,r,n){let o=sb(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var vl="~constantCatch";function $l(e){let t=()=>e;return t[vl]=!0,t}var xl;var ji={value:void 0,enumerable:!1},Sl="captureStackTrace"in Error?Error:null;function cb(e){let t=Sl;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Sl=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function _(e,t,r,n){let o={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{ji.value=new s(p);try{Object.defineProperty(f,"_zod",ji)}finally{ji.value=void 0}}if(f._zod.traits.add(e),t(f,p),a){let h=Object.getPrototypeOf(f),g=f._zod.constr.prototype,w=h;for(;w&&w!==g;)w=Object.getPrototypeOf(w);let v=w??h;a.has(v)||(a.add(v),Ni(v,i))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in f||(f[h]=m[h].bind(f)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let p=n?.Parent?cb(l):this;c(p,f);let m=p._zod.deferred;if(m){for(let g of m)g();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var We=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},pr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(xl=globalThis).__zod_globalConfig??(xl.__zod_globalConfig={});var Se=globalThis.__zod_globalConfig;function Ae(e){return e&&Object.assign(Se,e),Se}function ub(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,ur,2)),e.message}function lb(e){this._zod.message=e}var db={get:ub,set:lb,enumerable:!0,configurable:!0},Zi={value:void 0,enumerable:!1},kl=new WeakSet([Object.prototype,Error.prototype]),zl=(e,t)=>{e.name="$ZodError",Zi.value=t,Object.defineProperty(e,"issues",Zi),Zi.value=void 0,Object.defineProperty(e,"message",db);let r=Object.getPrototypeOf(e);kl.has(r)||(kl.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},Pl=_("$ZodError",zl),El=_("$ZodError",zl,void 0,{Parent:Error});function fb(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Il(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?fb(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Tl(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[l];d&&f._errors.push(t(i)),c=f,u++}}}};return n(e),r}function _o(e,t){return{callee:t?.callee??e,Err:t?.Err}}var wo=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new We;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>Ge(u,i,Ae())));throw fo(c,s?.callee??t),c}return a.value};return t};var bo=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>Ge(u,i,Ae())));throw fo(c,s?.callee??t),c}return a.value};return t};var Kr=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new We;return s.issues.length?Ol(e,s.issues,o):{success:!0,data:s.value}},Mi=Kr(El);function Ol(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>Ge(o,r,Ae()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var vo=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?Ol(e,s.issues,o):{success:!0,data:s.value}};var mb=Symbol.for("zod.compile.invalid"),hb=Symbol.for("zod.compile.fallback"),$o=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==mb)return!0;if(n.definite===!0&&r===void 0)return!1}return gb(e,t,r)});function gb(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[hb]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new We;return s.issues.length===0}var xo=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Rl=e=>{let t=wo(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,_o(r,i))};return r};var Al=e=>{let t=wo(e),r=(n,o,s,i)=>t(n,o,s,_o(r,i));return r};var Cl=e=>{let t=bo(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,_o(r,i))};return r};var Nl=e=>{let t=bo(e),r=async(n,o,s,i)=>await t(n,o,s,_o(r,i));return r};var jl=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Kr(e)(t,r,o)};var Dl=e=>(t,r,n)=>Kr(e)(t,r,n);var Zl=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return vo(e)(t,r,o)};var Ml=e=>async(t,r,n)=>vo(e)(t,r,n);var ql=/^[cC][0-9a-z]{6,}$/,Fl=/^[0-9a-z]+$/,Ll=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ul=/^[0-9a-vA-V]{20}$/,Vl=/^[A-Za-z0-9]{27}$/,Hl=/^[a-zA-Z0-9_-]{21}$/;function Bl(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Jl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Kl=/^([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})$/,Fi=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[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|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var Gl=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var yb="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Wl(){return new RegExp(yb,"u")}var Yl=/^(?:(?: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])$/,Xl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var Ql=/^((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])$/,ed=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,td=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rd=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var nd=/^https?$/,od=/^\+[1-9]\d{6,14}$/;var sd="(?:(?:\\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])))";function _b(e){return new RegExp(`^${e}$`)}var id=_b(sd);function qi(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ad(e){return new RegExp(`^${qi(e)}$`)}function cd(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${qi({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${qi({precision:e.precision})}`:r;return new RegExp(`^${sd}T(?:${n})$`)}var ud=/^[\s\S]{0,}$/;var Li=/^-?\d+$/,Gr=/^-?\d+(?:\.\d+)?$/,ld=/^(?:true|false)$/i,dd=/^null$/i;var fd=/^[^A-Z]*$/,pd=/^[^a-z]*$/;var le=_("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Ui=e=>{let t=e.value;return!zi(t)&&t.length!==void 0},So={number:"number",bigint:"bigint",object:"date"},Vi=_("$ZodCheckLessThan",(e,t)=>{le.init(e,t);let r=So[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:So[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Hi=_("$ZodCheckGreaterThan",(e,t)=>{le.init(e,t);let r=So[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:So[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),md=_("$ZodCheckMultipleOf",(e,t)=>{le.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):Pi(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),hd=_("$ZodCheckNumberFormat",(e,t)=>{le.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Vr[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});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:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var gd=_("$ZodCheckMaxLength",(e,t)=>{var r;le.init(e,t),(r=e._zod.def).when??(r.when=Ui),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?Br(o):s)<=t.maximum)return;let a=Jr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),yd=_("$ZodCheckMinLength",(e,t)=>{var r;le.init(e,t),(r=e._zod.def).when??(r.when=Ui),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?Br(o):s)>=t.minimum)return;let a=Jr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),_d=_("$ZodCheckLengthEquals",(e,t)=>{var r;le.init(e,t),(r=e._zod.def).when??(r.when=Ui),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?Br(o):s;if(i===t.length)return;let a=Jr(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Yr=_("$ZodCheckStringFormat",(e,t)=>{var r,n;le.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),wd=_("$ZodCheckRegex",(e,t)=>{Yr.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),bd=_("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=fd),Yr.init(e,t)}),vd=_("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=pd),Yr.init(e,t)}),$d=_("$ZodCheckIncludes",(e,t)=>{le.init(e,t);let r=lt(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),xd=_("$ZodCheckStartsWith",(e,t)=>{le.init(e,t);let r=new RegExp(`^${lt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Sd=_("$ZodCheckEndsWith",(e,t)=>{le.init(e,t);let r=new RegExp(`.*${lt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var kd=_("$ZodCheckOverwrite",(e,t)=>{le.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var ko=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
10
|
+
deps: ${r}}`};var lI={keyword:"dependencies",type:"object",schemaType:"object",error:yt.error,code(e){let[t,r]=dI(e);e_(e,t),t_(e,r)}};function dI({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function e_(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,lo.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,lo.checkReportMissingProp)(e,u)}):(r.if((0,Nu._)`${c} && (${(0,lo.checkMissingProp)(e,a,s)})`),(0,lo.reportMissingProp)(e,s),r.else())}}yt.validatePropertyDeps=e_;function t_(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,uI.alwaysValidSchema)(s,t[a])||(r.if((0,lo.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}yt.validateSchemaDeps=t_;yt.default=lI});var o_=S(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var n_=q(),fI=K(),pI={message:"property name must be valid",params:({params:e})=>(0,n_._)`{propertyName: ${e.propertyName}}`},mI={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:pI,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,fI.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,n_.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};ju.default=mI});var Zu=S(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var yi=nt(),pt=q(),hI=Et(),_i=K(),gI={message:"must NOT have additional properties",params:({params:e})=>(0,pt._)`{additionalProperty: ${e.additionalProperty}}`},yI={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:gI,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,_i.alwaysValidSchema)(i,r))return;let u=(0,yi.allSchemaProperties)(n.properties),l=(0,yi.allSchemaProperties)(n.patternProperties);d(),e.ok((0,pt._)`${s} === ${hI.default.errors}`);function d(){t.forIn("key",o,g=>{!u.length&&!l.length?m(g):t.if(f(g),()=>m(g))})}function f(g){let y;if(u.length>8){let v=(0,_i.schemaRefOrVal)(i,n.properties,"properties");y=(0,yi.isOwnProperty)(t,v,g)}else u.length?y=(0,pt.or)(...u.map(v=>(0,pt._)`${g} === ${v}`)):y=pt.nil;return l.length&&(y=(0,pt.or)(y,...l.map(v=>(0,pt._)`${(0,yi.usePattern)(e,v)}.test(${g})`))),(0,pt.not)(y)}function p(g){t.code((0,pt._)`delete ${o}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,_i.alwaysValidSchema)(i,r)){let y=t.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),t.if((0,pt.not)(y),()=>{e.reset(),p(g)})):(h(g,y),a||t.if((0,pt.not)(y),()=>t.break()))}}function h(g,y,v){let $={keyword:"additionalProperties",dataProp:g,dataPropType:_i.Type.Str};v===!1&&Object.assign($,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema($,y)}}};Du.default=yI});var a_=S(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});var _I=Gn(),s_=nt(),Mu=K(),i_=Zu(),wI={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&i_.default.code(new _I.KeywordCxt(s,i_.default,"additionalProperties"));let i=(0,s_.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Mu.mergeEvaluated.props(t,(0,Mu.toHash)(i),s.props));let a=i.filter(d=>!(0,Mu.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,s_.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};qu.default=wI});var d_=S(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var c_=nt(),wi=q(),u_=K(),l_=K(),bI={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,c_.allSchemaProperties)(r),c=a.filter(h=>(0,u_.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=t.name("valid");s.props!==!0&&!(s.props instanceof wi.Name)&&(s.props=(0,l_.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let h of a)u&&p(h),s.allErrors?m(h):(t.var(l,!0),m(h),t.if(l))}function p(h){for(let g in u)new RegExp(h).test(g)&&(0,u_.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){t.forIn("key",n,g=>{t.if((0,wi._)`${(0,c_.usePattern)(e,h)}.test(${g})`,()=>{let y=c.includes(h);y||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:l_.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,wi._)`${d}[${g}]`,!0):!y&&!s.allErrors&&t.if((0,wi.not)(l),()=>t.break())})})}}};Fu.default=bI});var f_=S(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});var vI=K(),$I={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,vI.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Lu.default=$I});var p_=S(Uu=>{"use strict";Object.defineProperty(Uu,"__esModule",{value:!0});var kI=nt(),xI={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:kI.validateUnion,error:{message:"must match a schema in anyOf"}};Uu.default=xI});var m_=S(Vu=>{"use strict";Object.defineProperty(Vu,"__esModule",{value:!0});var bi=q(),SI=K(),zI={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,bi._)`{passingSchemas: ${e.passing}}`},PI={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:zI,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let f;(0,SI.alwaysValidSchema)(o,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,bi._)`${c} && ${i}`).assign(i,!1).assign(a,(0,bi._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,bi.Name)})})}}};Vu.default=PI});var h_=S(Bu=>{"use strict";Object.defineProperty(Bu,"__esModule",{value:!0});var II=K(),EI={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,II.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};Bu.default=EI});var __=S(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});var vi=q(),y_=K(),TI={message:({params:e})=>(0,vi.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,vi._)`{failingKeyword: ${e.ifClause}}`},OI={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:TI,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,y_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=g_(n,"then"),s=g_(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,vi.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let f=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,vi._)`${l}`):e.setParams({ifClause:l})}}}};function g_(e,t){let r=e.schema[t];return r!==void 0&&!(0,y_.alwaysValidSchema)(e,r)}Hu.default=OI});var w_=S(Ku=>{"use strict";Object.defineProperty(Ku,"__esModule",{value:!0});var RI=K(),AI={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,RI.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Ku.default=AI});var b_=S(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});var CI=Tu(),NI=Wy(),jI=Ou(),DI=Xy(),ZI=Qy(),MI=r_(),qI=o_(),FI=Zu(),LI=a_(),UI=d_(),VI=f_(),BI=p_(),HI=m_(),KI=h_(),JI=__(),GI=w_();function WI(e=!1){let t=[VI.default,BI.default,HI.default,KI.default,JI.default,GI.default,qI.default,FI.default,MI.default,LI.default,UI.default];return e?t.push(NI.default,DI.default):t.push(CI.default,jI.default),t.push(ZI.default),t}Ju.default=WI});var v_=S(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});var me=q(),YI={message:({schemaCode:e})=>(0,me.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,me._)`{format: ${e}}`},XI={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:YI,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,me._)`${m}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,me._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,me._)`${h}.type || "string"`).assign(y,(0,me._)`${h}.validate`),()=>r.assign(g,(0,me._)`"string"`).assign(y,h)),e.fail$data((0,me.or)(v(),$()));function v(){return c.strictSchema===!1?me.nil:(0,me._)`${i} && !${y}`}function $(){let I=l.$async?(0,me._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,me._)`${y}(${n})`,x=(0,me._)`(typeof ${y} == "function" ? ${I} : ${y}.test(${n}))`;return(0,me._)`${y} && ${y} !== true && ${g} === ${t} && !${x}`}}function p(){let m=d.formats[s];if(!m){v();return}if(m===!0)return;let[h,g,y]=$(m);h===t&&e.pass(I());function v(){if(c.strictSchema===!1){d.logger.warn(x());return}throw new Error(x());function x(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function $(x){let R=x instanceof RegExp?(0,me.regexpCode)(x):c.code.formats?(0,me._)`${c.code.formats}${(0,me.getProperty)(s)}`:void 0,k=r.scopeValue("formats",{key:s,ref:x,code:R});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,me._)`${k}.validate`]:["string",x,k]}function I(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,me._)`await ${y}(${n})`}return typeof g=="function"?(0,me._)`${y}(${n})`:(0,me._)`${y}.test(${n})`}}}};Gu.default=XI});var $_=S(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});var QI=v_(),eE=[QI.default];Wu.default=eE});var k_=S(Ur=>{"use strict";Object.defineProperty(Ur,"__esModule",{value:!0});Ur.contentVocabulary=Ur.metadataVocabulary=void 0;Ur.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Ur.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var S_=S(Yu=>{"use strict";Object.defineProperty(Yu,"__esModule",{value:!0});var tE=Ry(),rE=Hy(),nE=b_(),oE=$_(),x_=k_(),sE=[tE.default,rE.default,(0,nE.default)(),oE.default,x_.metadataVocabulary,x_.contentVocabulary];Yu.default=sE});var P_=S($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.DiscrError=void 0;var z_;(function(e){e.Tag="tag",e.Mapping="mapping"})(z_||($i.DiscrError=z_={}))});var E_=S(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});var Vr=q(),Xu=P_(),I_=ti(),iE=Wn(),aE=K(),cE={message:({params:{discrError:e,tagName:t}})=>e===Xu.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Vr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},uE={keyword:"discriminator",type:"object",schemaType:"object",error:cE,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{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=t.let("valid",!1),u=t.const("tag",(0,Vr._)`${r}${(0,Vr.getProperty)(a)}`);t.if((0,Vr._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Xu.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let p=f();t.if(!1);for(let m in p)t.elseIf((0,Vr._)`${u} === ${m}`),t.assign(c,d(p[m]));t.else(),e.error(!1,{discrError:Xu.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(p){let m=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:p},m);return e.mergeEvaluated(h,Vr.Name),m}function f(){var p;let m={},h=y(o),g=!0;for(let I=0;I<i.length;I++){let x=i[I];if(x?.$ref&&!(0,aE.schemaHasRulesButRef)(x,s.self.RULES)){let k=x.$ref;if(x=I_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,k),x instanceof I_.SchemaEnv&&(x=x.schema),x===void 0)throw new iE.default(s.opts.uriResolver,s.baseId,k)}let R=(p=x?.properties)===null||p===void 0?void 0:p[a];if(typeof R!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(x)),v(R,I)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:I}){return Array.isArray(I)&&I.includes(a)}function v(I,x){if(I.const)$(I.const,x);else if(I.enum)for(let R of I.enum)$(R,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function $(I,x){if(typeof I!="string"||I in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[I]=x}}}};Qu.default=uE});var T_=S((hZ,lE)=>{lE.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 tl=S((ie,el)=>{"use strict";Object.defineProperty(ie,"__esModule",{value:!0});ie.MissingRefError=ie.ValidationError=ie.CodeGen=ie.Name=ie.nil=ie.stringify=ie.str=ie._=ie.KeywordCxt=ie.Ajv=void 0;var dE=zy(),fE=S_(),pE=E_(),O_=T_(),mE=["/properties"],ki="http://json-schema.org/draft-07/schema",Br=class extends dE.default{_addVocabularies(){super._addVocabularies(),fE.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(pE.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(O_,mE):O_;this.addMetaSchema(t,ki,!1),this.refs["http://json-schema.org/schema"]=ki}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ki)?ki:void 0)}};ie.Ajv=Br;el.exports=ie=Br;el.exports.Ajv=Br;Object.defineProperty(ie,"__esModule",{value:!0});ie.default=Br;var hE=Gn();Object.defineProperty(ie,"KeywordCxt",{enumerable:!0,get:function(){return hE.KeywordCxt}});var Hr=q();Object.defineProperty(ie,"_",{enumerable:!0,get:function(){return Hr._}});Object.defineProperty(ie,"str",{enumerable:!0,get:function(){return Hr.str}});Object.defineProperty(ie,"stringify",{enumerable:!0,get:function(){return Hr.stringify}});Object.defineProperty(ie,"nil",{enumerable:!0,get:function(){return Hr.nil}});Object.defineProperty(ie,"Name",{enumerable:!0,get:function(){return Hr.Name}});Object.defineProperty(ie,"CodeGen",{enumerable:!0,get:function(){return Hr.CodeGen}});var gE=Qs();Object.defineProperty(ie,"ValidationError",{enumerable:!0,get:function(){return gE.default}});var yE=Wn();Object.defineProperty(ie,"MissingRefError",{enumerable:!0,get:function(){return yE.default}})});var M_=S(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.formatNames=wt.fastFormats=wt.fullFormats=void 0;function _t(e,t){return{validate:e,compare:t}}wt.fullFormats={date:_t(N_,sl),time:_t(nl(!0),il),"date-time":_t(R_(!0),D_),"iso-time":_t(nl(),j_),"iso-date-time":_t(R_(),Z_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:kE,"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:TE,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:xE,int32:{type:"number",validate:PE},int64:{type:"number",validate:IE},float:{type:"number",validate:C_},double:{type:"number",validate:C_},password:!0,binary:!0};wt.fastFormats={...wt.fullFormats,date:_t(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,sl),time:_t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,il),"date-time":_t(/^\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,D_),"iso-time":_t(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,j_),"iso-date-time":_t(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Z_),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};wt.formatNames=Object.keys(wt.fullFormats);function _E(e){return e%4===0&&(e%100!==0||e%400===0)}var wE=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,bE=[0,31,28,31,30,31,30,31,31,30,31,30,31];function N_(e){let t=wE.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&_E(r)?29:bE[n])}function sl(e,t){if(e&&t)return e>t?1:e<t?-1:0}var rl=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function nl(e){return function(r){let n=rl.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||e&&!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 il(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function j_(e,t){if(!(e&&t))return;let r=rl.exec(e),n=rl.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var ol=/t|\s/i;function R_(e){let t=nl(e);return function(n){let o=n.split(ol);return o.length===2&&N_(o[0])&&t(o[1])}}function D_(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function Z_(e,t){if(!(e&&t))return;let[r,n]=e.split(ol),[o,s]=t.split(ol),i=sl(r,o);if(i!==void 0)return i||il(n,s)}var vE=/\/|:/,$E=/^(?:[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 kE(e){return vE.test(e)&&$E.test(e)}var A_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function xE(e){return A_.lastIndex=0,A_.test(e)}var SE=-(2**31),zE=2**31-1;function PE(e){return Number.isInteger(e)&&e<=zE&&e>=SE}function IE(e){return Number.isInteger(e)}function C_(){return!0}var EE=/[^\\]\\Z/;function TE(e){if(EE.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var q_=S(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Kr.formatLimitDefinition=void 0;var OE=tl(),mt=q(),Wt=mt.operators,xi={formatMaximum:{okStr:"<=",ok:Wt.LTE,fail:Wt.GT},formatMinimum:{okStr:">=",ok:Wt.GTE,fail:Wt.LT},formatExclusiveMaximum:{okStr:"<",ok:Wt.LT,fail:Wt.GTE},formatExclusiveMinimum:{okStr:">",ok:Wt.GT,fail:Wt.LTE}},RE={message:({keyword:e,schemaCode:t})=>(0,mt.str)`should be ${xi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,mt._)`{comparison: ${xi[e].okStr}, limit: ${t}}`};Kr.formatLimitDefinition={keyword:Object.keys(xi),type:"string",schemaType:"string",$data:!0,error:RE,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new OE.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=t.const("fmt",(0,mt._)`${f}[${c.schemaCode}]`);e.fail$data((0,mt.or)((0,mt._)`typeof ${p} != "object"`,(0,mt._)`${p} instanceof RegExp`,(0,mt._)`typeof ${p}.compare != "function"`,d(p)))}function l(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${o}": format "${f}" does not define "compare" function`);let m=t.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,mt._)`${i.code.formats}${(0,mt.getProperty)(f)}`:void 0});e.fail$data(d(m))}function d(f){return(0,mt._)`${f}.compare(${r}, ${n}) ${xi[o].fail} 0`}},dependencies:["format"]};var AE=e=>(e.addKeyword(Kr.formatLimitDefinition),e);Kr.default=AE});var V_=S((fo,U_)=>{"use strict";Object.defineProperty(fo,"__esModule",{value:!0});var Jr=M_(),CE=q_(),al=q(),F_=new al.Name("fullFormats"),NE=new al.Name("fastFormats"),cl=(e,t={keywords:!0})=>{if(Array.isArray(t))return L_(e,t,Jr.fullFormats,F_),e;let[r,n]=t.mode==="fast"?[Jr.fastFormats,NE]:[Jr.fullFormats,F_],o=t.formats||Jr.formatNames;return L_(e,o,r,n),t.keywords&&(0,CE.default)(e),e};cl.get=(e,t="full")=>{let n=(t==="fast"?Jr.fastFormats:Jr.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function L_(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,al._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}U_.exports=fo=cl;Object.defineProperty(fo,"__esModule",{value:!0});fo.default=cl});import{existsSync as pO}from"node:fs";import{homedir as Ww}from"node:os";import{isAbsolute as mO,join as Ci,sep as hO}from"node:path";import{fileURLToPath as gO}from"node:url";import hh from"node:process";var C={};Sl(C,{BIGINT_FORMAT_RANGES:()=>xo,CONSTANT_CATCH:()=>Dl,Class:()=>Zi,NUMBER_FORMAT_RANGES:()=>tn,aborted:()=>at,allowsEval:()=>Ui,assert:()=>cb,assertEqual:()=>nb,assertIs:()=>ib,assertNever:()=>ab,assertNotEqual:()=>ob,assignProp:()=>He,attachSchema:()=>rn,base64ToUint8Array:()=>Nl,base64urlToUint8Array:()=>Pb,cached:()=>br,captureStackTrace:()=>$o,cleanEnum:()=>zb,cleanRegex:()=>en,clone:()=>it,cloneDef:()=>db,codePointLength:()=>nn,constantCatch:()=>Zl,createTransparentProxy:()=>yb,defineLazy:()=>Il,defineLazyInternal:()=>G,derived:()=>Ob,esc:()=>Fi,escapeRegex:()=>$t,explicitlyAborted:()=>Hi,extend:()=>bb,finalizeIssue:()=>ct,floatSafeRemainder:()=>qi,getElementAtPath:()=>fb,getEnumValues:()=>_r,getLengthableOrigin:()=>on,getParsedType:()=>gb,getSizableOrigin:()=>Cl,hexToUint8Array:()=>Eb,hide:()=>Po,installLazyProp:()=>Nb,isObject:()=>Xt,isPlainObject:()=>Ct,issue:()=>$r,joinValues:()=>vo,jsonStringifyReplacer:()=>wr,members:()=>Ji,merge:()=>$b,mergeDefs:()=>vt,normalizeParams:()=>A,nullish:()=>Mi,numKeys:()=>hb,objectClone:()=>ub,omit:()=>wb,optionalKeys:()=>Bi,own:()=>At,parsedType:()=>Ki,partial:()=>kb,pick:()=>_b,prefixIssues:()=>kt,primitiveTypes:()=>Rl,promiseAllObject:()=>pb,propertyKeyTypes:()=>Vi,randomString:()=>mb,rawShape:()=>vr,required:()=>xb,safeExtend:()=>vb,shallowClone:()=>Ol,sizeCaps:()=>zo,slugify:()=>Li,stringifyPrimitive:()=>ko,toZod:()=>sb,uint8ArrayToBase64:()=>jl,uint8ArrayToBase64url:()=>Ib,uint8ArrayToHex:()=>Tb,unwrapMessage:()=>yr});function nb(e){return e}function ob(e){return e}function sb(){return e=>e}function ib(e){}function ab(e){throw new Error("Unexpected value in exhaustive check")}function cb(e){}function _r(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function vo(e,t="|"){return e.map(r=>ko(r)).join(t)}function wr(e,t){return typeof t=="bigint"?t.toString():t}var Di=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function br(e){return new Di(e)}function Mi(e){return e==null}function en(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function qi(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var Pl=Symbol("evaluating");function Il(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Pl)return n===void 0&&(n=Pl,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ub(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function He(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function vr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function bt(e){return vr(e._zod.def)??e._zod.def.shape}function El(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return He(this,t,n),n},enumerable:!0,configurable:!0})}function Tl(e,t,r){t in e?He(e,t,r):e[t]=r}function Yt(e,t,r,n){let o=bt(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?El(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):Tl(e,s,n?n(i.value,s):i.value))}}function lb(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?El(e,r,()=>t[r]):Tl(e,r,n.value))}}function vt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function db(e){return vt(e._zod.def)}function fb(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function pb(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function mb(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Fi(e){return JSON.stringify(e)}function Li(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var $o="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Xt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Ui=br(()=>{if(Ze.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Ct(e){if(Xt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Xt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Ol(e){return Ct(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function hb(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var gb=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},Vi=new Set(["string","number","symbol"]),Rl=new Set(["string","number","bigint","boolean","symbol","undefined"]);function $t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function it(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function A(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function yb(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function ko(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Bi(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var tn={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]},xo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function _b(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return Yt(s,e,So(e,t)),it(e,vt(r,{shape:s,checks:[]}))}function So(e,t){let r=bt(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function wb(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(So(e,t)),i={};return Yt(i,e,Reflect.ownKeys(bt(e)).filter(a=>!s.has(a))),it(e,vt(r,{shape:i,checks:[]}))}function bb(e,t){if(!Ct(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=bt(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return it(e,vt(e._zod.def,{shape:Al(e,t)}))}function Al(e,t){let r={};return Yt(r,e,Reflect.ownKeys(bt(e))),lb(r,t),r}function vb(e,t){if(!Ct(t))throw new Error("Invalid input to safeExtend: expected a plain object");return it(e,vt(e._zod.def,{shape:Al(e,t)}))}function $b(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};Yt(r,e,Reflect.ownKeys(bt(e))),Yt(r,t,Reflect.ownKeys(bt(t)));let n=vt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return it(e,n)}function kb(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(So(t,r)):void 0,c={};return Yt(c,t,Reflect.ownKeys(bt(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),it(t,vt(t._zod.def,{shape:c,checks:[]}))}function xb(e,t,r){let n=r?new Set(So(t,r)):void 0,o={};return Yt(o,t,Reflect.ownKeys(bt(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),it(t,vt(t._zod.def,{shape:o}))}function at(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function Hi(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function kt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function yr(e){return typeof e=="string"?e:e?.message}function zo(e){let t=[];for(let r of e??[]){let n=r._zod.def;if(!/_(length|size)$|_equals$/.test(n.check))break;let o=n.maximum??n.length??n.size;o>=0&&t.push([o,r])}return t}function rn(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function ct(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:yr(e.inst?._zod.def?.error?.(e))??yr(s?.(e))??yr(t?.error?.(e))??yr(r.customError?.(e))??yr(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function Cl(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var Sb=/[\uD800-\uDBFF]/;function nn(e){let t=e.length;if(!Sb.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function on(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Ki(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function $r(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function zb(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Nl(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function jl(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Pb(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Nl(t+r)}function Ib(e){return jl(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Eb(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function Tb(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Zi=class{constructor(...t){}};function Ji(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Rb(e,r,n.value)}}function At(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function Po(e,t,r){return At(e,t,r,!1)}function Ob(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return At(this,r,n(this))},set(o){At(this,r,o)}})}return t}function Rb(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:At(this,t,r.bind(this))},set(n){At(this,t,n)}})}function Ab(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var ji,Rt=!1,Cb={configurable:!0,get(){Rt=!0}};function G(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&ji!==e._zod){ji=void 0;return}ji=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Cb);let o=Rt;Rt=!1;try{let s=r(this);return Rt?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Rt=Rt||o,s}catch(s){throw delete this[t],Rt=Rt||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Nb(e,t,r,n){let o=Ab(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var Dl="~constantCatch";function Zl(e){let t=()=>e;return t[Dl]=!0,t}var Ml;var Gi={value:void 0,enumerable:!1},ql="captureStackTrace"in Error?Error:null;function jb(e){let t=ql;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return ql=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function b(e,t,r,n){let o={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{Gi.value=new s(p);try{Object.defineProperty(f,"_zod",Gi)}finally{Gi.value=void 0}}if(f._zod.traits.add(e),t(f,p),a){let h=Object.getPrototypeOf(f),g=f._zod.constr.prototype,y=h;for(;y&&y!==g;)y=Object.getPrototypeOf(y);let v=y??h;a.has(v)||(a.add(v),Ji(v,i))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in f||(f[h]=m[h].bind(f)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let p=n?.Parent?jb(l):this;c(p,f);let m=p._zod.deferred;if(m){for(let g of m)g();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var ut=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},kr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Ml=globalThis).__zod_globalConfig??(Ml.__zod_globalConfig={});var Ze=globalThis.__zod_globalConfig;function Ke(e){return e&&Object.assign(Ze,e),Ze}function Db(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,wr,2)),e.message}function Zb(e){this._zod.message=e}var Mb={get:Db,set:Zb,enumerable:!0,configurable:!0},Yi={value:void 0,enumerable:!1},Fl=new WeakSet([Object.prototype,Error.prototype]),Ll=(e,t)=>{e.name="$ZodError",Yi.value=t,Object.defineProperty(e,"issues",Yi),Yi.value=void 0,Object.defineProperty(e,"message",Mb);let r=Object.getPrototypeOf(e);Fl.has(r)||(Fl.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},Ul=b("$ZodError",Ll),Vl=b("$ZodError",Ll,void 0,{Parent:Error});function qb(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Bl(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?qb(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Hl(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[l];d&&f._errors.push(t(i)),c=f,u++}}}};return n(e),r}function Io(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Eo=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ut;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ct(u,i,Ke())));throw $o(c,s?.callee??t),c}return a.value};return t};var To=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ct(u,i,Ke())));throw $o(c,s?.callee??t),c}return a.value};return t};var sn=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ut;return s.issues.length?Kl(e,s.issues,o):{success:!0,data:s.value}},Xi=sn(Vl);function Kl(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>ct(o,r,Ke()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var Oo=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?Kl(e,s.issues,o):{success:!0,data:s.value}};var Lb=Symbol.for("zod.compile.invalid"),Ub=Symbol.for("zod.compile.fallback"),Ro=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Lb)return!0;if(n.definite===!0&&r===void 0)return!1}return Vb(e,t,r)});function Vb(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[Ub]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new ut;return s.issues.length===0}var Ao=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Jl=e=>{let t=Eo(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Io(r,i))};return r};var Gl=e=>{let t=Eo(e),r=(n,o,s,i)=>t(n,o,s,Io(r,i));return r};var Wl=e=>{let t=To(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Io(r,i))};return r};var Yl=e=>{let t=To(e),r=async(n,o,s,i)=>await t(n,o,s,Io(r,i));return r};var Xl=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return sn(e)(t,r,o)};var Ql=e=>(t,r,n)=>sn(e)(t,r,n);var ed=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Oo(e)(t,r,o)};var td=e=>async(t,r,n)=>Oo(e)(t,r,n);var rd=/^[cC][0-9a-z]{6,}$/,nd=/^[0-9a-z]+$/,od=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,sd=/^[0-9a-vA-V]{20}$/,id=/^[A-Za-z0-9]{27}$/,ad=/^[a-zA-Z0-9_-]{21}$/;function cd(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var ud=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ld=/^([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})$/,ea=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[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|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var dd=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Bb="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function fd(){return new RegExp(Bb,"u")}var pd=/^(?:(?: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])$/,md=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;var hd=/^((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])$/,gd=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,yd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,_d=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var wd=/^https?$/,bd=/^\+[1-9]\d{6,14}$/;var vd="(?:(?:\\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])))";function Hb(e){return new RegExp(`^${e}$`)}var $d=Hb(vd);function Qi(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function kd(e){return new RegExp(`^${Qi(e)}$`)}function xd(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Qi({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Qi({precision:e.precision})}`:r;return new RegExp(`^${vd}T(?:${n})$`)}var Sd=/^[\s\S]{0,}$/;var ta=/^-?\d+$/,an=/^-?\d+(?:\.\d+)?$/,zd=/^(?:true|false)$/i,Pd=/^null$/i;var Id=/^[^A-Z]*$/,Ed=/^[^a-z]*$/;var _e=b("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var ra=e=>{let t=e.value;return!Mi(t)&&t.length!==void 0},Co={number:"number",bigint:"bigint",object:"date"},na=b("$ZodCheckLessThan",(e,t)=>{_e.init(e,t);let r=Co[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:Co[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),oa=b("$ZodCheckGreaterThan",(e,t)=>{_e.init(e,t);let r=Co[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:Co[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Td=b("$ZodCheckMultipleOf",(e,t)=>{_e.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):qi(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Od=b("$ZodCheckNumberFormat",(e,t)=>{_e.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=tn[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});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:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Rd=b("$ZodCheckMaxLength",(e,t)=>{var r;_e.init(e,t),(r=e._zod.def).when??(r.when=ra),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?nn(o):s)<=t.maximum)return;let a=on(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ad=b("$ZodCheckMinLength",(e,t)=>{var r;_e.init(e,t),(r=e._zod.def).when??(r.when=ra),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?nn(o):s)>=t.minimum)return;let a=on(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Cd=b("$ZodCheckLengthEquals",(e,t)=>{var r;_e.init(e,t),(r=e._zod.def).when??(r.when=ra),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?nn(o):s;if(i===t.length)return;let a=on(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),un=b("$ZodCheckStringFormat",(e,t)=>{var r,n;_e.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Nd=b("$ZodCheckRegex",(e,t)=>{un.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),jd=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Id),un.init(e,t)}),Dd=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Ed),un.init(e,t)}),Zd=b("$ZodCheckIncludes",(e,t)=>{_e.init(e,t);let r=$t(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Md=b("$ZodCheckStartsWith",(e,t)=>{_e.init(e,t);let r=new RegExp(`^${$t(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),qd=b("$ZodCheckEndsWith",(e,t)=>{_e.init(e,t);let r=new RegExp(`.*${$t(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Fd=b("$ZodCheckOverwrite",(e,t)=>{_e.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var No=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
|
|
11
11
|
`).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 t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
|
|
12
12
|
${r.join(`
|
|
13
13
|
`)}
|
|
14
|
-
};`)(...Object.values(this.closed))}};var Pd={major:4,minor:6,patch:7};var G=_("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pd;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=Ke(a),d;for(let f of c){if(f._zod.def.when){if(Ai(a)||!f._zod.def.when(a))continue}else if(l)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new We;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(Hr(a.issues,p,e),l||(l=Ke(a,p)))});else{if(a.issues.length===p)continue;Hr(a.issues,p,e),l||(l=Ke(a,p))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(Ke(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new We;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new We;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return yo(this,"~standard",Ji(this))},set"~standard"(e){wt(this,"~standard",e)}}),Zd=(e,t)=>e.issues.length?{issues:e.issues.map(r=>Ge(r,t,Ae()))}:{value:e.value};async function wb(e,t){let r={async:!0};return Zd(await e._zod.run({value:t,issues:[]},r),r)}function Ji(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Zd(n,r)}catch{}return wb(e,t)},vendor:"zod",version:1}}var Io=_("$ZodString",(e,t)=>{G.init(e,t),e._zod.pattern=t.pattern??ud,e._zod.parse=(r,n)=>{if(t.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:e}),r}}),W=_("$ZodStringFormat",(e,t)=>{Yr.init(e,t),Io.init(e,t)}),Md=_("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Kl),W.init(e,t)}),qd=_("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Fi(n))}else t.pattern??(t.pattern=Fi());W.init(e,t)}),Fd=_("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Gl),W.init(e,t)}),Ld=1,Po=2;function Ud(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function bb(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Ud(e)||Po:vb(e,t)}function vb(e,t){if(!t.normalize&&t.protocol?.source===nd.source&&!/^https?:\/\//i.test(e))return Ld;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Po}return new URL(e)}catch{return Po}}var $b=/[\t\n\r]/g;function Ed(e){return e.replace($b,"")}function xb(e,t){return t.lastIndex=0,t.test(e.hostname)}function Sb(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Vd=_("$ZodURL",(e,t)=>{W.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=bb(n,t);if(o===Ld){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Po){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Ed(n);return}t.hostname&&!xb(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!Sb(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:Ed(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Hd=_("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Wl()),W.init(e,t)}),Bd=_("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Hl:Bl(t.length)),W.init(e,t)}),Jd=_("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ql),W.init(e,t)}),Kd=_("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Fl),W.init(e,t)}),Gd=_("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Ll),W.init(e,t)}),Wd=_("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ul),W.init(e,t)}),Yd=_("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Vl),W.init(e,t)}),Xd=_("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=cd(t)),W.init(e,t)}),Qd=_("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=id),W.init(e,t)}),ef=_("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ad(t)),W.init(e,t)}),tf=_("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Jl),W.init(e,t)}),rf=_("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Yl),W.init(e,t)}),kb=/^[0-9a-fA-F:.]+$/;function nf(e){return kb.test(e)?Ud(`http://[${e}]`):!1}var of=_("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xl),W.init(e,t),e._zod.check=r=>{nf(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var sf=_("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Ql),W.init(e,t)});function zb(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:nf(r)}var af=_("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ed),W.init(e,t),e._zod.check=r=>{zb(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function cf(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ki=/^[0-9a-zA-Z+/]*={0,2}$/,uf=_("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ki),W.init(e,t),e._zod.check=r=>{cf(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),To=/^[A-Za-z0-9_-]*$/;function Pb(e){if(!To.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return cf(r)}var lf=_("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=To),W.init(e,t),e._zod.check=r=>{Pb(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),df=_("$ZodE164",(e,t)=>{t.pattern??(t.pattern=od),W.init(e,t)});function Eb(e,t=null){try{let r=e.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||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var ff=_("$ZodJWT",(e,t)=>{W.init(e,t),e._zod.check=r=>{Eb(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Gi=_("$ZodNumber",(e,t)=>{G.init(e,t),e._zod.pattern=Gr,e._zod.parse=(r,n)=>{if(t.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:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),pf=_("$ZodNumberFormat",(e,t)=>{hd.init(e,t),Gi.init(e,t)}),mf=_("$ZodBoolean",(e,t)=>{G.init(e,t),e._zod.pattern=ld,e._zod.parse=(r,n)=>{if(t.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:e}),r}});var hf=_("$ZodNull",(e,t)=>{G.init(e,t),e._zod.pattern=dd,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var gf=_("$ZodUnknown",(e,t)=>{G.init(e,t),e._zod.parse=r=>r}),yf=_("$ZodNever",(e,t)=>{G.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Ib(e,t){let r=go(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map(s=>s[0])),o=e._zod.parse;e._zod.parse=(s,i)=>{let a=t(s.value);if(a>n&&!i?.skipChecks&&i?.direction!=="backward"){for(let[c,u]of go(e._zod.def.checks))if(a>c&&u._zod.def.when(s)){let l=s.issues.length;return u._zod.check(s),s.issues[l].continue=!1,Hr(s.issues,l,e),s}}return o(s,i)}}var Tb=e=>Array.isArray(e)?e.length:-1;function Id(e,t,r){e.issues.length&&t.issues.push(...dt(r,e.issues)),t.value[r]=e.value}var _f=_("$ZodArray",(e,t)=>{G.init(e,t);let r=Se.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Id(d,n,c)));else if(Id(l,n,c),a&&l.issues.length!==0&&Ke(l))break}return i.length?Promise.all(i).then(()=>n):n},Ib(e,Tb)});function Eo(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...dt(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var Ob=[];function wf(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:Ob,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=Ri(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function bf(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout,p=0;for(let m in t){if(i&&r.issues.length!==p){if(Ke(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){l==="never"&&a.push(m);continue}if(l==="never"){a.push(m);continue}let h=u.run({value:t[m],issues:[]},n);h instanceof Promise?e.push(h.then(g=>Eo(g,r,m,t,d,f))):Eo(h,r,m,t,d,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var Rb=_("$ZodObject",(e,t)=>{G.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=lr(()=>wf(t));U(e,"propValues",u=>{let l=u.def.shape,d={};for(let f in l){let p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||Re(d,f,new Set);for(let m of p.values)d[f].add(m);p.optin!==void 0&&d[f].add(void 0)}}return d});let s=Mt,i=t.catchall,a,c=Se.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let f=[],p=a.shape,m=l?.abortEarly,h=u.issues.length;for(let g of a.allKeys){if(m&&u.issues.length!==h){if(Ke(u,h))break;h=u.issues.length}if(g==="__proto__")continue;let w=p[g],v=w._zod.optin,$=w._zod.optout,O=w._zod.run({value:d[g],issues:[]},l);O instanceof Promise?f.push(O.then(k=>Eo(k,u,g,d,v,$))):Eo(O,u,g,d,v,$)}return i?bf(f,d,u,l,o.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),vf=_("$ZodObjectJIT",(e,t)=>{Rb.init(e,t);let r=e._zod.parse,n=lr(()=>wf(t)),o=Se.memoizer,s=p=>{let m=n.value,h=m.symbolKeys,g=new ko(["payload","ctx"],{shape:p,inst:e,memo:o,syms:h}),w=k=>`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`,v=(k,N)=>`
|
|
15
|
-
let ${
|
|
16
|
-
for (let i = 0; i < ${
|
|
17
|
-
const iss = ${
|
|
18
|
-
iss.path = iss.path ? [${
|
|
14
|
+
};`)(...Object.values(this.closed))}};var Ud={major:4,minor:6,patch:7};var re=b("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ud;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=at(a),d;for(let f of c){if(f._zod.def.when){if(Hi(a)||!f._zod.def.when(a))continue}else if(l)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new ut;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(rn(a.issues,p,e),l||(l=at(a,p)))});else{if(a.issues.length===p)continue;rn(a.issues,p,e),l||(l=at(a,p))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(at(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ut;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ut;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return Po(this,"~standard",ia(this))},set"~standard"(e){At(this,"~standard",e)}}),ef=(e,t)=>e.issues.length?{issues:e.issues.map(r=>ct(r,t,Ke()))}:{value:e.value};async function Kb(e,t){let r={async:!0};return ef(await e._zod.run({value:t,issues:[]},r),r)}function ia(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return ef(n,r)}catch{}return Kb(e,t)},vendor:"zod",version:1}}var Mo=b("$ZodString",(e,t)=>{re.init(e,t),e._zod.pattern=t.pattern??Sd,e._zod.parse=(r,n)=>{if(t.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:e}),r}}),ne=b("$ZodStringFormat",(e,t)=>{un.init(e,t),Mo.init(e,t)}),tf=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ld),ne.init(e,t)}),rf=b("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ea(n))}else t.pattern??(t.pattern=ea());ne.init(e,t)}),nf=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=dd),ne.init(e,t)}),of=1,Do=2;function sf(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Jb(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?sf(e)||Do:Gb(e,t)}function Gb(e,t){if(!t.normalize&&t.protocol?.source===wd.source&&!/^https?:\/\//i.test(e))return of;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Do}return new URL(e)}catch{return Do}}var Wb=/[\t\n\r]/g;function Vd(e){return e.replace(Wb,"")}function Yb(e,t){return t.lastIndex=0,t.test(e.hostname)}function Xb(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var af=b("$ZodURL",(e,t)=>{ne.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=Jb(n,t);if(o===of){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Do){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Vd(n);return}t.hostname&&!Yb(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!Xb(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:Vd(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),cf=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=fd()),ne.init(e,t)}),uf=b("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?ad:cd(t.length)),ne.init(e,t)}),lf=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=rd),ne.init(e,t)}),df=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=nd),ne.init(e,t)}),ff=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=od),ne.init(e,t)}),pf=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=sd),ne.init(e,t)}),mf=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=id),ne.init(e,t)}),hf=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=xd(t)),ne.init(e,t)}),gf=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=$d),ne.init(e,t)}),yf=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=kd(t)),ne.init(e,t)}),_f=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=ud),ne.init(e,t)}),wf=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=pd),ne.init(e,t)}),Qb=/^[0-9a-fA-F:.]+$/;function bf(e){return Qb.test(e)?sf(`http://[${e}]`):!1}var vf=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=md),ne.init(e,t),e._zod.check=r=>{bf(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var $f=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=hd),ne.init(e,t)});function e0(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:bf(r)}var kf=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=gd),ne.init(e,t),e._zod.check=r=>{e0(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function xf(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var aa=/^[0-9a-zA-Z+/]*={0,2}$/,Sf=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=aa),ne.init(e,t),e._zod.check=r=>{xf(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),qo=/^[A-Za-z0-9_-]*$/;function t0(e){if(!qo.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return xf(r)}var zf=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=qo),ne.init(e,t),e._zod.check=r=>{t0(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Pf=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=bd),ne.init(e,t)});function r0(e,t=null){try{let r=e.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||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var If=b("$ZodJWT",(e,t)=>{ne.init(e,t),e._zod.check=r=>{r0(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var ca=b("$ZodNumber",(e,t)=>{re.init(e,t),e._zod.pattern=an,e._zod.parse=(r,n)=>{if(t.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:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),Ef=b("$ZodNumberFormat",(e,t)=>{Od.init(e,t),ca.init(e,t)}),Tf=b("$ZodBoolean",(e,t)=>{re.init(e,t),e._zod.pattern=zd,e._zod.parse=(r,n)=>{if(t.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:e}),r}});var Of=b("$ZodNull",(e,t)=>{re.init(e,t),e._zod.pattern=Pd,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var Rf=b("$ZodUnknown",(e,t)=>{re.init(e,t),e._zod.parse=r=>r}),Af=b("$ZodNever",(e,t)=>{re.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function n0(e,t){let r=zo(e._zod.def.checks);if(!r.length)return;let n=Math.min(...r.map(s=>s[0])),o=e._zod.parse;e._zod.parse=(s,i)=>{let a=t(s.value);if(a>n&&!i?.skipChecks&&i?.direction!=="backward"){for(let[c,u]of zo(e._zod.def.checks))if(a>c&&u._zod.def.when(s)){let l=s.issues.length;return u._zod.check(s),s.issues[l].continue=!1,rn(s.issues,l,e),s}}return o(s,i)}}var o0=e=>Array.isArray(e)?e.length:-1;function Bd(e,t,r){e.issues.length&&t.issues.push(...kt(r,e.issues)),t.value[r]=e.value}var Cf=b("$ZodArray",(e,t)=>{re.init(e,t);let r=Ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Bd(d,n,c)));else if(Bd(l,n,c),a&&l.issues.length!==0&&at(l))break}return i.length?Promise.all(i).then(()=>n):n},n0(e,o0)});function Zo(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...kt(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var s0=[];function Nf(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:s0,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=Bi(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function jf(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout,p=0;for(let m in t){if(i&&r.issues.length!==p){if(at(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){l==="never"&&a.push(m);continue}if(l==="never"){a.push(m);continue}let h=u.run({value:t[m],issues:[]},n);h instanceof Promise?e.push(h.then(g=>Zo(g,r,m,t,d,f))):Zo(h,r,m,t,d,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var i0=b("$ZodObject",(e,t)=>{re.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=br(()=>Nf(t));G(e,"propValues",u=>{let l=u.def.shape,d={};for(let f in l){let p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||He(d,f,new Set);for(let m of p.values)d[f].add(m);p.optin!==void 0&&d[f].add(void 0)}}return d});let s=Xt,i=t.catchall,a,c=Ze.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let f=[],p=a.shape,m=l?.abortEarly,h=u.issues.length;for(let g of a.allKeys){if(m&&u.issues.length!==h){if(at(u,h))break;h=u.issues.length}if(g==="__proto__")continue;let y=p[g],v=y._zod.optin,$=y._zod.optout,I=y._zod.run({value:d[g],issues:[]},l);I instanceof Promise?f.push(I.then(x=>Zo(x,u,g,d,v,$))):Zo(I,u,g,d,v,$)}return i?jf(f,d,u,l,o.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),Df=b("$ZodObjectJIT",(e,t)=>{i0.init(e,t);let r=e._zod.parse,n=br(()=>Nf(t)),o=Ze.memoizer,s=p=>{let m=n.value,h=m.symbolKeys,g=new No(["payload","ctx"],{shape:p,inst:e,memo:o,syms:h}),y=x=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,v=(x,R)=>`
|
|
15
|
+
let ${x}_ab = false;
|
|
16
|
+
for (let i = 0; i < ${x}.issues.length; i++) {
|
|
17
|
+
const iss = ${x}.issues[i];
|
|
18
|
+
iss.path = iss.path ? [${R}, ...iss.path] : [${R}];
|
|
19
19
|
payload.issues.push(iss);
|
|
20
|
-
if (iss.continue !== true) ${
|
|
20
|
+
if (iss.continue !== true) ${x}_ab = true;
|
|
21
21
|
}
|
|
22
|
-
if (${
|
|
22
|
+
if (${x}_ab && ctx && ctx.abortEarly) {
|
|
23
23
|
payload.value = newResult;
|
|
24
24
|
return payload;
|
|
25
|
-
}`;g.write("const input = payload.value;");let $=Object.create(null),
|
|
26
|
-
const ${
|
|
27
|
-
if (!${
|
|
28
|
-
if (${
|
|
25
|
+
}`;g.write("const input = payload.value;");let $=Object.create(null),I=0;for(let x of m.allKeys)$[x]=`key_${I++}`;g.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let x of m.allKeys){if(x==="__proto__")continue;let R=$[x],k=typeof x=="symbol"?`syms[${h.indexOf(x)}]`:Fi(x),E=`${k} in input`,M=p[x],P=M?._zod?.optin,U=P!==void 0,te=M?._zod?.optout==="optional";if(g.write(`const ${R} = ${y(k)};`),U&&te){let ae=P==="optional"?`${R}_present`:`${R}.value !== undefined || ${R}_present`;g.write(`
|
|
26
|
+
const ${R}_present = ${E};
|
|
27
|
+
if (!${R}.issues.length || ${R}_present) {
|
|
28
|
+
if (${R}.issues.length) {${v(R,k)}
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
if (${
|
|
32
|
-
newResult[${
|
|
31
|
+
if (${ae}) {
|
|
32
|
+
newResult[${k}] = ${R}.value;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
`)}else
|
|
37
|
-
if (${
|
|
36
|
+
`)}else U?(g.write(`
|
|
37
|
+
if (${R}.issues.length) {${v(R,k)}
|
|
38
38
|
}
|
|
39
|
-
`),
|
|
40
|
-
if (${
|
|
41
|
-
newResult[${
|
|
39
|
+
`),P==="defaulted"?g.write(`newResult[${k}] = ${R}.value;`):g.write(`
|
|
40
|
+
if (${R}.value !== undefined || ${E}) {
|
|
41
|
+
newResult[${k}] = ${R}.value;
|
|
42
42
|
}
|
|
43
43
|
`)):g.write(`
|
|
44
|
-
const ${
|
|
45
|
-
if (${
|
|
44
|
+
const ${R}_present = ${E};
|
|
45
|
+
if (${R}.issues.length) {${v(R,k)}
|
|
46
46
|
}
|
|
47
|
-
if (!${
|
|
47
|
+
if (!${R}_present && !${R}.issues.length) {
|
|
48
48
|
payload.issues.push({
|
|
49
49
|
code: "invalid_type",
|
|
50
50
|
expected: "nonoptional",
|
|
51
51
|
input: undefined,
|
|
52
|
-
path: [${
|
|
52
|
+
path: [${k}]
|
|
53
53
|
});
|
|
54
54
|
if (ctx && ctx.abortEarly) {
|
|
55
55
|
payload.value = newResult;
|
|
@@ -57,48 +57,49 @@ ${r.join(`
|
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
if (${
|
|
61
|
-
newResult[${
|
|
60
|
+
if (${R}_present) {
|
|
61
|
+
newResult[${k}] = ${R}.value;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,a=Mt,c=!Se.jitless,l=c&&Ti.value,d=t.catchall,f;e._zod.parse=(p,m)=>{f??(f=n.value);let h=p.value;return a(h)?c&&l&&m?.async===!1&&m.jitless!==!0?(i||(i=s(t.shape)),p=i(p,m),d?bf([],h,p,m,f,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p)}});function Td(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!Ke(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>Ge(i,n,Ae())))}),t)}var Wi=_("$ZodUnion",(e,t)=>{G.init(e,t),U(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),U(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),U(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),U(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>Ur(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>Td(a,n,e,o)):Td(i,n,e,o)}});function Ab(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var $f=_("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Wi.init(e,t);let r=e._zod.parse;U(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||Re(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=dr(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=lr(()=>Ab(t));e._zod.parse=(o,s)=>{let i=o.value;if(!Mt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),xf=_("$ZodIntersection",(e,t)=>{G.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Od(r,c,u)):Od(r,s,i)}});function Bi(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(bt(e)&&bt(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Bi(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=Bi(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 Od(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);s.has(f)||s.set(f,u),d=[f]}else return!1;for(let f of d)n.has(f)||n.set(f,{}),n.get(f)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=Bi(t.value,r.value);if(!c.valid){if(Ke(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Sf=_("$ZodRecord",(e,t)=>{G.init(e,t);let r=Se.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!bt(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>Ge(m,o,Ae())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...dt(l,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...dt(l,p.issues)),n.value[f]=p.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&Gr.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(l=m)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>Ge(m,o,Ae())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[u],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...dt(u,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...dt(u,p.issues)),n.value[f]=p.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var kf=_("$ZodEnum",(e,t)=>{G.init(e,t);let r=cr(t.entries),n=new Set(r);e._zod.values=n,U(e,"pattern",o=>{let s=cr(o.def.entries).filter(i=>Oi.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>lt(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),zf=_("$ZodLiteral",(e,t)=>{G.init(e,t);let r=new Set(t.values);e._zod.values=r,U(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?lt(s):s?lt(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Pf=_("$ZodTransform",(e,t)=>{G.init(e,t),e._zod.optin="optional",Se.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new pr(e.constructor.name);let o=t.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 We;return r.value=o,r}});function Rd(e,t){return e.value=t.issues.length?void 0:t.value,e}var Yi=_("$ZodOptional",(e,t)=>{G.init(e,t),U(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",U(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),U(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ur(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Rd(r,s)):Rd(r,o)}return t.innerType._zod.run(r,n)}}),Ef=_("$ZodExactOptional",(e,t)=>{Yi.init(e,t),U(e,"values",r=>r.def.innerType._zod.values),U(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),If=_("$ZodNullable",(e,t)=>{G.init(e,t),U(e,"optin",r=>r.def.innerType._zod.optin),U(e,"optout",r=>r.def.innerType._zod.optout),U(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Ur(n.source)}|null)$`):void 0}),U(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Tf=_("$ZodDefault",(e,t)=>{G.init(e,t),e._zod.optin="defaulted",U(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Ad(s,t)):Ad(o,t)}});function Ad(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Of=_("$ZodPrefault",(e,t)=>{G.init(e,t),e._zod.optin="defaulted",U(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Rf=_("$ZodNonOptional",(e,t)=>{G.init(e,t),U(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Cd(s,e)):Cd(o,e)}});function Cd(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Nd(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Ge(o,n,Ae()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Af=_("$ZodCatch",(e,t)=>{G.init(e,t),U(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),U(e,"optout",r=>r.def.innerType._zod.optout),U(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Nd(r,s,t,n)):Nd(r,o,t,n)}});var Xi=_("$ZodPipe",(e,t)=>{G.init(e,t),U(e,"values",r=>r.def.in._zod.values),U(e,"optin",r=>r.def.in._zod.optin),U(e,"optout",r=>r.def.out._zod.optout),U(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>zo(i,t.in,n)):zo(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>zo(s,t.out,n)):zo(o,t.out,n)}});function zo(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Cf=_("$ZodPreprocess",(e,t)=>{Xi.init(e,t)}),Nf=_("$ZodReadonly",(e,t)=>{G.init(e,t),U(e,"propValues",r=>r.def.innerType._zod.propValues),U(e,"values",r=>r.def.innerType._zod.values),U(e,"optin",r=>r.def.innerType?._zod?.optin),U(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(jd):jd(o)}});function jd(e){return e.memo||(e.value=Object.freeze(e.value)),e}var jf=_("$ZodCustom",(e,t)=>{le.init(e,t),G.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Dd(s,r,n,e));Dd(o,r,n,e)}});function Dd(e,t,r,n){if(!e){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),t.issues.push(fr(o))}}var ea=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ta="~memo",Df=[];function Zf(e){return e!==null&&typeof e=="object"}function Qi(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var Mf=new WeakMap,Xr=0,Ao=1,Qr=2;function Co(e,t,r){let n=Mf.get(e);if(n!==void 0)return n?Qr:Xr;if(t.has(e))return Qr;t.add(e);let o=Xr,s=l=>{if(o!==Qr&&l?._zod){let d=Co(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let f=Xr;for(let p of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,p);if(d&&!m.enumerable)continue;let h=m.get?Ao:m.value?._zod?Co(m.value,t,r):Xr;h>f&&(f=h)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=dr(c);a(l?i(l,!0):Ao),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?Co(l,t,!1):Ao);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)s(f);else if(Array.isArray(f))for(let p of f)s(p)}}}return t.delete(e),Cb(e,o)}function Cb(e,t){return t!==Ao&&Mf.set(e,t===Qr),t}function Nb(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var Oo,Ro=[],jb={alloc(e,t,r){let n=Oo;if(!n)return r;Oo=void 0;let o={value:r,issues:null};return n.set(t.value,o),Ro.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&Db(s,o.value))throw new ea;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let w=Co(e,new Set,!1);if(w===Xr)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);w===Qr||n?r=!0:n=!0}let l=c.value;if(!Zf(l))return i(c,u);let d=u[ta];d||(d={buckets:new WeakMap,backEdges:void 0},u[ta]=d);let f;o===u?f=s:(f=Nb(d,e),o=u,s=f);let p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...Qi(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;Oo=f;let m=Ro.length,h=i(c,u);Oo=void 0;let g=Ro.length>m?Ro.pop():void 0;return h instanceof Promise?h.then(w=>(g&&(g.issues=w.issues.length?Qi(w.issues):Df),w)):(g&&(g.issues=h.issues.length?Qi(h.issues):Df),h)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function qf(){return jb}function Db(e,t){let r=e[ta]?.backEdges;return r!==void 0&&Zf(t)&&r.has(t)}var Zb=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??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",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=Ci(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${po(s.values[0])}`:`Invalid option: expected one of ${lo(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${lo(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Ff(){return{localeError:Zb()}}var Lf;var ra=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function Mb(){return new ra}(Lf=globalThis).__zod_globalRegistry??(Lf.__zod_globalRegistry=Mb());var qt=globalThis.__zod_globalRegistry;function Uf(e){return e.checks&&(e.checks=[...e.checks]),e}function Vf(e,t){return new e(Uf({type:"string",...E(t)}))}function Hf(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...E(t)})}function Bf(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...E(t)})}function Jf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...E(t)})}function Kf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...E(t)})}function Gf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...E(t)})}function Wf(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...E(t)})}function Yf(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...E(t)})}function Xf(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...E(t)})}function Qf(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...E(t)})}function ep(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...E(t)})}function tp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...E(t)})}function rp(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...E(t)})}function np(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...E(t)})}function op(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...E(t)})}function sp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...E(t)})}function ip(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...E(t)})}function ap(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...E(t)})}function cp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...E(t)})}function up(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...E(t)})}function lp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...E(t)})}function dp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...E(t)})}function fp(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...E(t)})}function No(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...E(t)})}function jo(e,t){return new e({type:"string",format:"date",check:"string_format",...E(t)})}function Do(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...E(t)})}function Zo(e,t){return new e({type:"string",format:"duration",check:"string_format",...E(t)})}function pp(e,t){return new e(Uf({type:"number",checks:[],...E(t)}))}function mp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...E(t)})}function hp(e,t){return new e({type:"boolean",...E(t)})}function gp(e,t){return new e({type:"null",...E(t)})}function yp(e){return new e({type:"unknown"})}function _p(e,t){return new e({type:"never",...E(t)})}function Mo(e,t){return new Vi({check:"less_than",...E(t),value:e,inclusive:!1})}function en(e,t){return new Vi({check:"less_than",...E(t),value:e,inclusive:!0})}function qo(e,t){return new Hi({check:"greater_than",...E(t),value:e,inclusive:!1})}function tn(e,t){return new Hi({check:"greater_than",...E(t),value:e,inclusive:!0})}function Fo(e,t){return new md({check:"multiple_of",...E(t),value:e})}function Lo(e,t){return new gd({check:"max_length",...E(t),maximum:e})}function mr(e,t){return new yd({check:"min_length",...E(t),minimum:e})}function Uo(e,t){return new _d({check:"length_equals",...E(t),length:e})}function na(e,t){return new wd({check:"string_format",format:"regex",...E(t),pattern:e})}function oa(e){return new bd({check:"string_format",format:"lowercase",...E(e)})}function sa(e){return new vd({check:"string_format",format:"uppercase",...E(e)})}function ia(e,t){return new $d({check:"string_format",format:"includes",...E(t),includes:e})}function aa(e,t){return new xd({check:"string_format",format:"starts_with",...E(t),prefix:e})}function ca(e,t){return new Sd({check:"string_format",format:"ends_with",...E(t),suffix:e})}function vt(e){return new kd({check:"overwrite",tx:e})}function ua(e){return vt(t=>t.normalize(e))}function la(){return vt(e=>e.trim())}function da(){return vt(e=>e.toLowerCase())}function fa(){return vt(e=>e.toUpperCase())}function pa(){return vt(e=>Ii(e))}function wp(e,t,r){return new e({type:"array",element:t,...E(r)})}function bp(e,t,r){let n=E(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function vp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...E(r)})}function $p(e,t){let r=qb(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(fr(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(fr(s))}},e(n.value,n)),t);return r}function qb(e,t){let r=new le({check:"custom",...E(t)});return r._zod.check=e,r}function rn(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&Re(e,n,r[n]);return e}function ha(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??qt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ft(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function ie(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),ie(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&rn(i.schema,c),t.io==="input"&&be(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function xp(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ga(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${xp(p)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+xp(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
64
|
+
`)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,a=Xt,c=!Ze.jitless,l=c&&Ui.value,d=t.catchall,f;e._zod.parse=(p,m)=>{f??(f=n.value);let h=p.value;return a(h)?c&&l&&m?.async===!1&&m.jitless!==!0?(i||(i=s(t.shape)),p=i(p,m),d?jf([],h,p,m,f,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p)}});function Hd(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!at(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>ct(i,n,Ke())))}),t)}var ua=b("$ZodUnion",(e,t)=>{re.init(e,t),G(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),G(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),G(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),G(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>en(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>Hd(a,n,e,o)):Hd(i,n,e,o)}});function a0(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var Zf=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,ua.init(e,t);let r=e._zod.parse;G(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||He(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=vr(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=br(()=>a0(t));e._zod.parse=(o,s)=>{let i=o.value;if(!Xt(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),Mf=b("$ZodIntersection",(e,t)=>{re.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Kd(r,c,u)):Kd(r,s,i)}});function sa(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Ct(e)&&Ct(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=sa(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=sa(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 Kd(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);s.has(f)||s.set(f,u),d=[f]}else return!1;for(let f of d)n.has(f)||n.set(f,{}),n.get(f)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=sa(t.value,r.value);if(!c.valid){if(at(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var qf=b("$ZodRecord",(e,t)=>{re.init(e,t);let r=Ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Ct(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>ct(m,o,Ke())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...kt(l,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...kt(l,p.issues)),n.value[f]=p.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&an.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(l=m)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>ct(m,o,Ke())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[u],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...kt(u,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...kt(u,p.issues)),n.value[f]=p.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var Ff=b("$ZodEnum",(e,t)=>{re.init(e,t);let r=_r(t.entries),n=new Set(r);e._zod.values=n,G(e,"pattern",o=>{let s=_r(o.def.entries).filter(i=>Vi.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>$t(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),Lf=b("$ZodLiteral",(e,t)=>{re.init(e,t);let r=new Set(t.values);e._zod.values=r,G(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?$t(s):s?$t(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Uf=b("$ZodTransform",(e,t)=>{re.init(e,t),e._zod.optin="optional",Ze.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new kr(e.constructor.name);let o=t.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 ut;return r.value=o,r}});function Jd(e,t){return e.value=t.issues.length?void 0:t.value,e}var la=b("$ZodOptional",(e,t)=>{re.init(e,t),G(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",G(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),G(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${en(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Jd(r,s)):Jd(r,o)}return t.innerType._zod.run(r,n)}}),Vf=b("$ZodExactOptional",(e,t)=>{la.init(e,t),G(e,"values",r=>r.def.innerType._zod.values),G(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Bf=b("$ZodNullable",(e,t)=>{re.init(e,t),G(e,"optin",r=>r.def.innerType._zod.optin),G(e,"optout",r=>r.def.innerType._zod.optout),G(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${en(n.source)}|null)$`):void 0}),G(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Hf=b("$ZodDefault",(e,t)=>{re.init(e,t),e._zod.optin="defaulted",G(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Gd(s,t)):Gd(o,t)}});function Gd(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Kf=b("$ZodPrefault",(e,t)=>{re.init(e,t),e._zod.optin="defaulted",G(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Jf=b("$ZodNonOptional",(e,t)=>{re.init(e,t),G(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Wd(s,e)):Wd(o,e)}});function Wd(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Yd(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>ct(o,n,Ke()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Gf=b("$ZodCatch",(e,t)=>{re.init(e,t),G(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),G(e,"optout",r=>r.def.innerType._zod.optout),G(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Yd(r,s,t,n)):Yd(r,o,t,n)}});var da=b("$ZodPipe",(e,t)=>{re.init(e,t),G(e,"values",r=>r.def.in._zod.values),G(e,"optin",r=>r.def.in._zod.optin),G(e,"optout",r=>r.def.out._zod.optout),G(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>jo(i,t.in,n)):jo(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>jo(s,t.out,n)):jo(o,t.out,n)}});function jo(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Wf=b("$ZodPreprocess",(e,t)=>{da.init(e,t)}),Yf=b("$ZodReadonly",(e,t)=>{re.init(e,t),G(e,"propValues",r=>r.def.innerType._zod.propValues),G(e,"values",r=>r.def.innerType._zod.values),G(e,"optin",r=>r.def.innerType?._zod?.optin),G(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Xd):Xd(o)}});function Xd(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Xf=b("$ZodCustom",(e,t)=>{_e.init(e,t),re.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Qd(s,r,n,e));Qd(o,r,n,e)}});function Qd(e,t,r,n){if(!e){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),t.issues.push($r(o))}}var pa=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ma="~memo",Qf=[];function ep(e){return e!==null&&typeof e=="object"}function fa(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var tp=new WeakMap,ln=0,Uo=1,dn=2;function Vo(e,t,r){let n=tp.get(e);if(n!==void 0)return n?dn:ln;if(t.has(e))return dn;t.add(e);let o=ln,s=l=>{if(o!==dn&&l?._zod){let d=Vo(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let f=ln;for(let p of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,p);if(d&&!m.enumerable)continue;let h=m.get?Uo:m.value?._zod?Vo(m.value,t,r):ln;h>f&&(f=h)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=vr(c);a(l?i(l,!0):Uo),s(c.catchall);break}case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?Vo(l,t,!1):Uo);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)s(f);else if(Array.isArray(f))for(let p of f)s(p)}}}return t.delete(e),c0(e,o)}function c0(e,t){return t!==Uo&&tp.set(e,t===dn),t}function u0(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var Fo,Lo=[],l0={alloc(e,t,r){let n=Fo;if(!n)return r;Fo=void 0;let o={value:r,issues:null};return n.set(t.value,o),Lo.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&d0(s,o.value))throw new pa;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let y=Vo(e,new Set,!1);if(y===ln)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);y===dn||n?r=!0:n=!0}let l=c.value;if(!ep(l))return i(c,u);let d=u[ma];d||(d={buckets:new WeakMap,backEdges:void 0},u[ma]=d);let f;o===u?f=s:(f=u0(d,e),o=u,s=f);let p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...fa(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;Fo=f;let m=Lo.length,h=i(c,u);Fo=void 0;let g=Lo.length>m?Lo.pop():void 0;return h instanceof Promise?h.then(y=>(g&&(g.issues=y.issues.length?fa(y.issues):Qf),y)):(g&&(g.issues=h.issues.length?fa(h.issues):Qf),h)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function rp(){return l0}function d0(e,t){let r=e[ma]?.backEdges;return r!==void 0&&ep(t)&&r.has(t)}var f0=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??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",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=Ki(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${ko(s.values[0])}`:`Invalid option: expected one of ${vo(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${vo(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function np(){return{localeError:f0()}}var op;var ha=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function p0(){return new ha}(op=globalThis).__zod_globalRegistry??(op.__zod_globalRegistry=p0());var Qt=globalThis.__zod_globalRegistry;function sp(e){return e.checks&&(e.checks=[...e.checks]),e}function ip(e,t){return new e(sp({type:"string",...A(t)}))}function ap(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...A(t)})}function cp(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...A(t)})}function up(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...A(t)})}function lp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...A(t)})}function dp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...A(t)})}function fp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...A(t)})}function pp(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...A(t)})}function mp(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...A(t)})}function hp(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...A(t)})}function gp(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...A(t)})}function yp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...A(t)})}function _p(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...A(t)})}function wp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...A(t)})}function bp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...A(t)})}function vp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...A(t)})}function $p(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...A(t)})}function kp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...A(t)})}function xp(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...A(t)})}function Sp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...A(t)})}function zp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...A(t)})}function Pp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...A(t)})}function Ip(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...A(t)})}function Bo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...A(t)})}function Ho(e,t){return new e({type:"string",format:"date",check:"string_format",...A(t)})}function Ko(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...A(t)})}function Jo(e,t){return new e({type:"string",format:"duration",check:"string_format",...A(t)})}function Ep(e,t){return new e(sp({type:"number",checks:[],...A(t)}))}function Tp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...A(t)})}function Op(e,t){return new e({type:"boolean",...A(t)})}function Rp(e,t){return new e({type:"null",...A(t)})}function Ap(e){return new e({type:"unknown"})}function Cp(e,t){return new e({type:"never",...A(t)})}function Go(e,t){return new na({check:"less_than",...A(t),value:e,inclusive:!1})}function fn(e,t){return new na({check:"less_than",...A(t),value:e,inclusive:!0})}function Wo(e,t){return new oa({check:"greater_than",...A(t),value:e,inclusive:!1})}function pn(e,t){return new oa({check:"greater_than",...A(t),value:e,inclusive:!0})}function Yo(e,t){return new Td({check:"multiple_of",...A(t),value:e})}function Xo(e,t){return new Rd({check:"max_length",...A(t),maximum:e})}function xr(e,t){return new Ad({check:"min_length",...A(t),minimum:e})}function Qo(e,t){return new Cd({check:"length_equals",...A(t),length:e})}function ga(e,t){return new Nd({check:"string_format",format:"regex",...A(t),pattern:e})}function ya(e){return new jd({check:"string_format",format:"lowercase",...A(e)})}function _a(e){return new Dd({check:"string_format",format:"uppercase",...A(e)})}function wa(e,t){return new Zd({check:"string_format",format:"includes",...A(t),includes:e})}function ba(e,t){return new Md({check:"string_format",format:"starts_with",...A(t),prefix:e})}function va(e,t){return new qd({check:"string_format",format:"ends_with",...A(t),suffix:e})}function Nt(e){return new Fd({check:"overwrite",tx:e})}function $a(e){return Nt(t=>t.normalize(e))}function ka(){return Nt(e=>e.trim())}function xa(){return Nt(e=>e.toLowerCase())}function Sa(){return Nt(e=>e.toUpperCase())}function za(){return Nt(e=>Li(e))}function Np(e,t,r){return new e({type:"array",element:t,...A(r)})}function jp(e,t,r){let n=A(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Dp(e,t,r){return new e({type:"custom",check:"custom",fn:t,...A(r)})}function Zp(e,t){let r=m0(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push($r(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push($r(s))}},e(n.value,n)),t);return r}function m0(e,t){let r=new _e({check:"custom",...A(t)});return r._zod.check=e,r}function mn(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&He(e,n,r[n]);return e}function Ia(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??Qt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function xt(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function pe(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),pe(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&mn(i.schema,c),t.io==="input"&&Ae(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Mp(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Ea(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${Mp(p)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Mp(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
65
65
|
|
|
66
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function zp(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;zp(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Pp=new Set(["type","properties","required","additionalProperties"]),Sp=["oneOf","anyOf"];function kp(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function ma(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Pp.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??kp(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:ma(a)??{allOf:a};Re(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=kp(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function Fb(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Pp)if(o in e)return;let r=t.filter(o=>Sp.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=ma(t);else{let o=r[0],s=Sp.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>ma([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,rn(e,n))}function ya(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):rn(u,m),rn(u,l),a._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(m.$ref&&p.def)for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())zp(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])Fb(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}rn(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Re(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:nn(t,"input",e.processors),output:nn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function be(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return be(n.element,r);if(n.type==="set")return be(n.valueType,r);if(n.type==="lazy")return be(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return be(n.innerType,r);if(n.type==="intersection")return be(n.left,r)||be(n.right,r);if(n.type==="record"||n.type==="map")return be(n.keyType,r)||be(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:be(n.in,r)||be(n.out,r);if(n.type==="object"){for(let o in n.shape)if(be(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(be(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(be(o,r))return!0;return!!(n.rest&&be(n.rest,r))}return!1}var Ep=(e,t={})=>r=>{let n=ha({...r,processors:t});return ie(e,n),ga(n,e),ya(n,e)},nn=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=ha({...o??{},target:s,io:t,processors:r});return ie(e,i),ga(i,e),ya(i,e)};var hr=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},gr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Ip=(e,t)=>{hr(e,"minimum",t),gr(e,"maximum",t)},Ap=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Cp=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Np=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},jp=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Tp=(e,t)=>hr(e,"minimum",t.minimum),Op=(e,t)=>gr(e,"maximum",t.maximum),Rp=e=>(t,r)=>{jp(t,r.format);let[n,o]=e[r.format];hr(t,"minimum",n),gr(t,"maximum",o)},Lb={greater_than:(e,t)=>hr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>gr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Ap(e,t.value),number_format:Rp(Vr),bigint_format:Rp(mo),min_length:Tp,max_length:Op,length_equals:(e,t)=>Ip(e,t.length),min_size:Tp,max_size:Op,size_equals:(e,t)=>Ip(e,t.size),string_format:(e,t)=>{jp(e,t.format),t.pattern&&Cp(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Np(e,t.mime)};function je(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)Lb[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&hr(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&hr(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&gr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&gr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Ap(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Np(t,o.mime);for(let s of o.patterns??[])Cp(t,s);return t}var Ub={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Vb=new Map([[Ki,td],[To,rd]]),Dp=e=>Vb.get(e)??e,Zp=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=je(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=Ub[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(Dp);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Mp=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=je(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),f?p?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let m=new Set;for(let w of a)Number.isFinite(w)&&w!==0?m.add(Math.abs(w)):ft(e,t,o,n,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(o.multipleOf=h),g.length&&(o.allOf=[...o.allOf??[],...g.map(w=>({multipleOf:w}))])}},qp=(e,t,r,n)=>{r.type="boolean"};var Fp=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Lp=(e,t,r,n)=>{r.not={}};var Up=(e,t,r,n)=>{};var Vp=(e,t,r,n)=>{let o=e._zod.def,s=cr(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},Hp=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(ft(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(ft(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var Bp=(e,t,r,n)=>{ft(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var Jp=(e,t,r,n)=>{ft(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var Kp=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=je(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ie(s.element,t,{...n,path:[...n.path,"items"]})};function Vo(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Vo(t.out):t.type==="catch"?Vo(t.innerType):e._zod.optin}var Gp=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&ft(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)Re(o.properties,u,ie(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];(t.io==="input"?Vo(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ie(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},Wp=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ie(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},Yp=(e,t,r,n)=>{let o=e._zod.def,s=ie(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=ie(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function _a(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let h=_a(e,m,r);return h===m?t:h}for(let m of["anyOf","oneOf"]){let h=t[m];if(!Array.isArray(h))continue;let g=h.map(w=>_a(e,w,r));g.some((w,v)=>w!==h[v])&&(t={...t,[m]:g})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(m=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(m=>typeof m=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(m=>typeof m=="number"?String(m):m):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",s||(p.pattern=(n.includes("number")?Gr:Li).source)),p}var wa=new WeakMap;function Hb(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of wa.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=_a(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var Xp=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=je(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=ie(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)Re(o.patternProperties,Dp(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=ie(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=wa.get(t);l||(l=[],wa.set(t,l),t.deferred.push(()=>Hb(t))),l.push(e)}o.additionalProperties=ie(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&Vo(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},Qp=(e,t,r,n)=>{let o=e._zod.def,s=ie(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},em=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},ba=Symbol();function tm(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(ft(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),ba):JSON.parse(i)}var rm=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=tm(o.defaultValue,e,t,r,n);i!==ba&&(r.default=i)},nm=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=tm(o.defaultValue,e,t,r,n);i!==ba&&(r._prefault=i)},om=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{ft(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},sm=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;ie(i,t,n);let a=t.seen.get(e);a.ref=i},im=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var va=(e,t,r,n)=>{let o=e._zod.def;ie(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var am=new WeakSet([Object.prototype,Error.prototype]);function Ho(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var ev=(e,t)=>{Pl.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);am.has(r)||(am.add(r),Ho(r,"format",n=>o=>Tl(n,o)),Ho(r,"flatten",n=>o=>Il(n,o)),Ho(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,ur,2)}),Ho(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,ur,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Ce=_("ZodError",ev,void 0,{Parent:Error});var cm=wo(Ce),um=bo(Ce),lm=Kr(Ce),dm=vo(Ce),fm=Rl(Ce),pm=Al(Ce),mm=Cl(Ce),hm=Nl(Ce),gm=jl(Ce),ym=Dl(Ce),_m=Zl(Ce),wm=Ml(Ce);function rv(){Se.localeError||Ae(Ff())}function Jo(){Se.memoizer||Ae({memoizer:qf()})}var re=_("ZodType",(e,t)=>(rv(),G.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(I.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return Je(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Hv(e,t))},superRefine(e,t){return this.check(Bv(e,t))},overwrite(e){return this.check(vt(e))},optional(){return te(this)},exactOptional(){return Av(this)},nullable(){return $m(this)},nullish(){return te($m(this))},nonoptional(e){return Mv(this,e)},array(){return M(this)},or(e){return Y([this,e])},and(e){return Ko(this,e)},transform(e){return xm(this,Im(e))},default(e){return jv(this,e)},prefault(e){return Zv(this,e)},catch(e){return Fv(this,e)},pipe(e){return xm(this,e)},readonly(){return Vv(this)},describe(e){let t=this.clone();return qt.add(t,{description:e}),t},meta(...e){if(e.length===0)return qt.get(this);let t=this.clone();return qt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return I.hide(this,"~standard",{...Ji(this),jsonSchema:{input:nn(this,"input"),output:nn(this,"output")}})},set"~standard"(e){I.own(this,"~standard",e)},parse:function e(t,r){return cm(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await um(this,t,r,{callee:e})},safeParse(e,t){return lm(this,e,t)},async safeParseAsync(e,t){return dm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){I.own(this,"spa",e)},validate(e,t){return $o(this,e,t)},validateAsync(e,t){return xo(this,e,t)},encode:function e(t,r){return fm(this,t,r,{callee:e})},decode:function e(t,r){return pm(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await mm(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await hm(this,t,r,{callee:e})},safeEncode(e,t){return gm(this,e,t)},safeDecode(e,t){return ym(this,e,t)},async safeEncodeAsync(e,t){return _m(this,e,t)},async safeDecodeAsync(e,t){return wm(this,e,t)},toJSONSchema(e){return Ep(this,{})(e)},get description(){return qt.get(this)?.description},get _def(){return this._zod.def}}),Sm=_("_ZodString",(e,t)=>{Io.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Zp(e,r,n,o)},I.derived({format:e=>je(e).format??null,minLength:e=>je(e).minimum??null,maxLength:e=>je(e).maximum??null},{regex(...e){return this.check(na(...e))},includes(...e){return this.check(ia(...e))},startsWith(...e){return this.check(aa(...e))},endsWith(...e){return this.check(ca(...e))},min(...e){return this.check(mr(...e))},max(...e){return this.check(Lo(...e))},length(...e){return this.check(Uo(...e))},nonempty(...e){return this.check(mr(1,...e))},lowercase(e){return this.check(oa(e))},uppercase(e){return this.check(sa(e))},trim(){return this.check(la())},normalize(...e){return this.check(ua(...e))},toLowerCase(){return this.check(da())},toUpperCase(){return this.check(fa())},slugify(){return this.check(pa())}})),nv=_("ZodString",(e,t)=>{Io.init(e,t),Sm.init(e,t)},{email(e){return this.check(Hf(ov,e))},url(e){return this.check(Yf(iv,e))},jwt(e){return this.check(fp(vv,e))},emoji(e){return this.check(Xf(av,e))},guid(e){return this.check(Bf(sv,e))},uuid(e){return this.check(Jf(Bo,e))},uuidv4(e){return this.check(Kf(Bo,e))},uuidv6(e){return this.check(Gf(Bo,e))},uuidv7(e){return this.check(Wf(Bo,e))},nanoid(e){return this.check(Qf(cv,e))},cuid(e){return this.check(ep(uv,e))},cuid2(e){return this.check(tp(lv,e))},ulid(e){return this.check(rp(dv,e))},base64(e){return this.check(up(_v,e))},base64url(e){return this.check(lp(wv,e))},xid(e){return this.check(np(fv,e))},ksuid(e){return this.check(op(pv,e))},ipv4(e){return this.check(sp(mv,e))},ipv6(e){return this.check(ip(hv,e))},cidrv4(e){return this.check(ap(gv,e))},cidrv6(e){return this.check(cp(yv,e))},e164(e){return this.check(dp(bv,e))},datetime(e){return this.check(No(sn,e))},date(e){return this.check(jo(an,e))},time(e){return this.check(Do(cn,e))},duration(e){return this.check(Zo(un,e))}});function y(e){return Vf(nv,e)}var ne=_("ZodStringFormat",(e,t)=>{W.init(e,t),Sm.init(e,t)}),sn=_("ZodISODateTime",(e,t)=>{Xd.init(e,t),ne.init(e,t)}),an=_("ZodISODate",(e,t)=>{Qd.init(e,t),ne.init(e,t)}),cn=_("ZodISOTime",(e,t)=>{ef.init(e,t),ne.init(e,t)}),un=_("ZodISODuration",(e,t)=>{tf.init(e,t),ne.init(e,t)}),ov=_("ZodEmail",(e,t)=>{Fd.init(e,t),ne.init(e,t)});var sv=_("ZodGUID",(e,t)=>{Md.init(e,t),ne.init(e,t)});var Bo=_("ZodUUID",(e,t)=>{qd.init(e,t),ne.init(e,t)});var iv=_("ZodURL",(e,t)=>{Vd.init(e,t),ne.init(e,t)});var av=_("ZodEmoji",(e,t)=>{Hd.init(e,t),ne.init(e,t)});var cv=_("ZodNanoID",(e,t)=>{Bd.init(e,t),ne.init(e,t)});var uv=_("ZodCUID",(e,t)=>{Jd.init(e,t),ne.init(e,t)});var lv=_("ZodCUID2",(e,t)=>{Kd.init(e,t),ne.init(e,t)});var dv=_("ZodULID",(e,t)=>{Gd.init(e,t),ne.init(e,t)});var fv=_("ZodXID",(e,t)=>{Wd.init(e,t),ne.init(e,t)});var pv=_("ZodKSUID",(e,t)=>{Yd.init(e,t),ne.init(e,t)});var mv=_("ZodIPv4",(e,t)=>{rf.init(e,t),ne.init(e,t)});var hv=_("ZodIPv6",(e,t)=>{of.init(e,t),ne.init(e,t)});var gv=_("ZodCIDRv4",(e,t)=>{sf.init(e,t),ne.init(e,t)});var yv=_("ZodCIDRv6",(e,t)=>{af.init(e,t),ne.init(e,t)});var _v=_("ZodBase64",(e,t)=>{uf.init(e,t),ne.init(e,t)});var wv=_("ZodBase64URL",(e,t)=>{lf.init(e,t),ne.init(e,t)});var bv=_("ZodE164",(e,t)=>{df.init(e,t),ne.init(e,t)});var vv=_("ZodJWT",(e,t)=>{ff.init(e,t),ne.init(e,t)});var km=_("ZodNumber",(e,t)=>{Gi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Mp(e,r,n,o),e.isFinite=!0},I.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=je(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=je(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=je(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>je(e).format??null},{gt(e,t){return this.check(qo(e,t))},gte(e,t){return this.check(tn(e,t))},min(e,t){return this.check(tn(e,t))},lt(e,t){return this.check(Mo(e,t))},lte(e,t){return this.check(en(e,t))},max(e,t){return this.check(en(e,t))},int(e){return this.check(bm(e))},safe(e){return this.check(bm(e))},positive(e){return this.check(qo(0,e))},nonnegative(e){return this.check(tn(0,e))},negative(e){return this.check(Mo(0,e))},nonpositive(e){return this.check(en(0,e))},multipleOf(e,t){return this.check(Fo(e,t))},step(e,t){return this.check(Fo(e,t))},finite(){return this}}));function H(e){return pp(km,e)}var $v=_("ZodNumberFormat",(e,t)=>{pf.init(e,t),km.init(e,t)});function bm(e){return mp($v,e)}var xv=_("ZodBoolean",(e,t)=>{mf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>qp(e,r,n,o)});function ue(e){return hp(xv,e)}var Sv=_("ZodNull",(e,t)=>{hf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Fp(e,r,n,o)});function zm(e){return gp(Sv,e)}var kv=_("ZodUnknown",(e,t)=>{gf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Up(e,r,n,o)});function ee(){return yp(kv)}var zv=_("ZodNever",(e,t)=>{yf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Lp(e,r,n,o)});function Pv(e){return _p(zv,e)}var Ev=_("ZodArray",(e,t)=>{Jo(),_f.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Kp(e,r,n,o),e.element=t.element},{min(e,t){return this.check(mr(e,t))},nonempty(e){return this.check(mr(1,e))},max(e,t){return this.check(Lo(e,t))},length(e,t){return this.check(Uo(e,t))},unwrap(){return this.element}});function M(e,t){return wp(Ev,e,t)}var Pm=_("ZodObject",(e,t)=>{Jo(),vf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gp(e,r,n,o),I.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return ke(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(I.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(I.mergeDefs(this._zod.def,{catchall:ee()}))},loose(){return this.clone(I.mergeDefs(this._zod.def,{catchall:ee()}))},strict(){return this.clone(I.mergeDefs(this._zod.def,{catchall:Pv()}))},strip(){return this.clone(I.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return I.extend(this,e)},safeExtend(e){return I.safeExtend(this,e)},merge(e){return I.merge(this,e)},pick(e){return I.pick(this,e)},omit(e){return I.omit(this,e)},partial(...e){return I.partial(Tm,this,e[0])},exactPartial(...e){return I.partial(Om,this,e[0],"exactPartial")},required(...e){return I.required(Rm,this,e[0])}});function S(e,t){let r={type:"object",shape:e??{},...I.normalizeParams(t)};return new Pm(r)}function ve(e,t){return new Pm({type:"object",shape:e,catchall:ee(),...I.normalizeParams(t)})}var Em=_("ZodUnion",(e,t)=>{Wi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wp(e,r,n,o),e.options=t.options});function Y(e,t){return new Em({type:"union",options:e,...I.normalizeParams(t)})}var Iv=_("ZodDiscriminatedUnion",(e,t)=>{Em.init(e,t),$f.init(e,t)});function xa(e,t,r){return new Iv({type:"union",options:t,discriminator:e,...I.normalizeParams(r)})}var Tv=_("ZodIntersection",(e,t)=>{xf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yp(e,r,n,o)});function Ko(e,t){return new Tv({type:"intersection",left:e,right:t})}var vm=_("ZodRecord",(e,t)=>{Jo(),Sf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xp(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function K(e,t,r){return!t||!t._zod?new vm({type:"record",keyType:y(),valueType:e,...I.normalizeParams(t)}):new vm({type:"record",keyType:e,valueType:t,...I.normalizeParams(r)})}var $a=_("ZodEnum",(e,t)=>{kf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Vp(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new $a({...t,checks:[],...I.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.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 $a({...t,checks:[],...I.normalizeParams(o),entries:s})}});function ke(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new $a({type:"enum",entries:r,...I.normalizeParams(t)})}var Ov=_("ZodLiteral",(e,t)=>{zf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hp(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function z(e,t){return new Ov({type:"literal",values:Array.isArray(e)?e:[e],...I.normalizeParams(t)})}var Rv=_("ZodTransform",(e,t)=>{Jo(),Pf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jp(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new pr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(I.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(I.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Im(e){return new Rv({type:"transform",transform:e})}var Tm=_("ZodOptional",(e,t)=>{Yi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>va(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function te(e){return new Tm({type:"optional",innerType:e})}var Om=_("ZodExactOptional",(e,t)=>{Ef.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>va(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Av(e){return new Om({type:"optional",innerType:e})}var Cv=_("ZodNullable",(e,t)=>{If.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qp(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function $m(e){return new Cv({type:"nullable",innerType:e})}var Nv=_("ZodDefault",(e,t)=>{Tf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function jv(e,t){return new Nv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():I.shallowClone(t)}})}var Dv=_("ZodPrefault",(e,t)=>{Of.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Zv(e,t){return new Dv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():I.shallowClone(t)}})}var Rm=_("ZodNonOptional",(e,t)=>{Rf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>em(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Mv(e,t){return new Rm({type:"nonoptional",innerType:e,...I.normalizeParams(t)})}var qv=_("ZodCatch",(e,t)=>{Af.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>om(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Fv(e,t){return new qv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:I.constantCatch(t)})}var Am=_("ZodPipe",(e,t)=>{Xi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sm(e,r,n,o),e.in=t.in,e.out=t.out});function xm(e,t){return new Am({type:"pipe",in:e,out:t})}var Lv=_("ZodPreprocess",(e,t)=>{Am.init(e,t),Cf.init(e,t)}),Uv=_("ZodReadonly",(e,t)=>{Nf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>im(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Vv(e){return new Uv({type:"readonly",innerType:e})}var Cm=_("ZodCustom",(e,t)=>{jf.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bp(e,r,n,o)});function Nm(e,t){return bp(Cm,e??(()=>!0),t)}function Hv(e,t={}){return vp(Cm,e,t)}function Bv(e,t){return $p(e,t)}function Sa(e,t){return new Lv({type:"pipe",in:Im(e),out:t})}var Go={};ul(Go,{ZodISODate:()=>an,ZodISODateTime:()=>sn,ZodISODuration:()=>un,ZodISOTime:()=>cn,date:()=>Kv,datetime:()=>Jv,duration:()=>Wv,time:()=>Gv});function Jv(e){return No(sn,e)}function Kv(e){return jo(an,e)}function Gv(e){return Do(cn,e)}function Wv(e){return Zo(un,e)}var za="2025-11-25";var jm=[za,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],$t="io.modelcontextprotocol/related-task",Yo="2.0",ce=Nm(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Dm=Y([y(),H().int()]),Zm=y(),FR=ve({ttl:H().optional(),pollInterval:H().optional()}),Yv=S({ttl:H().optional()}),Xv=S({taskId:y()}),Pa=ve({progressToken:Dm.optional(),[$t]:Xv.optional()}),Ne=S({_meta:Pa.optional()}),ln=Ne.extend({task:Yv.optional()}),Mm=e=>ln.safeParse(e).success,de=S({method:y(),params:Ne.loose().optional()}),De=S({_meta:Pa.optional()}),Ze=S({method:y(),params:De.loose().optional()}),fe=ve({_meta:Pa.optional()}),Xo=Y([y(),H().int()]),qm=S({jsonrpc:z(Yo),id:Xo,...de.shape}).strict(),Ea=e=>qm.safeParse(e).success,Fm=S({jsonrpc:z(Yo),...Ze.shape}).strict(),Lm=e=>Fm.safeParse(e).success,Ia=S({jsonrpc:z(Yo),id:Xo,result:fe}).strict(),dn=e=>Ia.safeParse(e).success;var A;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(A||(A={}));var Ta=S({jsonrpc:z(Yo),id:Xo.optional(),error:S({code:H().int(),message:y(),data:ee().optional()})}).strict();var Um=e=>Ta.safeParse(e).success;var Vm=Y([qm,Fm,Ia,Ta]),LR=Y([Ia,Ta]),Qo=fe.strict(),Qv=De.extend({requestId:Xo.optional(),reason:y().optional()}),es=Ze.extend({method:z("notifications/cancelled"),params:Qv}),e0=S({src:y(),mimeType:y().optional(),sizes:M(y()).optional(),theme:ke(["light","dark"]).optional()}),fn=S({icons:M(e0).optional()}),yr=S({name:y(),title:y().optional()}),Hm=yr.extend({...yr.shape,...fn.shape,version:y(),websiteUrl:y().optional(),description:y().optional()}),t0=Ko(S({applyDefaults:ue().optional()}),K(y(),ee())),r0=Sa(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Ko(S({form:t0.optional(),url:ce.optional()}),K(y(),ee()).optional())),n0=ve({list:ce.optional(),cancel:ce.optional(),requests:ve({sampling:ve({createMessage:ce.optional()}).optional(),elicitation:ve({create:ce.optional()}).optional()}).optional()}),o0=ve({list:ce.optional(),cancel:ce.optional(),requests:ve({tools:ve({call:ce.optional()}).optional()}).optional()}),s0=S({experimental:K(y(),ce).optional(),sampling:S({context:ce.optional(),tools:ce.optional()}).optional(),elicitation:r0.optional(),roots:S({listChanged:ue().optional()}).optional(),tasks:n0.optional(),extensions:K(y(),ce).optional()}),i0=Ne.extend({protocolVersion:y(),capabilities:s0,clientInfo:Hm}),Oa=de.extend({method:z("initialize"),params:i0});var a0=S({experimental:K(y(),ce).optional(),logging:ce.optional(),completions:ce.optional(),prompts:S({listChanged:ue().optional()}).optional(),resources:S({subscribe:ue().optional(),listChanged:ue().optional()}).optional(),tools:S({listChanged:ue().optional()}).optional(),tasks:o0.optional(),extensions:K(y(),ce).optional()}),c0=fe.extend({protocolVersion:y(),capabilities:a0,serverInfo:Hm,instructions:y().optional()}),Ra=Ze.extend({method:z("notifications/initialized"),params:De.optional()});var ts=de.extend({method:z("ping"),params:Ne.optional()}),u0=S({progress:H(),total:te(H()),message:te(y())}),l0=S({...De.shape,...u0.shape,progressToken:Dm}),rs=Ze.extend({method:z("notifications/progress"),params:l0}),d0=Ne.extend({cursor:Zm.optional()}),pn=de.extend({params:d0.optional()}),mn=fe.extend({nextCursor:Zm.optional()}),f0=ke(["working","input_required","completed","failed","cancelled"]),hn=S({taskId:y(),status:f0,ttl:Y([H(),zm()]),createdAt:y(),lastUpdatedAt:y(),pollInterval:te(H()),statusMessage:te(y())}),_r=fe.extend({task:hn}),p0=De.merge(hn),gn=Ze.extend({method:z("notifications/tasks/status"),params:p0}),ns=de.extend({method:z("tasks/get"),params:Ne.extend({taskId:y()})}),os=fe.merge(hn),ss=de.extend({method:z("tasks/result"),params:Ne.extend({taskId:y()})}),UR=fe.loose(),is=pn.extend({method:z("tasks/list")}),as=mn.extend({tasks:M(hn)}),cs=de.extend({method:z("tasks/cancel"),params:Ne.extend({taskId:y()})}),Bm=fe.merge(hn),Jm=S({uri:y(),mimeType:te(y()),_meta:K(y(),ee()).optional()}),Km=Jm.extend({text:y()}),Aa=y().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Gm=Jm.extend({blob:Aa}),yn=ke(["user","assistant"]),wr=S({audience:M(yn).optional(),priority:H().min(0).max(1).optional(),lastModified:Go.datetime({offset:!0}).optional()}),Wm=S({...yr.shape,...fn.shape,uri:y(),description:te(y()),mimeType:te(y()),size:te(H()),annotations:wr.optional(),_meta:te(ve({}))}),m0=S({...yr.shape,...fn.shape,uriTemplate:y(),description:te(y()),mimeType:te(y()),annotations:wr.optional(),_meta:te(ve({}))}),h0=pn.extend({method:z("resources/list")}),g0=mn.extend({resources:M(Wm)}),y0=pn.extend({method:z("resources/templates/list")}),_0=mn.extend({resourceTemplates:M(m0)}),Ca=Ne.extend({uri:y()}),w0=Ca,b0=de.extend({method:z("resources/read"),params:w0}),v0=fe.extend({contents:M(Y([Km,Gm]))}),$0=Ze.extend({method:z("notifications/resources/list_changed"),params:De.optional()}),x0=Ca,S0=de.extend({method:z("resources/subscribe"),params:x0}),k0=Ca,z0=de.extend({method:z("resources/unsubscribe"),params:k0}),P0=De.extend({uri:y()}),E0=Ze.extend({method:z("notifications/resources/updated"),params:P0}),I0=S({name:y(),description:te(y()),required:te(ue())}),T0=S({...yr.shape,...fn.shape,description:te(y()),arguments:te(M(I0)),_meta:te(ve({}))}),O0=pn.extend({method:z("prompts/list")}),R0=mn.extend({prompts:M(T0)}),A0=Ne.extend({name:y(),arguments:K(y(),y()).optional()}),C0=de.extend({method:z("prompts/get"),params:A0}),Na=S({type:z("text"),text:y(),annotations:wr.optional(),_meta:K(y(),ee()).optional()}),ja=S({type:z("image"),data:Aa,mimeType:y(),annotations:wr.optional(),_meta:K(y(),ee()).optional()}),Da=S({type:z("audio"),data:Aa,mimeType:y(),annotations:wr.optional(),_meta:K(y(),ee()).optional()}),N0=S({type:z("tool_use"),name:y(),id:y(),input:K(y(),ee()),_meta:K(y(),ee()).optional()}),j0=S({type:z("resource"),resource:Y([Km,Gm]),annotations:wr.optional(),_meta:K(y(),ee()).optional()}),D0=Wm.extend({type:z("resource_link")}),Za=Y([Na,ja,Da,D0,j0]),Z0=S({role:yn,content:Za}),M0=fe.extend({description:y().optional(),messages:M(Z0)}),q0=Ze.extend({method:z("notifications/prompts/list_changed"),params:De.optional()}),F0=S({title:y().optional(),readOnlyHint:ue().optional(),destructiveHint:ue().optional(),idempotentHint:ue().optional(),openWorldHint:ue().optional()}),L0=S({taskSupport:ke(["required","optional","forbidden"]).optional()}),Ym=S({...yr.shape,...fn.shape,description:y().optional(),inputSchema:S({type:z("object"),properties:K(y(),ce).optional(),required:M(y()).optional()}).catchall(ee()),outputSchema:S({type:z("object"),properties:K(y(),ce).optional(),required:M(y()).optional()}).catchall(ee()).optional(),annotations:F0.optional(),execution:L0.optional(),_meta:K(y(),ee()).optional()}),Ma=pn.extend({method:z("tools/list")}),U0=mn.extend({tools:M(Ym)}),us=fe.extend({content:M(Za).default([]),structuredContent:K(y(),ee()).optional(),isError:ue().optional()}),VR=us.or(fe.extend({toolResult:ee()})),V0=ln.extend({name:y(),arguments:K(y(),ee()).optional()}),_n=de.extend({method:z("tools/call"),params:V0}),H0=Ze.extend({method:z("notifications/tools/list_changed"),params:De.optional()}),HR=S({autoRefresh:ue().default(!0),debounceMs:H().int().nonnegative().default(300)}),wn=ke(["debug","info","notice","warning","error","critical","alert","emergency"]),B0=Ne.extend({level:wn}),qa=de.extend({method:z("logging/setLevel"),params:B0}),J0=De.extend({level:wn,logger:y().optional(),data:ee()}),K0=Ze.extend({method:z("notifications/message"),params:J0}),G0=S({name:y().optional()}),W0=S({hints:M(G0).optional(),costPriority:H().min(0).max(1).optional(),speedPriority:H().min(0).max(1).optional(),intelligencePriority:H().min(0).max(1).optional()}),Y0=S({mode:ke(["auto","required","none"]).optional()}),X0=S({type:z("tool_result"),toolUseId:y().describe("The unique identifier for the corresponding tool call."),content:M(Za).default([]),structuredContent:S({}).loose().optional(),isError:ue().optional(),_meta:K(y(),ee()).optional()}),Q0=xa("type",[Na,ja,Da]),Wo=xa("type",[Na,ja,Da,N0,X0]),e$=S({role:yn,content:Y([Wo,M(Wo)]),_meta:K(y(),ee()).optional()}),t$=ln.extend({messages:M(e$),modelPreferences:W0.optional(),systemPrompt:y().optional(),includeContext:ke(["none","thisServer","allServers"]).optional(),temperature:H().optional(),maxTokens:H().int(),stopSequences:M(y()).optional(),metadata:ce.optional(),tools:M(Ym).optional(),toolChoice:Y0.optional()}),r$=de.extend({method:z("sampling/createMessage"),params:t$}),bn=fe.extend({model:y(),stopReason:te(ke(["endTurn","stopSequence","maxTokens"]).or(y())),role:yn,content:Q0}),Fa=fe.extend({model:y(),stopReason:te(ke(["endTurn","stopSequence","maxTokens","toolUse"]).or(y())),role:yn,content:Y([Wo,M(Wo)])}),n$=S({type:z("boolean"),title:y().optional(),description:y().optional(),default:ue().optional()}),o$=S({type:z("string"),title:y().optional(),description:y().optional(),minLength:H().optional(),maxLength:H().optional(),format:ke(["email","uri","date","date-time"]).optional(),default:y().optional()}),s$=S({type:ke(["number","integer"]),title:y().optional(),description:y().optional(),minimum:H().optional(),maximum:H().optional(),default:H().optional()}),i$=S({type:z("string"),title:y().optional(),description:y().optional(),enum:M(y()),default:y().optional()}),a$=S({type:z("string"),title:y().optional(),description:y().optional(),oneOf:M(S({const:y(),title:y()})),default:y().optional()}),c$=S({type:z("string"),title:y().optional(),description:y().optional(),enum:M(y()),enumNames:M(y()).optional(),default:y().optional()}),u$=Y([i$,a$]),l$=S({type:z("array"),title:y().optional(),description:y().optional(),minItems:H().optional(),maxItems:H().optional(),items:S({type:z("string"),enum:M(y())}),default:M(y()).optional()}),d$=S({type:z("array"),title:y().optional(),description:y().optional(),minItems:H().optional(),maxItems:H().optional(),items:S({anyOf:M(S({const:y(),title:y()}))}),default:M(y()).optional()}),f$=Y([l$,d$]),p$=Y([c$,u$,f$]),m$=Y([p$,n$,o$,s$]),h$=ln.extend({mode:z("form").optional(),message:y(),requestedSchema:S({type:z("object"),properties:K(y(),m$),required:M(y()).optional()})}),g$=ln.extend({mode:z("url"),message:y(),elicitationId:y(),url:y().url()}),y$=Y([h$,g$]),_$=de.extend({method:z("elicitation/create"),params:y$}),w$=De.extend({elicitationId:y()}),b$=Ze.extend({method:z("notifications/elicitation/complete"),params:w$}),br=fe.extend({action:ke(["accept","decline","cancel"]),content:Sa(e=>e===null?void 0:e,K(y(),Y([y(),H(),ue(),M(y())])).optional())}),v$=S({type:z("ref/resource"),uri:y()});var $$=S({type:z("ref/prompt"),name:y()}),x$=Ne.extend({ref:Y([$$,v$]),argument:S({name:y(),value:y()}),context:S({arguments:K(y(),y()).optional()}).optional()}),S$=de.extend({method:z("completion/complete"),params:x$});var k$=fe.extend({completion:ve({values:M(y()).max(100),total:te(H().int()),hasMore:te(ue())})}),z$=S({uri:y().startsWith("file://"),name:y().optional(),_meta:K(y(),ee()).optional()}),P$=de.extend({method:z("roots/list"),params:Ne.optional()}),La=fe.extend({roots:M(z$)}),E$=Ze.extend({method:z("notifications/roots/list_changed"),params:De.optional()}),BR=Y([ts,Oa,S$,qa,C0,O0,h0,y0,b0,S0,z0,_n,Ma,ns,ss,is,cs]),JR=Y([es,rs,Ra,E$,gn]),KR=Y([Qo,bn,Fa,br,La,os,as,_r]),GR=Y([ts,r$,_$,P$,ns,ss,is,cs]),WR=Y([es,rs,K0,E0,$0,H0,q0,gn,b$]),YR=Y([Qo,c0,k$,M0,R0,g0,_0,v0,us,U0,os,as,_r]),T=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===A.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new ka(o.elicitations,r)}return new e(t,r,n)}},ka=class extends T{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(A.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var I$=10*1024*1024,ls=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??I$}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
67
|
-
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),
|
|
68
|
-
`}var
|
|
69
|
-
`,"utf8"),ah(r,e),gs(e)}var ws=class{dir;itemsDir;imagesDir;palaceFile;palace={value:Ua(),stamp:"",broken:!1};items=new Map;rev=1;constructor(t,{create:r=!0}={}){this.dir=t,this.itemsDir=ze(t,"items"),this.imagesDir=ze(t,"images"),this.palaceFile=ze(t,"palace.json"),r&&(ms(this.itemsDir,{recursive:!0}),ms(this.imagesDir,{recursive:!0}));let n=this.refreshPalace();if(!r&&(n.stamp===""||n.broken))throw new b(`\u65E0\u6CD5\u8BFB\u53D6 ${this.palaceFile}`)}refreshPalace(){if(!vr(this.palaceFile))return this.palace.stamp!==""&&(this.palace={value:Ua(),stamp:"",broken:!1},this.rev+=1),this.palace;let t=gs(this.palaceFile);if(t===this.palace.stamp)return this.palace;let r=this.palace.schema;try{let n=JSON.parse(sh(this.palaceFile,"utf8"));r=_s(n),this.palace={value:M$(n),stamp:t,broken:!1,schema:r}}catch(n){console.warn("[dsh-palace] palace.json \u89E3\u6790\u5931\u8D25\uFF0C\u7EE7\u7EED\u4F7F\u7528\u5185\u5B58\u4E2D\u7684\u6570\u636E",n),this.palace={...this.palace,stamp:t,broken:!0,schema:r}}return this.rev+=1,this.palace}refreshItem(t){St(t);let r=ze(this.itemsDir,`${t}.json`),n=this.items.get(t);if(!vr(r))return n!==void 0&&(this.items.delete(t),this.rev+=1),{value:Ft(t),stamp:"",broken:!1};let o=gs(r);if(n!==void 0&&n.stamp===o)return n;let s,i=n?.schema;try{let a=JSON.parse(sh(r,"utf8"));i=_s(a),s={value:q$(a,t),stamp:o,broken:!1,schema:i}}catch(a){console.warn(`[dsh-palace] items/${t}.json \u89E3\u6790\u5931\u8D25`,a),s={value:n?.value??Ft(t),stamp:o,broken:!0,schema:i}}return n!==void 0&&(this.rev+=1),this.items.set(t,s),s}getPalace(){return this.refreshPalace().value}getItem(t){return this.refreshItem(t).value}checkDisk(){for(let t of this.getPalace().cells)t.kind!=="group"&&this.refreshItem(t.id);return this.rev}summaries(){let t={};for(let r of this.getPalace().cells)r.kind!=="group"&&(t[r.id]=rh(this.getItem(r.id)));return t}snapshotBeforeWrite(){let t=".snapshots",r=ze(this.dir,t),n=ze(r,vn());try{let o=C$(r,{throwIfNoEntry:!1});if(o&&!o.isDirectory())throw new Error("\u5FEB\u7167\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55");if(vr(n))return;ms(r,{recursive:!0});let s=N$(ze(r,".partial-"));try{for(let a of oh(this.dir))a!==t&&A$(ze(this.dir,a),ze(s,a),{recursive:!0,verbatimSymlinks:!0});vr(n)||ah(s,n)}finally{hs(s,{recursive:!0,force:!0})}let i=oh(r,{withFileTypes:!0}).filter(a=>a.isDirectory()&&/^\d{4}-\d{2}-\d{2}$/.test(a.name)).map(a=>a.name);for(let a of i.sort().slice(0,-3))hs(ze(r,a),{recursive:!0,force:!0})}catch(o){console.warn("[dsh-palace] \u6BCF\u65E5\u5FEB\u7167\u5931\u8D25\uFF0C\u7EE7\u7EED\u5199\u5165",o)}}assertWritable(){let t=this.refreshPalace();this.assertSupportedSchema(t,"palace.json");for(let r of t.value.cells)r.kind==="group"||!ch.test(r.id)||this.assertSupportedSchema(this.refreshItem(r.id),`items/${r.id}.json`)}assertSupportedSchema(t,r){if((t.schema??2)>2)throw new b(`${r} \u7684\u6570\u636E\u7248\u672C\u8F83\u65B0\uFF0C\u8BF7\u5347\u7EA7\u63D2\u4EF6`)}mutate(t){try{return Promise.resolve(this.commit(t))}catch(r){return Promise.reject(r)}}commit(t){this.assertWritable();let r=this.palace;if(r.broken)throw new b("palace.json \u683C\u5F0F\u6709\u8BEF\uFF1A\u8BF7\u5148\u4FEE\u597D\u6216\u5220\u6389\u8FD9\u4E2A\u6587\u4EF6\uFF0C\u518D\u7EE7\u7EED\u64CD\u4F5C");let n=structuredClone(r.value),o=new Map,s=[],a=t({palace:n,item:f=>{let p=o.get(f);if(p!==void 0){if(p.item===null)throw new b("\u683C\u5B50\u5DF2\u5220\u9664");return p.item}let m=this.refreshItem(f);if(this.assertSupportedSchema(m,`items/${f}.json`),m.broken)throw new b(`items/${f}.json \u683C\u5F0F\u6709\u8BEF\uFF1A\u8BF7\u5148\u4FEE\u597D\u6216\u5220\u6389\u8FD9\u4E2A\u6587\u4EF6`);let h=structuredClone(m.value);return o.set(f,{item:h,before:JSON.stringify(m.value),stamp:m.stamp}),h},createItem:f=>{this.assertSupportedSchema(this.refreshItem(f.id),`items/${f.id}.json`),o.set(f.id,{item:f,before:"",stamp:""})},deleteItem:f=>{this.assertSupportedSchema(this.refreshItem(f),`items/${f}.json`),o.set(f,{item:null,before:"",stamp:""})},deleteImage:f=>{s.push(f)}});if(a instanceof Promise)throw new Error("mutate \u7684\u56DE\u8C03\u5FC5\u987B\u662F\u540C\u6B65\u7684");let c=JSON.stringify(n)!==JSON.stringify(r.value),u=[...o].filter(([,{item:f,before:p}])=>f===null||JSON.stringify(f)!==p);(c||u.length>0||s.length>0)&&this.snapshotBeforeWrite();let l=(f,p)=>(vr(f)?gs(f):"")!==p;if(l(this.palaceFile,r.stamp))throw new b("palace.json \u521A\u88AB\u5176\u4ED6\u7A0B\u5E8F\u4FEE\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5");for(let[f,p]of o)if(p.before!==""&&l(ze(this.itemsDir,`${f}.json`),p.stamp))throw new b(`items/${f}.json \u521A\u88AB\u5176\u4ED6\u7A0B\u5E8F\u4FEE\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5`);for(let[f,{item:p}]of u){if(p===null)continue;vr(this.itemsDir)||ms(this.itemsDir,{recursive:!0});let m=ih(ze(this.itemsDir,`${f}.json`),p);this.items.set(f,{value:p,stamp:m,broken:!1})}if(c){let f=ih(this.palaceFile,n);this.palace={value:n,stamp:f,broken:!1}}this.rev+=1;let d=(f,p)=>{try{p()}catch(m){console.warn(`[dsh-palace] \u6E05\u7406 ${f} \u5931\u8D25\uFF0C\u5DF2\u5FFD\u7565`,m)}};for(let[f,{item:p}]of o)p===null&&(this.items.delete(f),d(`items/${f}.json`,()=>hs(ze(this.itemsDir,`${f}.json`),{force:!0})));for(let f of s)/^[\w.-]+$/.test(f)&&d(`images/${f}`,()=>hs(ze(this.imagesDir,f),{force:!0}));return a}};function kt(e,t){if(typeof e!="string"||e.trim()==="")throw new b(`${t}\u4E0D\u80FD\u4E3A\u7A7A`);return e.trim()}function $n(e,t){if(e!=null){if(typeof e!="string")throw new b(`${t}\u5E94\u4E3A\u6587\u5B57`);return e.trim()===""?void 0:e.trim()}}function Va(e,t){if(!(e==null||e==="")){if(!nh(e))throw new b(`${t}\u683C\u5F0F\u5E94\u4E3A YYYY-MM-DD`);return e}}function bs(e,t){if(!Number.isSafeInteger(e))throw new b(`${t}\u5E94\u4E3A\u6574\u6570`);return e}function xn(e,t,r,n){n?delete e[t]:r!==void 0&&(e[t]=r)}function Ut(e){return e===null||e===""}function Vt(e,t){St(t);let r=e.cells.find(n=>n.id===t);if(r===void 0)throw new b("\u683C\u5B50\u4E0D\u5B58\u5728");return r}function Fe(e,t){let r=Vt(e.palace,t);if(r.kind==="group")throw new b("\u5206\u7EC4\u6CA1\u6709\u7B14\u8BB0\u672C");return e.item(r.id)}function F$(e){let t=e;if(t?.type==="pdf"&&typeof t.path=="string"&&Number.isSafeInteger(t.pageCount))return{type:"pdf",path:t.path,pageCount:t.pageCount};if(t?.type==="epub"&&typeof t.path=="string")return{type:"epub",path:t.path};if(t?.type==="video"&&typeof t.url=="string")return{type:"video",url:t.url};throw new b("\u539F\u6587\u4FE1\u606F\u65E0\u6548")}function Ha(e,t,r,n){return e.cells.find(o=>o.parentId===t&&o.col===r&&o.row===n)}function Ba(e,t){let r=e.cells.filter(o=>o.parentId===t).length,n=t===null?3:Math.max(2,Math.ceil(Math.sqrt(r+1)));for(let o=0;;o++){let s=o%n,i=Math.floor(o/n);if(Ha(e,t,s,i)===void 0)return{col:s,row:i}}}function uh(e,t,r){if(t==null)return null;let n=Vt(e,t);if(n.kind!=="group")throw new b("\u53EA\u80FD\u653E\u8FDB\u5206\u7EC4\u91CC");if(r==="group")throw new b("\u5206\u7EC4\u91CC\u4E0D\u80FD\u518D\u653E\u5206\u7EC4");return n.id}function lh(e,t,r){if(e!==null&&(t<0||r<0))throw new b("\u5206\u7EC4\u91CC\u7684\u5750\u6807\u4E0D\u80FD\u4E3A\u8D1F")}function Ja(e,t){t===null||e.cells.some(r=>r.parentId===t)||(e.cells=e.cells.filter(r=>r.id!==t))}var Ka="https://dsh-palace.pages.dev";async function dh(e){return e.mutate(t=>{let r={id:Me("c"),kind:"note",parentId:null,...Ba(t.palace,null),title:"Memory Palace \u2197",subtitle:"\u4EC0\u4E48\u662F",icon:"open-book",href:Ka,createdAt:qe()};return t.palace.cells.push(r),t.createItem(Ft(r.id,null)),r})}async function zt(e,t){let r=t.kind;if(r!=="book"&&r!=="note"&&r!=="group")throw new b("\u683C\u5B50\u7C7B\u578B\u5E94\u4E3A book / note / group");let n=kt(t.title,"\u6807\u9898"),o=$n(t.subtitle,"\u5907\u6CE8"),s=r==="book"?F$(t.source):null,i=Va(t.targetDate,"\u76EE\u6807\u65E5\u671F");return e.mutate(a=>{let c=uh(a.palace,t.parentId,r),u;if(t.col===void 0&&t.row===void 0)u=Ba(a.palace,c);else if(u={col:bs(t.col,"\u5217"),row:bs(t.row,"\u884C")},lh(c,u.col,u.row),Ha(a.palace,c,u.col,u.row)!==void 0)throw new b("\u8FD9\u4E2A\u4F4D\u7F6E\u5DF2\u7ECF\u6709\u683C\u5B50\u4E86");let l={id:Me("c"),kind:r,parentId:c,...u,title:n,...o?{subtitle:o}:{},createdAt:qe()};if(a.palace.cells.push(l),r!=="group"){let d=Ft(l.id,s);i!==void 0&&(d.targetDate=i),r==="book"&&t.outline!==void 0&&(d.chapters=gh(t.outline),d.chapters.length>0&&t.outlineSource!==void 0&&(d.outlineSource=t.outlineSource)),a.createItem(d)}return l})}async function fh(e,t){let r=t.title===void 0?void 0:kt(t.title,"\u6807\u9898"),n=$n(t.subtitle,"\u5907\u6CE8"),o=$n(t.icon,"\u56FE\u6807");if(o!==void 0&&!/^[a-z][a-z0-9-]{0,30}$/.test(o))throw new b("\u56FE\u6807\u540D\u65E0\u6548");return e.mutate(s=>{let i=Vt(s.palace,t.id);return r!==void 0&&(i.title=r),xn(i,"subtitle",n,Ut(t.subtitle)),xn(i,"icon",o,Ut(t.icon)),i})}async function ph(e,t){let r=t.col===void 0&&t.row===void 0,n=r?0:bs(t.col,"\u5217"),o=r?0:bs(t.row,"\u884C");return e.mutate(s=>{let i=Vt(s.palace,t.id),a=uh(s.palace,t.parentId,i.kind);if(a===i.id)throw new b("\u4E0D\u80FD\u653E\u8FDB\u81EA\u5DF1\u91CC\u9762");if(r){if(i.parentId===a)return i;({col:n,row:o}=Ba(s.palace,a))}lh(a,n,o);let c=[i.parentId],u=Ha(s.palace,a,n,o);if(u!==void 0&&u.id!==i.id){if(c.push(u.parentId),u.kind==="group"&&i.parentId!==null)throw new b("\u5206\u7EC4\u4E0D\u80FD\u6362\u8FDB\u53E6\u4E00\u4E2A\u5206\u7EC4\u91CC");u.parentId=i.parentId,u.col=i.col,u.row=i.row}i.parentId=a,i.col=n,i.row=o;for(let l of c)Ja(s.palace,l);return i})}async function mh(e,t){let r=t.title===void 0?"\u65B0\u5206\u7EC4":kt(t.title,"\u6807\u9898");return e.mutate(n=>{let o=Vt(n.palace,t.id),s=Vt(n.palace,t.ontoId);if(o.id===s.id)throw new b("\u4E0D\u80FD\u548C\u81EA\u5DF1\u7EC4\u6210\u5206\u7EC4");if(o.kind==="group"||s.kind==="group")throw new b("\u5206\u7EC4\u4E0D\u80FD\u518D\u653E\u8FDB\u5206\u7EC4");if(s.parentId!==null)throw new b("\u53EA\u80FD\u5728\u6700\u5916\u5C42\u62D6\u6210\u5206\u7EC4");let i={id:Me("c"),kind:"group",parentId:null,col:s.col,row:s.row,title:r,createdAt:qe()};n.palace.cells.push(i),s.parentId=i.id,s.col=0,s.row=0;let a=o.parentId;return o.parentId=i.id,o.col=1,o.row=0,Ja(n.palace,a),i})}async function vs(e,t){return e.mutate(r=>{let n=Vt(r.palace,t.id);if(n.kind==="group"){if(r.palace.cells.some(o=>o.parentId===n.id))throw new b("\u5206\u7EC4\u91CC\u8FD8\u6709\u683C\u5B50\uFF0C\u5148\u79FB\u51FA\u53BB\u6216\u5220\u6389")}else{for(let o of r.item(n.id).cards)o.image&&r.deleteImage(o.image);r.deleteItem(n.id)}r.palace.cells=r.palace.cells.filter(o=>o.id!==n.id),Ja(r.palace,n.parentId)})}async function $s(e,t){let r=Va(t.targetDate,"\u76EE\u6807\u65E5\u671F"),n=Va(t.finishedAt,"\u8BFB\u5B8C\u65E5\u671F");return e.mutate(o=>{let s=Fe(o,t.id);return xn(s,"targetDate",r,Ut(t.targetDate)),xn(s,"finishedAt",n,Ut(t.finishedAt)),s})}async function hh(e,t){let r=kt(t.loc,"\u4F4D\u7F6E"),n=t.percent;if(typeof n!="number"||!(n>=0&&n<=1))throw new b("percent \u5E94\u4E3A 0\u20131 \u7684\u5C0F\u6570");return e.mutate(o=>{Fe(o,t.id).position={loc:r,percent:n}})}function gh(e,t=[]){let r=new Map;for(let o of t)for(let s of o.sections)s.done&&r.set(`${o.title}\0${s.title}`,s);let n=o=>typeof o=="string"&&o!==""?{loc:o}:{};return e.filter(o=>typeof o?.title=="string"&&o.title.trim()!=="").map(o=>{let s=o.title.trim(),i=(o.sections??[]).map(c=>typeof c=="string"?{title:c}:c).filter(c=>typeof c?.title=="string"&&c.title.trim()!==""),a=(i.length>0?i:[{title:s,loc:o.loc}]).map(c=>{let u=c.title.trim(),l=r.get(`${s}\0${u}`);return{id:Me("s"),title:u,...n(c.loc),done:l!==void 0,...l?.doneAt!==void 0?{doneAt:l.doneAt}:{}}});return{id:Me("ch"),title:s,sections:a}})}async function xs(e,t){if(!Array.isArray(t.chapters)||t.chapters.length===0)throw new b("\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A");let r=t.chapters;return e.mutate(n=>{let o=Fe(n,t.id),s=(u,l)=>`${u.title}\0${l.title}`,i=new Map;for(let u of o.chapters)for(let l of u.sections)i.set(l.id,s(u,l));let a=gh(r,o.chapters);if(a.length===0)throw new b("\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A");o.chapters=a;let c=new Map;for(let u of o.chapters)for(let l of u.sections)c.has(s(u,l))||c.set(s(u,l),l.id);for(let u of o.cards){if(u.sectionId===void 0)continue;let l=c.get(i.get(u.sectionId)??"");l!==void 0?u.sectionId=l:delete u.sectionId}return t.source!==void 0&&(o.outlineSource=t.source),o})}async function yh(e,t){return e.mutate(r=>{let n=xt(Fe(r,t.id),t.sectionId);if(n===void 0)throw new b("\u8282\u4E0D\u5B58\u5728");n.section.done=t.done===!0,n.section.done?n.section.doneAt=qe():delete n.section.doneAt})}async function _h(e,t){return e.mutate(r=>{let n=Fe(r,t.id);if(xt(n,t.sectionId)===void 0)throw new b("\u8282\u4E0D\u5B58\u5728");let o=!0,s=qe();for(let i of n.chapters)for(let a of i.sections)o&&!a.done&&(a.done=!0,a.doneAt=s),!o&&a.done&&(a.done=!1,delete a.doneAt),a.id===t.sectionId&&(o=!1)})}async function wh(e,t){return e.mutate(r=>{for(let n of Fe(r,t.id).chapters)for(let o of n.sections)o.done=!1,delete o.doneAt})}var L$=new Set(["excerpt","thought","mistake"]);function bh(e,t,r){for(let n of e.palace.cells)if(n.kind!=="group"&&e.item(n.id).cards.some(o=>o.image===t&&o.id!==r))throw new b("\u8FD9\u5F20\u56FE\u7247\u5DF2\u7ECF\u5C5E\u4E8E\u53E6\u4E00\u5F20\u5361\u7247")}function vh(e){if(e.type==="thought"&&e.note===void 0)throw new b("\u60F3\u6CD5\u4E0D\u80FD\u4E3A\u7A7A");if(e.type!=="thought"&&e.quote===void 0&&e.image===void 0)throw new b("\u6458\u5F55\u548C\u9519\u9898\u9700\u8981\u539F\u6587\u6216\u56FE\u7247")}function $h(e,t,r){if(t.sectionId!==void 0&&!Ut(t.sectionId)&&xt(e,t.sectionId)===void 0)throw new b("\u8282\u4E0D\u5B58\u5728");if(t.status!==void 0&&t.status!=="todo"&&t.status!=="mastered")throw new b("\u72B6\u6001\u5E94\u4E3A todo / mastered");if(t.image!==void 0&&!Ut(t.image)&&(typeof t.image!="string"||!/^[\w.-]+$/.test(t.image)))throw new b("\u56FE\u7247\u6587\u4EF6\u540D\u65E0\u6548");for(let n of["sectionId","loc","quote","note","answer","image"])xn(r,n,$n(t[n],n),Ut(t[n]));if(t.status!==void 0&&(r.status=t.status),t.share!==void 0)if(t.share===null)delete r.share;else{if(typeof t.share!="object"||Array.isArray(t.share))throw new b("\u5206\u4EAB\u8349\u7A3F\u683C\u5F0F\u4E0D\u5BF9");if(JSON.stringify(t.share).length>64*1024)throw new b("\u5206\u4EAB\u8349\u7A3F\u592A\u5927");r.share=t.share}}async function Ss(e,t){let r=t.type;if(!L$.has(r))throw new b("\u5361\u7247\u7C7B\u578B\u5E94\u4E3A excerpt / thought / mistake");return e.mutate(n=>{let o=Fe(n,t.id),s={id:Me("k"),type:r,createdAt:qe()};return $h(o,t,s),r==="mistake"&&s.status===void 0&&(s.status="todo"),vh(s),s.image!==void 0&&bh(n,s.image,s.id),o.cards.push(s),s})}async function xh(e,t){return e.mutate(r=>{let n=Fe(r,t.id),o=n.cards.find(i=>i.id===t.cardId);if(o===void 0)throw new b("\u5361\u7247\u4E0D\u5B58\u5728");if(t.type!==void 0)throw new b("\u5361\u7247\u7C7B\u578B\u4E0D\u80FD\u4FEE\u6539");let s=o.image;return $h(n,t,o),vh(o),o.image!==void 0&&o.image!==s&&bh(r,o.image,o.id),s!==void 0&&s!==o.image&&r.deleteImage(s),o})}async function Sh(e,t){return e.mutate(r=>{let n=Fe(r,t.id),o=n.cards.find(s=>s.id===t.cardId);if(o===void 0)throw new b("\u5361\u7247\u4E0D\u5B58\u5728");o.image&&r.deleteImage(o.image),n.cards=n.cards.filter(s=>s.id!==o.id);for(let s of n.inspirations)s.cardIds&&(s.cardIds=s.cardIds.filter(i=>i!==o.id))})}async function ks(e,t){let r=kt(t.title,"\u7075\u611F\u6807\u9898"),n=kt(t.body,"\u7075\u611F\u6B63\u6587"),o=$n(t.sessionId,"sessionId");return e.mutate(s=>{let i=Fe(s,t.id),a=Array.isArray(t.cardIds)?t.cardIds.filter(u=>i.cards.some(l=>l.id===u)):[],c={id:Me("i"),title:r,body:n,...o?{sessionId:o}:{},...a.length?{cardIds:a}:{},createdAt:qe()};return i.inspirations.push(c),c})}async function kh(e,t){let r=t.title===void 0?void 0:kt(t.title,"\u7075\u611F\u6807\u9898"),n=t.body===void 0?void 0:kt(t.body,"\u7075\u611F\u6B63\u6587");return e.mutate(o=>{let s=Fe(o,t.id).inspirations.find(i=>i.id===t.inspirationId);if(s===void 0)throw new b("\u7075\u611F\u4E0D\u5B58\u5728");return r!==void 0&&(s.title=r),n!==void 0&&(s.body=n),s})}async function zh(e,t){return e.mutate(r=>{let n=Fe(r,t.id);if(!n.inspirations.some(o=>o.id===t.inspirationId))throw new b("\u7075\u611F\u4E0D\u5B58\u5728");n.inspirations=n.inspirations.filter(o=>o.id!==t.inspirationId)})}import{isAbsolute as jI}from"node:path";function zs(e){return!!e._zod}function Pt(e,t){return zs(e)?Mi(e,t):e.safeParse(t)}function Ps(e){if(!e)return;let t;if(zs(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Es(e){if(zs(e)){let s=e._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=e._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=e.value;if(n!==void 0)return n}function Et(e){return e==="completed"||e==="failed"||e==="cancelled"}var oA=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Wa(e){let r=Ps(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Es(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Ya(e,t){let r=Pt(e,t);if(!r.success)throw r.error;return r.data}var G$=6e4,Is=class{constructor(t){this._options=t,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(es,r=>{this._oncancel(r)}),this.setNotificationHandler(rs,r=>{this._onprogress(r)}),this.setRequestHandler(ts,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ns,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new T(A.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ss,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(!await this._taskStore.getTask(s,n.sessionId))throw new T(A.InvalidParams,`Task not found: ${s}`);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 T(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 T(A.InvalidParams,`Task not found: ${s}`);if(!Et(i.status))return await this._waitForTaskUpdate(s,n.signal,n.sessionId),await o();if(Et(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s,n.sessionId),{...a,_meta:{...a._meta,[$t]:{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 T(A.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(cs,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new T(A.InvalidParams,`Task not found: ${r.params.taskId}`);if(Et(o.status))throw new T(A.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId,n.sessionId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new T(A.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof T?o:new T(A.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),T.fromError(A.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){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=t;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),dn(s)||Um(s)?this._onresponse(s):Ea(s)?this._onrequest(s,i):Lm(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=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=T.fromError(A.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[$t]?.taskId,i=o?.sessionId,a=this._taskStore,c=!0,u;if(s&&a&&this._taskMessageQueue&&i!==void 0&&(c=!1,u=(async()=>{if(!await a.getTask(s,i))throw new T(A.InvalidParams,`Task not found: ${s}`);c=!0})()),n===void 0){let m={jsonrpc:"2.0",id:t.id,error:{code:A.MethodNotFound,message:"Method not found"}};if(s&&u){let h={type:"error",message:m,timestamp:Date.now()};u.then(()=>this._enqueueTaskMessage(s,h,i),()=>o?.send(m)).catch(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}else s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:m,timestamp:Date.now()},o?.sessionId).catch(h=>this._onerror(new Error(`Failed to enqueue error response: ${h}`))):o?.send(m).catch(h=>this._onerror(new Error(`Failed to send an error response: ${h}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(t.id,l);let d=Mm(t.params)?t.params.task:void 0,f=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,p={signal:l.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async m=>{if(l.signal.aborted)return;let h={relatedRequestId:t.id};s&&(h.relatedTask={taskId:s}),await this.notification(m,h)},sendRequest:async(m,h,g)=>{if(l.signal.aborted)throw new T(A.ConnectionClosed,"Request was cancelled");let w={...g,relatedRequestId:t.id};s&&!w.relatedTask&&(w.relatedTask={taskId:s});let v=w.relatedTask?.taskId??s;return v&&f&&await f.updateTaskStatus(v,"input_required"),await this.request(m,h,w)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:f,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(u??Promise.resolve()).then(()=>{if(u&&l.signal.aborted)throw new T(A.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,p)).then(async m=>{if(l.signal.aborted)return;let h={result:m,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:h,timestamp:Date.now()},o?.sessionId):await o?.send(h)},async m=>{if(l.signal.aborted)return;let h={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(m.code)?m.code:A.InternalError,message:m.message??"Internal error",...m.data!==void 0&&{data:m.data}}};s&&this._taskMessageQueue&&c?await this._enqueueTaskMessage(s,{type:"error",message:h,timestamp:Date.now()},o?.sessionId):await o?.send(h)}).catch(m=>this._onerror(new Error(`Failed to send response: ${m}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.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(t)}`));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(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),dn(t))n(t);else{let i=new T(t.error.code,t.error.message,t.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(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(dn(t)&&t.result&&typeof t.result=="object"){let i=t.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),dn(t))o(t);else{let i=T.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof T?i:new T(A.InternalError,String(i))}}return}let s;try{let i=await this.request(t,_r,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new T(A.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Et(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new T(A.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new T(A.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof T?i:new T(A.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[$t]:c}});let m=v=>{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(v)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(O=>this._onerror(new Error(`Failed to send cancellation: ${O}`)));let $=v instanceof T?v:new T(A.RequestTimeout,String(v));l($)};this._responseHandlers.set(f,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let $=Pt(r,v.result);$.success?u($.data):l($.error)}catch($){l($)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??G$,g=()=>m(T.fromError(A.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let w=c?.taskId;if(w){let v=$=>{let O=this._responseHandlers.get(f);O?O($):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,v),this._enqueueTaskMessage(w,{type:"request",message:p,timestamp:Date.now()}).catch($=>{this._cleanupTimeout(f),l($)})}else this._transport.send(p,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(f),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},os,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},as,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Bm,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[$t]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[$t]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[$t]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=Wa(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=Ya(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=Wa(t);this._notificationHandlers.set(n,o=>{let s=Ya(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,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(t,r,n??this._transport?.sessionId,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&Ea(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new T(A.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r,n){let o=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(t,n);s?.pollInterval&&(o=s.pollInterval)}catch{}return new Promise((s,i)=>{if(r.aborted){i(new T(A.InvalidRequest,"Request cancelled"));return}let a=setTimeout(s,o);r.addEventListener("abort",()=>{clearTimeout(a),i(new T(A.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new T(A.InvalidParams,"Failed to retrieve task: Task not found");return s},storeTaskResult:async(o,s,i)=>{await n.storeTaskResult(o,s,i,r);let a=await n.getTask(o,r);if(a){let c=gn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Et(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 T(A.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Et(a.status))throw new T(A.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${s}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(o,s,i,r);let c=await n.getTask(o,r);if(c){let u=gn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Et(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Ph(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Eh(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];Ph(i)&&Ph(s)?r[o]={...i,...s}:r[o]=s}return r}var T_=ll(Lu(),1),O_=ll(I_(),1);function cI(){let e=new T_.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,O_.default)(e),e}var Mr=class{constructor(t){this._ajv=t??cI()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var mi=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.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:t},bn,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.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"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},br,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function R_(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function A_(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var hi=class extends Is{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(wn.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 Mr,this.setRequestHandler(Oa,n=>this._oninitialize(n)),this.setNotificationHandler(Ra,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(qa,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=wn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new mi(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Eh(this._capabilities,t)}setRequestHandler(t,r){let o=Ps(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Es(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=Pt(_n,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new T(A.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=Pt(_r,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new T(A.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=Pt(us,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new T(A.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);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 ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);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 ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);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 ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){A_(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&R_(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:jm.includes(r)?r:za,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"},Qo)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.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 t.tools?this.request({method:"sampling/createMessage",params:t},Fa,r):this.request({method:"sampling/createMessage",params:t},bn,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},br,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},br,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new T(A.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof T?i:new T(A.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(t,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:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},La,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}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"})}};import{appendFileSync as uI,existsSync as Wu,mkdirSync as lI,readFileSync as Yu,renameSync as dI,statSync as C_,writeFileSync as fI}from"node:fs";import{join as to}from"node:path";var no=500,N_=40,j_=40,D_=5,Xu=e=>[...e].length,nr=(e,t)=>e<t?`${e}|${t}`:`${t}|${e}`;function ro(e){let t=new Map;for(let r of e.cards)t.set(r.id,r.createdAt);for(let r of e.inspirations)t.set(r.id,r.createdAt);return t}function pI(e){let t=/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(e);if(t===null)return{body:e.trim(),writtenAt:""};let r={};for(let o of t[1].split(`
|
|
70
|
-
`)){let s=o.indexOf(":");s>0&&(r[o.slice(0,s).trim()]=o.slice(s+1).trim())}let n;try{n=r.topics?JSON.parse(r.topics):void 0}catch{n=void 0}return{...r.summary?{summary:r.summary}:{},...Array.isArray(n)?{topics:n.filter(o=>typeof o=="string")}:{},body:t[2].trim(),writtenAt:r.writtenAt??""}}function
|
|
66
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Lp(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Lp(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Up=new Set(["type","properties","required","additionalProperties"]),qp=["oneOf","anyOf"];function Fp(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Pa(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Up.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??Fp(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:Pa(a)??{allOf:a};He(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=Fp(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function h0(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Up)if(o in e)return;let r=t.filter(o=>qp.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=Pa(t);else{let o=r[0],s=qp.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>Pa([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,mn(e,n))}function Ta(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):mn(u,m),mn(u,l),a._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(m.$ref&&p.def)for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Lp(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])h0(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}mn(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,He(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:hn(t,"input",e.processors),output:hn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ae(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ae(n.element,r);if(n.type==="set")return Ae(n.valueType,r);if(n.type==="lazy")return Ae(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Ae(n.innerType,r);if(n.type==="intersection")return Ae(n.left,r)||Ae(n.right,r);if(n.type==="record"||n.type==="map")return Ae(n.keyType,r)||Ae(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ae(n.in,r)||Ae(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Ae(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Ae(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Ae(o,r))return!0;return!!(n.rest&&Ae(n.rest,r))}return!1}var Vp=(e,t={})=>r=>{let n=Ia({...r,processors:t});return pe(e,n),Ea(n,e),Ta(n,e)},hn=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=Ia({...o??{},target:s,io:t,processors:r});return pe(e,i),Ea(i,e),Ta(i,e)};var Sr=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},zr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Bp=(e,t)=>{Sr(e,"minimum",t),zr(e,"maximum",t)},Gp=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Wp=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Yp=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},Xp=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Hp=(e,t)=>Sr(e,"minimum",t.minimum),Kp=(e,t)=>zr(e,"maximum",t.maximum),Jp=e=>(t,r)=>{Xp(t,r.format);let[n,o]=e[r.format];Sr(t,"minimum",n),zr(t,"maximum",o)},g0={greater_than:(e,t)=>Sr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>zr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Gp(e,t.value),number_format:Jp(tn),bigint_format:Jp(xo),min_length:Hp,max_length:Kp,length_equals:(e,t)=>Bp(e,t.length),min_size:Hp,max_size:Kp,size_equals:(e,t)=>Bp(e,t.size),string_format:(e,t)=>{Xp(e,t.format),t.pattern&&Wp(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Yp(e,t.mime)};function Xe(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)g0[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&Sr(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&Sr(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&zr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&zr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Gp(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Yp(t,o.mime);for(let s of o.patterns??[])Wp(t,s);return t}var y0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},_0=new Map([[aa,yd],[qo,_d]]),Qp=e=>_0.get(e)??e,em=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=Xe(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=y0[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(Qp);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},tm=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=Xe(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),f?p?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let m=new Set;for(let y of a)Number.isFinite(y)&&y!==0?m.add(Math.abs(y)):xt(e,t,o,n,`A multipleOf divisor of ${y} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(o.multipleOf=h),g.length&&(o.allOf=[...o.allOf??[],...g.map(y=>({multipleOf:y}))])}},rm=(e,t,r,n)=>{r.type="boolean"};var nm=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var om=(e,t,r,n)=>{r.not={}};var sm=(e,t,r,n)=>{};var im=(e,t,r,n)=>{let o=e._zod.def,s=_r(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},am=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(xt(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(xt(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var cm=(e,t,r,n)=>{xt(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var um=(e,t,r,n)=>{xt(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var lm=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=Xe(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=pe(s.element,t,{...n,path:[...n.path,"items"]})};function es(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?es(t.out):t.type==="catch"?es(t.innerType):e._zod.optin}var dm=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&xt(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)He(o.properties,u,pe(i[u],t,{...n,path:[...n.path,"properties",u]}));let c=[];for(let u of Object.keys(i)){let l=s.shape[u];(t.io==="input"?es(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=pe(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},fm=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>pe(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},pm=(e,t,r,n)=>{let o=e._zod.def,s=pe(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=pe(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function Oa(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let h=Oa(e,m,r);return h===m?t:h}for(let m of["anyOf","oneOf"]){let h=t[m];if(!Array.isArray(h))continue;let g=h.map(y=>Oa(e,y,r));g.some((y,v)=>y!==h[v])&&(t={...t,[m]:g})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(m=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(m=>typeof m=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(m=>typeof m=="number"?String(m):m):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",s||(p.pattern=(n.includes("number")?an:ta).source)),p}var Ra=new WeakMap;function w0(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of Ra.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=Oa(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var mm=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=Xe(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=pe(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)He(o.patternProperties,Qp(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=pe(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=Ra.get(t);l||(l=[],Ra.set(t,l),t.deferred.push(()=>w0(t))),l.push(e)}o.additionalProperties=pe(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&es(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},hm=(e,t,r,n)=>{let o=e._zod.def,s=pe(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},gm=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Aa=Symbol();function ym(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(xt(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),Aa):JSON.parse(i)}var _m=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=ym(o.defaultValue,e,t,r,n);i!==Aa&&(r.default=i)},wm=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=ym(o.defaultValue,e,t,r,n);i!==Aa&&(r._prefault=i)},bm=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{xt(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},vm=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;pe(i,t,n);let a=t.seen.get(e);a.ref=i},$m=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var Ca=(e,t,r,n)=>{let o=e._zod.def;pe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var km=new WeakSet([Object.prototype,Error.prototype]);function ts(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var I0=(e,t)=>{Ul.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);km.has(r)||(km.add(r),ts(r,"format",n=>o=>Hl(n,o)),ts(r,"flatten",n=>o=>Bl(n,o)),ts(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,wr,2)}),ts(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,wr,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Je=b("ZodError",I0,void 0,{Parent:Error});var xm=Eo(Je),Sm=To(Je),zm=sn(Je),Pm=Oo(Je),Im=Jl(Je),Em=Gl(Je),Tm=Wl(Je),Om=Yl(Je),Rm=Xl(Je),Am=Ql(Je),Cm=ed(Je),Nm=td(Je);function T0(){Ze.localeError||Ke(np())}function ns(){Ze.memoizer||Ke({memoizer:rp()})}var le=b("ZodType",(e,t)=>(T0(),re.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(C.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return it(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(wv(e,t))},superRefine(e,t){return this.check(bv(e,t))},overwrite(e){return this.check(Nt(e))},optional(){return ue(this)},exactOptional(){return av(this)},nullable(){return Zm(this)},nullish(){return ue(Zm(this))},nonoptional(e){return pv(this,e)},array(){return B(this)},or(e){return oe([this,e])},and(e){return os(this,e)},transform(e){return Mm(this,Bm(e))},default(e){return lv(this,e)},prefault(e){return fv(this,e)},catch(e){return hv(this,e)},pipe(e){return Mm(this,e)},readonly(){return _v(this)},describe(e){let t=this.clone();return Qt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Qt.get(this);let t=this.clone();return Qt.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return C.hide(this,"~standard",{...ia(this),jsonSchema:{input:hn(this,"input"),output:hn(this,"output")}})},set"~standard"(e){C.own(this,"~standard",e)},parse:function e(t,r){return xm(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await Sm(this,t,r,{callee:e})},safeParse(e,t){return zm(this,e,t)},async safeParseAsync(e,t){return Pm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){C.own(this,"spa",e)},validate(e,t){return Ro(this,e,t)},validateAsync(e,t){return Ao(this,e,t)},encode:function e(t,r){return Im(this,t,r,{callee:e})},decode:function e(t,r){return Em(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Tm(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Om(this,t,r,{callee:e})},safeEncode(e,t){return Rm(this,e,t)},safeDecode(e,t){return Am(this,e,t)},async safeEncodeAsync(e,t){return Cm(this,e,t)},async safeDecodeAsync(e,t){return Nm(this,e,t)},toJSONSchema(e){return Vp(this,{})(e)},get description(){return Qt.get(this)?.description},get _def(){return this._zod.def}}),qm=b("_ZodString",(e,t)=>{Mo.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>em(e,r,n,o)},C.derived({format:e=>Xe(e).format??null,minLength:e=>Xe(e).minimum??null,maxLength:e=>Xe(e).maximum??null},{regex(...e){return this.check(ga(...e))},includes(...e){return this.check(wa(...e))},startsWith(...e){return this.check(ba(...e))},endsWith(...e){return this.check(va(...e))},min(...e){return this.check(xr(...e))},max(...e){return this.check(Xo(...e))},length(...e){return this.check(Qo(...e))},nonempty(...e){return this.check(xr(1,...e))},lowercase(e){return this.check(ya(e))},uppercase(e){return this.check(_a(e))},trim(){return this.check(ka())},normalize(...e){return this.check($a(...e))},toLowerCase(){return this.check(xa())},toUpperCase(){return this.check(Sa())},slugify(){return this.check(za())}})),O0=b("ZodString",(e,t)=>{Mo.init(e,t),qm.init(e,t)},{email(e){return this.check(ap(R0,e))},url(e){return this.check(pp(C0,e))},jwt(e){return this.check(Ip(G0,e))},emoji(e){return this.check(mp(N0,e))},guid(e){return this.check(cp(A0,e))},uuid(e){return this.check(up(rs,e))},uuidv4(e){return this.check(lp(rs,e))},uuidv6(e){return this.check(dp(rs,e))},uuidv7(e){return this.check(fp(rs,e))},nanoid(e){return this.check(hp(j0,e))},cuid(e){return this.check(gp(D0,e))},cuid2(e){return this.check(yp(Z0,e))},ulid(e){return this.check(_p(M0,e))},base64(e){return this.check(Sp(H0,e))},base64url(e){return this.check(zp(K0,e))},xid(e){return this.check(wp(q0,e))},ksuid(e){return this.check(bp(F0,e))},ipv4(e){return this.check(vp(L0,e))},ipv6(e){return this.check($p(U0,e))},cidrv4(e){return this.check(kp(V0,e))},cidrv6(e){return this.check(xp(B0,e))},e164(e){return this.check(Pp(J0,e))},datetime(e){return this.check(Bo(yn,e))},date(e){return this.check(Ho(_n,e))},time(e){return this.check(Ko(wn,e))},duration(e){return this.check(Jo(bn,e))}});function _(e){return ip(O0,e)}var de=b("ZodStringFormat",(e,t)=>{ne.init(e,t),qm.init(e,t)}),yn=b("ZodISODateTime",(e,t)=>{hf.init(e,t),de.init(e,t)}),_n=b("ZodISODate",(e,t)=>{gf.init(e,t),de.init(e,t)}),wn=b("ZodISOTime",(e,t)=>{yf.init(e,t),de.init(e,t)}),bn=b("ZodISODuration",(e,t)=>{_f.init(e,t),de.init(e,t)}),R0=b("ZodEmail",(e,t)=>{nf.init(e,t),de.init(e,t)});var A0=b("ZodGUID",(e,t)=>{tf.init(e,t),de.init(e,t)});var rs=b("ZodUUID",(e,t)=>{rf.init(e,t),de.init(e,t)});var C0=b("ZodURL",(e,t)=>{af.init(e,t),de.init(e,t)});var N0=b("ZodEmoji",(e,t)=>{cf.init(e,t),de.init(e,t)});var j0=b("ZodNanoID",(e,t)=>{uf.init(e,t),de.init(e,t)});var D0=b("ZodCUID",(e,t)=>{lf.init(e,t),de.init(e,t)});var Z0=b("ZodCUID2",(e,t)=>{df.init(e,t),de.init(e,t)});var M0=b("ZodULID",(e,t)=>{ff.init(e,t),de.init(e,t)});var q0=b("ZodXID",(e,t)=>{pf.init(e,t),de.init(e,t)});var F0=b("ZodKSUID",(e,t)=>{mf.init(e,t),de.init(e,t)});var L0=b("ZodIPv4",(e,t)=>{wf.init(e,t),de.init(e,t)});var U0=b("ZodIPv6",(e,t)=>{vf.init(e,t),de.init(e,t)});var V0=b("ZodCIDRv4",(e,t)=>{$f.init(e,t),de.init(e,t)});var B0=b("ZodCIDRv6",(e,t)=>{kf.init(e,t),de.init(e,t)});var H0=b("ZodBase64",(e,t)=>{Sf.init(e,t),de.init(e,t)});var K0=b("ZodBase64URL",(e,t)=>{zf.init(e,t),de.init(e,t)});var J0=b("ZodE164",(e,t)=>{Pf.init(e,t),de.init(e,t)});var G0=b("ZodJWT",(e,t)=>{If.init(e,t),de.init(e,t)});var Fm=b("ZodNumber",(e,t)=>{ca.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tm(e,r,n,o),e.isFinite=!0},C.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Xe(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Xe(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Xe(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Xe(e).format??null},{gt(e,t){return this.check(Wo(e,t))},gte(e,t){return this.check(pn(e,t))},min(e,t){return this.check(pn(e,t))},lt(e,t){return this.check(Go(e,t))},lte(e,t){return this.check(fn(e,t))},max(e,t){return this.check(fn(e,t))},int(e){return this.check(jm(e))},safe(e){return this.check(jm(e))},positive(e){return this.check(Wo(0,e))},nonnegative(e){return this.check(pn(0,e))},negative(e){return this.check(Go(0,e))},nonpositive(e){return this.check(fn(0,e))},multipleOf(e,t){return this.check(Yo(e,t))},step(e,t){return this.check(Yo(e,t))},finite(){return this}}));function Y(e){return Ep(Fm,e)}var W0=b("ZodNumberFormat",(e,t)=>{Ef.init(e,t),Fm.init(e,t)});function jm(e){return Tp(W0,e)}var Y0=b("ZodBoolean",(e,t)=>{Tf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rm(e,r,n,o)});function ye(e){return Op(Y0,e)}var X0=b("ZodNull",(e,t)=>{Of.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nm(e,r,n,o)});function Lm(e){return Rp(X0,e)}var Q0=b("ZodUnknown",(e,t)=>{Rf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sm(e,r,n,o)});function ce(){return Ap(Q0)}var ev=b("ZodNever",(e,t)=>{Af.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>om(e,r,n,o)});function tv(e){return Cp(ev,e)}var rv=b("ZodArray",(e,t)=>{ns(),Cf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lm(e,r,n,o),e.element=t.element},{min(e,t){return this.check(xr(e,t))},nonempty(e){return this.check(xr(1,e))},max(e,t){return this.check(Xo(e,t))},length(e,t){return this.check(Qo(e,t))},unwrap(){return this.element}});function B(e,t){return Np(rv,e,t)}var Um=b("ZodObject",(e,t)=>{ns(),Df.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dm(e,r,n,o),C.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Me(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(C.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(C.mergeDefs(this._zod.def,{catchall:ce()}))},loose(){return this.clone(C.mergeDefs(this._zod.def,{catchall:ce()}))},strict(){return this.clone(C.mergeDefs(this._zod.def,{catchall:tv()}))},strip(){return this.clone(C.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return C.extend(this,e)},safeExtend(e){return C.safeExtend(this,e)},merge(e){return C.merge(this,e)},pick(e){return C.pick(this,e)},omit(e){return C.omit(this,e)},partial(...e){return C.partial(Hm,this,e[0])},exactPartial(...e){return C.partial(Km,this,e[0],"exactPartial")},required(...e){return C.required(Jm,this,e[0])}});function z(e,t){let r={type:"object",shape:e??{},...C.normalizeParams(t)};return new Um(r)}function Ce(e,t){return new Um({type:"object",shape:e,catchall:ce(),...C.normalizeParams(t)})}var Vm=b("ZodUnion",(e,t)=>{ua.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fm(e,r,n,o),e.options=t.options});function oe(e,t){return new Vm({type:"union",options:e,...C.normalizeParams(t)})}var nv=b("ZodDiscriminatedUnion",(e,t)=>{Vm.init(e,t),Zf.init(e,t)});function ja(e,t,r){return new nv({type:"union",options:t,discriminator:e,...C.normalizeParams(r)})}var ov=b("ZodIntersection",(e,t)=>{Mf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pm(e,r,n,o)});function os(e,t){return new ov({type:"intersection",left:e,right:t})}var Dm=b("ZodRecord",(e,t)=>{ns(),qf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mm(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function ee(e,t,r){return!t||!t._zod?new Dm({type:"record",keyType:_(),valueType:e,...C.normalizeParams(t)}):new Dm({type:"record",keyType:e,valueType:t,...C.normalizeParams(r)})}var Na=b("ZodEnum",(e,t)=>{Ff.init(e,t),le.init(e,t),e._zod.processJSONSchema=(n,o,s)=>im(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Na({...t,checks:[],...C.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.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 Na({...t,checks:[],...C.normalizeParams(o),entries:s})}});function Me(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Na({type:"enum",entries:r,...C.normalizeParams(t)})}var sv=b("ZodLiteral",(e,t)=>{Lf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>am(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function T(e,t){return new sv({type:"literal",values:Array.isArray(e)?e:[e],...C.normalizeParams(t)})}var iv=b("ZodTransform",(e,t)=>{ns(),Uf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>um(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new kr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(C.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(C.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Bm(e){return new iv({type:"transform",transform:e})}var Hm=b("ZodOptional",(e,t)=>{la.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ca(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ue(e){return new Hm({type:"optional",innerType:e})}var Km=b("ZodExactOptional",(e,t)=>{Vf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ca(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function av(e){return new Km({type:"optional",innerType:e})}var cv=b("ZodNullable",(e,t)=>{Bf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Zm(e){return new cv({type:"nullable",innerType:e})}var uv=b("ZodDefault",(e,t)=>{Hf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>_m(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function lv(e,t){return new uv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():C.shallowClone(t)}})}var dv=b("ZodPrefault",(e,t)=>{Kf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>wm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function fv(e,t){return new dv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():C.shallowClone(t)}})}var Jm=b("ZodNonOptional",(e,t)=>{Jf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function pv(e,t){return new Jm({type:"nonoptional",innerType:e,...C.normalizeParams(t)})}var mv=b("ZodCatch",(e,t)=>{Gf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>bm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function hv(e,t){return new mv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:C.constantCatch(t)})}var Gm=b("ZodPipe",(e,t)=>{da.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>vm(e,r,n,o),e.in=t.in,e.out=t.out});function Mm(e,t){return new Gm({type:"pipe",in:e,out:t})}var gv=b("ZodPreprocess",(e,t)=>{Gm.init(e,t),Wf.init(e,t)}),yv=b("ZodReadonly",(e,t)=>{Yf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>$m(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function _v(e){return new yv({type:"readonly",innerType:e})}var Wm=b("ZodCustom",(e,t)=>{Xf.init(e,t),le.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cm(e,r,n,o)});function Ym(e,t){return jp(Wm,e??(()=>!0),t)}function wv(e,t={}){return Dp(Wm,e,t)}function bv(e,t){return Zp(e,t)}function Da(e,t){return new gv({type:"pipe",in:Bm(e),out:t})}var ss={};Sl(ss,{ZodISODate:()=>_n,ZodISODateTime:()=>yn,ZodISODuration:()=>bn,ZodISOTime:()=>wn,date:()=>$v,datetime:()=>vv,duration:()=>xv,time:()=>kv});function vv(e){return Bo(yn,e)}function $v(e){return Ho(_n,e)}function kv(e){return Ko(wn,e)}function xv(e){return Jo(bn,e)}var Ma="2025-11-25";var Xm=[Ma,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],jt="io.modelcontextprotocol/related-task",as="2.0",he=Ym(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Qm=oe([_(),Y().int()]),eh=_(),FA=Ce({ttl:Y().optional(),pollInterval:Y().optional()}),Sv=z({ttl:Y().optional()}),zv=z({taskId:_()}),qa=Ce({progressToken:Qm.optional(),[jt]:zv.optional()}),Ge=z({_meta:qa.optional()}),vn=Ge.extend({task:Sv.optional()}),th=e=>vn.safeParse(e).success,we=z({method:_(),params:Ge.loose().optional()}),Qe=z({_meta:qa.optional()}),et=z({method:_(),params:Qe.loose().optional()}),be=Ce({_meta:qa.optional()}),cs=oe([_(),Y().int()]),rh=z({jsonrpc:T(as),id:cs,...we.shape}).strict(),Fa=e=>rh.safeParse(e).success,nh=z({jsonrpc:T(as),...et.shape}).strict(),oh=e=>nh.safeParse(e).success,La=z({jsonrpc:T(as),id:cs,result:be}).strict(),$n=e=>La.safeParse(e).success;var D;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(D||(D={}));var Ua=z({jsonrpc:T(as),id:cs.optional(),error:z({code:Y().int(),message:_(),data:ce().optional()})}).strict();var sh=e=>Ua.safeParse(e).success;var ih=oe([rh,nh,La,Ua]),LA=oe([La,Ua]),us=be.strict(),Pv=Qe.extend({requestId:cs.optional(),reason:_().optional()}),ls=et.extend({method:T("notifications/cancelled"),params:Pv}),Iv=z({src:_(),mimeType:_().optional(),sizes:B(_()).optional(),theme:Me(["light","dark"]).optional()}),kn=z({icons:B(Iv).optional()}),Pr=z({name:_(),title:_().optional()}),ah=Pr.extend({...Pr.shape,...kn.shape,version:_(),websiteUrl:_().optional(),description:_().optional()}),Ev=os(z({applyDefaults:ye().optional()}),ee(_(),ce())),Tv=Da(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,os(z({form:Ev.optional(),url:he.optional()}),ee(_(),ce()).optional())),Ov=Ce({list:he.optional(),cancel:he.optional(),requests:Ce({sampling:Ce({createMessage:he.optional()}).optional(),elicitation:Ce({create:he.optional()}).optional()}).optional()}),Rv=Ce({list:he.optional(),cancel:he.optional(),requests:Ce({tools:Ce({call:he.optional()}).optional()}).optional()}),Av=z({experimental:ee(_(),he).optional(),sampling:z({context:he.optional(),tools:he.optional()}).optional(),elicitation:Tv.optional(),roots:z({listChanged:ye().optional()}).optional(),tasks:Ov.optional(),extensions:ee(_(),he).optional()}),Cv=Ge.extend({protocolVersion:_(),capabilities:Av,clientInfo:ah}),Va=we.extend({method:T("initialize"),params:Cv});var Nv=z({experimental:ee(_(),he).optional(),logging:he.optional(),completions:he.optional(),prompts:z({listChanged:ye().optional()}).optional(),resources:z({subscribe:ye().optional(),listChanged:ye().optional()}).optional(),tools:z({listChanged:ye().optional()}).optional(),tasks:Rv.optional(),extensions:ee(_(),he).optional()}),jv=be.extend({protocolVersion:_(),capabilities:Nv,serverInfo:ah,instructions:_().optional()}),Ba=et.extend({method:T("notifications/initialized"),params:Qe.optional()});var ds=we.extend({method:T("ping"),params:Ge.optional()}),Dv=z({progress:Y(),total:ue(Y()),message:ue(_())}),Zv=z({...Qe.shape,...Dv.shape,progressToken:Qm}),fs=et.extend({method:T("notifications/progress"),params:Zv}),Mv=Ge.extend({cursor:eh.optional()}),xn=we.extend({params:Mv.optional()}),Sn=be.extend({nextCursor:eh.optional()}),qv=Me(["working","input_required","completed","failed","cancelled"]),zn=z({taskId:_(),status:qv,ttl:oe([Y(),Lm()]),createdAt:_(),lastUpdatedAt:_(),pollInterval:ue(Y()),statusMessage:ue(_())}),Ir=be.extend({task:zn}),Fv=Qe.merge(zn),Pn=et.extend({method:T("notifications/tasks/status"),params:Fv}),ps=we.extend({method:T("tasks/get"),params:Ge.extend({taskId:_()})}),ms=be.merge(zn),hs=we.extend({method:T("tasks/result"),params:Ge.extend({taskId:_()})}),UA=be.loose(),gs=xn.extend({method:T("tasks/list")}),ys=Sn.extend({tasks:B(zn)}),_s=we.extend({method:T("tasks/cancel"),params:Ge.extend({taskId:_()})}),ch=be.merge(zn),uh=z({uri:_(),mimeType:ue(_()),_meta:ee(_(),ce()).optional()}),lh=uh.extend({text:_()}),Ha=_().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),dh=uh.extend({blob:Ha}),In=Me(["user","assistant"]),Er=z({audience:B(In).optional(),priority:Y().min(0).max(1).optional(),lastModified:ss.datetime({offset:!0}).optional()}),fh=z({...Pr.shape,...kn.shape,uri:_(),description:ue(_()),mimeType:ue(_()),size:ue(Y()),annotations:Er.optional(),_meta:ue(Ce({}))}),Lv=z({...Pr.shape,...kn.shape,uriTemplate:_(),description:ue(_()),mimeType:ue(_()),annotations:Er.optional(),_meta:ue(Ce({}))}),Uv=xn.extend({method:T("resources/list")}),Vv=Sn.extend({resources:B(fh)}),Bv=xn.extend({method:T("resources/templates/list")}),Hv=Sn.extend({resourceTemplates:B(Lv)}),Ka=Ge.extend({uri:_()}),Kv=Ka,Jv=we.extend({method:T("resources/read"),params:Kv}),Gv=be.extend({contents:B(oe([lh,dh]))}),Wv=et.extend({method:T("notifications/resources/list_changed"),params:Qe.optional()}),Yv=Ka,Xv=we.extend({method:T("resources/subscribe"),params:Yv}),Qv=Ka,e$=we.extend({method:T("resources/unsubscribe"),params:Qv}),t$=Qe.extend({uri:_()}),r$=et.extend({method:T("notifications/resources/updated"),params:t$}),n$=z({name:_(),description:ue(_()),required:ue(ye())}),o$=z({...Pr.shape,...kn.shape,description:ue(_()),arguments:ue(B(n$)),_meta:ue(Ce({}))}),s$=xn.extend({method:T("prompts/list")}),i$=Sn.extend({prompts:B(o$)}),a$=Ge.extend({name:_(),arguments:ee(_(),_()).optional()}),c$=we.extend({method:T("prompts/get"),params:a$}),Ja=z({type:T("text"),text:_(),annotations:Er.optional(),_meta:ee(_(),ce()).optional()}),Ga=z({type:T("image"),data:Ha,mimeType:_(),annotations:Er.optional(),_meta:ee(_(),ce()).optional()}),Wa=z({type:T("audio"),data:Ha,mimeType:_(),annotations:Er.optional(),_meta:ee(_(),ce()).optional()}),u$=z({type:T("tool_use"),name:_(),id:_(),input:ee(_(),ce()),_meta:ee(_(),ce()).optional()}),l$=z({type:T("resource"),resource:oe([lh,dh]),annotations:Er.optional(),_meta:ee(_(),ce()).optional()}),d$=fh.extend({type:T("resource_link")}),Ya=oe([Ja,Ga,Wa,d$,l$]),f$=z({role:In,content:Ya}),p$=be.extend({description:_().optional(),messages:B(f$)}),m$=et.extend({method:T("notifications/prompts/list_changed"),params:Qe.optional()}),h$=z({title:_().optional(),readOnlyHint:ye().optional(),destructiveHint:ye().optional(),idempotentHint:ye().optional(),openWorldHint:ye().optional()}),g$=z({taskSupport:Me(["required","optional","forbidden"]).optional()}),ph=z({...Pr.shape,...kn.shape,description:_().optional(),inputSchema:z({type:T("object"),properties:ee(_(),he).optional(),required:B(_()).optional()}).catchall(ce()),outputSchema:z({type:T("object"),properties:ee(_(),he).optional(),required:B(_()).optional()}).catchall(ce()).optional(),annotations:h$.optional(),execution:g$.optional(),_meta:ee(_(),ce()).optional()}),Xa=xn.extend({method:T("tools/list")}),y$=Sn.extend({tools:B(ph)}),ws=be.extend({content:B(Ya).default([]),structuredContent:ee(_(),ce()).optional(),isError:ye().optional()}),VA=ws.or(be.extend({toolResult:ce()})),_$=vn.extend({name:_(),arguments:ee(_(),ce()).optional()}),En=we.extend({method:T("tools/call"),params:_$}),w$=et.extend({method:T("notifications/tools/list_changed"),params:Qe.optional()}),BA=z({autoRefresh:ye().default(!0),debounceMs:Y().int().nonnegative().default(300)}),Tn=Me(["debug","info","notice","warning","error","critical","alert","emergency"]),b$=Ge.extend({level:Tn}),Qa=we.extend({method:T("logging/setLevel"),params:b$}),v$=Qe.extend({level:Tn,logger:_().optional(),data:ce()}),$$=et.extend({method:T("notifications/message"),params:v$}),k$=z({name:_().optional()}),x$=z({hints:B(k$).optional(),costPriority:Y().min(0).max(1).optional(),speedPriority:Y().min(0).max(1).optional(),intelligencePriority:Y().min(0).max(1).optional()}),S$=z({mode:Me(["auto","required","none"]).optional()}),z$=z({type:T("tool_result"),toolUseId:_().describe("The unique identifier for the corresponding tool call."),content:B(Ya).default([]),structuredContent:z({}).loose().optional(),isError:ye().optional(),_meta:ee(_(),ce()).optional()}),P$=ja("type",[Ja,Ga,Wa]),is=ja("type",[Ja,Ga,Wa,u$,z$]),I$=z({role:In,content:oe([is,B(is)]),_meta:ee(_(),ce()).optional()}),E$=vn.extend({messages:B(I$),modelPreferences:x$.optional(),systemPrompt:_().optional(),includeContext:Me(["none","thisServer","allServers"]).optional(),temperature:Y().optional(),maxTokens:Y().int(),stopSequences:B(_()).optional(),metadata:he.optional(),tools:B(ph).optional(),toolChoice:S$.optional()}),T$=we.extend({method:T("sampling/createMessage"),params:E$}),On=be.extend({model:_(),stopReason:ue(Me(["endTurn","stopSequence","maxTokens"]).or(_())),role:In,content:P$}),ec=be.extend({model:_(),stopReason:ue(Me(["endTurn","stopSequence","maxTokens","toolUse"]).or(_())),role:In,content:oe([is,B(is)])}),O$=z({type:T("boolean"),title:_().optional(),description:_().optional(),default:ye().optional()}),R$=z({type:T("string"),title:_().optional(),description:_().optional(),minLength:Y().optional(),maxLength:Y().optional(),format:Me(["email","uri","date","date-time"]).optional(),default:_().optional()}),A$=z({type:Me(["number","integer"]),title:_().optional(),description:_().optional(),minimum:Y().optional(),maximum:Y().optional(),default:Y().optional()}),C$=z({type:T("string"),title:_().optional(),description:_().optional(),enum:B(_()),default:_().optional()}),N$=z({type:T("string"),title:_().optional(),description:_().optional(),oneOf:B(z({const:_(),title:_()})),default:_().optional()}),j$=z({type:T("string"),title:_().optional(),description:_().optional(),enum:B(_()),enumNames:B(_()).optional(),default:_().optional()}),D$=oe([C$,N$]),Z$=z({type:T("array"),title:_().optional(),description:_().optional(),minItems:Y().optional(),maxItems:Y().optional(),items:z({type:T("string"),enum:B(_())}),default:B(_()).optional()}),M$=z({type:T("array"),title:_().optional(),description:_().optional(),minItems:Y().optional(),maxItems:Y().optional(),items:z({anyOf:B(z({const:_(),title:_()}))}),default:B(_()).optional()}),q$=oe([Z$,M$]),F$=oe([j$,D$,q$]),L$=oe([F$,O$,R$,A$]),U$=vn.extend({mode:T("form").optional(),message:_(),requestedSchema:z({type:T("object"),properties:ee(_(),L$),required:B(_()).optional()})}),V$=vn.extend({mode:T("url"),message:_(),elicitationId:_(),url:_().url()}),B$=oe([U$,V$]),H$=we.extend({method:T("elicitation/create"),params:B$}),K$=Qe.extend({elicitationId:_()}),J$=et.extend({method:T("notifications/elicitation/complete"),params:K$}),Tr=be.extend({action:Me(["accept","decline","cancel"]),content:Da(e=>e===null?void 0:e,ee(_(),oe([_(),Y(),ye(),B(_())])).optional())}),G$=z({type:T("ref/resource"),uri:_()});var W$=z({type:T("ref/prompt"),name:_()}),Y$=Ge.extend({ref:oe([W$,G$]),argument:z({name:_(),value:_()}),context:z({arguments:ee(_(),_()).optional()}).optional()}),X$=we.extend({method:T("completion/complete"),params:Y$});var Q$=be.extend({completion:Ce({values:B(_()).max(100),total:ue(Y().int()),hasMore:ue(ye())})}),ek=z({uri:_().startsWith("file://"),name:_().optional(),_meta:ee(_(),ce()).optional()}),tk=we.extend({method:T("roots/list"),params:Ge.optional()}),tc=be.extend({roots:B(ek)}),rk=et.extend({method:T("notifications/roots/list_changed"),params:Qe.optional()}),HA=oe([ds,Va,X$,Qa,c$,s$,Uv,Bv,Jv,Xv,e$,En,Xa,ps,hs,gs,_s]),KA=oe([ls,fs,Ba,rk,Pn]),JA=oe([us,On,ec,Tr,tc,ms,ys,Ir]),GA=oe([ds,T$,H$,tk,ps,hs,gs,_s]),WA=oe([ls,fs,$$,r$,Wv,w$,m$,Pn,J$]),YA=oe([us,jv,Q$,p$,i$,Vv,Hv,Gv,ws,y$,ms,ys,Ir]),N=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===D.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Za(o.elicitations,r)}return new e(t,r,n)}},Za=class extends N{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(D.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var nk=10*1024*1024,bs=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??nk}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
|
|
67
|
+
`);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),ok(r)}clear(){this._buffer=void 0}};function ok(e){return ih.parse(JSON.parse(e))}function mh(e){return JSON.stringify(e)+`
|
|
68
|
+
`}var vs=class{constructor(t=hh.stdin,r=hh.stdout,n){this._stdin=t,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 bs({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 t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}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(t){return new Promise(r=>{let n=mh(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function rc(){return{schema:2,cells:[]}}function St(e,t=null){return{schema:2,id:e,source:t,chapters:[],cards:[],inspirations:[]}}function er(e){let t=0,r=0,n;for(let o of e.chapters)for(let s of o.sections)r+=1,s.done?t+=1:n===void 0&&(n={chapter:o,section:s});return{done:t,total:r,current:n}}function ks(e,t=tr()){if(e.targetDate===void 0)return;let{done:r,total:n}=er(e),o=n-r,s=sk(t,e.targetDate)+1;if(s<=0)return{remaining:o,daysLeft:s,overdue:o>0};let i=o===0?0:Math.ceil(o/s*10)/10;return{remaining:o,daysLeft:s,perDay:i,overdue:!1}}function _h(e,t=tr()){let{done:r,total:n}=er(e),o=ks(e,t);return{done:r,total:n,...o?.perDay!==void 0?{perDay:o.perDay}:{},...o?.overdue?{overdue:!0}:{},cards:e.cards.length,finished:e.finishedAt!==void 0,...e.source!==null?{source:e.source.type}:{},...gh(e)!==void 0?{period:gh(e)}:{},...yh(e,r,n)!==void 0?{percent:yh(e,r,n)}:{}}}function gh(e){let t=[...e.chapters.flatMap(o=>o.sections.map(s=>s.doneAt)),...e.cards.map(o=>o.createdAt),...e.inspirations.map(o=>o.createdAt)].filter(o=>typeof o=="string"&&o!=="");if(t.length===0)return e.finishedAt?{start:$s(e.finishedAt),end:$s(e.finishedAt)}:void 0;let r=$s(t.reduce((o,s)=>o<s?o:s));if(!e.finishedAt)return{start:r};let n=$s(e.finishedAt);return{start:r<n?r:n,end:n}}function $s(e){return/^\d{4}-\d{2}-\d{2}$/.test(e)?e.slice(0,7):tr(new Date(e)).slice(0,7)}function nc(e){let{position:t}=e;return e.source===null&&t&&(t.loc===""||t.loc.startsWith("weread:"))?t:void 0}function yh(e,t,r){if(e.finishedAt!==void 0)return 1;let n=e.source?.type==="epub"?e.position:nc(e);return n?n.percent:r>0?t/r:void 0}function Dt(e,t){if(t!==void 0)for(let r of e.chapters){let n=r.sections.find(o=>o.id===t);if(n!==void 0)return{chapter:r,section:n}}}function tr(e=new Date){let t=e.getFullYear(),r=String(e.getMonth()+1).padStart(2,"0"),n=String(e.getDate()).padStart(2,"0");return`${t}-${r}-${n}`}function sk(e,t){let r=Date.UTC(+e.slice(0,4),+e.slice(5,7)-1,+e.slice(8,10)),n=Date.UTC(+t.slice(0,4),+t.slice(5,7)-1,+t.slice(8,10));return Math.round((n-r)/864e5)}function wh(e){return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(e)}import{randomBytes as ik}from"node:crypto";import{cpSync as ak,existsSync as Or,lstatSync as ck,mkdirSync as xs,mkdtempSync as uk,readdirSync as bh,readFileSync as vh,renameSync as kh,rmSync as Ss,statSync as lk,writeFileSync as dk}from"node:fs";import{join as qe}from"node:path";var w=class extends Error{};function We(e){return`${e}_${ik(5).toString("hex")}`}function Ne(){return new Date().toISOString()}var xh=/^c_[0-9a-f]{10}$/,fk=new Set(["book","note","group"]);function Zt(e){if(typeof e!="string"||!xh.test(e))throw new w("\u683C\u5B50 id \u65E0\u6548")}function Is(e){return typeof e?.schema=="number"&&e.schema>2?e.schema:2}function pk(e){if(e===null||typeof e!="object"||!Array.isArray(e.cells))throw new Error("\u7F3A\u5C11 cells \u6570\u7EC4");for(let t of e.cells){if(typeof t?.id!="string"||!fk.has(t.kind)||!Number.isSafeInteger(t.col)||!Number.isSafeInteger(t.row)||typeof t.title!="string")throw new Error(`\u683C\u5B50\u683C\u5F0F\u6709\u8BEF\uFF1A${JSON.stringify(t)?.slice(0,80)}`);t.parentId===void 0&&(t.parentId=null)}return{...e,schema:Is(e),cells:e.cells}}function mk(e,t){if(e===null||typeof e!="object")throw new Error("\u4E0D\u662F JSON \u5BF9\u8C61");for(let r of["chapters","cards","inspirations"])if(e[r]!==void 0&&!Array.isArray(e[r]))throw new Error(`${r} \u5E94\u4E3A\u6570\u7EC4`);for(let r of e.chapters??[]){if(typeof r?.id!="string"||!Array.isArray(r.sections))throw new Error("\u7AE0\u683C\u5F0F\u6709\u8BEF");for(let n of r.sections)if(typeof n?.id!="string"||typeof n.done!="boolean")throw new Error("\u8282\u683C\u5F0F\u6709\u8BEF")}for(let r of e.cards??[])if(typeof r?.id!="string"||typeof r.type!="string")throw new Error("\u5361\u7247\u683C\u5F0F\u6709\u8BEF");for(let r of e.inspirations??[])if(typeof r?.id!="string")throw new Error("\u7075\u611F\u683C\u5F0F\u6709\u8BEF");if(e.source!==void 0&&e.source!==null&&typeof e.source!="object")throw new Error("source \u683C\u5F0F\u6709\u8BEF");return{...St(t),...e,schema:Is(e),id:t,chapters:e.chapters??[],cards:e.cards??[],inspirations:e.inspirations??[]}}function zs(e){let t=lk(e);return`${t.mtimeMs}:${t.size}`}function $h(e,t){let r=`${e}.${process.pid}.tmp`;return dk(r,JSON.stringify(t,null,2)+`
|
|
69
|
+
`,"utf8"),kh(r,e),zs(e)}var Es=class{dir;itemsDir;imagesDir;palaceFile;palace={value:rc(),stamp:"",broken:!1};items=new Map;rev=1;constructor(t,{create:r=!0}={}){this.dir=t,this.itemsDir=qe(t,"items"),this.imagesDir=qe(t,"images"),this.palaceFile=qe(t,"palace.json"),r&&(xs(this.itemsDir,{recursive:!0}),xs(this.imagesDir,{recursive:!0}));let n=this.refreshPalace();if(!r&&(n.stamp===""||n.broken))throw new w(`\u65E0\u6CD5\u8BFB\u53D6 ${this.palaceFile}`)}refreshPalace(){if(!Or(this.palaceFile))return this.palace.stamp!==""&&(this.palace={value:rc(),stamp:"",broken:!1},this.rev+=1),this.palace;let t=zs(this.palaceFile);if(t===this.palace.stamp)return this.palace;let r=this.palace.schema;try{let n=JSON.parse(vh(this.palaceFile,"utf8"));r=Is(n),this.palace={value:pk(n),stamp:t,broken:!1,schema:r}}catch(n){console.warn("[dsh-palace] palace.json \u89E3\u6790\u5931\u8D25\uFF0C\u7EE7\u7EED\u4F7F\u7528\u5185\u5B58\u4E2D\u7684\u6570\u636E",n),this.palace={...this.palace,stamp:t,broken:!0,schema:r}}return this.rev+=1,this.palace}refreshItem(t){Zt(t);let r=qe(this.itemsDir,`${t}.json`),n=this.items.get(t);if(!Or(r))return n!==void 0&&(this.items.delete(t),this.rev+=1),{value:St(t),stamp:"",broken:!1};let o=zs(r);if(n!==void 0&&n.stamp===o)return n;let s,i=n?.schema;try{let a=JSON.parse(vh(r,"utf8"));i=Is(a),s={value:mk(a,t),stamp:o,broken:!1,schema:i}}catch(a){console.warn(`[dsh-palace] items/${t}.json \u89E3\u6790\u5931\u8D25`,a),s={value:n?.value??St(t),stamp:o,broken:!0,schema:i}}return n!==void 0&&(this.rev+=1),this.items.set(t,s),s}getPalace(){return this.refreshPalace().value}getItem(t){return this.refreshItem(t).value}checkDisk(){for(let t of this.getPalace().cells)t.kind!=="group"&&this.refreshItem(t.id);return this.rev}summaries(){let t={};for(let r of this.getPalace().cells)r.kind!=="group"&&(t[r.id]=_h(this.getItem(r.id)));return t}snapshotBeforeWrite(){let t=".snapshots",r=qe(this.dir,t),n=qe(r,tr());try{let o=ck(r,{throwIfNoEntry:!1});if(o&&!o.isDirectory())throw new Error("\u5FEB\u7167\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55");if(Or(n))return;xs(r,{recursive:!0});let s=uk(qe(r,".partial-"));try{for(let a of bh(this.dir))a!==t&&ak(qe(this.dir,a),qe(s,a),{recursive:!0,verbatimSymlinks:!0});Or(n)||kh(s,n)}finally{Ss(s,{recursive:!0,force:!0})}let i=bh(r,{withFileTypes:!0}).filter(a=>a.isDirectory()&&/^\d{4}-\d{2}-\d{2}$/.test(a.name)).map(a=>a.name);for(let a of i.sort().slice(0,-3))Ss(qe(r,a),{recursive:!0,force:!0})}catch(o){console.warn("[dsh-palace] \u6BCF\u65E5\u5FEB\u7167\u5931\u8D25\uFF0C\u7EE7\u7EED\u5199\u5165",o)}}assertWritable(){let t=this.refreshPalace();this.assertSupportedSchema(t,"palace.json");for(let r of t.value.cells)r.kind==="group"||!xh.test(r.id)||this.assertSupportedSchema(this.refreshItem(r.id),`items/${r.id}.json`)}assertSupportedSchema(t,r){if((t.schema??2)>2)throw new w(`${r} \u7684\u6570\u636E\u7248\u672C\u8F83\u65B0\uFF0C\u8BF7\u5347\u7EA7\u63D2\u4EF6`)}mutate(t){try{return Promise.resolve(this.commit(t))}catch(r){return Promise.reject(r)}}commit(t){this.assertWritable();let r=this.palace;if(r.broken)throw new w("palace.json \u683C\u5F0F\u6709\u8BEF\uFF1A\u8BF7\u5148\u4FEE\u597D\u6216\u5220\u6389\u8FD9\u4E2A\u6587\u4EF6\uFF0C\u518D\u7EE7\u7EED\u64CD\u4F5C");let n=structuredClone(r.value),o=new Map,s=[],a=t({palace:n,item:f=>{let p=o.get(f);if(p!==void 0){if(p.item===null)throw new w("\u683C\u5B50\u5DF2\u5220\u9664");return p.item}let m=this.refreshItem(f);if(this.assertSupportedSchema(m,`items/${f}.json`),m.broken)throw new w(`items/${f}.json \u683C\u5F0F\u6709\u8BEF\uFF1A\u8BF7\u5148\u4FEE\u597D\u6216\u5220\u6389\u8FD9\u4E2A\u6587\u4EF6`);let h=structuredClone(m.value);return o.set(f,{item:h,before:JSON.stringify(m.value),stamp:m.stamp}),h},createItem:f=>{this.assertSupportedSchema(this.refreshItem(f.id),`items/${f.id}.json`),o.set(f.id,{item:f,before:"",stamp:""})},deleteItem:f=>{this.assertSupportedSchema(this.refreshItem(f),`items/${f}.json`),o.set(f,{item:null,before:"",stamp:""})},deleteImage:f=>{s.push(f)}});if(a instanceof Promise)throw new Error("mutate \u7684\u56DE\u8C03\u5FC5\u987B\u662F\u540C\u6B65\u7684");let c=JSON.stringify(n)!==JSON.stringify(r.value),u=[...o].filter(([,{item:f,before:p}])=>f===null||JSON.stringify(f)!==p);(c||u.length>0||s.length>0)&&this.snapshotBeforeWrite();let l=(f,p)=>(Or(f)?zs(f):"")!==p;if(l(this.palaceFile,r.stamp))throw new w("palace.json \u521A\u88AB\u5176\u4ED6\u7A0B\u5E8F\u4FEE\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5");for(let[f,p]of o)if(p.before!==""&&l(qe(this.itemsDir,`${f}.json`),p.stamp))throw new w(`items/${f}.json \u521A\u88AB\u5176\u4ED6\u7A0B\u5E8F\u4FEE\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5`);for(let[f,{item:p}]of u){if(p===null)continue;Or(this.itemsDir)||xs(this.itemsDir,{recursive:!0});let m=$h(qe(this.itemsDir,`${f}.json`),p);this.items.set(f,{value:p,stamp:m,broken:!1})}if(c){let f=$h(this.palaceFile,n);this.palace={value:n,stamp:f,broken:!1}}this.rev+=1;let d=(f,p)=>{try{p()}catch(m){console.warn(`[dsh-palace] \u6E05\u7406 ${f} \u5931\u8D25\uFF0C\u5DF2\u5FFD\u7565`,m)}};for(let[f,{item:p}]of o)p===null&&(this.items.delete(f),d(`items/${f}.json`,()=>Ss(qe(this.itemsDir,`${f}.json`),{force:!0})));for(let f of s)/^[\w.-]+$/.test(f)&&d(`images/${f}`,()=>Ss(qe(this.imagesDir,f),{force:!0}));return a}};function Mt(e,t){if(typeof e!="string"||e.trim()==="")throw new w(`${t}\u4E0D\u80FD\u4E3A\u7A7A`);return e.trim()}function Rn(e,t){if(e!=null){if(typeof e!="string")throw new w(`${t}\u5E94\u4E3A\u6587\u5B57`);return e.trim()===""?void 0:e.trim()}}function oc(e,t){if(!(e==null||e==="")){if(!wh(e))throw new w(`${t}\u683C\u5F0F\u5E94\u4E3A YYYY-MM-DD`);return e}}function Ts(e,t){if(!Number.isSafeInteger(e))throw new w(`${t}\u5E94\u4E3A\u6574\u6570`);return e}function An(e,t,r,n){n?delete e[t]:r!==void 0&&(e[t]=r)}function rr(e){return e===null||e===""}function nr(e,t){Zt(t);let r=e.cells.find(n=>n.id===t);if(r===void 0)throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");return r}function tt(e,t){let r=nr(e.palace,t);if(r.kind==="group")throw new w("\u5206\u7EC4\u6CA1\u6709\u7B14\u8BB0\u672C");return e.item(r.id)}function hk(e){let t=e;if(t?.type==="pdf"&&typeof t.path=="string"&&Number.isSafeInteger(t.pageCount))return{type:"pdf",path:t.path,pageCount:t.pageCount};if(t?.type==="epub"&&typeof t.path=="string")return{type:"epub",path:t.path};if(t?.type==="video"&&typeof t.url=="string")return{type:"video",url:t.url};throw new w("\u539F\u6587\u4FE1\u606F\u65E0\u6548")}function sc(e,t,r,n){return e.cells.find(o=>o.parentId===t&&o.col===r&&o.row===n)}function Cn(e,t){let r=e.cells.filter(o=>o.parentId===t).length,n=t===null?3:Math.max(2,Math.ceil(Math.sqrt(r+1)));for(let o=0;;o++){let s=o%n,i=Math.floor(o/n);if(sc(e,t,s,i)===void 0)return{col:s,row:i}}}function Sh(e,t,r){if(t==null)return null;let n=nr(e,t);if(n.kind!=="group")throw new w("\u53EA\u80FD\u653E\u8FDB\u5206\u7EC4\u91CC");if(r==="group")throw new w("\u5206\u7EC4\u91CC\u4E0D\u80FD\u518D\u653E\u5206\u7EC4");return n.id}function zh(e,t,r){if(e!==null&&(t<0||r<0))throw new w("\u5206\u7EC4\u91CC\u7684\u5750\u6807\u4E0D\u80FD\u4E3A\u8D1F")}function ic(e,t){t===null||e.cells.some(r=>r.parentId===t)||(e.cells=e.cells.filter(r=>r.id!==t))}var ac="https://dsh-palace.pages.dev";async function Ph(e){return e.mutate(t=>{let r={id:We("c"),kind:"note",parentId:null,...Cn(t.palace,null),title:"Memory Palace \u2197",subtitle:"\u4EC0\u4E48\u662F",icon:"open-book",href:ac,createdAt:Ne()};return t.palace.cells.push(r),t.createItem(St(r.id,null)),r})}async function qt(e,t){let r=t.kind;if(r!=="book"&&r!=="note"&&r!=="group")throw new w("\u683C\u5B50\u7C7B\u578B\u5E94\u4E3A book / note / group");let n=Mt(t.title,"\u6807\u9898"),o=Rn(t.subtitle,"\u5907\u6CE8"),s=r==="book"?hk(t.source):null,i=oc(t.targetDate,"\u76EE\u6807\u65E5\u671F");return e.mutate(a=>{let c=Sh(a.palace,t.parentId,r),u;if(t.col===void 0&&t.row===void 0)u=Cn(a.palace,c);else if(u={col:Ts(t.col,"\u5217"),row:Ts(t.row,"\u884C")},zh(c,u.col,u.row),sc(a.palace,c,u.col,u.row)!==void 0)throw new w("\u8FD9\u4E2A\u4F4D\u7F6E\u5DF2\u7ECF\u6709\u683C\u5B50\u4E86");let l={id:We("c"),kind:r,parentId:c,...u,title:n,...o?{subtitle:o}:{},createdAt:Ne()};if(a.palace.cells.push(l),r!=="group"){let d=St(l.id,s);i!==void 0&&(d.targetDate=i),r==="book"&&t.outline!==void 0&&(d.chapters=As(t.outline),d.chapters.length>0&&t.outlineSource!==void 0&&(d.outlineSource=t.outlineSource)),a.createItem(d)}return l})}async function Ih(e,t){let r=t.title===void 0?void 0:Mt(t.title,"\u6807\u9898"),n=Rn(t.subtitle,"\u5907\u6CE8"),o=Rn(t.icon,"\u56FE\u6807");if(o!==void 0&&!/^[a-z][a-z0-9-]{0,30}$/.test(o))throw new w("\u56FE\u6807\u540D\u65E0\u6548");return e.mutate(s=>{let i=nr(s.palace,t.id);return r!==void 0&&(i.title=r),An(i,"subtitle",n,rr(t.subtitle)),An(i,"icon",o,rr(t.icon)),i})}async function Eh(e,t){let r=t.col===void 0&&t.row===void 0,n=r?0:Ts(t.col,"\u5217"),o=r?0:Ts(t.row,"\u884C");return e.mutate(s=>{let i=nr(s.palace,t.id),a=Sh(s.palace,t.parentId,i.kind);if(a===i.id)throw new w("\u4E0D\u80FD\u653E\u8FDB\u81EA\u5DF1\u91CC\u9762");if(r){if(i.parentId===a)return i;({col:n,row:o}=Cn(s.palace,a))}zh(a,n,o);let c=[i.parentId],u=sc(s.palace,a,n,o);if(u!==void 0&&u.id!==i.id){if(c.push(u.parentId),u.kind==="group"&&i.parentId!==null)throw new w("\u5206\u7EC4\u4E0D\u80FD\u6362\u8FDB\u53E6\u4E00\u4E2A\u5206\u7EC4\u91CC");u.parentId=i.parentId,u.col=i.col,u.row=i.row}i.parentId=a,i.col=n,i.row=o;for(let l of c)ic(s.palace,l);return i})}async function Th(e,t){let r=t.title===void 0?"\u65B0\u5206\u7EC4":Mt(t.title,"\u6807\u9898");return e.mutate(n=>{let o=nr(n.palace,t.id),s=nr(n.palace,t.ontoId);if(o.id===s.id)throw new w("\u4E0D\u80FD\u548C\u81EA\u5DF1\u7EC4\u6210\u5206\u7EC4");if(o.kind==="group"||s.kind==="group")throw new w("\u5206\u7EC4\u4E0D\u80FD\u518D\u653E\u8FDB\u5206\u7EC4");if(s.parentId!==null)throw new w("\u53EA\u80FD\u5728\u6700\u5916\u5C42\u62D6\u6210\u5206\u7EC4");let i={id:We("c"),kind:"group",parentId:null,col:s.col,row:s.row,title:r,createdAt:Ne()};n.palace.cells.push(i),s.parentId=i.id,s.col=0,s.row=0;let a=o.parentId;return o.parentId=i.id,o.col=1,o.row=0,ic(n.palace,a),i})}async function Os(e,t){return e.mutate(r=>{let n=nr(r.palace,t.id);if(n.kind==="group"){if(r.palace.cells.some(o=>o.parentId===n.id))throw new w("\u5206\u7EC4\u91CC\u8FD8\u6709\u683C\u5B50\uFF0C\u5148\u79FB\u51FA\u53BB\u6216\u5220\u6389")}else{for(let o of r.item(n.id).cards)o.image&&r.deleteImage(o.image);r.deleteItem(n.id)}r.palace.cells=r.palace.cells.filter(o=>o.id!==n.id),ic(r.palace,n.parentId)})}async function Rs(e,t){let r=oc(t.targetDate,"\u76EE\u6807\u65E5\u671F"),n=oc(t.finishedAt,"\u8BFB\u5B8C\u65E5\u671F");return e.mutate(o=>{let s=tt(o,t.id);return An(s,"targetDate",r,rr(t.targetDate)),An(s,"finishedAt",n,rr(t.finishedAt)),s})}async function Oh(e,t){let r=Mt(t.loc,"\u4F4D\u7F6E"),n=t.percent;if(typeof n!="number"||!(n>=0&&n<=1))throw new w("percent \u5E94\u4E3A 0\u20131 \u7684\u5C0F\u6570");return e.mutate(o=>{tt(o,t.id).position={loc:r,percent:n}})}function As(e,t=[]){let r=new Map;for(let o of t)for(let s of o.sections)s.done&&r.set(`${o.title}\0${s.title}`,s);let n=o=>typeof o=="string"&&o!==""?{loc:o}:{};return e.filter(o=>typeof o?.title=="string"&&o.title.trim()!=="").map(o=>{let s=o.title.trim(),i=(o.sections??[]).map(c=>typeof c=="string"?{title:c}:c).filter(c=>typeof c?.title=="string"&&c.title.trim()!==""),a=(i.length>0?i:[{title:s,loc:o.loc}]).map(c=>{let u=c.title.trim(),l=r.get(`${s}\0${u}`);return{id:We("s"),title:u,...n(c.loc),done:l!==void 0,...l?.doneAt!==void 0?{doneAt:l.doneAt}:{}}});return{id:We("ch"),title:s,sections:a}})}async function Cs(e,t){if(!Array.isArray(t.chapters)||t.chapters.length===0)throw new w("\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A");let r=t.chapters;return e.mutate(n=>{let o=tt(n,t.id),s=(u,l)=>`${u.title}\0${l.title}`,i=new Map;for(let u of o.chapters)for(let l of u.sections)i.set(l.id,s(u,l));let a=As(r,o.chapters);if(a.length===0)throw new w("\u76EE\u5F55\u4E0D\u80FD\u4E3A\u7A7A");o.chapters=a;let c=new Map;for(let u of o.chapters)for(let l of u.sections)c.has(s(u,l))||c.set(s(u,l),l.id);for(let u of o.cards){if(u.sectionId===void 0)continue;let l=c.get(i.get(u.sectionId)??"");l!==void 0?u.sectionId=l:delete u.sectionId}return t.source!==void 0&&(o.outlineSource=t.source),o})}async function Rh(e,t){return e.mutate(r=>{let n=Dt(tt(r,t.id),t.sectionId);if(n===void 0)throw new w("\u8282\u4E0D\u5B58\u5728");n.section.done=t.done===!0,n.section.done?n.section.doneAt=Ne():delete n.section.doneAt})}async function Ah(e,t){return e.mutate(r=>{let n=tt(r,t.id);if(Dt(n,t.sectionId)===void 0)throw new w("\u8282\u4E0D\u5B58\u5728");let o=!0,s=Ne();for(let i of n.chapters)for(let a of i.sections)o&&!a.done&&(a.done=!0,a.doneAt=s),!o&&a.done&&(a.done=!1,delete a.doneAt),a.id===t.sectionId&&(o=!1)})}async function Ch(e,t){return e.mutate(r=>{for(let n of tt(r,t.id).chapters)for(let o of n.sections)o.done=!1,delete o.doneAt})}var gk=new Set(["excerpt","thought","mistake"]);function Nh(e,t,r){for(let n of e.palace.cells)if(n.kind!=="group"&&e.item(n.id).cards.some(o=>o.image===t&&o.id!==r))throw new w("\u8FD9\u5F20\u56FE\u7247\u5DF2\u7ECF\u5C5E\u4E8E\u53E6\u4E00\u5F20\u5361\u7247")}function jh(e){if(e.type==="thought"&&e.note===void 0)throw new w("\u60F3\u6CD5\u4E0D\u80FD\u4E3A\u7A7A");if(e.type!=="thought"&&e.quote===void 0&&e.image===void 0)throw new w("\u6458\u5F55\u548C\u9519\u9898\u9700\u8981\u539F\u6587\u6216\u56FE\u7247")}function Dh(e,t,r){if(t.sectionId!==void 0&&!rr(t.sectionId)&&Dt(e,t.sectionId)===void 0)throw new w("\u8282\u4E0D\u5B58\u5728");if(t.status!==void 0&&t.status!=="todo"&&t.status!=="mastered")throw new w("\u72B6\u6001\u5E94\u4E3A todo / mastered");if(t.image!==void 0&&!rr(t.image)&&(typeof t.image!="string"||!/^[\w.-]+$/.test(t.image)))throw new w("\u56FE\u7247\u6587\u4EF6\u540D\u65E0\u6548");for(let n of["sectionId","loc","quote","note","answer","image"])An(r,n,Rn(t[n],n),rr(t[n]));if(t.status!==void 0&&(r.status=t.status),t.share!==void 0)if(t.share===null)delete r.share;else{if(typeof t.share!="object"||Array.isArray(t.share))throw new w("\u5206\u4EAB\u8349\u7A3F\u683C\u5F0F\u4E0D\u5BF9");if(JSON.stringify(t.share).length>64*1024)throw new w("\u5206\u4EAB\u8349\u7A3F\u592A\u5927");r.share=t.share}}async function Ns(e,t){let r=t.type;if(!gk.has(r))throw new w("\u5361\u7247\u7C7B\u578B\u5E94\u4E3A excerpt / thought / mistake");return e.mutate(n=>{let o=tt(n,t.id),s={id:We("k"),type:r,createdAt:Ne()};return Dh(o,t,s),r==="mistake"&&s.status===void 0&&(s.status="todo"),jh(s),s.image!==void 0&&Nh(n,s.image,s.id),o.cards.push(s),s})}async function Zh(e,t){return e.mutate(r=>{let n=tt(r,t.id),o=n.cards.find(i=>i.id===t.cardId);if(o===void 0)throw new w("\u5361\u7247\u4E0D\u5B58\u5728");if(t.type!==void 0)throw new w("\u5361\u7247\u7C7B\u578B\u4E0D\u80FD\u4FEE\u6539");let s=o.image;return Dh(n,t,o),jh(o),o.image!==void 0&&o.image!==s&&Nh(r,o.image,o.id),s!==void 0&&s!==o.image&&r.deleteImage(s),o})}async function Mh(e,t){return e.mutate(r=>{let n=tt(r,t.id),o=n.cards.find(s=>s.id===t.cardId);if(o===void 0)throw new w("\u5361\u7247\u4E0D\u5B58\u5728");o.image&&r.deleteImage(o.image),n.cards=n.cards.filter(s=>s.id!==o.id);for(let s of n.inspirations)s.cardIds&&(s.cardIds=s.cardIds.filter(i=>i!==o.id))})}async function js(e,t){let r=Mt(t.title,"\u7075\u611F\u6807\u9898"),n=Mt(t.body,"\u7075\u611F\u6B63\u6587"),o=Rn(t.sessionId,"sessionId");return e.mutate(s=>{let i=tt(s,t.id),a=Array.isArray(t.cardIds)?t.cardIds.filter(u=>i.cards.some(l=>l.id===u)):[],c={id:We("i"),title:r,body:n,...o?{sessionId:o}:{},...a.length?{cardIds:a}:{},createdAt:Ne()};return i.inspirations.push(c),c})}async function qh(e,t){let r=t.title===void 0?void 0:Mt(t.title,"\u7075\u611F\u6807\u9898"),n=t.body===void 0?void 0:Mt(t.body,"\u7075\u611F\u6B63\u6587");return e.mutate(o=>{let s=tt(o,t.id).inspirations.find(i=>i.id===t.inspirationId);if(s===void 0)throw new w("\u7075\u611F\u4E0D\u5B58\u5728");return r!==void 0&&(s.title=r),n!==void 0&&(s.body=n),s})}async function Fh(e,t){return e.mutate(r=>{let n=tt(r,t.id);if(!n.inspirations.some(o=>o.id===t.inspirationId))throw new w("\u7075\u611F\u4E0D\u5B58\u5728");n.inspirations=n.inspirations.filter(o=>o.id!==t.inspirationId)})}import{isAbsolute as CT}from"node:path";function Ds(e){return!!e._zod}function Ft(e,t){return Ds(e)?Xi(e,t):e.safeParse(t)}function Zs(e){if(!e)return;let t;if(Ds(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Ms(e){if(Ds(e)){let s=e._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=e._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=e.value;if(n!==void 0)return n}function Lt(e){return e==="completed"||e==="failed"||e==="cancelled"}var oC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function uc(e){let r=Zs(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Ms(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function lc(e,t){let r=Ft(e,t);if(!r.success)throw r.error;return r.data}var kk=6e4,qs=class{constructor(t){this._options=t,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(ls,r=>{this._oncancel(r)}),this.setNotificationHandler(fs,r=>{this._onprogress(r)}),this.setRequestHandler(ds,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ps,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new N(D.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(hs,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(!await this._taskStore.getTask(s,n.sessionId))throw new N(D.InvalidParams,`Task not found: ${s}`);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 N(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 N(D.InvalidParams,`Task not found: ${s}`);if(!Lt(i.status))return await this._waitForTaskUpdate(s,n.signal,n.sessionId),await o();if(Lt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s,n.sessionId),{...a,_meta:{...a._meta,[jt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(gs,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 N(D.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(_s,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new N(D.InvalidParams,`Task not found: ${r.params.taskId}`);if(Lt(o.status))throw new N(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,n.sessionId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new N(D.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof N?o:new N(D.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),N.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(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){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=t;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),$n(s)||sh(s)?this._onresponse(s):Fa(s)?this._onrequest(s,i):oh(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=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=N.fromError(D.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[jt]?.taskId,i=o?.sessionId,a=this._taskStore,c=!0,u;if(s&&a&&this._taskMessageQueue&&i!==void 0&&(c=!1,u=(async()=>{if(!await a.getTask(s,i))throw new N(D.InvalidParams,`Task not found: ${s}`);c=!0})()),n===void 0){let m={jsonrpc:"2.0",id:t.id,error:{code:D.MethodNotFound,message:"Method not found"}};if(s&&u){let h={type:"error",message:m,timestamp:Date.now()};u.then(()=>this._enqueueTaskMessage(s,h,i),()=>o?.send(m)).catch(g=>this._onerror(new Error(`Failed to send an error response: ${g}`)))}else s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:m,timestamp:Date.now()},o?.sessionId).catch(h=>this._onerror(new Error(`Failed to enqueue error response: ${h}`))):o?.send(m).catch(h=>this._onerror(new Error(`Failed to send an error response: ${h}`)));return}let l=new AbortController;this._requestHandlerAbortControllers.set(t.id,l);let d=th(t.params)?t.params.task:void 0,f=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,p={signal:l.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async m=>{if(l.signal.aborted)return;let h={relatedRequestId:t.id};s&&(h.relatedTask={taskId:s}),await this.notification(m,h)},sendRequest:async(m,h,g)=>{if(l.signal.aborted)throw new N(D.ConnectionClosed,"Request was cancelled");let y={...g,relatedRequestId:t.id};s&&!y.relatedTask&&(y.relatedTask={taskId:s});let v=y.relatedTask?.taskId??s;return v&&f&&await f.updateTaskStatus(v,"input_required"),await this.request(m,h,y)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:f,taskRequestedTtl:d?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};(u??Promise.resolve()).then(()=>{if(u&&l.signal.aborted)throw new N(D.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,p)).then(async m=>{if(l.signal.aborted)return;let h={result:m,jsonrpc:"2.0",id:t.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:h,timestamp:Date.now()},o?.sessionId):await o?.send(h)},async m=>{if(l.signal.aborted)return;let h={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(m.code)?m.code:D.InternalError,message:m.message??"Internal error",...m.data!==void 0&&{data:m.data}}};s&&this._taskMessageQueue&&c?await this._enqueueTaskMessage(s,{type:"error",message:h,timestamp:Date.now()},o?.sessionId):await o?.send(h)}).catch(m=>this._onerror(new Error(`Failed to send response: ${m}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.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(t)}`));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(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),$n(t))n(t);else{let i=new N(t.error.code,t.error.message,t.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(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if($n(t)&&t.result&&typeof t.result=="object"){let i=t.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),$n(t))o(t);else{let i=N.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof N?i:new N(D.InternalError,String(i))}}return}let s;try{let i=await this.request(t,Ir,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new N(D.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Lt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new N(D.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new N(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 N?i:new N(D.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[jt]:c}});let m=v=>{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(v)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(I=>this._onerror(new Error(`Failed to send cancellation: ${I}`)));let $=v instanceof N?v:new N(D.RequestTimeout,String(v));l($)};this._responseHandlers.set(f,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let $=Ft(r,v.result);$.success?u($.data):l($.error)}catch($){l($)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??kk,g=()=>m(N.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 v=$=>{let I=this._responseHandlers.get(f);I?I($):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,v),this._enqueueTaskMessage(y,{type:"request",message:p,timestamp:Date.now()}).catch($=>{this._cleanupTimeout(f),l($)})}else this._transport.send(p,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(v=>{this._cleanupTimeout(f),l(v)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},ms,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},ys,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},ch,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[jt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[jt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[jt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=uc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=lc(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=uc(t);this._notificationHandlers.set(n,o=>{let s=lc(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,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(t,r,n??this._transport?.sessionId,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&Fa(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new N(D.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r,n){let o=this._options?.defaultTaskPollInterval??1e3;try{let s=await this._taskStore?.getTask(t,n);s?.pollInterval&&(o=s.pollInterval)}catch{}return new Promise((s,i)=>{if(r.aborted){i(new N(D.InvalidRequest,"Request cancelled"));return}let a=setTimeout(s,o);r.addEventListener("abort",()=>{clearTimeout(a),i(new N(D.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new N(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=Pn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Lt(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 N(D.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Lt(a.status))throw new N(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=Pn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Lt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Lh(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Uh(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];Lh(i)&&Lh(s)?r[o]={...i,...s}:r[o]=s}return r}var B_=zl(tl(),1),H_=zl(V_(),1);function jE(){let e=new B_.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,H_.default)(e),e}var Gr=class{constructor(t){this._ajv=t??jE()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Si=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.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:t},On,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.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"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},Tr,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function K_(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function J_(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var zi=class extends qs{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Tn.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 Gr,this.setRequestHandler(Va,n=>this._oninitialize(n)),this.setNotificationHandler(Ba,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Qa,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Tn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Si(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Uh(this._capabilities,t)}setRequestHandler(t,r){let o=Zs(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Ms(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=Ft(En,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new N(D.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=Ft(Ir,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new N(D.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=Ft(ws,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new N(D.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);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 ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);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 ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);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 ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){J_(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&K_(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:Xm.includes(r)?r:Ma,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"},us)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.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 t.tools?this.request({method:"sampling/createMessage",params:t},ec,r):this.request({method:"sampling/createMessage",params:t},On,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},Tr,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Tr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new N(D.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof N?i:new N(D.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(t,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:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},tc,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}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"})}};import{appendFileSync as DE,existsSync as ul,mkdirSync as ZE,readFileSync as ll,renameSync as ME,statSync as G_,writeFileSync as qE}from"node:fs";import{join as po}from"node:path";var ho=500,W_=40,Y_=40,X_=5,fl=e=>[...e].length;function dl(e){if(typeof e!="string"||e.trim()==="")throw new w("\u8981\u5199\u4E00\u53E5\u7406\u7531");let t=e.trim().replace(/\n/g," ");if(fl(t)>Y_)throw new w(`\u7406\u7531\u6700\u591A ${Y_} \u5B57`);return t}var Ee=(e,t)=>e<t?`${e}|${t}`:`${t}|${e}`;function mo(e){let t=new Map;for(let r of e.cards)t.set(r.id,r.createdAt);for(let r of e.inspirations)t.set(r.id,r.createdAt);return t}function FE(e){let t=/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/.exec(e);if(t===null)return{body:e.trim(),writtenAt:""};let r={};for(let o of t[1].split(`
|
|
70
|
+
`)){let s=o.indexOf(":");s>0&&(r[o.slice(0,s).trim()]=o.slice(s+1).trim())}let n;try{n=r.topics?JSON.parse(r.topics):void 0}catch{n=void 0}return{...r.summary?{summary:r.summary}:{},...Array.isArray(n)?{topics:n.filter(o=>typeof o=="string")}:{},body:t[2].trim(),writtenAt:r.writtenAt??""}}function LE(e){return`---
|
|
71
71
|
${[...e.summary?[`summary: ${e.summary}`]:[],...e.topics?.length?[`topics: ${JSON.stringify(e.topics)}`]:[],`writtenAt: ${e.writtenAt}`].join(`
|
|
72
72
|
`)}
|
|
73
73
|
---
|
|
74
74
|
${e.body}
|
|
75
|
-
`}var
|
|
76
|
-
`))if(o.trim()!=="")try{let s=JSON.parse(o);(s.type==="link"||s.type==="cut")&&typeof s.from=="string"&&typeof s.to=="string"&&n.push(s)}catch{}return this.cache={stamp:r,records:n},n}append(t){this.store.assertWritable(),this.store.snapshotBeforeWrite();let n=(
|
|
77
|
-
`;
|
|
78
|
-
`:"")+JSON.stringify(
|
|
79
|
-
|
|
75
|
+
`}var Wr=class{dir;cellsDir;linksFile;cache={stamp:"",records:[]};store;constructor(t){this.store=t,this.dir=po(t.dir,"memory"),this.cellsDir=po(this.dir,"cells"),this.linksFile=po(t.dir,"links.jsonl")}pageFile(t){return t==="me"?po(this.dir,"me.md"):(Zt(t),po(this.cellsDir,`${t}.md`))}readPage(t){let r=this.pageFile(t);if(ul(r))try{return FE(ll(r,"utf8"))}catch{return}}writePage(t,r){if(this.store.assertWritable(),t!=="me"&&this.cellOf(t,!1),typeof r.body!="string"||r.body.trim()==="")throw new w("\u6B63\u6587\u4E0D\u80FD\u4E3A\u7A7A");let n=r.body.trim(),o=fl(n);if(o>ho)throw new w(`\u6B63\u6587 ${o} \u5B57\uFF0C\u4E0A\u9650 ${ho} \u5B57\uFF1A\u8BF7\u5408\u5E76\u76F8\u8FD1\u7684\u5185\u5BB9\u3001\u5220\u6389\u8FC7\u65F6\u7684\uFF0C\u7CBE\u7B80\u540E\u518D\u5199`);let s=typeof r.summary=="string"&&r.summary.trim()!==""?r.summary.trim().replace(/\n/g," "):void 0;if(s!==void 0&&fl(s)>W_)throw new w(`\u4E00\u53E5\u8BDD\u6982\u62EC\u6700\u591A ${W_} \u5B57`);let i;if(r.topics!==void 0){if(!Array.isArray(r.topics))throw new w("\u4E3B\u9898\u8BCD\u5E94\u4E3A\u6570\u7EC4");if(i=[...new Set(r.topics.filter(l=>typeof l=="string").map(l=>l.trim()).filter(Boolean))],i.length>X_)throw new w(`\u4E3B\u9898\u8BCD\u6700\u591A ${X_} \u4E2A`)}let a={...t!=="me"&&s?{summary:s}:{},...t!=="me"&&i?.length?{topics:i}:{},body:n,writtenAt:Ne()},c=this.pageFile(t);this.store.snapshotBeforeWrite(),ZE(this.cellsDir,{recursive:!0});let u=`${c}.${process.pid}.tmp`;return qE(u,LE(a),"utf8"),ME(u,c),a}debt(t){let r=this.readPage(t)?.writtenAt??"",n=0;for(let o of mo(this.store.getItem(t)).values())o>r&&(n+=1);return n}records(){if(!ul(this.linksFile))return[];let t=G_(this.linksFile),r=`${t.mtimeMs}:${t.size}`;if(r===this.cache.stamp)return this.cache.records;let n=[];for(let o of ll(this.linksFile,"utf8").split(`
|
|
76
|
+
`))if(o.trim()!=="")try{let s=JSON.parse(o);(s.type==="link"||s.type==="cut"||s.type==="retitle"&&typeof s.why=="string")&&typeof s.from=="string"&&typeof s.to=="string"&&n.push(s)}catch{}return this.cache={stamp:r,records:n},n}append(t){if(t.length===0)return;this.store.assertWritable(),this.store.snapshotBeforeWrite();let n=(ul(this.linksFile)?G_(this.linksFile).size:0)>0&&ll(this.linksFile,"utf8").at(-1)!==`
|
|
77
|
+
`;DE(this.linksFile,(n?`
|
|
78
|
+
`:"")+t.map(o=>JSON.stringify(o)).join(`
|
|
79
|
+
`)+`
|
|
80
|
+
`,"utf8"),this.store.rev+=1}cellOf(t,r){Zt(t);let n=this.store.getPalace().cells.find(o=>o.id===t);if(n===void 0||!r&&n.kind==="group")throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");return n}lastCut(t,r){let n="";for(let o of this.records())o.type==="cut"&&Ee(o.from,o.to)===Ee(t,r)&&o.createdAt>n&&(n=o.createdAt);return n}addLink(t){let r=this.cellOf(t.from,!1),n=this.cellOf(t.to,!1);if(r.id===n.id)throw new w("\u4E0D\u80FD\u8FDE\u5230\u81EA\u5DF1");let o=dl(t.why);if(!Array.isArray(t.evidence))throw new w("evidence \u5E94\u4E3A\u5361\u7247 / \u7075\u611F id \u7684\u6570\u7EC4");let s=[...new Set(t.evidence.filter(d=>typeof d=="string"))],i=mo(this.store.getItem(r.id)),a=mo(this.store.getItem(n.id)),c=s.filter(d=>!i.has(d)&&!a.has(d));if(c.length>0)throw new w(`\u8FD9\u4E9B\u8BC1\u636E\u4E0D\u5728\u4E24\u7AEF\u7684\u683C\u5B50\u91CC\uFF1A${c.join("\u3001")}`);if(!s.some(d=>i.has(d))||!s.some(d=>a.has(d)))throw new w("\u4E24\u7AEF\u90FD\u8981\u81F3\u5C11\u6709\u4E00\u5F20\u5361\u7247\u6216\u4E00\u6761\u7075\u611F\u4F5C\u4E3A\u8BC1\u636E");if(this.lastCut(r.id,n.id)!==""&&t.userAsked!==!0)throw new w("\u7528\u6237\u526A\u65AD\u8FC7\u8FD9\u4E24\u683C\u4E4B\u95F4\u7684\u7535\u5F27\uFF1A\u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\u91CD\u65B0\u8FDE\uFF0C\u5426\u5219\u4E0D\u8981\u518D\u8FDE");let u=new Set(this.validLinks().filter(d=>Ee(d.from,d.to)===Ee(r.id,n.id)).flatMap(d=>d.evidence));if(s.every(d=>u.has(d)))throw new w("\u8FD9\u4E9B\u8BC1\u636E\u5DF2\u7ECF\u8FDE\u8FC7\u4E86\uFF1B\u6709\u65B0\u7684\u5361\u7247\u6216\u7075\u611F\u518D\u8FDE");let l={type:"link",id:We("l"),from:r.id,to:n.id,why:o,evidence:s,...t.sessionId?{sessionId:t.sessionId}:{},createdAt:Ne()};return this.append([l]),l}previewImportedLinks(t){let r=this.records(),n=new Set(r.filter(l=>l.type==="cut").map(l=>Ee(l.from,l.to))),o=new Set(r.flatMap(l=>l.type==="link"&&l.sourceKey?[l.sourceKey]:[])),s=this.validLinks(),i=new Set(s.map(l=>l.sourceKey)),a=new Set(s.map(l=>Ee(l.from,l.to))),c=t.filter(l=>!n.has(Ee(l.from,l.to))),u=c.filter(l=>!i.has(l.sourceKey));return{pending:c.filter(l=>!o.has(l.sourceKey)),arcs:new Set(u.map(l=>Ee(l.from,l.to)).filter(l=>!a.has(l))).size,strands:u.length}}addImportedLinks(t){if(t.length===0)return;let{pending:r}=this.previewImportedLinks(t);this.append(r.map(n=>({...n,type:"link",id:We("l"),why:dl(n.why),createdAt:Ne()})))}retitleLink(t){let r=this.cellOf(t.from,!1).id,n=this.cellOf(t.to,!1).id,o=dl(t.why),s=this.arcs().find(i=>Ee(i.from,i.to)===Ee(r,n));if(!s)throw new w("\u8FD9\u4E24\u683C\u4E4B\u95F4\u6CA1\u6709\u6709\u6548\u7535\u5F27");s.why!==o&&this.append([{type:"retitle",from:r,to:n,why:o}])}cut(t){let r=this.cellOf(t.from,!0),n=this.cellOf(t.to,!0);this.append([{type:"cut",from:r.id,to:n.id,createdAt:Ne()}])}validLinks(){let t=new Map(this.store.getPalace().cells.filter(i=>i.kind!=="group").map(i=>[i.id,i])),r=new Map,n=i=>{let a=r.get(i);return a===void 0&&(a=mo(this.store.getItem(i)),r.set(i,a)),a},o=this.records(),s=new Map;for(let i of o)if(i.type==="cut"){let a=Ee(i.from,i.to);i.createdAt>(s.get(a)??"")&&s.set(a,i.createdAt)}return o.filter(i=>{if(i.type!=="link"||!t.has(i.from)||!t.has(i.to)||i.createdAt<=(s.get(Ee(i.from,i.to))??""))return!1;let a=Array.isArray(i.evidence)?i.evidence:[];return a.some(c=>n(i.from).has(c))&&a.some(c=>n(i.to).has(c))})}arcs(){let t=new Map;for(let n of this.records())n.type==="cut"&&t.delete(Ee(n.from,n.to)),n.type==="retitle"&&t.set(Ee(n.from,n.to),n.why);let r=new Map;for(let n of this.validLinks()){let o=Ee(n.from,n.to),s=r.get(o);s?s.push(n):r.set(o,[n])}return[...r.values()].map(n=>{let o=n.reduce((s,i)=>i.createdAt>=s.createdAt?i:s);return{from:o.from,to:o.to,strands:n.length,why:t.get(Ee(o.from,o.to))??o.why,lastAt:o.createdAt,links:n}}).sort((n,o)=>o.strands-n.strands||(o.lastAt>n.lastAt?1:-1))}lastTouched(t,r){let n=t.createdAt,o=s=>{s!==void 0&&s>n&&(n=s)};if(t.kind!=="group"){let s=this.store.getItem(t.id);for(let i of mo(s).values())o(i);for(let i of s.chapters)for(let a of i.sections)o(a.doneAt);o(this.readPage(t.id)?.writtenAt)}for(let s of r)(s.from===t.id||s.to===t.id)&&o(s.lastAt);return n}context(t){let r=t.maxChars??6e3,n=this.store.getPalace(),o=this.arcs(),s=t.itemId!==void 0?n.cells.find(p=>p.id===t.itemId&&p.kind!=="group"):void 0,i=new Set;if(s)for(let p of o)(p.from===s.id||p.to===s.id)&&i.add(p.from===s.id?p.to:p.from);let a=p=>n.cells.find(m=>m.id===p)?.title??p,c=p=>p.parentId?n.cells.find(m=>m.id===p.parentId)?.title:void 0,u=[];u.push("## Memory Palace\uFF1A\u8BB0\u5FC6"),u.push(`\u4E0B\u9762\u662F\u4F60\uFF08AI\uFF09\u5728\u5BAB\u6BBF\u91CC\u7EF4\u62A4\u7684\u8BB0\u5FC6\uFF0C\u5E2E\u52A9\u4F60\u8BA4\u8BC6\u7528\u6237\u3001\u628A\u7528\u6237\u7684\u60F3\u6CD5\u8FDE\u8D77\u6765\u3002\u7528\u6CD5\uFF1A
|
|
80
81
|
- \u7528\u6237\u900F\u9732\u4E86\u503C\u5F97\u957F\u671F\u8BB0\u4F4F\u7684\u4E8B\uFF08\u559C\u597D\u3001\u6B63\u5728\u7ECF\u5386\u7684\u4E8B\u3001\u6DF1\u5165\u804A\u8FC7\u7684\u8BDD\u9898\uFF09\uFF0C\u7528 palace_wiki_write(target="me") \u6574\u9875\u66F4\u65B0\u300C\u5173\u4E8E\u7528\u6237\u300D\uFF1B\u53EA\u8BB0\u7528\u6237\u8BF4\u8FC7\u6216\u505A\u8FC7\u7684\u4E8B\u5B9E\uFF0C\u4E0D\u7ED9\u7528\u6237\u8D34\u6027\u683C\u6807\u7B7E\u3002
|
|
81
82
|
- \u5728\u4E00\u683C\u91CC\u804A\u51FA\u4E86\u65B0\u7684\u8BA4\u8BC6\uFF0C\u7528 palace_wiki_write \u66F4\u65B0\u8FD9\u4E00\u683C\u7684 wiki\uFF1A\u53EA\u5199\u5361\u7247\u548C\u7075\u611F\u91CC\u6CA1\u6709\u7684\uFF08\u8FD9\u4E00\u683C\u5BF9\u7528\u6237\u610F\u5473\u7740\u4EC0\u4E48\u3001\u5361\u5728\u54EA\u3001\u53CD\u590D\u51FA\u73B0\u7684\u4E3B\u9898\u3001\u6CA1\u89E3\u51B3\u7684\u7591\u95EE\uFF09\uFF0C\u53E5\u672B\u7528 [^\u5361\u7247\u6216\u7075\u611F id] \u6807\u51FA\u4F9D\u636E\u3002
|
|
82
83
|
- \u7528\u6237\u7684\u60F3\u6CD5\u628A\u4E24\u683C\u8FDE\u5728\u4E00\u8D77\u65F6\uFF08\u4E24\u672C\u5C0F\u8BF4\u4E0D\u4F1A\u4E92\u76F8\u63D0\u53CA\uFF0C\u4F46\u7528\u6237\u7684\u5FF5\u5934\u4F1A\uFF09\uFF0C\u7528 palace_link \u8FDE\u4E00\u6761\u7535\u5F27\uFF0C\u4E24\u7AEF\u5404\u5E26\u81F3\u5C11\u4E00\u5F20\u5361\u7247\u6216\u7075\u611F\u4F5C\u8BC1\u636E\u3002
|
|
83
|
-
- \u6BCF\u9875\u4E0A\u9650 ${
|
|
84
|
+
- \u6BCF\u9875\u4E0A\u9650 ${ho} \u5B57\uFF0C\u8D85\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1A\u5408\u5E76\u3001\u5220\u6389\u8FC7\u65F6\u7684\uFF0C\u518D\u6574\u9875\u91CD\u5199\u3002\u7EAF\u529F\u80FD\u6027\u7684\u8BF7\u6C42\uFF08\u52A0\u4E66\u3001\u5220\u4E66\uFF09\u4E0D\u7528\u7BA1\u8BB0\u5FC6\u3002
|
|
84
85
|
- \u522B\u7684\u683C\u5B50\u7684 wiki \u7528 palace_wiki_read \u8BFB\uFF1B\u4E0B\u9762\u7684\u7D22\u5F15\u53EF\u80FD\u53EA\u662F\u8282\u9009\uFF0C\u5168\u90E8\u683C\u5B50\u7528 palace_overview \u67E5\u3002`);let l=this.readPage("me");u.push(`### \u5173\u4E8E\u7528\u6237\uFF08me\uFF09
|
|
85
86
|
${l?l.body:"\uFF08\u8FD8\u6CA1\u6709\u8BB0\u5F55\uFF09"}`);let d=n.cells.filter(p=>p.kind!=="group");if(d.length>0){let p=d.map(v=>({c:v,at:this.lastTouched(v,o)})).sort((v,$)=>$.at>v.at?1:-1),m=[],h=[],g=u.join(`
|
|
86
87
|
|
|
87
|
-
`).length;for(let[v,{c:$,at:
|
|
88
|
+
`).length;for(let[v,{c:$,at:I}]of p.entries()){let x=this.readPage($.id),R=`- ${$.title} id=${$.id}${c($)?` \u3014${c($)}\u3015`:""}`+(x?.summary?` \xB7 ${x.summary}`:"")+(x?.topics?.length?` \xB7 ${x.topics.join("\u3001")}`:"")+` \xB7 ${I.slice(0,7)}`;($.id===s?.id||i.has($.id)||v<30)&&g+R.length<r*.7?(m.push(R),g+=R.length+1):h.push($.title)}let y=`### \u5BAB\u6BBF\u7D22\u5F15\uFF08\u6807\u9898 \xB7 \u4E00\u53E5\u8BDD \xB7 \u4E3B\u9898\u8BCD \xB7 \u6700\u8FD1\u6D3B\u8DC3\u6708\u4EFD\uFF09
|
|
88
89
|
${m.join(`
|
|
89
|
-
`)}`;h.length>0&&(
|
|
90
|
-
\u5176\u4F59 ${h.length} \u683C\uFF1A${h.join("\u3001").slice(0,Math.max(200,r-g-800))}`),u.push(
|
|
90
|
+
`)}`;h.length>0&&(y+=`
|
|
91
|
+
\u5176\u4F59 ${h.length} \u683C\uFF1A${h.join("\u3001").slice(0,Math.max(200,r-g-800))}`),u.push(y)}if(s){let p=this.readPage(s.id),m=this.debt(s.id),h=`### \u5F53\u524D\u683C\u5B50\u300A${s.title}\u300B\u7684 wiki
|
|
91
92
|
${p?p.body:"\uFF08\u8FD8\u6CA1\u5199\uFF09"}`;m>0&&(h+=`
|
|
92
|
-
\uFF08\u8FD9\u4E00\u9875\u4E4B\u540E\u65B0\u589E\u4E86 ${m} \u6761\u5361\u7247 / \u7075\u611F\uFF0C\u65B9\u4FBF\u65F6\u66F4\u65B0\uFF09`);let g=o.filter(
|
|
93
|
+
\uFF08\u8FD9\u4E00\u9875\u4E4B\u540E\u65B0\u589E\u4E86 ${m} \u6761\u5361\u7247 / \u7075\u611F\uFF0C\u65B9\u4FBF\u65F6\u66F4\u65B0\uFF09`);let g=o.filter(y=>y.from===s.id||y.to===s.id).slice(0,8);g.length>0&&(h+=`
|
|
93
94
|
\u7535\u5F27\uFF1A
|
|
94
|
-
${g.map(
|
|
95
|
+
${g.map(y=>`- \u2194 ${a(y.from===s.id?y.to:y.from)}\uFF08${y.strands} \u80A1\uFF09\uFF1A${y.why}`).join(`
|
|
95
96
|
`)}`),u.push(h)}let f=u.join(`
|
|
96
97
|
|
|
97
|
-
`);return f.length>r?f.slice(0,r):f}};var
|
|
98
|
-
`)}function
|
|
98
|
+
`);return f.length>r?f.slice(0,r):f}};import{createHash as UE}from"node:crypto";var Pi=e=>UE("sha256").update(JSON.stringify(e)).digest("hex"),Ii=(e,...t)=>`${e}_${Pi(t).slice(0,10)}`;async function pl(e,t,r,n){let o=e.getPalace(),s=new Map(o.cells.map(k=>[k.id,k])),i=new Map;for(let k of o.cells)if(k.kind!=="group")for(let E of e.getItem(k.id).cards)E.importSource?.source===r.source&&i.set(E.importSource.key,{cell:k,card:E});let a=new Map,c=new Map,u=[],l=new Map,d=new Map,f=Ne();for(let k of r.groups){let E=k.itemId??Ii("c",r.source,k.key),M=s.get(E)??a.get(E);if(k.itemId!==void 0&&(M===void 0||M.kind==="group"))throw new w("\u5BFC\u5165\u76EE\u6807\u5FC5\u987B\u662F\u5DF2\u6709\u7684\u4E66\u6216\u7B14\u8BB0\u683C\u5B50");if(M===void 0&&(k.kind==="book"||k.cards.some(P=>!i.has(P.key)))&&(M={id:E,kind:k.kind??"note",title:k.title,href:k.href,parentId:null,col:0,row:0,createdAt:f},a.set(E,M)),M&&k.chapters?.length&&(a.has(E)||e.getItem(E).chapters.length===0)&&c.set(E,As(k.chapters)),M?.kind==="book"&&k.progress){let{percent:P,finishedAt:U,chapterUid:te}=k.progress,ae=a.has(E)?void 0:e.getItem(E),xe=(c.get(E)??ae?.chapters??[]).flatMap(Oe=>Oe.sections),ge=te===void 0?-1:xe.findIndex(Oe=>Oe.loc===te),Ye=xe.slice(0,Math.max(0,ge)).flatMap((Oe,Re)=>Oe.done?[]:[Re]),V=ge<0?"":"weread:"+te;u.push({bookId:k.key,title:M.title,percent:Math.round(P*100),finished:(U??ae?.finishedAt)!==void 0,markRead:Ye.length}),(Ye.length||ae?.position?.loc!==V||ae.position.percent!==P||U!==void 0&&ae.finishedAt!==U)&&l.set(E,{percent:P,finishedAt:U,loc:V,mark:Ye})}for(let P of k.cards){if(d.has(P.key))throw new w(`\u65B9\u6848\u91CC\u91CD\u590D\u51FA\u73B0\uFF1A${P.key}`);let U=i.get(P.key);if(U&&k.itemId!==void 0&&U.cell.id!==k.itemId)throw new w(`\u5DF2\u5BFC\u5165\u7684\u7B14\u8BB0\u7559\u5728\u539F\u683C\u5B50\uFF1A${P.key}`);let te=Pi(P.type===void 0?[P.note,P.frontmatter]:[P.type,P.note,P.quote,P.sectionKey]),ae={...U?.card??{id:Ii("k",r.source,P.key),type:"thought",createdAt:f},...P.type!==void 0?{type:P.type,quote:P.quote}:{},note:U?.card.importSource?.digest===te?U.card.note:P.note,importSource:{source:r.source,key:P.key,digest:te,frontmatter:P.frontmatter}};d.set(P.key,{cell:U?.cell??M,card:ae,previous:U?.card,sectionKey:P.sectionKey})}}let p=[],m=new Map;for(let k of r.links){let E=d.get(k.from),M=d.get(k.to)??i.get(k.to);if(!E||!M||E.cell.id===M.cell.id)continue;let P=JSON.stringify([k.from,k.to]),U=(m.get(P)??0)+1;m.set(P,U);let te=Pi([r.source,P,U,E.cell.id,M.cell.id]);p.push({sourceKey:te,from:E.cell.id,to:M.cell.id,why:k.why,evidence:[E.card.id,M.card.id],fromPath:k.from,toPath:k.to})}let h=[...d.values()].filter(({previous:k,card:E})=>k?.importSource?.digest!==E.importSource?.digest),{pending:g,arcs:y,strands:v}=t.previewImportedLinks(p.map(({sourceKey:k,from:E,to:M,why:P,evidence:U})=>({sourceKey:k,from:E,to:M,why:P,evidence:U}))),$={cells:a.size,cards:h.filter(k=>!k.previous).length,updatedCards:h.filter(k=>k.previous).length,arcs:y,strands:v,...u.length?{progress:u}:{}},I=Pi([r,[...d].map(([k,E])=>[k,E.cell.id,E.previous?.id]),p,g,[...c.keys()],[...l],$]);if(n===void 0)return{preview:!0,...$,token:I};if(n!==I)throw new w("\u7B14\u8BB0\u3001\u65B9\u6848\u6216\u5BAB\u6BBF\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9884\u89C8\u5E76\u786E\u8BA4");(h.length||a.size||c.size||l.size)&&await e.mutate(k=>{for(let E of a.values())Object.assign(E,Cn(k.palace,null)),k.palace.cells.push(E),k.createItem(St(E.id,null));for(let[E,M]of c)k.item(E).chapters=M;for(let[E,{percent:M,finishedAt:P,loc:U,mark:te}]of l){let ae=k.item(E);ae.position={loc:U,percent:M},P!==void 0&&(ae.finishedAt=P);let xe=ae.chapters.flatMap(ge=>ge.sections);for(let ge of te){let Ye=xe[ge];Ye&&!Ye.done&&Object.assign(Ye,{done:!0,doneAt:f})}}for(let{cell:E,card:M,previous:P,sectionKey:U}of h){let te=k.item(E.id);U!==void 0&&(M.sectionId=te.chapters.flatMap(ge=>ge.sections).find(ge=>ge.loc===U)?.id);let{cards:ae}=te,xe=P===void 0?-1:ae.findIndex(ge=>ge.id===P.id);xe===-1?ae.push(M):ae[xe]=M}}),t.addImportedLinks(g);let x=new Set(t.validLinks().map(k=>k.sourceKey)),R=new Map;for(let{sourceKey:k,from:E,to:M,fromPath:P,toPath:U,evidence:te}of p)if(x.has(k)&&R.set([E,M].sort().join(":"),{from:E,to:M,fromPath:P,toPath:U,evidence:te}),R.size===20)break;return{preview:!1,...$,links:[...R.values()]}}var ml={book:"\u4E66",note:"\u7B14\u8BB0",group:"\u5206\u7EC4"},ew={excerpt:"\u6458\u5F55",thought:"\u60F3\u6CD5",mistake:"\u9519\u9898"};function Q_(e,t,r){let n=`${ml[t.kind]}\u300C${t.title}\u300D${t.subtitle?`\uFF08${t.subtitle}\uFF09`:""} id=${t.id}`;if(t.kind!=="group"){let o=e.getItem(t.id),s=er(o),i=ks(o),a=o.cards.filter(u=>u.type==="mistake"&&u.status==="todo").length;o.source!==null&&(n+=` \u539F\u6587 ${o.source.type}${o.source.type==="pdf"?` ${o.source.pageCount} \u9875`:""}`);let c=nc(o);if(c){let u=o.chapters.findIndex(l=>l.sections.some(d=>"weread:"+d.loc===c.loc))+1;n+=` \u5DF2\u8BFB ${Math.round(c.percent*100)}%${u?`\uFF0C\u8BFB\u5230\u7B2C ${u} \u7AE0`:""}\uFF08\u6765\u81EA\u5FAE\u4FE1\u8BFB\u4E66\uFF09`}else s.total>0?n+=` \u8FDB\u5EA6 ${s.done}/${s.total} \u8282`:o.source?.type==="pdf"&&(n+="\uFF08\u8FD8\u6CA1\u6709\u76EE\u5F55\uFF09");o.targetDate&&(n+=` \u76EE\u6807\u65E5\u671F ${o.targetDate}`),i?.perDay!==void 0&&i.remaining>0&&(n+=` \u6BCF\u5929\u7EA6 ${i.perDay} \u8282`),!c&&s.current&&(n+=` \u5F53\u524D\uFF1A${s.current.chapter.title} \u203A ${s.current.section.title}`),o.cards.length>0&&(n+=` \u5361\u7247 ${o.cards.length} \u5F20${a>0?`\uFF08\u5F85\u91CD\u505A\u9519\u9898 ${a}\uFF09`:""}`),o.inspirations.length>0&&(n+=` \u7075\u611F ${o.inspirations.length} \u6761`)}return t.id===r&&(n+=" \u2190 \u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u683C\u5B50"),n}function VE(e,t){let r=e.getPalace().cells;if(r.length===0)return"\u5BAB\u6BBF\u662F\u7A7A\u7684\u3002";let n=[];for(let o of r.filter(s=>s.parentId===null)){n.push(Q_(e,o,t));for(let s of r.filter(i=>i.parentId===o.id))n.push(` ${Q_(e,s,t)}`)}return n.join(`
|
|
99
|
+
`)}function BE(e,t){let r=e.getPalace().cells.find(a=>a.id===t);if(r===void 0||r.kind==="group")throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");let n=e.getItem(t),o=n.chapters.length===0?"\uFF08\u8FD8\u6CA1\u6709\u76EE\u5F55\uFF09":n.chapters.map((a,c)=>`${c+1}. ${a.title}
|
|
99
100
|
${a.sections.map(u=>` - ${u.done?"[x]":"[ ]"} ${u.title} (section_id=${u.id})`).join(`
|
|
100
101
|
`)}`).join(`
|
|
101
|
-
`),s=n.cards.slice(-20).map(a=>`- ${
|
|
102
|
+
`),s=n.cards.slice(-20).map(a=>`- ${ew[a.type]} ${a.id}\uFF1A${(a.quote??a.note??"").slice(0,60)}`).join(`
|
|
102
103
|
`),i=n.inspirations.slice(-10).map(a=>`- ${a.id} ${a.createdAt.slice(0,10)} ${a.title}`).join(`
|
|
103
104
|
`);return`\u300A${r.title}\u300B\u76EE\u5F55\uFF1A
|
|
104
105
|
${o}`+(s?`
|
|
@@ -107,30 +108,33 @@ ${o}`+(s?`
|
|
|
107
108
|
${s}`:"")+(i?`
|
|
108
109
|
|
|
109
110
|
\u7075\u611F\uFF1A
|
|
110
|
-
${i}`:"")}function
|
|
111
|
-
${
|
|
111
|
+
${i}`:"")}function HE(e,t){let r=Dt(e,t.sectionId);return r?` ${r.chapter.title} \u203A ${r.section.title}`:""}async function Te(e){try{return await e()}catch(t){if(t instanceof w)return`\u64CD\u4F5C\u5931\u8D25\uFF1A${t.message}`;throw t}}function KE(e,t){return{name:"palace_overview",description:"\u67E5\u770B\u7528\u6237\u7684 Memory Palace\uFF08\u8BB0\u5FC6\u5BAB\u6BBF\uFF09\uFF1A\u6240\u6709\u5206\u7EC4\u3001\u4E66\u3001\u7B14\u8BB0\u7684 id\u3001\u8FDB\u5EA6\u3001\u5361\u7247\u6570"+(t?"\uFF0C\u4EE5\u53CA\u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u662F\u54EA\u4E2A\u683C\u5B50":"")+"\u3002\u6D89\u53CA\u5BAB\u6BBF\u7684\u4EFB\u4F55\u64CD\u4F5C\u524D\u5148\u8C03\u7528\u5B83\u62FF\u5230 id\u3002\u4F20 item_id \u53EF\u67E5\u770B\u8FD9\u4E2A\u683C\u5B50\u7684\u5B8C\u6574\u76EE\u5F55\uFF08\u542B section_id\uFF09\u3001\u6700\u8FD1\u7684\u5361\u7247\u548C\u7075\u611F\u3002",parameters:{item_id:{type:"string",description:"\u53EF\u9009\uFF1A\u67E5\u770B\u8FD9\u4E2A\u683C\u5B50\u7684\u8BE6\u60C5"}},async execute(r,n){return Te(async()=>r.item_id===void 0?VE(e,n.highlightId):BE(e,r.item_id))}}}function tw(e,t,r){let n=r.currentItem?{type:"string"}:{type:"string",minLength:1,required:!0,description:"\u76EE\u6807\u683C\u5B50 id"};return[KE(e,r.currentItem),{name:"palace_add",description:"\u5F80\u5BAB\u6BBF\u91CC\u653E\u4E1C\u897F\u3002kind=group \u65B0\u5EFA\u5206\u7EC4\uFF08title\uFF09\uFF1Bkind=note \u65B0\u5EFA\u7B14\u8BB0\u683C\u5B50\uFF08title\uFF0C\u7528\u4E8E\u6CA1\u6709\u539F\u6587\u7684\u4E1C\u897F\uFF1A\u65E5\u8BB0\u3001\u5FC3\u60C5\u3001\u8FFD\u5267\uFF09\uFF1Bkind=book \u6DFB\u52A0 PDF / EPUB\uFF08path \u4E3A\u7EDD\u5BF9\u8DEF\u5F84\uFF09\u6216\u89C6\u9891\uFF08url\uFF0C\u5267\u3001\u7EFC\u827A\u3001\u8BFE\u90FD\u7B97\uFF09\uFF0C\u53EF\u9009 title\u3001subtitle\uFF08\u5907\u6CE8\uFF1A\u683C\u5B50\u4E0A\u6807\u9898\u4E0A\u65B9\u7684\u4E00\u884C\u5C0F\u5B57\uFF0C\u7528\u6237\u60F3\u586B\u4EC0\u4E48\u90FD\u884C\uFF0C\u5E38\u89C1\u662F\u4F5C\u8005\u6216\u53E6\u4E00\u79CD\u8BED\u8A00\u7684\u4E66\u540D\uFF09\u3002title \u7528\u4E66\u7684\u539F\u540D\uFF0C\u5927\u5C0F\u5199\u7167\u539F\u4E66\uFF08\u5982 Invention of Nature\uFF09\uFF0C\u4E0D\u5E26\u6587\u4EF6\u540D\u91CC\u7684 - _ \u300A\u300B \u7B49\u7B26\u53F7\uFF1B\u5916\u6587\u4E66\u53EF\u628A\u4E2D\u6587\u8BD1\u540D\u653E subtitle\u3001target_date\uFF08YYYY-MM-DD\uFF09\u3002parent_id \u586B\u5206\u7EC4 id \u53EF\u4EE5\u76F4\u63A5\u653E\u8FDB\u5206\u7EC4\uFF08\u5206\u7EC4\u91CC\u4E0D\u80FD\u518D\u653E\u5206\u7EC4\uFF09\u3002"+r.videoHelp,parameters:{kind:{type:"string",enum:["group","note","book"],required:!0},title:{type:"string"},subtitle:{type:"string"},parent_id:{type:"string"},path:{type:"string",description:"book\uFF1APDF \u6216 EPUB \u7684\u7EDD\u5BF9\u8DEF\u5F84"},url:{type:"string",description:"book\uFF1A\u89C6\u9891\u94FE\u63A5\uFF08http / https\uFF09"},target_date:{type:"string"}},async execute(o,s){return Te(async()=>{if(o.kind!=="book"){let u=await qt(e,{kind:o.kind,title:o.title,subtitle:o.subtitle,parentId:o.parent_id});return`\u5DF2\u65B0\u5EFA${ml[u.kind]}\u300C${u.title}\u300D id=${u.id}`}let i=await r.addBook({file:o.path,url:o.url,title:o.title,subtitle:o.subtitle,parentId:o.parent_id,targetDate:o.target_date},s.signal),a=e.getItem(i.id),c=er(a).total;return a.source?.type==="video"?c>0?`\u5DF2\u6DFB\u52A0\u89C6\u9891\u300A${i.title}\u300B id=${i.id}\uFF0C\u5171 ${c} \u96C6\u3002`:`\u5DF2\u6DFB\u52A0\u89C6\u9891\u300A${i.title}\u300B id=${i.id}\uFF0C\u8FD8\u6CA1\u6709\u5206\u96C6\u76EE\u5F55\u3002\u5148\u544A\u8BC9\u7528\u6237\u5DF2\u7ECF\u653E\u8FDB\u6765\u4E86\uFF0C\u95EE\u8981\u4E0D\u8981\u4E0A\u7F51\u67E5\u5206\u96C6\u548C\u6BCF\u4E00\u96C6\u7684\u94FE\u63A5\uFF08\u8981\u82B1\u4E00\u4E24\u5206\u949F\uFF09\uFF1B\u7528\u6237\u5DF2\u7ECF\u8981\u4E86\u76EE\u5F55\u5C31\u76F4\u63A5\u67E5\uFF0C\u67E5\u597D\u7528 palace_set_outline \u5199\u5165\u3002`:a.source?.type==="epub"?`\u5DF2\u6DFB\u52A0\u300A${i.title}\u300B id=${i.id}\u3002\u7528\u6237\u7B2C\u4E00\u6B21\u5728\u7B14\u8BB0\u672C\u91CC\u6253\u5F00\u9605\u8BFB\u65F6\u4F1A\u81EA\u52A8\u8BFB\u51FA\u76EE\u5F55\u3002`:`\u5DF2\u6DFB\u52A0\u300A${i.title}\u300B id=${i.id}\uFF0C\u5171 ${a.source?.type==="pdf"?a.source.pageCount:"?"} \u9875\u3002`+(c>0?`\u5DF2\u4ECE PDF \u4E66\u7B7E\u8BFB\u51FA\u76EE\u5F55\uFF1A${a.chapters.length} \u7AE0 ${c} \u8282\u3002`:"\u8FD9\u672C PDF \u6CA1\u6709\u4E66\u7B7E\uFF0C\u9700\u8981\u751F\u6210\u76EE\u5F55\uFF1A\u8BF7\u7528\u6237\u5728\u53F3\u4FA7\u7B14\u8BB0\u672C\u7684\u300C\u8FDB\u5EA6\u300D\u91CC\u52FE\u9009\u76EE\u5F55\u9875\uFF0C\u6216\u544A\u8BC9\u4F60\u76EE\u5F55\u5728\u7B2C\u51E0\u9875\uFF0C\u7136\u540E\u7528 palace_read \u8BFB\u53D6\u3002")})}},{name:"palace_remove",description:"\u4ECE\u5BAB\u6BBF\u91CC\u5220\u6389\u4E00\u4E2A\u683C\u5B50\uFF08\u4E66\u3001\u7B14\u8BB0\u6216\u7A7A\u5206\u7EC4\uFF09\uFF0C\u8FDE\u540C\u5B83\u7684\u8FDB\u5EA6\u3001\u5361\u7247\u548C\u7075\u611F\uFF0C\u4E0D\u5220\u7535\u8111\u4E0A\u7684\u539F\u6587\u4EF6\u3002\u5206\u7EC4\u91CC\u6700\u540E\u4E00\u683C\u5220\u6389\u6216\u79FB\u51FA\u540E\uFF0C\u5206\u7EC4\u4F1A\u81EA\u52A8\u6D88\u5931\uFF0C\u4E0D\u7528\u518D\u5220\u3002\u4E0D\u53EF\u64A4\u9500\uFF1A\u8C03\u7528\u524D\u5FC5\u987B\u5148\u8BF4\u6E05\u8981\u5220\u7684\u662F\u54EA\u4E00\u4E2A\u3001\u4F1A\u4E22\u6389\u591A\u5C11\u5361\u7247\u548C\u7075\u611F\uFF0C\u7B49\u7528\u6237\u660E\u786E\u540C\u610F\u540E\u518D\u8C03\u7528\u3002\u5206\u7EC4\u91CC\u8FD8\u6709\u4E1C\u897F\u65F6\u4E0D\u80FD\u5220\u3002",parameters:{item_id:{type:"string",required:!0}},async execute(o){return Te(async()=>{let s=e.getPalace().cells.find(a=>a.id===o.item_id);if(s===void 0)throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");let i=s.kind==="group"?void 0:e.getItem(s.id);return await Os(e,{id:s.id}),`\u5DF2\u5220\u9664${ml[s.kind]}\u300C${s.title}\u300D`+(i?`\uFF08\u5361\u7247 ${i.cards.length} \u5F20\u3001\u7075\u611F ${i.inspirations.length} \u6761\uFF09`:"")})}},{name:"palace_read",description:"\u8BFB\u53D6\u67D0\u672C PDF \u6307\u5B9A\u9875\u7684\u6587\u5B57\uFF08\u9875\u7801\u4E3A PDF \u7684\u9875\u5E8F\u53F7\uFF0C\u4ECE 1 \u5F00\u59CB\uFF0C\u4E0D\u662F\u4E66\u4E0A\u5370\u7684\u9875\u7801\uFF09\u3002\u7528\u4E8E\u8BFB\u53D6\u76EE\u5F55\u9875\u6765\u751F\u6210\u7AE0\u8282\u7ED3\u6784\u3002\u6BCF\u6B21\u6700\u591A 30 \u9875\u3002",parameters:{item_id:{type:"string",required:!0},pages:{type:"array",items:{type:"integer"},required:!0,description:"PDF \u9875\u5E8F\u53F7\u5217\u8868"}},async execute(o){return Te(async()=>{let s=e.getItem(o.item_id).source;if(s?.type!=="pdf")throw new w("\u8FD9\u4E2A\u683C\u5B50\u4E0D\u662F PDF");let i=[...new Set(o.pages)].slice(0,30),a=await r.readPageTexts(s.path,i),c=a.filter(l=>l.text.length<r.scannedThreshold).map(l=>l.page),u=a.map(l=>`=== \u7B2C ${l.page} \u9875 ===
|
|
112
|
+
${l.text||"\uFF08\u65E0\u6587\u5B57\uFF09"}`).join(`
|
|
112
113
|
|
|
113
|
-
`);return
|
|
114
|
+
`);return c.length>0&&(u+=`
|
|
114
115
|
|
|
115
|
-
\u6CE8\u610F\uFF1A\u7B2C ${
|
|
116
|
-
${
|
|
117
|
-
`)}`})}},{name:"palace_add_card",description:"\u8BB0\u4E00\u5F20\u5361\u7247\u3002type=mistake \u9519\u9898\uFF1A\u7528\u6237\u53D1\u6765\u9519\u9898\u622A\u56FE\u5E76\u8BF4\u300C\u8BB0\u9519\u9898\u300D\u65F6\u8C03\u7528\uFF0C\u5148\u770B\u56FE\u628A\u9898\u76EE\u5B8C\u6574\u8F6C\u6210\u6587\u5B57\u5199\u8FDB quote\uFF08\u542B\u9009\u9879\uFF09\uFF0C\u80FD\u5224\u65AD\u7684\u8BDD\u628A\u7B54\u6848\u548C\u89E3\u6790\u5199\u8FDB answer\uFF1Btype=excerpt \u6458\u5F55\uFF1Aquote \u662F\u539F\u6587\uFF0Cnote \u662F\u7528\u6237\u7684\u60F3\u6CD5\uFF1Btype=thought \u60F3\u6CD5\uFF1A\u53EA\u6709 note\
|
|
118
|
-
\u4E00\u53E5\u8BDD\uFF1A${
|
|
119
|
-
\u4E3B\u9898\u8BCD\uFF1A${
|
|
116
|
+
\u6CE8\u610F\uFF1A\u7B2C ${c.join("\u3001")} \u9875\u6CA1\u6709\u6587\u5B57\u5C42\uFF08\u53EF\u80FD\u662F\u626B\u63CF\u4EF6\uFF09\u3002\u5982\u679C\u5BF9\u8BDD\u91CC\u9644\u6709\u8FD9\u4E9B\u9875\u7684\u56FE\u7247\uFF0C\u8BF7\u76F4\u63A5\u770B\u56FE\u8BC6\u522B\uFF1B`+r.scannedPageHelp),u})}},{name:"palace_set_outline",description:"\u5199\u5165\uFF08\u8986\u76D6\uFF09\u4E66\u7684\u76EE\u5F55\u7ED3\u6784\uFF0C\u53EA\u8981\u4E24\u7EA7\uFF1A\u7AE0 \u203A \u8282\u3002\u6CA1\u6709\u5206\u8282\u7684\u7AE0\uFF0Csections \u7559\u7A7A\u5373\u53EF\uFF08\u4F1A\u81EA\u52A8\u7B97\u4F5C\u4E00\u8282\uFF09\u3002\u6807\u9898\u4FDD\u6301\u539F\u4E66\u5199\u6CD5\uFF0C\u53BB\u6389\u9875\u7801\u548C\u7701\u7565\u53F7\u3002\u91CD\u65B0\u751F\u6210\u76EE\u5F55\u65F6\uFF0C\u6807\u9898\u4E0D\u53D8\u7684\u8282\u4F1A\u4FDD\u7559\u5B8C\u6210\u72B6\u6001\u3002\u9875\u7801 page \u53EF\u9009\uFF0C\u586B PDF \u9875\u5E8F\u53F7\uFF08\u4E66\u4E0A\u5370\u7684\u9875\u7801 + \u504F\u79FB\u91CF\uFF09\uFF1B\u4E0D\u786E\u5B9A\u5C31\u4E0D\u586B\u3002\u89C6\u9891\u7684\u6BCF\u4E00\u96C6\u53EF\u4EE5\u586B url\uFF08\u8FD9\u4E00\u96C6\u7684\u64AD\u653E\u94FE\u63A5\uFF0Chttp / https\uFF09\uFF0C\u7528\u6237\u70B9\u300C\u64AD\u653E\u300D\u76F4\u63A5\u6253\u5F00\uFF1B\u4E0D\u586B\u5C31\u6253\u5F00\u4F5C\u54C1\u94FE\u63A5\u3002",parameters:{item_id:{type:"string",required:!0},chapters:{type:"array",required:!0,items:{type:"object",additionalProperties:!1,properties:{title:{type:"string",required:!0},sections:{type:"array",items:{type:"object",additionalProperties:!1,properties:{title:{type:"string",required:!0},page:{type:"integer"},url:{type:"string"}}}}}}}},async execute(o){return Te(async()=>{let s=!1;try{s=e.getItem(String(o.item_id)).source?.type==="video"}catch{}let i=u=>s?typeof u.url=="string"&&/^https?:\/\/\S+$/.test(u.url.trim())?{loc:u.url.trim()}:{}:Number.isInteger(u.page)?{loc:String(u.page)}:{},a=o.chapters.map(u=>({title:u.title,sections:(u.sections??[]).map(l=>({title:l.title,...i(l)}))})),c=await Cs(e,{id:o.item_id,chapters:a,source:"ai"});return`\u5DF2\u5199\u5165\u76EE\u5F55\uFF1A${c.chapters.length} \u7AE0 ${er(c).total} \u8282\u3002\u7528\u6237\u53EF\u4EE5\u5728\u53F3\u4FA7\u7B14\u8BB0\u672C\u91CC\u67E5\u770B\u548C\u6253\u52FE\u3002`})}},{name:"palace_set_target_dates",description:"\u8BBE\u7F6E\u4E66\u7684\u76EE\u6807\u5B8C\u6210\u65E5\u671F\uFF08YYYY-MM-DD\uFF09\uFF0C\u7528\u4E8E\u89C4\u5212\u8FDB\u5EA6\u3002\u53EF\u4E00\u6B21\u8BBE\u7F6E\u591A\u672C\u3002\u89C4\u5212\u65F6\u53C2\u8003\u5404\u4E66\u7684\u8282\u6570\uFF0C\u5E76\u7ED9\u590D\u4E60\u7559\u51FA\u65F6\u95F4\u3002\u8BBE\u7F6E\u524D\u5148\u548C\u7528\u6237\u786E\u8BA4\u65B9\u6848\u3002",parameters:{items:{type:"array",required:!0,items:{type:"object",additionalProperties:!1,properties:{item_id:{type:"string",required:!0},target_date:{type:"string",required:!0}}}}},async execute(o){return Te(async()=>{let s=[];for(let i of o.items){let a=await Rs(e,{id:i.item_id,targetDate:i.target_date}),c=e.getPalace().cells.find(l=>l.id===i.item_id)?.title??i.item_id,u=ks(a);s.push(`\u300A${c}\u300B\u2192 ${a.targetDate}`+(u?.perDay!==void 0?`\uFF0C\u5269 ${u.remaining} \u8282\uFF0C\u6BCF\u5929\u7EA6 ${u.perDay} \u8282`:""))}return`\u5DF2\u8BBE\u7F6E\uFF1A
|
|
117
|
+
${s.join(`
|
|
118
|
+
`)}`})}},{name:"palace_add_card",description:"\u8BB0\u4E00\u5F20\u5361\u7247\u3002type=mistake \u9519\u9898\uFF1A\u7528\u6237\u53D1\u6765\u9519\u9898\u622A\u56FE\u5E76\u8BF4\u300C\u8BB0\u9519\u9898\u300D\u65F6\u8C03\u7528\uFF0C\u5148\u770B\u56FE\u628A\u9898\u76EE\u5B8C\u6574\u8F6C\u6210\u6587\u5B57\u5199\u8FDB quote\uFF08\u542B\u9009\u9879\uFF09\uFF0C\u80FD\u5224\u65AD\u7684\u8BDD\u628A\u7B54\u6848\u548C\u89E3\u6790\u5199\u8FDB answer\uFF1Btype=excerpt \u6458\u5F55\uFF1Aquote \u662F\u539F\u6587\uFF0Cnote \u662F\u7528\u6237\u7684\u60F3\u6CD5\uFF1Btype=thought \u60F3\u6CD5\uFF1A\u53EA\u6709 note\u3002"+r.imageHelp+(r.currentItem?"item_id \u4E0D\u586B\u65F6\u8BB0\u5230\u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u683C\u5B50\uFF1B":"item_id \u586B\u76EE\u6807\u683C\u5B50 id\uFF1B")+"section_id \u4E0D\u586B\u65F6\uFF0C\u6458\u5F55\u548C\u9519\u9898\u9ED8\u8BA4\u6302\u5230\u5F53\u524D\u5728\u5B66\u7684\u90A3\u4E00\u8282\u3002",parameters:{type:{type:"string",enum:["mistake","excerpt","thought"],required:!0},quote:{type:"string",description:"\u539F\u6587\u6216\u9898\u76EE"},note:{type:"string",description:"\u60F3\u6CD5\u3001\u6279\u6CE8\u6216\u9519\u56E0\uFF08\u7528\u6237\u8BF4\u4E86\u624D\u586B\uFF09"},answer:{type:"string",description:"\u9519\u9898\u7684\u7B54\u6848\u4E0E\u89E3\u6790"},image:{type:"string",description:r.imageDescription},item_id:n,section_id:{type:"string"}},async execute(o,s){return Te(async()=>{let i=o.item_id,a=e.getItem(i),c=o.section_id??(o.type==="thought"?void 0:er(a).current?.section.id),u=r.saveImage(o.image),l=await Ns(e,{id:i,type:o.type,quote:o.quote,note:o.note,answer:o.answer,image:u,sectionId:c});return`\u5DF2\u8BB0\u5165\u300A${e.getPalace().cells.find(f=>f.id===i)?.title}\u300B${HE(e.getItem(i),l)}\u7684${ew[l.type]}`+(o.image?u?"\uFF0C\u539F\u56FE\u5DF2\u4FDD\u5B58\u3002":"\u3002\uFF08\u6CA1\u6709\u627E\u5230\u539F\u56FE\uFF09":"\u3002")+(s.nudge?.(i,"wiki")??"")})}},{name:"palace_add_inspiration",description:"\u628A\u8FD9\u6B21\u5BF9\u8BDD\u5B58\u6210\u4E00\u6761\u300C\u7075\u611F\u300D\uFF1A\u7528\u6237\u8BF4\u300C\u5B58\u6210\u7075\u611F\u300D\u300C\u8BB0\u4E0B\u6765\u300D\u4E4B\u7C7B\u65F6\u8C03\u7528\u3002\u7528\u7528\u6237\u7684\u53E3\u543B\u3001\u7B80\u6D01\u5730\u603B\u7ED3\u8FD9\u6B21\u5BF9\u8BDD\u91CC\u7528\u6237\u7684\u60F3\u6CD5\u548C\u5F97\u51FA\u7684\u7ED3\u8BBA\uFF08\u4E0D\u662F\u590D\u8FF0 AI \u8BF4\u4E86\u4EC0\u4E48\uFF09\uFF0Cbody \u7528 Markdown\uFF0C\u51E0\u6BB5\u5373\u53EF\uFF1Btitle \u4E00\u53E5\u8BDD\u70B9\u9898\u3002"+(r.currentItem?"item_id \u4E0D\u586B\u65F6\u5B58\u5230\u7528\u6237\u5F53\u524D\u6253\u5F00\u7684\u683C\u5B50\u3002":"item_id \u5FC5\u987B\u586B\u76EE\u6807\u683C\u5B50 id\u3002"),parameters:{title:{type:"string",required:!0},body:{type:"string",required:!0},item_id:n,card_ids:{type:"array",items:{type:"string"},description:"\u53EF\u9009\uFF1A\u8FD9\u6B21\u5BF9\u8BDD\u6D89\u53CA\u7684\u5361\u7247"}},async execute(o,s){return Te(async()=>{let i=o.item_id,a=await js(e,{id:i,title:o.title,body:o.body,cardIds:o.card_ids,...s.attribution});return`\u5DF2\u5B58\u5230\u300A${e.getPalace().cells.find(u=>u.id===i)?.title}\u300B\u7684\u7075\u611F\uFF1A\u300C${a.title}\u300D id=${a.id}`+(s.nudge?.(i,"link")??"")+(s.nudge?.(i,"wiki")??"")})}},{name:"palace_wiki_read",description:"\u8BFB\u4E00\u9875\u8BB0\u5FC6\uFF1Atarget \u586B\u683C\u5B50 id \u8BFB\u8FD9\u4E00\u683C\u7684 wiki\uFF08\u4E00\u53E5\u8BDD\u3001\u4E3B\u9898\u8BCD\u3001\u6B63\u6587\uFF09\uFF0C\u586B me \u8BFB\u300C\u5173\u4E8E\u7528\u6237\u300D\u3002"+r.wikiReadHelp,parameters:{target:{type:"string",required:!0,description:"\u683C\u5B50 id \u6216 me"}},async execute(o){return Te(async()=>{let s=t.readPage(o.target);if(o.target!=="me"){let i=e.getPalace().cells.find(c=>c.id===o.target);if(i===void 0||i.kind==="group")throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");let a=t.debt(i.id);return s===void 0?`\u300A${i.title}\u300B\u8FD8\u6CA1\u6709 wiki\u3002`+(a>0?`\u5DF2\u6709 ${a} \u6761\u5361\u7247 / \u7075\u611F\uFF0C\u53EF\u4EE5\u7528 palace_overview \u67E5\u770B\u540E\u5199\u4E00\u9875\u3002`:""):`\u300A${i.title}\u300Bwiki\uFF08${s.writtenAt.slice(0,10)}\uFF09
|
|
119
|
+
\u4E00\u53E5\u8BDD\uFF1A${s.summary??"\uFF08\u65E0\uFF09"}
|
|
120
|
+
\u4E3B\u9898\u8BCD\uFF1A${s.topics?.join("\u3001")??"\uFF08\u65E0\uFF09"}
|
|
120
121
|
|
|
121
|
-
${
|
|
122
|
+
${s.body}`+(a>0?`
|
|
122
123
|
|
|
123
|
-
\uFF08\u8FD9\u4E00\u9875\u4E4B\u540E\u65B0\u589E\u4E86 ${
|
|
124
|
-
${o.body}`})}},{name:"palace_wiki_write",description:`\u6574\u9875\u91CD\u5199\u4E00\u9875\u8BB0\u5FC6\uFF08\u4F1A\u8986\u76D6\u65E7\u5185\u5BB9\uFF0C\u5148\u5728\u65E7\u5185\u5BB9\u57FA\u7840\u4E0A\u6539\uFF09\u3002\u6B63\u6587\u6700\u591A ${no} \u5B57\uFF0C\u8D85\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1A\u5408\u5E76\u76F8\u8FD1\u7684\u3001\u5220\u6389\u8FC7\u65F6\u7684\u518D\u5199\u3002target=me\uFF1A\u5173\u4E8E\u7528\u6237\u7684\u957F\u671F\u8BB0\u5FC6\uFF0C\u5206\u300C\u957F\u671F\u300D\u300C\u6700\u8FD1\u300D\u4E24\u6BB5\uFF0C\u53EA\u8BB0\u7528\u6237\u8BF4\u8FC7\u6216\u505A\u8FC7\u7684\u4E8B\u5B9E\uFF08\u559C\u597D\u3001\u6B63\u5728\u7ECF\u5386\u7684\u4E8B\u3001\u6DF1\u5165\u804A\u8FC7\u7684\u8BDD\u9898\uFF09\uFF0C\u4E0D\u8D34\u6027\u683C\u6807\u7B7E\u3002target=\u683C\u5B50 id\uFF1A\u8FD9\u4E00\u683C\u7684 wiki\uFF0C\u53EA\u5199\u5361\u7247\u548C\u7075\u611F\u91CC\u6CA1\u6709\u7684\u4E1C\u897F\uFF08\u5BF9\u7528\u6237\u610F\u5473\u7740\u4EC0\u4E48\u3001\u5361\u5728\u54EA\u3001\u53CD\u590D\u51FA\u73B0\u7684\u4E3B\u9898\u3001\u6CA1\u89E3\u51B3\u7684\u7591\u95EE\uFF09\uFF0C\u53E5\u672B\u7528 [^\u5361\u7247\u6216\u7075\u611F id] \u6807\u51FA\u4F9D\u636E\uFF1Bsummary \u4E00\u53E5\u8BDD\uFF08\u226440 \u5B57\uFF09\uFF0Ctopics 3\u20135 \u4E2A\u4E3B\u9898\u8BCD\uFF08\u81EA\u7531\u586B\u5199\uFF0C\u8DE8\u683C\u5B50\u76F8\u901A\u7684\u8BCD\u66F4\u597D\uFF0C\u6BD4\u5982\u300C\u7B49\u5F85\u300D\u300C\u5B64\u72EC\u300D\uFF09\u3002`,parameters:{target:{type:"string",required:!0,description:"\u683C\u5B50 id \u6216 me"},body:{type:"string",required:!0,description:"Markdown \u6B63\u6587"},summary:{type:"string"},topics:{type:"array",items:{type:"string"}}},async execute(n){return Be(async()=>{let o=t.writePage(n.target,{body:n.body,summary:n.summary,topics:n.topics});return n.target==="me"?"\u5DF2\u66F4\u65B0\u300C\u5173\u4E8E\u7528\u6237\u300D\u3002":`\u5DF2\u66F4\u65B0\u300A${e.getPalace().cells.find(i=>i.id===n.target)?.title}\u300B\u7684 wiki`+(o.topics?.length?`\uFF08\u4E3B\u9898\u8BCD\uFF1A${o.topics.join("\u3001")}\uFF09`:"")+"\u3002"})}},{name:"palace_link",description:"\u5728\u4E24\u683C\u4E4B\u95F4\u8FDE\u4E00\u6761\u7535\u5F27\uFF08\u8054\u60F3\uFF09\uFF1A\u7528\u6237\u7684\u67D0\u4E2A\u60F3\u6CD5\u3001\u4E3B\u9898\u6216\u7591\u95EE\u628A\u8FD9\u4E24\u683C\u8FDE\u5728\u4E00\u8D77\u65F6\u8C03\u7528\u3002\u4E0D\u9700\u8981\u4E24\u672C\u4E66\u4E92\u76F8\u63D0\u53CA\uFF0C\u8FDE\u7684\u662F\u7528\u6237\u7684\u5FF5\u5934\u3002why \u4E00\u53E5\u8BDD\u8BF4\u6E05\u8FDE\u5728\u54EA\uFF08\u226440 \u5B57\uFF0C\u4F8B\u5982\u300C\u90FD\u5728\u5199\u7B49\u5F85\uFF1A\u76D6\u8328\u6BD4\u7B49\u7EFF\u706F\uFF0C\u4F60\u5728\u7B49 offer\u300D\uFF09\uFF1Bevidence \u586B\u4E24\u7AEF\u5404\u81F3\u5C11\u4E00\u5F20\u5361\u7247\u6216\u4E00\u6761\u7075\u611F\u7684 id\u3002\u540C\u6837\u7684\u8BC1\u636E\u4E0D\u80FD\u91CD\u590D\u8FDE\uFF1B\u6709\u65B0\u8BC1\u636E\u5C31\u518D\u8FDE\u4E00\u6761\uFF0C\u7535\u5F27\u4F1A\u53D8\u7C97\u3002\u7528\u6237\u526A\u65AD\u8FC7\u7684\u4E24\u683C\uFF0C\u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\uFF0C\u5426\u5219\u4E0D\u8981\u518D\u8FDE\u3002",parameters:{from:{type:"string",required:!0,description:"\u683C\u5B50 id"},to:{type:"string",required:!0,description:"\u683C\u5B50 id"},why:{type:"string",required:!0},evidence:{type:"array",items:{type:"string"},required:!0,description:"\u5361\u7247 / \u7075\u611F id"},user_asked:{type:"boolean",description:"\u7528\u6237\u660E\u786E\u8981\u6C42\u8FDE\uFF08\u526A\u65AD\u8FC7\u7684\u4E5F\u80FD\u91CD\u8FDE\uFF09"}},async execute(n,o){return Be(async()=>{let s=t.addLink({from:n.from,to:n.to,why:n.why,evidence:n.evidence,...o.attribution,userAsked:n.user_asked===!0}),i=e.getPalace().cells,a=t.arcs().find(c=>c.links.some(u=>u.id===s.id));return`\u5DF2\u8FDE\u4E0A\u300A${i.find(c=>c.id===s.from)?.title}\u300B\u2194\u300A${i.find(c=>c.id===s.to)?.title}\u300B\uFF1A${s.why}\uFF08\u73B0\u5728 ${a?.strands??1} \u80A1\uFF09`})}},{name:"palace_unlink",description:"\u526A\u65AD\u4E24\u683C\u4E4B\u95F4\u7684\u7535\u5F27\uFF08\u7528\u6237\u8BF4\u8FD9\u4E24\u4E2A\u6CA1\u5173\u7CFB\u3001\u8FDE\u9519\u4E86\u65F6\u8C03\u7528\uFF09\u3002\u4E4B\u524D\u7684\u8054\u60F3\u90FD\u4E0D\u518D\u663E\u793A\uFF0C\u4EE5\u540E\u4E5F\u4E0D\u4F1A\u81EA\u52A8\u518D\u8FDE\u3002",parameters:{from:{type:"string",required:!0},to:{type:"string",required:!0}},async execute(n){return Be(async()=>(t.cut({from:n.from,to:n.to}),"\u5DF2\u526A\u65AD\u3002"))}}]}function F_(e){return{name:"palace_context",description:"\u8BFB\u53D6 Memory Palace \u7684\u8BB0\u5FC6\u80CC\u666F\uFF0C\u53EF\u6307\u5B9A\u683C\u5B50 id\u3002",parameters:{item_id:{type:"string"}},async execute(t){return e.context({itemId:t.item_id})}}}function L_(e){return{name:"palace_open",description:"\u6253\u5F00\u6211\u7684\u8BB0\u5FC6\u5BAB\u6BBF\uFF1A\u8FD4\u56DE\u672C\u673A\u6D4F\u89C8\u5668\u53EF\u4EE5\u6253\u5F00\u7684\u5BAB\u6BBF\u7F51\u9875\u5730\u5740\u3002",parameters:{},async execute(){return e}}}import{closeSync as zI,copyFileSync as PI,existsSync as tl,mkdirSync as EI,openSync as II,readdirSync as TI,readSync as OI,statSync as RI}from"node:fs";import{homedir as tw}from"node:os";import{basename as ew,extname as _i,isAbsolute as rw,join as so}from"node:path";var U_="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130 Safari/537.36",oo=class extends Error{};function V_(e){if(!/^https?:\/\//.test(e))return/BV[0-9A-Za-z]{10}/.test(e);try{let t=new URL(e).hostname;return t==="b23.tv"||t==="bilibili.com"||t.endsWith(".bilibili.com")}catch{return!1}}async function wI(e,t){let r=e.match(/BV[0-9A-Za-z]{10}/);if(r)return r[0];let n=e.match(/https?:\/\/b23\.tv\/[0-9A-Za-z]+/);if(n){let s=(await fetch(n[0],{redirect:"follow",headers:{"user-agent":U_},signal:H_(t)})).url.match(/BV[0-9A-Za-z]{10}/);if(s)return s[0]}throw new oo("\u6CA1\u6709\u8BC6\u522B\u5230 B \u7AD9\u89C6\u9891\u94FE\u63A5\uFF08\u9700\u8981\u5305\u542B BV \u53F7\uFF0C\u6216 b23.tv \u77ED\u94FE\uFF09")}async function bI(e,t){let r=await fetch(`https://api.bilibili.com/x/web-interface/view?bvid=${e}`,{headers:{"user-agent":U_,referer:"https://www.bilibili.com/"},signal:H_(t)});if(!r.ok)throw new oo(`B \u7AD9\u63A5\u53E3\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${r.status}\uFF09`);let n=await r.json();if(n.code!==0||n.data===void 0)throw new oo(`B \u7AD9\u8FD4\u56DE\u9519\u8BEF\uFF1A${n.message??n.code}`);return n.data}function H_(e){let t=AbortSignal.timeout(15e3);return e?AbortSignal.any([e,t]):t}async function B_(e,t){let r=await wI(e,t),n=await bI(r,t),o=`https://www.bilibili.com/video/${n.bvid}`,s=n.pages??[];if(s.length>1)return{title:n.title,url:o,chapters:[{title:"\u5168\u90E8\u89C6\u9891",episodes:s.map(a=>({title:a.part||`\u7B2C ${a.page} \u96C6`,url:`${o}?p=${a.page}`}))}]};let i=n.ugc_season;if(i!==void 0&&i.sections.some(a=>a.episodes.length>1)){let a=i.sections.filter(c=>c.episodes.length>0).map(c=>({title:i.sections.length===1?"\u5168\u90E8\u89C6\u9891":c.title,episodes:c.episodes.map(u=>({title:u.title,url:`https://www.bilibili.com/video/${u.bvid}`}))}));return{title:i.title||n.title,url:o,chapters:a}}return{title:n.title,url:o,chapters:[{title:"\u5168\u90E8\u89C6\u9891",episodes:[{title:n.title,url:o}]}]}}import{readFile as vI}from"node:fs/promises";import{createRequire as $I}from"node:module";import{dirname as xI,join as J_,sep as K_}from"node:path";var SI=$I(import.meta.url),G_;function kI(){return G_??=import("pdfjs-dist/legacy/build/pdf.mjs"),G_}function el(){return xI(SI.resolve("pdfjs-dist/package.json"))}async function X_(e){let t=await kI(),r=new Uint8Array(await vI(e)),n=el(),o=t.getDocument({data:r,cMapUrl:J_(n,"cmaps")+K_,cMapPacked:!0,standardFontDataUrl:J_(n,"standard_fonts")+K_,isEvalSupported:!1,disableFontFace:!0,verbosity:0});return{doc:await o.promise,close:()=>o.destroy()}}async function W_(e,t){try{let r=typeof t=="string"?await e.getDestination(t):t;if(!Array.isArray(r)||r.length===0)return;let n=r[0];if(typeof n=="number")return n+1;if(n!==null&&typeof n=="object")return await e.getPageIndex(n)+1}catch{}}function Y_(e){return e.replace(/\s+/g," ").trim()}async function Q_(e){let{doc:t,close:r}=await X_(e);try{let n=await t.getOutline()??[];for(;n.length===1&&n[0].items.length>0;)n=n[0].items;let o=[];for(let i of n){let a=[];for(let u of i.items){let l=Y_(u.title);l!==""&&a.push({title:l,page:await W_(t,u.dest)})}let c=Y_(i.title);c!==""&&o.push({title:c,page:await W_(t,i.dest),sections:a})}let s;try{let a=(await t.getMetadata()).info;typeof a?.Title=="string"&&a.Title.trim()!==""&&(s=a.Title.trim())}catch{}return{pageCount:t.numPages,title:s,outline:o}}finally{await r()}}async function gi(e,t){let{doc:r,close:n}=await X_(e);try{let o=[];for(let s of t){if(!Number.isInteger(s)||s<1||s>r.numPages)continue;let i=await r.getPage(s),a=await i.getTextContent(),c="";for(let u of a.items)"str"in u&&(c+=u.str,u.hasEOL&&(c+=`
|
|
124
|
+
\uFF08\u8FD9\u4E00\u9875\u4E4B\u540E\u65B0\u589E\u4E86 ${a} \u6761\u5361\u7247 / \u7075\u611F\uFF09`:"")}return s===void 0?"\u8FD8\u6CA1\u6709\u5173\u4E8E\u7528\u6237\u7684\u8BB0\u5F55\u3002":`\u5173\u4E8E\u7528\u6237\uFF08${s.writtenAt.slice(0,10)}\uFF09\uFF1A
|
|
125
|
+
${s.body}`})}},{name:"palace_wiki_write",description:`\u6574\u9875\u91CD\u5199\u4E00\u9875\u8BB0\u5FC6\uFF08\u4F1A\u8986\u76D6\u65E7\u5185\u5BB9\uFF0C\u5148\u5728\u65E7\u5185\u5BB9\u57FA\u7840\u4E0A\u6539\uFF09\u3002\u6B63\u6587\u6700\u591A ${ho} \u5B57\uFF0C\u8D85\u4E86\u4F1A\u88AB\u62D2\u7EDD\uFF1A\u5408\u5E76\u76F8\u8FD1\u7684\u3001\u5220\u6389\u8FC7\u65F6\u7684\u518D\u5199\u3002target=me\uFF1A\u5173\u4E8E\u7528\u6237\u7684\u957F\u671F\u8BB0\u5FC6\uFF0C\u5206\u300C\u957F\u671F\u300D\u300C\u6700\u8FD1\u300D\u4E24\u6BB5\uFF0C\u53EA\u8BB0\u7528\u6237\u8BF4\u8FC7\u6216\u505A\u8FC7\u7684\u4E8B\u5B9E\uFF08\u559C\u597D\u3001\u6B63\u5728\u7ECF\u5386\u7684\u4E8B\u3001\u6DF1\u5165\u804A\u8FC7\u7684\u8BDD\u9898\uFF09\uFF0C\u4E0D\u8D34\u6027\u683C\u6807\u7B7E\u3002target=\u683C\u5B50 id\uFF1A\u8FD9\u4E00\u683C\u7684 wiki\uFF0C\u53EA\u5199\u5361\u7247\u548C\u7075\u611F\u91CC\u6CA1\u6709\u7684\u4E1C\u897F\uFF08\u5BF9\u7528\u6237\u610F\u5473\u7740\u4EC0\u4E48\u3001\u5361\u5728\u54EA\u3001\u53CD\u590D\u51FA\u73B0\u7684\u4E3B\u9898\u3001\u6CA1\u89E3\u51B3\u7684\u7591\u95EE\uFF09\uFF0C\u53E5\u672B\u7528 [^\u5361\u7247\u6216\u7075\u611F id] \u6807\u51FA\u4F9D\u636E\uFF1Bsummary \u4E00\u53E5\u8BDD\uFF08\u226440 \u5B57\uFF09\uFF0Ctopics 3\u20135 \u4E2A\u4E3B\u9898\u8BCD\uFF08\u81EA\u7531\u586B\u5199\uFF0C\u8DE8\u683C\u5B50\u76F8\u901A\u7684\u8BCD\u66F4\u597D\uFF0C\u6BD4\u5982\u300C\u7B49\u5F85\u300D\u300C\u5B64\u72EC\u300D\uFF09\u3002`,parameters:{target:{type:"string",required:!0,description:"\u683C\u5B50 id \u6216 me"},body:{type:"string",required:!0,description:"Markdown \u6B63\u6587"},summary:{type:"string"},topics:{type:"array",items:{type:"string"}}},async execute(o){return Te(async()=>{let s=t.writePage(o.target,{body:o.body,summary:o.summary,topics:o.topics});return o.target==="me"?"\u5DF2\u66F4\u65B0\u300C\u5173\u4E8E\u7528\u6237\u300D\u3002":`\u5DF2\u66F4\u65B0\u300A${e.getPalace().cells.find(a=>a.id===o.target)?.title}\u300B\u7684 wiki`+(s.topics?.length?`\uFF08\u4E3B\u9898\u8BCD\uFF1A${s.topics.join("\u3001")}\uFF09`:"")+"\u3002"})}},{name:"palace_link",description:"\u5728\u4E24\u683C\u4E4B\u95F4\u8FDE\u4E00\u6761\u7535\u5F27\uFF08\u8054\u60F3\uFF09\uFF1A\u7528\u6237\u7684\u67D0\u4E2A\u60F3\u6CD5\u3001\u4E3B\u9898\u6216\u7591\u95EE\u628A\u8FD9\u4E24\u683C\u8FDE\u5728\u4E00\u8D77\u65F6\u8C03\u7528\u3002\u4E0D\u9700\u8981\u4E24\u672C\u4E66\u4E92\u76F8\u63D0\u53CA\uFF0C\u8FDE\u7684\u662F\u7528\u6237\u7684\u5FF5\u5934\u3002why \u4E00\u53E5\u8BDD\u8BF4\u6E05\u8FDE\u5728\u54EA\uFF08\u226440 \u5B57\uFF0C\u4F8B\u5982\u300C\u90FD\u5728\u5199\u7B49\u5F85\uFF1A\u76D6\u8328\u6BD4\u7B49\u7EFF\u706F\uFF0C\u4F60\u5728\u7B49 offer\u300D\uFF09\uFF1Bevidence \u586B\u4E24\u7AEF\u5404\u81F3\u5C11\u4E00\u5F20\u5361\u7247\u6216\u4E00\u6761\u7075\u611F\u7684 id\u3002\u540C\u6837\u7684\u8BC1\u636E\u4E0D\u80FD\u91CD\u590D\u8FDE\uFF1B\u6709\u65B0\u8BC1\u636E\u5C31\u518D\u8FDE\u4E00\u6761\uFF0C\u7535\u5F27\u4F1A\u53D8\u7C97\u3002\u7528\u6237\u526A\u65AD\u8FC7\u7684\u4E24\u683C\uFF0C\u9664\u975E\u7528\u6237\u660E\u786E\u8981\u6C42\uFF0C\u5426\u5219\u4E0D\u8981\u518D\u8FDE\u3002\u53EA\u6539\u5DF2\u6709\u7535\u5F27\u7684\u9898\u8BCD\u65F6\u586B update_why=true\uFF0Cwhy \u4ECE\u4E24\u7AEF\u539F\u6587\u6458\u53D6\uFF0C\u7701\u7565 evidence\u3002",parameters:{from:{type:"string",required:!0,description:"\u683C\u5B50 id"},to:{type:"string",required:!0,description:"\u683C\u5B50 id"},why:{type:"string",required:!0},evidence:{type:"array",items:{type:"string"},description:"\u8FDE\u7EBF\u5FC5\u586B\uFF1A\u5361\u7247 / \u7075\u611F id"},update_why:{type:"boolean",description:"\u53EA\u66F4\u65B0\u73B0\u6709\u7535\u5F27\u7684\u9898\u8BCD"},user_asked:{type:"boolean",description:"\u7528\u6237\u660E\u786E\u8981\u6C42\u8FDE\uFF08\u526A\u65AD\u8FC7\u7684\u4E5F\u80FD\u91CD\u8FDE\uFF09"}},async execute(o,s){return Te(async()=>{if(o.update_why===!0)return t.retitleLink({from:o.from,to:o.to,why:o.why}),"\u5DF2\u66F4\u65B0\u7535\u5F27\u9898\u8BCD\u3002";let i=t.addLink({from:o.from,to:o.to,why:o.why,evidence:o.evidence,...s.attribution,userAsked:o.user_asked===!0}),a=e.getPalace().cells,c=t.arcs().find(u=>u.links.some(l=>l.id===i.id));return`\u5DF2\u8FDE\u4E0A\u300A${a.find(u=>u.id===i.from)?.title}\u300B\u2194\u300A${a.find(u=>u.id===i.to)?.title}\u300B\uFF1A${i.why}\uFF08\u73B0\u5728 ${c?.strands??1} \u80A1\uFF09`})}},{name:"palace_unlink",description:"\u526A\u65AD\u4E24\u683C\u4E4B\u95F4\u7684\u7535\u5F27\uFF08\u7528\u6237\u8BF4\u8FD9\u4E24\u4E2A\u6CA1\u5173\u7CFB\u3001\u8FDE\u9519\u4E86\u65F6\u8C03\u7528\uFF09\u3002\u4E4B\u524D\u7684\u8054\u60F3\u90FD\u4E0D\u518D\u663E\u793A\uFF0C\u4EE5\u540E\u4E5F\u4E0D\u4F1A\u81EA\u52A8\u518D\u8FDE\u3002",parameters:{from:{type:"string",required:!0},to:{type:"string",required:!0}},async execute(o){return Te(async()=>(t.cut({from:o.from,to:o.to}),"\u5DF2\u526A\u65AD\u3002"))}}]}function rw(e,t,r){let n={type:"string",required:!0,description:"\u7528\u6237\u63D0\u4F9B\u7684\u7B14\u8BB0\u5E93\u6587\u4EF6\u5939\u7EDD\u5BF9\u8DEF\u5F84"};return[{name:"palace_scan_obsidian",description:"\u53EA\u8BFB\u626B\u63CF Obsidian \u7B14\u8BB0\u5E93\u3002\u5411\u7528\u6237\u8BE2\u95EE\u8DEF\u5F84\u540E\u8C03\u7528\uFF0C\u6309\u6587\u4EF6\u5939\u7EDF\u8BA1\u7BC7\u6570\u3001\u6807\u7B7E\u548C\u53EF\u89E3\u6790\u53CC\u94FE\uFF0C\u6BCF\u9875\u5217\u51FA\u6700\u591A 100 \u7BC7\u3002\u548C\u7528\u6237\u5546\u91CF\u5206\u683C\u65B9\u6848\u540E\u518D\u9884\u89C8\u3002",parameters:{path:n,offset:{type:"integer",description:"\u4E0B\u4E00\u9875\u8D77\u70B9\uFF0C\u4F7F\u7528\u4E0A\u6B21\u8FD4\u56DE\u7684 nextOffset"}},async execute(o,s){return Te(async()=>JSON.stringify(await r.scan(o.path,o.offset,s.signal)))}},{name:"palace_import_obsidian",description:"\u5BFC\u5165 Obsidian \u7B14\u8BB0\u3002plan \u7701\u7565\u65F6\u6309\u6587\u4EF6\u5939\u5EFA\u683C\uFF1B\u6241\u5E73\u7B14\u8BB0\u5E93\u6309\u6807\u7B7E\u548C\u53CC\u94FE\u5546\u91CF\u5206\u683C\u3002plan \u6BCF\u4E2A\u76EE\u6807\u7528 paths \u6216 tags \u9009\u7B14\u8BB0\uFF0C\u4E8C\u9009\u4E00\uFF0C\u518D\u6307\u5B9A\u65B0\u683C\u5B50\u6807\u9898\u6216\u5DF2\u6709\u683C\u5B50 id\u3002\u5148\u7701\u7565 confirmation \u83B7\u53D6\u65B0\u589E\u683C\u5B50\u3001\u5361\u7247\u548C\u7535\u5F27\u7684\u9884\u89C8\uFF0C\u5411\u7528\u6237\u590D\u8FF0\u5E76\u7B49\u786E\u8BA4\uFF0C\u518D\u7528\u76F8\u540C\u65B9\u6848\u548C\u9884\u89C8\u7684 token \u8C03\u7528\u3002\u53CC\u94FE\u81EA\u52A8\u8FDE\u7EBF\u3002\u5BFC\u5165\u540E\u6309\u7ED3\u679C\u91CC\u7684\u4E24\u7AEF\u7B14\u8BB0\u8DEF\u5F84\u8BFB\u539F\u6587\uFF0C\u5FC5\u8981\u65F6\u7528 palace_link \u7684 update_why \u6539\u987A\u9898\u8BCD\u3002",parameters:{path:n,plan:{type:"array",items:{type:"object",additionalProperties:!1,properties:{title:{type:"string",description:"\u65B0\u7B14\u8BB0\u683C\u5B50\u6807\u9898"},item_id:{type:"string",description:"\u5DF2\u6709\u4E66\u6216\u7B14\u8BB0\u683C\u5B50 id"},paths:{type:"array",items:{type:"string"},description:"\u626B\u63CF\u8FD4\u56DE\u7684\u7B14\u8BB0\u76F8\u5BF9\u8DEF\u5F84"},tags:{type:"array",items:{type:"string"},description:"\u626B\u63CF\u8FD4\u56DE\u7684\u6807\u7B7E\uFF0C\u5339\u914D\u5176\u4E2D\u4EFB\u610F\u4E00\u4E2A\u5C31\u9009\u5165"}}}},confirmation:{type:"string",description:"\u4EC5\u5728\u7528\u6237\u786E\u8BA4\u540E\u4F20\u5165\u9884\u89C8\u8FD4\u56DE\u7684 token"}},async execute(o,s){return Te(async()=>{if(o.confirmation!==void 0&&typeof o.confirmation!="string")throw new w("\u786E\u8BA4\u503C\u5FC5\u987B\u662F\u9884\u89C8\u8FD4\u56DE\u7684 token");let i=await r.prepare(o.path,o.plan,s.signal);return s.signal?.throwIfAborted(),JSON.stringify(await pl(e,t,i,o.confirmation))})}}]}function nw(e,t,r){let n=()=>{let o=new Set(e.getPalace().cells.filter(s=>s.kind==="book").map(s=>s.id));return s=>o.has(Ii("c","weread",s))};return[{name:"palace_scan_weread",description:"\u67E5\u770B\u5FAE\u4FE1\u8BFB\u4E66\u4E66\u67B6\u53CA\u7B14\u8BB0\u3002\u540C\u6B65\u6216\u518D\u6B21\u4ECE\u5165\u53E3\u5BFC\u5165\u65F6\uFF0C\u9ED8\u8BA4\u9884\u89C8\u5DF2\u5BFC\u5165\u7684\u4E66\uFF1B\u6709\u7B14\u8BB0\u4F46\u672A\u5BFC\u5165\u7684\u4E66\u53EA\u63D0\u793A\uFF0C\u7528\u6237\u660E\u786E\u9009\u4E2D\u624D\u5BFC\u5165\u3002",parameters:{},async execute(o,{signal:s}){return Te(async()=>JSON.stringify(await r.scan(s,n())))}},{name:"palace_import_weread",description:"\u5BFC\u5165\u6216\u540C\u6B65\u5FAE\u4FE1\u8BFB\u4E66\u3002\u540C\u6B65\u5148\u626B\u63CF\uFF0C\u7701\u7565 plan \u9ED8\u8BA4\u540C\u6B65\u5DF2\u5BFC\u5165\u7684\u4E66\uFF1B\u660E\u786E\u9009\u4E66\u624D\u4F20 bookId \u5217\u8868\u3002\u5148\u7701\u7565 confirmation\uFF0C\u5411\u7528\u6237\u8BF4\u660E\u65B0\u589E\u3001\u66F4\u65B0\u7684\u5361\u7247\u6570\u3001\u9605\u8BFB\u767E\u5206\u6BD4\u548C\u5C06\u6807\u8BB0\u4E3A\u5DF2\u8BFB\u7684\u8282\u6570\uFF08markRead\uFF09\uFF1B\u7528\u6237\u786E\u8BA4\u540E\u7528\u540C\u4E00\u65B9\u6848\u548C\u9884\u89C8 token \u5199\u5165\u3002",parameters:{plan:{type:"array",items:{type:"string"}},confirmation:{type:"string"}},async execute({plan:o,confirmation:s},{signal:i}){return Te(async()=>{if(s!==void 0&&typeof s!="string")throw new w("\u8BF7\u4F7F\u7528\u9884\u89C8\u8FD4\u56DE\u7684 token");let a=await r.prepare(o,s!==void 0,i,n());if(i?.aborted)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u5BFC\u5165\u5DF2\u53D6\u6D88");return JSON.stringify(await pl(e,t,a,s))})}}]}function ow(e,t=""){return{name:"palace_context",description:"\u8BFB\u53D6 Memory Palace \u7684\u8BB0\u5FC6\u80CC\u666F\uFF0C\u53EF\u6307\u5B9A\u683C\u5B50 id\u3002"+t,parameters:{item_id:{type:"string"}},async execute(r){return e.context({itemId:r.item_id})}}}function sw(e){return{name:"palace_open",description:"\u6253\u5F00\u6211\u7684\u8BB0\u5FC6\u5BAB\u6BBF\uFF1A\u8FD4\u56DE\u672C\u673A\u6D4F\u89C8\u5668\u53EF\u4EE5\u6253\u5F00\u7684\u5BAB\u6BBF\u7F51\u9875\u5730\u5740\u3002",parameters:{},async execute(){return e}}}import{closeSync as tT,copyFileSync as rT,existsSync as gl,mkdirSync as nT,openSync as oT,readdirSync as sT,readSync as iT,statSync as aT}from"node:fs";import{homedir as _w}from"node:os";import{basename as yw,extname as Oi,isAbsolute as ww,join as yo}from"node:path";var iw="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130 Safari/537.36",go=class extends Error{};function aw(e){if(!/^https?:\/\//.test(e))return/BV[0-9A-Za-z]{10}/.test(e);try{let t=new URL(e).hostname;return t==="b23.tv"||t==="bilibili.com"||t.endsWith(".bilibili.com")}catch{return!1}}async function JE(e,t){let r=e.match(/BV[0-9A-Za-z]{10}/);if(r)return r[0];let n=e.match(/https?:\/\/b23\.tv\/[0-9A-Za-z]+/);if(n){let s=(await fetch(n[0],{redirect:"follow",headers:{"user-agent":iw},signal:cw(t)})).url.match(/BV[0-9A-Za-z]{10}/);if(s)return s[0]}throw new go("\u6CA1\u6709\u8BC6\u522B\u5230 B \u7AD9\u89C6\u9891\u94FE\u63A5\uFF08\u9700\u8981\u5305\u542B BV \u53F7\uFF0C\u6216 b23.tv \u77ED\u94FE\uFF09")}async function GE(e,t){let r=await fetch(`https://api.bilibili.com/x/web-interface/view?bvid=${e}`,{headers:{"user-agent":iw,referer:"https://www.bilibili.com/"},signal:cw(t)});if(!r.ok)throw new go(`B \u7AD9\u63A5\u53E3\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${r.status}\uFF09`);let n=await r.json();if(n.code!==0||n.data===void 0)throw new go(`B \u7AD9\u8FD4\u56DE\u9519\u8BEF\uFF1A${n.message??n.code}`);return n.data}function cw(e){let t=AbortSignal.timeout(15e3);return e?AbortSignal.any([e,t]):t}async function uw(e,t){let r=await JE(e,t),n=await GE(r,t),o=`https://www.bilibili.com/video/${n.bvid}`,s=n.pages??[];if(s.length>1)return{title:n.title,url:o,chapters:[{title:"\u5168\u90E8\u89C6\u9891",episodes:s.map(a=>({title:a.part||`\u7B2C ${a.page} \u96C6`,url:`${o}?p=${a.page}`}))}]};let i=n.ugc_season;if(i!==void 0&&i.sections.some(a=>a.episodes.length>1)){let a=i.sections.filter(c=>c.episodes.length>0).map(c=>({title:i.sections.length===1?"\u5168\u90E8\u89C6\u9891":c.title,episodes:c.episodes.map(u=>({title:u.title,url:`https://www.bilibili.com/video/${u.bvid}`}))}));return{title:i.title||n.title,url:o,chapters:a}}return{title:n.title,url:o,chapters:[{title:"\u5168\u90E8\u89C6\u9891",episodes:[{title:n.title,url:o}]}]}}import{readFile as WE}from"node:fs/promises";import{createRequire as YE}from"node:module";import{dirname as XE,join as lw,sep as dw}from"node:path";var QE=YE(import.meta.url),fw;function eT(){return fw??=import("pdfjs-dist/legacy/build/pdf.mjs"),fw}function hl(){return XE(QE.resolve("pdfjs-dist/package.json"))}async function hw(e){let t=await eT(),r=new Uint8Array(await WE(e)),n=hl(),o=t.getDocument({data:r,cMapUrl:lw(n,"cmaps")+dw,cMapPacked:!0,standardFontDataUrl:lw(n,"standard_fonts")+dw,isEvalSupported:!1,disableFontFace:!0,verbosity:0});return{doc:await o.promise,close:()=>o.destroy()}}async function pw(e,t){try{let r=typeof t=="string"?await e.getDestination(t):t;if(!Array.isArray(r)||r.length===0)return;let n=r[0];if(typeof n=="number")return n+1;if(n!==null&&typeof n=="object")return await e.getPageIndex(n)+1}catch{}}function mw(e){return e.replace(/\s+/g," ").trim()}async function gw(e){let{doc:t,close:r}=await hw(e);try{let n=await t.getOutline()??[];for(;n.length===1&&n[0].items.length>0;)n=n[0].items;let o=[];for(let i of n){let a=[];for(let u of i.items){let l=mw(u.title);l!==""&&a.push({title:l,page:await pw(t,u.dest)})}let c=mw(i.title);c!==""&&o.push({title:c,page:await pw(t,i.dest),sections:a})}let s;try{let a=(await t.getMetadata()).info;typeof a?.Title=="string"&&a.Title.trim()!==""&&(s=a.Title.trim())}catch{}return{pageCount:t.numPages,title:s,outline:o}}finally{await r()}}async function Ei(e,t){let{doc:r,close:n}=await hw(e);try{let o=[];for(let s of t){if(!Number.isInteger(s)||s<1||s>r.numPages)continue;let i=await r.getPage(s),a=await i.getTextContent(),c="";for(let u of a.items)"str"in u&&(c+=u.str,u.hasEOL&&(c+=`
|
|
125
126
|
`));o.push({page:s,text:c.replace(/[ \t]+/g," ").replace(/\n{3,}/g,`
|
|
126
127
|
|
|
127
|
-
`).trim()}),i.cleanup()}return o}finally{await n()}}var
|
|
128
|
+
`).trim()}),i.cleanup()}return o}finally{await n()}}var Ti=20;function _o(e){return e.startsWith("~/")?yo(_w(),e.slice(2)):e}async function Ri(e,t,r,{readVideo:n=!0}={}){let o=()=>{if(r?.aborted)throw new w("\u5DF2\u53D6\u6D88")},s,i,a=[],c;if(typeof t.url=="string"&&t.url.trim()!==""){let u=t.url.trim();if(!n||!aw(u)){if(!/^https?:\/\/\S+$/.test(u))throw new w("\u89C6\u9891\u94FE\u63A5\u8981\u4EE5 http:// \u6216 https:// \u5F00\u5934");if(typeof t.title!="string"||t.title.trim()==="")throw new w(n?"\u4E0D\u662F B \u7AD9\u94FE\u63A5\u65F6\u8981\u586B\u4F5C\u54C1\u540D":"\u89C6\u9891\u94FE\u63A5\u8981\u586B\u4F5C\u54C1\u540D");return o(),qt(e,{kind:"book",title:t.title.trim(),subtitle:t.subtitle,source:{type:"video",url:u},parentId:t.parentId,targetDate:t.targetDate})}let l=await uw(u,r).catch(d=>{throw o(),new w(d.message)});s={type:"video",url:l.url},i=l.title,a=l.chapters.map(d=>({title:d.title,sections:d.episodes.map(f=>({title:f.title,loc:f.url}))})),c="video"}else if(typeof t.file=="string"&&t.file.trim()!==""){let u=_o(t.file.trim().replace(/^['"]|['"]$/g,""));if(!ww(u))throw new w("\u8BF7\u63D0\u4F9B PDF \u7684\u5B8C\u6574\u8DEF\u5F84\uFF08\u4EE5 / \u5F00\u5934\uFF09");if(!gl(u)||!aT(u).isFile())throw new w(`\u627E\u4E0D\u5230\u6587\u4EF6\uFF1A${u}`);let l=Oi(u).toLowerCase();if(l!==".pdf"&&l!==".epub")throw new w("\u76EE\u524D\u53EA\u652F\u6301 PDF \u548C EPUB \u6587\u4EF6");if(l===".epub"){if(!cT(u))throw new w("\u8FD9\u4E0D\u662F\u6709\u6548\u7684 EPUB \u6587\u4EF6\uFF08\u53EF\u80FD\u635F\u574F\u6216\u6CA1\u4E0B\u8F7D\u5B8C\u6574\uFF09");return s={type:"epub",path:u},i=yw(u,l),typeof t.title=="string"&&t.title.trim()!==""&&(i=t.title.trim()),o(),qt(e,{kind:"book",title:i,subtitle:t.subtitle,source:s,parentId:t.parentId,targetDate:t.targetDate})}let d=await gw(u).catch(f=>{throw new w(`PDF \u6253\u4E0D\u5F00\uFF1A${f.message}`)});s={type:"pdf",path:u,pageCount:d.pageCount},i=yw(u,Oi(u)),a=d.outline.map(f=>({title:f.title,...f.page!==void 0?{loc:String(f.page)}:{},sections:f.sections.map(p=>({title:p.title,...p.page!==void 0?{loc:String(p.page)}:{}}))})),c="bookmarks"}else throw new w("\u8BF7\u9009\u62E9 PDF \u6587\u4EF6\uFF0C\u6216\u7C98\u8D34\u89C6\u9891\u94FE\u63A5");return typeof t.title=="string"&&t.title.trim()!==""&&(i=t.title.trim()),o(),qt(e,{kind:"book",title:i,subtitle:t.subtitle,source:s,parentId:t.parentId,targetDate:t.targetDate,outline:a,outlineSource:c})}function cT(e){let t=oT(e,"r");try{let r=Buffer.alloc(4);return iT(t,r,0,4,0)===4&&r.equals(Buffer.from([80,75,3,4]))}finally{tT(t)}}function uT(e){let t=e.match(/sha256:([0-9a-f]{8,64})/i)?.[1]?.toLowerCase();if(t===void 0)return;let r=process.env.DSH_HOME??yo(_w(),".dsh"),n=yo(r,"attachments","v1","objects",t.slice(0,2));if(!gl(n))return;let o=sT(n).find(s=>s.startsWith(t));return o===void 0?void 0:yo(n,o)}var lT=new Set([".png",".jpg",".jpeg",".webp",".gif"]);function bw(e,t){if(typeof t!="string"||t.trim()==="")return;let r=_o(t.trim().replace(/^['"]|['"]$/g,"")),n=ww(r)&&gl(r)?r:uT(r);if(n===void 0)return;let o=lT.has(Oi(n).toLowerCase())?Oi(n).toLowerCase():".png",s=`${We("img")}${o}`;return e.assertWritable(),e.snapshotBeforeWrite(),nT(e.imagesDir,{recursive:!0}),rT(n,yo(e.imagesDir,s)),s}import{createHash as dT}from"node:crypto";import{constants as vw}from"node:fs";import{open as fT,readdir as pT,realpath as mT,stat as hT}from"node:fs/promises";import{isAbsolute as gT,join as $w,posix as Ot}from"node:path";function yT(e,t,r){let n=e.replace(/^(?:\uFEFF)?(?:[ \t]*\r?\n)*/,"");if(/^ {0,3}#{1,6}(?:[ \t]|\r?\n|$)/.test(n)||/^ {0,3}\S[^\r\n]*\r?\n {0,3}(?:=+|-+)[ \t]*(?:\r?\n|$)/.test(n))return e;let o=Ot.basename(t).replace(/\.md$/i,"").replace(/[\r\n]+/g," "),s=r.match(/\r?\n/)?.[0]??`
|
|
129
|
+
`;return`# ${o}${s}${s}${e}`}async function kw(e,t){if(typeof e!="string"||!gT(_o(e)))throw new w("\u8BF7\u63D0\u4F9B Obsidian \u7B14\u8BB0\u5E93\u7684\u7EDD\u5BF9\u8DEF\u5F84");let r=[],n=[],o;try{if(o=await mT(_o(e)),!(await hT(o)).isDirectory())throw new w("\u8BF7\u9009\u62E9 Obsidian \u7B14\u8BB0\u5E93\u6587\u4EF6\u5939");async function c(u){t?.throwIfAborted();let l=await pT($w(o,u),{withFileTypes:!0});for(let d of l.sort((f,p)=>f.name.localeCompare(p.name))){if(t?.throwIfAborted(),d.name.startsWith("."))continue;let f=Ot.join(u,d.name);if(d.isDirectory()){await c(f);continue}if(!d.isFile()||!/\.md$/i.test(d.name))continue;let p=await fT($w(o,f),vw.O_RDONLY|vw.O_NOFOLLOW),m;try{m=await p.readFile({encoding:"utf8",signal:t})}finally{await p.close()}let h=/^(?:\uFEFF)?---[ \t]*\r?\n[\s\S]*?^---[ \t]*(?:\r?\n|$)/m.exec(m),g=h?.index===0?h[0]:void 0,y=m.slice(g?.length??0),v=/^tags:[ \t]*(.*)((?:\r?\n[ \t]*-[ \t]+[^\r\n]*)*)/m.exec(g??""),$=v?v[1]+v[2].replace(/^[ \t]*-[ \t]+/gm," "):"",I=new Set($.match(/[\p{L}\p{N}_/-]+/gu)??[]),x=y.replace(/<!--[^]*?(?:-->|$)|%%[^]*?(?:%%|$)/g,k=>k.replace(/[^\r\n]/g," ")),R;for(let k of x.split(/\r?\n/)){let E=/^ {0,3}(`{3,}|~{3,})/.exec(k)?.[1];if(E&&!R){R=E;continue}if(R){E?.startsWith(R)&&k.trim()===E&&(R=void 0);continue}let M=k.replace(/(`+)[^`]*\1/g,P=>" ".repeat(P.length));for(let P of M.matchAll(/(?:^|[\s((,。!?、;:])#([\p{L}\p{N}_/-]+)/gu))I.add(P[1]);for(let P of M.matchAll(/(!|\\)?\[\[([^\]\n]+)\]\]/g)){if(P[1])continue;let U=P[2].split(/[|#]/,1)[0].trim();if(!U)continue;let te=P.index,ae=te+P[0].length,xe=k.slice(0,te).split(/[。!?!?]/).at(-1)??"",ge=k.slice(ae).split(/[。!?!?]/,1)[0],Ye=[...(xe+P[0]+ge).trim()],V=Ye.length<=40?Ye.join(""):[...xe.trimEnd()].slice(-8).concat([...P[0]+ge]).slice(0,40).join("").trim();n.push({from:f,to:U,why:V})}}r.push({key:f,note:yT(y,f,m),frontmatter:g,tags:[...I].sort()})}}await c("")}catch(c){throw t?.aborted||c instanceof w?c:new w("\u65E0\u6CD5\u8BFB\u53D6\u8FD9\u4E2A Obsidian \u7B14\u8BB0\u5E93\uFF0C\u8BF7\u786E\u8BA4\u8DEF\u5F84\u548C\u8BFB\u53D6\u6743\u9650")}let s=new Set(r.map(c=>c.key)),i=new Map;for(let{key:c}of r){let u=Ot.basename(c).replace(/\.md$/i,""),l=i.get(u);l?l.push(c):i.set(u,[c])}let a=n.flatMap(c=>{let u=/\.md$/i.test(c.to)?c.to:c.to+".md",l=Ot.normalize(Ot.join(Ot.dirname(c.from),u)),d=i.get(c.to.replace(/\.md$/i,"")),f=u.startsWith(".")?s.has(l)?l:void 0:u.includes("/")?s.has(u)?u:s.has(l)?l:void 0:s.has(l)?l:d?.length===1?d[0]:void 0;return f&&f!==c.from?[{...c,to:f}]:[]});return{root:o,notes:r,links:a,unresolved:n.length-a.length}}var xw={async scan(e,t,r){if(t!==void 0&&(typeof t!="number"||!Number.isSafeInteger(t)||t<0))throw new w("offset \u5E94\u4E3A\u975E\u8D1F\u6574\u6570");let{notes:n,links:o,unresolved:s}=await kw(e,r),i=Number(t??0),a=new Map,c=new Map;for(let l of o){let d=c.get(l.from);d?d.push(l.to):c.set(l.from,[l.to])}let u=n.map(({key:l,tags:d})=>{let f=Ot.dirname(l),p=a.get(f)??{path:f,count:0,tags:new Set,links:0};a.set(f,p);let m=c.get(l)??[];p.count+=1;for(let h of d)p.tags.add(h);return p.links+=m.length,{path:l,tags:d,links:m}});return{count:n.length,links:o.length,unresolved:s,folders:[...a.values()].map(l=>({...l,tags:[...l.tags].sort()})),notes:u.slice(i,i+100),nextOffset:i+100<u.length?i+100:void 0}},async prepare(e,t,r){let{root:n,notes:o,links:s}=await kw(e,r);if(o.length===0)throw new w("\u8FD9\u4E2A\u6587\u4EF6\u5939\u6CA1\u6709 Markdown \u7B14\u8BB0");let i="obsidian:"+dT("sha256").update(n).digest("hex"),a=[];if(t===void 0){let c=new Map;for(let u of o){let l=Ot.dirname(u.key),d=c.get(l)??{key:"folder:"+l,title:Ot.basename(l==="."?n:l)||"Obsidian",cards:[]};c.set(l,d),d.cards.push(u)}a.push(...c.values())}else{if(!Array.isArray(t)||t.length===0)throw new w("\u5206\u683C\u65B9\u6848\u81F3\u5C11\u9700\u8981\u4E00\u4E2A\u76EE\u6807");let c=new Map(o.map(u=>[u.key,u]));for(let u of t){if(!u||typeof u!="object")throw new w("\u5206\u683C\u65B9\u6848\u65E0\u6548");let{title:l,item_id:d,paths:f,tags:p}=u;if(f===void 0==(p===void 0))throw new w("\u6BCF\u4E2A\u76EE\u6807\u8BF7\u5728 paths \u548C tags \u4E2D\u9009\u4E00\u9879");let m=f??p;if(!Array.isArray(m)||m.length===0||m.some(g=>typeof g!="string"||!g.trim()))throw new w("paths \u6216 tags \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u6587\u5B57\u5217\u8868");let h=f===void 0?o.filter(g=>g.tags.some(y=>m.includes(y))):m.map(g=>{let y=c.get(g);if(!y)throw new w(`\u65B9\u6848\u4E2D\u7684\u7B14\u8BB0\u4E0D\u5B58\u5728\uFF1A${g}`);return y});if(h.length===0)throw new w("\u6240\u9009\u6807\u7B7E\u6CA1\u6709\u5339\u914D\u7684\u7B14\u8BB0");if(typeof d=="string"&&d)a.push({key:d,itemId:d,title:"",cards:h});else if(d===void 0&&typeof l=="string"&&l.trim())a.push({key:"title:"+l.trim(),title:l.trim(),cards:h});else throw new w("\u6BCF\u4E2A\u76EE\u6807\u8BF7\u586B\u5DF2\u6709\u683C\u5B50 item_id \u6216\u65B0\u683C\u5B50 title")}}return{source:i,groups:a,links:s}}};import{randomUUID as _T}from"node:crypto";import{mkdirSync as wT,readFileSync as bT,realpathSync as Sw,renameSync as vT,rmSync as zw,writeFileSync as $T}from"node:fs";import{homedir as kT}from"node:os";import{basename as xT,dirname as Pw,isAbsolute as ST,join as Ew,relative as zT,sep as PT}from"node:path";import{setTimeout as IT}from"node:timers/promises";var ET="https://i.weread.qq.com/api/agent/gateway",TT="1.0.6",Tw=e=>typeof e=="string"&&/^wrk-[A-Za-z0-9_-]+$/.test(e),Ow=Ew(kT(),".dsh-palace","weread.json");function Rw(e=Ow){try{let{key:t}=JSON.parse(bT(e,"utf8"));if(Tw(t))return t}catch(t){if(t.code==="ENOENT")return}throw new w("\u65E0\u6CD5\u8BFB\u53D6\u5FAE\u4FE1\u8BFB\u4E66 Key\uFF0C\u8BF7\u5728\u5BAB\u6BBF\u91CD\u65B0\u4FDD\u5B58")}function Aw(e,t=Ow,r){if(e===void 0)return Rw(t)!==void 0;if(e!==null&&!Tw(e))throw new w("\u8BF7\u8F93\u5165\u6709\u6548\u7684\u5FAE\u4FE1\u8BFB\u4E66 API Key");let n=t+"."+_T();try{if(e===null)return zw(t,{force:!0}),!1;if(wT(Pw(t),{recursive:!0,mode:448}),r!==void 0){let o=zT(Sw(r),Ew(Sw(Pw(t)),xT(t)));if(!ST(o)&&o!==".."&&!o.startsWith(".."+PT))throw new w("\u5FAE\u4FE1\u8BFB\u4E66 Key \u5FC5\u987B\u4FDD\u5B58\u5728\u5BAB\u6BBF\u6570\u636E\u76EE\u5F55\u5916")}return $T(n,JSON.stringify({key:e}),{mode:384,flag:"wx"}),vT(n,t),!0}catch(o){throw o instanceof w?o:new w("\u65E0\u6CD5\u4FDD\u5B58\u6216\u5220\u9664\u5FAE\u4FE1\u8BFB\u4E66 Key")}finally{try{zw(n,{force:!0})}catch{}}}var Iw=({chapterUid:e,range:t})=>e!=null&&t?.trim()?JSON.stringify([String(e),t]):void 0,OT={"/shelf/sync":"books","/user/notebooks":"books","/review/list/mine":"reviews","/book/chapterinfo":"chapters","/book/bookmarklist":"updated","/book/getprogress":"book"};function RT(e,t,r){let n=[];for(let s of e){let i=s.title?.trim();if(!i)continue;let a=s.level??1,c={title:i,loc:String(s.chapterUid),sections:[]};a===1||a===2&&!n.length?n.push(c):a===2&&n.at(-1).sections.push({title:c.title,loc:c.loc})}let o=new Set([r,...t.map(s=>s.sectionKey)]);for(let s of n)s.sections?.length&&s.loc&&o.has(s.loc)&&s.sections.unshift({title:s.title,loc:s.loc});return n}function AT(e=fetch,t=Rw){let r=new Set;async function n(c,u,l,d,f=!1){async function p(){let m=AbortSignal.timeout(12e3),h=d?AbortSignal.any([d,m]):m,g=await e(ET,{method:"POST",redirect:"error",signal:h,headers:{Authorization:`Bearer ${c}`,"Content-Type":"application/json"},body:JSON.stringify({api_name:u,skill_version:TT,...l})});return{response:g,data:g.ok?await g.json():{}}}try{for(;r.size>=3;)d?.throwIfAborted(),await Promise.race(r).catch(()=>{});d?.throwIfAborted();let m=p();r.add(m);let{response:h,data:g}=await m.finally(()=>r.delete(m)),y=Number(g?.errcode||h.status);if(y===429){let $=Number(h.headers.get("retry-after")??1);if($>=0&&$<=3&&!f)return await IT($*1e3,void 0,{signal:d}),n(c,u,l,d,!0);throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u8BF7\u6C42\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5")}if(y===401||y===403)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u9274\u6743\u5931\u8D25\uFF0C\u8BF7\u66F4\u6362 API Key");if(!h.ok||!g||Number(g.errcode??0)!==0)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u63A5\u53E3\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5");let v=g[OT[u]];if(u==="/book/getprogress"?!v||typeof v!="object"||Array.isArray(v):!Array.isArray(v))throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u56DE\u5305\u4E0D\u5B8C\u6574\uFF0C\u8BF7\u91CD\u8BD5");return g}catch(m){throw m instanceof w?m:d?.aborted?new w("\u5FAE\u4FE1\u8BFB\u4E66\u5BFC\u5165\u5DF2\u53D6\u6D88"):new w("\u8FDE\u63A5\u5FAE\u4FE1\u8BFB\u4E66\u5931\u8D25\u6216\u8D85\u65F6\uFF0C\u8BF7\u91CD\u8BD5")}}function o(){let c=t();if(!c)throw new w("\u8BF7\u5148\u5728\u5BAB\u6BBF\u300C\u4ECE\u5FAE\u4FE1\u8BFB\u4E66\u5BFC\u5165\u300D\u91CC\u4FDD\u5B58 API Key");return c}async function s(c,u){let l=await n(c,"/shelf/sync",{},u),d=new Map(l.books.map(p=>[p.bookId,{...p,hasNotes:!1}])),f;for(;;){let p=await n(c,"/user/notebooks",{count:100,lastSort:f},u);for(let h of p.books){let g=d.get(h.bookId)??h.book;g&&d.set(h.bookId,{...g,bookId:h.bookId,hasNotes:!!(h.noteCount||h.reviewCount)})}if(!p.hasMore)break;let m=p.books.at(-1)?.sort;if(m===void 0||m===f)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u7B14\u8BB0\u5217\u8868\u5206\u9875\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");f=m}return{books:d,total:l.books.length+(l.albums?.length??0)+ +(Object.keys(l.mp??{}).length>0)}}let i,a;return{async scan(c,u=l=>!1){let l=o();i={key:l,data:await s(l,c)},a=void 0;let{books:d,total:f}=i.data;return{total:f,withNotes:[...d.values()].filter(p=>p.hasNotes).length,books:[...d.values()].map(({bookId:p,title:m,author:h,category:g,finishReading:y,readUpdateTime:v,publishTime:$,hasNotes:I})=>({bookId:p,title:m,author:h,category:g,finished:y===1,readUpdateTime:v,publishTime:$,hasNotes:I,imported:u(p)}))}},async prepare(c,u,l,d){if(c!==void 0&&(!Array.isArray(c)||c.length===0||c.some($=>typeof $!="string"||!$)))throw new w("\u8BF7\u63D0\u4F9B\u8981\u5BFC\u5165\u7684 bookId \u5217\u8868");let f=o(),p=c===void 0?void 0:[...new Set(c)],m=JSON.stringify(p??null);if(u&&a?.key===f&&a.plan===m)return a.batch;if(u)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u5BFC\u5165\u9884\u89C8\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9884\u89C8\u5E76\u786E\u8BA4");let{books:h}=i?.key===f?i.data:await s(f,l);i=void 0;let g=p??[...h.keys()].filter(d);if(!g.length)throw new w("\u6CA1\u6709\u53EF\u540C\u6B65\u7684\u4E66\uFF0C\u8BF7\u5148\u9009\u4E66\u5BFC\u5165");let y=[];for(let $ of g){let I=h.get($);if(!I)throw new w("\u9009\u4E2D\u7684\u4E66\u4E0D\u5728\u4E66\u67B6\u6216\u7B14\u8BB0\u672C\u91CC\uFF0C\u8BF7\u91CD\u65B0\u626B\u63CF");let x=[I.readerLink,I.deepLink].find(V=>typeof V=="string"&&/^https?:\/\//.test(V)),R={key:$,kind:"book",title:I.title,href:x,cards:[]};y.push(R);let{book:{progress:k,finishTime:E,chapterUid:M}}=await n(f,"/book/getprogress",{bookId:$},l);if(typeof k=="number"&&Number.isInteger(k)&&k>=0&&k<=100){let V=k===100&&typeof E=="number"&&E>0?new Date(E*1e3):void 0;R.progress={percent:k/100,chapterUid:M?.toString(),finishedAt:V&&Number.isFinite(V.getTime())?tr(V):void 0}}if(!I.hasNotes)continue;let P=async()=>{let V=[],Oe=0;for(;;){let Re=await n(f,"/review/list/mine",{bookid:$,synckey:Oe,count:100},l);if(V.push(...Re.reviews),!Re.hasMore)return V;if(!Re.synckey||Re.synckey===Oe)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u60F3\u6CD5\u5217\u8868\u5206\u9875\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");Oe=Re.synckey}},[U,te,ae]=await Promise.all([n(f,"/book/chapterinfo",{bookId:$},l),n(f,"/book/bookmarklist",{bookId:$},l),P()]),xe=new Map,ge=new Map;for(let V of te.updated)if(V.markText?.trim()){let Oe=JSON.stringify([$,"bookmark",V.bookmarkId]),Re={key:Oe,type:"excerpt",quote:V.markText,sectionKey:V.chapterUid?.toString()};xe.set(Oe,Re);let Qr=Iw(V);Qr!==void 0&&ge.set(Qr,Re)}let Ye=new Map(ae.map(({review:V})=>[V.reviewId,V]));for(let V of Ye.values())if(V.abstract?.trim()||V.content?.trim()){let Oe=Iw(V),Re=Oe===void 0?void 0:ge.get(Oe);if(Re){V.content?.trim()&&(Re.note=Re.note?Re.note+`
|
|
130
|
+
|
|
131
|
+
`+V.content:V.content);continue}let Qr=JSON.stringify([$,"review",V.reviewId]);xe.set(Qr,{key:Qr,type:V.abstract?.trim()?"excerpt":"thought",quote:V.abstract||void 0,note:V.content,sectionKey:V.chapterUid?.toString()})}R.cards=[...xe.values()],R.chapters=RT(U.chapters,R.cards,R.progress?.chapterUid)}let v={source:"weread",groups:y,links:[]};return a={key:f,plan:m,batch:v},v}}}var Cw=AT();var NT=new Set(["palace_remove","palace_unlink"]),jT=new Set(["palace_overview","palace_read","palace_wiki_read","palace_context","palace_open","palace_scan_obsidian","palace_scan_weread"]);function yl(e){let{required:t,properties:r,items:n,...o}=e;return Array.isArray(t)&&(o.required=t),r&&(o.properties=Object.fromEntries(Object.entries(r).map(([s,i])=>[s,yl(i)])),o.required=Object.entries(r).filter(([,s])=>s.required===!0).map(([s])=>s)),n&&(o.items=yl(n)),o}var DT="Memory Palace \u662F\u7528\u6237\u672C\u673A\u7684\u77E5\u8BC6\u4E0E\u8BB0\u5FC6\u5E93\u3002\u4EC5\u5728\u7528\u6237\u8C08\u5230\u5BAB\u6BBF\u6216\u5176\u4E2D\u5185\u5BB9\u65F6\u4F7F\u7528\u3002\u5F00\u59CB\u5BAB\u6BBF\u8BDD\u9898\u65F6\u5148\u8C03\u7528 palace_context\uFF0C\u5DF2\u77E5\u683C\u5B50 id \u5C31\u4F20 item_id\uFF1B\u5207\u6362\u683C\u5B50\u65F6\u91CD\u65B0\u8BFB\u53D6\u3002\u4E0D\u8981\u5047\u5B9A\u80CC\u666F\u5DF2\u81EA\u52A8\u6CE8\u5165\u3002\u64CD\u4F5C\u524D\u7528 palace_overview \u6838\u5B9E\u683C\u5B50 id\uFF0C\u5199\u5361\u7247\u548C\u7075\u611F\u5FC5\u987B\u663E\u5F0F\u4F20 item_id\u3002\u53EA\u8BB0\u7528\u6237\u8868\u8FBE\u8FC7\u7684\u4E8B\u5B9E\u548C\u60F3\u6CD5\uFF0C\u4E0D\u628A AI \u7684\u63A8\u6D4B\u8BB0\u6210\u7528\u6237\u89C2\u70B9\uFF1B\u66F4\u65B0\u8BB0\u5FC6\u524D\u5148\u8BFB\u65E7\u9875\uFF0C\u4FDD\u7559\u4ECD\u7136\u6709\u6548\u7684\u4FE1\u606F\u3002\u7528\u6237\u8981\u6C42\u4FDD\u5B58\u5BF9\u8BDD\u65F6\u7528 palace_add_inspiration\uFF0C\u5FC5\u8981\u65F6\u66F4\u65B0\u683C\u5B50\u8BB0\u5FC6\uFF1B\u7EAF\u529F\u80FD\u64CD\u4F5C\u4E0D\u5F3A\u884C\u66F4\u65B0\u8BB0\u5FC6\u3002\u5220\u9664\u524D\u8BF4\u660E\u76EE\u6807\u53CA\u5361\u7247\u3001\u7075\u611F\u6570\u91CF\u5E76\u53D6\u5F97\u7528\u6237\u660E\u786E\u540C\u610F\u3002\u7F51\u9875\u7531 palace_open \u8FD4\u56DE\uFF0C\u804A\u5929\u4ECD\u5728 Codex \u4E2D\u8FDB\u884C\u3002";function Nw(e,t){let r=new Wr(e),n=tw(e,r,{addBook:(c,u)=>Ri(e,c,u,{readVideo:!1}),readPageTexts:Ei,scannedThreshold:Ti,scannedPageHelp:"\u5426\u5219\u8BF7\u8BFB\u53D6\u672C\u673A PDF \u5BF9\u5E94\u9875\u7684\u56FE\u7247\uFF0C\u6216\u8BF7\u7528\u6237\u628A\u8FD9\u4E9B\u9875\u7684\u622A\u56FE\u9644\u5230 Codex \u5BF9\u8BDD\u3002",videoHelp:"\u89C6\u9891\u586B url \u548C\u6B63\u5F0F\u4F5C\u54C1\u540D title\uFF0C\u5148\u4FDD\u5B58\u94FE\u63A5\u3002",imageHelp:"image \u586B\u672C\u673A\u56FE\u7247\u7684\u7EDD\u5BF9\u8DEF\u5F84\u3002",imageDescription:"\u622A\u56FE\u7684\u672C\u673A\u7EDD\u5BF9\u8DEF\u5F84",currentItem:!1,wikiReadHelp:"\u9700\u8981\u80CC\u666F\u65F6\u5148\u8C03\u7528 palace_context\uFF1B\u66F4\u65B0\u8BB0\u5FC6\u524D\u5148\u8BFB\u53D6\u65E7\u9875\u3002",saveImage:c=>typeof c=="string"&&CT(c)?bw(e,c):void 0}),o=new Gr,s=ow(r,"\u5F00\u59CB\u5BAB\u6BBF\u8BDD\u9898\u6216\u5207\u6362\u683C\u5B50\u65F6\u5148\u8C03\u7528\uFF1B\u8BB0\u5FC6\u4E0D\u4F1A\u81EA\u52A8\u6CE8\u5165 Codex \u5BF9\u8BDD\u3002"),i=new Map([...n,...rw(e,r,xw),...nw(e,r,Cw),s,sw(t)].map(({name:c,description:u,parameters:l,execute:d})=>{let f=yl({type:"object",properties:l,additionalProperties:!1}),p={name:c,description:u,inputSchema:f,annotations:{readOnlyHint:jT.has(c),destructiveHint:NT.has(c)}};return[c,{tool:p,execute:d,validate:o.getValidator(f)}]})),a=new zi({name:"dsh-palace",version:"1.0.0"},{capabilities:{tools:{}},jsonSchemaValidator:o,instructions:DT});return a.setRequestHandler(Xa,()=>({tools:[...i.values()].map(({tool:c})=>c)})),a.setRequestHandler(En,async({params:c},{signal:u})=>{let l=i.get(c.name);if(!l)throw new N(D.InvalidParams,"\u672A\u77E5\u5DE5\u5177");let d=l.validate(c.arguments??{});if(!d.valid)throw new N(D.InvalidParams,d.errorMessage);let f=await l.execute(d.data,{signal:u});return/^操作失败:(?:palace\.json|items\/[^\n]+\.json) 刚被其他程序修改过,请重试$/.test(f)&&(f="\u64CD\u4F5C\u5931\u8D25\uFF1A\u6570\u636E\u521A\u88AB\u522B\u5904\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5"),{content:[{type:"text",text:f}],isError:f.startsWith("\u64CD\u4F5C\u5931\u8D25\uFF1A")}}),a}import{randomUUID as ZT}from"node:crypto";import{lstatSync as jw,mkdirSync as MT,readFileSync as qT,renameSync as FT,rmSync as LT,writeFileSync as UT}from"node:fs";import{dirname as VT}from"node:path";var _l=e=>JSON.stringify(e).replace(/\u007f/g,"\\u007f"),wl=()=>new Error("\u68C0\u6D4B\u5230\u590D\u6742\u7684 MCP \u914D\u7F6E\uFF0C\u8BF7\u6309 README \u624B\u52A8\u8BBE\u7F6E dsh-palace"),bl=/(?:[\w-]+|"[^"\\]*"|'[^']*')/.source,BT=new RegExp(`^\\s*(\\[\\[?)\\s*(${bl}(?:\\s*\\.\\s*${bl})*)\\s*(\\]\\]?)\\s*(?:#.*)?$`),Dw=e=>new RegExp(`^\\s*(?:${e}|"${e}"|'${e}')\\s*[.=]`);function Zw(e,t){let r=`${e}.${ZT()}.tmp`;try{UT(r,t,{mode:384,flag:"wx"}),FT(r,e)}finally{LT(r,{force:!0})}}function Mw(e,t,r){let n=jw(e,{throwIfNoEntry:!1});if(n&&!n.isFile())throw wl();let o=n?qT(e,"utf8"):"";if(o.includes('"""')||o.includes("'''"))throw wl();let s=o.includes(`\r
|
|
128
132
|
`)?`\r
|
|
129
133
|
`:`
|
|
130
|
-
`,i=[],a=(o.match(/[^\n]*\n|[^\n]+$/g)??[]).filter(l=>{let d=
|
|
131
|
-
`)?s:"")+c.join(s)+s;if(u!==o){if(n?
|
|
134
|
+
`,i=[],a=(o.match(/[^\n]*\n|[^\n]+$/g)??[]).filter(l=>{let d=BT.exec(l.trimEnd());d&&(i=[...d[2].matchAll(new RegExp(bl,"g"))].map(([p])=>p.replace(/^["']|["']$/g,"")));let f=i[0]==="mcp_servers"&&i[1]==="dsh-palace";if(d?d[1].length!==d[3].length||i[0]==="mcp_servers"&&d[1]==="[[":/^\s*\[/.test(l)||i.length===0&&Dw("mcp_servers").test(l)||i.length===1&&i[0]==="mcp_servers"&&Dw("dsh-palace").test(l))throw wl();return!f}).join(""),c=["[mcp_servers.dsh-palace]",`command = ${_l(process.execPath)}`,`args = [${_l(t)}]`];r!==void 0&&c.push("","[mcp_servers.dsh-palace.env]",`DSH_PALACE_DATA_DIR = ${_l(r)}`);let u=a+(a&&!a.endsWith(`
|
|
135
|
+
`)?s:"")+c.join(s)+s;if(u!==o){if(n?Zw(`${e}.bak`,o):MT(VT(e),{recursive:!0}),jw(e,{throwIfNoEntry:!1})?.mtimeMs!==n?.mtimeMs)throw new Error("Codex \u914D\u7F6E\u521A\u88AB\u522B\u5904\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5");Zw(e,u)}}import{once as uO}from"node:events";import{createReadStream as lO}from"node:fs";import{createServer as dO}from"node:http";import{Readable as Hw}from"node:stream";import{pipeline as Kw}from"node:stream/promises";import{execFile as JT,spawn as $l}from"node:child_process";import{createReadStream as GT,existsSync as gr,statSync as WT}from"node:fs";import{homedir as YT}from"node:os";import{basename as XT,extname as QT,join as bo,normalize as eO,sep as xl}from"node:path";import{Readable as tO}from"node:stream";import{fileURLToPath as Lw}from"node:url";import{execFile as HT}from"node:child_process";var KT=`ObjC.import('CoreServices')
|
|
132
136
|
function run(argv) {
|
|
133
137
|
const w = $(argv[0])
|
|
134
138
|
const r = $.DCSCopyTextDefinition($(), w, $.CFRangeMake(0, w.length))
|
|
135
139
|
return r ? ObjC.unwrap(ObjC.castRefToObject(r)) : ''
|
|
136
|
-
}`,sl=/^[A-Za-zÀ-ɏ]+(?:['’-][A-Za-zÀ-ɏ]+)*$/,io=new Map;async function fw(e){if(process.platform!=="darwin")return{supported:!1,definition:null};let t=await dw(e.replace(/’/g,"'")),r=t!==null&&t.length<160?/→\s*([A-Za-z]+(?:-[A-Za-z]+)*)/.exec(t)?.[1]:void 0,n=r!==void 0&&r.toLowerCase()!==e.toLowerCase()?await dw(r):null;return{supported:!0,definition:t,...n!==null?{lemma:{word:r,definition:n}}:{}}}async function dw(e){if(!sl.test(e)||e.length>80)return null;if(io.has(e))return io.get(e);let t=await new Promise((n,o)=>{BI("osascript",["-l","JavaScript","-e",JI,e],{timeout:5e3,maxBuffer:1<<20},(s,i)=>{s?o(new b("\u7CFB\u7EDF\u8BCD\u5178\u6CA1\u6709\u54CD\u5E94")):n(i.trim())})}),r=t===""?null:t;return io.size>2e3&&io.clear(),io.set(e,r),r}var rT="/api/dsh-palace";function nT(e,t){if(t.kind==="book"||t.source!==void 0)throw new b("\u6DFB\u52A0\u4E66\u8BF7\u7528 addBook");return zt(e,{...t,outline:void 0,outlineSource:void 0})}var mw={addBook:wi,addCell:nT,updateCell:fh,moveCell:ph,groupCells:mh,deleteCell:vs,updateItem:$s,setPosition:hh,setOutline:xs,setSectionDone:yh,markUpTo:_h,resetProgress:wh,addCard:Ss,updateCard:xh,deleteCard:Sh,addInspiration:ks,updateInspiration:kh,deleteInspiration:zh};function oe(e,t=200){return new Response(JSON.stringify(e),{status:t,headers:{"content-type":"application/json; charset=utf-8","cache-control":"no-store"}})}function oT(e){return e instanceof b?oe({ok:!1,error:e.message},400):(console.error("[dsh-palace]",e),oe({ok:!1,error:`\u5185\u90E8\u9519\u8BEF\uFF1A${e?.message??String(e)}`},500))}function Fr(e,t){let r=WI(e).size,n=tT.toWeb(GI(e));return new Response(n,{headers:{"content-type":t,"content-length":String(r),"cache-control":"no-store"}})}function hw(e){let t=YI();return e===t||e.startsWith(t+cl)?"~"+e.slice(t.length):e}function Lr(e){let t=process.platform==="darwin"?il("open",[e],{detached:!0,stdio:"ignore"}):process.platform==="win32"?il("cmd",["/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}):il("xdg-open",[e],{detached:!0,stdio:"ignore"});t.on("error",r=>console.error("[dsh-palace] \u6253\u5F00\u5931\u8D25",e,r)),t.unref()}function sT(){return process.platform!=="darwin"?Promise.resolve(void 0):new Promise(e=>{KI("osascript",["-e",'set f to choose file with prompt "\u9009\u62E9 PDF \u6216 EPUB" of type {"com.adobe.pdf", "org.idpf.epub-container"}',"-e","POSIX path of f"],{timeout:10*6e4},(t,r)=>{e(t?null:r.trim())})})}var iT=["jszip.min.js","epub.min.js"];function al(){let e=pw(new URL("../vendor/",import.meta.url));return or(e)?e:pw(new URL("../../vendor/",import.meta.url))}var aT={webp:"image/webp",png:"image/png",svg:"image/svg+xml",ttf:"font/ttf",woff2:"font/woff2"},cT={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};function bi(e,t){St(t);let r=e.getPalace().cells.find(n=>n.id===t);if(r===void 0||r.kind==="group")throw new b("\u683C\u5B50\u4E0D\u5B58\u5728");return e.getItem(t)}function gw(e,t,r=new qr(e)){let n=(o,s,i)=>({path:`${rT}/${s}`,methods:[o],requestBody:"buffered",fetch:async a=>{try{let c=o==="POST"?await a.json().catch(()=>({}))??{}:{};return await i({url:new URL(a.url),body:c,signal:a.signal})}catch(c){return oT(c)}}});return[n("GET","palace",()=>oe({ok:!0,rev:e.rev,palace:e.getPalace(),summaries:e.summaries(),dataDir:hw(e.dir)})),n("GET","chat-workspace",()=>oe({ok:!0,cwd:e.dir})),n("GET","arcs",()=>oe({ok:!0,rev:e.rev,arcs:r.arcs()})),n("POST","cut-arc",({body:o})=>(r.cut({from:o.from,to:o.to}),oe({ok:!0,rev:e.rev}))),n("GET","lookup",async({url:o})=>oe({ok:!0,...await fw(o.searchParams.get("word")??"")})),n("POST","open-dictionary",({body:o})=>{let s=typeof o.word=="string"?o.word:"";if(process.platform!=="darwin"||!sl.test(s))throw new b("\u65E0\u6CD5\u6253\u5F00\u8BCD\u5178");return Lr(`dict://${encodeURIComponent(s)}`),oe({ok:!0})}),n("GET","item",({url:o})=>oe({ok:!0,rev:e.rev,item:bi(e,o.searchParams.get("id"))})),n("GET","rev",()=>oe({ok:!0,rev:e.checkDisk()})),n("POST","op",async({body:o,signal:s})=>{let i=String(o.op),a=Object.hasOwn(mw,i)?mw[i]:void 0;if(a===void 0)return oe({ok:!1,error:`\u672A\u77E5\u64CD\u4F5C ${i}`},400);let c=await a(e,o.args??{},s);return oe({ok:!0,rev:e.rev,result:c??null})}),n("GET","file",({url:o})=>{let s=bi(e,o.searchParams.get("id")).source;if(s===null||s.type==="video")throw new b("\u8FD9\u4E2A\u683C\u5B50\u6CA1\u6709\u539F\u6587\u6587\u4EF6");return or(s.path)?Fr(s.path,s.type==="pdf"?"application/pdf":"application/epub+zip"):oe({ok:!1,error:"\u627E\u4E0D\u5230\u539F\u6587\u6587\u4EF6\uFF0C\u53EF\u80FD\u88AB\u79FB\u52A8\u6216\u5220\u9664\u4E86"},404)}),n("GET","page-text",async({url:o})=>{let s=bi(e,o.searchParams.get("id")).source;if(s?.type!=="pdf")throw new b("\u8FD9\u4E0D\u662F PDF");let i=(o.searchParams.get("pages")??"").split(",").map(Number).filter(Number.isInteger),a=await gi(s.path,i),c=a.filter(u=>u.text.length<yi).map(u=>u.page);return oe({ok:!0,pages:a,scanned:c})}),n("GET","image",({url:o})=>{let s=XI(o.searchParams.get("name")??""),i=ao(e.imagesDir,s),a=cT[QI(s).toLowerCase()];return s===""||a===void 0||!or(i)?new Response("not found",{status:404}):Fr(i,a)}),n("GET","asset",({url:o})=>{let s=eT(o.searchParams.get("f")??"");if(s.startsWith("reader/")){let d=s.slice(7);if(!iT.includes(d))return new Response("not found",{status:404});let f=Fr(ao(al(),d),"text/javascript; charset=utf-8");return f.headers.set("cache-control","public, max-age=86400"),f}let i=/^themes\/[a-z][a-z0-9-]{0,30}\/(?:[a-z]+\/)?[A-Za-z0-9][A-Za-z0-9-]{0,60}\.(webp|png|svg|ttf|woff2)$/.exec(s.split(cl).join("/"));if(i!==null){let d=ao(al(),s);if(!or(d))return new Response("not found",{status:404});let f=Fr(d,aT[i[1]]);return f.headers.set("cache-control","public, max-age=86400"),f}let a=/^fonts\/([a-z0-9][a-z0-9-]{0,60})\.woff2$/.exec(s)?.[1];if(a!==void 0){let d=ao(al(),"fonts",`${a}.woff2`);if(!or(d))return new Response("not found",{status:404});let f=Fr(d,"font/woff2");return f.headers.set("cache-control","public, max-age=31536000, immutable"),f}if(!["cmaps","standard_fonts","wasm","iccs"].some(d=>s.startsWith(d+cl))||s.includes(".."))return new Response("not found",{status:404});let u=ao(el(),s);if(!or(u))return new Response("not found",{status:404});let l=Fr(u,u.endsWith(".wasm")?"application/wasm":"application/octet-stream");return l.headers.set("cache-control","public, max-age=31536000, immutable"),l}),n("POST","pick-file",async()=>oe({ok:!0,path:await sT()})),n("POST","open",({body:o})=>{if(o.target==="welcome")return Lr(Ka),oe({ok:!0});if(o.target==="dataDir")return Lr(e.dir),oe({ok:!0});let s=e.getPalace().cells.find(u=>u.id===o.id)?.href;if(s!==void 0&&/^https?:\/\//.test(s))return Lr(s),oe({ok:!0});let i=bi(e,o.id),a=xt(i,typeof o.sectionId=="string"?o.sectionId:void 0)?.section,c=i.source;if(c===null)throw new b("\u8FD9\u4E2A\u683C\u5B50\u6CA1\u6709\u539F\u6587");if(c.type==="video"){let u=a?.loc;return Lr(u!==void 0&&/^https?:\/\//.test(u)?u:c.url),oe({ok:!0})}if(!or(c.path))throw new b(`\u627E\u4E0D\u5230\u6587\u4EF6\uFF1A${hw(c.path)}`);return Lr(c.path),oe({ok:!0})}),n("POST","active",({body:o})=>{let s=typeof o.sessionId=="string"?o.sessionId:void 0;return s===void 0?oe({ok:!1,error:"\u7F3A\u5C11 sessionId"},400):(typeof o.itemId=="string"?t.set(s,o.itemId):t.delete(s),oe({ok:!0}))})]}var ww="127.0.0.1",fT='<!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Memory Palace</title><div id="app"></div><script src="/palace-web.js" defer></script></html>';async function bw(e,t=4196){let r=new Map(gw(e,new Map).map(a=>[a.path,a])),n=dT(async(a,c)=>{let u=a.headers.host,l=a.socket.localPort,d=`http://${u}`;if(u!==`${ww}:${l}`&&u!==`localhost:${l}`||a.method!=="GET"&&a.headers.origin!==d){c.writeHead(403).end();return}c.setHeader("x-content-type-options","nosniff"),c.setHeader("x-frame-options","DENY"),c.setHeader("cross-origin-resource-policy","same-origin");try{let f=new URL(a.url??"/",d),{pathname:p}=f;if(f.origin!==d){c.writeHead(403).end();return}if(a.method==="GET"&&p==="/"){c.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(fT);return}if(a.method==="GET"&&p==="/palace-web.js"){c.setHeader("content-type","text/javascript; charset=utf-8"),await _w(lT(new URL("./palace-web.js",import.meta.url)),c);return}let m=r.get(p);if(m===void 0){c.writeHead(404).end();return}let h=a.headers.origin,g=a.headers["sec-fetch-site"];if(h!==void 0&&h!==d||g==="cross-site"||g==="same-site"){c.writeHead(403).end();return}if(a.method!=="GET"&&a.method!=="POST"||!m.methods.includes(a.method)){c.writeHead(405,{allow:m.methods.join(", ")}).end();return}let w=new AbortController;c.once("close",()=>w.abort());let v=a.method==="POST"?yw.toWeb(a):void 0,$={method:a.method,headers:a.headers,body:v,duplex:"half",signal:w.signal},O=await m.fetch(new Request(f,$));c.writeHead(O.status,Object.fromEntries(O.headers)),O.body===null?c.end():await _w(yw.from(O.body),c)}catch(f){if(c.destroyed)return;console.error("[dsh-palace:localhost]",f),c.headersSent?c.destroy():c.writeHead(500).end("\u5BAB\u6BBF\u7F51\u9875\u8BF7\u6C42\u5931\u8D25")}}),o=a=>(n.listen(a,ww),uT(n,"listening"));try{await o(t)}catch(a){if(a.code!=="EADDRINUSE")throw a;await o(0)}n.unref();let{address:s,port:i}=n.address();return{url:`http://${s}:${i}/`,close:()=>{n.close(),n.closeAllConnections()}}}async function yT(){let e=process.env.DSH_PALACE_DATA_DIR,t=e??vi(vw(),"Documents","dsh-palace-data");if(!mT(t))throw new Error("DSH_PALACE_DATA_DIR \u5FC5\u987B\u662F\u6570\u636E\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84");let r=process.argv.includes("--install"),n=gT(import.meta.url);if(r&&n.split(hT).includes("_npx"))throw new Error("npx \u7F13\u5B58\u91CC\u7684\u8DEF\u5F84\u53EF\u80FD\u5931\u6548\u3002\u8BF7\u8FD0\u884C npm install -g dsh-palace && dsh-palace-mcp --install");let o=r&&e===void 0&&!pT(vi(t,"palace.json")),s=new ws(t,{create:o});if(r){o&&await dh(s);let c=vi(process.env.CODEX_HOME||vi(vw(),".codex"),"config.toml");lw(c,n,e),console.error("Memory Palace \u5DF2\u5199\u5165 Codex \u914D\u7F6E\uFF0C\u8BF7\u91CD\u542F\u684C\u9762\u7AEF\u3002");return}let i=await bw(s),a=iw(s,i.url);a.onclose=i.close,process.stdin.once("end",()=>{a.close()}),await a.connect(new ds).catch(c=>{throw i.close(),c})}yT().catch(e=>{console.error(`\u65E0\u6CD5\u542F\u52A8 Memory Palace MCP\uFF1A${e.message}\u3002\u8BF7\u786E\u8BA4 Harness \u6570\u636E\u76EE\u5F55\u548C DSH_PALACE_DATA_DIR \u8BBE\u7F6E\u3002`),process.exitCode=1});
|
|
140
|
+
}`,vl=/^[A-Za-zÀ-ɏ]+(?:['’-][A-Za-zÀ-ɏ]+)*$/,wo=new Map;async function Fw(e){if(process.platform!=="darwin")return{supported:!1,definition:null};let t=await qw(e.replace(/’/g,"'")),r=t!==null&&t.length<160?/→\s*([A-Za-z]+(?:-[A-Za-z]+)*)/.exec(t)?.[1]:void 0,n=r!==void 0&&r.toLowerCase()!==e.toLowerCase()?await qw(r):null;return{supported:!0,definition:t,...n!==null?{lemma:{word:r,definition:n}}:{}}}async function qw(e){if(!vl.test(e)||e.length>80)return null;if(wo.has(e))return wo.get(e);let t=await new Promise((n,o)=>{HT("osascript",["-l","JavaScript","-e",KT,e],{timeout:5e3,maxBuffer:1<<20},(s,i)=>{s?o(new w("\u7CFB\u7EDF\u8BCD\u5178\u6CA1\u6709\u54CD\u5E94")):n(i.trim())})}),r=t===""?null:t;return wo.size>2e3&&wo.clear(),wo.set(e,r),r}var rO="/api/dsh-palace";function nO(e,t){if(t.kind==="book"||t.source!==void 0)throw new w("\u6DFB\u52A0\u4E66\u8BF7\u7528 addBook");return qt(e,{...t,outline:void 0,outlineSource:void 0})}var Uw={addBook:Ri,addCell:nO,updateCell:Ih,moveCell:Eh,groupCells:Th,deleteCell:Os,updateItem:Rs,setPosition:Oh,setOutline:Cs,setSectionDone:Rh,markUpTo:Ah,resetProgress:Ch,addCard:Ns,updateCard:Zh,deleteCard:Mh,addInspiration:js,updateInspiration:qh,deleteInspiration:Fh};function fe(e,t=200){return new Response(JSON.stringify(e),{status:t,headers:{"content-type":"application/json; charset=utf-8","cache-control":"no-store"}})}function oO(e){return e instanceof w?fe({ok:!1,error:e.message},400):(console.error("[dsh-palace]",e),fe({ok:!1,error:`\u5185\u90E8\u9519\u8BEF\uFF1A${e?.message??String(e)}`},500))}function Yr(e,t){let r=WT(e).size,n=tO.toWeb(GT(e));return new Response(n,{headers:{"content-type":t,"content-length":String(r),"cache-control":"no-store"}})}function Vw(e){let t=YT();return e===t||e.startsWith(t+xl)?"~"+e.slice(t.length):e}function Xr(e){let t=process.platform==="darwin"?$l("open",[e],{detached:!0,stdio:"ignore"}):process.platform==="win32"?$l("cmd",["/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}):$l("xdg-open",[e],{detached:!0,stdio:"ignore"});t.on("error",r=>console.error("[dsh-palace] \u6253\u5F00\u5931\u8D25",e,r)),t.unref()}function sO(){return process.platform!=="darwin"?Promise.resolve(void 0):new Promise(e=>{JT("osascript",["-e",'set f to choose file with prompt "\u9009\u62E9 PDF \u6216 EPUB" of type {"com.adobe.pdf", "org.idpf.epub-container"}',"-e","POSIX path of f"],{timeout:10*6e4},(t,r)=>{e(t?null:r.trim())})})}var iO=["jszip.min.js","epub.min.js"];function kl(){let e=Lw(new URL("../vendor/",import.meta.url));return gr(e)?e:Lw(new URL("../../vendor/",import.meta.url))}var aO={webp:"image/webp",png:"image/png",svg:"image/svg+xml",ttf:"font/ttf",woff2:"font/woff2"},cO={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};function Ai(e,t){Zt(t);let r=e.getPalace().cells.find(n=>n.id===t);if(r===void 0||r.kind==="group")throw new w("\u683C\u5B50\u4E0D\u5B58\u5728");return e.getItem(t)}function Bw(e,t,r=new Wr(e)){let n=(o,s,i)=>({path:`${rO}/${s}`,methods:[o],requestBody:"buffered",fetch:async a=>{try{let c=o==="POST"?await a.json().catch(()=>({}))??{}:{};return await i({url:new URL(a.url),body:c,signal:a.signal})}catch(c){return oO(c)}}});return[n("POST","weread-key",({body:o})=>fe({ok:!0,saved:Aw(o.key,void 0,e.dir)})),n("GET","palace",()=>fe({ok:!0,rev:e.rev,palace:e.getPalace(),summaries:e.summaries(),dataDir:Vw(e.dir)})),n("GET","chat-workspace",()=>fe({ok:!0,cwd:e.dir})),n("GET","arcs",()=>fe({ok:!0,rev:e.rev,arcs:r.arcs()})),n("POST","cut-arc",({body:o})=>(r.cut({from:o.from,to:o.to}),fe({ok:!0,rev:e.rev}))),n("GET","lookup",async({url:o})=>fe({ok:!0,...await Fw(o.searchParams.get("word")??"")})),n("POST","open-dictionary",({body:o})=>{let s=typeof o.word=="string"?o.word:"";if(process.platform!=="darwin"||!vl.test(s))throw new w("\u65E0\u6CD5\u6253\u5F00\u8BCD\u5178");return Xr(`dict://${encodeURIComponent(s)}`),fe({ok:!0})}),n("GET","item",({url:o})=>fe({ok:!0,rev:e.rev,item:Ai(e,o.searchParams.get("id"))})),n("GET","rev",()=>fe({ok:!0,rev:e.checkDisk()})),n("POST","op",async({body:o,signal:s})=>{let i=String(o.op),a=Object.hasOwn(Uw,i)?Uw[i]:void 0;if(a===void 0)return fe({ok:!1,error:`\u672A\u77E5\u64CD\u4F5C ${i}`},400);let c=await a(e,o.args??{},s);return fe({ok:!0,rev:e.rev,result:c??null})}),n("GET","file",({url:o})=>{let s=Ai(e,o.searchParams.get("id")).source;if(s===null||s.type==="video")throw new w("\u8FD9\u4E2A\u683C\u5B50\u6CA1\u6709\u539F\u6587\u6587\u4EF6");return gr(s.path)?Yr(s.path,s.type==="pdf"?"application/pdf":"application/epub+zip"):fe({ok:!1,error:"\u627E\u4E0D\u5230\u539F\u6587\u6587\u4EF6\uFF0C\u53EF\u80FD\u88AB\u79FB\u52A8\u6216\u5220\u9664\u4E86"},404)}),n("GET","page-text",async({url:o})=>{let s=Ai(e,o.searchParams.get("id")).source;if(s?.type!=="pdf")throw new w("\u8FD9\u4E0D\u662F PDF");let i=(o.searchParams.get("pages")??"").split(",").map(Number).filter(Number.isInteger),a=await Ei(s.path,i),c=a.filter(u=>u.text.length<Ti).map(u=>u.page);return fe({ok:!0,pages:a,scanned:c})}),n("GET","image",({url:o})=>{let s=XT(o.searchParams.get("name")??""),i=bo(e.imagesDir,s),a=cO[QT(s).toLowerCase()];return s===""||a===void 0||!gr(i)?new Response("not found",{status:404}):Yr(i,a)}),n("GET","asset",({url:o})=>{let s=eO(o.searchParams.get("f")??"");if(s.startsWith("reader/")){let d=s.slice(7);if(!iO.includes(d))return new Response("not found",{status:404});let f=Yr(bo(kl(),d),"text/javascript; charset=utf-8");return f.headers.set("cache-control","public, max-age=86400"),f}let i=/^themes\/[a-z][a-z0-9-]{0,30}\/(?:[a-z]+\/)?[A-Za-z0-9][A-Za-z0-9-]{0,60}\.(webp|png|svg|ttf|woff2)$/.exec(s.split(xl).join("/"));if(i!==null){let d=bo(kl(),s);if(!gr(d))return new Response("not found",{status:404});let f=Yr(d,aO[i[1]]);return f.headers.set("cache-control","public, max-age=86400"),f}let a=/^fonts\/([a-z0-9][a-z0-9-]{0,60})\.woff2$/.exec(s)?.[1];if(a!==void 0){let d=bo(kl(),"fonts",`${a}.woff2`);if(!gr(d))return new Response("not found",{status:404});let f=Yr(d,"font/woff2");return f.headers.set("cache-control","public, max-age=31536000, immutable"),f}if(!["cmaps","standard_fonts","wasm","iccs"].some(d=>s.startsWith(d+xl))||s.includes(".."))return new Response("not found",{status:404});let u=bo(hl(),s);if(!gr(u))return new Response("not found",{status:404});let l=Yr(u,u.endsWith(".wasm")?"application/wasm":"application/octet-stream");return l.headers.set("cache-control","public, max-age=31536000, immutable"),l}),n("POST","pick-file",async()=>fe({ok:!0,path:await sO()})),n("POST","open",({body:o})=>{if(o.target==="welcome")return Xr(ac),fe({ok:!0});if(o.target==="dataDir")return Xr(e.dir),fe({ok:!0});let s=e.getPalace().cells.find(u=>u.id===o.id)?.href;if(s!==void 0&&/^https?:\/\//.test(s))return Xr(s),fe({ok:!0});let i=Ai(e,o.id),a=Dt(i,typeof o.sectionId=="string"?o.sectionId:void 0)?.section,c=i.source;if(c===null)throw new w("\u8FD9\u4E2A\u683C\u5B50\u6CA1\u6709\u539F\u6587");if(c.type==="video"){let u=a?.loc;return Xr(u!==void 0&&/^https?:\/\//.test(u)?u:c.url),fe({ok:!0})}if(!gr(c.path))throw new w(`\u627E\u4E0D\u5230\u6587\u4EF6\uFF1A${Vw(c.path)}`);return Xr(c.path),fe({ok:!0})}),n("POST","active",({body:o})=>{let s=typeof o.sessionId=="string"?o.sessionId:void 0;return s===void 0?fe({ok:!1,error:"\u7F3A\u5C11 sessionId"},400):(typeof o.itemId=="string"?t.set(s,o.itemId):t.delete(s),fe({ok:!0}))})]}var Jw="127.0.0.1",fO='<!doctype html><html lang="zh-CN"><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>Memory Palace</title><div id="app"></div><script src="/palace-web.js" defer></script></html>';async function Gw(e,t=4196){let r=new Map(Bw(e,new Map).map(a=>[a.path,a])),n=dO(async(a,c)=>{let u=a.headers.host,l=a.socket.localPort,d=`http://${u}`;if(u!==`${Jw}:${l}`&&u!==`localhost:${l}`||a.method!=="GET"&&a.headers.origin!==d){c.writeHead(403).end();return}c.setHeader("x-content-type-options","nosniff"),c.setHeader("x-frame-options","DENY"),c.setHeader("cross-origin-resource-policy","same-origin");try{let f=new URL(a.url??"/",d),{pathname:p}=f;if(f.origin!==d){c.writeHead(403).end();return}if(a.method==="GET"&&p==="/"){c.writeHead(200,{"content-type":"text/html; charset=utf-8"}).end(fO);return}if(a.method==="GET"&&p==="/palace-web.js"){c.setHeader("content-type","text/javascript; charset=utf-8"),await Kw(lO(new URL("./palace-web.js",import.meta.url)),c);return}let m=r.get(p);if(m===void 0){c.writeHead(404).end();return}let h=a.headers.origin,g=a.headers["sec-fetch-site"];if(h!==void 0&&h!==d||g==="cross-site"||g==="same-site"){c.writeHead(403).end();return}if(a.method!=="GET"&&a.method!=="POST"||!m.methods.includes(a.method)){c.writeHead(405,{allow:m.methods.join(", ")}).end();return}let y=new AbortController;c.once("close",()=>y.abort());let v=a.method==="POST"?Hw.toWeb(a):void 0,$={method:a.method,headers:a.headers,body:v,duplex:"half",signal:y.signal},I=await m.fetch(new Request(f,$));c.writeHead(I.status,Object.fromEntries(I.headers)),I.body===null?c.end():await Kw(Hw.from(I.body),c)}catch(f){if(c.destroyed)return;console.error("[dsh-palace:localhost]",f),c.headersSent?c.destroy():c.writeHead(500).end("\u5BAB\u6BBF\u7F51\u9875\u8BF7\u6C42\u5931\u8D25")}}),o=a=>(n.listen(a,Jw),uO(n,"listening"));try{await o(t)}catch(a){if(a.code!=="EADDRINUSE")throw a;await o(0)}n.unref();let{address:s,port:i}=n.address();return{url:`http://${s}:${i}/`,close:()=>{n.close(),n.closeAllConnections()}}}async function yO(){let e=process.env.DSH_PALACE_DATA_DIR,t=e??Ci(Ww(),"Documents","dsh-palace-data");if(!mO(t))throw new Error("DSH_PALACE_DATA_DIR \u5FC5\u987B\u662F\u6570\u636E\u76EE\u5F55\u7684\u7EDD\u5BF9\u8DEF\u5F84");let r=process.argv.includes("--install"),n=gO(import.meta.url);if(r&&n.split(hO).includes("_npx"))throw new Error("npx \u7F13\u5B58\u91CC\u7684\u8DEF\u5F84\u53EF\u80FD\u5931\u6548\u3002\u8BF7\u8FD0\u884C npm install -g dsh-palace && dsh-palace-mcp --install");let o=r&&e===void 0&&!pO(Ci(t,"palace.json")),s=new Es(t,{create:o});if(r){o&&await Ph(s);let c=Ci(process.env.CODEX_HOME||Ci(Ww(),".codex"),"config.toml");Mw(c,n,e),console.error("Memory Palace \u5DF2\u5199\u5165 Codex \u914D\u7F6E\uFF0C\u8BF7\u91CD\u542F\u684C\u9762\u7AEF\u3002");return}let i=await Gw(s),a=Nw(s,i.url);a.onclose=i.close,process.stdin.once("end",()=>{a.close()}),await a.connect(new vs).catch(c=>{throw i.close(),c})}yO().catch(e=>{console.error(`\u65E0\u6CD5\u542F\u52A8 Memory Palace MCP\uFF1A${e.message}\u3002\u8BF7\u786E\u8BA4 Harness \u6570\u636E\u76EE\u5F55\u548C DSH_PALACE_DATA_DIR \u8BBE\u7F6E\u3002`),process.exitCode=1});
|