dsh-palace 1.3.1 → 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/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 Kw=Object.create;var Ei=Object.defineProperty;var Jw=Object.getOwnPropertyDescriptor;var Gw=Object.getOwnPropertyNames;var Ww=Object.getPrototypeOf,Yw=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},wl=(e,t)=>{for(var r in t)Ei(e,r,{get:t[r],enumerable:!0})},Xw=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Gw(t))!Yw.call(e,o)&&o!==r&&Ei(e,o,{get:()=>t[o],enumerable:!(n=Jw(t,o))||n.enumerable});return e};var bl=(e,t,r)=>(r=e!=null?Kw(Ww(e)):{},Xw(t||!e||!e.__esModule?Ei(r,"default",{value:e,enumerable:!0}):r,e));var An=S(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:!0});G.regexpCode=G.getEsmExportName=G.getProperty=G.safeStringify=G.stringify=G.strConcat=G.addCodeArg=G.str=G._=G.nil=G._Code=G.Name=G.IDENTIFIER=G._CodeOrName=void 0;var On=class{};G._CodeOrName=On;G.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Qt=class extends On{constructor(t){if(super(),!G.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}}};G.Name=Qt;var Ye=class extends On{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 Qt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};G._Code=Ye;G.nil=new Ye("");function Zh(e,...t){let r=[e[0]],n=0;for(;n<t.length;)sc(r,t[n]),r.push(e[++n]);return new Ye(r)}G._=Zh;var oc=new Ye("+");function Mh(e,...t){let r=[Rn(e[0])],n=0;for(;n<t.length;)r.push(oc),sc(r,t[n]),r.push(oc,Rn(e[++n]));return bk(r),new Ye(r)}G.str=Mh;function sc(e,t){t instanceof Ye?e.push(...t._items):t instanceof Qt?e.push(t):e.push(kk(t))}G.addCodeArg=sc;function bk(e){let t=1;for(;t<e.length-1;){if(e[t]===oc){let r=vk(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function vk(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof Qt||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 Qt))return`"${e}${t.slice(1)}`}function $k(e,t){return t.emptyStr()?e:e.emptyStr()?t:Mh`${e}${t}`}G.strConcat=$k;function kk(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Rn(Array.isArray(e)?e.join(","):e)}function xk(e){return new Ye(Rn(e))}G.stringify=xk;function Rn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}G.safeStringify=Rn;function Sk(e){return typeof e=="string"&&G.IDENTIFIER.test(e)?new Ye(`.${e}`):Zh`[${e}]`}G.getProperty=Sk;function zk(e){if(typeof e=="string"&&G.IDENTIFIER.test(e))return new Ye(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}G.getEsmExportName=zk;function Pk(e){return new Ye(e.toString())}G.regexpCode=Pk});var cc=S(Ze=>{"use strict";Object.defineProperty(Ze,"__esModule",{value:!0});Ze.ValueScope=Ze.ValueScopeName=Ze.Scope=Ze.varKinds=Ze.UsedValueState=void 0;var De=An(),ic=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},js;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(js||(Ze.UsedValueState=js={}));Ze.varKinds={const:new De.Name("const"),let:new De.Name("let"),var:new De.Name("var")};var Ds=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof De.Name?t:this.name(t)}name(t){return new De.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}}};Ze.Scope=Ds;var Zs=class extends De.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,De._)`.${new De.Name(r)}[${n}]`}};Ze.ValueScopeName=Zs;var Ik=(0,De._)`\n`,ac=class extends Ds{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?Ik:De.nil}}get(){return this._scope}name(t){return new Zs(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,De._)`${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=De.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,js.Started);let l=r(u);if(l){let d=this.opts.es5?Ze.varKinds.var:Ze.varKinds.const;s=(0,De._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,De._)`${s}${l}${this.opts._n}`;else throw new ic(u);c.set(u,js.Completed)})}return s}};Ze.ValueScope=ac});var q=S(L=>{"use strict";Object.defineProperty(L,"__esModule",{value:!0});L.or=L.and=L.not=L.CodeGen=L.operators=L.varKinds=L.ValueScopeName=L.ValueScope=L.Scope=L.Name=L.regexpCode=L.stringify=L.getProperty=L.nil=L.strConcat=L.str=L._=void 0;var B=An(),st=cc(),Mt=An();Object.defineProperty(L,"_",{enumerable:!0,get:function(){return Mt._}});Object.defineProperty(L,"str",{enumerable:!0,get:function(){return Mt.str}});Object.defineProperty(L,"strConcat",{enumerable:!0,get:function(){return Mt.strConcat}});Object.defineProperty(L,"nil",{enumerable:!0,get:function(){return Mt.nil}});Object.defineProperty(L,"getProperty",{enumerable:!0,get:function(){return Mt.getProperty}});Object.defineProperty(L,"stringify",{enumerable:!0,get:function(){return Mt.stringify}});Object.defineProperty(L,"regexpCode",{enumerable:!0,get:function(){return Mt.regexpCode}});Object.defineProperty(L,"Name",{enumerable:!0,get:function(){return Mt.Name}});var Ls=cc();Object.defineProperty(L,"Scope",{enumerable:!0,get:function(){return Ls.Scope}});Object.defineProperty(L,"ValueScope",{enumerable:!0,get:function(){return Ls.ValueScope}});Object.defineProperty(L,"ValueScopeName",{enumerable:!0,get:function(){return Ls.ValueScopeName}});Object.defineProperty(L,"varKinds",{enumerable:!0,get:function(){return Ls.varKinds}});L.operators={GT:new B._Code(">"),GTE:new B._Code(">="),LT:new B._Code("<"),LTE:new B._Code("<="),EQ:new B._Code("==="),NEQ:new B._Code("!=="),NOT:new B._Code("!"),OR:new B._Code("||"),AND:new B._Code("&&"),ADD:new B._Code("+")};var $t=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},uc=class extends $t{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?st.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=Ir(this.rhs,t,r)),this}get names(){return this.rhs instanceof B._CodeOrName?this.rhs.names:{}}},Ms=class extends $t{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 B.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=Ir(this.rhs,t,r),this}get names(){let t=this.lhs instanceof B.Name?{}:{...this.lhs.names};return Fs(t,this.rhs)}},lc=class extends Ms{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},dc=class extends $t{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},fc=class extends $t{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},pc=class extends $t{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},mc=class extends $t{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=Ir(this.code,t,r),this}get names(){return this.code instanceof B._CodeOrName?this.code.names:{}}},Cn=class extends $t{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)||(Ek(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>rr(t,r.names),{})}},kt=class extends Cn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},hc=class extends Cn{},Pr=class extends kt{};Pr.kind="else";var er=class e extends kt{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 Pr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(qh(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=Ir(this.condition,t,r),this}get names(){let t=super.names;return Fs(t,this.condition),this.else&&rr(t,this.else.names),t}};er.kind="if";var tr=class extends kt{};tr.kind="for";var gc=class extends tr{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=Ir(this.iteration,t,r),this}get names(){return rr(super.names,this.iteration.names)}},yc=class extends tr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?st.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=Fs(super.names,this.from);return Fs(t,this.to)}},qs=class extends tr{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=Ir(this.iterable,t,r),this}get names(){return rr(super.names,this.iterable.names)}},Nn=class extends kt{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)}};Nn.kind="func";var jn=class extends Cn{render(t){return"return "+super.render(t)}};jn.kind="return";var _c=class extends kt{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&&rr(t,this.catch.names),this.finally&&rr(t,this.finally.names),t}},Dn=class extends kt{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Dn.kind="catch";var Zn=class extends kt{render(t){return"finally"+super.render(t)}};Zn.kind="finally";var wc=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
4
- `:""},this._extScope=t,this._scope=new st.Scope({parent:t}),this._nodes=[new hc]}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 uc(t,s,n)),s}const(t,r,n){return this._def(st.varKinds.const,t,r,n)}let(t,r,n){return this._def(st.varKinds.let,t,r,n)}var(t,r,n){return this._def(st.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Ms(t,r,n))}add(t,r){return this._leafNode(new lc(t,L.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==B.nil&&this._leafNode(new mc(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,B.addCodeArg)(r,o));return r.push("}"),new B._Code(r)}if(t,r,n){if(this._blockNode(new er(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 er(t))}else(){return this._elseNode(new Pr)}endIf(){return this._endBlockNode(er,Pr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new gc(t),r)}forRange(t,r,n,o,s=this.opts.es5?st.varKinds.var:st.varKinds.let){let i=this._scope.toName(t);return this._for(new yc(s,i,r,n),()=>o(i))}forOf(t,r,n,o=st.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof B.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,B._)`${i}.length`,a=>{this.var(s,(0,B._)`${i}[${a}]`),n(s)})}return this._for(new qs("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?st.varKinds.var:st.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,B._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new qs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(tr)}label(t){return this._leafNode(new dc(t))}break(t){return this._leafNode(new fc(t))}return(t){let r=new jn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(jn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new _c;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Dn(s),r(s)}return n&&(this._currNode=o.finally=new Zn,this.code(n)),this._endBlockNode(Dn,Zn)}throw(t){return this._leafNode(new pc(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=B.nil,n,o){return this._blockNode(new Nn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Nn)}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 er))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}};L.CodeGen=wc;function rr(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Fs(e,t){return t instanceof B._CodeOrName?rr(e,t.names):e}function Ir(e,t,r){if(e instanceof B.Name)return n(e);if(!o(e))return e;return new B._Code(e._items.reduce((s,i)=>(i instanceof B.Name&&(i=n(i)),i instanceof B._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 B._Code&&s._items.some(i=>i instanceof B.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function Ek(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function qh(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,B._)`!${bc(e)}`}L.not=qh;var Tk=Fh(L.operators.AND);function Ok(...e){return e.reduce(Tk)}L.and=Ok;var Rk=Fh(L.operators.OR);function Ak(...e){return e.reduce(Rk)}L.or=Ak;function Fh(e){return(t,r)=>t===B.nil?r:r===B.nil?t:(0,B._)`${bc(t)} ${e} ${bc(r)}`}function bc(e){return e instanceof B.Name?e:(0,B._)`(${e})`}});var H=S(U=>{"use strict";Object.defineProperty(U,"__esModule",{value:!0});U.checkStrictMode=U.getErrorPath=U.Type=U.useFunc=U.setEvaluated=U.evaluatedPropsToName=U.mergeEvaluated=U.eachItem=U.unescapeJsonPointer=U.escapeJsonPointer=U.escapeFragment=U.unescapeFragment=U.schemaRefOrVal=U.schemaHasRulesButRef=U.schemaHasRules=U.checkUnknownRules=U.alwaysValidSchema=U.toHash=void 0;var X=q(),Ck=An();function Nk(e){let t={};for(let r of e)t[r]=!0;return t}U.toHash=Nk;function jk(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(Vh(e,t),!Bh(t,e.self.RULES.all))}U.alwaysValidSchema=jk;function Vh(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]||Jh(e,`unknown keyword: "${s}"`)}U.checkUnknownRules=Vh;function Bh(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}U.schemaHasRules=Bh;function Dk(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}U.schemaHasRulesButRef=Dk;function Zk({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,X._)`${r}`}return(0,X._)`${e}${t}${(0,X.getProperty)(n)}`}U.schemaRefOrVal=Zk;function Mk(e){return Hh(decodeURIComponent(e))}U.unescapeFragment=Mk;function qk(e){return encodeURIComponent($c(e))}U.escapeFragment=qk;function $c(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}U.escapeJsonPointer=$c;function Hh(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}U.unescapeJsonPointer=Hh;function Fk(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}U.eachItem=Fk;function Lh({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof X.Name?(s instanceof X.Name?e(o,s,i):t(o,s,i),i):s instanceof X.Name?(t(o,i,s),s):r(s,i);return a===X.Name&&!(c instanceof X.Name)?n(o,c):c}}U.mergeEvaluated={props:Lh({mergeNames:(e,t,r)=>e.if((0,X._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,X._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,X._)`${r} || {}`).code((0,X._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,X._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,X._)`${r} || {}`),kc(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:Kh}),items:Lh({mergeNames:(e,t,r)=>e.if((0,X._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,X._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,X._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,X._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Kh(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,X._)`{}`);return t!==void 0&&kc(e,r,t),r}U.evaluatedPropsToName=Kh;function kc(e,t,r){Object.keys(r).forEach(n=>e.assign((0,X._)`${t}${(0,X.getProperty)(n)}`,!0))}U.setEvaluated=kc;var Uh={};function Lk(e,t){return e.scopeValue("func",{ref:t,code:Uh[t.code]||(Uh[t.code]=new Ck._Code(t.code))})}U.useFunc=Lk;var vc;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(vc||(U.Type=vc={}));function Uk(e,t,r){if(e instanceof X.Name){let n=t===vc.Num;return r?n?(0,X._)`"[" + ${e} + "]"`:(0,X._)`"['" + ${e} + "']"`:n?(0,X._)`"/" + ${e}`:(0,X._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,X.getProperty)(e).toString():"/"+$c(e)}U.getErrorPath=Uk;function Jh(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}U.checkStrictMode=Jh});var xt=S(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var ke=q(),Vk={data:new ke.Name("data"),valCxt:new ke.Name("valCxt"),instancePath:new ke.Name("instancePath"),parentData:new ke.Name("parentData"),parentDataProperty:new ke.Name("parentDataProperty"),rootData:new ke.Name("rootData"),dynamicAnchors:new ke.Name("dynamicAnchors"),vErrors:new ke.Name("vErrors"),errors:new ke.Name("errors"),this:new ke.Name("this"),self:new ke.Name("self"),scope:new ke.Name("scope"),json:new ke.Name("json"),jsonPos:new ke.Name("jsonPos"),jsonLen:new ke.Name("jsonLen"),jsonPart:new ke.Name("jsonPart")};xc.default=Vk});var Mn=S(xe=>{"use strict";Object.defineProperty(xe,"__esModule",{value:!0});xe.extendErrors=xe.resetErrorsCount=xe.reportExtraError=xe.reportError=xe.keyword$DataError=xe.keywordError=void 0;var K=q(),Us=H(),Re=xt();xe.keywordError={message:({keyword:e})=>(0,K.str)`must pass "${e}" keyword validation`};xe.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,K.str)`"${e}" keyword must be ${t} ($data)`:(0,K.str)`"${e}" keyword is invalid ($data)`};function Bk(e,t=xe.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Yh(e,t,r);n??(i||a)?Gh(s,c):Wh(o,(0,K._)`[${c}]`)}xe.reportError=Bk;function Hk(e,t=xe.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Yh(e,t,r);Gh(o,a),s||i||Wh(n,Re.default.vErrors)}xe.reportExtraError=Hk;function Kk(e,t){e.assign(Re.default.errors,t),e.if((0,K._)`${Re.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,K._)`${Re.default.vErrors}.length`,t),()=>e.assign(Re.default.vErrors,null)))}xe.resetErrorsCount=Kk;function Jk({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,Re.default.errors,a=>{e.const(i,(0,K._)`${Re.default.vErrors}[${a}]`),e.if((0,K._)`${i}.instancePath === undefined`,()=>e.assign((0,K._)`${i}.instancePath`,(0,K.strConcat)(Re.default.instancePath,s.errorPath))),e.assign((0,K._)`${i}.schemaPath`,(0,K.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,K._)`${i}.schema`,r),e.assign((0,K._)`${i}.data`,n))})}xe.extendErrors=Jk;function Gh(e,t){let r=e.const("err",t);e.if((0,K._)`${Re.default.vErrors} === null`,()=>e.assign(Re.default.vErrors,(0,K._)`[${r}]`),(0,K._)`${Re.default.vErrors}.push(${r})`),e.code((0,K._)`${Re.default.errors}++`)}function Wh(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,K._)`new ${e.ValidationError}(${t})`):(r.assign((0,K._)`${n}.errors`,t),r.return(!1))}var nr={keyword:new K.Name("keyword"),schemaPath:new K.Name("schemaPath"),params:new K.Name("params"),propertyName:new K.Name("propertyName"),message:new K.Name("message"),schema:new K.Name("schema"),parentSchema:new K.Name("parentSchema")};function Yh(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,K._)`{}`:Gk(e,t,r)}function Gk(e,t,r={}){let{gen:n,it:o}=e,s=[Wk(o,r),Yk(e,r)];return Xk(e,t,s),n.object(...s)}function Wk({errorPath:e},{instancePath:t}){let r=t?(0,K.str)`${e}${(0,Us.getErrorPath)(t,Us.Type.Str)}`:e;return[Re.default.instancePath,(0,K.strConcat)(Re.default.instancePath,r)]}function Yk({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,K.str)`${t}/${e}`;return r&&(o=(0,K.str)`${o}${(0,Us.getErrorPath)(r,Us.Type.Str)}`),[nr.schemaPath,o]}function Xk(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([nr.keyword,o],[nr.params,typeof t=="function"?t(e):t||(0,K._)`{}`]),c.messages&&n.push([nr.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([nr.schema,i],[nr.parentSchema,(0,K._)`${l}${d}`],[Re.default.data,s]),u&&n.push([nr.propertyName,u])}});var Qh=S(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.boolOrEmptySchema=Er.topBoolOrEmptySchema=void 0;var Qk=Mn(),ex=q(),tx=xt(),rx={message:"boolean schema is false"};function nx(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Xh(e,!1):typeof r=="object"&&r.$async===!0?t.return(tx.default.data):(t.assign((0,ex._)`${n}.errors`,null),t.return(!0))}Er.topBoolOrEmptySchema=nx;function ox(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Xh(e)):r.var(t,!0)}Er.boolOrEmptySchema=ox;function Xh(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,Qk.reportError)(o,rx,void 0,t)}});var Sc=S(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.getRules=Tr.isJSONType=void 0;var sx=["string","number","integer","boolean","null","object","array"],ix=new Set(sx);function ax(e){return typeof e=="string"&&ix.has(e)}Tr.isJSONType=ax;function cx(){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:{}}}Tr.getRules=cx});var zc=S(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});qt.shouldUseRule=qt.shouldUseGroup=qt.schemaHasRulesForType=void 0;function ux({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&eg(e,n)}qt.schemaHasRulesForType=ux;function eg(e,t){return t.rules.some(r=>tg(e,r))}qt.shouldUseGroup=eg;function tg(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))}qt.shouldUseRule=tg});var qn=S(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.reportTypeError=Se.checkDataTypes=Se.checkDataType=Se.coerceAndCheckDataType=Se.getJSONTypes=Se.getSchemaTypes=Se.DataType=void 0;var lx=Sc(),dx=zc(),fx=Mn(),Z=q(),rg=H(),Or;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Or||(Se.DataType=Or={}));function px(e){let t=ng(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}Se.getSchemaTypes=px;function ng(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(lx.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}Se.getJSONTypes=ng;function mx(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,dx.schemaHasRulesForType)(e,t[0]));if(i){let a=Ic(t,n,o.strictNumbers,Or.Wrong);r.if(a,()=>{s.length?gx(e,t,s):Ec(e)})}return i}Se.coerceAndCheckDataType=mx;var og=new Set(["string","number","integer","boolean","null"]);function hx(e,t){return t?e.filter(r=>og.has(r)||t==="array"&&r==="array"):[]}function gx(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(Ic(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,Z._)`${a} !== undefined`);for(let u of r)(og.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Ec(e),n.endIf(),n.if((0,Z._)`${a} !== undefined`,()=>{n.assign(o,a),yx(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
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
5
  || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,Z._)`+${o}`);return;case"integer":n.elseIf((0,Z._)`${i} === "boolean" || ${o} === null
6
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 yx({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,Z._)`${t} !== undefined`,()=>e.assign((0,Z._)`${t}[${r}]`,n))}function Pc(e,t,r,n=Or.Correct){let o=n===Or.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===Or.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)}}Se.checkDataType=Pc;function Ic(e,t,r,n){if(e.length===1)return Pc(e[0],t,r,n);let o,s=(0,rg.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,Pc(i,t,r,n));return o}Se.checkDataTypes=Ic;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 Ec(e){let t=wx(e);(0,fx.reportError)(t,_x)}Se.reportTypeError=Ec;function wx(e){let{gen:t,data:r,schema:n}=e,o=(0,rg.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var ig=S(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.assignDefaults=void 0;var Rr=q(),bx=H();function vx(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)sg(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>sg(e,s,o.default))}Vs.assignDefaults=vx;function sg(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Rr._)`${s}${(0,Rr.getProperty)(t)}`;if(o){(0,bx.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Rr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Rr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Rr._)`${a} = ${(0,Rr.stringify)(r)}`)}});var Xe=S(Y=>{"use strict";Object.defineProperty(Y,"__esModule",{value:!0});Y.validateUnion=Y.validateArray=Y.usePattern=Y.callValidateCode=Y.schemaProperties=Y.allSchemaProperties=Y.noPropertyInData=Y.propertyInData=Y.isOwnProperty=Y.hasPropFunc=Y.reportMissingProp=Y.checkMissingProp=Y.checkReportMissingProp=void 0;var ne=q(),Tc=H(),Ft=xt(),$x=H();function kx(e,t){let{gen:r,data:n,it:o}=e;r.if(Rc(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,ne._)`${t}`},!0),e.error()})}Y.checkReportMissingProp=kx;function xx({gen:e,data:t,it:{opts:r}},n,o){return(0,ne.or)(...n.map(s=>(0,ne.and)(Rc(e,t,s,r.ownProperties),(0,ne._)`${o} = ${s}`)))}Y.checkMissingProp=xx;function Sx(e,t){e.setParams({missingProperty:t},!0),e.error()}Y.reportMissingProp=Sx;function ag(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,ne._)`Object.prototype.hasOwnProperty`})}Y.hasPropFunc=ag;function Oc(e,t,r){return(0,ne._)`${ag(e)}.call(${t}, ${r})`}Y.isOwnProperty=Oc;function zx(e,t,r,n){let o=(0,ne._)`${t}${(0,ne.getProperty)(r)} !== undefined`;return n?(0,ne._)`${o} && ${Oc(e,t,r)}`:o}Y.propertyInData=zx;function Rc(e,t,r,n){let o=(0,ne._)`${t}${(0,ne.getProperty)(r)} === undefined`;return n?(0,ne.or)(o,(0,ne.not)(Oc(e,t,r))):o}Y.noPropertyInData=Rc;function cg(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Y.allSchemaProperties=cg;function Px(e,t){return cg(t).filter(r=>!(0,Tc.alwaysValidSchema)(e,t[r]))}Y.schemaProperties=Px;function Ix({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,ne._)`${e}, ${t}, ${n}${o}`:t,d=[[Ft.default.instancePath,(0,ne.strConcat)(Ft.default.instancePath,s)],[Ft.default.parentData,i.parentData],[Ft.default.parentDataProperty,i.parentDataProperty],[Ft.default.rootData,Ft.default.rootData]];i.opts.dynamicRef&&d.push([Ft.default.dynamicAnchors,Ft.default.dynamicAnchors]);let f=(0,ne._)`${l}, ${r.object(...d)}`;return c!==ne.nil?(0,ne._)`${a}.call(${c}, ${f})`:(0,ne._)`${a}(${f})`}Y.callValidateCode=Ix;var Ex=(0,ne._)`new RegExp`;function Tx({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,ne._)`${o.code==="new RegExp"?Ex:(0,$x.useFunc)(e,o)}(${r}, ${n})`})}Y.usePattern=Tx;function Ox(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,ne._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:Tc.Type.Num},s),t.if((0,ne.not)(s),a)})}}Y.validateArray=Ox;function Rx(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,Tc.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,ne._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,ne.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}Y.validateUnion=Rx});var dg=S(lt=>{"use strict";Object.defineProperty(lt,"__esModule",{value:!0});lt.validateKeywordUsage=lt.validSchemaType=lt.funcKeywordCode=lt.macroKeywordCode=void 0;var Ae=q(),or=xt(),Ax=Xe(),Cx=Mn();function Nx(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=lg(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:Ae.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}lt.macroKeywordCode=Nx;function jx(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;Zx(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=lg(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&&ug(e),g(()=>e.error());else{let y=t.async?p():m();t.modifying&&ug(e),g(()=>Dx(e,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,Ae._)`await `),v=>n.assign(d,!1).if((0,Ae._)`${v} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,Ae._)`${v}.errors`),()=>n.throw(v))),y}function m(){let y=(0,Ae._)`${l}.errors`;return n.assign(y,null),h(Ae.nil),y}function h(y=t.async?(0,Ae._)`await `:Ae.nil){let v=c.opts.passContext?or.default.this:or.default.self,k=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Ae._)`${y}${(0,Ax.callValidateCode)(e,l,v,k)}`,t.modifying)}function g(y){var v;n.if((0,Ae.not)((v=t.valid)!==null&&v!==void 0?v:d),y)}}lt.funcKeywordCode=jx;function ug(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Ae._)`${n.parentData}[${n.parentDataProperty}]`))}function Dx(e,t){let{gen:r}=e;r.if((0,Ae._)`Array.isArray(${t})`,()=>{r.assign(or.default.vErrors,(0,Ae._)`${or.default.vErrors} === null ? ${t} : ${or.default.vErrors}.concat(${t})`).assign(or.default.errors,(0,Ae._)`${or.default.vErrors}.length`),(0,Cx.extendErrors)(e)},()=>e.error())}function Zx({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function lg(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,Ae.stringify)(r)})}function Mx(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")}lt.validSchemaType=Mx;function qx({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)}}lt.validateKeywordUsage=qx});var pg=S(Lt=>{"use strict";Object.defineProperty(Lt,"__esModule",{value:!0});Lt.extendSubschemaMode=Lt.extendSubschemaData=Lt.getSubschema=void 0;var dt=q(),fg=H();function Fx(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,dt._)`${e.schemaPath}${(0,dt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,dt._)`${e.schemaPath}${(0,dt.getProperty)(t)}${(0,dt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,fg.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')}Lt.getSubschema=Fx;function Lx(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,dt._)`${t.data}${(0,dt.getProperty)(r)}`,!0);c(f),e.errorPath=(0,dt.str)`${u}${(0,fg.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,dt._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof dt.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]}}Lt.extendSubschemaData=Lx;function Ux(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}Lt.extendSubschemaMode=Ux});var Ac=S((pD,mg)=>{"use strict";mg.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 gg=S((mD,hg)=>{"use strict";var Ut=hg.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(){};Bs(t,n,o,e,"",e)};Ut.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Ut.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Ut.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Ut.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 Bs(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 Ut.arrayKeywords)for(var f=0;f<d.length;f++)Bs(e,t,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in Ut.propsKeywords){if(d&&typeof d=="object")for(var p in d)Bs(e,t,r,d[p],o+"/"+l+"/"+Vx(p),s,o,l,n,p)}else(l in Ut.keywords||e.allKeys&&!(l in Ut.skipKeywords))&&Bs(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function Vx(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Fn=S(Me=>{"use strict";Object.defineProperty(Me,"__esModule",{value:!0});Me.getSchemaRefs=Me.resolveUrl=Me.normalizeId=Me._getFullPath=Me.getFullPath=Me.inlineRef=void 0;var Bx=H(),Hx=Ac(),Kx=gg(),Jx=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Gx(e,t=!0){return typeof e=="boolean"?!0:t===!0?!Cc(e):t?yg(e)<=t:!1}Me.inlineRef=Gx;var Wx=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Cc(e){for(let t in e){if(Wx.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(Cc)||typeof r=="object"&&Cc(r))return!0}return!1}function yg(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!Jx.has(r)&&(typeof e[r]=="object"&&(0,Bx.eachItem)(e[r],n=>t+=yg(n)),t===1/0))return 1/0}return t}function _g(e,t="",r){r!==!1&&(t=Ar(t));let n=e.parse(t);return wg(e,n)}Me.getFullPath=_g;function wg(e,t){return e.serialize(t).split("#")[0]+"#"}Me._getFullPath=wg;var Yx=/#\/?$/;function Ar(e){return e?e.replace(Yx,""):""}Me.normalizeId=Ar;function Xx(e,t,r){return r=Ar(r),e.resolve(t,r)}Me.resolveUrl=Xx;var Qx=/^[a-z_][-a-z0-9._]*$/i;function eS(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Ar(e[r]||t),s={"":o},i=_g(n,o,!1),a={},c=new Set;return Kx(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(k){let T=this.opts.uriResolver.resolve;if(k=Ar(g?T(g,k):k),c.has(k))throw l(k);c.add(k);let x=this.refs[k];return typeof x=="string"&&(x=this.refs[x]),typeof x=="object"?u(d,x.schema,k):k!==Ar(h)&&(k[0]==="#"?(u(d,a[k],k),a[k]=d):this.refs[k]=h),k}function v(k){if(typeof k=="string"){if(!Qx.test(k))throw new Error(`invalid anchor "${k}"`);y.call(this,`#${k}`)}}}),a;function u(d,f,p){if(f!==void 0&&!Hx(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Me.getSchemaRefs=eS});var Vn=S(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Vt.getData=Vt.KeywordCxt=Vt.validateFunctionCode=void 0;var xg=Qh(),bg=qn(),jc=zc(),Hs=qn(),tS=ig(),Un=dg(),Nc=pg(),E=q(),N=xt(),rS=Fn(),St=H(),Ln=Mn();function nS(e){if(Pg(e)&&(Ig(e),zg(e))){iS(e);return}Sg(e,()=>(0,xg.topBoolOrEmptySchema)(e))}Vt.validateFunctionCode=nS;function Sg({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,E._)`${N.default.data}, ${N.default.valCxt}`,n.$async,()=>{e.code((0,E._)`"use strict"; ${vg(r,o)}`),sS(e,o),e.code(s)}):e.func(t,(0,E._)`${N.default.data}, ${oS(o)}`,n.$async,()=>e.code(vg(r,o)).code(s))}function oS(e){return(0,E._)`{${N.default.instancePath}="", ${N.default.parentData}, ${N.default.parentDataProperty}, ${N.default.rootData}=${N.default.data}${e.dynamicRef?(0,E._)`, ${N.default.dynamicAnchors}={}`:E.nil}}={}`}function sS(e,t){e.if(N.default.valCxt,()=>{e.var(N.default.instancePath,(0,E._)`${N.default.valCxt}.${N.default.instancePath}`),e.var(N.default.parentData,(0,E._)`${N.default.valCxt}.${N.default.parentData}`),e.var(N.default.parentDataProperty,(0,E._)`${N.default.valCxt}.${N.default.parentDataProperty}`),e.var(N.default.rootData,(0,E._)`${N.default.valCxt}.${N.default.rootData}`),t.dynamicRef&&e.var(N.default.dynamicAnchors,(0,E._)`${N.default.valCxt}.${N.default.dynamicAnchors}`)},()=>{e.var(N.default.instancePath,(0,E._)`""`),e.var(N.default.parentData,(0,E._)`undefined`),e.var(N.default.parentDataProperty,(0,E._)`undefined`),e.var(N.default.rootData,N.default.data),t.dynamicRef&&e.var(N.default.dynamicAnchors,(0,E._)`{}`)})}function iS(e){let{schema:t,opts:r,gen:n}=e;Sg(e,()=>{r.$comment&&t.$comment&&Tg(e),dS(e),n.let(N.default.vErrors,null),n.let(N.default.errors,0),r.unevaluated&&aS(e),Eg(e),mS(e)})}function aS(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,E._)`${r}.evaluated`),t.if((0,E._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,E._)`${e.evaluated}.props`,(0,E._)`undefined`)),t.if((0,E._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,E._)`${e.evaluated}.items`,(0,E._)`undefined`))}function vg(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,E._)`/*# sourceURL=${r} */`:E.nil}function cS(e,t){if(Pg(e)&&(Ig(e),zg(e))){uS(e,t);return}(0,xg.boolOrEmptySchema)(e,t)}function zg({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 Pg(e){return typeof e.schema!="boolean"}function uS(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&Tg(e),fS(e),pS(e);let s=n.const("_errs",N.default.errors);Eg(e,s),n.var(t,(0,E._)`${s} === ${N.default.errors}`)}function Ig(e){(0,St.checkUnknownRules)(e),lS(e)}function Eg(e,t){if(e.opts.jtd)return $g(e,[],!1,t);let r=(0,bg.getSchemaTypes)(e.schema),n=(0,bg.coerceAndCheckDataType)(e,r);$g(e,r,!n,t)}function lS(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,St.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function dS(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,St.checkStrictMode)(e,"default is ignored in the schema root")}function fS(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,rS.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function pS(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Tg({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,E._)`${N.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,E.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,E._)`${N.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function mS(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,E._)`${N.default.errors} === 0`,()=>t.return(N.default.data),()=>t.throw((0,E._)`new ${o}(${N.default.vErrors})`)):(t.assign((0,E._)`${n}.errors`,N.default.vErrors),s.unevaluated&&hS(e),t.return((0,E._)`${N.default.errors} === 0`))}function hS({gen:e,evaluated:t,props:r,items:n}){r instanceof E.Name&&e.assign((0,E._)`${t}.props`,r),n instanceof E.Name&&e.assign((0,E._)`${t}.items`,n)}function $g(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,St.schemaHasRulesButRef)(s,l))){o.block(()=>Rg(e,"$ref",l.all.$ref.definition));return}c.jtd||gS(e,t),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,jc.shouldUseGroup)(s,f)&&(f.type?(o.if((0,Hs.checkDataType)(f.type,i,c.strictNumbers)),kg(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,Hs.reportTypeError)(e)),o.endIf()):kg(e,f),a||o.if((0,E._)`${N.default.errors} === ${n||0}`))}}function kg(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,tS.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,jc.shouldUseRule)(n,s)&&Rg(e,s.keyword,s.definition,t.type)})}function gS(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(yS(e,t),e.opts.allowUnionTypes||_S(e,t),wS(e,e.dataTypes))}function yS(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Og(e.dataTypes,r)||Dc(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),vS(e,t)}}function _S(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&Dc(e,"use allowUnionTypes to allow union type keyword")}function wS(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,jc.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>bS(t,i))&&Dc(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function bS(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Og(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function vS(e,t){let r=[];for(let n of e.dataTypes)Og(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function Dc(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,St.checkStrictMode)(e,t,e.opts.strictTypes)}var Ks=class{constructor(t,r,n){if((0,Un.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,St.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",Ag(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,Un.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",N.default.errors))}result(t,r,n){this.failResult((0,E.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,E.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,E._)`${r} !== undefined && (${(0,E.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?Ln.reportExtraError:Ln.reportError)(this,this.def.error,r)}$dataError(){(0,Ln.reportError)(this,this.def.$dataError||Ln.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Ln.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=E.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=E.nil,r=E.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,E.or)((0,E._)`${o} === undefined`,r)),t!==E.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==E.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,E.or)(i(),a());function i(){if(n.length){if(!(r instanceof E.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,E._)`${(0,Hs.checkDataTypes)(c,r,s.opts.strictNumbers,Hs.DataType.Wrong)}`}return E.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,E._)`!${c}(${r})`}return E.nil}}subschema(t,r){let n=(0,Nc.getSubschema)(this.it,t);(0,Nc.extendSubschemaData)(n,this.it,t),(0,Nc.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return cS(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=St.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=St.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,E.Name)),!0}};Vt.KeywordCxt=Ks;function Rg(e,t,r,n){let o=new Ks(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Un.funcKeywordCode)(o,r):"macro"in r?(0,Un.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Un.funcKeywordCode)(o,r)}var $S=/^\/(?:[^~]|~0|~1)*$/,kS=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Ag(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return N.default.rootData;if(e[0]==="/"){if(!$S.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=N.default.rootData}else{let u=kS.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,E._)`${s}${(0,E.getProperty)((0,St.unescapeJsonPointer)(u))}`,i=(0,E._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Vt.getData=Ag});var Js=S(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});var Zc=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};Mc.default=Zc});var Bn=S(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});var qc=Fn(),Fc=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,qc.resolveUrl)(t,r,n),this.missingSchema=(0,qc.normalizeId)((0,qc.getFullPath)(t,this.missingRef))}};Lc.default=Fc});var Ws=S(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.resolveSchema=Qe.getCompilingSchema=Qe.resolveRef=Qe.compileSchema=Qe.SchemaEnv=void 0;var it=q(),xS=Js(),sr=xt(),at=Fn(),Cg=H(),SS=Vn(),Cr=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,at.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};Qe.SchemaEnv=Cr;function Vc(e){let t=Ng.call(this,e);if(t)return t;let r=(0,at.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new it.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:xS.default,code:(0,it._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:sr.default.data,parentData:sr.default.parentData,parentDataProperty:sr.default.parentDataProperty,dataNames:[sr.default.data],dataPathArr:[it.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,it.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:it.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,it._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,SS.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(sr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let p=new Function(`${sr.default.self}`,`${sr.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 it.Name?void 0:m,items:h instanceof it.Name?void 0:h,dynamicProps:m instanceof it.Name,dynamicItems:h instanceof it.Name},p.source&&(p.source.evaluated=(0,it.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)}}Qe.compileSchema=Vc;function zS(e,t,r){var n;r=(0,at.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=ES.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 Cr({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=PS.call(this,s)}Qe.resolveRef=zS;function PS(e){return(0,at.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:Vc.call(this,e)}function Ng(e){for(let t of this._compilations)if(IS(t,e))return t}Qe.getCompilingSchema=Ng;function IS(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function ES(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Gs.call(this,e,t)}function Gs(e,t){let r=this.opts.uriResolver.parse(t),n=(0,at._getFullPath)(this.opts.uriResolver,r),o=(0,at.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return Uc.call(this,r,e);let s=(0,at.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Gs.call(this,e,i);return typeof a?.schema!="object"?void 0:Uc.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Vc.call(this,i),s===(0,at.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,at.resolveUrl)(this.opts.uriResolver,o,u)),new Cr({schema:a,schemaId:c,root:e,baseId:o})}return Uc.call(this,r,i)}}Qe.resolveSchema=Gs;var TS=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Uc(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,Cg.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!TS.has(a)&&u&&(t=(0,at.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Cg.schemaHasRulesButRef)(r,this.RULES)){let a=(0,at.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Gs.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Cr({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var jg=S((bD,OS)=>{OS.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 Wc=S((vD,Vg)=>{"use strict";var RS=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Hc=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),AS=RegExp.prototype.test.bind(/^\d*$/u),ir=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Kc=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Zg=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),Jc=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),CS=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),qe=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)qe[t]="%"+e[t>>4]+e[t&15]}function ze(e){return e<2048?qe[192|e>>6]+qe[128|e&63]:e<65536?qe[224|e>>12]+qe[128|e>>6&63]+qe[128|e&63]:qe[240|e>>18]+qe[128|e>>12&63]+qe[128|e>>6&63]+qe[128|e&63]}function NS(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 jS=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),DS=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),ZS=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),MS=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function qS(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!ZS(e[t])){if(e[t]==="%"&&t+2<e.length&&ir(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function Dg(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 FS(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||!Hc(c))return;s+=2;continue}if(!jS(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:Dg(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 Dg(i)}function Bc(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&&DS(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(LS(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),!qS(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=FS(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function LS(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function Mg(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 US(e){if(e===""||e[0]==="/")return Mg(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 VS={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},BS=/[@/?#:]/g,HS=/[@/?#]/g;function qg(e,t){let r=t?HS:BS;return r.lastIndex=0,e.replace(r,n=>VS[n])}function Fg(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(ir(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&Kc(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function KS(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(ir(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&Kc(i)?t+=i:t+="%"+s,r+=2;continue}}if(Zg(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Ug(o)?n:qe[o];else if(o<55296||o>57343)t+=ze(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ze(65536+(o-55296<<10)+(s-56320)),r++):t+=ze(65533)}else t+=ze(65533)}}return t}function JS(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(ir(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),Zg(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=qe[i];else if(i<55296||i>57343)r+=ze(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=ze(65536+(i-55296<<10)+(a-56320)),o++):r+=ze(65533)}else r+=ze(65533)}}return r}function Gc(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(ir(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=qe[s];else if(s<55296||s>57343)r+=ze(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=ze(65536+(s-55296<<10)+(i-56320)),n++):r+=ze(65533)}else r+=ze(65533)}}return r}function Lg(e){return Gc(e,CS)}function GS(e){return Gc(e,Jc)}function WS(e){return Gc(e,Jc)}function Ug(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 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(ir(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));Kc(i)?t+=i:t+="%"+s,r+=2;continue}}if(Jc(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=Ug(o)?n:qe[o];else if(o<55296||o>57343)t+=ze(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=ze(65536+(o-55296<<10)+(s-56320)),r++):t+=ze(65533)}else t+=ze(65533)}}return t}function XS(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(ir(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function QS(e){let t=[];if(e.userinfo!==void 0&&(t.push(Lg(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!Hc(r)){let n=Bc(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=Fg(r,!0),n=Bc(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=qg(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!AS(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}Vg.exports={nonSimpleDomain:MS,recomposeAuthority:QS,reescapeHostDelimiters:qg,normalizePercentEncoding:Fg,normalizePathEncoding:KS,serializePathEncoding:JS,normalizeQueryFragmentEncoding:YS,encodeUserinfo:Lg,encodeQuery:GS,encodeFragment:WS,escapePreservingEscapes:XS,removeDotSegments:Mg,removeDotSegmentsRelative:US,isIPv4:Hc,isUUID:RS,normalizeIPv6:Bc,stringArrayToHexStripped:NS}});var Gg=S(($D,Jg)=>{"use strict";var{isUUID:ez}=Wc(),tz=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,rz=["http","https","ws","wss","urn","urn:uuid"];function nz(e){return rz.indexOf(e)!==-1}function Yc(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 Bg(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function Hg(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 oz(e){return e.secure=Yc(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function sz(e){if((e.port===(Yc(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 iz(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match(tz);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=Xc(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function az(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=Xc(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 cz(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!ez(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function uz(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var Kg={scheme:"http",domainHost:!0,parse:Bg,serialize:Hg},lz={scheme:"https",domainHost:Kg.domainHost,parse:Bg,serialize:Hg},Ys={scheme:"ws",domainHost:!0,parse:oz,serialize:sz},dz={scheme:"wss",domainHost:Ys.domainHost,parse:Ys.parse,serialize:Ys.serialize},fz={scheme:"urn",parse:iz,serialize:az,skipNormalize:!0},pz={scheme:"urn:uuid",parse:cz,serialize:uz,skipNormalize:!0},Xs={http:Kg,https:lz,ws:Ys,wss:dz,urn:fz,"urn:uuid":pz};Object.setPrototypeOf(Xs,null);function Xc(e){return e&&(Xs[e]||Xs[e.toLowerCase()])||void 0}Jg.exports={wsIsSecure:Yc,SCHEMES:Xs,isValidSchemeName:nz,getSchemeHandler:Xc}});var ly=S((kD,ni)=>{"use strict";var{normalizeIPv6:ey,removeDotSegments:Kn,removeDotSegmentsRelative:ty,recomposeAuthority:mz,normalizePercentEncoding:Qc,normalizePathEncoding:hz,serializePathEncoding:Wg,normalizeQueryFragmentEncoding:Yg,encodeQuery:gz,encodeFragment:yz,reescapeHostDelimiters:_z,isIPv4:ry,nonSimpleDomain:wz}=Wc(),{SCHEMES:ny,getSchemeHandler:eu}=Gg(),oy=/^[A-Za-z][A-Za-z0-9+.-]*$/u,sy="URI scheme is malformed.",Qs="URI host is malformed.",bz=/[\0-\x20"#/:<>?@[\\\]^`{|}\x7F]/u;function Xg(e){let t=String(e);if(!oy.test(t))throw new TypeError(sy);return t}function vz(e,t){return typeof e=="string"?e=Tz(e,t):typeof e=="object"&&(e=ti(ar(e,t),t)),e}function $z(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}=ei(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:f,malformedSchemeSpecific:p,malformedHost:m,malformedScheme:h}=ei(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=iy(o,l,n,!0),y=eu(r&&r.scheme||g.scheme),v=g.host,k=v!==void 0&&v!==""&&(ry(v)||ey(v).isIPV6);if(cy(g,r||{},y,k))throw new Error(Qs);ay(g,r||{},y,k);let T=v&&v.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(v);if(g.error&&!T)throw new Error(g.error);return n.skipEscape=!0,ar(g,n)}function iy(e,t,r,n){let o={};if(n||(e=ti(ar(e,r),r),t=ti(ar(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=Kn(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=Kn(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=Kn(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]!=="/"?ty(o.path):Kn(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 kz(e,t,r){let n=Qg(e,r),o=Qg(t,r);return n!==void 0&&o!==void 0&&n===o}function ar(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=Xg(r.scheme));let s=eu(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=Qc(r.path):r.path=Wg(r.path,c)),n.reference!=="suffix"&&r.scheme&&(r.scheme=Xg(r.scheme),o.push(r.scheme,":"));let u=mz(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]!=="/"?ty(l):Kn(l)),a&&(l=Wg(l,!0)),u===void 0&&l[0]==="/"&&l[1]==="/"&&(l="/%2F"+l.slice(2)),o.push(l)}return r.query!==void 0&&o.push("?",gz(r.query)),r.fragment!==void 0&&o.push("#",yz(r.fragment)),o.join("")}var xz=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,Sz=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,zz=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function Pz(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 Hn(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 ri(e){return e[0]==="["&&e[e.length-1]==="]"}function Iz(e){let t=e[4];return Hn(e[3])||t!==void 0&&!ri(t)&&Hn(t)||Hn(e[6])||Hn(e[7])||Hn(e[8])}function ay(e,t,r,n){if(cy(e,t,r,n))return e.error=e.error||Qs,!0;if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!ri(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&wz(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(!Ez(o))return e.error=e.error||Qs,!0;e.host=o.hostname}return!1}function cy(e,t,r,n){return!!(e.host&&n===!1&&!ri(e.host)&&(t.domainHost||r&&r.domainHost)&&bz.test(e.host))}function Ez(e){return e.username===""&&e.password===""&&e.port===""&&e.pathname==="/"&&e.search===""&&e.hash===""&&e.hostname!==""}function ei(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(Sz);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let f=e.match(zz);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(xz);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&&(oy.test(n.scheme)?n.scheme=n.scheme.toLowerCase():(n.error=n.error||sy,u=!0)),s=Iz(p),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=p[5]);let m=Pz(n,p);if(m!==void 0&&(n.error=n.error||m,o=!0),n.host)if(ry(n.host)===!1){let y=ri(n.host),v=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,k=ey(n.host);l=k.isIPV6||k.isIPVFuture===!0,c=v&&(!y||k.error===!0),n.host=l?k.host:k.host.toLowerCase(),c&&(n.error=n.error||Qs,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=eu(r.scheme||n.scheme);if(c||(a=ay(n,r,h,l)),e.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:Qc(n.host,!0);l||(g=Qc(g.toLowerCase())),n.host=l||r.scheme!=="null"?_z(g,l):g}(!h||h&&!h.skipNormalize)&&(n.path&&(n.path=hz(n.path)),n.query&&(n.query=Yg(n.query)),n.fragment&&(n.fragment=Yg(n.fragment))),h&&h.parse&&(h.parse(n,r),h===ny.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 ti(e,t){return ei(e,t).parsed}function Tz(e,t){return uy(e,t).normalized}function uy(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=ei(e,t);return{normalized:n||o||s||i||a?e:ar(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function Qg(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:ar(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=uy(r,t);return o||s||i||a||c?void 0:n}var tu={SCHEMES:ny,normalize:vz,resolve:$z,resolveComponent:iy,equal:kz,serialize:ar,parse:ti};ni.exports=tu;ni.exports.default=tu;ni.exports.fastUri=tu});var fy=S(ru=>{"use strict";Object.defineProperty(ru,"__esModule",{value:!0});var dy=ly();dy.code='require("ajv/dist/runtime/uri").default';ru.default=dy});var by=S(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.CodeGen=ve.Name=ve.nil=ve.stringify=ve.str=ve._=ve.KeywordCxt=void 0;var Oz=Vn();Object.defineProperty(ve,"KeywordCxt",{enumerable:!0,get:function(){return Oz.KeywordCxt}});var Nr=q();Object.defineProperty(ve,"_",{enumerable:!0,get:function(){return Nr._}});Object.defineProperty(ve,"str",{enumerable:!0,get:function(){return Nr.str}});Object.defineProperty(ve,"stringify",{enumerable:!0,get:function(){return Nr.stringify}});Object.defineProperty(ve,"nil",{enumerable:!0,get:function(){return Nr.nil}});Object.defineProperty(ve,"Name",{enumerable:!0,get:function(){return Nr.Name}});Object.defineProperty(ve,"CodeGen",{enumerable:!0,get:function(){return Nr.CodeGen}});var Rz=Js(),yy=Bn(),Az=Sc(),Jn=Ws(),Cz=q(),Gn=Fn(),oi=qn(),ou=H(),py=jg(),Nz=fy(),_y=(e,t)=>new RegExp(e,t);_y.code="new RegExp";var jz=["removeAdditional","useDefaults","coerceTypes"],Dz=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Zz={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."},Mz={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},my=200;function qz(e){var t,r,n,o,s,i,a,c,u,l,d,f,p,m,h,g,y,v,k,T,x,$,P,F,C;let D=e.strict,de=(t=e.code)===null||t===void 0?void 0:t.optimize,M=de===!0||de===void 0?1:de||0,me=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:_y,se=(o=e.uriResolver)!==null&&o!==void 0?o:Nz.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:D)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:D)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:D)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:D)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=e.strictRequired)!==null&&p!==void 0?p:D)!==null&&m!==void 0?m:!1,code:e.code?{...e.code,optimize:M,regExp:me}:{optimize:M,regExp:me},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:my,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:my,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(v=e.messages)!==null&&v!==void 0?v:!0,inlineRefs:(k=e.inlineRefs)!==null&&k!==void 0?k:!0,schemaId:(T=e.schemaId)!==null&&T!==void 0?T:"$id",addUsedSchema:(x=e.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:($=e.validateSchema)!==null&&$!==void 0?$:!0,validateFormats:(P=e.validateFormats)!==null&&P!==void 0?P:!0,unicodeRegExp:(F=e.unicodeRegExp)!==null&&F!==void 0?F:!0,int32range:(C=e.int32range)!==null&&C!==void 0?C:!0,uriResolver:se}}var Wn=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,...qz(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new Cz.ValueScope({scope:{},prefixes:Dz,es5:r,lines:n}),this.logger=Hz(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,Az.getRules)(),hy.call(this,Zz,t,"NOT SUPPORTED"),hy.call(this,Mz,t,"DEPRECATED","warn"),this._metaOpts=Vz.call(this),t.formats&&Lz.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&Uz.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),Fz.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=py;n==="id"&&(o={...py},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 yy.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,Gn.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=gy.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Jn.SchemaEnv({schema:{},schemaId:n});if(r=Jn.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=gy.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,Gn.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(Jz.call(this,n,r),!r)return(0,ou.eachItem)(n,s=>nu.call(this,s)),this;Wz.call(this,r);let o={...r,type:(0,oi.getJSONTypes)(r.type),schemaType:(0,oi.getJSONTypes)(r.schemaType)};return(0,ou.eachItem)(n,o.type.length===0?s=>nu.call(this,s,o):s=>o.type.forEach(i=>nu.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]=wy(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,Gn.normalizeId)(i||n);let u=Gn.getSchemaRefs.call(this,t,n);return c=new Jn.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):Jn.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{Jn.compileSchema.call(this,t)}finally{this.opts=r}}};Wn.ValidationError=Rz.default;Wn.MissingRefError=yy.default;ve.default=Wn;function hy(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 gy(e){return e=(0,Gn.normalizeId)(e),this.schemas[e]||this.refs[e]}function Fz(){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 Lz(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function Uz(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 Vz(){let e={...this.opts};for(let t of jz)delete e[t];return e}var Bz={log(){},warn(){},error(){}};function Hz(e){if(e===!1)return Bz;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 Kz=/^[a-z_$][a-z0-9_$:-]*$/i;function Jz(e,t){let{RULES:r}=this;if((0,ou.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Kz.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 nu(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,oi.getJSONTypes)(t.type),schemaType:(0,oi.getJSONTypes)(t.schemaType)}};t.before?Gz.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 Gz(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 Wz(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=wy(t)),e.validateSchema=this.compile(t,!0))}var Yz={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function wy(e){return{anyOf:[e,Yz]}}});var vy=S(su=>{"use strict";Object.defineProperty(su,"__esModule",{value:!0});var Xz={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};su.default=Xz});var Sy=S(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});cr.callRef=cr.getValidate=void 0;var Qz=Bn(),$y=Xe(),Fe=q(),jr=xt(),ky=Ws(),si=H(),eP={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=ky.resolveRef.call(c,u,o,r);if(l===void 0)throw new Qz.default(n.opts.uriResolver,o,r);if(l instanceof ky.SchemaEnv)return f(l);return p(l);function d(){if(s===u)return ii(e,i,s,s.$async);let m=t.scopeValue("root",{ref:u});return ii(e,(0,Fe._)`${m}.validate`,u,u.$async)}function f(m){let h=xy(e,m);ii(e,h,m,m.$async)}function p(m){let h=t.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Fe.stringify)(m)}:{ref:m}),g=t.name("valid"),y=e.subschema({schema:m,dataTypes:[],schemaPath:Fe.nil,topSchemaRef:h,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function xy(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Fe._)`${r.scopeValue("wrapper",{ref:t})}.validate`}cr.getValidate=xy;function ii(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?jr.default.this:Fe.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,Fe._)`await ${(0,$y.callValidateCode)(e,t,u)}`),p(t),i||o.assign(m,!0)},h=>{o.if((0,Fe._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),f(h),i||o.assign(m,!1)}),e.ok(m)}function d(){e.result((0,$y.callValidateCode)(e,t,u),()=>p(t),()=>f(t))}function f(m){let h=(0,Fe._)`${m}.errors`;o.assign(jr.default.vErrors,(0,Fe._)`${jr.default.vErrors} === null ? ${h} : ${jr.default.vErrors}.concat(${h})`),o.assign(jr.default.errors,(0,Fe._)`${jr.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=si.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,Fe._)`${m}.evaluated.props`);s.props=si.mergeEvaluated.props(o,y,s.props,Fe.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=si.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,Fe._)`${m}.evaluated.items`);s.items=si.mergeEvaluated.items(o,y,s.items,Fe.Name)}}}cr.callRef=ii;cr.default=eP});var zy=S(iu=>{"use strict";Object.defineProperty(iu,"__esModule",{value:!0});var tP=vy(),rP=Sy(),nP=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",tP.default,rP.default];iu.default=nP});var Py=S(au=>{"use strict";Object.defineProperty(au,"__esModule",{value:!0});var ai=q(),Bt=ai.operators,ci={maximum:{okStr:"<=",ok:Bt.LTE,fail:Bt.GT},minimum:{okStr:">=",ok:Bt.GTE,fail:Bt.LT},exclusiveMaximum:{okStr:"<",ok:Bt.LT,fail:Bt.GTE},exclusiveMinimum:{okStr:">",ok:Bt.GT,fail:Bt.LTE}},oP={message:({keyword:e,schemaCode:t})=>(0,ai.str)`must be ${ci[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ai._)`{comparison: ${ci[e].okStr}, limit: ${t}}`},sP={keyword:Object.keys(ci),type:"number",schemaType:"number",$data:!0,error:oP,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ai._)`${r} ${ci[t].fail} ${n} || isNaN(${r})`)}};au.default=sP});var Iy=S(cu=>{"use strict";Object.defineProperty(cu,"__esModule",{value:!0});var Yn=q(),iP={message:({schemaCode:e})=>(0,Yn.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,Yn._)`{multipleOf: ${e}}`},aP={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:iP,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,Yn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Yn._)`${i} !== parseInt(${i})`;e.fail$data((0,Yn._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};cu.default=aP});var Ty=S(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});function Ey(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}uu.default=Ey;Ey.code='require("ajv/dist/runtime/ucs2length").default'});var Oy=S(lu=>{"use strict";Object.defineProperty(lu,"__esModule",{value:!0});var ur=q(),cP=H(),uP=Ty(),lP={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,ur.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,ur._)`{limit: ${e}}`},dP={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:lP,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?ur.operators.GT:ur.operators.LT,i=o.opts.unicode===!1?(0,ur._)`${r}.length`:(0,ur._)`${(0,cP.useFunc)(e.gen,uP.default)}(${r})`;e.fail$data((0,ur._)`${i} ${s} ${n}`)}};lu.default=dP});var Ry=S(du=>{"use strict";Object.defineProperty(du,"__esModule",{value:!0});var fP=Xe(),pP=H(),Dr=q(),mP={message:({schemaCode:e})=>(0,Dr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Dr._)`{pattern: ${e}}`},hP={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:mP,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,Dr._)`new RegExp`:(0,pP.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Dr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Dr._)`!${l}`)}else{let c=(0,fP.usePattern)(e,o);e.fail$data((0,Dr._)`!${c}.test(${r})`)}}};du.default=hP});var Ay=S(fu=>{"use strict";Object.defineProperty(fu,"__esModule",{value:!0});var Xn=q(),gP={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,Xn.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Xn._)`{limit: ${e}}`},yP={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:gP,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?Xn.operators.GT:Xn.operators.LT;e.fail$data((0,Xn._)`Object.keys(${r}).length ${o} ${n}`)}};fu.default=yP});var Cy=S(pu=>{"use strict";Object.defineProperty(pu,"__esModule",{value:!0});var Qn=Xe(),eo=q(),_P=H(),wP={message:({params:{missingProperty:e}})=>(0,eo.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,eo._)`{missingProperty: ${e}}`},bP={keyword:"required",type:"object",schemaType:"array",$data:!0,error:wP,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(eo.nil,d);else for(let p of r)(0,Qn.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,Qn.checkMissingProp)(e,r,p)),(0,Qn.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",n,p=>{e.setParams({missingProperty:p}),t.if((0,Qn.noPropertyInData)(t,o,p,a.ownProperties),()=>e.error())})}function f(p,m){e.setParams({missingProperty:p}),t.forOf(p,n,()=>{t.assign(m,(0,Qn.propertyInData)(t,o,p,a.ownProperties)),t.if((0,eo.not)(m),()=>{e.error(),t.break()})},eo.nil)}}};pu.default=bP});var Ny=S(mu=>{"use strict";Object.defineProperty(mu,"__esModule",{value:!0});var to=q(),vP={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,to.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,to._)`{limit: ${e}}`},$P={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:vP,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?to.operators.GT:to.operators.LT;e.fail$data((0,to._)`${r}.length ${o} ${n}`)}};mu.default=$P});var ui=S(hu=>{"use strict";Object.defineProperty(hu,"__esModule",{value:!0});var jy=Ac();jy.code='require("ajv/dist/runtime/equal").default';hu.default=jy});var Dy=S(yu=>{"use strict";Object.defineProperty(yu,"__esModule",{value:!0});var gu=qn(),$e=q(),kP=H(),xP=ui(),SP={message:({params:{i:e,j:t}})=>(0,$e.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,$e._)`{i: ${e}, j: ${t}}`},zP={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:SP,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,gu.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,$e._)`${i} === false`),e.ok(c);function l(){let m=t.let("i",(0,$e._)`${r}.length`),h=t.let("j");e.setParams({i:m,j:h}),t.assign(c,!0),t.if((0,$e._)`${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,gu.checkDataTypes)(u,g,a.opts.strictNumbers,gu.DataType.Wrong),v=t.const("indices",(0,$e._)`{}`);t.for((0,$e._)`;${m}--;`,()=>{t.let(g,(0,$e._)`${r}[${m}]`),t.if(y,(0,$e._)`continue`),u.length>1&&t.if((0,$e._)`typeof ${g} == "string"`,(0,$e._)`${g} += "_"`),t.if((0,$e._)`typeof ${v}[${g}] == "number"`,()=>{t.assign(h,(0,$e._)`${v}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,$e._)`${v}[${g}] = ${m}`)})}function p(m,h){let g=(0,kP.useFunc)(t,xP.default),y=t.name("outer");t.label(y).for((0,$e._)`;${m}--;`,()=>t.for((0,$e._)`${h} = ${m}; ${h}--;`,()=>t.if((0,$e._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{e.error(),t.assign(c,!1).break(y)})))}}};yu.default=zP});var Zy=S(wu=>{"use strict";Object.defineProperty(wu,"__esModule",{value:!0});var _u=q(),PP=H(),IP=ui(),EP={message:"must be equal to constant",params:({schemaCode:e})=>(0,_u._)`{allowedValue: ${e}}`},TP={keyword:"const",$data:!0,error:EP,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,_u._)`!${(0,PP.useFunc)(t,IP.default)}(${r}, ${o})`):e.fail((0,_u._)`${s} !== ${r}`)}};wu.default=TP});var My=S(bu=>{"use strict";Object.defineProperty(bu,"__esModule",{value:!0});var ro=q(),OP=H(),RP=ui(),AP={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,ro._)`{allowedValues: ${e}}`},CP={keyword:"enum",schemaType:"array",$data:!0,error:AP,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,OP.useFunc)(t,RP.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,ro.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,ro._)`${u()}(${r}, ${p})`,()=>t.assign(l,!0).break()))}function f(p,m){let h=o[m];return typeof h=="object"&&h!==null?(0,ro._)`${u()}(${r}, ${p}[${m}])`:(0,ro._)`${r} === ${h}`}}};bu.default=CP});var qy=S(vu=>{"use strict";Object.defineProperty(vu,"__esModule",{value:!0});var NP=Py(),jP=Iy(),DP=Oy(),ZP=Ry(),MP=Ay(),qP=Cy(),FP=Ny(),LP=Dy(),UP=Zy(),VP=My(),BP=[NP.default,jP.default,DP.default,ZP.default,MP.default,qP.default,FP.default,LP.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},UP.default,VP.default];vu.default=BP});var ku=S(no=>{"use strict";Object.defineProperty(no,"__esModule",{value:!0});no.validateAdditionalItems=void 0;var lr=q(),$u=H(),HP={message:({params:{len:e}})=>(0,lr.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,lr._)`{limit: ${e}}`},KP={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:HP,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,$u.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Fy(e,n)}};function Fy(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,lr._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,lr._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,$u.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,lr._)`${a} <= ${t.length}`);r.if((0,lr.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:$u.Type.Num},u),i.allErrors||r.if((0,lr.not)(u),()=>r.break())})}}no.validateAdditionalItems=Fy;no.default=KP});var xu=S(oo=>{"use strict";Object.defineProperty(oo,"__esModule",{value:!0});oo.validateTuple=void 0;var Ly=q(),li=H(),JP=Xe(),GP={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return Uy(e,"additionalItems",t);r.items=!0,!(0,li.alwaysValidSchema)(r,t)&&e.ok((0,JP.validateArray)(e))}};function Uy(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=li.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Ly._)`${s}.length`);r.forEach((d,f)=>{(0,li.alwaysValidSchema)(a,d)||(n.if((0,Ly._)`${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,li.checkStrictMode)(a,g,f.strictTuples)}}}oo.validateTuple=Uy;oo.default=GP});var Vy=S(Su=>{"use strict";Object.defineProperty(Su,"__esModule",{value:!0});var WP=xu(),YP={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,WP.validateTuple)(e,"items")};Su.default=YP});var Hy=S(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});var By=q(),XP=H(),QP=Xe(),eI=ku(),tI={message:({params:{len:e}})=>(0,By.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,By._)`{limit: ${e}}`},rI={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:tI,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,XP.alwaysValidSchema)(n,t)&&(o?(0,eI.validateAdditionalItems)(e,o):e.ok((0,QP.validateArray)(e)))}};zu.default=rI});var Ky=S(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});var et=q(),di=H(),nI={message:({params:{min:e,max:t}})=>t===void 0?(0,et.str)`must contain at least ${e} valid item(s)`:(0,et.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,et._)`{minContains: ${e}}`:(0,et._)`{minContains: ${e}, maxContains: ${t}}`},oI={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:nI,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,et._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,di.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,di.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,di.alwaysValidSchema)(s,r)){let h=(0,et._)`${l} >= ${i}`;a!==void 0&&(h=(0,et._)`${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,et._)`${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:di.Type.Num,compositeRule:!0},h),g()})}function m(h){t.code((0,et._)`${h}++`),a===void 0?t.if((0,et._)`${h} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,et._)`${h} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,et._)`${h} >= ${i}`,()=>t.assign(d,!0)))}}};Pu.default=oI});var Wy=S(ft=>{"use strict";Object.defineProperty(ft,"__esModule",{value:!0});ft.validateSchemaDeps=ft.validatePropertyDeps=ft.error=void 0;var Iu=q(),sI=H(),so=Xe();ft.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Iu.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Iu._)`{property: ${e},
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 iI={keyword:"dependencies",type:"object",schemaType:"object",error:ft.error,code(e){let[t,r]=aI(e);Jy(e,t),Gy(e,r)}};function aI({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 Jy(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,so.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,so.checkReportMissingProp)(e,u)}):(r.if((0,Iu._)`${c} && (${(0,so.checkMissingProp)(e,a,s)})`),(0,so.reportMissingProp)(e,s),r.else())}}ft.validatePropertyDeps=Jy;function Gy(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,sI.alwaysValidSchema)(s,t[a])||(r.if((0,so.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))}ft.validateSchemaDeps=Gy;ft.default=iI});var Xy=S(Eu=>{"use strict";Object.defineProperty(Eu,"__esModule",{value:!0});var Yy=q(),cI=H(),uI={message:"property name must be valid",params:({params:e})=>(0,Yy._)`{propertyName: ${e.propertyName}}`},lI={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:uI,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,cI.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,Yy.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Eu.default=lI});var Ou=S(Tu=>{"use strict";Object.defineProperty(Tu,"__esModule",{value:!0});var fi=Xe(),ct=q(),dI=xt(),pi=H(),fI={message:"must NOT have additional properties",params:({params:e})=>(0,ct._)`{additionalProperty: ${e.additionalProperty}}`},pI={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:fI,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,pi.alwaysValidSchema)(i,r))return;let u=(0,fi.allSchemaProperties)(n.properties),l=(0,fi.allSchemaProperties)(n.patternProperties);d(),e.ok((0,ct._)`${s} === ${dI.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,pi.schemaRefOrVal)(i,n.properties,"properties");y=(0,fi.isOwnProperty)(t,v,g)}else u.length?y=(0,ct.or)(...u.map(v=>(0,ct._)`${g} === ${v}`)):y=ct.nil;return l.length&&(y=(0,ct.or)(y,...l.map(v=>(0,ct._)`${(0,fi.usePattern)(e,v)}.test(${g})`))),(0,ct.not)(y)}function p(g){t.code((0,ct._)`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,pi.alwaysValidSchema)(i,r)){let y=t.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),t.if((0,ct.not)(y),()=>{e.reset(),p(g)})):(h(g,y),a||t.if((0,ct.not)(y),()=>t.break()))}}function h(g,y,v){let k={keyword:"additionalProperties",dataProp:g,dataPropType:pi.Type.Str};v===!1&&Object.assign(k,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(k,y)}}};Tu.default=pI});var t_=S(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});var mI=Vn(),Qy=Xe(),Ru=H(),e_=Ou(),hI={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&&e_.default.code(new mI.KeywordCxt(s,e_.default,"additionalProperties"));let i=(0,Qy.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Ru.mergeEvaluated.props(t,(0,Ru.toHash)(i),s.props));let a=i.filter(d=>!(0,Ru.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,Qy.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)}}};Au.default=hI});var s_=S(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});var r_=Xe(),mi=q(),n_=H(),o_=H(),gI={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,r_.allSchemaProperties)(r),c=a.filter(h=>(0,n_.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 mi.Name)&&(s.props=(0,o_.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,n_.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){t.forIn("key",n,g=>{t.if((0,mi._)`${(0,r_.usePattern)(e,h)}.test(${g})`,()=>{let y=c.includes(h);y||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:o_.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,mi._)`${d}[${g}]`,!0):!y&&!s.allErrors&&t.if((0,mi.not)(l),()=>t.break())})})}}};Cu.default=gI});var i_=S(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});var yI=H(),_I={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,yI.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"}};Nu.default=_I});var a_=S(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var wI=Xe(),bI={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:wI.validateUnion,error:{message:"must match a schema in anyOf"}};ju.default=bI});var c_=S(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var hi=q(),vI=H(),$I={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,hi._)`{passingSchemas: ${e.passing}}`},kI={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:$I,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,vI.alwaysValidSchema)(o,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,hi._)`${c} && ${i}`).assign(i,!1).assign(a,(0,hi._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,hi.Name)})})}}};Du.default=kI});var u_=S(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});var xI=H(),SI={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,xI.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};Zu.default=SI});var f_=S(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});var gi=q(),d_=H(),zI={message:({params:e})=>(0,gi.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,gi._)`{failingKeyword: ${e.ifClause}}`},PI={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:zI,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,d_.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=l_(n,"then"),s=l_(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,gi.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,gi._)`${l}`):e.setParams({ifClause:l})}}}};function l_(e,t){let r=e.schema[t];return r!==void 0&&!(0,d_.alwaysValidSchema)(e,r)}Mu.default=PI});var p_=S(qu=>{"use strict";Object.defineProperty(qu,"__esModule",{value:!0});var II=H(),EI={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,II.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};qu.default=EI});var m_=S(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var TI=ku(),OI=Vy(),RI=xu(),AI=Hy(),CI=Ky(),NI=Wy(),jI=Xy(),DI=Ou(),ZI=t_(),MI=s_(),qI=i_(),FI=a_(),LI=c_(),UI=u_(),VI=f_(),BI=p_();function HI(e=!1){let t=[qI.default,FI.default,LI.default,UI.default,VI.default,BI.default,jI.default,DI.default,NI.default,ZI.default,MI.default];return e?t.push(OI.default,AI.default):t.push(TI.default,RI.default),t.push(CI.default),t}Fu.default=HI});var h_=S(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});var pe=q(),KI={message:({schemaCode:e})=>(0,pe.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,pe._)`{format: ${e}}`},JI={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:KI,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,pe._)`${m}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,pe._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,pe._)`${h}.type || "string"`).assign(y,(0,pe._)`${h}.validate`),()=>r.assign(g,(0,pe._)`"string"`).assign(y,h)),e.fail$data((0,pe.or)(v(),k()));function v(){return c.strictSchema===!1?pe.nil:(0,pe._)`${i} && !${y}`}function k(){let T=l.$async?(0,pe._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,pe._)`${y}(${n})`,x=(0,pe._)`(typeof ${y} == "function" ? ${T} : ${y}.test(${n}))`;return(0,pe._)`${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]=k(m);h===t&&e.pass(T());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 k(x){let $=x instanceof RegExp?(0,pe.regexpCode)(x):c.code.formats?(0,pe._)`${c.code.formats}${(0,pe.getProperty)(s)}`:void 0,P=r.scopeValue("formats",{key:s,ref:x,code:$});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,pe._)`${P}.validate`]:["string",x,P]}function T(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,pe._)`await ${y}(${n})`}return typeof g=="function"?(0,pe._)`${y}(${n})`:(0,pe._)`${y}.test(${n})`}}}};Lu.default=JI});var g_=S(Uu=>{"use strict";Object.defineProperty(Uu,"__esModule",{value:!0});var GI=h_(),WI=[GI.default];Uu.default=WI});var y_=S(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.contentVocabulary=Zr.metadataVocabulary=void 0;Zr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Zr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var w_=S(Vu=>{"use strict";Object.defineProperty(Vu,"__esModule",{value:!0});var YI=zy(),XI=qy(),QI=m_(),eE=g_(),__=y_(),tE=[YI.default,XI.default,(0,QI.default)(),eE.default,__.metadataVocabulary,__.contentVocabulary];Vu.default=tE});var v_=S(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0});yi.DiscrError=void 0;var b_;(function(e){e.Tag="tag",e.Mapping="mapping"})(b_||(yi.DiscrError=b_={}))});var k_=S(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});var Mr=q(),Bu=v_(),$_=Ws(),rE=Bn(),nE=H(),oE={message:({params:{discrError:e,tagName:t}})=>e===Bu.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Mr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},sE={keyword:"discriminator",type:"object",schemaType:"object",error:oE,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,Mr._)`${r}${(0,Mr.getProperty)(a)}`);t.if((0,Mr._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:Bu.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,Mr._)`${u} === ${m}`),t.assign(c,d(p[m]));t.else(),e.error(!1,{discrError:Bu.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,Mr.Name),m}function f(){var p;let m={},h=y(o),g=!0;for(let T=0;T<i.length;T++){let x=i[T];if(x?.$ref&&!(0,nE.schemaHasRulesButRef)(x,s.self.RULES)){let P=x.$ref;if(x=$_.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,P),x instanceof $_.SchemaEnv&&(x=x.schema),x===void 0)throw new rE.default(s.opts.uriResolver,s.baseId,P)}let $=(p=x?.properties)===null||p===void 0?void 0:p[a];if(typeof $!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(x)),v($,T)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:T}){return Array.isArray(T)&&T.includes(a)}function v(T,x){if(T.const)k(T.const,x);else if(T.enum)for(let $ of T.enum)k($,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function k(T,x){if(typeof T!="string"||T in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[T]=x}}}};Hu.default=sE});var x_=S((dZ,iE)=>{iE.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 Ju=S((oe,Ku)=>{"use strict";Object.defineProperty(oe,"__esModule",{value:!0});oe.MissingRefError=oe.ValidationError=oe.CodeGen=oe.Name=oe.nil=oe.stringify=oe.str=oe._=oe.KeywordCxt=oe.Ajv=void 0;var aE=by(),cE=w_(),uE=k_(),S_=x_(),lE=["/properties"],_i="http://json-schema.org/draft-07/schema",qr=class extends aE.default{_addVocabularies(){super._addVocabularies(),cE.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(uE.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(S_,lE):S_;this.addMetaSchema(t,_i,!1),this.refs["http://json-schema.org/schema"]=_i}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(_i)?_i:void 0)}};oe.Ajv=qr;Ku.exports=oe=qr;Ku.exports.Ajv=qr;Object.defineProperty(oe,"__esModule",{value:!0});oe.default=qr;var dE=Vn();Object.defineProperty(oe,"KeywordCxt",{enumerable:!0,get:function(){return dE.KeywordCxt}});var Fr=q();Object.defineProperty(oe,"_",{enumerable:!0,get:function(){return Fr._}});Object.defineProperty(oe,"str",{enumerable:!0,get:function(){return Fr.str}});Object.defineProperty(oe,"stringify",{enumerable:!0,get:function(){return Fr.stringify}});Object.defineProperty(oe,"nil",{enumerable:!0,get:function(){return Fr.nil}});Object.defineProperty(oe,"Name",{enumerable:!0,get:function(){return Fr.Name}});Object.defineProperty(oe,"CodeGen",{enumerable:!0,get:function(){return Fr.CodeGen}});var fE=Js();Object.defineProperty(oe,"ValidationError",{enumerable:!0,get:function(){return fE.default}});var pE=Bn();Object.defineProperty(oe,"MissingRefError",{enumerable:!0,get:function(){return pE.default}})});var A_=S(mt=>{"use strict";Object.defineProperty(mt,"__esModule",{value:!0});mt.formatNames=mt.fastFormats=mt.fullFormats=void 0;function pt(e,t){return{validate:e,compare:t}}mt.fullFormats={date:pt(E_,Xu),time:pt(Wu(!0),Qu),"date-time":pt(z_(!0),O_),"iso-time":pt(Wu(),T_),"iso-date-time":pt(z_(),R_),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:wE,"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:zE,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:bE,int32:{type:"number",validate:kE},int64:{type:"number",validate:xE},float:{type:"number",validate:I_},double:{type:"number",validate:I_},password:!0,binary:!0};mt.fastFormats={...mt.fullFormats,date:pt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Xu),time:pt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Qu),"date-time":pt(/^\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,O_),"iso-time":pt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,T_),"iso-date-time":pt(/^\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,R_),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};mt.formatNames=Object.keys(mt.fullFormats);function mE(e){return e%4===0&&(e%100!==0||e%400===0)}var hE=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,gE=[0,31,28,31,30,31,30,31,31,30,31,30,31];function E_(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&&mE(r)?29:gE[n])}function Xu(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Gu=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Wu(e){return function(r){let n=Gu.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 Qu(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 T_(e,t){if(!(e&&t))return;let r=Gu.exec(e),n=Gu.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 Yu=/t|\s/i;function z_(e){let t=Wu(e);return function(n){let o=n.split(Yu);return o.length===2&&E_(o[0])&&t(o[1])}}function O_(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function R_(e,t){if(!(e&&t))return;let[r,n]=e.split(Yu),[o,s]=t.split(Yu),i=Xu(r,o);if(i!==void 0)return i||Qu(n,s)}var yE=/\/|:/,_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 wE(e){return yE.test(e)&&_E.test(e)}var P_=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function bE(e){return P_.lastIndex=0,P_.test(e)}var vE=-(2**31),$E=2**31-1;function kE(e){return Number.isInteger(e)&&e<=$E&&e>=vE}function xE(e){return Number.isInteger(e)}function I_(){return!0}var SE=/[^\\]\\Z/;function zE(e){if(SE.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var C_=S(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});Lr.formatLimitDefinition=void 0;var PE=Ju(),ut=q(),Ht=ut.operators,wi={formatMaximum:{okStr:"<=",ok:Ht.LTE,fail:Ht.GT},formatMinimum:{okStr:">=",ok:Ht.GTE,fail:Ht.LT},formatExclusiveMaximum:{okStr:"<",ok:Ht.LT,fail:Ht.GTE},formatExclusiveMinimum:{okStr:">",ok:Ht.GT,fail:Ht.LTE}},IE={message:({keyword:e,schemaCode:t})=>(0,ut.str)`should be ${wi[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ut._)`{comparison: ${wi[e].okStr}, limit: ${t}}`};Lr.formatLimitDefinition={keyword:Object.keys(wi),type:"string",schemaType:"string",$data:!0,error:IE,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 PE.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,ut._)`${f}[${c.schemaCode}]`);e.fail$data((0,ut.or)((0,ut._)`typeof ${p} != "object"`,(0,ut._)`${p} instanceof RegExp`,(0,ut._)`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,ut._)`${i.code.formats}${(0,ut.getProperty)(f)}`:void 0});e.fail$data(d(m))}function d(f){return(0,ut._)`${f}.compare(${r}, ${n}) ${wi[o].fail} 0`}},dependencies:["format"]};var EE=e=>(e.addKeyword(Lr.formatLimitDefinition),e);Lr.default=EE});var Z_=S((io,D_)=>{"use strict";Object.defineProperty(io,"__esModule",{value:!0});var Ur=A_(),TE=C_(),el=q(),N_=new el.Name("fullFormats"),OE=new el.Name("fastFormats"),tl=(e,t={keywords:!0})=>{if(Array.isArray(t))return j_(e,t,Ur.fullFormats,N_),e;let[r,n]=t.mode==="fast"?[Ur.fastFormats,OE]:[Ur.fullFormats,N_],o=t.formats||Ur.formatNames;return j_(e,o,r,n),t.keywords&&(0,TE.default)(e),e};tl.get=(e,t="full")=>{let n=(t==="fast"?Ur.fastFormats:Ur.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function j_(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,el._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}D_.exports=io=tl;Object.defineProperty(io,"__esModule",{value:!0});io.default=tl});import{existsSync as uO}from"node:fs";import{homedir as Bw}from"node:os";import{isAbsolute as lO,join as Ii,sep as dO}from"node:path";import{fileURLToPath as fO}from"node:url";import uh from"node:process";var R={};wl(R,{BIGINT_FORMAT_RANGES:()=>wo,CONSTANT_CATCH:()=>Ol,Class:()=>Ri,NUMBER_FORMAT_RANGES:()=>Gr,aborted:()=>rt,allowsEval:()=>Di,assert:()=>ob,assertEqual:()=>Qw,assertIs:()=>rb,assertNever:()=>nb,assertNotEqual:()=>eb,assignProp:()=>Le,attachSchema:()=>Wr,base64ToUint8Array:()=>El,base64urlToUint8Array:()=>kb,cached:()=>hr,captureStackTrace:()=>yo,cleanEnum:()=>$b,cleanRegex:()=>Jr,clone:()=>tt,cloneDef:()=>ab,codePointLength:()=>Yr,constantCatch:()=>Rl,createTransparentProxy:()=>pb,defineLazy:()=>$l,defineLazyInternal:()=>J,derived:()=>Pb,esc:()=>Ni,escapeRegex:()=>yt,explicitlyAborted:()=>qi,extend:()=>gb,finalizeIssue:()=>nt,floatSafeRemainder:()=>Ci,getElementAtPath:()=>cb,getEnumValues:()=>pr,getLengthableOrigin:()=>Xr,getParsedType:()=>fb,getSizableOrigin:()=>Il,hexToUint8Array:()=>Sb,hide:()=>$o,installLazyProp:()=>Ob,isObject:()=>Jt,isPlainObject:()=>Tt,issue:()=>yr,joinValues:()=>go,jsonStringifyReplacer:()=>mr,members:()=>Li,merge:()=>_b,mergeDefs:()=>gt,normalizeParams:()=>O,nullish:()=>Ai,numKeys:()=>db,objectClone:()=>sb,omit:()=>hb,optionalKeys:()=>Mi,own:()=>Et,parsedType:()=>Fi,partial:()=>wb,pick:()=>mb,prefixIssues:()=>_t,primitiveTypes:()=>zl,promiseAllObject:()=>ub,propertyKeyTypes:()=>Zi,randomString:()=>lb,rawShape:()=>gr,required:()=>bb,safeExtend:()=>yb,shallowClone:()=>Sl,sizeCaps:()=>vo,slugify:()=>ji,stringifyPrimitive:()=>_o,toZod:()=>tb,uint8ArrayToBase64:()=>Tl,uint8ArrayToBase64url:()=>xb,uint8ArrayToHex:()=>zb,unwrapMessage:()=>fr});function Qw(e){return e}function eb(e){return e}function tb(){return e=>e}function rb(e){}function nb(e){throw new Error("Unexpected value in exhaustive check")}function ob(e){}function pr(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 go(e,t="|"){return e.map(r=>_o(r)).join(t)}function mr(e,t){return typeof t=="bigint"?t.toString():t}var Oi=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 hr(e){return new Oi(e)}function Ai(e){return e==null}function Jr(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Ci(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 vl=Symbol("evaluating");function $l(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==vl)return n===void 0&&(n=vl,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function sb(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Le(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function gr(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function ht(e){return gr(e._zod.def)??e._zod.def.shape}function kl(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return Le(this,t,n),n},enumerable:!0,configurable:!0})}function xl(e,t,r){t in e?Le(e,t,r):e[t]=r}function Kt(e,t,r,n){let o=ht(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?kl(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):xl(e,s,n?n(i.value,s):i.value))}}function ib(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?kl(e,r,()=>t[r]):xl(e,r,n.value))}}function gt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function ab(e){return gt(e._zod.def)}function cb(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function ub(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 lb(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ni(e){return JSON.stringify(e)}function ji(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var yo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Jt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Di=hr(()=>{if(Ce.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function Tt(e){if(Jt(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Jt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Sl(e){return Tt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function db(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var fb=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}`)}},Zi=new Set(["string","number","symbol"]),zl=new Set(["string","number","bigint","boolean","symbol","undefined"]);function yt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tt(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function O(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 pb(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 _o(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Mi(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var Gr={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]},wo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function mb(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 Kt(s,e,bo(e,t)),tt(e,gt(r,{shape:s,checks:[]}))}function bo(e,t){let r=ht(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 hb(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(bo(e,t)),i={};return Kt(i,e,Reflect.ownKeys(ht(e)).filter(a=>!s.has(a))),tt(e,gt(r,{shape:i,checks:[]}))}function gb(e,t){if(!Tt(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=ht(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 tt(e,gt(e._zod.def,{shape:Pl(e,t)}))}function Pl(e,t){let r={};return Kt(r,e,Reflect.ownKeys(ht(e))),ib(r,t),r}function yb(e,t){if(!Tt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return tt(e,gt(e._zod.def,{shape:Pl(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={};Kt(r,e,Reflect.ownKeys(ht(e))),Kt(r,t,Reflect.ownKeys(ht(t)));let n=gt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return tt(e,n)}function wb(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(bo(t,r)):void 0,c={};return Kt(c,t,Reflect.ownKeys(ht(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),tt(t,gt(t._zod.def,{shape:c,checks:[]}))}function bb(e,t,r){let n=r?new Set(bo(t,r)):void 0,o={};return Kt(o,t,Reflect.ownKeys(ht(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),tt(t,gt(t._zod.def,{shape:o}))}function rt(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 qi(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 _t(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function fr(e){return typeof e=="string"?e:e?.message}function vo(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 Wr(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function nt(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:fr(e.inst?._zod.def?.error?.(e))??fr(s?.(e))??fr(t?.error?.(e))??fr(r.customError?.(e))??fr(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 Il(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var vb=/[\uD800-\uDBFF]/;function Yr(e){let t=e.length;if(!vb.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 Xr(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Fi(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 yr(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function $b(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function El(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 Tl(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function kb(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return El(t+r)}function xb(e){return Tl(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Sb(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 zb(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var Ri=class{constructor(...t){}};function Li(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Ib(e,r,n.value)}}function Et(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function $o(e,t,r){return Et(e,t,r,!1)}function Pb(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Et(this,r,n(this))},set(o){Et(this,r,o)}})}return t}function Ib(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Et(this,t,r.bind(this))},set(n){Et(this,t,n)}})}function Eb(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var Ti,It=!1,Tb={configurable:!0,get(){It=!0}};function J(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&Ti!==e._zod){Ti=void 0;return}Ti=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,Tb);let o=It;It=!1;try{let s=r(this);return It?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),It=It||o,s}catch(s){throw delete this[t],It=It||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Ob(e,t,r,n){let o=Eb(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 Ol="~constantCatch";function Rl(e){let t=()=>e;return t[Ol]=!0,t}var Al;var Ui={value:void 0,enumerable:!1},Cl="captureStackTrace"in Error?Error:null;function Rb(e){let t=Cl;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Cl=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{Ui.value=new s(p);try{Object.defineProperty(f,"_zod",Ui)}finally{Ui.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),Li(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?Rb(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 ot=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},_r=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Al=globalThis).__zod_globalConfig??(Al.__zod_globalConfig={});var Ce=globalThis.__zod_globalConfig;function Ue(e){return e&&Object.assign(Ce,e),Ce}function Ab(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,mr,2)),e.message}function Cb(e){this._zod.message=e}var Nb={get:Ab,set:Cb,enumerable:!0,configurable:!0},Bi={value:void 0,enumerable:!1},Nl=new WeakSet([Object.prototype,Error.prototype]),jl=(e,t)=>{e.name="$ZodError",Bi.value=t,Object.defineProperty(e,"issues",Bi),Bi.value=void 0,Object.defineProperty(e,"message",Nb);let r=Object.getPrototypeOf(e);Nl.has(r)||(Nl.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})}}))},Dl=b("$ZodError",jl),Zl=b("$ZodError",jl,void 0,{Parent:Error});function jb(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 Ml(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?jb(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function ql(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 ko(e,t){return{callee:t?.callee??e,Err:t?.Err}}var xo=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 ot;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>nt(u,i,Ue())));throw yo(c,s?.callee??t),c}return a.value};return t};var So=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=>nt(u,i,Ue())));throw yo(c,s?.callee??t),c}return a.value};return t};var Qr=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 ot;return s.issues.length?Fl(e,s.issues,o):{success:!0,data:s.value}},Hi=Qr(Zl);function Fl(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>nt(o,r,Ue()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var zo=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?Fl(e,s.issues,o):{success:!0,data:s.value}};var Zb=Symbol.for("zod.compile.invalid"),Mb=Symbol.for("zod.compile.fallback"),Po=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==Zb)return!0;if(n.definite===!0&&r===void 0)return!1}return qb(e,t,r)});function qb(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[Mb]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new ot;return s.issues.length===0}var Io=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},Ll=e=>{let t=xo(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,ko(r,i))};return r};var Ul=e=>{let t=xo(e),r=(n,o,s,i)=>t(n,o,s,ko(r,i));return r};var Vl=e=>{let t=So(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,ko(r,i))};return r};var Bl=e=>{let t=So(e),r=async(n,o,s,i)=>await t(n,o,s,ko(r,i));return r};var Hl=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Qr(e)(t,r,o)};var Kl=e=>(t,r,n)=>Qr(e)(t,r,n);var Jl=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return zo(e)(t,r,o)};var Gl=e=>async(t,r,n)=>zo(e)(t,r,n);var Wl=/^[cC][0-9a-z]{6,}$/,Yl=/^[0-9a-z]+$/,Xl=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Ql=/^[0-9a-vA-V]{20}$/,ed=/^[A-Za-z0-9]{27}$/,td=/^[a-zA-Z0-9_-]{21}$/;function rd(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var nd=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var od=/^([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})$/,Ji=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 sd=/^(?:[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 Fb="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function id(){return new RegExp(Fb,"u")}var ad=/^(?:(?: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])$/,cd=/^(([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 ud=/^((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])$/,ld=/^(([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])$/,dd=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fd=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var pd=/^https?$/,md=/^\+[1-9]\d{6,14}$/;var hd="(?:(?:\\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 Lb(e){return new RegExp(`^${e}$`)}var gd=Lb(hd);function Ki(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 yd(e){return new RegExp(`^${Ki(e)}$`)}function _d(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${Ki({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${Ki({precision:e.precision})}`:r;return new RegExp(`^${hd}T(?:${n})$`)}var wd=/^[\s\S]{0,}$/;var Gi=/^-?\d+$/,en=/^-?\d+(?:\.\d+)?$/,bd=/^(?:true|false)$/i,vd=/^null$/i;var $d=/^[^A-Z]*$/,kd=/^[^a-z]*$/;var ye=b("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Wi=e=>{let t=e.value;return!Ai(t)&&t.length!==void 0},Eo={number:"number",bigint:"bigint",object:"date"},Yi=b("$ZodCheckLessThan",(e,t)=>{ye.init(e,t);let r=Eo[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:Eo[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})}}),Xi=b("$ZodCheckGreaterThan",(e,t)=>{ye.init(e,t);let r=Eo[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:Eo[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})}}),xd=b("$ZodCheckMultipleOf",(e,t)=>{ye.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):Ci(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})}}),Sd=b("$ZodCheckNumberFormat",(e,t)=>{ye.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=Gr[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 zd=b("$ZodCheckMaxLength",(e,t)=>{var r;ye.init(e,t),(r=e._zod.def).when??(r.when=Wi),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?Yr(o):s)<=t.maximum)return;let a=Xr(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Pd=b("$ZodCheckMinLength",(e,t)=>{var r;ye.init(e,t),(r=e._zod.def).when??(r.when=Wi),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?Yr(o):s)>=t.minimum)return;let a=Xr(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Id=b("$ZodCheckLengthEquals",(e,t)=>{var r;ye.init(e,t),(r=e._zod.def).when??(r.when=Wi),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?Yr(o):s;if(i===t.length)return;let a=Xr(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})}}),rn=b("$ZodCheckStringFormat",(e,t)=>{var r,n;ye.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=()=>{})}),Ed=b("$ZodCheckRegex",(e,t)=>{rn.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})}}),Td=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=$d),rn.init(e,t)}),Od=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=kd),rn.init(e,t)}),Rd=b("$ZodCheckIncludes",(e,t)=>{ye.init(e,t);let r=yt(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})}}),Ad=b("$ZodCheckStartsWith",(e,t)=>{ye.init(e,t);let r=new RegExp(`^${yt(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})}}),Cd=b("$ZodCheckEndsWith",(e,t)=>{ye.init(e,t);let r=new RegExp(`.*${yt(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 Nd=b("$ZodCheckOverwrite",(e,t)=>{ye.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var To=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 Dd={major:4,minor:6,patch:7};var ee=b("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Dd;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=rt(a),d;for(let f of c){if(f._zod.def.when){if(qi(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 ot;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(Wr(a.issues,p,e),l||(l=rt(a,p)))});else{if(a.issues.length===p)continue;Wr(a.issues,p,e),l||(l=rt(a,p))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(rt(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ot;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 ot;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return $o(this,"~standard",ea(this))},set"~standard"(e){Et(this,"~standard",e)}}),Jd=(e,t)=>e.issues.length?{issues:e.issues.map(r=>nt(r,t,Ue()))}:{value:e.value};async function Ub(e,t){let r={async:!0};return Jd(await e._zod.run({value:t,issues:[]},r),r)}function ea(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Jd(n,r)}catch{}return Ub(e,t)},vendor:"zod",version:1}}var Co=b("$ZodString",(e,t)=>{ee.init(e,t),e._zod.pattern=t.pattern??wd,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}}),te=b("$ZodStringFormat",(e,t)=>{rn.init(e,t),Co.init(e,t)}),Gd=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=od),te.init(e,t)}),Wd=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=Ji(n))}else t.pattern??(t.pattern=Ji());te.init(e,t)}),Yd=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=sd),te.init(e,t)}),Xd=1,Ro=2;function Qd(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Vb(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Qd(e)||Ro:Bb(e,t)}function Bb(e,t){if(!t.normalize&&t.protocol?.source===pd.source&&!/^https?:\/\//i.test(e))return Xd;try{if(typeof URL<"u"){let r=URL;if(typeof r.parse=="function")return r.parse(e)??Ro}return new URL(e)}catch{return Ro}}var Hb=/[\t\n\r]/g;function Zd(e){return e.replace(Hb,"")}function Kb(e,t){return t.lastIndex=0,t.test(e.hostname)}function Jb(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var ef=b("$ZodURL",(e,t)=>{te.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=Vb(n,t);if(o===Xd){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Ro){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}if(o===!0){r.value=Zd(n);return}t.hostname&&!Kb(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&&!Jb(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:Zd(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),tf=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=id()),te.init(e,t)}),rf=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?td:rd(t.length)),te.init(e,t)}),nf=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Wl),te.init(e,t)}),of=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Yl),te.init(e,t)}),sf=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Xl),te.init(e,t)}),af=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ql),te.init(e,t)}),cf=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=ed),te.init(e,t)}),uf=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=_d(t)),te.init(e,t)}),lf=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=gd),te.init(e,t)}),df=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=yd(t)),te.init(e,t)}),ff=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=nd),te.init(e,t)}),pf=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=ad),te.init(e,t)}),Gb=/^[0-9a-fA-F:.]+$/;function mf(e){return Gb.test(e)?Qd(`http://[${e}]`):!1}var hf=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=cd),te.init(e,t),e._zod.check=r=>{mf(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var gf=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ud),te.init(e,t)});function Wb(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:mf(r)}var yf=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ld),te.init(e,t),e._zod.check=r=>{Wb(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function _f(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var ta=/^[0-9a-zA-Z+/]*={0,2}$/,wf=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ta),te.init(e,t),e._zod.check=r=>{_f(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),No=/^[A-Za-z0-9_-]*$/;function Yb(e){if(!No.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return _f(r)}var bf=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=No),te.init(e,t),e._zod.check=r=>{Yb(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),vf=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=md),te.init(e,t)});function Xb(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 $f=b("$ZodJWT",(e,t)=>{te.init(e,t),e._zod.check=r=>{Xb(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var ra=b("$ZodNumber",(e,t)=>{ee.init(e,t),e._zod.pattern=en,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}}),kf=b("$ZodNumberFormat",(e,t)=>{Sd.init(e,t),ra.init(e,t)}),xf=b("$ZodBoolean",(e,t)=>{ee.init(e,t),e._zod.pattern=bd,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 Sf=b("$ZodNull",(e,t)=>{ee.init(e,t),e._zod.pattern=vd,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 zf=b("$ZodUnknown",(e,t)=>{ee.init(e,t),e._zod.parse=r=>r}),Pf=b("$ZodNever",(e,t)=>{ee.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Qb(e,t){let r=vo(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 vo(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,Wr(s.issues,l,e),s}}return o(s,i)}}var ev=e=>Array.isArray(e)?e.length:-1;function Md(e,t,r){e.issues.length&&t.issues.push(..._t(r,e.issues)),t.value[r]=e.value}var If=b("$ZodArray",(e,t)=>{ee.init(e,t);let r=Ce.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=>Md(d,n,c)));else if(Md(l,n,c),a&&l.issues.length!==0&&rt(l))break}return i.length?Promise.all(i).then(()=>n):n},Qb(e,ev)});function Ao(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(..._t(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 tv=[];function Ef(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:tv,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=Mi(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Tf(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(rt(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=>Ao(g,r,m,t,d,f))):Ao(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 rv=b("$ZodObject",(e,t)=>{ee.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=hr(()=>Ef(t));J(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)||Le(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=Jt,i=t.catchall,a,c=Ce.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(rt(u,h))break;h=u.issues.length}if(g==="__proto__")continue;let y=p[g],v=y._zod.optin,k=y._zod.optout,T=y._zod.run({value:d[g],issues:[]},l);T instanceof Promise?f.push(T.then(x=>Ao(x,u,g,d,v,k))):Ao(T,u,g,d,v,k)}return i?Tf(f,d,u,l,o.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),Of=b("$ZodObjectJIT",(e,t)=>{rv.init(e,t);let r=e._zod.parse,n=hr(()=>Ef(t)),o=Ce.memoizer,s=p=>{let m=n.value,h=m.symbolKeys,g=new To(["payload","ctx"],{shape:p,inst:e,memo:o,syms:h}),y=x=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,v=(x,$)=>`
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
15
  let ${x}_ab = false;
16
16
  for (let i = 0; i < ${x}.issues.length; i++) {
17
17
  const iss = ${x}.issues[i];
18
- iss.path = iss.path ? [${$}, ...iss.path] : [${$}];
18
+ iss.path = iss.path ? [${R}, ...iss.path] : [${R}];
19
19
  payload.issues.push(iss);
20
20
  if (iss.continue !== true) ${x}_ab = true;
21
21
  }
22
22
  if (${x}_ab && ctx && ctx.abortEarly) {
23
23
  payload.value = newResult;
24
24
  return payload;
25
- }`;g.write("const input = payload.value;");let k=Object.create(null),T=0;for(let x of m.allKeys)k[x]=`key_${T++}`;g.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(let x of m.allKeys){if(x==="__proto__")continue;let $=k[x],P=typeof x=="symbol"?`syms[${h.indexOf(x)}]`:Ni(x),F=`${P} in input`,C=p[x],D=C?._zod?.optin,de=D!==void 0,M=C?._zod?.optout==="optional";if(g.write(`const ${$} = ${y(P)};`),de&&M){let me=D==="optional"?`${$}_present`:`${$}.value !== undefined || ${$}_present`;g.write(`
26
- const ${$}_present = ${F};
27
- if (!${$}.issues.length || ${$}_present) {
28
- if (${$}.issues.length) {${v($,P)}
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 (${me}) {
32
- newResult[${P}] = ${$}.value;
31
+ if (${ae}) {
32
+ newResult[${k}] = ${R}.value;
33
33
  }
34
34
  }
35
35
 
36
- `)}else de?(g.write(`
37
- if (${$}.issues.length) {${v($,P)}
36
+ `)}else U?(g.write(`
37
+ if (${R}.issues.length) {${v(R,k)}
38
38
  }
39
- `),D==="defaulted"?g.write(`newResult[${P}] = ${$}.value;`):g.write(`
40
- if (${$}.value !== undefined || ${F}) {
41
- newResult[${P}] = ${$}.value;
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 ${$}_present = ${F};
45
- if (${$}.issues.length) {${v($,P)}
44
+ const ${R}_present = ${E};
45
+ if (${R}.issues.length) {${v(R,k)}
46
46
  }
47
- if (!${$}_present && !${$}.issues.length) {
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: [${P}]
52
+ path: [${k}]
53
53
  });
54
54
  if (ctx && ctx.abortEarly) {
55
55
  payload.value = newResult;
@@ -57,35 +57,35 @@ ${r.join(`
57
57
  }
58
58
  }
59
59
 
60
- if (${$}_present) {
61
- newResult[${P}] = ${$}.value;
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=Jt,c=!Ce.jitless,l=c&&Di.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?Tf([],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 qd(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=>!rt(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=>nt(i,n,Ue())))}),t)}var na=b("$ZodUnion",(e,t)=>{ee.init(e,t),J(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),J(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),J(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)))}),J(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=>Jr(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=>qd(a,n,e,o)):qd(i,n,e,o)}});function nv(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 Rf=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,na.init(e,t);let r=e._zod.parse;J(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)||Le(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=gr(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=hr(()=>nv(t));e._zod.parse=(o,s)=>{let i=o.value;if(!Jt(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)}}),Af=b("$ZodIntersection",(e,t)=>{ee.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])=>Fd(r,c,u)):Fd(r,s,i)}});function Qi(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(Tt(e)&&Tt(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=Qi(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=Qi(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 Fd(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=Qi(t.value,r.value);if(!c.valid){if(rt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Cf=b("$ZodRecord",(e,t)=>{ee.init(e,t);let r=Ce.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Tt(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=>nt(m,o,Ue())),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(..._t(l,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(..._t(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"&&en.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=>nt(m,o,Ue())),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(..._t(u,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(..._t(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 Nf=b("$ZodEnum",(e,t)=>{ee.init(e,t);let r=pr(t.entries),n=new Set(r);e._zod.values=n,J(e,"pattern",o=>{let s=pr(o.def.entries).filter(i=>Zi.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>yt(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}}),jf=b("$ZodLiteral",(e,t)=>{ee.init(e,t);let r=new Set(t.values);e._zod.values=r,J(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?yt(s):s?yt(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 Df=b("$ZodTransform",(e,t)=>{ee.init(e,t),e._zod.optin="optional",Ce.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new _r(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 ot;return r.value=o,r}});function Ld(e,t){return e.value=t.issues.length?void 0:t.value,e}var oa=b("$ZodOptional",(e,t)=>{ee.init(e,t),J(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",J(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),J(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Jr(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=>Ld(r,s)):Ld(r,o)}return t.innerType._zod.run(r,n)}}),Zf=b("$ZodExactOptional",(e,t)=>{oa.init(e,t),J(e,"values",r=>r.def.innerType._zod.values),J(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Mf=b("$ZodNullable",(e,t)=>{ee.init(e,t),J(e,"optin",r=>r.def.innerType._zod.optin),J(e,"optout",r=>r.def.innerType._zod.optout),J(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${Jr(n.source)}|null)$`):void 0}),J(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)}),qf=b("$ZodDefault",(e,t)=>{ee.init(e,t),e._zod.optin="defaulted",J(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=>Ud(s,t)):Ud(o,t)}});function Ud(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Ff=b("$ZodPrefault",(e,t)=>{ee.init(e,t),e._zod.optin="defaulted",J(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))}),Lf=b("$ZodNonOptional",(e,t)=>{ee.init(e,t),J(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=>Vd(s,e)):Vd(o,e)}});function Vd(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 Bd(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>nt(o,n,Ue()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Uf=b("$ZodCatch",(e,t)=>{ee.init(e,t),J(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),J(e,"optout",r=>r.def.innerType._zod.optout),J(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=>Bd(r,s,t,n)):Bd(r,o,t,n)}});var sa=b("$ZodPipe",(e,t)=>{ee.init(e,t),J(e,"values",r=>r.def.in._zod.values),J(e,"optin",r=>r.def.in._zod.optin),J(e,"optout",r=>r.def.out._zod.optout),J(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=>Oo(i,t.in,n)):Oo(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Oo(s,t.out,n)):Oo(o,t.out,n)}});function Oo(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 Vf=b("$ZodPreprocess",(e,t)=>{sa.init(e,t)}),Bf=b("$ZodReadonly",(e,t)=>{ee.init(e,t),J(e,"propValues",r=>r.def.innerType._zod.propValues),J(e,"values",r=>r.def.innerType._zod.values),J(e,"optin",r=>r.def.innerType?._zod?.optin),J(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(Hd):Hd(o)}});function Hd(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Hf=b("$ZodCustom",(e,t)=>{ye.init(e,t),ee.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=>Kd(s,r,n,e));Kd(o,r,n,e)}});function Kd(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(yr(o))}}var aa=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},ca="~memo",Kf=[];function Jf(e){return e!==null&&typeof e=="object"}function ia(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var Gf=new WeakMap,nn=0,Zo=1,on=2;function Mo(e,t,r){let n=Gf.get(e);if(n!==void 0)return n?on:nn;if(t.has(e))return on;t.add(e);let o=nn,s=l=>{if(o!==on&&l?._zod){let d=Mo(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let f=nn;for(let p of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,p);if(d&&!m.enumerable)continue;let h=m.get?Zo:m.value?._zod?Mo(m.value,t,r):nn;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=gr(c);a(l?i(l,!0):Zo),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?Mo(l,t,!1):Zo);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),ov(e,o)}function ov(e,t){return t!==Zo&&Gf.set(e,t===on),t}function sv(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var jo,Do=[],iv={alloc(e,t,r){let n=jo;if(!n)return r;jo=void 0;let o={value:r,issues:null};return n.set(t.value,o),Do.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"&&av(s,o.value))throw new aa;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=Mo(e,new Set,!1);if(y===nn)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);y===on||n?r=!0:n=!0}let l=c.value;if(!Jf(l))return i(c,u);let d=u[ca];d||(d={buckets:new WeakMap,backEdges:void 0},u[ca]=d);let f;o===u?f=s:(f=sv(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(...ia(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;jo=f;let m=Do.length,h=i(c,u);jo=void 0;let g=Do.length>m?Do.pop():void 0;return h instanceof Promise?h.then(y=>(g&&(g.issues=y.issues.length?ia(y.issues):Kf),y)):(g&&(g.issues=h.issues.length?ia(h.issues):Kf),h)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function Wf(){return iv}function av(e,t){let r=e[ca]?.backEdges;return r!==void 0&&Jf(t)&&r.has(t)}var cv=()=>{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=Fi(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 ${_o(s.values[0])}`:`Invalid option: expected one of ${go(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":""}: ${go(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 Yf(){return{localeError:cv()}}var Xf;var ua=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 uv(){return new ua}(Xf=globalThis).__zod_globalRegistry??(Xf.__zod_globalRegistry=uv());var Gt=globalThis.__zod_globalRegistry;function Qf(e){return e.checks&&(e.checks=[...e.checks]),e}function ep(e,t){return new e(Qf({type:"string",...O(t)}))}function tp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...O(t)})}function rp(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...O(t)})}function np(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...O(t)})}function op(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...O(t)})}function sp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...O(t)})}function ip(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...O(t)})}function ap(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...O(t)})}function cp(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...O(t)})}function up(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...O(t)})}function lp(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...O(t)})}function dp(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...O(t)})}function fp(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...O(t)})}function pp(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...O(t)})}function mp(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...O(t)})}function hp(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...O(t)})}function gp(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...O(t)})}function yp(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...O(t)})}function _p(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...O(t)})}function wp(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...O(t)})}function bp(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...O(t)})}function vp(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...O(t)})}function $p(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...O(t)})}function qo(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...O(t)})}function Fo(e,t){return new e({type:"string",format:"date",check:"string_format",...O(t)})}function Lo(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...O(t)})}function Uo(e,t){return new e({type:"string",format:"duration",check:"string_format",...O(t)})}function kp(e,t){return new e(Qf({type:"number",checks:[],...O(t)}))}function xp(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...O(t)})}function Sp(e,t){return new e({type:"boolean",...O(t)})}function zp(e,t){return new e({type:"null",...O(t)})}function Pp(e){return new e({type:"unknown"})}function Ip(e,t){return new e({type:"never",...O(t)})}function Vo(e,t){return new Yi({check:"less_than",...O(t),value:e,inclusive:!1})}function sn(e,t){return new Yi({check:"less_than",...O(t),value:e,inclusive:!0})}function Bo(e,t){return new Xi({check:"greater_than",...O(t),value:e,inclusive:!1})}function an(e,t){return new Xi({check:"greater_than",...O(t),value:e,inclusive:!0})}function Ho(e,t){return new xd({check:"multiple_of",...O(t),value:e})}function Ko(e,t){return new zd({check:"max_length",...O(t),maximum:e})}function wr(e,t){return new Pd({check:"min_length",...O(t),minimum:e})}function Jo(e,t){return new Id({check:"length_equals",...O(t),length:e})}function la(e,t){return new Ed({check:"string_format",format:"regex",...O(t),pattern:e})}function da(e){return new Td({check:"string_format",format:"lowercase",...O(e)})}function fa(e){return new Od({check:"string_format",format:"uppercase",...O(e)})}function pa(e,t){return new Rd({check:"string_format",format:"includes",...O(t),includes:e})}function ma(e,t){return new Ad({check:"string_format",format:"starts_with",...O(t),prefix:e})}function ha(e,t){return new Cd({check:"string_format",format:"ends_with",...O(t),suffix:e})}function Ot(e){return new Nd({check:"overwrite",tx:e})}function ga(e){return Ot(t=>t.normalize(e))}function ya(){return Ot(e=>e.trim())}function _a(){return Ot(e=>e.toLowerCase())}function wa(){return Ot(e=>e.toUpperCase())}function ba(){return Ot(e=>ji(e))}function Ep(e,t,r){return new e({type:"array",element:t,...O(r)})}function Tp(e,t,r){let n=O(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Op(e,t,r){return new e({type:"custom",check:"custom",fn:t,...O(r)})}function Rp(e,t){let r=lv(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(yr(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(yr(s))}},e(n.value,n)),t);return r}function lv(e,t){let r=new ye({check:"custom",...O(t)});return r._zod.check=e,r}function cn(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&Le(e,n,r[n]);return e}function $a(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??Gt,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 wt(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 fe(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),fe(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&cn(i.schema,c),t.io==="input"&&Ee(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 Ap(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function ka(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}/${Ap(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+Ap(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 jp(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;jp(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 Dp=new Set(["type","properties","required","additionalProperties"]),Cp=["oneOf","anyOf"];function Np(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function va(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Dp.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]??Np(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:va(a)??{allOf:a};Le(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=Np(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 dv(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Dp)if(o in e)return;let r=t.filter(o=>Cp.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=va(t);else{let o=r[0],s=Cp.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=>va([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,cn(e,n))}function xa(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)):cn(u,m),cn(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())jp(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)??[])dv(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)}cn(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,Le(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:un(t,"input",e.processors),output:un(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ee(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 Ee(n.element,r);if(n.type==="set")return Ee(n.valueType,r);if(n.type==="lazy")return Ee(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 Ee(n.innerType,r);if(n.type==="intersection")return Ee(n.left,r)||Ee(n.right,r);if(n.type==="record"||n.type==="map")return Ee(n.keyType,r)||Ee(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ee(n.in,r)||Ee(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Ee(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Ee(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Ee(o,r))return!0;return!!(n.rest&&Ee(n.rest,r))}return!1}var Zp=(e,t={})=>r=>{let n=$a({...r,processors:t});return fe(e,n),ka(n,e),xa(n,e)},un=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=$a({...o??{},target:s,io:t,processors:r});return fe(e,i),ka(i,e),xa(i,e)};var br=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},vr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Mp=(e,t)=>{br(e,"minimum",t),vr(e,"maximum",t)},Up=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Vp=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Bp=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},Hp=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},qp=(e,t)=>br(e,"minimum",t.minimum),Fp=(e,t)=>vr(e,"maximum",t.maximum),Lp=e=>(t,r)=>{Hp(t,r.format);let[n,o]=e[r.format];br(t,"minimum",n),vr(t,"maximum",o)},fv={greater_than:(e,t)=>br(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>vr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Up(e,t.value),number_format:Lp(Gr),bigint_format:Lp(wo),min_length:qp,max_length:Fp,length_equals:(e,t)=>Mp(e,t.length),min_size:qp,max_size:Fp,size_equals:(e,t)=>Mp(e,t.size),string_format:(e,t)=>{Hp(e,t.format),t.pattern&&Vp(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)=>Bp(e,t.mime)};function Ke(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)fv[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&br(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&br(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&vr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&vr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Up(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Bp(t,o.mime);for(let s of o.patterns??[])Vp(t,s);return t}var pv={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},mv=new Map([[ta,dd],[No,fd]]),Kp=e=>mv.get(e)??e,Jp=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=Ke(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=pv[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(Kp);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}))])}},Gp=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=Ke(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)):wt(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}))])}},Wp=(e,t,r,n)=>{r.type="boolean"};var Yp=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Xp=(e,t,r,n)=>{r.not={}};var Qp=(e,t,r,n)=>{};var em=(e,t,r,n)=>{let o=e._zod.def,s=pr(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},tm=(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(wt(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(wt(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 rm=(e,t,r,n)=>{wt(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var nm=(e,t,r,n)=>{wt(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var om=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=Ke(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=fe(s.element,t,{...n,path:[...n.path,"items"]})};function Go(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Go(t.out):t.type==="catch"?Go(t.innerType):e._zod.optin}var sm=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&wt(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let u in i)Le(o.properties,u,fe(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"?Go(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=fe(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},im=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>fe(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},am=(e,t,r,n)=>{let o=e._zod.def,s=fe(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=fe(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 Sa(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=Sa(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=>Sa(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")?en:Gi).source)),p}var za=new WeakMap;function hv(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 za.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=Sa(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 cm=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=Ke(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=fe(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)Le(o.patternProperties,Kp(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=fe(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=za.get(t);l||(l=[],za.set(t,l),t.deferred.push(()=>hv(t))),l.push(e)}o.additionalProperties=fe(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&Go(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))}},um=(e,t,r,n)=>{let o=e._zod.def,s=fe(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"}]},lm=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},Pa=Symbol();function dm(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(wt(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),Pa):JSON.parse(i)}var fm=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=dm(o.defaultValue,e,t,r,n);i!==Pa&&(r.default=i)},pm=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=dm(o.defaultValue,e,t,r,n);i!==Pa&&(r._prefault=i)},mm=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{wt(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},hm=(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;fe(i,t,n);let a=t.seen.get(e);a.ref=i},gm=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var Ia=(e,t,r,n)=>{let o=e._zod.def;fe(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};var ym=new WeakSet([Object.prototype,Error.prototype]);function Wo(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 xv=(e,t)=>{Dl.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);ym.has(r)||(ym.add(r),Wo(r,"format",n=>o=>ql(n,o)),Wo(r,"flatten",n=>o=>Ml(n,o)),Wo(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,mr,2)}),Wo(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,mr,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Ve=b("ZodError",xv,void 0,{Parent:Error});var _m=xo(Ve),wm=So(Ve),bm=Qr(Ve),vm=zo(Ve),$m=Ll(Ve),km=Ul(Ve),xm=Vl(Ve),Sm=Bl(Ve),zm=Hl(Ve),Pm=Kl(Ve),Im=Jl(Ve),Em=Gl(Ve);function zv(){Ce.localeError||Ue(Yf())}function Xo(){Ce.memoizer||Ue({memoizer:Wf()})}var ce=b("ZodType",(e,t)=>(zv(),ee.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(R.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 tt(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(h0(e,t))},superRefine(e,t){return this.check(g0(e,t))},overwrite(e){return this.check(Ot(e))},optional(){return ae(this)},exactOptional(){return n0(this)},nullable(){return Rm(this)},nullish(){return ae(Rm(this))},nonoptional(e){return u0(this,e)},array(){return V(this)},or(e){return re([this,e])},and(e){return Qo(this,e)},transform(e){return Am(this,Mm(e))},default(e){return i0(this,e)},prefault(e){return c0(this,e)},catch(e){return d0(this,e)},pipe(e){return Am(this,e)},readonly(){return m0(this)},describe(e){let t=this.clone();return Gt.add(t,{description:e}),t},meta(...e){if(e.length===0)return Gt.get(this);let t=this.clone();return Gt.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 R.hide(this,"~standard",{...ea(this),jsonSchema:{input:un(this,"input"),output:un(this,"output")}})},set"~standard"(e){R.own(this,"~standard",e)},parse:function e(t,r){return _m(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await wm(this,t,r,{callee:e})},safeParse(e,t){return bm(this,e,t)},async safeParseAsync(e,t){return vm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){R.own(this,"spa",e)},validate(e,t){return Po(this,e,t)},validateAsync(e,t){return Io(this,e,t)},encode:function e(t,r){return $m(this,t,r,{callee:e})},decode:function e(t,r){return km(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await xm(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Sm(this,t,r,{callee:e})},safeEncode(e,t){return zm(this,e,t)},safeDecode(e,t){return Pm(this,e,t)},async safeEncodeAsync(e,t){return Im(this,e,t)},async safeDecodeAsync(e,t){return Em(this,e,t)},toJSONSchema(e){return Zp(this,{})(e)},get description(){return Gt.get(this)?.description},get _def(){return this._zod.def}}),Cm=b("_ZodString",(e,t)=>{Co.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jp(e,r,n,o)},R.derived({format:e=>Ke(e).format??null,minLength:e=>Ke(e).minimum??null,maxLength:e=>Ke(e).maximum??null},{regex(...e){return this.check(la(...e))},includes(...e){return this.check(pa(...e))},startsWith(...e){return this.check(ma(...e))},endsWith(...e){return this.check(ha(...e))},min(...e){return this.check(wr(...e))},max(...e){return this.check(Ko(...e))},length(...e){return this.check(Jo(...e))},nonempty(...e){return this.check(wr(1,...e))},lowercase(e){return this.check(da(e))},uppercase(e){return this.check(fa(e))},trim(){return this.check(ya())},normalize(...e){return this.check(ga(...e))},toLowerCase(){return this.check(_a())},toUpperCase(){return this.check(wa())},slugify(){return this.check(ba())}})),Pv=b("ZodString",(e,t)=>{Co.init(e,t),Cm.init(e,t)},{email(e){return this.check(tp(Iv,e))},url(e){return this.check(ap(Tv,e))},jwt(e){return this.check($p(Bv,e))},emoji(e){return this.check(cp(Ov,e))},guid(e){return this.check(rp(Ev,e))},uuid(e){return this.check(np(Yo,e))},uuidv4(e){return this.check(op(Yo,e))},uuidv6(e){return this.check(sp(Yo,e))},uuidv7(e){return this.check(ip(Yo,e))},nanoid(e){return this.check(up(Rv,e))},cuid(e){return this.check(lp(Av,e))},cuid2(e){return this.check(dp(Cv,e))},ulid(e){return this.check(fp(Nv,e))},base64(e){return this.check(wp(Lv,e))},base64url(e){return this.check(bp(Uv,e))},xid(e){return this.check(pp(jv,e))},ksuid(e){return this.check(mp(Dv,e))},ipv4(e){return this.check(hp(Zv,e))},ipv6(e){return this.check(gp(Mv,e))},cidrv4(e){return this.check(yp(qv,e))},cidrv6(e){return this.check(_p(Fv,e))},e164(e){return this.check(vp(Vv,e))},datetime(e){return this.check(qo(dn,e))},date(e){return this.check(Fo(fn,e))},time(e){return this.check(Lo(pn,e))},duration(e){return this.check(Uo(mn,e))}});function _(e){return ep(Pv,e)}var ue=b("ZodStringFormat",(e,t)=>{te.init(e,t),Cm.init(e,t)}),dn=b("ZodISODateTime",(e,t)=>{uf.init(e,t),ue.init(e,t)}),fn=b("ZodISODate",(e,t)=>{lf.init(e,t),ue.init(e,t)}),pn=b("ZodISOTime",(e,t)=>{df.init(e,t),ue.init(e,t)}),mn=b("ZodISODuration",(e,t)=>{ff.init(e,t),ue.init(e,t)}),Iv=b("ZodEmail",(e,t)=>{Yd.init(e,t),ue.init(e,t)});var Ev=b("ZodGUID",(e,t)=>{Gd.init(e,t),ue.init(e,t)});var Yo=b("ZodUUID",(e,t)=>{Wd.init(e,t),ue.init(e,t)});var Tv=b("ZodURL",(e,t)=>{ef.init(e,t),ue.init(e,t)});var Ov=b("ZodEmoji",(e,t)=>{tf.init(e,t),ue.init(e,t)});var Rv=b("ZodNanoID",(e,t)=>{rf.init(e,t),ue.init(e,t)});var Av=b("ZodCUID",(e,t)=>{nf.init(e,t),ue.init(e,t)});var Cv=b("ZodCUID2",(e,t)=>{of.init(e,t),ue.init(e,t)});var Nv=b("ZodULID",(e,t)=>{sf.init(e,t),ue.init(e,t)});var jv=b("ZodXID",(e,t)=>{af.init(e,t),ue.init(e,t)});var Dv=b("ZodKSUID",(e,t)=>{cf.init(e,t),ue.init(e,t)});var Zv=b("ZodIPv4",(e,t)=>{pf.init(e,t),ue.init(e,t)});var Mv=b("ZodIPv6",(e,t)=>{hf.init(e,t),ue.init(e,t)});var qv=b("ZodCIDRv4",(e,t)=>{gf.init(e,t),ue.init(e,t)});var Fv=b("ZodCIDRv6",(e,t)=>{yf.init(e,t),ue.init(e,t)});var Lv=b("ZodBase64",(e,t)=>{wf.init(e,t),ue.init(e,t)});var Uv=b("ZodBase64URL",(e,t)=>{bf.init(e,t),ue.init(e,t)});var Vv=b("ZodE164",(e,t)=>{vf.init(e,t),ue.init(e,t)});var Bv=b("ZodJWT",(e,t)=>{$f.init(e,t),ue.init(e,t)});var Nm=b("ZodNumber",(e,t)=>{ra.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gp(e,r,n,o),e.isFinite=!0},R.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Ke(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Ke(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Ke(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Ke(e).format??null},{gt(e,t){return this.check(Bo(e,t))},gte(e,t){return this.check(an(e,t))},min(e,t){return this.check(an(e,t))},lt(e,t){return this.check(Vo(e,t))},lte(e,t){return this.check(sn(e,t))},max(e,t){return this.check(sn(e,t))},int(e){return this.check(Tm(e))},safe(e){return this.check(Tm(e))},positive(e){return this.check(Bo(0,e))},nonnegative(e){return this.check(an(0,e))},negative(e){return this.check(Vo(0,e))},nonpositive(e){return this.check(sn(0,e))},multipleOf(e,t){return this.check(Ho(e,t))},step(e,t){return this.check(Ho(e,t))},finite(){return this}}));function W(e){return kp(Nm,e)}var Hv=b("ZodNumberFormat",(e,t)=>{kf.init(e,t),Nm.init(e,t)});function Tm(e){return xp(Hv,e)}var Kv=b("ZodBoolean",(e,t)=>{xf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wp(e,r,n,o)});function ge(e){return Sp(Kv,e)}var Jv=b("ZodNull",(e,t)=>{Sf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Yp(e,r,n,o)});function jm(e){return zp(Jv,e)}var Gv=b("ZodUnknown",(e,t)=>{zf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qp(e,r,n,o)});function ie(){return Pp(Gv)}var Wv=b("ZodNever",(e,t)=>{Pf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xp(e,r,n,o)});function Yv(e){return Ip(Wv,e)}var Xv=b("ZodArray",(e,t)=>{Xo(),If.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>om(e,r,n,o),e.element=t.element},{min(e,t){return this.check(wr(e,t))},nonempty(e){return this.check(wr(1,e))},max(e,t){return this.check(Ko(e,t))},length(e,t){return this.check(Jo(e,t))},unwrap(){return this.element}});function V(e,t){return Ep(Xv,e,t)}var Dm=b("ZodObject",(e,t)=>{Xo(),Of.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sm(e,r,n,o),R.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return Ne(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(R.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(R.mergeDefs(this._zod.def,{catchall:ie()}))},loose(){return this.clone(R.mergeDefs(this._zod.def,{catchall:ie()}))},strict(){return this.clone(R.mergeDefs(this._zod.def,{catchall:Yv()}))},strip(){return this.clone(R.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return R.extend(this,e)},safeExtend(e){return R.safeExtend(this,e)},merge(e){return R.merge(this,e)},pick(e){return R.pick(this,e)},omit(e){return R.omit(this,e)},partial(...e){return R.partial(qm,this,e[0])},exactPartial(...e){return R.partial(Fm,this,e[0],"exactPartial")},required(...e){return R.required(Lm,this,e[0])}});function z(e,t){let r={type:"object",shape:e??{},...R.normalizeParams(t)};return new Dm(r)}function Te(e,t){return new Dm({type:"object",shape:e,catchall:ie(),...R.normalizeParams(t)})}var Zm=b("ZodUnion",(e,t)=>{na.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>im(e,r,n,o),e.options=t.options});function re(e,t){return new Zm({type:"union",options:e,...R.normalizeParams(t)})}var Qv=b("ZodDiscriminatedUnion",(e,t)=>{Zm.init(e,t),Rf.init(e,t)});function Ta(e,t,r){return new Qv({type:"union",options:t,discriminator:e,...R.normalizeParams(r)})}var e0=b("ZodIntersection",(e,t)=>{Af.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>am(e,r,n,o)});function Qo(e,t){return new e0({type:"intersection",left:e,right:t})}var Om=b("ZodRecord",(e,t)=>{Xo(),Cf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>cm(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function Q(e,t,r){return!t||!t._zod?new Om({type:"record",keyType:_(),valueType:e,...R.normalizeParams(t)}):new Om({type:"record",keyType:e,valueType:t,...R.normalizeParams(r)})}var Ea=b("ZodEnum",(e,t)=>{Nf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(n,o,s)=>em(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 Ea({...t,checks:[],...R.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 Ea({...t,checks:[],...R.normalizeParams(o),entries:s})}});function Ne(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Ea({type:"enum",entries:r,...R.normalizeParams(t)})}var t0=b("ZodLiteral",(e,t)=>{jf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>tm(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 I(e,t){return new t0({type:"literal",values:Array.isArray(e)?e:[e],...R.normalizeParams(t)})}var r0=b("ZodTransform",(e,t)=>{Xo(),Df.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nm(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new _r(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(R.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(R.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 Mm(e){return new r0({type:"transform",transform:e})}var qm=b("ZodOptional",(e,t)=>{oa.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ia(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function ae(e){return new qm({type:"optional",innerType:e})}var Fm=b("ZodExactOptional",(e,t)=>{Zf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ia(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function n0(e){return new Fm({type:"optional",innerType:e})}var o0=b("ZodNullable",(e,t)=>{Mf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>um(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Rm(e){return new o0({type:"nullable",innerType:e})}var s0=b("ZodDefault",(e,t)=>{qf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function i0(e,t){return new s0({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var a0=b("ZodPrefault",(e,t)=>{Ff.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>pm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function c0(e,t){return new a0({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var Lm=b("ZodNonOptional",(e,t)=>{Lf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function u0(e,t){return new Lm({type:"nonoptional",innerType:e,...R.normalizeParams(t)})}var l0=b("ZodCatch",(e,t)=>{Uf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>mm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function d0(e,t){return new l0({type:"catch",innerType:e,catchValue:typeof t=="function"?t:R.constantCatch(t)})}var Um=b("ZodPipe",(e,t)=>{sa.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>hm(e,r,n,o),e.in=t.in,e.out=t.out});function Am(e,t){return new Um({type:"pipe",in:e,out:t})}var f0=b("ZodPreprocess",(e,t)=>{Um.init(e,t),Vf.init(e,t)}),p0=b("ZodReadonly",(e,t)=>{Bf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>gm(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function m0(e){return new p0({type:"readonly",innerType:e})}var Vm=b("ZodCustom",(e,t)=>{Hf.init(e,t),ce.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rm(e,r,n,o)});function Bm(e,t){return Tp(Vm,e??(()=>!0),t)}function h0(e,t={}){return Op(Vm,e,t)}function g0(e,t){return Rp(e,t)}function Oa(e,t){return new f0({type:"pipe",in:Mm(e),out:t})}var es={};wl(es,{ZodISODate:()=>fn,ZodISODateTime:()=>dn,ZodISODuration:()=>mn,ZodISOTime:()=>pn,date:()=>_0,datetime:()=>y0,duration:()=>b0,time:()=>w0});function y0(e){return qo(dn,e)}function _0(e){return Fo(fn,e)}function w0(e){return Lo(pn,e)}function b0(e){return Uo(mn,e)}var Aa="2025-11-25";var Hm=[Aa,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Rt="io.modelcontextprotocol/related-task",rs="2.0",he=Bm(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Km=re([_(),W().int()]),Jm=_(),DA=Te({ttl:W().optional(),pollInterval:W().optional()}),v0=z({ttl:W().optional()}),$0=z({taskId:_()}),Ca=Te({progressToken:Km.optional(),[Rt]:$0.optional()}),Be=z({_meta:Ca.optional()}),hn=Be.extend({task:v0.optional()}),Gm=e=>hn.safeParse(e).success,_e=z({method:_(),params:Be.loose().optional()}),Je=z({_meta:Ca.optional()}),Ge=z({method:_(),params:Je.loose().optional()}),we=Te({_meta:Ca.optional()}),ns=re([_(),W().int()]),Wm=z({jsonrpc:I(rs),id:ns,..._e.shape}).strict(),Na=e=>Wm.safeParse(e).success,Ym=z({jsonrpc:I(rs),...Ge.shape}).strict(),Xm=e=>Ym.safeParse(e).success,ja=z({jsonrpc:I(rs),id:ns,result:we}).strict(),gn=e=>ja.safeParse(e).success;var j;(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"})(j||(j={}));var Da=z({jsonrpc:I(rs),id:ns.optional(),error:z({code:W().int(),message:_(),data:ie().optional()})}).strict();var Qm=e=>Da.safeParse(e).success;var eh=re([Wm,Ym,ja,Da]),ZA=re([ja,Da]),os=we.strict(),k0=Je.extend({requestId:ns.optional(),reason:_().optional()}),ss=Ge.extend({method:I("notifications/cancelled"),params:k0}),x0=z({src:_(),mimeType:_().optional(),sizes:V(_()).optional(),theme:Ne(["light","dark"]).optional()}),yn=z({icons:V(x0).optional()}),$r=z({name:_(),title:_().optional()}),th=$r.extend({...$r.shape,...yn.shape,version:_(),websiteUrl:_().optional(),description:_().optional()}),S0=Qo(z({applyDefaults:ge().optional()}),Q(_(),ie())),z0=Oa(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Qo(z({form:S0.optional(),url:he.optional()}),Q(_(),ie()).optional())),P0=Te({list:he.optional(),cancel:he.optional(),requests:Te({sampling:Te({createMessage:he.optional()}).optional(),elicitation:Te({create:he.optional()}).optional()}).optional()}),I0=Te({list:he.optional(),cancel:he.optional(),requests:Te({tools:Te({call:he.optional()}).optional()}).optional()}),E0=z({experimental:Q(_(),he).optional(),sampling:z({context:he.optional(),tools:he.optional()}).optional(),elicitation:z0.optional(),roots:z({listChanged:ge().optional()}).optional(),tasks:P0.optional(),extensions:Q(_(),he).optional()}),T0=Be.extend({protocolVersion:_(),capabilities:E0,clientInfo:th}),Za=_e.extend({method:I("initialize"),params:T0});var O0=z({experimental:Q(_(),he).optional(),logging:he.optional(),completions:he.optional(),prompts:z({listChanged:ge().optional()}).optional(),resources:z({subscribe:ge().optional(),listChanged:ge().optional()}).optional(),tools:z({listChanged:ge().optional()}).optional(),tasks:I0.optional(),extensions:Q(_(),he).optional()}),R0=we.extend({protocolVersion:_(),capabilities:O0,serverInfo:th,instructions:_().optional()}),Ma=Ge.extend({method:I("notifications/initialized"),params:Je.optional()});var is=_e.extend({method:I("ping"),params:Be.optional()}),A0=z({progress:W(),total:ae(W()),message:ae(_())}),C0=z({...Je.shape,...A0.shape,progressToken:Km}),as=Ge.extend({method:I("notifications/progress"),params:C0}),N0=Be.extend({cursor:Jm.optional()}),_n=_e.extend({params:N0.optional()}),wn=we.extend({nextCursor:Jm.optional()}),j0=Ne(["working","input_required","completed","failed","cancelled"]),bn=z({taskId:_(),status:j0,ttl:re([W(),jm()]),createdAt:_(),lastUpdatedAt:_(),pollInterval:ae(W()),statusMessage:ae(_())}),kr=we.extend({task:bn}),D0=Je.merge(bn),vn=Ge.extend({method:I("notifications/tasks/status"),params:D0}),cs=_e.extend({method:I("tasks/get"),params:Be.extend({taskId:_()})}),us=we.merge(bn),ls=_e.extend({method:I("tasks/result"),params:Be.extend({taskId:_()})}),MA=we.loose(),ds=_n.extend({method:I("tasks/list")}),fs=wn.extend({tasks:V(bn)}),ps=_e.extend({method:I("tasks/cancel"),params:Be.extend({taskId:_()})}),rh=we.merge(bn),nh=z({uri:_(),mimeType:ae(_()),_meta:Q(_(),ie()).optional()}),oh=nh.extend({text:_()}),qa=_().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),sh=nh.extend({blob:qa}),$n=Ne(["user","assistant"]),xr=z({audience:V($n).optional(),priority:W().min(0).max(1).optional(),lastModified:es.datetime({offset:!0}).optional()}),ih=z({...$r.shape,...yn.shape,uri:_(),description:ae(_()),mimeType:ae(_()),size:ae(W()),annotations:xr.optional(),_meta:ae(Te({}))}),Z0=z({...$r.shape,...yn.shape,uriTemplate:_(),description:ae(_()),mimeType:ae(_()),annotations:xr.optional(),_meta:ae(Te({}))}),M0=_n.extend({method:I("resources/list")}),q0=wn.extend({resources:V(ih)}),F0=_n.extend({method:I("resources/templates/list")}),L0=wn.extend({resourceTemplates:V(Z0)}),Fa=Be.extend({uri:_()}),U0=Fa,V0=_e.extend({method:I("resources/read"),params:U0}),B0=we.extend({contents:V(re([oh,sh]))}),H0=Ge.extend({method:I("notifications/resources/list_changed"),params:Je.optional()}),K0=Fa,J0=_e.extend({method:I("resources/subscribe"),params:K0}),G0=Fa,W0=_e.extend({method:I("resources/unsubscribe"),params:G0}),Y0=Je.extend({uri:_()}),X0=Ge.extend({method:I("notifications/resources/updated"),params:Y0}),Q0=z({name:_(),description:ae(_()),required:ae(ge())}),e$=z({...$r.shape,...yn.shape,description:ae(_()),arguments:ae(V(Q0)),_meta:ae(Te({}))}),t$=_n.extend({method:I("prompts/list")}),r$=wn.extend({prompts:V(e$)}),n$=Be.extend({name:_(),arguments:Q(_(),_()).optional()}),o$=_e.extend({method:I("prompts/get"),params:n$}),La=z({type:I("text"),text:_(),annotations:xr.optional(),_meta:Q(_(),ie()).optional()}),Ua=z({type:I("image"),data:qa,mimeType:_(),annotations:xr.optional(),_meta:Q(_(),ie()).optional()}),Va=z({type:I("audio"),data:qa,mimeType:_(),annotations:xr.optional(),_meta:Q(_(),ie()).optional()}),s$=z({type:I("tool_use"),name:_(),id:_(),input:Q(_(),ie()),_meta:Q(_(),ie()).optional()}),i$=z({type:I("resource"),resource:re([oh,sh]),annotations:xr.optional(),_meta:Q(_(),ie()).optional()}),a$=ih.extend({type:I("resource_link")}),Ba=re([La,Ua,Va,a$,i$]),c$=z({role:$n,content:Ba}),u$=we.extend({description:_().optional(),messages:V(c$)}),l$=Ge.extend({method:I("notifications/prompts/list_changed"),params:Je.optional()}),d$=z({title:_().optional(),readOnlyHint:ge().optional(),destructiveHint:ge().optional(),idempotentHint:ge().optional(),openWorldHint:ge().optional()}),f$=z({taskSupport:Ne(["required","optional","forbidden"]).optional()}),ah=z({...$r.shape,...yn.shape,description:_().optional(),inputSchema:z({type:I("object"),properties:Q(_(),he).optional(),required:V(_()).optional()}).catchall(ie()),outputSchema:z({type:I("object"),properties:Q(_(),he).optional(),required:V(_()).optional()}).catchall(ie()).optional(),annotations:d$.optional(),execution:f$.optional(),_meta:Q(_(),ie()).optional()}),Ha=_n.extend({method:I("tools/list")}),p$=wn.extend({tools:V(ah)}),ms=we.extend({content:V(Ba).default([]),structuredContent:Q(_(),ie()).optional(),isError:ge().optional()}),qA=ms.or(we.extend({toolResult:ie()})),m$=hn.extend({name:_(),arguments:Q(_(),ie()).optional()}),kn=_e.extend({method:I("tools/call"),params:m$}),h$=Ge.extend({method:I("notifications/tools/list_changed"),params:Je.optional()}),FA=z({autoRefresh:ge().default(!0),debounceMs:W().int().nonnegative().default(300)}),xn=Ne(["debug","info","notice","warning","error","critical","alert","emergency"]),g$=Be.extend({level:xn}),Ka=_e.extend({method:I("logging/setLevel"),params:g$}),y$=Je.extend({level:xn,logger:_().optional(),data:ie()}),_$=Ge.extend({method:I("notifications/message"),params:y$}),w$=z({name:_().optional()}),b$=z({hints:V(w$).optional(),costPriority:W().min(0).max(1).optional(),speedPriority:W().min(0).max(1).optional(),intelligencePriority:W().min(0).max(1).optional()}),v$=z({mode:Ne(["auto","required","none"]).optional()}),$$=z({type:I("tool_result"),toolUseId:_().describe("The unique identifier for the corresponding tool call."),content:V(Ba).default([]),structuredContent:z({}).loose().optional(),isError:ge().optional(),_meta:Q(_(),ie()).optional()}),k$=Ta("type",[La,Ua,Va]),ts=Ta("type",[La,Ua,Va,s$,$$]),x$=z({role:$n,content:re([ts,V(ts)]),_meta:Q(_(),ie()).optional()}),S$=hn.extend({messages:V(x$),modelPreferences:b$.optional(),systemPrompt:_().optional(),includeContext:Ne(["none","thisServer","allServers"]).optional(),temperature:W().optional(),maxTokens:W().int(),stopSequences:V(_()).optional(),metadata:he.optional(),tools:V(ah).optional(),toolChoice:v$.optional()}),z$=_e.extend({method:I("sampling/createMessage"),params:S$}),Sn=we.extend({model:_(),stopReason:ae(Ne(["endTurn","stopSequence","maxTokens"]).or(_())),role:$n,content:k$}),Ja=we.extend({model:_(),stopReason:ae(Ne(["endTurn","stopSequence","maxTokens","toolUse"]).or(_())),role:$n,content:re([ts,V(ts)])}),P$=z({type:I("boolean"),title:_().optional(),description:_().optional(),default:ge().optional()}),I$=z({type:I("string"),title:_().optional(),description:_().optional(),minLength:W().optional(),maxLength:W().optional(),format:Ne(["email","uri","date","date-time"]).optional(),default:_().optional()}),E$=z({type:Ne(["number","integer"]),title:_().optional(),description:_().optional(),minimum:W().optional(),maximum:W().optional(),default:W().optional()}),T$=z({type:I("string"),title:_().optional(),description:_().optional(),enum:V(_()),default:_().optional()}),O$=z({type:I("string"),title:_().optional(),description:_().optional(),oneOf:V(z({const:_(),title:_()})),default:_().optional()}),R$=z({type:I("string"),title:_().optional(),description:_().optional(),enum:V(_()),enumNames:V(_()).optional(),default:_().optional()}),A$=re([T$,O$]),C$=z({type:I("array"),title:_().optional(),description:_().optional(),minItems:W().optional(),maxItems:W().optional(),items:z({type:I("string"),enum:V(_())}),default:V(_()).optional()}),N$=z({type:I("array"),title:_().optional(),description:_().optional(),minItems:W().optional(),maxItems:W().optional(),items:z({anyOf:V(z({const:_(),title:_()}))}),default:V(_()).optional()}),j$=re([C$,N$]),D$=re([R$,A$,j$]),Z$=re([D$,P$,I$,E$]),M$=hn.extend({mode:I("form").optional(),message:_(),requestedSchema:z({type:I("object"),properties:Q(_(),Z$),required:V(_()).optional()})}),q$=hn.extend({mode:I("url"),message:_(),elicitationId:_(),url:_().url()}),F$=re([M$,q$]),L$=_e.extend({method:I("elicitation/create"),params:F$}),U$=Je.extend({elicitationId:_()}),V$=Ge.extend({method:I("notifications/elicitation/complete"),params:U$}),Sr=we.extend({action:Ne(["accept","decline","cancel"]),content:Oa(e=>e===null?void 0:e,Q(_(),re([_(),W(),ge(),V(_())])).optional())}),B$=z({type:I("ref/resource"),uri:_()});var H$=z({type:I("ref/prompt"),name:_()}),K$=Be.extend({ref:re([H$,B$]),argument:z({name:_(),value:_()}),context:z({arguments:Q(_(),_()).optional()}).optional()}),J$=_e.extend({method:I("completion/complete"),params:K$});var G$=we.extend({completion:Te({values:V(_()).max(100),total:ae(W().int()),hasMore:ae(ge())})}),W$=z({uri:_().startsWith("file://"),name:_().optional(),_meta:Q(_(),ie()).optional()}),Y$=_e.extend({method:I("roots/list"),params:Be.optional()}),Ga=we.extend({roots:V(W$)}),X$=Ge.extend({method:I("notifications/roots/list_changed"),params:Je.optional()}),LA=re([is,Za,J$,Ka,o$,t$,M0,F0,V0,J0,W0,kn,Ha,cs,ls,ds,ps]),UA=re([ss,as,Ma,X$,vn]),VA=re([os,Sn,Ja,Sr,Ga,us,fs,kr]),BA=re([is,z$,L$,Y$,cs,ls,ds,ps]),HA=re([ss,as,_$,X0,H0,h$,l$,vn,V$]),KA=re([os,R0,G$,u$,r$,q0,L0,B0,ms,p$,us,fs,kr]),A=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===j.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Ra(o.elicitations,r)}return new e(t,r,n)}},Ra=class extends A{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(j.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};var Q$=10*1024*1024,hs=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??Q$}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),ek(r)}clear(){this._buffer=void 0}};function ek(e){return eh.parse(JSON.parse(e))}function ch(e){return JSON.stringify(e)+`
68
- `}var gs=class{constructor(t=uh.stdin,r=uh.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 hs({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=ch(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};function Wa(){return{schema:2,cells:[]}}function bt(e,t=null){return{schema:2,id:e,source:t,chapters:[],cards:[],inspirations:[]}}function Wt(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 _s(e,t=zn()){if(e.targetDate===void 0)return;let{done:r,total:n}=Wt(e),o=n-r,s=tk(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 fh(e,t=zn()){let{done:r,total:n}=Wt(e),o=_s(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}:{},...lh(e)!==void 0?{period:lh(e)}:{},...dh(e,r,n)!==void 0?{percent:dh(e,r,n)}:{}}}function lh(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:ys(e.finishedAt),end:ys(e.finishedAt)}:void 0;let r=ys(t.reduce((o,s)=>o<s?o:s));if(!e.finishedAt)return{start:r};let n=ys(e.finishedAt);return{start:r<n?r:n,end:n}}function ys(e){return/^\d{4}-\d{2}-\d{2}$/.test(e)?e.slice(0,7):zn(new Date(e)).slice(0,7)}function dh(e,t,r){return e.finishedAt!==void 0?1:e.source?.type==="epub"&&e.position!==void 0?e.position.percent:r>0?t/r:void 0}function At(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 zn(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 tk(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 ph(e){return typeof e=="string"&&/^\d{4}-\d{2}-\d{2}$/.test(e)}import{randomBytes as rk}from"node:crypto";import{cpSync as nk,existsSync as zr,lstatSync as ok,mkdirSync as ws,mkdtempSync as sk,readdirSync as mh,readFileSync as hh,renameSync as yh,rmSync as bs,statSync as ik,writeFileSync as ak}from"node:fs";import{join as je}from"node:path";var w=class extends Error{};function He(e){return`${e}_${rk(5).toString("hex")}`}function Oe(){return new Date().toISOString()}var _h=/^c_[0-9a-f]{10}$/,ck=new Set(["book","note","group"]);function Ct(e){if(typeof e!="string"||!_h.test(e))throw new w("\u683C\u5B50 id \u65E0\u6548")}function ks(e){return typeof e?.schema=="number"&&e.schema>2?e.schema:2}function uk(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"||!ck.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:ks(e),cells:e.cells}}function lk(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{...bt(t),...e,schema:ks(e),id:t,chapters:e.chapters??[],cards:e.cards??[],inspirations:e.inspirations??[]}}function vs(e){let t=ik(e);return`${t.mtimeMs}:${t.size}`}function gh(e,t){let r=`${e}.${process.pid}.tmp`;return ak(r,JSON.stringify(t,null,2)+`
69
- `,"utf8"),yh(r,e),vs(e)}var xs=class{dir;itemsDir;imagesDir;palaceFile;palace={value:Wa(),stamp:"",broken:!1};items=new Map;rev=1;constructor(t,{create:r=!0}={}){this.dir=t,this.itemsDir=je(t,"items"),this.imagesDir=je(t,"images"),this.palaceFile=je(t,"palace.json"),r&&(ws(this.itemsDir,{recursive:!0}),ws(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(!zr(this.palaceFile))return this.palace.stamp!==""&&(this.palace={value:Wa(),stamp:"",broken:!1},this.rev+=1),this.palace;let t=vs(this.palaceFile);if(t===this.palace.stamp)return this.palace;let r=this.palace.schema;try{let n=JSON.parse(hh(this.palaceFile,"utf8"));r=ks(n),this.palace={value:uk(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){Ct(t);let r=je(this.itemsDir,`${t}.json`),n=this.items.get(t);if(!zr(r))return n!==void 0&&(this.items.delete(t),this.rev+=1),{value:bt(t),stamp:"",broken:!1};let o=vs(r);if(n!==void 0&&n.stamp===o)return n;let s,i=n?.schema;try{let a=JSON.parse(hh(r,"utf8"));i=ks(a),s={value:lk(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??bt(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]=fh(this.getItem(r.id)));return t}snapshotBeforeWrite(){let t=".snapshots",r=je(this.dir,t),n=je(r,zn());try{let o=ok(r,{throwIfNoEntry:!1});if(o&&!o.isDirectory())throw new Error("\u5FEB\u7167\u8DEF\u5F84\u4E0D\u662F\u666E\u901A\u76EE\u5F55");if(zr(n))return;ws(r,{recursive:!0});let s=sk(je(r,".partial-"));try{for(let a of mh(this.dir))a!==t&&nk(je(this.dir,a),je(s,a),{recursive:!0,verbatimSymlinks:!0});zr(n)||yh(s,n)}finally{bs(s,{recursive:!0,force:!0})}let i=mh(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))bs(je(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"||!_h.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)=>(zr(f)?vs(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(je(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;zr(this.itemsDir)||ws(this.itemsDir,{recursive:!0});let m=gh(je(this.itemsDir,`${f}.json`),p);this.items.set(f,{value:p,stamp:m,broken:!1})}if(c){let f=gh(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`,()=>bs(je(this.itemsDir,`${f}.json`),{force:!0})));for(let f of s)/^[\w.-]+$/.test(f)&&d(`images/${f}`,()=>bs(je(this.imagesDir,f),{force:!0}));return a}};function Nt(e,t){if(typeof e!="string"||e.trim()==="")throw new w(`${t}\u4E0D\u80FD\u4E3A\u7A7A`);return e.trim()}function Pn(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 Ya(e,t){if(!(e==null||e==="")){if(!ph(e))throw new w(`${t}\u683C\u5F0F\u5E94\u4E3A YYYY-MM-DD`);return e}}function Ss(e,t){if(!Number.isSafeInteger(e))throw new w(`${t}\u5E94\u4E3A\u6574\u6570`);return e}function In(e,t,r,n){n?delete e[t]:r!==void 0&&(e[t]=r)}function Yt(e){return e===null||e===""}function Xt(e,t){Ct(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 We(e,t){let r=Xt(e.palace,t);if(r.kind==="group")throw new w("\u5206\u7EC4\u6CA1\u6709\u7B14\u8BB0\u672C");return e.item(r.id)}function dk(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 Xa(e,t,r,n){return e.cells.find(o=>o.parentId===t&&o.col===r&&o.row===n)}function En(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(Xa(e,t,s,i)===void 0)return{col:s,row:i}}}function wh(e,t,r){if(t==null)return null;let n=Xt(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 bh(e,t,r){if(e!==null&&(t<0||r<0))throw new w("\u5206\u7EC4\u91CC\u7684\u5750\u6807\u4E0D\u80FD\u4E3A\u8D1F")}function Qa(e,t){t===null||e.cells.some(r=>r.parentId===t)||(e.cells=e.cells.filter(r=>r.id!==t))}var ec="https://dsh-palace.pages.dev";async function vh(e){return e.mutate(t=>{let r={id:He("c"),kind:"note",parentId:null,...En(t.palace,null),title:"Memory Palace \u2197",subtitle:"\u4EC0\u4E48\u662F",icon:"open-book",href:ec,createdAt:Oe()};return t.palace.cells.push(r),t.createItem(bt(r.id,null)),r})}async function jt(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=Nt(t.title,"\u6807\u9898"),o=Pn(t.subtitle,"\u5907\u6CE8"),s=r==="book"?dk(t.source):null,i=Ya(t.targetDate,"\u76EE\u6807\u65E5\u671F");return e.mutate(a=>{let c=wh(a.palace,t.parentId,r),u;if(t.col===void 0&&t.row===void 0)u=En(a.palace,c);else if(u={col:Ss(t.col,"\u5217"),row:Ss(t.row,"\u884C")},bh(c,u.col,u.row),Xa(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:He("c"),kind:r,parentId:c,...u,title:n,...o?{subtitle:o}:{},createdAt:Oe()};if(a.palace.cells.push(l),r!=="group"){let d=bt(l.id,s);i!==void 0&&(d.targetDate=i),r==="book"&&t.outline!==void 0&&(d.chapters=Is(t.outline),d.chapters.length>0&&t.outlineSource!==void 0&&(d.outlineSource=t.outlineSource)),a.createItem(d)}return l})}async function $h(e,t){let r=t.title===void 0?void 0:Nt(t.title,"\u6807\u9898"),n=Pn(t.subtitle,"\u5907\u6CE8"),o=Pn(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=Xt(s.palace,t.id);return r!==void 0&&(i.title=r),In(i,"subtitle",n,Yt(t.subtitle)),In(i,"icon",o,Yt(t.icon)),i})}async function kh(e,t){let r=t.col===void 0&&t.row===void 0,n=r?0:Ss(t.col,"\u5217"),o=r?0:Ss(t.row,"\u884C");return e.mutate(s=>{let i=Xt(s.palace,t.id),a=wh(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}=En(s.palace,a))}bh(a,n,o);let c=[i.parentId],u=Xa(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)Qa(s.palace,l);return i})}async function xh(e,t){let r=t.title===void 0?"\u65B0\u5206\u7EC4":Nt(t.title,"\u6807\u9898");return e.mutate(n=>{let o=Xt(n.palace,t.id),s=Xt(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:He("c"),kind:"group",parentId:null,col:s.col,row:s.row,title:r,createdAt:Oe()};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,Qa(n.palace,a),i})}async function zs(e,t){return e.mutate(r=>{let n=Xt(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),Qa(r.palace,n.parentId)})}async function Ps(e,t){let r=Ya(t.targetDate,"\u76EE\u6807\u65E5\u671F"),n=Ya(t.finishedAt,"\u8BFB\u5B8C\u65E5\u671F");return e.mutate(o=>{let s=We(o,t.id);return In(s,"targetDate",r,Yt(t.targetDate)),In(s,"finishedAt",n,Yt(t.finishedAt)),s})}async function Sh(e,t){let r=Nt(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=>{We(o,t.id).position={loc:r,percent:n}})}function Is(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:He("s"),title:u,...n(c.loc),done:l!==void 0,...l?.doneAt!==void 0?{doneAt:l.doneAt}:{}}});return{id:He("ch"),title:s,sections:a}})}async function Es(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=We(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=Is(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 zh(e,t){return e.mutate(r=>{let n=At(We(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=Oe():delete n.section.doneAt})}async function Ph(e,t){return e.mutate(r=>{let n=We(r,t.id);if(At(n,t.sectionId)===void 0)throw new w("\u8282\u4E0D\u5B58\u5728");let o=!0,s=Oe();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 Ih(e,t){return e.mutate(r=>{for(let n of We(r,t.id).chapters)for(let o of n.sections)o.done=!1,delete o.doneAt})}var fk=new Set(["excerpt","thought","mistake"]);function Eh(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 Th(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 Oh(e,t,r){if(t.sectionId!==void 0&&!Yt(t.sectionId)&&At(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&&!Yt(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"])In(r,n,Pn(t[n],n),Yt(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 Ts(e,t){let r=t.type;if(!fk.has(r))throw new w("\u5361\u7247\u7C7B\u578B\u5E94\u4E3A excerpt / thought / mistake");return e.mutate(n=>{let o=We(n,t.id),s={id:He("k"),type:r,createdAt:Oe()};return Oh(o,t,s),r==="mistake"&&s.status===void 0&&(s.status="todo"),Th(s),s.image!==void 0&&Eh(n,s.image,s.id),o.cards.push(s),s})}async function Rh(e,t){return e.mutate(r=>{let n=We(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 Oh(n,t,o),Th(o),o.image!==void 0&&o.image!==s&&Eh(r,o.image,o.id),s!==void 0&&s!==o.image&&r.deleteImage(s),o})}async function Ah(e,t){return e.mutate(r=>{let n=We(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 Os(e,t){let r=Nt(t.title,"\u7075\u611F\u6807\u9898"),n=Nt(t.body,"\u7075\u611F\u6B63\u6587"),o=Pn(t.sessionId,"sessionId");return e.mutate(s=>{let i=We(s,t.id),a=Array.isArray(t.cardIds)?t.cardIds.filter(u=>i.cards.some(l=>l.id===u)):[],c={id:He("i"),title:r,body:n,...o?{sessionId:o}:{},...a.length?{cardIds:a}:{},createdAt:Oe()};return i.inspirations.push(c),c})}async function Ch(e,t){let r=t.title===void 0?void 0:Nt(t.title,"\u7075\u611F\u6807\u9898"),n=t.body===void 0?void 0:Nt(t.body,"\u7075\u611F\u6B63\u6587");return e.mutate(o=>{let s=We(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 Nh(e,t){return e.mutate(r=>{let n=We(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 TT}from"node:path";function Rs(e){return!!e._zod}function Dt(e,t){return Rs(e)?Hi(e,t):e.safeParse(t)}function As(e){if(!e)return;let t;if(Rs(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Cs(e){if(Rs(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 Zt(e){return e==="completed"||e==="failed"||e==="cancelled"}var eC=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function rc(e){let r=As(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Cs(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function nc(e,t){let r=Dt(e,t);if(!r.success)throw r.error;return r.data}var wk=6e4,Ns=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(ss,r=>{this._oncancel(r)}),this.setNotificationHandler(as,r=>{this._onprogress(r)}),this.setRequestHandler(is,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(cs,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(j.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(ls,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(!await this._taskStore.getTask(s,n.sessionId))throw new A(j.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 A(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 A(j.InvalidParams,`Task not found: ${s}`);if(!Zt(i.status))return await this._waitForTaskUpdate(s,n.signal,n.sessionId),await o();if(Zt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s,n.sessionId),{...a,_meta:{...a._meta,[Rt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(ds,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new A(j.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(ps,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(j.InvalidParams,`Task not found: ${r.params.taskId}`);if(Zt(o.status))throw new A(j.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 A(j.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof A?o:new A(j.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),A.fromError(j.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),gn(s)||Qm(s)?this._onresponse(s):Na(s)?this._onrequest(s,i):Xm(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=A.fromError(j.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?.[Rt]?.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 A(j.InvalidParams,`Task not found: ${s}`);c=!0})()),n===void 0){let m={jsonrpc:"2.0",id:t.id,error:{code:j.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=Gm(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 A(j.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 A(j.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:j.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),gn(t))n(t);else{let i=new A(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(gn(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),gn(t))o(t);else{let i=A.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 A?i:new A(j.InternalError,String(i))}}return}let s;try{let i=await this.request(t,kr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new A(j.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Zt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new A(j.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new A(j.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof A?i:new A(j.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||{},[Rt]: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(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`)));let k=v instanceof A?v:new A(j.RequestTimeout,String(v));l(k)};this._responseHandlers.set(f,v=>{if(!n?.signal?.aborted){if(v instanceof Error)return l(v);try{let k=Dt(r,v.result);k.success?u(k.data):l(k.error)}catch(k){l(k)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??wk,g=()=>m(A.fromError(j.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let v=k=>{let T=this._responseHandlers.get(f);T?T(k):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(k=>{this._cleanupTimeout(f),l(k)})}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},us,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},fs,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},rh,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||{},[Rt]: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||{},[Rt]: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||{},[Rt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=rc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=nc(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=rc(t);this._notificationHandlers.set(n,o=>{let s=nc(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"&&Na(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new A(j.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 A(j.InvalidRequest,"Request cancelled"));return}let a=setTimeout(s,o);r.addEventListener("abort",()=>{clearTimeout(a),i(new A(j.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 A(j.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=vn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Zt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new A(j.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Zt(a.status))throw new A(j.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=vn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Zt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function jh(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Dh(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];jh(i)&&jh(s)?r[o]={...i,...s}:r[o]=s}return r}var M_=bl(Ju(),1),q_=bl(Z_(),1);function RE(){let e=new M_.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,q_.default)(e),e}var Vr=class{constructor(t){this._ajv=t??RE()}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 bi=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},Sn,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},Sr,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 F_(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 L_(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 vi=class extends Ns{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(xn.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 Vr,this.setRequestHandler(Za,n=>this._oninitialize(n)),this.setNotificationHandler(Ma,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Ka,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=xn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new bi(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Dh(this._capabilities,t)}setRequestHandler(t,r){let o=As(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=Cs(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=Dt(kn,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new A(j.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=Dt(kr,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new A(j.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=Dt(ms,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new A(j.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){L_(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&F_(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:Hm.includes(r)?r:Aa,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"},os)}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},Ja,r):this.request({method:"sampling/createMessage",params:t},Sn,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},Sr,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},Sr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new A(j.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof A?i:new A(j.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},Ga,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 AE,existsSync as rl,mkdirSync as CE,readFileSync as nl,renameSync as NE,statSync as U_,writeFileSync as jE}from"node:fs";import{join as ao}from"node:path";var uo=500,V_=40,B_=40,H_=5,sl=e=>[...e].length;function ol(e){if(typeof e!="string"||e.trim()==="")throw new w("\u8981\u5199\u4E00\u53E5\u7406\u7531");let t=e.trim().replace(/\n/g," ");if(sl(t)>B_)throw new w(`\u7406\u7531\u6700\u591A ${B_} \u5B57`);return t}var Pe=(e,t)=>e<t?`${e}|${t}`:`${t}|${e}`;function co(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 DE(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 ZE(e){return`---
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 Br=class{dir;cellsDir;linksFile;cache={stamp:"",records:[]};store;constructor(t){this.store=t,this.dir=ao(t.dir,"memory"),this.cellsDir=ao(this.dir,"cells"),this.linksFile=ao(t.dir,"links.jsonl")}pageFile(t){return t==="me"?ao(this.dir,"me.md"):(Ct(t),ao(this.cellsDir,`${t}.md`))}readPage(t){let r=this.pageFile(t);if(rl(r))try{return DE(nl(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=sl(n);if(o>uo)throw new w(`\u6B63\u6587 ${o} \u5B57\uFF0C\u4E0A\u9650 ${uo} \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&&sl(s)>V_)throw new w(`\u4E00\u53E5\u8BDD\u6982\u62EC\u6700\u591A ${V_} \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>H_)throw new w(`\u4E3B\u9898\u8BCD\u6700\u591A ${H_} \u4E2A`)}let a={...t!=="me"&&s?{summary:s}:{},...t!=="me"&&i?.length?{topics:i}:{},body:n,writtenAt:Oe()},c=this.pageFile(t);this.store.snapshotBeforeWrite(),CE(this.cellsDir,{recursive:!0});let u=`${c}.${process.pid}.tmp`;return jE(u,ZE(a),"utf8"),NE(u,c),a}debt(t){let r=this.readPage(t)?.writtenAt??"",n=0;for(let o of co(this.store.getItem(t)).values())o>r&&(n+=1);return n}records(){if(!rl(this.linksFile))return[];let t=U_(this.linksFile),r=`${t.mtimeMs}:${t.size}`;if(r===this.cache.stamp)return this.cache.records;let n=[];for(let o of nl(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=(rl(this.linksFile)?U_(this.linksFile).size:0)>0&&nl(this.linksFile,"utf8").at(-1)!==`
77
- `;AE(this.linksFile,(n?`
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
78
  `:"")+t.map(o=>JSON.stringify(o)).join(`
79
79
  `)+`
80
- `,"utf8"),this.store.rev+=1}cellOf(t,r){Ct(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"&&Pe(o.from,o.to)===Pe(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=ol(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=co(this.store.getItem(r.id)),a=co(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=>Pe(d.from,d.to)===Pe(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:He("l"),from:r.id,to:n.id,why:o,evidence:s,...t.sessionId?{sessionId:t.sessionId}:{},createdAt:Oe()};return this.append([l]),l}previewImportedLinks(t){let r=this.records(),n=new Set(r.filter(l=>l.type==="cut").map(l=>Pe(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=>Pe(l.from,l.to))),c=t.filter(l=>!n.has(Pe(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=>Pe(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:He("l"),why:ol(n.why),createdAt:Oe()})))}retitleLink(t){let r=this.cellOf(t.from,!1).id,n=this.cellOf(t.to,!1).id,o=ol(t.why),s=this.arcs().find(i=>Pe(i.from,i.to)===Pe(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:Oe()}])}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=co(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=Pe(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(Pe(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(Pe(n.from,n.to)),n.type==="retitle"&&t.set(Pe(n.from,n.to),n.why);let r=new Map;for(let n of this.validLinks()){let o=Pe(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(Pe(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 co(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
+ `,"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
81
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
82
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
83
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
84
- - \u6BCF\u9875\u4E0A\u9650 ${uo} \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
+ - \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
85
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
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,k)=>k.at>v.at?1:-1),m=[],h=[],g=u.join(`
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(`
87
87
 
88
- `).length;for(let[v,{c:k,at:T}]of p.entries()){let x=this.readPage(k.id),$=`- ${k.title} id=${k.id}${c(k)?` \u3014${c(k)}\u3015`:""}`+(x?.summary?` \xB7 ${x.summary}`:"")+(x?.topics?.length?` \xB7 ${x.topics.join("\u3001")}`:"")+` \xB7 ${T.slice(0,7)}`;(k.id===s?.id||i.has(k.id)||v<30)&&g+$.length<r*.7?(m.push($),g+=$.length+1):h.push(k.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
+ `).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
89
89
  ${m.join(`
90
90
  `)}`;h.length>0&&(y+=`
91
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
@@ -95,11 +95,11 @@ ${p?p.body:"\uFF08\u8FD8\u6CA1\u5199\uFF09"}`;m>0&&(h+=`
95
95
  ${g.map(y=>`- \u2194 ${a(y.from===s.id?y.to:y.from)}\uFF08${y.strands} \u80A1\uFF09\uFF1A${y.why}`).join(`
96
96
  `)}`),u.push(h)}let f=u.join(`
97
97
 
98
- `);return f.length>r?f.slice(0,r):f}};import{createHash as ME}from"node:crypto";var $i=e=>ME("sha256").update(JSON.stringify(e)).digest("hex"),K_=(e,...t)=>`${e}_${$i(t).slice(0,10)}`;async function il(e,t,r,n,o=!1){let s=e.getPalace(),i=new Map(s.cells.map($=>[$.id,$])),a=new Map;for(let $ of s.cells)if($.kind!=="group")for(let P of e.getItem($.id).cards)P.importSource?.source===r.source&&a.set(P.importSource.key,{cell:$,card:P});let c=new Map,u=new Map,l=new Map,d=Oe();for(let $ of r.groups){let P=$.itemId??K_("c",r.source,$.key),F=i.get(P)??c.get(P);if($.itemId!==void 0&&(F===void 0||F.kind==="group"))throw new w("\u5BFC\u5165\u76EE\u6807\u5FC5\u987B\u662F\u5DF2\u6709\u7684\u4E66\u6216\u7B14\u8BB0\u683C\u5B50");F===void 0&&($.kind==="book"||$.cards.some(C=>!a.has(C.key)))&&(F={id:P,kind:$.kind??"note",title:$.title,href:$.href,parentId:null,col:0,row:0,createdAt:d},c.set(P,F)),F&&$.chapters?.length&&(c.has(P)||e.getItem(P).chapters.length===0)&&u.set(P,$.chapters);for(let C of $.cards){if(l.has(C.key))throw new w(`\u65B9\u6848\u91CC\u91CD\u590D\u51FA\u73B0\uFF1A${C.key}`);let D=a.get(C.key);if(D&&$.itemId!==void 0&&D.cell.id!==$.itemId)throw new w(`\u5DF2\u5BFC\u5165\u7684\u7B14\u8BB0\u7559\u5728\u539F\u683C\u5B50\uFF1A${C.key}`);let de=$i(C.type===void 0?[C.note,C.frontmatter]:[C.type,C.note,C.quote,C.sectionKey]),M={...D?.card??{id:K_("k",r.source,C.key),type:C.type??"thought",quote:C.quote,createdAt:d},note:D?.card.importSource?.digest===de?D.card.note:C.note,importSource:{source:r.source,key:C.key,digest:de,frontmatter:C.frontmatter}};l.set(C.key,{cell:D?.cell??F,card:M,previous:D?.card,sectionKey:C.sectionKey})}}let f=[],p=new Map;for(let $ of r.links){let P=l.get($.from),F=l.get($.to)??a.get($.to);if(!P||!F||P.cell.id===F.cell.id)continue;let C=JSON.stringify([$.from,$.to]),D=(p.get(C)??0)+1;p.set(C,D);let de=$i([r.source,C,D,P.cell.id,F.cell.id]);f.push({sourceKey:de,from:P.cell.id,to:F.cell.id,why:$.why,evidence:[P.card.id,F.card.id],fromPath:$.from,toPath:$.to})}let m=[...l.values()].filter(({previous:$,card:P})=>$===void 0||!o&&$.importSource?.digest!==P.importSource?.digest),{pending:h,arcs:g,strands:y}=t.previewImportedLinks(f.map(({sourceKey:$,from:P,to:F,why:C,evidence:D})=>({sourceKey:$,from:P,to:F,why:C,evidence:D}))),v={cells:c.size,cards:m.filter($=>!$.previous).length,updatedCards:m.filter($=>$.previous).length,arcs:g,strands:y},k=$i([r,[...l].map(([$,P])=>[$,P.cell.id,P.previous?.id]),f,h,[...u.keys()],v]);if(n===void 0)return{preview:!0,...v,token:k};if(n!==k)throw new w("\u7B14\u8BB0\u3001\u65B9\u6848\u6216\u5BAB\u6BBF\u5DF2\u53D8\u5316\uFF0C\u8BF7\u91CD\u65B0\u9884\u89C8\u5E76\u786E\u8BA4");(m.length||c.size||u.size)&&await e.mutate($=>{for(let P of c.values())Object.assign(P,En($.palace,null)),$.palace.cells.push(P),$.createItem(bt(P.id,null));for(let[P,F]of u)$.item(P).chapters=Is(F);for(let{cell:P,card:F,previous:C,sectionKey:D}of m){let de=$.item(P.id);D!==void 0&&(F.sectionId=de.chapters.flatMap(se=>se.sections).find(se=>se.loc===D)?.id);let{cards:M}=de,me=C===void 0?-1:M.findIndex(se=>se.id===C.id);me===-1?M.push(F):M[me]=F}}),t.addImportedLinks(h);let T=new Set(t.validLinks().map($=>$.sourceKey)),x=new Map;for(let{sourceKey:$,from:P,to:F,fromPath:C,toPath:D,evidence:de}of f)if(T.has($)&&x.set([P,F].sort().join(":"),{from:P,to:F,fromPath:C,toPath:D,evidence:de}),x.size===20)break;return{preview:!1,...v,links:[...x.values()]}}var al={book:"\u4E66",note:"\u7B14\u8BB0",group:"\u5206\u7EC4"},G_={excerpt:"\u6458\u5F55",thought:"\u60F3\u6CD5",mistake:"\u9519\u9898"};function J_(e,t,r){let n=`${al[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=Wt(o),i=_s(o),a=o.cards.filter(c=>c.type==="mistake"&&c.status==="todo").length;o.source!==null&&(n+=` \u539F\u6587 ${o.source.type}${o.source.type==="pdf"?` ${o.source.pageCount} \u9875`:""}`),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`),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 qE(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(J_(e,o,t));for(let s of r.filter(i=>i.parentId===o.id))n.push(` ${J_(e,s,t)}`)}return n.join(`
99
- `)}function FE(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}
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}
100
100
  ${a.sections.map(u=>` - ${u.done?"[x]":"[ ]"} ${u.title} (section_id=${u.id})`).join(`
101
101
  `)}`).join(`
102
- `),s=n.cards.slice(-20).map(a=>`- ${G_[a.type]} ${a.id}\uFF1A${(a.quote??a.note??"").slice(0,60)}`).join(`
102
+ `),s=n.cards.slice(-20).map(a=>`- ${ew[a.type]} ${a.id}\uFF1A${(a.quote??a.note??"").slice(0,60)}`).join(`
103
103
  `),i=n.inspirations.slice(-10).map(a=>`- ${a.id} ${a.createdAt.slice(0,10)} ${a.title}`).join(`
104
104
  `);return`\u300A${r.title}\u300B\u76EE\u5F55\uFF1A
105
105
  ${o}`+(s?`
@@ -108,33 +108,33 @@ ${o}`+(s?`
108
108
  ${s}`:"")+(i?`
109
109
 
110
110
  \u7075\u611F\uFF1A
111
- ${i}`:"")}function LE(e,t){let r=At(e,t.sectionId);return r?` ${r.chapter.title} \u203A ${r.section.title}`:""}async function Ie(e){try{return await e()}catch(t){if(t instanceof w)return`\u64CD\u4F5C\u5931\u8D25\uFF1A${t.message}`;throw t}}function UE(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 Ie(async()=>r.item_id===void 0?qE(e,n.highlightId):FE(e,r.item_id))}}}function W_(e,t,r){let n=r.currentItem?{type:"string"}:{type:"string",minLength:1,required:!0,description:"\u76EE\u6807\u683C\u5B50 id"};return[UE(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 Ie(async()=>{if(o.kind!=="book"){let u=await jt(e,{kind:o.kind,title:o.title,subtitle:o.subtitle,parentId:o.parent_id});return`\u5DF2\u65B0\u5EFA${al[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=Wt(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 Ie(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 zs(e,{id:s.id}),`\u5DF2\u5220\u9664${al[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 Ie(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 ===
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
112
  ${l.text||"\uFF08\u65E0\u6587\u5B57\uFF09"}`).join(`
113
113
 
114
114
  `);return c.length>0&&(u+=`
115
115
 
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 Ie(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 Es(e,{id:o.item_id,chapters:a,source:"ai"});return`\u5DF2\u5199\u5165\u76EE\u5F55\uFF1A${c.chapters.length} \u7AE0 ${Wt(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 Ie(async()=>{let s=[];for(let i of o.items){let a=await Ps(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=_s(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
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
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 Ie(async()=>{let i=o.item_id,a=e.getItem(i),c=o.section_id??(o.type==="thought"?void 0:Wt(a).current?.section.id),u=r.saveImage(o.image),l=await Ts(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${LE(e.getItem(i),l)}\u7684${G_[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 Ie(async()=>{let i=o.item_id,a=await Os(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 Ie(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
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
119
  \u4E00\u53E5\u8BDD\uFF1A${s.summary??"\uFF08\u65E0\uFF09"}
120
120
  \u4E3B\u9898\u8BCD\uFF1A${s.topics?.join("\u3001")??"\uFF08\u65E0\uFF09"}
121
121
 
122
122
  ${s.body}`+(a>0?`
123
123
 
124
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 ${uo} \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 Ie(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 Ie(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 Ie(async()=>(t.cut({from:o.from,to:o.to}),"\u5DF2\u526A\u65AD\u3002"))}}]}function Y_(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 Ie(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 Ie(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 il(e,t,i,o.confirmation))})}}]}function X_(e,t,r){return[{name:"palace_scan_weread",description:"\u9884\u89C8\u5FAE\u4FE1\u8BFB\u4E66\u4E66\u67B6\u548C\u6709\u5212\u7EBF\u6216\u60F3\u6CD5\u7684\u4E66\u3002\u7528\u6237\u63D0\u51FA\u5BFC\u5165\u65F6\uFF0C\u5148\u7528\u8FD9\u4E9B\u4FE1\u606F\u5546\u91CF\u8981\u5BFC\u5165\u54EA\u4E9B\u4E66\u3002",parameters:{},async execute(n,{signal:o}){return Ie(async()=>JSON.stringify(await r.scan(o)))}},{name:"palace_import_weread",description:"\u628A\u9009\u4E2D\u7684\u5FAE\u4FE1\u8BFB\u4E66\u4E66\u548C\u7B14\u8BB0\u5BFC\u5165\u5BAB\u6BBF\u3002plan \u586B\u626B\u63CF\u5F97\u5230\u7684 bookId \u5217\u8868\u3002\u5148\u7701\u7565 confirmation \u8FDB\u884C\u9884\u89C8\uFF0C\u7B49\u7528\u6237\u786E\u8BA4\u540E\u7528\u540C\u4E00\u65B9\u6848\u548C\u9884\u89C8\u7684 token \u5199\u5165\u3002",parameters:{plan:{type:"array",required:!0,items:{type:"string"}},confirmation:{type:"string"}},async execute({plan:n,confirmation:o},{signal:s}){return Ie(async()=>{if(o!==void 0&&typeof o!="string")throw new w("\u8BF7\u4F7F\u7528\u9884\u89C8\u8FD4\u56DE\u7684 token");let i=await r.prepare(n,o!==void 0,s);if(s?.aborted)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u5BFC\u5165\u5DF2\u53D6\u6D88");return JSON.stringify(await il(e,t,i,o,!0))})}}]}function Q_(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 ew(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 YE,copyFileSync as XE,existsSync as ul,mkdirSync as QE,openSync as eT,readdirSync as tT,readSync as rT,statSync as nT}from"node:fs";import{homedir as pw}from"node:os";import{basename as fw,extname as Si,isAbsolute as mw,join as fo}from"node:path";var tw="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130 Safari/537.36",lo=class extends Error{};function rw(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 VE(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":tw},signal:nw(t)})).url.match(/BV[0-9A-Za-z]{10}/);if(s)return s[0]}throw new lo("\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 BE(e,t){let r=await fetch(`https://api.bilibili.com/x/web-interface/view?bvid=${e}`,{headers:{"user-agent":tw,referer:"https://www.bilibili.com/"},signal:nw(t)});if(!r.ok)throw new lo(`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 lo(`B \u7AD9\u8FD4\u56DE\u9519\u8BEF\uFF1A${n.message??n.code}`);return n.data}function nw(e){let t=AbortSignal.timeout(15e3);return e?AbortSignal.any([e,t]):t}async function ow(e,t){let r=await VE(e,t),n=await BE(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 HE}from"node:fs/promises";import{createRequire as KE}from"node:module";import{dirname as JE,join as sw,sep as iw}from"node:path";var GE=KE(import.meta.url),aw;function WE(){return aw??=import("pdfjs-dist/legacy/build/pdf.mjs"),aw}function cl(){return JE(GE.resolve("pdfjs-dist/package.json"))}async function lw(e){let t=await WE(),r=new Uint8Array(await HE(e)),n=cl(),o=t.getDocument({data:r,cMapUrl:sw(n,"cmaps")+iw,cMapPacked:!0,standardFontDataUrl:sw(n,"standard_fonts")+iw,isEvalSupported:!1,disableFontFace:!0,verbosity:0});return{doc:await o.promise,close:()=>o.destroy()}}async function cw(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 uw(e){return e.replace(/\s+/g," ").trim()}async function dw(e){let{doc:t,close:r}=await lw(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=uw(u.title);l!==""&&a.push({title:l,page:await cw(t,u.dest)})}let c=uw(i.title);c!==""&&o.push({title:c,page:await cw(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 ki(e,t){let{doc:r,close:n}=await lw(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
+ ${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+=`
126
126
  `));o.push({page:s,text:c.replace(/[ \t]+/g," ").replace(/\n{3,}/g,`
127
127
 
128
- `).trim()}),i.cleanup()}return o}finally{await n()}}var xi=20;function po(e){return e.startsWith("~/")?fo(pw(),e.slice(2)):e}async function zi(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||!rw(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(),jt(e,{kind:"book",title:t.title.trim(),subtitle:t.subtitle,source:{type:"video",url:u},parentId:t.parentId,targetDate:t.targetDate})}let l=await ow(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=po(t.file.trim().replace(/^['"]|['"]$/g,""));if(!mw(u))throw new w("\u8BF7\u63D0\u4F9B PDF \u7684\u5B8C\u6574\u8DEF\u5F84\uFF08\u4EE5 / \u5F00\u5934\uFF09");if(!ul(u)||!nT(u).isFile())throw new w(`\u627E\u4E0D\u5230\u6587\u4EF6\uFF1A${u}`);let l=Si(u).toLowerCase();if(l!==".pdf"&&l!==".epub")throw new w("\u76EE\u524D\u53EA\u652F\u6301 PDF \u548C EPUB \u6587\u4EF6");if(l===".epub"){if(!oT(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=fw(u,l),typeof t.title=="string"&&t.title.trim()!==""&&(i=t.title.trim()),o(),jt(e,{kind:"book",title:i,subtitle:t.subtitle,source:s,parentId:t.parentId,targetDate:t.targetDate})}let d=await dw(u).catch(f=>{throw new w(`PDF \u6253\u4E0D\u5F00\uFF1A${f.message}`)});s={type:"pdf",path:u,pageCount:d.pageCount},i=fw(u,Si(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(),jt(e,{kind:"book",title:i,subtitle:t.subtitle,source:s,parentId:t.parentId,targetDate:t.targetDate,outline:a,outlineSource:c})}function oT(e){let t=eT(e,"r");try{let r=Buffer.alloc(4);return rT(t,r,0,4,0)===4&&r.equals(Buffer.from([80,75,3,4]))}finally{YE(t)}}function sT(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??fo(pw(),".dsh"),n=fo(r,"attachments","v1","objects",t.slice(0,2));if(!ul(n))return;let o=tT(n).find(s=>s.startsWith(t));return o===void 0?void 0:fo(n,o)}var iT=new Set([".png",".jpg",".jpeg",".webp",".gif"]);function hw(e,t){if(typeof t!="string"||t.trim()==="")return;let r=po(t.trim().replace(/^['"]|['"]$/g,"")),n=mw(r)&&ul(r)?r:sT(r);if(n===void 0)return;let o=iT.has(Si(n).toLowerCase())?Si(n).toLowerCase():".png",s=`${He("img")}${o}`;return e.assertWritable(),e.snapshotBeforeWrite(),QE(e.imagesDir,{recursive:!0}),XE(n,fo(e.imagesDir,s)),s}import{createHash as aT}from"node:crypto";import{constants as gw}from"node:fs";import{open as cT,readdir as uT,realpath as lT,stat as dT}from"node:fs/promises";import{isAbsolute as fT,join as yw,posix as zt}from"node:path";function pT(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=zt.basename(t).replace(/\.md$/i,"").replace(/[\r\n]+/g," "),s=r.match(/\r?\n/)?.[0]??`
129
- `;return`# ${o}${s}${s}${e}`}async function _w(e,t){if(typeof e!="string"||!fT(po(e)))throw new w("\u8BF7\u63D0\u4F9B Obsidian \u7B14\u8BB0\u5E93\u7684\u7EDD\u5BF9\u8DEF\u5F84");let r=[],n=[],o;try{if(o=await lT(po(e)),!(await dT(o)).isDirectory())throw new w("\u8BF7\u9009\u62E9 Obsidian \u7B14\u8BB0\u5E93\u6587\u4EF6\u5939");async function c(u){t?.throwIfAborted();let l=await uT(yw(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=zt.join(u,d.name);if(d.isDirectory()){await c(f);continue}if(!d.isFile()||!/\.md$/i.test(d.name))continue;let p=await cT(yw(o,f),gw.O_RDONLY|gw.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??""),k=v?v[1]+v[2].replace(/^[ \t]*-[ \t]+/gm," "):"",T=new Set(k.match(/[\p{L}\p{N}_/-]+/gu)??[]),x=y.replace(/<!--[^]*?(?:-->|$)|%%[^]*?(?:%%|$)/g,P=>P.replace(/[^\r\n]/g," ")),$;for(let P of x.split(/\r?\n/)){let F=/^ {0,3}(`{3,}|~{3,})/.exec(P)?.[1];if(F&&!$){$=F;continue}if($){F?.startsWith($)&&P.trim()===F&&($=void 0);continue}let C=P.replace(/(`+)[^`]*\1/g,D=>" ".repeat(D.length));for(let D of C.matchAll(/(?:^|[\s((,。!?、;:])#([\p{L}\p{N}_/-]+)/gu))T.add(D[1]);for(let D of C.matchAll(/(!|\\)?\[\[([^\]\n]+)\]\]/g)){if(D[1])continue;let de=D[2].split(/[|#]/,1)[0].trim();if(!de)continue;let M=D.index,me=M+D[0].length,se=P.slice(0,M).split(/[。!?!?]/).at(-1)??"",Pt=P.slice(me).split(/[。!?!?]/,1)[0],_l=[...(se+D[0]+Pt).trim()],Hw=_l.length<=40?_l.join(""):[...se.trimEnd()].slice(-8).concat([...D[0]+Pt]).slice(0,40).join("").trim();n.push({from:f,to:de,why:Hw})}}r.push({key:f,note:pT(y,f,m),frontmatter:g,tags:[...T].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=zt.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=zt.normalize(zt.join(zt.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 ww={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 _w(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=zt.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 _w(e,r);if(o.length===0)throw new w("\u8FD9\u4E2A\u6587\u4EF6\u5939\u6CA1\u6709 Markdown \u7B14\u8BB0");let i="obsidian:"+aT("sha256").update(n).digest("hex"),a=[];if(t===void 0){let c=new Map;for(let u of o){let l=zt.dirname(u.key),d=c.get(l)??{key:"folder:"+l,title:zt.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 mT}from"node:crypto";import{mkdirSync as hT,readFileSync as gT,realpathSync as bw,renameSync as yT,rmSync as vw,writeFileSync as _T}from"node:fs";import{homedir as wT}from"node:os";import{basename as bT,dirname as $w,isAbsolute as vT,join as xw,relative as $T,sep as kT}from"node:path";import{setTimeout as xT}from"node:timers/promises";var ST="https://i.weread.qq.com/api/agent/gateway",zT="1.0.6",Sw=e=>typeof e=="string"&&/^wrk-[A-Za-z0-9_-]+$/.test(e),zw=xw(wT(),".dsh-palace","weread.json");function Pw(e=zw){try{let{key:t}=JSON.parse(gT(e,"utf8"));if(Sw(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 Iw(e,t=zw,r){if(e===void 0)return Pw(t)!==void 0;if(e!==null&&!Sw(e))throw new w("\u8BF7\u8F93\u5165\u6709\u6548\u7684\u5FAE\u4FE1\u8BFB\u4E66 API Key");let n=t+"."+mT();try{if(e===null)return vw(t,{force:!0}),!1;if(hT($w(t),{recursive:!0,mode:448}),r!==void 0){let o=$T(bw(r),xw(bw($w(t)),bT(t)));if(!vT(o)&&o!==".."&&!o.startsWith(".."+kT))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"}),yT(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{vw(n,{force:!0})}catch{}}}var kw=({chapterUid:e,range:t})=>e!=null&&t?.trim()?JSON.stringify([String(e),t]):void 0,PT={"/shelf/sync":"books","/user/notebooks":"books","/review/list/mine":"reviews","/book/chapterinfo":"chapters","/book/bookmarklist":"updated"};function IT(e,t){let r=[];for(let o of e){let s=o.title?.trim();if(!s)continue;let i=o.level??1,a={title:s,loc:String(o.chapterUid),sections:[]};i===1||i===2&&!r.length?r.push(a):i===2&&r.at(-1).sections.push({title:a.title,loc:a.loc})}let n=new Set(t.map(o=>o.sectionKey));for(let o of r)o.sections?.length&&o.loc&&n.has(o.loc)&&o.sections.unshift({title:o.title,loc:o.loc});return r}function ET(e=fetch,t=Pw){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(ST,{method:"POST",redirect:"error",signal:h,headers:{Authorization:`Bearer ${c}`,"Content-Type":"application/json"},body:JSON.stringify({api_name:u,skill_version:zT,...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 v=Number(h.headers.get("retry-after")??1);if(v>=0&&v<=3&&!f)return await xT(v*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");if(!Array.isArray(g[PT[u]]))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){let u=o();i={key:u,data:await s(u,c)},a=void 0;let{books:l,total:d}=i.data;return{total:d,withNotes:[...l.values()].filter(f=>f.hasNotes).length,books:[...l.values()].map(({bookId:f,title:p,author:m,category:h,finishReading:g,readUpdateTime:y,publishTime:v,hasNotes:k})=>({bookId:f,title:p,author:m,category:h,finished:g===1,readUpdateTime:y,publishTime:v,hasNotes:k}))}},async prepare(c,u,l){if(!Array.isArray(c)||c.length===0||c.some(y=>typeof y!="string"||!y))throw new w("\u8BF7\u63D0\u4F9B\u8981\u5BFC\u5165\u7684 bookId \u5217\u8868");let d=o(),f=[...new Set(c)],p=JSON.stringify(f);if(u&&a?.key===d&&a.plan===p)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:m}=i?.key===d?i.data:await s(d,l),h=[];for(let y of f){let v=m.get(y);if(!v)throw new w("\u9009\u4E2D\u7684\u4E66\u4E0D\u5728\u4E66\u67B6\u6216\u7B14\u8BB0\u672C\u91CC\uFF0C\u8BF7\u91CD\u65B0\u626B\u63CF");let k=[v.readerLink,v.deepLink].find(M=>typeof M=="string"&&/^https?:\/\//.test(M)),T={key:y,kind:"book",title:v.title,href:k,cards:[]};if(h.push(T),!v.hasNotes)continue;let x=async()=>{let M=[],me=0;for(;;){let se=await n(d,"/review/list/mine",{bookid:y,synckey:me,count:100},l);if(M.push(...se.reviews),!se.hasMore)return M;if(!se.synckey||se.synckey===me)throw new w("\u5FAE\u4FE1\u8BFB\u4E66\u60F3\u6CD5\u5217\u8868\u5206\u9875\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");me=se.synckey}},[$,P,F]=await Promise.all([n(d,"/book/chapterinfo",{bookId:y},l),n(d,"/book/bookmarklist",{bookId:y},l),x()]),C=new Map,D=new Map;for(let M of P.updated)if(M.markText?.trim()){let me=JSON.stringify([y,"bookmark",M.bookmarkId]),se={key:me,type:"excerpt",quote:M.markText,sectionKey:M.chapterUid?.toString()};C.set(me,se);let Pt=kw(M);Pt!==void 0&&D.set(Pt,se)}let de=new Map(F.map(({review:M})=>[M.reviewId,M]));for(let M of de.values())if(M.abstract?.trim()||M.content?.trim()){let me=kw(M),se=me===void 0?void 0:D.get(me);if(se){M.content?.trim()&&(se.note=se.note?se.note+`
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
130
 
131
- `+M.content:M.content);continue}let Pt=JSON.stringify([y,"review",M.reviewId]);C.set(Pt,{key:Pt,type:M.abstract?.trim()?"excerpt":"thought",quote:M.abstract||void 0,note:M.content,sectionKey:M.chapterUid?.toString()})}T.cards=[...C.values()],T.chapters=IT($.chapters,T.cards)}let g={source:"weread",groups:h,links:[]};return a={key:d,plan:p,batch:g},g}}}var Ew=ET();var OT=new Set(["palace_remove","palace_unlink"]),RT=new Set(["palace_overview","palace_read","palace_wiki_read","palace_context","palace_open","palace_scan_obsidian","palace_scan_weread"]);function ll(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,ll(i)])),o.required=Object.entries(r).filter(([,s])=>s.required===!0).map(([s])=>s)),n&&(o.items=ll(n)),o}var AT="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 Tw(e,t){let r=new Br(e),n=W_(e,r,{addBook:(c,u)=>zi(e,c,u,{readVideo:!1}),readPageTexts:ki,scannedThreshold:xi,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"&&TT(c)?hw(e,c):void 0}),o=new Vr,s=Q_(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,...Y_(e,r,ww),...X_(e,r,Ew),s,ew(t)].map(({name:c,description:u,parameters:l,execute:d})=>{let f=ll({type:"object",properties:l,additionalProperties:!1}),p={name:c,description:u,inputSchema:f,annotations:{readOnlyHint:RT.has(c),destructiveHint:OT.has(c)}};return[c,{tool:p,execute:d,validate:o.getValidator(f)}]})),a=new vi({name:"dsh-palace",version:"1.0.0"},{capabilities:{tools:{}},jsonSchemaValidator:o,instructions:AT});return a.setRequestHandler(Ha,()=>({tools:[...i.values()].map(({tool:c})=>c)})),a.setRequestHandler(kn,async({params:c},{signal:u})=>{let l=i.get(c.name);if(!l)throw new A(j.InvalidParams,"\u672A\u77E5\u5DE5\u5177");let d=l.validate(c.arguments??{});if(!d.valid)throw new A(j.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 CT}from"node:crypto";import{lstatSync as Ow,mkdirSync as NT,readFileSync as jT,renameSync as DT,rmSync as ZT,writeFileSync as MT}from"node:fs";import{dirname as qT}from"node:path";var dl=e=>JSON.stringify(e).replace(/\u007f/g,"\\u007f"),fl=()=>new Error("\u68C0\u6D4B\u5230\u590D\u6742\u7684 MCP \u914D\u7F6E\uFF0C\u8BF7\u6309 README \u624B\u52A8\u8BBE\u7F6E dsh-palace"),pl=/(?:[\w-]+|"[^"\\]*"|'[^']*')/.source,FT=new RegExp(`^\\s*(\\[\\[?)\\s*(${pl}(?:\\s*\\.\\s*${pl})*)\\s*(\\]\\]?)\\s*(?:#.*)?$`),Rw=e=>new RegExp(`^\\s*(?:${e}|"${e}"|'${e}')\\s*[.=]`);function Aw(e,t){let r=`${e}.${CT()}.tmp`;try{MT(r,t,{mode:384,flag:"wx"}),DT(r,e)}finally{ZT(r,{force:!0})}}function Cw(e,t,r){let n=Ow(e,{throwIfNoEntry:!1});if(n&&!n.isFile())throw fl();let o=n?jT(e,"utf8"):"";if(o.includes('"""')||o.includes("'''"))throw fl();let s=o.includes(`\r
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
132
132
  `)?`\r
133
133
  `:`
134
- `,i=[],a=(o.match(/[^\n]*\n|[^\n]+$/g)??[]).filter(l=>{let d=FT.exec(l.trimEnd());d&&(i=[...d[2].matchAll(new RegExp(pl,"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&&Rw("mcp_servers").test(l)||i.length===1&&i[0]==="mcp_servers"&&Rw("dsh-palace").test(l))throw fl();return!f}).join(""),c=["[mcp_servers.dsh-palace]",`command = ${dl(process.execPath)}`,`args = [${dl(t)}]`];r!==void 0&&c.push("","[mcp_servers.dsh-palace.env]",`DSH_PALACE_DATA_DIR = ${dl(r)}`);let u=a+(a&&!a.endsWith(`
135
- `)?s:"")+c.join(s)+s;if(u!==o){if(n?Aw(`${e}.bak`,o):NT(qT(e),{recursive:!0}),Ow(e,{throwIfNoEntry:!1})?.mtimeMs!==n?.mtimeMs)throw new Error("Codex \u914D\u7F6E\u521A\u88AB\u522B\u5904\u6539\u8FC7\uFF0C\u8BF7\u91CD\u8BD5");Aw(e,u)}}import{once as sO}from"node:events";import{createReadStream as iO}from"node:fs";import{createServer as aO}from"node:http";import{Readable as Fw}from"node:stream";import{pipeline as Lw}from"node:stream/promises";import{execFile as VT,spawn as hl}from"node:child_process";import{createReadStream as BT,existsSync as dr,statSync as HT}from"node:fs";import{homedir as KT}from"node:os";import{basename as JT,extname as GT,join as ho,normalize as WT,sep as yl}from"node:path";import{Readable as YT}from"node:stream";import{fileURLToPath as Dw}from"node:url";import{execFile as LT}from"node:child_process";var UT=`ObjC.import('CoreServices')
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')
136
136
  function run(argv) {
137
137
  const w = $(argv[0])
138
138
  const r = $.DCSCopyTextDefinition($(), w, $.CFRangeMake(0, w.length))
139
139
  return r ? ObjC.unwrap(ObjC.castRefToObject(r)) : ''
140
- }`,ml=/^[A-Za-zÀ-ɏ]+(?:['’-][A-Za-zÀ-ɏ]+)*$/,mo=new Map;async function jw(e){if(process.platform!=="darwin")return{supported:!1,definition:null};let t=await Nw(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 Nw(r):null;return{supported:!0,definition:t,...n!==null?{lemma:{word:r,definition:n}}:{}}}async function Nw(e){if(!ml.test(e)||e.length>80)return null;if(mo.has(e))return mo.get(e);let t=await new Promise((n,o)=>{LT("osascript",["-l","JavaScript","-e",UT,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 mo.size>2e3&&mo.clear(),mo.set(e,r),r}var XT="/api/dsh-palace";function QT(e,t){if(t.kind==="book"||t.source!==void 0)throw new w("\u6DFB\u52A0\u4E66\u8BF7\u7528 addBook");return jt(e,{...t,outline:void 0,outlineSource:void 0})}var Zw={addBook:zi,addCell:QT,updateCell:$h,moveCell:kh,groupCells:xh,deleteCell:zs,updateItem:Ps,setPosition:Sh,setOutline:Es,setSectionDone:zh,markUpTo:Ph,resetProgress:Ih,addCard:Ts,updateCard:Rh,deleteCard:Ah,addInspiration:Os,updateInspiration:Ch,deleteInspiration:Nh};function le(e,t=200){return new Response(JSON.stringify(e),{status:t,headers:{"content-type":"application/json; charset=utf-8","cache-control":"no-store"}})}function eO(e){return e instanceof w?le({ok:!1,error:e.message},400):(console.error("[dsh-palace]",e),le({ok:!1,error:`\u5185\u90E8\u9519\u8BEF\uFF1A${e?.message??String(e)}`},500))}function Hr(e,t){let r=HT(e).size,n=YT.toWeb(BT(e));return new Response(n,{headers:{"content-type":t,"content-length":String(r),"cache-control":"no-store"}})}function Mw(e){let t=KT();return e===t||e.startsWith(t+yl)?"~"+e.slice(t.length):e}function Kr(e){let t=process.platform==="darwin"?hl("open",[e],{detached:!0,stdio:"ignore"}):process.platform==="win32"?hl("cmd",["/c","start","",e],{detached:!0,stdio:"ignore",windowsHide:!0}):hl("xdg-open",[e],{detached:!0,stdio:"ignore"});t.on("error",r=>console.error("[dsh-palace] \u6253\u5F00\u5931\u8D25",e,r)),t.unref()}function tO(){return process.platform!=="darwin"?Promise.resolve(void 0):new Promise(e=>{VT("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 rO=["jszip.min.js","epub.min.js"];function gl(){let e=Dw(new URL("../vendor/",import.meta.url));return dr(e)?e:Dw(new URL("../../vendor/",import.meta.url))}var nO={webp:"image/webp",png:"image/png",svg:"image/svg+xml",ttf:"font/ttf",woff2:"font/woff2"},oO={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".gif":"image/gif"};function Pi(e,t){Ct(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 qw(e,t,r=new Br(e)){let n=(o,s,i)=>({path:`${XT}/${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 eO(c)}}});return[n("POST","weread-key",({body:o})=>le({ok:!0,saved:Iw(o.key,void 0,e.dir)})),n("GET","palace",()=>le({ok:!0,rev:e.rev,palace:e.getPalace(),summaries:e.summaries(),dataDir:Mw(e.dir)})),n("GET","chat-workspace",()=>le({ok:!0,cwd:e.dir})),n("GET","arcs",()=>le({ok:!0,rev:e.rev,arcs:r.arcs()})),n("POST","cut-arc",({body:o})=>(r.cut({from:o.from,to:o.to}),le({ok:!0,rev:e.rev}))),n("GET","lookup",async({url:o})=>le({ok:!0,...await jw(o.searchParams.get("word")??"")})),n("POST","open-dictionary",({body:o})=>{let s=typeof o.word=="string"?o.word:"";if(process.platform!=="darwin"||!ml.test(s))throw new w("\u65E0\u6CD5\u6253\u5F00\u8BCD\u5178");return Kr(`dict://${encodeURIComponent(s)}`),le({ok:!0})}),n("GET","item",({url:o})=>le({ok:!0,rev:e.rev,item:Pi(e,o.searchParams.get("id"))})),n("GET","rev",()=>le({ok:!0,rev:e.checkDisk()})),n("POST","op",async({body:o,signal:s})=>{let i=String(o.op),a=Object.hasOwn(Zw,i)?Zw[i]:void 0;if(a===void 0)return le({ok:!1,error:`\u672A\u77E5\u64CD\u4F5C ${i}`},400);let c=await a(e,o.args??{},s);return le({ok:!0,rev:e.rev,result:c??null})}),n("GET","file",({url:o})=>{let s=Pi(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 dr(s.path)?Hr(s.path,s.type==="pdf"?"application/pdf":"application/epub+zip"):le({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=Pi(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 ki(s.path,i),c=a.filter(u=>u.text.length<xi).map(u=>u.page);return le({ok:!0,pages:a,scanned:c})}),n("GET","image",({url:o})=>{let s=JT(o.searchParams.get("name")??""),i=ho(e.imagesDir,s),a=oO[GT(s).toLowerCase()];return s===""||a===void 0||!dr(i)?new Response("not found",{status:404}):Hr(i,a)}),n("GET","asset",({url:o})=>{let s=WT(o.searchParams.get("f")??"");if(s.startsWith("reader/")){let d=s.slice(7);if(!rO.includes(d))return new Response("not found",{status:404});let f=Hr(ho(gl(),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(yl).join("/"));if(i!==null){let d=ho(gl(),s);if(!dr(d))return new Response("not found",{status:404});let f=Hr(d,nO[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=ho(gl(),"fonts",`${a}.woff2`);if(!dr(d))return new Response("not found",{status:404});let f=Hr(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+yl))||s.includes(".."))return new Response("not found",{status:404});let u=ho(cl(),s);if(!dr(u))return new Response("not found",{status:404});let l=Hr(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()=>le({ok:!0,path:await tO()})),n("POST","open",({body:o})=>{if(o.target==="welcome")return Kr(ec),le({ok:!0});if(o.target==="dataDir")return Kr(e.dir),le({ok:!0});let s=e.getPalace().cells.find(u=>u.id===o.id)?.href;if(s!==void 0&&/^https?:\/\//.test(s))return Kr(s),le({ok:!0});let i=Pi(e,o.id),a=At(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 Kr(u!==void 0&&/^https?:\/\//.test(u)?u:c.url),le({ok:!0})}if(!dr(c.path))throw new w(`\u627E\u4E0D\u5230\u6587\u4EF6\uFF1A${Mw(c.path)}`);return Kr(c.path),le({ok:!0})}),n("POST","active",({body:o})=>{let s=typeof o.sessionId=="string"?o.sessionId:void 0;return s===void 0?le({ok:!1,error:"\u7F3A\u5C11 sessionId"},400):(typeof o.itemId=="string"?t.set(s,o.itemId):t.delete(s),le({ok:!0}))})]}var Uw="127.0.0.1",cO='<!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 Vw(e,t=4196){let r=new Map(qw(e,new Map).map(a=>[a.path,a])),n=aO(async(a,c)=>{let u=a.headers.host,l=a.socket.localPort,d=`http://${u}`;if(u!==`${Uw}:${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(cO);return}if(a.method==="GET"&&p==="/palace-web.js"){c.setHeader("content-type","text/javascript; charset=utf-8"),await Lw(iO(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"?Fw.toWeb(a):void 0,k={method:a.method,headers:a.headers,body:v,duplex:"half",signal:y.signal},T=await m.fetch(new Request(f,k));c.writeHead(T.status,Object.fromEntries(T.headers)),T.body===null?c.end():await Lw(Fw.from(T.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,Uw),sO(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 pO(){let e=process.env.DSH_PALACE_DATA_DIR,t=e??Ii(Bw(),"Documents","dsh-palace-data");if(!lO(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=fO(import.meta.url);if(r&&n.split(dO).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&&!uO(Ii(t,"palace.json")),s=new xs(t,{create:o});if(r){o&&await vh(s);let c=Ii(process.env.CODEX_HOME||Ii(Bw(),".codex"),"config.toml");Cw(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 Vw(s),a=Tw(s,i.url);a.onclose=i.close,process.stdin.once("end",()=>{a.close()}),await a.connect(new gs).catch(c=>{throw i.close(),c})}pO().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});