claude-mem 13.6.2 → 13.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +3 -0
- package/dist/npx-cli/index.js +279 -297
- package/openclaw/openclaw.plugin.json +1 -1
- package/package.json +2 -2
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/package.json +2 -2
- package/plugin/scripts/context-generator.cjs +56 -87
- package/plugin/scripts/mcp-server.cjs +30 -30
- package/plugin/scripts/server-beta-service.cjs +133 -133
- package/plugin/scripts/transcript-watcher.cjs +13 -13
- package/plugin/scripts/worker-service.cjs +268 -318
- package/plugin/skills/version-bump/SKILL.md +15 -9
- package/plugin/ui/viewer-bundle.js +11 -11
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var K_=Object.create;var Bs=Object.defineProperty;var G_=Object.getOwnPropertyDescriptor;var J_=Object.getOwnPropertyNames;var Y_=Object.getPrototypeOf,X_=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Au=(t,e)=>{for(var r in e)Bs(t,r,{get:e[r],enumerable:!0})},Q_=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of J_(e))!X_.call(t,o)&&o!==r&&Bs(t,o,{get:()=>e[o],enumerable:!(n=G_(e,o))||n.enumerable});return t};var xt=(t,e,r)=>(r=t!=null?K_(Y_(t)):{},Q_(e||!t||!t.__esModule?Bs(r,"default",{value:t,enumerable:!0}):r,t));var _n=w(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.regexpCode=Z.getEsmExportName=Z.getProperty=Z.safeStringify=Z.stringify=Z.strConcat=Z.addCodeArg=Z.str=Z._=Z.nil=Z._Code=Z.Name=Z.IDENTIFIER=Z._CodeOrName=void 0;var hn=class{};Z._CodeOrName=hn;Z.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Wt=class extends hn{constructor(e){if(super(),!Z.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Z.Name=Wt;var qe=class extends hn{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Wt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Z._Code=qe;Z.nil=new qe("");function em(t,...e){let r=[t[0]],n=0;for(;n<e.length;)da(r,e[n]),r.push(t[++n]);return new qe(r)}Z._=em;var la=new qe("+");function tm(t,...e){let r=[gn(t[0])],n=0;for(;n<e.length;)r.push(la),da(r,e[n]),r.push(la,gn(t[++n]));return Rb(r),new qe(r)}Z.str=tm;function da(t,e){e instanceof qe?t.push(...e._items):e instanceof Wt?t.push(e):t.push(Ab(e))}Z.addCodeArg=da;function Rb(t){let e=1;for(;e<t.length-1;){if(t[e]===la){let r=Ib(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Ib(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Wt||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Wt))return`"${t}${e.slice(1)}`}function Ob(t,e){return e.emptyStr()?t:t.emptyStr()?e:tm`${t}${e}`}Z.strConcat=Ob;function Ab(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:gn(Array.isArray(t)?t.join(","):t)}function Mb(t){return new qe(gn(t))}Z.stringify=Mb;function gn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Z.safeStringify=gn;function Cb(t){return typeof t=="string"&&Z.IDENTIFIER.test(t)?new qe(`.${t}`):em`[${t}]`}Z.getProperty=Cb;function Nb(t){if(typeof t=="string"&&Z.IDENTIFIER.test(t))return new qe(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Z.getEsmExportName=Nb;function Db(t){return new qe(t.toString())}Z.regexpCode=Db});var ma=w(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.ValueScope=Re.ValueScopeName=Re.Scope=Re.varKinds=Re.UsedValueState=void 0;var ze=_n(),pa=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Zo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Zo||(Re.UsedValueState=Zo={}));Re.varKinds={const:new ze.Name("const"),let:new ze.Name("let"),var:new ze.Name("var")};var Fo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof ze.Name?e:this.name(e)}name(e){return new ze.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Re.Scope=Fo;var Ho=class extends ze.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,ze._)`.${new ze.Name(r)}[${n}]`}};Re.ValueScopeName=Ho;var jb=(0,ze._)`\n`,fa=class extends Fo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?jb:ze.nil}}get(){return this._scope}name(e){return new Ho(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,ze._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=ze.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Zo.Started);let l=r(u);if(l){let d=this.opts.es5?Re.varKinds.var:Re.varKinds.const;s=(0,ze._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,ze._)`${s}${l}${this.opts._n}`;else throw new pa(u);c.set(u,Zo.Completed)})}return s}};Re.ValueScope=fa});var A=w(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.or=M.and=M.not=M.CodeGen=M.operators=M.varKinds=M.ValueScopeName=M.ValueScope=M.Scope=M.Name=M.regexpCode=M.stringify=M.getProperty=M.nil=M.strConcat=M.str=M._=void 0;var j=_n(),Je=ma(),At=_n();Object.defineProperty(M,"_",{enumerable:!0,get:function(){return At._}});Object.defineProperty(M,"str",{enumerable:!0,get:function(){return At.str}});Object.defineProperty(M,"strConcat",{enumerable:!0,get:function(){return At.strConcat}});Object.defineProperty(M,"nil",{enumerable:!0,get:function(){return At.nil}});Object.defineProperty(M,"getProperty",{enumerable:!0,get:function(){return At.getProperty}});Object.defineProperty(M,"stringify",{enumerable:!0,get:function(){return At.stringify}});Object.defineProperty(M,"regexpCode",{enumerable:!0,get:function(){return At.regexpCode}});Object.defineProperty(M,"Name",{enumerable:!0,get:function(){return At.Name}});var Ko=ma();Object.defineProperty(M,"Scope",{enumerable:!0,get:function(){return Ko.Scope}});Object.defineProperty(M,"ValueScope",{enumerable:!0,get:function(){return Ko.ValueScope}});Object.defineProperty(M,"ValueScopeName",{enumerable:!0,get:function(){return Ko.ValueScopeName}});Object.defineProperty(M,"varKinds",{enumerable:!0,get:function(){return Ko.varKinds}});M.operators={GT:new j._Code(">"),GTE:new j._Code(">="),LT:new j._Code("<"),LTE:new j._Code("<="),EQ:new j._Code("==="),NEQ:new j._Code("!=="),NOT:new j._Code("!"),OR:new j._Code("||"),AND:new j._Code("&&"),ADD:new j._Code("+")};var _t=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},ha=class extends _t{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Je.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=gr(this.rhs,e,r)),this}get names(){return this.rhs instanceof j._CodeOrName?this.rhs.names:{}}},Wo=class extends _t{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof j.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=gr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof j.Name?{}:{...this.lhs.names};return Bo(e,this.rhs)}},ga=class extends Wo{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},_a=class extends _t{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},ya=class extends _t{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},Sa=class extends _t{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},va=class extends _t{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=gr(this.code,e,r),this}get names(){return this.code instanceof j._CodeOrName?this.code.names:{}}},yn=class extends _t{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(Lb(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Kt(e,r.names),{})}},yt=class extends yn{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},ba=class extends yn{},hr=class extends yt{};hr.kind="else";var Vt=class t extends yt{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new hr(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(rm(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=gr(this.condition,e,r),this}get names(){let e=super.names;return Bo(e,this.condition),this.else&&Kt(e,this.else.names),e}};Vt.kind="if";var Bt=class extends yt{};Bt.kind="for";var Ea=class extends Bt{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=gr(this.iteration,e,r),this}get names(){return Kt(super.names,this.iteration.names)}},wa=class extends Bt{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?Je.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Bo(super.names,this.from);return Bo(e,this.to)}},Vo=class extends Bt{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=gr(this.iterable,e,r),this}get names(){return Kt(super.names,this.iterable.names)}},Sn=class extends yt{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};Sn.kind="func";var vn=class extends yn{render(e){return"return "+super.render(e)}};vn.kind="return";var ka=class extends yt{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Kt(e,this.catch.names),this.finally&&Kt(e,this.finally.names),e}},bn=class extends yt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};bn.kind="catch";var En=class extends yt{render(e){return"finally"+super.render(e)}};En.kind="finally";var xa=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
-
`:""},this._extScope=e,this._scope=new Je.Scope({parent:e}),this._nodes=[new ba]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new ha(e,s,n)),s}const(e,r,n){return this._def(Je.varKinds.const,e,r,n)}let(e,r,n){return this._def(Je.varKinds.let,e,r,n)}var(e,r,n){return this._def(Je.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Wo(e,r,n))}add(e,r){return this._leafNode(new ga(e,M.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==j.nil&&this._leafNode(new va(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,j.addCodeArg)(r,o));return r.push("}"),new j._Code(r)}if(e,r,n){if(this._blockNode(new Vt(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Vt(e))}else(){return this._elseNode(new hr)}endIf(){return this._endBlockNode(Vt,hr)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new Ea(e),r)}forRange(e,r,n,o,s=this.opts.es5?Je.varKinds.var:Je.varKinds.let){let i=this._scope.toName(e);return this._for(new wa(s,i,r,n),()=>o(i))}forOf(e,r,n,o=Je.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof j.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,j._)`${i}.length`,a=>{this.var(s,(0,j._)`${i}[${a}]`),n(s)})}return this._for(new Vo("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?Je.varKinds.var:Je.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,j._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Vo("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Bt)}label(e){return this._leafNode(new _a(e))}break(e){return this._leafNode(new ya(e))}return(e){let r=new vn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(vn)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new ka;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new bn(s),r(s)}return n&&(this._currNode=o.finally=new En,this.code(n)),this._endBlockNode(bn,En)}throw(e){return this._leafNode(new Sa(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=j.nil,n,o){return this._blockNode(new Sn(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Sn)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof Vt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};M.CodeGen=xa;function Kt(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Bo(t,e){return e instanceof j._CodeOrName?Kt(t,e.names):t}function gr(t,e,r){if(t instanceof j.Name)return n(t);if(!o(t))return t;return new j._Code(t._items.reduce((s,i)=>(i instanceof j.Name&&(i=n(i)),i instanceof j._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof j._Code&&s._items.some(i=>i instanceof j.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Lb(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function rm(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,j._)`!${$a(t)}`}M.not=rm;var Ub=nm(M.operators.AND);function qb(...t){return t.reduce(Ub)}M.and=qb;var Zb=nm(M.operators.OR);function Fb(...t){return t.reduce(Zb)}M.or=Fb;function nm(t){return(e,r)=>e===j.nil?r:r===j.nil?e:(0,j._)`${$a(e)} ${t} ${$a(r)}`}function $a(t){return t instanceof j.Name?t:(0,j._)`(${t})`}});var F=w(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.checkStrictMode=C.getErrorPath=C.Type=C.useFunc=C.setEvaluated=C.evaluatedPropsToName=C.mergeEvaluated=C.eachItem=C.unescapeJsonPointer=C.escapeJsonPointer=C.escapeFragment=C.unescapeFragment=C.schemaRefOrVal=C.schemaHasRulesButRef=C.schemaHasRules=C.checkUnknownRules=C.alwaysValidSchema=C.toHash=void 0;var B=A(),Hb=_n();function Wb(t){let e={};for(let r of t)e[r]=!0;return e}C.toHash=Wb;function Vb(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(im(t,e),!am(e,t.self.RULES.all))}C.alwaysValidSchema=Vb;function im(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||lm(t,`unknown keyword: "${s}"`)}C.checkUnknownRules=im;function am(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}C.schemaHasRules=am;function Bb(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}C.schemaHasRulesButRef=Bb;function Kb({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,B._)`${r}`}return(0,B._)`${t}${e}${(0,B.getProperty)(n)}`}C.schemaRefOrVal=Kb;function Gb(t){return cm(decodeURIComponent(t))}C.unescapeFragment=Gb;function Jb(t){return encodeURIComponent(Ta(t))}C.escapeFragment=Jb;function Ta(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}C.escapeJsonPointer=Ta;function cm(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}C.unescapeJsonPointer=cm;function Yb(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}C.eachItem=Yb;function om({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof B.Name?(s instanceof B.Name?t(o,s,i):e(o,s,i),i):s instanceof B.Name?(e(o,i,s),s):r(s,i);return a===B.Name&&!(c instanceof B.Name)?n(o,c):c}}C.mergeEvaluated={props:om({mergeNames:(t,e,r)=>t.if((0,B._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,B._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,B._)`${r} || {}`).code((0,B._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,B._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,B._)`${r} || {}`),za(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:um}),items:om({mergeNames:(t,e,r)=>t.if((0,B._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,B._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,B._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,B._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function um(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,B._)`{}`);return e!==void 0&&za(t,r,e),r}C.evaluatedPropsToName=um;function za(t,e,r){Object.keys(r).forEach(n=>t.assign((0,B._)`${e}${(0,B.getProperty)(n)}`,!0))}C.setEvaluated=za;var sm={};function Xb(t,e){return t.scopeValue("func",{ref:e,code:sm[e.code]||(sm[e.code]=new Hb._Code(e.code))})}C.useFunc=Xb;var Pa;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(Pa||(C.Type=Pa={}));function Qb(t,e,r){if(t instanceof B.Name){let n=e===Pa.Num;return r?n?(0,B._)`"[" + ${t} + "]"`:(0,B._)`"['" + ${t} + "']"`:n?(0,B._)`"/" + ${t}`:(0,B._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,B.getProperty)(t).toString():"/"+Ta(t)}C.getErrorPath=Qb;function lm(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}C.checkStrictMode=lm});var St=w(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});var ve=A(),eE={data:new ve.Name("data"),valCxt:new ve.Name("valCxt"),instancePath:new ve.Name("instancePath"),parentData:new ve.Name("parentData"),parentDataProperty:new ve.Name("parentDataProperty"),rootData:new ve.Name("rootData"),dynamicAnchors:new ve.Name("dynamicAnchors"),vErrors:new ve.Name("vErrors"),errors:new ve.Name("errors"),this:new ve.Name("this"),self:new ve.Name("self"),scope:new ve.Name("scope"),json:new ve.Name("json"),jsonPos:new ve.Name("jsonPos"),jsonLen:new ve.Name("jsonLen"),jsonPart:new ve.Name("jsonPart")};Ra.default=eE});var wn=w(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.extendErrors=be.resetErrorsCount=be.reportExtraError=be.reportError=be.keyword$DataError=be.keywordError=void 0;var q=A(),Go=F(),$e=St();be.keywordError={message:({keyword:t})=>(0,q.str)`must pass "${t}" keyword validation`};be.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,q.str)`"${t}" keyword must be ${e} ($data)`:(0,q.str)`"${t}" keyword is invalid ($data)`};function tE(t,e=be.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=fm(t,e,r);n??(i||a)?dm(s,c):pm(o,(0,q._)`[${c}]`)}be.reportError=tE;function rE(t,e=be.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=fm(t,e,r);dm(o,a),s||i||pm(n,$e.default.vErrors)}be.reportExtraError=rE;function nE(t,e){t.assign($e.default.errors,e),t.if((0,q._)`${$e.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,q._)`${$e.default.vErrors}.length`,e),()=>t.assign($e.default.vErrors,null)))}be.resetErrorsCount=nE;function oE({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,$e.default.errors,a=>{t.const(i,(0,q._)`${$e.default.vErrors}[${a}]`),t.if((0,q._)`${i}.instancePath === undefined`,()=>t.assign((0,q._)`${i}.instancePath`,(0,q.strConcat)($e.default.instancePath,s.errorPath))),t.assign((0,q._)`${i}.schemaPath`,(0,q.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,q._)`${i}.schema`,r),t.assign((0,q._)`${i}.data`,n))})}be.extendErrors=oE;function dm(t,e){let r=t.const("err",e);t.if((0,q._)`${$e.default.vErrors} === null`,()=>t.assign($e.default.vErrors,(0,q._)`[${r}]`),(0,q._)`${$e.default.vErrors}.push(${r})`),t.code((0,q._)`${$e.default.errors}++`)}function pm(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,q._)`new ${t.ValidationError}(${e})`):(r.assign((0,q._)`${n}.errors`,e),r.return(!1))}var Gt={keyword:new q.Name("keyword"),schemaPath:new q.Name("schemaPath"),params:new q.Name("params"),propertyName:new q.Name("propertyName"),message:new q.Name("message"),schema:new q.Name("schema"),parentSchema:new q.Name("parentSchema")};function fm(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,q._)`{}`:sE(t,e,r)}function sE(t,e,r={}){let{gen:n,it:o}=t,s=[iE(o,r),aE(t,r)];return cE(t,e,s),n.object(...s)}function iE({errorPath:t},{instancePath:e}){let r=e?(0,q.str)`${t}${(0,Go.getErrorPath)(e,Go.Type.Str)}`:t;return[$e.default.instancePath,(0,q.strConcat)($e.default.instancePath,r)]}function aE({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,q.str)`${e}/${t}`;return r&&(o=(0,q.str)`${o}${(0,Go.getErrorPath)(r,Go.Type.Str)}`),[Gt.schemaPath,o]}function cE(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Gt.keyword,o],[Gt.params,typeof e=="function"?e(t):e||(0,q._)`{}`]),c.messages&&n.push([Gt.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Gt.schema,i],[Gt.parentSchema,(0,q._)`${l}${d}`],[$e.default.data,s]),u&&n.push([Gt.propertyName,u])}});var hm=w(_r=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.boolOrEmptySchema=_r.topBoolOrEmptySchema=void 0;var uE=wn(),lE=A(),dE=St(),pE={message:"boolean schema is false"};function fE(t){let{gen:e,schema:r,validateName:n}=t;r===!1?mm(t,!1):typeof r=="object"&&r.$async===!0?e.return(dE.default.data):(e.assign((0,lE._)`${n}.errors`,null),e.return(!0))}_r.topBoolOrEmptySchema=fE;function mE(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),mm(t)):r.var(e,!0)}_r.boolOrEmptySchema=mE;function mm(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,uE.reportError)(o,pE,void 0,e)}});var Ia=w(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.getRules=yr.isJSONType=void 0;var hE=["string","number","integer","boolean","null","object","array"],gE=new Set(hE);function _E(t){return typeof t=="string"&&gE.has(t)}yr.isJSONType=_E;function yE(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}yr.getRules=yE});var Oa=w(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.shouldUseRule=Mt.shouldUseGroup=Mt.schemaHasRulesForType=void 0;function SE({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&gm(t,n)}Mt.schemaHasRulesForType=SE;function gm(t,e){return e.rules.some(r=>_m(t,r))}Mt.shouldUseGroup=gm;function _m(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Mt.shouldUseRule=_m});var kn=w(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var vE=Ia(),bE=Oa(),EE=wn(),O=A(),ym=F(),Sr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Sr||(Ee.DataType=Sr={}));function wE(t){let e=Sm(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ee.getSchemaTypes=wE;function Sm(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(vE.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ee.getJSONTypes=Sm;function kE(t,e){let{gen:r,data:n,opts:o}=t,s=xE(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,bE.schemaHasRulesForType)(t,e[0]));if(i){let a=Ma(e,n,o.strictNumbers,Sr.Wrong);r.if(a,()=>{s.length?$E(t,e,s):Ca(t)})}return i}Ee.coerceAndCheckDataType=kE;var vm=new Set(["string","number","integer","boolean","null"]);function xE(t,e){return e?t.filter(r=>vm.has(r)||e==="array"&&r==="array"):[]}function $E(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,O._)`typeof ${o}`),a=n.let("coerced",(0,O._)`undefined`);s.coerceTypes==="array"&&n.if((0,O._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,O._)`${o}[0]`).assign(i,(0,O._)`typeof ${o}`).if(Ma(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,O._)`${a} !== undefined`);for(let u of r)(vm.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Ca(t),n.endIf(),n.if((0,O._)`${a} !== undefined`,()=>{n.assign(o,a),PE(t,a)});function c(u){switch(u){case"string":n.elseIf((0,O._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,O._)`"" + ${o}`).elseIf((0,O._)`${o} === null`).assign(a,(0,O._)`""`);return;case"number":n.elseIf((0,O._)`${i} == "boolean" || ${o} === null
|
|
2
|
+
"use strict";var G_=Object.create;var Ks=Object.defineProperty;var J_=Object.getOwnPropertyDescriptor;var Y_=Object.getOwnPropertyNames;var X_=Object.getPrototypeOf,Q_=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>{try{return e||t((e={exports:{}}).exports,e),e.exports}catch(r){throw e=0,r}},Cu=(t,e)=>{for(var r in e)Ks(t,r,{get:e[r],enumerable:!0})},ey=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Y_(e))!Q_.call(t,o)&&o!==r&&Ks(t,o,{get:()=>e[o],enumerable:!(n=J_(e,o))||n.enumerable});return t};var xt=(t,e,r)=>(r=t!=null?G_(X_(t)):{},ey(e||!t||!t.__esModule?Ks(r,"default",{value:t,enumerable:!0}):r,t));var gn=w(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.regexpCode=Z.getEsmExportName=Z.getProperty=Z.safeStringify=Z.stringify=Z.strConcat=Z.addCodeArg=Z.str=Z._=Z.nil=Z._Code=Z.Name=Z.IDENTIFIER=Z._CodeOrName=void 0;var mn=class{};Z._CodeOrName=mn;Z.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Wt=class extends mn{constructor(e){if(super(),!Z.IDENTIFIER.test(e))throw new Error("CodeGen: name must be a valid identifier");this.str=e}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};Z.Name=Wt;var qe=class extends mn{constructor(e){super(),this._items=typeof e=="string"?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===""||e==='""'}get str(){var e;return(e=this._str)!==null&&e!==void 0?e:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var e;return(e=this._names)!==null&&e!==void 0?e:this._names=this._items.reduce((r,n)=>(n instanceof Wt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};Z._Code=qe;Z.nil=new qe("");function rm(t,...e){let r=[t[0]],n=0;for(;n<e.length;)fa(r,e[n]),r.push(t[++n]);return new qe(r)}Z._=rm;var pa=new qe("+");function nm(t,...e){let r=[hn(t[0])],n=0;for(;n<e.length;)r.push(pa),fa(r,e[n]),r.push(pa,hn(t[++n]));return Ib(r),new qe(r)}Z.str=nm;function fa(t,e){e instanceof qe?t.push(...e._items):e instanceof Wt?t.push(e):t.push(Mb(e))}Z.addCodeArg=fa;function Ib(t){let e=1;for(;e<t.length-1;){if(t[e]===pa){let r=Ob(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Ob(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Wt||t[t.length-1]!=='"'?void 0:typeof e!="string"?`${t.slice(0,-1)}${e}"`:e[0]==='"'?t.slice(0,-1)+e.slice(1):void 0;if(typeof e=="string"&&e[0]==='"'&&!(t instanceof Wt))return`"${t}${e.slice(1)}`}function Ab(t,e){return e.emptyStr()?t:t.emptyStr()?e:nm`${t}${e}`}Z.strConcat=Ab;function Mb(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:hn(Array.isArray(t)?t.join(","):t)}function Cb(t){return new qe(hn(t))}Z.stringify=Cb;function hn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}Z.safeStringify=hn;function Nb(t){return typeof t=="string"&&Z.IDENTIFIER.test(t)?new qe(`.${t}`):rm`[${t}]`}Z.getProperty=Nb;function Db(t){if(typeof t=="string"&&Z.IDENTIFIER.test(t))return new qe(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}Z.getEsmExportName=Db;function jb(t){return new qe(t.toString())}Z.regexpCode=jb});var ga=w(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.ValueScope=Re.ValueScopeName=Re.Scope=Re.varKinds=Re.UsedValueState=void 0;var ze=gn(),ma=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},qo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(qo||(Re.UsedValueState=qo={}));Re.varKinds={const:new ze.Name("const"),let:new ze.Name("let"),var:new ze.Name("var")};var Zo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof ze.Name?e:this.name(e)}name(e){return new ze.Name(this._newName(e))}_newName(e){let r=this._names[e]||this._nameGroup(e);return`${e}${r.index++}`}_nameGroup(e){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(e)||this._prefixes&&!this._prefixes.has(e))throw new Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};Re.Scope=Zo;var Fo=class extends ze.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,ze._)`.${new ze.Name(r)}[${n}]`}};Re.ValueScopeName=Fo;var Lb=(0,ze._)`\n`,ha=class extends Zo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?Lb:ze.nil}}get(){return this._scope}name(e){return new Fo(e,this._newName(e))}value(e,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(e),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(e,r){let n=this._values[e];if(n)return n.get(r)}scopeRefs(e,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,ze._)`${e}${n.scopePath}`})}scopeCode(e=this._values,r,n){return this._reduceValues(e,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(e,r,n={},o){let s=ze.nil;for(let i in e){let a=e[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,qo.Started);let l=r(u);if(l){let d=this.opts.es5?Re.varKinds.var:Re.varKinds.const;s=(0,ze._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,ze._)`${s}${l}${this.opts._n}`;else throw new ma(u);c.set(u,qo.Completed)})}return s}};Re.ValueScope=ha});var A=w(M=>{"use strict";Object.defineProperty(M,"__esModule",{value:!0});M.or=M.and=M.not=M.CodeGen=M.operators=M.varKinds=M.ValueScopeName=M.ValueScope=M.Scope=M.Name=M.regexpCode=M.stringify=M.getProperty=M.nil=M.strConcat=M.str=M._=void 0;var j=gn(),Je=ga(),At=gn();Object.defineProperty(M,"_",{enumerable:!0,get:function(){return At._}});Object.defineProperty(M,"str",{enumerable:!0,get:function(){return At.str}});Object.defineProperty(M,"strConcat",{enumerable:!0,get:function(){return At.strConcat}});Object.defineProperty(M,"nil",{enumerable:!0,get:function(){return At.nil}});Object.defineProperty(M,"getProperty",{enumerable:!0,get:function(){return At.getProperty}});Object.defineProperty(M,"stringify",{enumerable:!0,get:function(){return At.stringify}});Object.defineProperty(M,"regexpCode",{enumerable:!0,get:function(){return At.regexpCode}});Object.defineProperty(M,"Name",{enumerable:!0,get:function(){return At.Name}});var Bo=ga();Object.defineProperty(M,"Scope",{enumerable:!0,get:function(){return Bo.Scope}});Object.defineProperty(M,"ValueScope",{enumerable:!0,get:function(){return Bo.ValueScope}});Object.defineProperty(M,"ValueScopeName",{enumerable:!0,get:function(){return Bo.ValueScopeName}});Object.defineProperty(M,"varKinds",{enumerable:!0,get:function(){return Bo.varKinds}});M.operators={GT:new j._Code(">"),GTE:new j._Code(">="),LT:new j._Code("<"),LTE:new j._Code("<="),EQ:new j._Code("==="),NEQ:new j._Code("!=="),NOT:new j._Code("!"),OR:new j._Code("||"),AND:new j._Code("&&"),ADD:new j._Code("+")};var gt=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},_a=class extends gt{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Je.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(e,r){if(e[this.name.str])return this.rhs&&(this.rhs=gr(this.rhs,e,r)),this}get names(){return this.rhs instanceof j._CodeOrName?this.rhs.names:{}}},Ho=class extends gt{constructor(e,r,n){super(),this.lhs=e,this.rhs=r,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,r){if(!(this.lhs instanceof j.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=gr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof j.Name?{}:{...this.lhs.names};return Vo(e,this.rhs)}},ya=class extends Ho{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Sa=class extends gt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},va=class extends gt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},ba=class extends gt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},Ea=class extends gt{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,r){return this.code=gr(this.code,e,r),this}get names(){return this.code instanceof j._CodeOrName?this.code.names:{}}},_n=class extends gt{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((r,n)=>r+n.render(e),"")}optimizeNodes(){let{nodes:e}=this,r=e.length;for(;r--;){let n=e[r].optimizeNodes();Array.isArray(n)?e.splice(r,1,...n):n?e[r]=n:e.splice(r,1)}return e.length>0?this:void 0}optimizeNames(e,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(e,r)||(Ub(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Kt(e,r.names),{})}},_t=class extends _n{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},wa=class extends _n{},hr=class extends _t{};hr.kind="else";var Vt=class t extends _t{constructor(e,r){super(r),this.condition=e}render(e){let r=`if(${this.condition})`+super.render(e);return this.else&&(r+="else "+this.else.render(e)),r}optimizeNodes(){super.optimizeNodes();let e=this.condition;if(e===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new hr(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(om(e),r instanceof t?[r]:r.nodes);if(!(e===!1||!this.nodes.length))return this}optimizeNames(e,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(e,r),!!(super.optimizeNames(e,r)||this.else))return this.condition=gr(this.condition,e,r),this}get names(){let e=super.names;return Vo(e,this.condition),this.else&&Kt(e,this.else.names),e}};Vt.kind="if";var Bt=class extends _t{};Bt.kind="for";var ka=class extends Bt{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iteration=gr(this.iteration,e,r),this}get names(){return Kt(super.names,this.iteration.names)}},xa=class extends Bt{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?Je.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(e)}get names(){let e=Vo(super.names,this.from);return Vo(e,this.to)}},Wo=class extends Bt{constructor(e,r,n,o){super(),this.loop=e,this.varKind=r,this.name=n,this.iterable=o}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,r){if(super.optimizeNames(e,r))return this.iterable=gr(this.iterable,e,r),this}get names(){return Kt(super.names,this.iterable.names)}},yn=class extends _t{constructor(e,r,n){super(),this.name=e,this.args=r,this.async=n}render(e){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(e)}};yn.kind="func";var Sn=class extends _n{render(e){return"return "+super.render(e)}};Sn.kind="return";var $a=class extends _t{render(e){let r="try"+super.render(e);return this.catch&&(r+=this.catch.render(e)),this.finally&&(r+=this.finally.render(e)),r}optimizeNodes(){var e,r;return super.optimizeNodes(),(e=this.catch)===null||e===void 0||e.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(e,r){var n,o;return super.optimizeNames(e,r),(n=this.catch)===null||n===void 0||n.optimizeNames(e,r),(o=this.finally)===null||o===void 0||o.optimizeNames(e,r),this}get names(){let e=super.names;return this.catch&&Kt(e,this.catch.names),this.finally&&Kt(e,this.finally.names),e}},vn=class extends _t{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};vn.kind="catch";var bn=class extends _t{render(e){return"finally"+super.render(e)}};bn.kind="finally";var Pa=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
|
|
3
|
+
`:""},this._extScope=e,this._scope=new Je.Scope({parent:e}),this._nodes=[new wa]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,r){let n=this._extScope.value(e,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,r){return this._extScope.getValue(e,r)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new _a(e,s,n)),s}const(e,r,n){return this._def(Je.varKinds.const,e,r,n)}let(e,r,n){return this._def(Je.varKinds.let,e,r,n)}var(e,r,n){return this._def(Je.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new Ho(e,r,n))}add(e,r){return this._leafNode(new ya(e,M.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==j.nil&&this._leafNode(new Ea(e)),this}object(...e){let r=["{"];for(let[n,o]of e)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,j.addCodeArg)(r,o));return r.push("}"),new j._Code(r)}if(e,r,n){if(this._blockNode(new Vt(e)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(e){return this._elseNode(new Vt(e))}else(){return this._elseNode(new hr)}endIf(){return this._endBlockNode(Vt,hr)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new ka(e),r)}forRange(e,r,n,o,s=this.opts.es5?Je.varKinds.var:Je.varKinds.let){let i=this._scope.toName(e);return this._for(new xa(s,i,r,n),()=>o(i))}forOf(e,r,n,o=Je.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof j.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,j._)`${i}.length`,a=>{this.var(s,(0,j._)`${i}[${a}]`),n(s)})}return this._for(new Wo("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?Je.varKinds.var:Je.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,j._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Wo("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Bt)}label(e){return this._leafNode(new Sa(e))}break(e){return this._leafNode(new va(e))}return(e){let r=new Sn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Sn)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new $a;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new vn(s),r(s)}return n&&(this._currNode=o.finally=new bn,this.code(n)),this._endBlockNode(vn,bn)}throw(e){return this._leafNode(new ba(e))}block(e,r){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(r),this}endBlock(e){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||e!==void 0&&n!==e)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=r,this}func(e,r=j.nil,n,o){return this._blockNode(new yn(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(yn)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,r){let n=this._currNode;if(n instanceof e||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${e.kind}/${r.kind}`:e.kind}"`)}_elseNode(e){let r=this._currNode;if(!(r instanceof Vt))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let r=this._nodes;r[r.length-1]=e}};M.CodeGen=Pa;function Kt(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Vo(t,e){return e instanceof j._CodeOrName?Kt(t,e.names):t}function gr(t,e,r){if(t instanceof j.Name)return n(t);if(!o(t))return t;return new j._Code(t._items.reduce((s,i)=>(i instanceof j.Name&&(i=n(i)),i instanceof j._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||e[s.str]!==1?s:(delete e[s.str],i)}function o(s){return s instanceof j._Code&&s._items.some(i=>i instanceof j.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function Ub(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function om(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,j._)`!${Ta(t)}`}M.not=om;var qb=sm(M.operators.AND);function Zb(...t){return t.reduce(qb)}M.and=Zb;var Fb=sm(M.operators.OR);function Hb(...t){return t.reduce(Fb)}M.or=Hb;function sm(t){return(e,r)=>e===j.nil?r:r===j.nil?e:(0,j._)`${Ta(e)} ${t} ${Ta(r)}`}function Ta(t){return t instanceof j.Name?t:(0,j._)`(${t})`}});var F=w(C=>{"use strict";Object.defineProperty(C,"__esModule",{value:!0});C.checkStrictMode=C.getErrorPath=C.Type=C.useFunc=C.setEvaluated=C.evaluatedPropsToName=C.mergeEvaluated=C.eachItem=C.unescapeJsonPointer=C.escapeJsonPointer=C.escapeFragment=C.unescapeFragment=C.schemaRefOrVal=C.schemaHasRulesButRef=C.schemaHasRules=C.checkUnknownRules=C.alwaysValidSchema=C.toHash=void 0;var B=A(),Wb=gn();function Vb(t){let e={};for(let r of t)e[r]=!0;return e}C.toHash=Vb;function Bb(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(cm(t,e),!um(e,t.self.RULES.all))}C.alwaysValidSchema=Bb;function cm(t,e=t.schema){let{opts:r,self:n}=t;if(!r.strictSchema||typeof e=="boolean")return;let o=n.RULES.keywords;for(let s in e)o[s]||pm(t,`unknown keyword: "${s}"`)}C.checkUnknownRules=cm;function um(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}C.schemaHasRules=um;function Kb(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(r!=="$ref"&&e.all[r])return!0;return!1}C.schemaHasRulesButRef=Kb;function Gb({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,B._)`${r}`}return(0,B._)`${t}${e}${(0,B.getProperty)(n)}`}C.schemaRefOrVal=Gb;function Jb(t){return lm(decodeURIComponent(t))}C.unescapeFragment=Jb;function Yb(t){return encodeURIComponent(Ra(t))}C.escapeFragment=Yb;function Ra(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}C.escapeJsonPointer=Ra;function lm(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}C.unescapeJsonPointer=lm;function Xb(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}C.eachItem=Xb;function im({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof B.Name?(s instanceof B.Name?t(o,s,i):e(o,s,i),i):s instanceof B.Name?(e(o,i,s),s):r(s,i);return a===B.Name&&!(c instanceof B.Name)?n(o,c):c}}C.mergeEvaluated={props:im({mergeNames:(t,e,r)=>t.if((0,B._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,B._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,B._)`${r} || {}`).code((0,B._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,B._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,B._)`${r} || {}`),Ia(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:dm}),items:im({mergeNames:(t,e,r)=>t.if((0,B._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,B._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,B._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,B._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function dm(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,B._)`{}`);return e!==void 0&&Ia(t,r,e),r}C.evaluatedPropsToName=dm;function Ia(t,e,r){Object.keys(r).forEach(n=>t.assign((0,B._)`${e}${(0,B.getProperty)(n)}`,!0))}C.setEvaluated=Ia;var am={};function Qb(t,e){return t.scopeValue("func",{ref:e,code:am[e.code]||(am[e.code]=new Wb._Code(e.code))})}C.useFunc=Qb;var za;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(za||(C.Type=za={}));function eE(t,e,r){if(t instanceof B.Name){let n=e===za.Num;return r?n?(0,B._)`"[" + ${t} + "]"`:(0,B._)`"['" + ${t} + "']"`:n?(0,B._)`"/" + ${t}`:(0,B._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,B.getProperty)(t).toString():"/"+Ra(t)}C.getErrorPath=eE;function pm(t,e,r=t.opts.strictSchema){if(r){if(e=`strict mode: ${e}`,r===!0)throw new Error(e);t.self.logger.warn(e)}}C.checkStrictMode=pm});var yt=w(Oa=>{"use strict";Object.defineProperty(Oa,"__esModule",{value:!0});var ve=A(),tE={data:new ve.Name("data"),valCxt:new ve.Name("valCxt"),instancePath:new ve.Name("instancePath"),parentData:new ve.Name("parentData"),parentDataProperty:new ve.Name("parentDataProperty"),rootData:new ve.Name("rootData"),dynamicAnchors:new ve.Name("dynamicAnchors"),vErrors:new ve.Name("vErrors"),errors:new ve.Name("errors"),this:new ve.Name("this"),self:new ve.Name("self"),scope:new ve.Name("scope"),json:new ve.Name("json"),jsonPos:new ve.Name("jsonPos"),jsonLen:new ve.Name("jsonLen"),jsonPart:new ve.Name("jsonPart")};Oa.default=tE});var En=w(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.extendErrors=be.resetErrorsCount=be.reportExtraError=be.reportError=be.keyword$DataError=be.keywordError=void 0;var q=A(),Ko=F(),$e=yt();be.keywordError={message:({keyword:t})=>(0,q.str)`must pass "${t}" keyword validation`};be.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,q.str)`"${t}" keyword must be ${e} ($data)`:(0,q.str)`"${t}" keyword is invalid ($data)`};function rE(t,e=be.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=hm(t,e,r);n??(i||a)?fm(s,c):mm(o,(0,q._)`[${c}]`)}be.reportError=rE;function nE(t,e=be.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=hm(t,e,r);fm(o,a),s||i||mm(n,$e.default.vErrors)}be.reportExtraError=nE;function oE(t,e){t.assign($e.default.errors,e),t.if((0,q._)`${$e.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,q._)`${$e.default.vErrors}.length`,e),()=>t.assign($e.default.vErrors,null)))}be.resetErrorsCount=oE;function sE({gen:t,keyword:e,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=t.name("err");t.forRange("i",o,$e.default.errors,a=>{t.const(i,(0,q._)`${$e.default.vErrors}[${a}]`),t.if((0,q._)`${i}.instancePath === undefined`,()=>t.assign((0,q._)`${i}.instancePath`,(0,q.strConcat)($e.default.instancePath,s.errorPath))),t.assign((0,q._)`${i}.schemaPath`,(0,q.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,q._)`${i}.schema`,r),t.assign((0,q._)`${i}.data`,n))})}be.extendErrors=sE;function fm(t,e){let r=t.const("err",e);t.if((0,q._)`${$e.default.vErrors} === null`,()=>t.assign($e.default.vErrors,(0,q._)`[${r}]`),(0,q._)`${$e.default.vErrors}.push(${r})`),t.code((0,q._)`${$e.default.errors}++`)}function mm(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,q._)`new ${t.ValidationError}(${e})`):(r.assign((0,q._)`${n}.errors`,e),r.return(!1))}var Gt={keyword:new q.Name("keyword"),schemaPath:new q.Name("schemaPath"),params:new q.Name("params"),propertyName:new q.Name("propertyName"),message:new q.Name("message"),schema:new q.Name("schema"),parentSchema:new q.Name("parentSchema")};function hm(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,q._)`{}`:iE(t,e,r)}function iE(t,e,r={}){let{gen:n,it:o}=t,s=[aE(o,r),cE(t,r)];return uE(t,e,s),n.object(...s)}function aE({errorPath:t},{instancePath:e}){let r=e?(0,q.str)`${t}${(0,Ko.getErrorPath)(e,Ko.Type.Str)}`:t;return[$e.default.instancePath,(0,q.strConcat)($e.default.instancePath,r)]}function cE({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,q.str)`${e}/${t}`;return r&&(o=(0,q.str)`${o}${(0,Ko.getErrorPath)(r,Ko.Type.Str)}`),[Gt.schemaPath,o]}function uE(t,{params:e,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=t,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([Gt.keyword,o],[Gt.params,typeof e=="function"?e(t):e||(0,q._)`{}`]),c.messages&&n.push([Gt.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Gt.schema,i],[Gt.parentSchema,(0,q._)`${l}${d}`],[$e.default.data,s]),u&&n.push([Gt.propertyName,u])}});var _m=w(_r=>{"use strict";Object.defineProperty(_r,"__esModule",{value:!0});_r.boolOrEmptySchema=_r.topBoolOrEmptySchema=void 0;var lE=En(),dE=A(),pE=yt(),fE={message:"boolean schema is false"};function mE(t){let{gen:e,schema:r,validateName:n}=t;r===!1?gm(t,!1):typeof r=="object"&&r.$async===!0?e.return(pE.default.data):(e.assign((0,dE._)`${n}.errors`,null),e.return(!0))}_r.topBoolOrEmptySchema=mE;function hE(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),gm(t)):r.var(e,!0)}_r.boolOrEmptySchema=hE;function gm(t,e){let{gen:r,data:n}=t,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:t};(0,lE.reportError)(o,fE,void 0,e)}});var Aa=w(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.getRules=yr.isJSONType=void 0;var gE=["string","number","integer","boolean","null","object","array"],_E=new Set(gE);function yE(t){return typeof t=="string"&&_E.has(t)}yr.isJSONType=yE;function SE(){let t={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...t,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},t.number,t.string,t.array,t.object],post:{rules:[]},all:{},keywords:{}}}yr.getRules=SE});var Ma=w(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.shouldUseRule=Mt.shouldUseGroup=Mt.schemaHasRulesForType=void 0;function vE({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&ym(t,n)}Mt.schemaHasRulesForType=vE;function ym(t,e){return e.rules.some(r=>Sm(t,r))}Mt.shouldUseGroup=ym;function Sm(t,e){var r;return t[e.keyword]!==void 0||((r=e.definition.implements)===null||r===void 0?void 0:r.some(n=>t[n]!==void 0))}Mt.shouldUseRule=Sm});var wn=w(Ee=>{"use strict";Object.defineProperty(Ee,"__esModule",{value:!0});Ee.reportTypeError=Ee.checkDataTypes=Ee.checkDataType=Ee.coerceAndCheckDataType=Ee.getJSONTypes=Ee.getSchemaTypes=Ee.DataType=void 0;var bE=Aa(),EE=Ma(),wE=En(),O=A(),vm=F(),Sr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(Sr||(Ee.DataType=Sr={}));function kE(t){let e=bm(t.type);if(e.includes("null")){if(t.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!e.length&&t.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');t.nullable===!0&&e.push("null")}return e}Ee.getSchemaTypes=kE;function bm(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(bE.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}Ee.getJSONTypes=bm;function xE(t,e){let{gen:r,data:n,opts:o}=t,s=$E(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,EE.schemaHasRulesForType)(t,e[0]));if(i){let a=Na(e,n,o.strictNumbers,Sr.Wrong);r.if(a,()=>{s.length?PE(t,e,s):Da(t)})}return i}Ee.coerceAndCheckDataType=xE;var Em=new Set(["string","number","integer","boolean","null"]);function $E(t,e){return e?t.filter(r=>Em.has(r)||e==="array"&&r==="array"):[]}function PE(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,O._)`typeof ${o}`),a=n.let("coerced",(0,O._)`undefined`);s.coerceTypes==="array"&&n.if((0,O._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,O._)`${o}[0]`).assign(i,(0,O._)`typeof ${o}`).if(Na(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,O._)`${a} !== undefined`);for(let u of r)(Em.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Da(t),n.endIf(),n.if((0,O._)`${a} !== undefined`,()=>{n.assign(o,a),TE(t,a)});function c(u){switch(u){case"string":n.elseIf((0,O._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,O._)`"" + ${o}`).elseIf((0,O._)`${o} === null`).assign(a,(0,O._)`""`);return;case"number":n.elseIf((0,O._)`${i} == "boolean" || ${o} === null
|
|
4
4
|
|| (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,O._)`+${o}`);return;case"integer":n.elseIf((0,O._)`${i} === "boolean" || ${o} === null
|
|
5
5
|
|| (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,O._)`+${o}`);return;case"boolean":n.elseIf((0,O._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,O._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,O._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,O._)`${i} === "string" || ${i} === "number"
|
|
6
|
-
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,O._)`[${o}]`)}}}function PE({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,O._)`${e} !== undefined`,()=>t.assign((0,O._)`${e}[${r}]`,n))}function Aa(t,e,r,n=Sr.Correct){let o=n===Sr.Correct?O.operators.EQ:O.operators.NEQ,s;switch(t){case"null":return(0,O._)`${e} ${o} null`;case"array":s=(0,O._)`Array.isArray(${e})`;break;case"object":s=(0,O._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,O._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,O._)`typeof ${e} ${o} ${t}`}return n===Sr.Correct?s:(0,O.not)(s);function i(a=O.nil){return(0,O.and)((0,O._)`typeof ${e} == "number"`,a,r?(0,O._)`isFinite(${e})`:O.nil)}}Ee.checkDataType=Aa;function Ma(t,e,r,n){if(t.length===1)return Aa(t[0],e,r,n);let o,s=(0,ym.toHash)(t);if(s.array&&s.object){let i=(0,O._)`typeof ${e} != "object"`;o=s.null?i:(0,O._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=O.nil;s.number&&delete s.integer;for(let i in s)o=(0,O.and)(o,Aa(i,e,r,n));return o}Ee.checkDataTypes=Ma;var TE={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,O._)`{type: ${t}}`:(0,O._)`{type: ${e}}`};function Ca(t){let e=zE(t);(0,EE.reportError)(e,TE)}Ee.reportTypeError=Ca;function zE(t){let{gen:e,data:r,schema:n}=t,o=(0,ym.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Em=w(Jo=>{"use strict";Object.defineProperty(Jo,"__esModule",{value:!0});Jo.assignDefaults=void 0;var vr=A(),RE=F();function IE(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)bm(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>bm(t,s,o.default))}Jo.assignDefaults=IE;function bm(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,vr._)`${s}${(0,vr.getProperty)(e)}`;if(o){(0,RE.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,vr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,vr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,vr._)`${a} = ${(0,vr.stringify)(r)}`)}});var Ze=w(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.validateUnion=V.validateArray=V.usePattern=V.callValidateCode=V.schemaProperties=V.allSchemaProperties=V.noPropertyInData=V.propertyInData=V.isOwnProperty=V.hasPropFunc=V.reportMissingProp=V.checkMissingProp=V.checkReportMissingProp=void 0;var X=A(),Na=F(),Ct=St(),OE=F();function AE(t,e){let{gen:r,data:n,it:o}=t;r.if(ja(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,X._)`${e}`},!0),t.error()})}V.checkReportMissingProp=AE;function ME({gen:t,data:e,it:{opts:r}},n,o){return(0,X.or)(...n.map(s=>(0,X.and)(ja(t,e,s,r.ownProperties),(0,X._)`${o} = ${s}`)))}V.checkMissingProp=ME;function CE(t,e){t.setParams({missingProperty:e},!0),t.error()}V.reportMissingProp=CE;function wm(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,X._)`Object.prototype.hasOwnProperty`})}V.hasPropFunc=wm;function Da(t,e,r){return(0,X._)`${wm(t)}.call(${e}, ${r})`}V.isOwnProperty=Da;function NE(t,e,r,n){let o=(0,X._)`${e}${(0,X.getProperty)(r)} !== undefined`;return n?(0,X._)`${o} && ${Da(t,e,r)}`:o}V.propertyInData=NE;function ja(t,e,r,n){let o=(0,X._)`${e}${(0,X.getProperty)(r)} === undefined`;return n?(0,X.or)(o,(0,X.not)(Da(t,e,r))):o}V.noPropertyInData=ja;function km(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}V.allSchemaProperties=km;function DE(t,e){return km(e).filter(r=>!(0,Na.alwaysValidSchema)(t,e[r]))}V.schemaProperties=DE;function jE({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,X._)`${t}, ${e}, ${n}${o}`:e,d=[[Ct.default.instancePath,(0,X.strConcat)(Ct.default.instancePath,s)],[Ct.default.parentData,i.parentData],[Ct.default.parentDataProperty,i.parentDataProperty],[Ct.default.rootData,Ct.default.rootData]];i.opts.dynamicRef&&d.push([Ct.default.dynamicAnchors,Ct.default.dynamicAnchors]);let p=(0,X._)`${l}, ${r.object(...d)}`;return c!==X.nil?(0,X._)`${a}.call(${c}, ${p})`:(0,X._)`${a}(${p})`}V.callValidateCode=jE;var LE=(0,X._)`new RegExp`;function UE({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,X._)`${o.code==="new RegExp"?LE:(0,OE.useFunc)(t,o)}(${r}, ${n})`})}V.usePattern=UE;function qE(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,X._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:Na.Type.Num},s),e.if((0,X.not)(s),a)})}}V.validateArray=qE;function ZE(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,Na.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,X._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,X.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}V.validateUnion=ZE});var Pm=w(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.validateKeywordUsage=nt.validSchemaType=nt.funcKeywordCode=nt.macroKeywordCode=void 0;var Pe=A(),Jt=St(),FE=Ze(),HE=wn();function WE(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=$m(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:Pe.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}nt.macroKeywordCode=WE;function VE(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;KE(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=$m(n,o,u),d=n.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)_(),e.modifying&&xm(t),S(()=>t.error());else{let b=e.async?f():m();e.modifying&&xm(t),S(()=>BE(t,b))}}function f(){let b=n.let("ruleErrs",null);return n.try(()=>_((0,Pe._)`await `),E=>n.assign(d,!1).if((0,Pe._)`${E} instanceof ${c.ValidationError}`,()=>n.assign(b,(0,Pe._)`${E}.errors`),()=>n.throw(E))),b}function m(){let b=(0,Pe._)`${l}.errors`;return n.assign(b,null),_(Pe.nil),b}function _(b=e.async?(0,Pe._)`await `:Pe.nil){let E=c.opts.passContext?Jt.default.this:Jt.default.self,v=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,Pe._)`${b}${(0,FE.callValidateCode)(t,l,E,v)}`,e.modifying)}function S(b){var E;n.if((0,Pe.not)((E=e.valid)!==null&&E!==void 0?E:d),b)}}nt.funcKeywordCode=VE;function xm(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Pe._)`${n.parentData}[${n.parentDataProperty}]`))}function BE(t,e){let{gen:r}=t;r.if((0,Pe._)`Array.isArray(${e})`,()=>{r.assign(Jt.default.vErrors,(0,Pe._)`${Jt.default.vErrors} === null ? ${e} : ${Jt.default.vErrors}.concat(${e})`).assign(Jt.default.errors,(0,Pe._)`${Jt.default.vErrors}.length`),(0,HE.extendErrors)(t)},()=>t.error())}function KE({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function $m(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Pe.stringify)(r)})}function GE(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}nt.validSchemaType=GE;function JE({schema:t,opts:e,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}nt.validateKeywordUsage=JE});var zm=w(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.extendSubschemaMode=Nt.extendSubschemaData=Nt.getSubschema=void 0;var ot=A(),Tm=F();function YE(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,ot._)`${t.schemaPath}${(0,ot.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,ot._)`${t.schemaPath}${(0,ot.getProperty)(e)}${(0,ot.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Tm.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')}Nt.getSubschema=YE;function XE(t,e,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,p=a.let("data",(0,ot._)`${e.data}${(0,ot.getProperty)(r)}`,!0);c(p),t.errorPath=(0,ot.str)`${u}${(0,Tm.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,ot._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof ot.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Nt.extendSubschemaData=XE;function QE(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Nt.extendSubschemaMode=QE});var La=w((mM,Rm)=>{"use strict";Rm.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Om=w((hM,Im)=>{"use strict";var Dt=Im.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Yo(e,n,o,t,"",t)};Dt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Dt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Dt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Dt.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 Yo(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Dt.arrayKeywords)for(var p=0;p<d.length;p++)Yo(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in Dt.propsKeywords){if(d&&typeof d=="object")for(var f in d)Yo(t,e,r,d[f],o+"/"+l+"/"+ew(f),s,o,l,n,f)}else(l in Dt.keywords||t.allKeys&&!(l in Dt.skipKeywords))&&Yo(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function ew(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var xn=w(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.getSchemaRefs=Ie.resolveUrl=Ie.normalizeId=Ie._getFullPath=Ie.getFullPath=Ie.inlineRef=void 0;var tw=F(),rw=La(),nw=Om(),ow=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function sw(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Ua(t):e?Am(t)<=e:!1}Ie.inlineRef=sw;var iw=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Ua(t){for(let e in t){if(iw.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Ua)||typeof r=="object"&&Ua(r))return!0}return!1}function Am(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!ow.has(r)&&(typeof t[r]=="object"&&(0,tw.eachItem)(t[r],n=>e+=Am(n)),e===1/0))return 1/0}return e}function Mm(t,e="",r){r!==!1&&(e=br(e));let n=t.parse(e);return Cm(t,n)}Ie.getFullPath=Mm;function Cm(t,e){return t.serialize(e).split("#")[0]+"#"}Ie._getFullPath=Cm;var aw=/#\/?$/;function br(t){return t?t.replace(aw,""):""}Ie.normalizeId=br;function cw(t,e,r){return r=br(r),t.resolve(e,r)}Ie.resolveUrl=cw;var uw=/^[a-z_][-a-z0-9._]*$/i;function lw(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=br(t[r]||e),s={"":o},i=Mm(n,o,!1),a={},c=new Set;return nw(t,{allKeys:!0},(d,p,f,m)=>{if(m===void 0)return;let _=i+p,S=s[m];typeof d[r]=="string"&&(S=b.call(this,d[r])),E.call(this,d.$anchor),E.call(this,d.$dynamicAnchor),s[p]=S;function b(v){let $=this.opts.uriResolver.resolve;if(v=br(S?$(S,v):v),c.has(v))throw l(v);c.add(v);let x=this.refs[v];return typeof x=="string"&&(x=this.refs[x]),typeof x=="object"?u(d,x.schema,v):v!==br(_)&&(v[0]==="#"?(u(d,a[v],v),a[v]=d):this.refs[v]=_),v}function E(v){if(typeof v=="string"){if(!uw.test(v))throw new Error(`invalid anchor "${v}"`);b.call(this,`#${v}`)}}}),a;function u(d,p,f){if(p!==void 0&&!rw(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ie.getSchemaRefs=lw});var Tn=w(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.getData=jt.KeywordCxt=jt.validateFunctionCode=void 0;var Um=hm(),Nm=kn(),Za=Oa(),Xo=kn(),dw=Em(),Pn=Pm(),qa=zm(),T=A(),R=St(),pw=xn(),vt=F(),$n=wn();function fw(t){if(Fm(t)&&(Hm(t),Zm(t))){gw(t);return}qm(t,()=>(0,Um.topBoolOrEmptySchema)(t))}jt.validateFunctionCode=fw;function qm({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,T._)`${R.default.data}, ${R.default.valCxt}`,n.$async,()=>{t.code((0,T._)`"use strict"; ${Dm(r,o)}`),hw(t,o),t.code(s)}):t.func(e,(0,T._)`${R.default.data}, ${mw(o)}`,n.$async,()=>t.code(Dm(r,o)).code(s))}function mw(t){return(0,T._)`{${R.default.instancePath}="", ${R.default.parentData}, ${R.default.parentDataProperty}, ${R.default.rootData}=${R.default.data}${t.dynamicRef?(0,T._)`, ${R.default.dynamicAnchors}={}`:T.nil}}={}`}function hw(t,e){t.if(R.default.valCxt,()=>{t.var(R.default.instancePath,(0,T._)`${R.default.valCxt}.${R.default.instancePath}`),t.var(R.default.parentData,(0,T._)`${R.default.valCxt}.${R.default.parentData}`),t.var(R.default.parentDataProperty,(0,T._)`${R.default.valCxt}.${R.default.parentDataProperty}`),t.var(R.default.rootData,(0,T._)`${R.default.valCxt}.${R.default.rootData}`),e.dynamicRef&&t.var(R.default.dynamicAnchors,(0,T._)`${R.default.valCxt}.${R.default.dynamicAnchors}`)},()=>{t.var(R.default.instancePath,(0,T._)`""`),t.var(R.default.parentData,(0,T._)`undefined`),t.var(R.default.parentDataProperty,(0,T._)`undefined`),t.var(R.default.rootData,R.default.data),e.dynamicRef&&t.var(R.default.dynamicAnchors,(0,T._)`{}`)})}function gw(t){let{schema:e,opts:r,gen:n}=t;qm(t,()=>{r.$comment&&e.$comment&&Vm(t),bw(t),n.let(R.default.vErrors,null),n.let(R.default.errors,0),r.unevaluated&&_w(t),Wm(t),kw(t)})}function _w(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,T._)`${r}.evaluated`),e.if((0,T._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,T._)`${t.evaluated}.props`,(0,T._)`undefined`)),e.if((0,T._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,T._)`${t.evaluated}.items`,(0,T._)`undefined`))}function Dm(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,T._)`/*# sourceURL=${r} */`:T.nil}function yw(t,e){if(Fm(t)&&(Hm(t),Zm(t))){Sw(t,e);return}(0,Um.boolOrEmptySchema)(t,e)}function Zm({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function Fm(t){return typeof t.schema!="boolean"}function Sw(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&Vm(t),Ew(t),ww(t);let s=n.const("_errs",R.default.errors);Wm(t,s),n.var(e,(0,T._)`${s} === ${R.default.errors}`)}function Hm(t){(0,vt.checkUnknownRules)(t),vw(t)}function Wm(t,e){if(t.opts.jtd)return jm(t,[],!1,e);let r=(0,Nm.getSchemaTypes)(t.schema),n=(0,Nm.coerceAndCheckDataType)(t,r);jm(t,r,!n,e)}function vw(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,vt.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function bw(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,vt.checkStrictMode)(t,"default is ignored in the schema root")}function Ew(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,pw.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function ww(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Vm({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,T._)`${R.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,T.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,T._)`${R.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function kw(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,T._)`${R.default.errors} === 0`,()=>e.return(R.default.data),()=>e.throw((0,T._)`new ${o}(${R.default.vErrors})`)):(e.assign((0,T._)`${n}.errors`,R.default.vErrors),s.unevaluated&&xw(t),e.return((0,T._)`${R.default.errors} === 0`))}function xw({gen:t,evaluated:e,props:r,items:n}){r instanceof T.Name&&t.assign((0,T._)`${e}.props`,r),n instanceof T.Name&&t.assign((0,T._)`${e}.items`,n)}function jm(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,vt.schemaHasRulesButRef)(s,l))){o.block(()=>Km(t,"$ref",l.all.$ref.definition));return}c.jtd||$w(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,Za.shouldUseGroup)(s,p)&&(p.type?(o.if((0,Xo.checkDataType)(p.type,i,c.strictNumbers)),Lm(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,Xo.reportTypeError)(t)),o.endIf()):Lm(t,p),a||o.if((0,T._)`${R.default.errors} === ${n||0}`))}}function Lm(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,dw.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Za.shouldUseRule)(n,s)&&Km(t,s.keyword,s.definition,e.type)})}function $w(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Pw(t,e),t.opts.allowUnionTypes||Tw(t,e),zw(t,t.dataTypes))}function Pw(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Bm(t.dataTypes,r)||Fa(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Iw(t,e)}}function Tw(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Fa(t,"use allowUnionTypes to allow union type keyword")}function zw(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Za.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Rw(e,i))&&Fa(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Rw(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Bm(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Iw(t,e){let r=[];for(let n of t.dataTypes)Bm(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Fa(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,vt.checkStrictMode)(t,e,t.opts.strictTypes)}var Qo=class{constructor(e,r,n){if((0,Pn.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,vt.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",Gm(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,Pn.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",R.default.errors))}result(e,r,n){this.failResult((0,T.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,T.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,T._)`${r} !== undefined && (${(0,T.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?$n.reportExtraError:$n.reportError)(this,this.def.error,r)}$dataError(){(0,$n.reportError)(this,this.def.$dataError||$n.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,$n.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=T.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=T.nil,r=T.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,T.or)((0,T._)`${o} === undefined`,r)),e!==T.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==T.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,T.or)(i(),a());function i(){if(n.length){if(!(r instanceof T.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,T._)`${(0,Xo.checkDataTypes)(c,r,s.opts.strictNumbers,Xo.DataType.Wrong)}`}return T.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,T._)`!${c}(${r})`}return T.nil}}subschema(e,r){let n=(0,qa.getSubschema)(this.it,e);(0,qa.extendSubschemaData)(n,this.it,e),(0,qa.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return yw(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=vt.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=vt.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,T.Name)),!0}};jt.KeywordCxt=Qo;function Km(t,e,r,n){let o=new Qo(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,Pn.funcKeywordCode)(o,r):"macro"in r?(0,Pn.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,Pn.funcKeywordCode)(o,r)}var Ow=/^\/(?:[^~]|~0|~1)*$/,Aw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Gm(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return R.default.rootData;if(t[0]==="/"){if(!Ow.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=R.default.rootData}else{let u=Aw.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,T._)`${s}${(0,T.getProperty)((0,vt.unescapeJsonPointer)(u))}`,i=(0,T._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}jt.getData=Gm});var es=w(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});var Ha=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Wa.default=Ha});var zn=w(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});var Va=xn(),Ba=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Va.resolveUrl)(e,r,n),this.missingSchema=(0,Va.normalizeId)((0,Va.getFullPath)(e,this.missingRef))}};Ka.default=Ba});var rs=w(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.resolveSchema=Fe.getCompilingSchema=Fe.resolveRef=Fe.compileSchema=Fe.SchemaEnv=void 0;var Ye=A(),Mw=es(),Yt=St(),Xe=xn(),Jm=F(),Cw=Tn(),Er=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Xe.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Fe.SchemaEnv=Er;function Ja(t){let e=Ym.call(this,t);if(e)return e;let r=(0,Xe.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new Ye.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:Mw.default,code:(0,Ye._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Yt.default.data,parentData:Yt.default.parentData,parentDataProperty:Yt.default.parentDataProperty,dataNames:[Yt.default.data],dataPathArr:[Ye.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Ye.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Ye.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Ye._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,Cw.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(Yt.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let f=new Function(`${Yt.default.self}`,`${Yt.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=t.schema,f.schemaEnv=t,t.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:_}=u;f.evaluated={props:m instanceof Ye.Name?void 0:m,items:_ instanceof Ye.Name?void 0:_,dynamicProps:m instanceof Ye.Name,dynamicItems:_ instanceof Ye.Name},f.source&&(f.source.evaluated=(0,Ye.stringify)(f.evaluated))}return t.validate=f,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}Fe.compileSchema=Ja;function Nw(t,e,r){var n;r=(0,Xe.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Lw.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Er({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=Dw.call(this,s)}Fe.resolveRef=Nw;function Dw(t){return(0,Xe.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Ja.call(this,t)}function Ym(t){for(let e of this._compilations)if(jw(e,t))return e}Fe.getCompilingSchema=Ym;function jw(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Lw(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||ts.call(this,t,e)}function ts(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Xe._getFullPath)(this.opts.uriResolver,r),o=(0,Xe.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return Ga.call(this,r,t);let s=(0,Xe.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=ts.call(this,t,i);return typeof a?.schema!="object"?void 0:Ga.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Ja.call(this,i),s===(0,Xe.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Xe.resolveUrl)(this.opts.uriResolver,o,u)),new Er({schema:a,schemaId:c,root:t,baseId:o})}return Ga.call(this,r,i)}}Fe.resolveSchema=ts;var Uw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ga(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Jm.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Uw.has(a)&&u&&(e=(0,Xe.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Jm.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Xe.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=ts.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Er({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var Xm=w((bM,qw)=>{qw.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 Xa=w((EM,rh)=>{"use strict";var Zw=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),eh=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function Ya(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var Fw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Qm(t){return t.length=0,!0}function Hw(t,e,r){if(t.length){let n=Ya(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function Ww(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=Hw;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=Qm}else{o.push(u);continue}}return o.length&&(a===Qm?r.zone=o.join(""):i?n.push(o.join("")):n.push(Ya(o))),r.address=n.join(""),r}function th(t){if(Vw(t,":")<2)return{host:t,isIPV6:!1};let e=Ww(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function Vw(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function Bw(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}function Kw(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function Gw(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!eh(r)){let n=th(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}rh.exports={nonSimpleDomain:Fw,recomposeAuthority:Gw,normalizeComponentEncoding:Kw,removeDotSegments:Bw,isIPv4:eh,isUUID:Zw,normalizeIPv6:th,stringArrayToHexStripped:Ya}});var ah=w((wM,ih)=>{"use strict";var{isUUID:Jw}=Xa(),Yw=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Xw=["http","https","ws","wss","urn","urn:uuid"];function Qw(t){return Xw.indexOf(t)!==-1}function Qa(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function nh(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function oh(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function ek(t){return t.secure=Qa(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function tk(t){if((t.port===(Qa(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function rk(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(Yw);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=ec(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function nk(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=ec(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function ok(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!Jw(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function sk(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var sh={scheme:"http",domainHost:!0,parse:nh,serialize:oh},ik={scheme:"https",domainHost:sh.domainHost,parse:nh,serialize:oh},ns={scheme:"ws",domainHost:!0,parse:ek,serialize:tk},ak={scheme:"wss",domainHost:ns.domainHost,parse:ns.parse,serialize:ns.serialize},ck={scheme:"urn",parse:rk,serialize:nk,skipNormalize:!0},uk={scheme:"urn:uuid",parse:ok,serialize:sk,skipNormalize:!0},os={http:sh,https:ik,ws:ns,wss:ak,urn:ck,"urn:uuid":uk};Object.setPrototypeOf(os,null);function ec(t){return t&&(os[t]||os[t.toLowerCase()])||void 0}ih.exports={wsIsSecure:Qa,SCHEMES:os,isValidSchemeName:Qw,getSchemeHandler:ec}});var lh=w((kM,is)=>{"use strict";var{normalizeIPv6:lk,removeDotSegments:Rn,recomposeAuthority:dk,normalizeComponentEncoding:ss,isIPv4:pk,nonSimpleDomain:fk}=Xa(),{SCHEMES:mk,getSchemeHandler:ch}=ah();function hk(t,e){return typeof t=="string"?t=st(bt(t,e),e):typeof t=="object"&&(t=bt(st(t,e),e)),t}function gk(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=uh(bt(t,n),bt(e,n),n,!0);return n.skipEscape=!0,st(o,n)}function uh(t,e,r,n){let o={};return n||(t=bt(st(t,r),r),e=bt(st(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=Rn(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=Rn(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=Rn(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=Rn(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function _k(t,e,r){return typeof t=="string"?(t=unescape(t),t=st(ss(bt(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=st(ss(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=st(ss(bt(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=st(ss(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function st(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=ch(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=dk(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=Rn(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var yk=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function bt(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let s=t.match(yk);if(s){if(n.scheme=s[1],n.userinfo=s[3],n.host=s[4],n.port=parseInt(s[5],10),n.path=s[6]||"",n.query=s[7],n.fragment=s[8],isNaN(n.port)&&(n.port=s[5]),n.host)if(pk(n.host)===!1){let c=lk(n.host);n.host=c.host.toLowerCase(),o=c.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let i=ch(r.scheme||n.scheme);if(!r.unicodeSupport&&(!i||!i.unicodeSupport)&&n.host&&(r.domainHost||i&&i.domainHost)&&o===!1&&fk(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!i||i&&!i.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),i&&i.parse&&i.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var tc={SCHEMES:mk,normalize:hk,resolve:gk,resolveComponent:uh,equal:_k,serialize:st,parse:bt};is.exports=tc;is.exports.default=tc;is.exports.fastUri=tc});var ph=w(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});var dh=lh();dh.code='require("ajv/dist/runtime/uri").default';rc.default=dh});var vh=w(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.CodeGen=ge.Name=ge.nil=ge.stringify=ge.str=ge._=ge.KeywordCxt=void 0;var Sk=Tn();Object.defineProperty(ge,"KeywordCxt",{enumerable:!0,get:function(){return Sk.KeywordCxt}});var wr=A();Object.defineProperty(ge,"_",{enumerable:!0,get:function(){return wr._}});Object.defineProperty(ge,"str",{enumerable:!0,get:function(){return wr.str}});Object.defineProperty(ge,"stringify",{enumerable:!0,get:function(){return wr.stringify}});Object.defineProperty(ge,"nil",{enumerable:!0,get:function(){return wr.nil}});Object.defineProperty(ge,"Name",{enumerable:!0,get:function(){return wr.Name}});Object.defineProperty(ge,"CodeGen",{enumerable:!0,get:function(){return wr.CodeGen}});var vk=es(),_h=zn(),bk=Ia(),In=rs(),Ek=A(),On=xn(),as=kn(),oc=F(),fh=Xm(),wk=ph(),yh=(t,e)=>new RegExp(t,e);yh.code="new RegExp";var kk=["removeAdditional","useDefaults","coerceTypes"],xk=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),$k={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."},Pk={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},mh=200;function Tk(t){var e,r,n,o,s,i,a,c,u,l,d,p,f,m,_,S,b,E,v,$,x,Se,we,Zt,nr;let ce=t.strict,kt=(e=t.code)===null||e===void 0?void 0:e.optimize,Ke=kt===!0||kt===void 0?1:kt||0,Lr=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:yh,B_=(o=t.uriResolver)!==null&&o!==void 0?o:wk.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:ce)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:ce)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:ce)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:ce)!==null&&p!==void 0?p:"log",strictRequired:(m=(f=t.strictRequired)!==null&&f!==void 0?f:ce)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:Ke,regExp:Lr}:{optimize:Ke,regExp:Lr},loopRequired:(_=t.loopRequired)!==null&&_!==void 0?_:mh,loopEnum:(S=t.loopEnum)!==null&&S!==void 0?S:mh,meta:(b=t.meta)!==null&&b!==void 0?b:!0,messages:(E=t.messages)!==null&&E!==void 0?E:!0,inlineRefs:(v=t.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(x=t.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(Se=t.validateSchema)!==null&&Se!==void 0?Se:!0,validateFormats:(we=t.validateFormats)!==null&&we!==void 0?we:!0,unicodeRegExp:(Zt=t.unicodeRegExp)!==null&&Zt!==void 0?Zt:!0,int32range:(nr=t.int32range)!==null&&nr!==void 0?nr:!0,uriResolver:B_}}var An=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...Tk(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new Ek.ValueScope({scope:{},prefixes:xk,es5:r,lines:n}),this.logger=Mk(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,bk.getRules)(),hh.call(this,$k,e,"NOT SUPPORTED"),hh.call(this,Pk,e,"DEPRECATED","warn"),this._metaOpts=Ok.call(this),e.formats&&Rk.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&Ik.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),zk.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=fh;n==="id"&&(o={...fh},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,e,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof _h.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,On.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,e);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(e){let r;for(;typeof(r=gh.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new In.SchemaEnv({schema:{},schemaId:n});if(r=In.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=gh.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,On.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Nk.call(this,n,r),!r)return(0,oc.eachItem)(n,s=>nc.call(this,s)),this;jk.call(this,r);let o={...r,type:(0,as.getJSONTypes)(r.type),schemaType:(0,as.getJSONTypes)(r.schemaType)};return(0,oc.eachItem)(n,o.type.length===0?s=>nc.call(this,s,o):s=>o.type.forEach(i=>nc.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=Sh(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,On.normalizeId)(i||n);let u=On.getSchemaRefs.call(this,e,n);return c=new In.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):In.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{In.compileSchema.call(this,e)}finally{this.opts=r}}};An.ValidationError=vk.default;An.MissingRefError=_h.default;ge.default=An;function hh(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function gh(t){return t=(0,On.normalizeId)(t),this.schemas[t]||this.refs[t]}function zk(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function Rk(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function Ik(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function Ok(){let t={...this.opts};for(let e of kk)delete t[e];return t}var Ak={log(){},warn(){},error(){}};function Mk(t){if(t===!1)return Ak;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var Ck=/^[a-z_$][a-z0-9_$:-]*$/i;function Nk(t,e){let{RULES:r}=this;if((0,oc.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Ck.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function nc(t,e,r){var n;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,as.getJSONTypes)(e.type),schemaType:(0,as.getJSONTypes)(e.schemaType)}};e.before?Dk.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function Dk(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function jk(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=Sh(e)),t.validateSchema=this.compile(e,!0))}var Lk={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Sh(t){return{anyOf:[t,Lk]}}});var bh=w(sc=>{"use strict";Object.defineProperty(sc,"__esModule",{value:!0});var Uk={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};sc.default=Uk});var xh=w(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.callRef=Xt.getValidate=void 0;var qk=zn(),Eh=Ze(),Oe=A(),kr=St(),wh=rs(),cs=F(),Zk={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=wh.resolveRef.call(c,u,o,r);if(l===void 0)throw new qk.default(n.opts.uriResolver,o,r);if(l instanceof wh.SchemaEnv)return p(l);return f(l);function d(){if(s===u)return us(t,i,s,s.$async);let m=e.scopeValue("root",{ref:u});return us(t,(0,Oe._)`${m}.validate`,u,u.$async)}function p(m){let _=kh(t,m);us(t,_,m,m.$async)}function f(m){let _=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Oe.stringify)(m)}:{ref:m}),S=e.name("valid"),b=t.subschema({schema:m,dataTypes:[],schemaPath:Oe.nil,topSchemaRef:_,errSchemaPath:r},S);t.mergeEvaluated(b),t.ok(S)}}};function kh(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Oe._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Xt.getValidate=kh;function us(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?kr.default.this:Oe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Oe._)`await ${(0,Eh.callValidateCode)(t,e,u)}`),f(e),i||o.assign(m,!0)},_=>{o.if((0,Oe._)`!(${_} instanceof ${s.ValidationError})`,()=>o.throw(_)),p(_),i||o.assign(m,!1)}),t.ok(m)}function d(){t.result((0,Eh.callValidateCode)(t,e,u),()=>f(e),()=>p(e))}function p(m){let _=(0,Oe._)`${m}.errors`;o.assign(kr.default.vErrors,(0,Oe._)`${kr.default.vErrors} === null ? ${_} : ${kr.default.vErrors}.concat(${_})`),o.assign(kr.default.errors,(0,Oe._)`${kr.default.vErrors}.length`)}function f(m){var _;if(!s.opts.unevaluated)return;let S=(_=r?.validate)===null||_===void 0?void 0:_.evaluated;if(s.props!==!0)if(S&&!S.dynamicProps)S.props!==void 0&&(s.props=cs.mergeEvaluated.props(o,S.props,s.props));else{let b=o.var("props",(0,Oe._)`${m}.evaluated.props`);s.props=cs.mergeEvaluated.props(o,b,s.props,Oe.Name)}if(s.items!==!0)if(S&&!S.dynamicItems)S.items!==void 0&&(s.items=cs.mergeEvaluated.items(o,S.items,s.items));else{let b=o.var("items",(0,Oe._)`${m}.evaluated.items`);s.items=cs.mergeEvaluated.items(o,b,s.items,Oe.Name)}}}Xt.callRef=us;Xt.default=Zk});var $h=w(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});var Fk=bh(),Hk=xh(),Wk=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Fk.default,Hk.default];ic.default=Wk});var Ph=w(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});var ls=A(),Lt=ls.operators,ds={maximum:{okStr:"<=",ok:Lt.LTE,fail:Lt.GT},minimum:{okStr:">=",ok:Lt.GTE,fail:Lt.LT},exclusiveMaximum:{okStr:"<",ok:Lt.LT,fail:Lt.GTE},exclusiveMinimum:{okStr:">",ok:Lt.GT,fail:Lt.LTE}},Vk={message:({keyword:t,schemaCode:e})=>(0,ls.str)`must be ${ds[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ls._)`{comparison: ${ds[t].okStr}, limit: ${e}}`},Bk={keyword:Object.keys(ds),type:"number",schemaType:"number",$data:!0,error:Vk,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,ls._)`${r} ${ds[e].fail} ${n} || isNaN(${r})`)}};ac.default=Bk});var Th=w(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var Mn=A(),Kk={message:({schemaCode:t})=>(0,Mn.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Mn._)`{multipleOf: ${t}}`},Gk={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Kk,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,Mn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Mn._)`${i} !== parseInt(${i})`;t.fail$data((0,Mn._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};cc.default=Gk});var Rh=w(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});function zh(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}uc.default=zh;zh.code='require("ajv/dist/runtime/ucs2length").default'});var Ih=w(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var Qt=A(),Jk=F(),Yk=Rh(),Xk={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Qt.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Qt._)`{limit: ${t}}`},Qk={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Xk,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?Qt.operators.GT:Qt.operators.LT,i=o.opts.unicode===!1?(0,Qt._)`${r}.length`:(0,Qt._)`${(0,Jk.useFunc)(t.gen,Yk.default)}(${r})`;t.fail$data((0,Qt._)`${i} ${s} ${n}`)}};lc.default=Qk});var Oh=w(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var e0=Ze(),ps=A(),t0={message:({schemaCode:t})=>(0,ps.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,ps._)`{pattern: ${t}}`},r0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:t0,code(t){let{data:e,$data:r,schema:n,schemaCode:o,it:s}=t,i=s.opts.unicodeRegExp?"u":"",a=r?(0,ps._)`(new RegExp(${o}, ${i}))`:(0,e0.usePattern)(t,n);t.fail$data((0,ps._)`!${a}.test(${e})`)}};dc.default=r0});var Ah=w(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var Cn=A(),n0={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Cn.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Cn._)`{limit: ${t}}`},o0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:n0,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?Cn.operators.GT:Cn.operators.LT;t.fail$data((0,Cn._)`Object.keys(${r}).length ${o} ${n}`)}};pc.default=o0});var Mh=w(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var Nn=Ze(),Dn=A(),s0=F(),i0={message:({params:{missingProperty:t}})=>(0,Dn.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Dn._)`{missingProperty: ${t}}`},a0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:i0,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let f=t.parentSchema.properties,{definedProperties:m}=t.it;for(let _ of r)if(f?.[_]===void 0&&!m.has(_)){let S=i.schemaEnv.baseId+i.errSchemaPath,b=`required property "${_}" is not defined at "${S}" (strictRequired)`;(0,s0.checkStrictMode)(i,b,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(Dn.nil,d);else for(let f of r)(0,Nn.checkReportMissingProp)(t,f)}function l(){let f=e.let("missing");if(c||s){let m=e.let("valid",!0);t.block$data(m,()=>p(f,m)),t.ok(m)}else e.if((0,Nn.checkMissingProp)(t,r,f)),(0,Nn.reportMissingProp)(t,f),e.else()}function d(){e.forOf("prop",n,f=>{t.setParams({missingProperty:f}),e.if((0,Nn.noPropertyInData)(e,o,f,a.ownProperties),()=>t.error())})}function p(f,m){t.setParams({missingProperty:f}),e.forOf(f,n,()=>{e.assign(m,(0,Nn.propertyInData)(e,o,f,a.ownProperties)),e.if((0,Dn.not)(m),()=>{t.error(),e.break()})},Dn.nil)}}};fc.default=a0});var Ch=w(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});var jn=A(),c0={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,jn.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,jn._)`{limit: ${t}}`},u0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:c0,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?jn.operators.GT:jn.operators.LT;t.fail$data((0,jn._)`${r}.length ${o} ${n}`)}};mc.default=u0});var fs=w(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});var Nh=La();Nh.code='require("ajv/dist/runtime/equal").default';hc.default=Nh});var Dh=w(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var gc=kn(),_e=A(),l0=F(),d0=fs(),p0={message:({params:{i:t,j:e}})=>(0,_e.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,_e._)`{i: ${t}, j: ${e}}`},f0={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:p0,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,gc.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,_e._)`${i} === false`),t.ok(c);function l(){let m=e.let("i",(0,_e._)`${r}.length`),_=e.let("j");t.setParams({i:m,j:_}),e.assign(c,!0),e.if((0,_e._)`${m} > 1`,()=>(d()?p:f)(m,_))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function p(m,_){let S=e.name("item"),b=(0,gc.checkDataTypes)(u,S,a.opts.strictNumbers,gc.DataType.Wrong),E=e.const("indices",(0,_e._)`{}`);e.for((0,_e._)`;${m}--;`,()=>{e.let(S,(0,_e._)`${r}[${m}]`),e.if(b,(0,_e._)`continue`),u.length>1&&e.if((0,_e._)`typeof ${S} == "string"`,(0,_e._)`${S} += "_"`),e.if((0,_e._)`typeof ${E}[${S}] == "number"`,()=>{e.assign(_,(0,_e._)`${E}[${S}]`),t.error(),e.assign(c,!1).break()}).code((0,_e._)`${E}[${S}] = ${m}`)})}function f(m,_){let S=(0,l0.useFunc)(e,d0.default),b=e.name("outer");e.label(b).for((0,_e._)`;${m}--;`,()=>e.for((0,_e._)`${_} = ${m}; ${_}--;`,()=>e.if((0,_e._)`${S}(${r}[${m}], ${r}[${_}])`,()=>{t.error(),e.assign(c,!1).break(b)})))}}};_c.default=f0});var jh=w(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var yc=A(),m0=F(),h0=fs(),g0={message:"must be equal to constant",params:({schemaCode:t})=>(0,yc._)`{allowedValue: ${t}}`},_0={keyword:"const",$data:!0,error:g0,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,yc._)`!${(0,m0.useFunc)(e,h0.default)}(${r}, ${o})`):t.fail((0,yc._)`${s} !== ${r}`)}};Sc.default=_0});var Lh=w(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var Ln=A(),y0=F(),S0=fs(),v0={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Ln._)`{allowedValues: ${t}}`},b0={keyword:"enum",schemaType:"array",$data:!0,error:v0,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,y0.useFunc)(e,S0.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let f=e.const("vSchema",s);l=(0,Ln.or)(...o.map((m,_)=>p(f,_)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,f=>e.if((0,Ln._)`${u()}(${r}, ${f})`,()=>e.assign(l,!0).break()))}function p(f,m){let _=o[m];return typeof _=="object"&&_!==null?(0,Ln._)`${u()}(${r}, ${f}[${m}])`:(0,Ln._)`${r} === ${_}`}}};vc.default=b0});var Uh=w(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var E0=Ph(),w0=Th(),k0=Ih(),x0=Oh(),$0=Ah(),P0=Mh(),T0=Ch(),z0=Dh(),R0=jh(),I0=Lh(),O0=[E0.default,w0.default,k0.default,x0.default,$0.default,P0.default,T0.default,z0.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},R0.default,I0.default];bc.default=O0});var wc=w(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.validateAdditionalItems=void 0;var er=A(),Ec=F(),A0={message:({params:{len:t}})=>(0,er.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,er._)`{limit: ${t}}`},M0={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:A0,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,Ec.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}qh(t,n)}};function qh(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,er._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,er._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,Ec.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,er._)`${a} <= ${e.length}`);r.if((0,er.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:Ec.Type.Num},u),i.allErrors||r.if((0,er.not)(u),()=>r.break())})}}Un.validateAdditionalItems=qh;Un.default=M0});var kc=w(qn=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});qn.validateTuple=void 0;var Zh=A(),ms=F(),C0=Ze(),N0={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Fh(t,"additionalItems",e);r.items=!0,!(0,ms.alwaysValidSchema)(r,e)&&t.ok((0,C0.validateArray)(t))}};function Fh(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=ms.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Zh._)`${s}.length`);r.forEach((d,p)=>{(0,ms.alwaysValidSchema)(a,d)||(n.if((0,Zh._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(d){let{opts:p,errSchemaPath:f}=a,m=r.length,_=m===d.minItems&&(m===d.maxItems||d[e]===!1);if(p.strictTuples&&!_){let S=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${f}"`;(0,ms.checkStrictMode)(a,S,p.strictTuples)}}}qn.validateTuple=Fh;qn.default=N0});var Hh=w(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var D0=kc(),j0={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,D0.validateTuple)(t,"items")};xc.default=j0});var Vh=w($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});var Wh=A(),L0=F(),U0=Ze(),q0=wc(),Z0={message:({params:{len:t}})=>(0,Wh.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Wh._)`{limit: ${t}}`},F0={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Z0,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,L0.alwaysValidSchema)(n,e)&&(o?(0,q0.validateAdditionalItems)(t,o):t.ok((0,U0.validateArray)(t)))}};$c.default=F0});var Bh=w(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var He=A(),hs=F(),H0={message:({params:{min:t,max:e}})=>e===void 0?(0,He.str)`must contain at least ${t} valid item(s)`:(0,He.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,He._)`{minContains: ${t}}`:(0,He._)`{minContains: ${t}, maxContains: ${e}}`},W0={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:H0,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,He._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,hs.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,hs.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,hs.alwaysValidSchema)(s,r)){let _=(0,He._)`${l} >= ${i}`;a!==void 0&&(_=(0,He._)`${_} && ${l} <= ${a}`),t.pass(_);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?f(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,He._)`${o}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let _=e.name("_valid"),S=e.let("count",0);f(_,()=>e.if(_,()=>m(S)))}function f(_,S){e.forRange("i",0,l,b=>{t.subschema({keyword:"contains",dataProp:b,dataPropType:hs.Type.Num,compositeRule:!0},_),S()})}function m(_){e.code((0,He._)`${_}++`),a===void 0?e.if((0,He._)`${_} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,He._)`${_} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,He._)`${_} >= ${i}`,()=>e.assign(d,!0)))}}};Pc.default=W0});var Jh=w(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.validateSchemaDeps=it.validatePropertyDeps=it.error=void 0;var Tc=A(),V0=F(),Zn=Ze();it.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Tc.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Tc._)`{property: ${t},
|
|
6
|
+
|| ${i} === "boolean" || ${o} === null`).assign(a,(0,O._)`[${o}]`)}}}function TE({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,O._)`${e} !== undefined`,()=>t.assign((0,O._)`${e}[${r}]`,n))}function Ca(t,e,r,n=Sr.Correct){let o=n===Sr.Correct?O.operators.EQ:O.operators.NEQ,s;switch(t){case"null":return(0,O._)`${e} ${o} null`;case"array":s=(0,O._)`Array.isArray(${e})`;break;case"object":s=(0,O._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,O._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,O._)`typeof ${e} ${o} ${t}`}return n===Sr.Correct?s:(0,O.not)(s);function i(a=O.nil){return(0,O.and)((0,O._)`typeof ${e} == "number"`,a,r?(0,O._)`isFinite(${e})`:O.nil)}}Ee.checkDataType=Ca;function Na(t,e,r,n){if(t.length===1)return Ca(t[0],e,r,n);let o,s=(0,vm.toHash)(t);if(s.array&&s.object){let i=(0,O._)`typeof ${e} != "object"`;o=s.null?i:(0,O._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=O.nil;s.number&&delete s.integer;for(let i in s)o=(0,O.and)(o,Ca(i,e,r,n));return o}Ee.checkDataTypes=Na;var zE={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,O._)`{type: ${t}}`:(0,O._)`{type: ${e}}`};function Da(t){let e=RE(t);(0,wE.reportError)(e,zE)}Ee.reportTypeError=Da;function RE(t){let{gen:e,data:r,schema:n}=t,o=(0,vm.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var km=w(Go=>{"use strict";Object.defineProperty(Go,"__esModule",{value:!0});Go.assignDefaults=void 0;var vr=A(),IE=F();function OE(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)wm(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>wm(t,s,o.default))}Go.assignDefaults=OE;function wm(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,vr._)`${s}${(0,vr.getProperty)(e)}`;if(o){(0,IE.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,vr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,vr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,vr._)`${a} = ${(0,vr.stringify)(r)}`)}});var Ze=w(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:!0});V.validateUnion=V.validateArray=V.usePattern=V.callValidateCode=V.schemaProperties=V.allSchemaProperties=V.noPropertyInData=V.propertyInData=V.isOwnProperty=V.hasPropFunc=V.reportMissingProp=V.checkMissingProp=V.checkReportMissingProp=void 0;var X=A(),ja=F(),Ct=yt(),AE=F();function ME(t,e){let{gen:r,data:n,it:o}=t;r.if(Ua(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,X._)`${e}`},!0),t.error()})}V.checkReportMissingProp=ME;function CE({gen:t,data:e,it:{opts:r}},n,o){return(0,X.or)(...n.map(s=>(0,X.and)(Ua(t,e,s,r.ownProperties),(0,X._)`${o} = ${s}`)))}V.checkMissingProp=CE;function NE(t,e){t.setParams({missingProperty:e},!0),t.error()}V.reportMissingProp=NE;function xm(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,X._)`Object.prototype.hasOwnProperty`})}V.hasPropFunc=xm;function La(t,e,r){return(0,X._)`${xm(t)}.call(${e}, ${r})`}V.isOwnProperty=La;function DE(t,e,r,n){let o=(0,X._)`${e}${(0,X.getProperty)(r)} !== undefined`;return n?(0,X._)`${o} && ${La(t,e,r)}`:o}V.propertyInData=DE;function Ua(t,e,r,n){let o=(0,X._)`${e}${(0,X.getProperty)(r)} === undefined`;return n?(0,X.or)(o,(0,X.not)(La(t,e,r))):o}V.noPropertyInData=Ua;function $m(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}V.allSchemaProperties=$m;function jE(t,e){return $m(e).filter(r=>!(0,ja.alwaysValidSchema)(t,e[r]))}V.schemaProperties=jE;function LE({schemaCode:t,data:e,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,X._)`${t}, ${e}, ${n}${o}`:e,d=[[Ct.default.instancePath,(0,X.strConcat)(Ct.default.instancePath,s)],[Ct.default.parentData,i.parentData],[Ct.default.parentDataProperty,i.parentDataProperty],[Ct.default.rootData,Ct.default.rootData]];i.opts.dynamicRef&&d.push([Ct.default.dynamicAnchors,Ct.default.dynamicAnchors]);let p=(0,X._)`${l}, ${r.object(...d)}`;return c!==X.nil?(0,X._)`${a}.call(${c}, ${p})`:(0,X._)`${a}(${p})`}V.callValidateCode=LE;var UE=(0,X._)`new RegExp`;function qE({gen:t,it:{opts:e}},r){let n=e.unicodeRegExp?"u":"",{regExp:o}=e.code,s=o(r,n);return t.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,X._)`${o.code==="new RegExp"?UE:(0,AE.useFunc)(t,o)}(${r}, ${n})`})}V.usePattern=qE;function ZE(t){let{gen:e,data:r,keyword:n,it:o}=t,s=e.name("valid");if(o.allErrors){let a=e.let("valid",!0);return i(()=>e.assign(a,!1)),a}return e.var(s,!0),i(()=>e.break()),s;function i(a){let c=e.const("len",(0,X._)`${r}.length`);e.forRange("i",0,c,u=>{t.subschema({keyword:n,dataProp:u,dataPropType:ja.Type.Num},s),e.if((0,X.not)(s),a)})}}V.validateArray=ZE;function FE(t){let{gen:e,schema:r,keyword:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,ja.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=e.let("valid",!1),a=e.name("_valid");e.block(()=>r.forEach((c,u)=>{let l=t.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);e.assign(i,(0,X._)`${i} || ${a}`),t.mergeValidEvaluated(l,a)||e.if((0,X.not)(i))})),t.result(i,()=>t.reset(),()=>t.error(!0))}V.validateUnion=FE});var zm=w(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.validateKeywordUsage=nt.validSchemaType=nt.funcKeywordCode=nt.macroKeywordCode=void 0;var Pe=A(),Jt=yt(),HE=Ze(),WE=En();function VE(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=Tm(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");t.subschema({schema:a,schemaPath:Pe.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),t.pass(u,()=>t.error(!0))}nt.macroKeywordCode=VE;function BE(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;GE(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=Tm(n,o,u),d=n.let("valid");t.block$data(d,p),t.ok((r=e.valid)!==null&&r!==void 0?r:d);function p(){if(e.errors===!1)_(),e.modifying&&Pm(t),S(()=>t.error());else{let b=e.async?f():m();e.modifying&&Pm(t),S(()=>KE(t,b))}}function f(){let b=n.let("ruleErrs",null);return n.try(()=>_((0,Pe._)`await `),E=>n.assign(d,!1).if((0,Pe._)`${E} instanceof ${c.ValidationError}`,()=>n.assign(b,(0,Pe._)`${E}.errors`),()=>n.throw(E))),b}function m(){let b=(0,Pe._)`${l}.errors`;return n.assign(b,null),_(Pe.nil),b}function _(b=e.async?(0,Pe._)`await `:Pe.nil){let E=c.opts.passContext?Jt.default.this:Jt.default.self,v=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,Pe._)`${b}${(0,HE.callValidateCode)(t,l,E,v)}`,e.modifying)}function S(b){var E;n.if((0,Pe.not)((E=e.valid)!==null&&E!==void 0?E:d),b)}}nt.funcKeywordCode=BE;function Pm(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Pe._)`${n.parentData}[${n.parentDataProperty}]`))}function KE(t,e){let{gen:r}=t;r.if((0,Pe._)`Array.isArray(${e})`,()=>{r.assign(Jt.default.vErrors,(0,Pe._)`${Jt.default.vErrors} === null ? ${e} : ${Jt.default.vErrors}.concat(${e})`).assign(Jt.default.errors,(0,Pe._)`${Jt.default.vErrors}.length`),(0,WE.extendErrors)(t)},()=>t.error())}function GE({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function Tm(t,e,r){if(r===void 0)throw new Error(`keyword "${e}" failed to compile`);return t.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Pe.stringify)(r)})}function JE(t,e,r=!1){return!e.length||e.some(n=>n==="array"?Array.isArray(t):n==="object"?t&&typeof t=="object"&&!Array.isArray(t):typeof t==n||r&&typeof t>"u")}nt.validSchemaType=JE;function YE({schema:t,opts:e,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(t,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(t[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(e.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}nt.validateKeywordUsage=YE});var Im=w(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Nt.extendSubschemaMode=Nt.extendSubschemaData=Nt.getSubschema=void 0;var ot=A(),Rm=F();function XE(t,{keyword:e,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(e!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(e!==void 0){let a=t.schema[e];return r===void 0?{schema:a,schemaPath:(0,ot._)`${t.schemaPath}${(0,ot.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,ot._)`${t.schemaPath}${(0,ot.getProperty)(e)}${(0,ot.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,Rm.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')}Nt.getSubschema=XE;function QE(t,e,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=e;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=e,p=a.let("data",(0,ot._)`${e.data}${(0,ot.getProperty)(r)}`,!0);c(p),t.errorPath=(0,ot.str)`${u}${(0,Rm.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,ot._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof ot.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(t.propertyName=i)}s&&(t.dataTypes=s);function c(u){t.data=u,t.dataLevel=e.dataLevel+1,t.dataTypes=[],e.definedProperties=new Set,t.parentData=e.data,t.dataNames=[...e.dataNames,u]}}Nt.extendSubschemaData=QE;function ew(t,{jtdDiscriminator:e,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(t.compositeRule=n),o!==void 0&&(t.createErrors=o),s!==void 0&&(t.allErrors=s),t.jtdDiscriminator=e,t.jtdMetadata=r}Nt.extendSubschemaMode=ew});var qa=w((mM,Om)=>{"use strict";Om.exports=function t(e,r){if(e===r)return!0;if(e&&r&&typeof e=="object"&&typeof r=="object"){if(e.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(e)){if(n=e.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!t(e[o],r[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===r.source&&e.flags===r.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===r.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===r.toString();if(s=Object.keys(e),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!t(e[i],r[i]))return!1}return!0}return e!==e&&r!==r}});var Mm=w((hM,Am)=>{"use strict";var Dt=Am.exports=function(t,e,r){typeof e=="function"&&(r=e,e={}),r=e.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Jo(e,n,o,t,"",t)};Dt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Dt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Dt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Dt.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 Jo(t,e,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){e(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Dt.arrayKeywords)for(var p=0;p<d.length;p++)Jo(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in Dt.propsKeywords){if(d&&typeof d=="object")for(var f in d)Jo(t,e,r,d[f],o+"/"+l+"/"+tw(f),s,o,l,n,f)}else(l in Dt.keywords||t.allKeys&&!(l in Dt.skipKeywords))&&Jo(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function tw(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var kn=w(Ie=>{"use strict";Object.defineProperty(Ie,"__esModule",{value:!0});Ie.getSchemaRefs=Ie.resolveUrl=Ie.normalizeId=Ie._getFullPath=Ie.getFullPath=Ie.inlineRef=void 0;var rw=F(),nw=qa(),ow=Mm(),sw=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function iw(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Za(t):e?Cm(t)<=e:!1}Ie.inlineRef=iw;var aw=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Za(t){for(let e in t){if(aw.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Za)||typeof r=="object"&&Za(r))return!0}return!1}function Cm(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!sw.has(r)&&(typeof t[r]=="object"&&(0,rw.eachItem)(t[r],n=>e+=Cm(n)),e===1/0))return 1/0}return e}function Nm(t,e="",r){r!==!1&&(e=br(e));let n=t.parse(e);return Dm(t,n)}Ie.getFullPath=Nm;function Dm(t,e){return t.serialize(e).split("#")[0]+"#"}Ie._getFullPath=Dm;var cw=/#\/?$/;function br(t){return t?t.replace(cw,""):""}Ie.normalizeId=br;function uw(t,e,r){return r=br(r),t.resolve(e,r)}Ie.resolveUrl=uw;var lw=/^[a-z_][-a-z0-9._]*$/i;function dw(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=br(t[r]||e),s={"":o},i=Nm(n,o,!1),a={},c=new Set;return ow(t,{allKeys:!0},(d,p,f,m)=>{if(m===void 0)return;let _=i+p,S=s[m];typeof d[r]=="string"&&(S=b.call(this,d[r])),E.call(this,d.$anchor),E.call(this,d.$dynamicAnchor),s[p]=S;function b(v){let $=this.opts.uriResolver.resolve;if(v=br(S?$(S,v):v),c.has(v))throw l(v);c.add(v);let x=this.refs[v];return typeof x=="string"&&(x=this.refs[x]),typeof x=="object"?u(d,x.schema,v):v!==br(_)&&(v[0]==="#"?(u(d,a[v],v),a[v]=d):this.refs[v]=_),v}function E(v){if(typeof v=="string"){if(!lw.test(v))throw new Error(`invalid anchor "${v}"`);b.call(this,`#${v}`)}}}),a;function u(d,p,f){if(p!==void 0&&!nw(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ie.getSchemaRefs=dw});var Pn=w(jt=>{"use strict";Object.defineProperty(jt,"__esModule",{value:!0});jt.getData=jt.KeywordCxt=jt.validateFunctionCode=void 0;var Zm=_m(),jm=wn(),Ha=Ma(),Yo=wn(),pw=km(),$n=zm(),Fa=Im(),T=A(),R=yt(),fw=kn(),St=F(),xn=En();function mw(t){if(Wm(t)&&(Vm(t),Hm(t))){_w(t);return}Fm(t,()=>(0,Zm.topBoolOrEmptySchema)(t))}jt.validateFunctionCode=mw;function Fm({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,T._)`${R.default.data}, ${R.default.valCxt}`,n.$async,()=>{t.code((0,T._)`"use strict"; ${Lm(r,o)}`),gw(t,o),t.code(s)}):t.func(e,(0,T._)`${R.default.data}, ${hw(o)}`,n.$async,()=>t.code(Lm(r,o)).code(s))}function hw(t){return(0,T._)`{${R.default.instancePath}="", ${R.default.parentData}, ${R.default.parentDataProperty}, ${R.default.rootData}=${R.default.data}${t.dynamicRef?(0,T._)`, ${R.default.dynamicAnchors}={}`:T.nil}}={}`}function gw(t,e){t.if(R.default.valCxt,()=>{t.var(R.default.instancePath,(0,T._)`${R.default.valCxt}.${R.default.instancePath}`),t.var(R.default.parentData,(0,T._)`${R.default.valCxt}.${R.default.parentData}`),t.var(R.default.parentDataProperty,(0,T._)`${R.default.valCxt}.${R.default.parentDataProperty}`),t.var(R.default.rootData,(0,T._)`${R.default.valCxt}.${R.default.rootData}`),e.dynamicRef&&t.var(R.default.dynamicAnchors,(0,T._)`${R.default.valCxt}.${R.default.dynamicAnchors}`)},()=>{t.var(R.default.instancePath,(0,T._)`""`),t.var(R.default.parentData,(0,T._)`undefined`),t.var(R.default.parentDataProperty,(0,T._)`undefined`),t.var(R.default.rootData,R.default.data),e.dynamicRef&&t.var(R.default.dynamicAnchors,(0,T._)`{}`)})}function _w(t){let{schema:e,opts:r,gen:n}=t;Fm(t,()=>{r.$comment&&e.$comment&&Km(t),Ew(t),n.let(R.default.vErrors,null),n.let(R.default.errors,0),r.unevaluated&&yw(t),Bm(t),xw(t)})}function yw(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,T._)`${r}.evaluated`),e.if((0,T._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,T._)`${t.evaluated}.props`,(0,T._)`undefined`)),e.if((0,T._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,T._)`${t.evaluated}.items`,(0,T._)`undefined`))}function Lm(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,T._)`/*# sourceURL=${r} */`:T.nil}function Sw(t,e){if(Wm(t)&&(Vm(t),Hm(t))){vw(t,e);return}(0,Zm.boolOrEmptySchema)(t,e)}function Hm({schema:t,self:e}){if(typeof t=="boolean")return!t;for(let r in t)if(e.RULES.all[r])return!0;return!1}function Wm(t){return typeof t.schema!="boolean"}function vw(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&Km(t),ww(t),kw(t);let s=n.const("_errs",R.default.errors);Bm(t,s),n.var(e,(0,T._)`${s} === ${R.default.errors}`)}function Vm(t){(0,St.checkUnknownRules)(t),bw(t)}function Bm(t,e){if(t.opts.jtd)return Um(t,[],!1,e);let r=(0,jm.getSchemaTypes)(t.schema),n=(0,jm.coerceAndCheckDataType)(t,r);Um(t,r,!n,e)}function bw(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,St.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Ew(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,St.checkStrictMode)(t,"default is ignored in the schema root")}function ww(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,fw.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function kw(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Km({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,T._)`${R.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,T.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,T._)`${R.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function xw(t){let{gen:e,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=t;r.$async?e.if((0,T._)`${R.default.errors} === 0`,()=>e.return(R.default.data),()=>e.throw((0,T._)`new ${o}(${R.default.vErrors})`)):(e.assign((0,T._)`${n}.errors`,R.default.vErrors),s.unevaluated&&$w(t),e.return((0,T._)`${R.default.errors} === 0`))}function $w({gen:t,evaluated:e,props:r,items:n}){r instanceof T.Name&&t.assign((0,T._)`${e}.props`,r),n instanceof T.Name&&t.assign((0,T._)`${e}.items`,n)}function Um(t,e,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=t,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,St.schemaHasRulesButRef)(s,l))){o.block(()=>Jm(t,"$ref",l.all.$ref.definition));return}c.jtd||Pw(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,Ha.shouldUseGroup)(s,p)&&(p.type?(o.if((0,Yo.checkDataType)(p.type,i,c.strictNumbers)),qm(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,Yo.reportTypeError)(t)),o.endIf()):qm(t,p),a||o.if((0,T._)`${R.default.errors} === ${n||0}`))}}function qm(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,pw.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Ha.shouldUseRule)(n,s)&&Jm(t,s.keyword,s.definition,e.type)})}function Pw(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(Tw(t,e),t.opts.allowUnionTypes||zw(t,e),Rw(t,t.dataTypes))}function Tw(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Gm(t.dataTypes,r)||Wa(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Ow(t,e)}}function zw(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Wa(t,"use allowUnionTypes to allow union type keyword")}function Rw(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Ha.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Iw(e,i))&&Wa(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Iw(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Gm(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Ow(t,e){let r=[];for(let n of t.dataTypes)Gm(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Wa(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,St.checkStrictMode)(t,e,t.opts.strictTypes)}var Xo=class{constructor(e,r,n){if((0,$n.validateKeywordUsage)(e,r,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=r.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,St.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=r,this.$data)this.schemaCode=e.gen.const("vSchema",Ym(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,$n.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=e.gen.const("_errs",R.default.errors))}result(e,r,n){this.failResult((0,T.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,T.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,T._)`${r} !== undefined && (${(0,T.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?xn.reportExtraError:xn.reportError)(this,this.def.error,r)}$dataError(){(0,xn.reportError)(this,this.def.$dataError||xn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,xn.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=T.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=T.nil,r=T.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,T.or)((0,T._)`${o} === undefined`,r)),e!==T.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==T.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,T.or)(i(),a());function i(){if(n.length){if(!(r instanceof T.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,T._)`${(0,Yo.checkDataTypes)(c,r,s.opts.strictNumbers,Yo.DataType.Wrong)}`}return T.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,T._)`!${c}(${r})`}return T.nil}}subschema(e,r){let n=(0,Fa.getSubschema)(this.it,e);(0,Fa.extendSubschemaData)(n,this.it,e),(0,Fa.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return Sw(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=St.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=St.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,T.Name)),!0}};jt.KeywordCxt=Xo;function Jm(t,e,r,n){let o=new Xo(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,$n.funcKeywordCode)(o,r):"macro"in r?(0,$n.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,$n.funcKeywordCode)(o,r)}var Aw=/^\/(?:[^~]|~0|~1)*$/,Mw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Ym(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return R.default.rootData;if(t[0]==="/"){if(!Aw.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=R.default.rootData}else{let u=Mw.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,T._)`${s}${(0,T.getProperty)((0,St.unescapeJsonPointer)(u))}`,i=(0,T._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}jt.getData=Ym});var Qo=w(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});var Va=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Ba.default=Va});var Tn=w(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});var Ka=kn(),Ga=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Ka.resolveUrl)(e,r,n),this.missingSchema=(0,Ka.normalizeId)((0,Ka.getFullPath)(e,this.missingRef))}};Ja.default=Ga});var ts=w(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.resolveSchema=Fe.getCompilingSchema=Fe.resolveRef=Fe.compileSchema=Fe.SchemaEnv=void 0;var Ye=A(),Cw=Qo(),Yt=yt(),Xe=kn(),Xm=F(),Nw=Pn(),Er=class{constructor(e){var r;this.refs={},this.dynamicAnchors={};let n;typeof e.schema=="object"&&(n=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=(r=e.baseId)!==null&&r!==void 0?r:(0,Xe.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};Fe.SchemaEnv=Er;function Xa(t){let e=Qm.call(this,t);if(e)return e;let r=(0,Xe.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new Ye.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:Cw.default,code:(0,Ye._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Yt.default.data,parentData:Yt.default.parentData,parentDataProperty:Yt.default.parentDataProperty,dataNames:[Yt.default.data],dataPathArr:[Ye.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Ye.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Ye.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Ye._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,Nw.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(Yt.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let f=new Function(`${Yt.default.self}`,`${Yt.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:f}),f.errors=null,f.schema=t.schema,f.schemaEnv=t,t.$async&&(f.$async=!0),this.opts.code.source===!0&&(f.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:_}=u;f.evaluated={props:m instanceof Ye.Name?void 0:m,items:_ instanceof Ye.Name?void 0:_,dynamicProps:m instanceof Ye.Name,dynamicItems:_ instanceof Ye.Name},f.source&&(f.source.evaluated=(0,Ye.stringify)(f.evaluated))}return t.validate=f,t}catch(d){throw delete t.validate,delete t.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(t)}}Fe.compileSchema=Xa;function Dw(t,e,r){var n;r=(0,Xe.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Uw.call(this,t,r);if(s===void 0){let i=(n=t.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Er({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=jw.call(this,s)}Fe.resolveRef=Dw;function jw(t){return(0,Xe.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Xa.call(this,t)}function Qm(t){for(let e of this._compilations)if(Lw(e,t))return e}Fe.getCompilingSchema=Qm;function Lw(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Uw(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||es.call(this,t,e)}function es(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Xe._getFullPath)(this.opts.uriResolver,r),o=(0,Xe.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return Ya.call(this,r,t);let s=(0,Xe.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=es.call(this,t,i);return typeof a?.schema!="object"?void 0:Ya.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Xa.call(this,i),s===(0,Xe.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Xe.resolveUrl)(this.opts.uriResolver,o,u)),new Er({schema:a,schemaId:c,root:t,baseId:o})}return Ya.call(this,r,i)}}Fe.resolveSchema=es;var qw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ya(t,{baseId:e,schema:r,root:n}){var o;if(((o=t.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of t.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,Xm.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!qw.has(a)&&u&&(e=(0,Xe.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Xm.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Xe.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=es.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Er({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var eh=w((bM,Zw)=>{Zw.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 ec=w((EM,oh)=>{"use strict";var Fw=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),rh=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);function Qa(t){let e="",r=0,n=0;for(n=0;n<t.length;n++)if(r=t[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n];break}for(n+=1;n<t.length;n++){if(r=t[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";e+=t[n]}return e}var Hw=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function th(t){return t.length=0,!0}function Ww(t,e,r){if(t.length){let n=Qa(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function Vw(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=Ww;for(let c=0;c<t.length;c++){let u=t[c];if(!(u==="["||u==="]"))if(u===":"){if(s===!0&&(i=!0),!a(o,n,r))break;if(++e>7){r.error=!0;break}c>0&&t[c-1]===":"&&(s=!0),n.push(":");continue}else if(u==="%"){if(!a(o,n,r))break;a=th}else{o.push(u);continue}}return o.length&&(a===th?r.zone=o.join(""):i?n.push(o.join("")):n.push(Qa(o))),r.address=n.join(""),r}function nh(t){if(Bw(t,":")<2)return{host:t,isIPV6:!1};let e=Vw(t);if(e.error)return{host:t,isIPV6:!1};{let r=e.address,n=e.address;return e.zone&&(r+="%"+e.zone,n+="%25"+e.zone),{host:r,isIPV6:!0,escapedHost:n}}}function Bw(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function Kw(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}function Gw(t,e){let r=e!==!0?escape:unescape;return t.scheme!==void 0&&(t.scheme=r(t.scheme)),t.userinfo!==void 0&&(t.userinfo=r(t.userinfo)),t.host!==void 0&&(t.host=r(t.host)),t.path!==void 0&&(t.path=r(t.path)),t.query!==void 0&&(t.query=r(t.query)),t.fragment!==void 0&&(t.fragment=r(t.fragment)),t}function Jw(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!rh(r)){let n=nh(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=t.host}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}oh.exports={nonSimpleDomain:Hw,recomposeAuthority:Jw,normalizeComponentEncoding:Gw,removeDotSegments:Kw,isIPv4:rh,isUUID:Fw,normalizeIPv6:nh,stringArrayToHexStripped:Qa}});var uh=w((wM,ch)=>{"use strict";var{isUUID:Yw}=ec(),Xw=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Qw=["http","https","ws","wss","urn","urn:uuid"];function ek(t){return Qw.indexOf(t)!==-1}function tc(t){return t.secure===!0?!0:t.secure===!1?!1:t.scheme?t.scheme.length===3&&(t.scheme[0]==="w"||t.scheme[0]==="W")&&(t.scheme[1]==="s"||t.scheme[1]==="S")&&(t.scheme[2]==="s"||t.scheme[2]==="S"):!1}function sh(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function ih(t){let e=String(t.scheme).toLowerCase()==="https";return(t.port===(e?443:80)||t.port==="")&&(t.port=void 0),t.path||(t.path="/"),t}function tk(t){return t.secure=tc(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function rk(t){if((t.port===(tc(t)?443:80)||t.port==="")&&(t.port=void 0),typeof t.secure=="boolean"&&(t.scheme=t.secure?"wss":"ws",t.secure=void 0),t.resourceName){let[e,r]=t.resourceName.split("?");t.path=e&&e!=="/"?e:void 0,t.query=r,t.resourceName=void 0}return t.fragment=void 0,t}function nk(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(Xw);if(r){let n=e.scheme||t.scheme||"urn";t.nid=r[1].toLowerCase(),t.nss=r[2];let o=`${n}:${e.nid||t.nid}`,s=rc(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function ok(t,e){if(t.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=e.scheme||t.scheme||"urn",n=t.nid.toLowerCase(),o=`${r}:${e.nid||n}`,s=rc(o);s&&(t=s.serialize(t,e));let i=t,a=t.nss;return i.path=`${n||e.nid}:${a}`,e.skipEscape=!0,i}function sk(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!Yw(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function ik(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var ah={scheme:"http",domainHost:!0,parse:sh,serialize:ih},ak={scheme:"https",domainHost:ah.domainHost,parse:sh,serialize:ih},rs={scheme:"ws",domainHost:!0,parse:tk,serialize:rk},ck={scheme:"wss",domainHost:rs.domainHost,parse:rs.parse,serialize:rs.serialize},uk={scheme:"urn",parse:nk,serialize:ok,skipNormalize:!0},lk={scheme:"urn:uuid",parse:sk,serialize:ik,skipNormalize:!0},ns={http:ah,https:ak,ws:rs,wss:ck,urn:uk,"urn:uuid":lk};Object.setPrototypeOf(ns,null);function rc(t){return t&&(ns[t]||ns[t.toLowerCase()])||void 0}ch.exports={wsIsSecure:tc,SCHEMES:ns,isValidSchemeName:ek,getSchemeHandler:rc}});var ph=w((kM,ss)=>{"use strict";var{normalizeIPv6:dk,removeDotSegments:zn,recomposeAuthority:pk,normalizeComponentEncoding:os,isIPv4:fk,nonSimpleDomain:mk}=ec(),{SCHEMES:hk,getSchemeHandler:lh}=uh();function gk(t,e){return typeof t=="string"?t=st(vt(t,e),e):typeof t=="object"&&(t=vt(st(t,e),e)),t}function _k(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=dh(vt(t,n),vt(e,n),n,!0);return n.skipEscape=!0,st(o,n)}function dh(t,e,r,n){let o={};return n||(t=vt(st(t,r),r),e=vt(st(e,r),r)),r=r||{},!r.tolerant&&e.scheme?(o.scheme=e.scheme,o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=zn(e.path||""),o.query=e.query):(e.userinfo!==void 0||e.host!==void 0||e.port!==void 0?(o.userinfo=e.userinfo,o.host=e.host,o.port=e.port,o.path=zn(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=zn(e.path):((t.userinfo!==void 0||t.host!==void 0||t.port!==void 0)&&!t.path?o.path="/"+e.path:t.path?o.path=t.path.slice(0,t.path.lastIndexOf("/")+1)+e.path:o.path=e.path,o.path=zn(o.path)),o.query=e.query):(o.path=t.path,e.query!==void 0?o.query=e.query:o.query=t.query),o.userinfo=t.userinfo,o.host=t.host,o.port=t.port),o.scheme=t.scheme),o.fragment=e.fragment,o}function yk(t,e,r){return typeof t=="string"?(t=unescape(t),t=st(os(vt(t,r),!0),{...r,skipEscape:!0})):typeof t=="object"&&(t=st(os(t,!0),{...r,skipEscape:!0})),typeof e=="string"?(e=unescape(e),e=st(os(vt(e,r),!0),{...r,skipEscape:!0})):typeof e=="object"&&(e=st(os(e,!0),{...r,skipEscape:!0})),t.toLowerCase()===e.toLowerCase()}function st(t,e){let r={host:t.host,scheme:t.scheme,userinfo:t.userinfo,port:t.port,path:t.path,query:t.query,nid:t.nid,nss:t.nss,uuid:t.uuid,fragment:t.fragment,reference:t.reference,resourceName:t.resourceName,secure:t.secure,error:""},n=Object.assign({},e),o=[],s=lh(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=unescape(r.path):(r.path=escape(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=pk(r);if(i!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(i),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let a=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(a=zn(a)),i===void 0&&a[0]==="/"&&a[1]==="/"&&(a="/%2F"+a.slice(2)),o.push(a)}return r.query!==void 0&&o.push("?",r.query),r.fragment!==void 0&&o.push("#",r.fragment),o.join("")}var Sk=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function vt(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let s=t.match(Sk);if(s){if(n.scheme=s[1],n.userinfo=s[3],n.host=s[4],n.port=parseInt(s[5],10),n.path=s[6]||"",n.query=s[7],n.fragment=s[8],isNaN(n.port)&&(n.port=s[5]),n.host)if(fk(n.host)===!1){let c=dk(n.host);n.host=c.host.toLowerCase(),o=c.isIPV6}else o=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let i=lh(r.scheme||n.scheme);if(!r.unicodeSupport&&(!i||!i.unicodeSupport)&&n.host&&(r.domainHost||i&&i.domainHost)&&o===!1&&mk(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(a){n.error=n.error||"Host's domain name can not be converted to ASCII: "+a}(!i||i&&!i.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=unescape(n.host))),n.path&&(n.path=escape(unescape(n.path))),n.fragment&&(n.fragment=encodeURI(decodeURIComponent(n.fragment)))),i&&i.parse&&i.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return n}var nc={SCHEMES:hk,normalize:gk,resolve:_k,resolveComponent:dh,equal:yk,serialize:st,parse:vt};ss.exports=nc;ss.exports.default=nc;ss.exports.fastUri=nc});var mh=w(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});var fh=ph();fh.code='require("ajv/dist/runtime/uri").default';oc.default=fh});var Eh=w(ge=>{"use strict";Object.defineProperty(ge,"__esModule",{value:!0});ge.CodeGen=ge.Name=ge.nil=ge.stringify=ge.str=ge._=ge.KeywordCxt=void 0;var vk=Pn();Object.defineProperty(ge,"KeywordCxt",{enumerable:!0,get:function(){return vk.KeywordCxt}});var wr=A();Object.defineProperty(ge,"_",{enumerable:!0,get:function(){return wr._}});Object.defineProperty(ge,"str",{enumerable:!0,get:function(){return wr.str}});Object.defineProperty(ge,"stringify",{enumerable:!0,get:function(){return wr.stringify}});Object.defineProperty(ge,"nil",{enumerable:!0,get:function(){return wr.nil}});Object.defineProperty(ge,"Name",{enumerable:!0,get:function(){return wr.Name}});Object.defineProperty(ge,"CodeGen",{enumerable:!0,get:function(){return wr.CodeGen}});var bk=Qo(),Sh=Tn(),Ek=Aa(),Rn=ts(),wk=A(),In=kn(),is=wn(),ic=F(),hh=eh(),kk=mh(),vh=(t,e)=>new RegExp(t,e);vh.code="new RegExp";var xk=["removeAdditional","useDefaults","coerceTypes"],$k=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),Pk={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."},Tk={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},gh=200;function zk(t){var e,r,n,o,s,i,a,c,u,l,d,p,f,m,_,S,b,E,v,$,x,Se,we,Zt,nr;let ae=t.strict,kt=(e=t.code)===null||e===void 0?void 0:e.optimize,Ke=kt===!0||kt===void 0?1:kt||0,jr=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:vh,K_=(o=t.uriResolver)!==null&&o!==void 0?o:kk.default;return{strictSchema:(i=(s=t.strictSchema)!==null&&s!==void 0?s:ae)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=t.strictNumbers)!==null&&a!==void 0?a:ae)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=t.strictTypes)!==null&&u!==void 0?u:ae)!==null&&l!==void 0?l:"log",strictTuples:(p=(d=t.strictTuples)!==null&&d!==void 0?d:ae)!==null&&p!==void 0?p:"log",strictRequired:(m=(f=t.strictRequired)!==null&&f!==void 0?f:ae)!==null&&m!==void 0?m:!1,code:t.code?{...t.code,optimize:Ke,regExp:jr}:{optimize:Ke,regExp:jr},loopRequired:(_=t.loopRequired)!==null&&_!==void 0?_:gh,loopEnum:(S=t.loopEnum)!==null&&S!==void 0?S:gh,meta:(b=t.meta)!==null&&b!==void 0?b:!0,messages:(E=t.messages)!==null&&E!==void 0?E:!0,inlineRefs:(v=t.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:($=t.schemaId)!==null&&$!==void 0?$:"$id",addUsedSchema:(x=t.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(Se=t.validateSchema)!==null&&Se!==void 0?Se:!0,validateFormats:(we=t.validateFormats)!==null&&we!==void 0?we:!0,unicodeRegExp:(Zt=t.unicodeRegExp)!==null&&Zt!==void 0?Zt:!0,int32range:(nr=t.int32range)!==null&&nr!==void 0?nr:!0,uriResolver:K_}}var On=class{constructor(e={}){this.schemas={},this.refs={},this.formats={},this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...zk(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new wk.ValueScope({scope:{},prefixes:$k,es5:r,lines:n}),this.logger=Ck(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,Ek.getRules)(),_h.call(this,Pk,e,"NOT SUPPORTED"),_h.call(this,Tk,e,"DEPRECATED","warn"),this._metaOpts=Ak.call(this),e.formats&&Ik.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&Ok.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),Rk.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=hh;n==="id"&&(o={...hh},o.id=o.$id,delete o.$id),r&&e&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:e,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof e=="object"?e[r]||e:void 0}validate(e,r){let n;if(typeof e=="string"){if(n=this.getSchema(e),!n)throw new Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(e,r){let n=this._addSchema(e,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,e,r);async function o(l,d){await s.call(this,l.$schema);let p=this._addSchema(l,d);return p.validate||i.call(this,p)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof Sh.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(e,r,n,o=this.opts.validateSchema){if(Array.isArray(e)){for(let i of e)this.addSchema(i,void 0,n,o);return this}let s;if(typeof e=="object"){let{schemaId:i}=this.opts;if(s=e[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,In.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(e,n,r,o,!0),this}addMetaSchema(e,r,n=this.opts.validateSchema){return this.addSchema(e,r,!0,n),this}validateSchema(e,r){if(typeof e=="boolean")return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,e);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(e){let r;for(;typeof(r=yh.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Rn.SchemaEnv({schema:{},schemaId:n});if(r=Rn.resolveSchema.call(this,o,e),!r)return;this.refs[e]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=yh.call(this,e);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[e],delete this.refs[e],this}case"object":{let r=e;this._cache.delete(r);let n=e[this.opts.schemaId];return n&&(n=(0,In.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(e){for(let r of e)this.addKeyword(r);return this}addKeyword(e,r){let n;if(typeof e=="string")n=e,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof e=="object"&&r===void 0){if(r=e,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(Dk.call(this,n,r),!r)return(0,ic.eachItem)(n,s=>sc.call(this,s)),this;Lk.call(this,r);let o={...r,type:(0,is.getJSONTypes)(r.type),schemaType:(0,is.getJSONTypes)(r.schemaType)};return(0,ic.eachItem)(n,o.type.length===0?s=>sc.call(this,s,o):s=>o.type.forEach(i=>sc.call(this,s,o,i))),this}getKeyword(e){let r=this.RULES.all[e];return typeof r=="object"?r.definition:!!r}removeKeyword(e){let{RULES:r}=this;delete r.keywords[e],delete r.all[e];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===e);o>=0&&n.rules.splice(o,1)}return this}addFormat(e,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[e]=r,this}errorsText(e=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!e||e.length===0?"No errors":e.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(e,r){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let o of r){let s=o.split("/").slice(1),i=e;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=bh(l))}}return e}_removeAllSchemas(e,r){for(let n in e){let o=e[n];(!r||r.test(n))&&(typeof o=="string"?delete e[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete e[n]))}}_addSchema(e,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof e=="object")i=e[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof e!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(e);if(c!==void 0)return c;n=(0,In.normalizeId)(i||n);let u=In.getSchemaRefs.call(this,e,n);return c=new Rn.SchemaEnv({schema:e,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(e,!0),c}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw new Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):Rn.compileSchema.call(this,e),!e.validate)throw new Error("ajv implementation error");return e.validate}_compileMetaSchema(e){let r=this.opts;this.opts=this._metaOpts;try{Rn.compileSchema.call(this,e)}finally{this.opts=r}}};On.ValidationError=bk.default;On.MissingRefError=Sh.default;ge.default=On;function _h(t,e,r,n="error"){for(let o in t){let s=o;s in e&&this.logger[n](`${r}: option ${o}. ${t[s]}`)}}function yh(t){return t=(0,In.normalizeId)(t),this.schemas[t]||this.refs[t]}function Rk(){let t=this.opts.schemas;if(t)if(Array.isArray(t))this.addSchema(t);else for(let e in t)this.addSchema(t[e],e)}function Ik(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function Ok(t){if(Array.isArray(t)){this.addVocabulary(t);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let e in t){let r=t[e];r.keyword||(r.keyword=e),this.addKeyword(r)}}function Ak(){let t={...this.opts};for(let e of xk)delete t[e];return t}var Mk={log(){},warn(){},error(){}};function Ck(t){if(t===!1)return Mk;if(t===void 0)return console;if(t.log&&t.warn&&t.error)return t;throw new Error("logger must implement log, warn and error methods")}var Nk=/^[a-z_$][a-z0-9_$:-]*$/i;function Dk(t,e){let{RULES:r}=this;if((0,ic.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!Nk.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!e&&e.$data&&!("code"in e||"validate"in e))throw new Error('$data keyword must have "code" or "validate" function')}function sc(t,e,r){var n;let o=e?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[t]=!0,!e)return;let a={keyword:t,definition:{...e,type:(0,is.getJSONTypes)(e.type),schemaType:(0,is.getJSONTypes)(e.schemaType)}};e.before?jk.call(this,i,a,e.before):i.rules.push(a),s.all[t]=a,(n=e.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function jk(t,e,r){let n=t.rules.findIndex(o=>o.keyword===r);n>=0?t.rules.splice(n,0,e):(t.rules.push(e),this.logger.warn(`rule ${r} is not defined`))}function Lk(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=bh(e)),t.validateSchema=this.compile(e,!0))}var Uk={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function bh(t){return{anyOf:[t,Uk]}}});var wh=w(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});var qk={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};ac.default=qk});var Ph=w(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.callRef=Xt.getValidate=void 0;var Zk=Tn(),kh=Ze(),Oe=A(),kr=yt(),xh=ts(),as=F(),Fk={keyword:"$ref",schemaType:"string",code(t){let{gen:e,schema:r,it:n}=t,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=xh.resolveRef.call(c,u,o,r);if(l===void 0)throw new Zk.default(n.opts.uriResolver,o,r);if(l instanceof xh.SchemaEnv)return p(l);return f(l);function d(){if(s===u)return cs(t,i,s,s.$async);let m=e.scopeValue("root",{ref:u});return cs(t,(0,Oe._)`${m}.validate`,u,u.$async)}function p(m){let _=$h(t,m);cs(t,_,m,m.$async)}function f(m){let _=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Oe.stringify)(m)}:{ref:m}),S=e.name("valid"),b=t.subschema({schema:m,dataTypes:[],schemaPath:Oe.nil,topSchemaRef:_,errSchemaPath:r},S);t.mergeEvaluated(b),t.ok(S)}}};function $h(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Oe._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Xt.getValidate=$h;function cs(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?kr.default.this:Oe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Oe._)`await ${(0,kh.callValidateCode)(t,e,u)}`),f(e),i||o.assign(m,!0)},_=>{o.if((0,Oe._)`!(${_} instanceof ${s.ValidationError})`,()=>o.throw(_)),p(_),i||o.assign(m,!1)}),t.ok(m)}function d(){t.result((0,kh.callValidateCode)(t,e,u),()=>f(e),()=>p(e))}function p(m){let _=(0,Oe._)`${m}.errors`;o.assign(kr.default.vErrors,(0,Oe._)`${kr.default.vErrors} === null ? ${_} : ${kr.default.vErrors}.concat(${_})`),o.assign(kr.default.errors,(0,Oe._)`${kr.default.vErrors}.length`)}function f(m){var _;if(!s.opts.unevaluated)return;let S=(_=r?.validate)===null||_===void 0?void 0:_.evaluated;if(s.props!==!0)if(S&&!S.dynamicProps)S.props!==void 0&&(s.props=as.mergeEvaluated.props(o,S.props,s.props));else{let b=o.var("props",(0,Oe._)`${m}.evaluated.props`);s.props=as.mergeEvaluated.props(o,b,s.props,Oe.Name)}if(s.items!==!0)if(S&&!S.dynamicItems)S.items!==void 0&&(s.items=as.mergeEvaluated.items(o,S.items,s.items));else{let b=o.var("items",(0,Oe._)`${m}.evaluated.items`);s.items=as.mergeEvaluated.items(o,b,s.items,Oe.Name)}}}Xt.callRef=cs;Xt.default=Fk});var Th=w(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var Hk=wh(),Wk=Ph(),Vk=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",Hk.default,Wk.default];cc.default=Vk});var zh=w(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});var us=A(),Lt=us.operators,ls={maximum:{okStr:"<=",ok:Lt.LTE,fail:Lt.GT},minimum:{okStr:">=",ok:Lt.GTE,fail:Lt.LT},exclusiveMaximum:{okStr:"<",ok:Lt.LT,fail:Lt.GTE},exclusiveMinimum:{okStr:">",ok:Lt.GT,fail:Lt.LTE}},Bk={message:({keyword:t,schemaCode:e})=>(0,us.str)`must be ${ls[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,us._)`{comparison: ${ls[t].okStr}, limit: ${e}}`},Kk={keyword:Object.keys(ls),type:"number",schemaType:"number",$data:!0,error:Bk,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,us._)`${r} ${ls[e].fail} ${n} || isNaN(${r})`)}};uc.default=Kk});var Rh=w(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var An=A(),Gk={message:({schemaCode:t})=>(0,An.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,An._)`{multipleOf: ${t}}`},Jk={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:Gk,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,An._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,An._)`${i} !== parseInt(${i})`;t.fail$data((0,An._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};lc.default=Jk});var Oh=w(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});function Ih(t){let e=t.length,r=0,n=0,o;for(;n<e;)r++,o=t.charCodeAt(n++),o>=55296&&o<=56319&&n<e&&(o=t.charCodeAt(n),(o&64512)===56320&&n++);return r}dc.default=Ih;Ih.code='require("ajv/dist/runtime/ucs2length").default'});var Ah=w(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var Qt=A(),Yk=F(),Xk=Oh(),Qk={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Qt.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Qt._)`{limit: ${t}}`},e0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:Qk,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?Qt.operators.GT:Qt.operators.LT,i=o.opts.unicode===!1?(0,Qt._)`${r}.length`:(0,Qt._)`${(0,Yk.useFunc)(t.gen,Xk.default)}(${r})`;t.fail$data((0,Qt._)`${i} ${s} ${n}`)}};pc.default=e0});var Mh=w(fc=>{"use strict";Object.defineProperty(fc,"__esModule",{value:!0});var t0=Ze(),ds=A(),r0={message:({schemaCode:t})=>(0,ds.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,ds._)`{pattern: ${t}}`},n0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:r0,code(t){let{data:e,$data:r,schema:n,schemaCode:o,it:s}=t,i=s.opts.unicodeRegExp?"u":"",a=r?(0,ds._)`(new RegExp(${o}, ${i}))`:(0,t0.usePattern)(t,n);t.fail$data((0,ds._)`!${a}.test(${e})`)}};fc.default=n0});var Ch=w(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});var Mn=A(),o0={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,Mn.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,Mn._)`{limit: ${t}}`},s0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:o0,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?Mn.operators.GT:Mn.operators.LT;t.fail$data((0,Mn._)`Object.keys(${r}).length ${o} ${n}`)}};mc.default=s0});var Nh=w(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});var Cn=Ze(),Nn=A(),i0=F(),a0={message:({params:{missingProperty:t}})=>(0,Nn.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Nn._)`{missingProperty: ${t}}`},c0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:a0,code(t){let{gen:e,schema:r,schemaCode:n,data:o,$data:s,it:i}=t,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let f=t.parentSchema.properties,{definedProperties:m}=t.it;for(let _ of r)if(f?.[_]===void 0&&!m.has(_)){let S=i.schemaEnv.baseId+i.errSchemaPath,b=`required property "${_}" is not defined at "${S}" (strictRequired)`;(0,i0.checkStrictMode)(i,b,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(Nn.nil,d);else for(let f of r)(0,Cn.checkReportMissingProp)(t,f)}function l(){let f=e.let("missing");if(c||s){let m=e.let("valid",!0);t.block$data(m,()=>p(f,m)),t.ok(m)}else e.if((0,Cn.checkMissingProp)(t,r,f)),(0,Cn.reportMissingProp)(t,f),e.else()}function d(){e.forOf("prop",n,f=>{t.setParams({missingProperty:f}),e.if((0,Cn.noPropertyInData)(e,o,f,a.ownProperties),()=>t.error())})}function p(f,m){t.setParams({missingProperty:f}),e.forOf(f,n,()=>{e.assign(m,(0,Cn.propertyInData)(e,o,f,a.ownProperties)),e.if((0,Nn.not)(m),()=>{t.error(),e.break()})},Nn.nil)}}};hc.default=c0});var Dh=w(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});var Dn=A(),u0={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Dn.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Dn._)`{limit: ${t}}`},l0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:u0,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?Dn.operators.GT:Dn.operators.LT;t.fail$data((0,Dn._)`${r}.length ${o} ${n}`)}};gc.default=l0});var ps=w(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var jh=qa();jh.code='require("ajv/dist/runtime/equal").default';_c.default=jh});var Lh=w(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var yc=wn(),_e=A(),d0=F(),p0=ps(),f0={message:({params:{i:t,j:e}})=>(0,_e.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,_e._)`{i: ${t}, j: ${e}}`},m0={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:f0,code(t){let{gen:e,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=t;if(!n&&!o)return;let c=e.let("valid"),u=s.items?(0,yc.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,_e._)`${i} === false`),t.ok(c);function l(){let m=e.let("i",(0,_e._)`${r}.length`),_=e.let("j");t.setParams({i:m,j:_}),e.assign(c,!0),e.if((0,_e._)`${m} > 1`,()=>(d()?p:f)(m,_))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function p(m,_){let S=e.name("item"),b=(0,yc.checkDataTypes)(u,S,a.opts.strictNumbers,yc.DataType.Wrong),E=e.const("indices",(0,_e._)`{}`);e.for((0,_e._)`;${m}--;`,()=>{e.let(S,(0,_e._)`${r}[${m}]`),e.if(b,(0,_e._)`continue`),u.length>1&&e.if((0,_e._)`typeof ${S} == "string"`,(0,_e._)`${S} += "_"`),e.if((0,_e._)`typeof ${E}[${S}] == "number"`,()=>{e.assign(_,(0,_e._)`${E}[${S}]`),t.error(),e.assign(c,!1).break()}).code((0,_e._)`${E}[${S}] = ${m}`)})}function f(m,_){let S=(0,d0.useFunc)(e,p0.default),b=e.name("outer");e.label(b).for((0,_e._)`;${m}--;`,()=>e.for((0,_e._)`${_} = ${m}; ${_}--;`,()=>e.if((0,_e._)`${S}(${r}[${m}], ${r}[${_}])`,()=>{t.error(),e.assign(c,!1).break(b)})))}}};Sc.default=m0});var Uh=w(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var vc=A(),h0=F(),g0=ps(),_0={message:"must be equal to constant",params:({schemaCode:t})=>(0,vc._)`{allowedValue: ${t}}`},y0={keyword:"const",$data:!0,error:_0,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,vc._)`!${(0,h0.useFunc)(e,g0.default)}(${r}, ${o})`):t.fail((0,vc._)`${s} !== ${r}`)}};bc.default=y0});var qh=w(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});var jn=A(),S0=F(),v0=ps(),b0={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,jn._)`{allowedValues: ${t}}`},E0={keyword:"enum",schemaType:"array",$data:!0,error:b0,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,S0.useFunc)(e,v0.default)),l;if(a||n)l=e.let("valid"),t.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let f=e.const("vSchema",s);l=(0,jn.or)(...o.map((m,_)=>p(f,_)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,f=>e.if((0,jn._)`${u()}(${r}, ${f})`,()=>e.assign(l,!0).break()))}function p(f,m){let _=o[m];return typeof _=="object"&&_!==null?(0,jn._)`${u()}(${r}, ${f}[${m}])`:(0,jn._)`${r} === ${_}`}}};Ec.default=E0});var Zh=w(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});var w0=zh(),k0=Rh(),x0=Ah(),$0=Mh(),P0=Ch(),T0=Nh(),z0=Dh(),R0=Lh(),I0=Uh(),O0=qh(),A0=[w0.default,k0.default,x0.default,$0.default,P0.default,T0.default,z0.default,R0.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},I0.default,O0.default];wc.default=A0});var xc=w(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.validateAdditionalItems=void 0;var er=A(),kc=F(),M0={message:({params:{len:t}})=>(0,er.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,er._)`{limit: ${t}}`},C0={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:M0,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,kc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Fh(t,n)}};function Fh(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,er._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,er._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,kc.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,er._)`${a} <= ${e.length}`);r.if((0,er.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:kc.Type.Num},u),i.allErrors||r.if((0,er.not)(u),()=>r.break())})}}Ln.validateAdditionalItems=Fh;Ln.default=C0});var $c=w(Un=>{"use strict";Object.defineProperty(Un,"__esModule",{value:!0});Un.validateTuple=void 0;var Hh=A(),fs=F(),N0=Ze(),D0={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Wh(t,"additionalItems",e);r.items=!0,!(0,fs.alwaysValidSchema)(r,e)&&t.ok((0,N0.validateArray)(t))}};function Wh(t,e,r=t.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=t;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=fs.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Hh._)`${s}.length`);r.forEach((d,p)=>{(0,fs.alwaysValidSchema)(a,d)||(n.if((0,Hh._)`${u} > ${p}`,()=>t.subschema({keyword:i,schemaProp:p,dataProp:p},c)),t.ok(c))});function l(d){let{opts:p,errSchemaPath:f}=a,m=r.length,_=m===d.minItems&&(m===d.maxItems||d[e]===!1);if(p.strictTuples&&!_){let S=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${f}"`;(0,fs.checkStrictMode)(a,S,p.strictTuples)}}}Un.validateTuple=Wh;Un.default=D0});var Vh=w(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var j0=$c(),L0={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,j0.validateTuple)(t,"items")};Pc.default=L0});var Kh=w(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});var Bh=A(),U0=F(),q0=Ze(),Z0=xc(),F0={message:({params:{len:t}})=>(0,Bh.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Bh._)`{limit: ${t}}`},H0={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:F0,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,U0.alwaysValidSchema)(n,e)&&(o?(0,Z0.validateAdditionalItems)(t,o):t.ok((0,q0.validateArray)(t)))}};Tc.default=H0});var Gh=w(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var He=A(),ms=F(),W0={message:({params:{min:t,max:e}})=>e===void 0?(0,He.str)`must contain at least ${t} valid item(s)`:(0,He.str)`must contain at least ${t} and no more than ${e} valid item(s)`,params:({params:{min:t,max:e}})=>e===void 0?(0,He._)`{minContains: ${t}}`:(0,He._)`{minContains: ${t}, maxContains: ${e}}`},V0={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:W0,code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=e.const("len",(0,He._)`${o}.length`);if(t.setParams({min:i,max:a}),a===void 0&&i===0){(0,ms.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,ms.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,ms.alwaysValidSchema)(s,r)){let _=(0,He._)`${l} >= ${i}`;a!==void 0&&(_=(0,He._)`${_} && ${l} <= ${a}`),t.pass(_);return}s.items=!0;let d=e.name("valid");a===void 0&&i===1?f(d,()=>e.if(d,()=>e.break())):i===0?(e.let(d,!0),a!==void 0&&e.if((0,He._)`${o}.length > 0`,p)):(e.let(d,!1),p()),t.result(d,()=>t.reset());function p(){let _=e.name("_valid"),S=e.let("count",0);f(_,()=>e.if(_,()=>m(S)))}function f(_,S){e.forRange("i",0,l,b=>{t.subschema({keyword:"contains",dataProp:b,dataPropType:ms.Type.Num,compositeRule:!0},_),S()})}function m(_){e.code((0,He._)`${_}++`),a===void 0?e.if((0,He._)`${_} >= ${i}`,()=>e.assign(d,!0).break()):(e.if((0,He._)`${_} > ${a}`,()=>e.assign(d,!1).break()),i===1?e.assign(d,!0):e.if((0,He._)`${_} >= ${i}`,()=>e.assign(d,!0)))}}};zc.default=V0});var Xh=w(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.validateSchemaDeps=it.validatePropertyDeps=it.error=void 0;var Rc=A(),B0=F(),qn=Ze();it.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,Rc.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,Rc._)`{property: ${t},
|
|
7
7
|
missingProperty: ${n},
|
|
8
8
|
depsCount: ${e},
|
|
9
|
-
deps: ${r}}`};var B0={keyword:"dependencies",type:"object",schemaType:"object",error:it.error,code(t){let[e,r]=K0(t);Kh(t,e),Gh(t,r)}};function K0({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function Kh(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,Zn.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,Zn.checkReportMissingProp)(t,u)}):(r.if((0,Tc._)`${c} && (${(0,Zn.checkMissingProp)(t,a,s)})`),(0,Zn.reportMissingProp)(t,s),r.else())}}it.validatePropertyDeps=Kh;function Gh(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,V0.alwaysValidSchema)(s,e[a])||(r.if((0,Zn.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}it.validateSchemaDeps=Gh;it.default=B0});var Xh=w(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var Yh=A(),G0=F(),J0={message:"property name must be valid",params:({params:t})=>(0,Yh._)`{propertyName: ${t.propertyName}}`},Y0={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:J0,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,G0.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,Yh.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};zc.default=Y0});var Ic=w(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});var gs=Ze(),Qe=A(),X0=St(),_s=F(),Q0={message:"must NOT have additional properties",params:({params:t})=>(0,Qe._)`{additionalProperty: ${t.additionalProperty}}`},ex={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:Q0,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,_s.alwaysValidSchema)(i,r))return;let u=(0,gs.allSchemaProperties)(n.properties),l=(0,gs.allSchemaProperties)(n.patternProperties);d(),t.ok((0,Qe._)`${s} === ${X0.default.errors}`);function d(){e.forIn("key",o,S=>{!u.length&&!l.length?m(S):e.if(p(S),()=>m(S))})}function p(S){let b;if(u.length>8){let E=(0,_s.schemaRefOrVal)(i,n.properties,"properties");b=(0,gs.isOwnProperty)(e,E,S)}else u.length?b=(0,Qe.or)(...u.map(E=>(0,Qe._)`${S} === ${E}`)):b=Qe.nil;return l.length&&(b=(0,Qe.or)(b,...l.map(E=>(0,Qe._)`${(0,gs.usePattern)(t,E)}.test(${S})`))),(0,Qe.not)(b)}function f(S){e.code((0,Qe._)`delete ${o}[${S}]`)}function m(S){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(S);return}if(r===!1){t.setParams({additionalProperty:S}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,_s.alwaysValidSchema)(i,r)){let b=e.name("valid");c.removeAdditional==="failing"?(_(S,b,!1),e.if((0,Qe.not)(b),()=>{t.reset(),f(S)})):(_(S,b),a||e.if((0,Qe.not)(b),()=>e.break()))}}function _(S,b,E){let v={keyword:"additionalProperties",dataProp:S,dataPropType:_s.Type.Str};E===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(v,b)}}};Rc.default=ex});var tg=w(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var tx=Tn(),Qh=Ze(),Oc=F(),eg=Ic(),rx={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&eg.default.code(new tx.KeywordCxt(s,eg.default,"additionalProperties"));let i=(0,Qh.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Oc.mergeEvaluated.props(e,(0,Oc.toHash)(i),s.props));let a=i.filter(d=>!(0,Oc.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,Qh.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Ac.default=rx});var sg=w(Mc=>{"use strict";Object.defineProperty(Mc,"__esModule",{value:!0});var rg=Ze(),ys=A(),ng=F(),og=F(),nx={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,rg.allSchemaProperties)(r),c=a.filter(_=>(0,ng.alwaysValidSchema)(s,r[_]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof ys.Name)&&(s.props=(0,og.evaluatedPropsToName)(e,s.props));let{props:d}=s;p();function p(){for(let _ of a)u&&f(_),s.allErrors?m(_):(e.var(l,!0),m(_),e.if(l))}function f(_){for(let S in u)new RegExp(_).test(S)&&(0,ng.checkStrictMode)(s,`property ${S} matches pattern ${_} (use allowMatchingProperties)`)}function m(_){e.forIn("key",n,S=>{e.if((0,ys._)`${(0,rg.usePattern)(t,_)}.test(${S})`,()=>{let b=c.includes(_);b||t.subschema({keyword:"patternProperties",schemaProp:_,dataProp:S,dataPropType:og.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,ys._)`${d}[${S}]`,!0):!b&&!s.allErrors&&e.if((0,ys.not)(l),()=>e.break())})})}}};Mc.default=nx});var ig=w(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});var ox=F(),sx={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,ox.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Cc.default=sx});var ag=w(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});var ix=Ze(),ax={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ix.validateUnion,error:{message:"must match a schema in anyOf"}};Nc.default=ax});var cg=w(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});var Ss=A(),cx=F(),ux={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,Ss._)`{passingSchemas: ${t.passing}}`},lx={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:ux,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,d)=>{let p;(0,cx.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,Ss._)`${c} && ${i}`).assign(i,!1).assign(a,(0,Ss._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,Ss.Name)})})}}};Dc.default=lx});var ug=w(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});var dx=F(),px={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,dx.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};jc.default=px});var pg=w(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});var vs=A(),dg=F(),fx={message:({params:t})=>(0,vs.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,vs._)`{failingKeyword: ${t.ifClause}}`},mx={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:fx,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,dg.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=lg(n,"then"),s=lg(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,vs.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,vs._)`${l}`):t.setParams({ifClause:l})}}}};function lg(t,e){let r=t.schema[e];return r!==void 0&&!(0,dg.alwaysValidSchema)(t,r)}Lc.default=mx});var fg=w(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});var hx=F(),gx={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,hx.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Uc.default=gx});var mg=w(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});var _x=wc(),yx=Hh(),Sx=kc(),vx=Vh(),bx=Bh(),Ex=Jh(),wx=Xh(),kx=Ic(),xx=tg(),$x=sg(),Px=ig(),Tx=ag(),zx=cg(),Rx=ug(),Ix=pg(),Ox=fg();function Ax(t=!1){let e=[Px.default,Tx.default,zx.default,Rx.default,Ix.default,Ox.default,wx.default,kx.default,Ex.default,xx.default,$x.default];return t?e.push(yx.default,vx.default):e.push(_x.default,Sx.default),e.push(bx.default),e}qc.default=Ax});var hg=w(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});var ie=A(),Mx={message:({schemaCode:t})=>(0,ie.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ie._)`{format: ${t}}`},Cx={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Mx,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():f();function p(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),_=r.const("fDef",(0,ie._)`${m}[${i}]`),S=r.let("fType"),b=r.let("format");r.if((0,ie._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(S,(0,ie._)`${_}.type || "string"`).assign(b,(0,ie._)`${_}.validate`),()=>r.assign(S,(0,ie._)`"string"`).assign(b,_)),t.fail$data((0,ie.or)(E(),v()));function E(){return c.strictSchema===!1?ie.nil:(0,ie._)`${i} && !${b}`}function v(){let $=l.$async?(0,ie._)`(${_}.async ? await ${b}(${n}) : ${b}(${n}))`:(0,ie._)`${b}(${n})`,x=(0,ie._)`(typeof ${b} == "function" ? ${$} : ${b}.test(${n}))`;return(0,ie._)`${b} && ${b} !== true && ${S} === ${e} && !${x}`}}function f(){let m=d.formats[s];if(!m){E();return}if(m===!0)return;let[_,S,b]=v(m);_===e&&t.pass($());function E(){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 v(x){let Se=x instanceof RegExp?(0,ie.regexpCode)(x):c.code.formats?(0,ie._)`${c.code.formats}${(0,ie.getProperty)(s)}`:void 0,we=r.scopeValue("formats",{key:s,ref:x,code:Se});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,ie._)`${we}.validate`]:["string",x,we]}function $(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ie._)`await ${b}(${n})`}return typeof S=="function"?(0,ie._)`${b}(${n})`:(0,ie._)`${b}.test(${n})`}}}};Zc.default=Cx});var gg=w(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});var Nx=hg(),Dx=[Nx.default];Fc.default=Dx});var _g=w(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.contentVocabulary=xr.metadataVocabulary=void 0;xr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];xr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Sg=w(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});var jx=$h(),Lx=Uh(),Ux=mg(),qx=gg(),yg=_g(),Zx=[jx.default,Lx.default,(0,Ux.default)(),qx.default,yg.metadataVocabulary,yg.contentVocabulary];Hc.default=Zx});var bg=w(bs=>{"use strict";Object.defineProperty(bs,"__esModule",{value:!0});bs.DiscrError=void 0;var vg;(function(t){t.Tag="tag",t.Mapping="mapping"})(vg||(bs.DiscrError=vg={}))});var wg=w(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var $r=A(),Wc=bg(),Eg=rs(),Fx=zn(),Hx=F(),Wx={message:({params:{discrError:t,tagName:e}})=>t===Wc.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,$r._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},Vx={keyword:"discriminator",type:"object",schemaType:"object",error:Wx,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,$r._)`${r}${(0,$r.getProperty)(a)}`);e.if((0,$r._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:Wc.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let f=p();e.if(!1);for(let m in f)e.elseIf((0,$r._)`${u} === ${m}`),e.assign(c,d(f[m]));e.else(),t.error(!1,{discrError:Wc.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(f){let m=e.name("valid"),_=t.subschema({keyword:"oneOf",schemaProp:f},m);return t.mergeEvaluated(_,$r.Name),m}function p(){var f;let m={},_=b(o),S=!0;for(let $=0;$<i.length;$++){let x=i[$];if(x?.$ref&&!(0,Hx.schemaHasRulesButRef)(x,s.self.RULES)){let we=x.$ref;if(x=Eg.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,we),x instanceof Eg.SchemaEnv&&(x=x.schema),x===void 0)throw new Fx.default(s.opts.uriResolver,s.baseId,we)}let Se=(f=x?.properties)===null||f===void 0?void 0:f[a];if(typeof Se!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);S=S&&(_||b(x)),E(Se,$)}if(!S)throw new Error(`discriminator: "${a}" must be required`);return m;function b({required:$}){return Array.isArray($)&&$.includes(a)}function E($,x){if($.const)v($.const,x);else if($.enum)for(let Se of $.enum)v(Se,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v($,x){if(typeof $!="string"||$ in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[$]=x}}}};Vc.default=Vx});var kg=w((pC,Bx)=>{Bx.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 Kc=w((Q,Bc)=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.MissingRefError=Q.ValidationError=Q.CodeGen=Q.Name=Q.nil=Q.stringify=Q.str=Q._=Q.KeywordCxt=Q.Ajv=void 0;var Kx=vh(),Gx=Sg(),Jx=wg(),xg=kg(),Yx=["/properties"],Es="http://json-schema.org/draft-07/schema",Pr=class extends Kx.default{_addVocabularies(){super._addVocabularies(),Gx.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(Jx.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(xg,Yx):xg;this.addMetaSchema(e,Es,!1),this.refs["http://json-schema.org/schema"]=Es}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(Es)?Es:void 0)}};Q.Ajv=Pr;Bc.exports=Q=Pr;Bc.exports.Ajv=Pr;Object.defineProperty(Q,"__esModule",{value:!0});Q.default=Pr;var Xx=Tn();Object.defineProperty(Q,"KeywordCxt",{enumerable:!0,get:function(){return Xx.KeywordCxt}});var Tr=A();Object.defineProperty(Q,"_",{enumerable:!0,get:function(){return Tr._}});Object.defineProperty(Q,"str",{enumerable:!0,get:function(){return Tr.str}});Object.defineProperty(Q,"stringify",{enumerable:!0,get:function(){return Tr.stringify}});Object.defineProperty(Q,"nil",{enumerable:!0,get:function(){return Tr.nil}});Object.defineProperty(Q,"Name",{enumerable:!0,get:function(){return Tr.Name}});Object.defineProperty(Q,"CodeGen",{enumerable:!0,get:function(){return Tr.CodeGen}});var Qx=es();Object.defineProperty(Q,"ValidationError",{enumerable:!0,get:function(){return Qx.default}});var e$=zn();Object.defineProperty(Q,"MissingRefError",{enumerable:!0,get:function(){return e$.default}})});var Ag=w(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.formatNames=ct.fastFormats=ct.fullFormats=void 0;function at(t,e){return{validate:t,compare:e}}ct.fullFormats={date:at(zg,Xc),time:at(Jc(!0),Qc),"date-time":at($g(!0),Ig),"iso-time":at(Jc(),Rg),"iso-date-time":at($g(),Og),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:i$,"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:f$,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:a$,int32:{type:"number",validate:l$},int64:{type:"number",validate:d$},float:{type:"number",validate:Tg},double:{type:"number",validate:Tg},password:!0,binary:!0};ct.fastFormats={...ct.fullFormats,date:at(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Xc),time:at(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Qc),"date-time":at(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Ig),"iso-time":at(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Rg),"iso-date-time":at(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Og),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};ct.formatNames=Object.keys(ct.fullFormats);function t$(t){return t%4===0&&(t%100!==0||t%400===0)}var r$=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,n$=[0,31,28,31,30,31,30,31,31,30,31,30,31];function zg(t){let e=r$.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&t$(r)?29:n$[n])}function Xc(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Gc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Jc(t){return function(r){let n=Gc.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function Qc(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function Rg(t,e){if(!(t&&e))return;let r=Gc.exec(t),n=Gc.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var Yc=/t|\s/i;function $g(t){let e=Jc(t);return function(n){let o=n.split(Yc);return o.length===2&&zg(o[0])&&e(o[1])}}function Ig(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function Og(t,e){if(!(t&&e))return;let[r,n]=t.split(Yc),[o,s]=e.split(Yc),i=Xc(r,o);if(i!==void 0)return i||Qc(n,s)}var o$=/\/|:/,s$=/^(?:[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 i$(t){return o$.test(t)&&s$.test(t)}var Pg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function a$(t){return Pg.lastIndex=0,Pg.test(t)}var c$=-(2**31),u$=2**31-1;function l$(t){return Number.isInteger(t)&&t<=u$&&t>=c$}function d$(t){return Number.isInteger(t)}function Tg(){return!0}var p$=/[^\\]\\Z/;function f$(t){if(p$.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var Mg=w(zr=>{"use strict";Object.defineProperty(zr,"__esModule",{value:!0});zr.formatLimitDefinition=void 0;var m$=Kc(),et=A(),Ut=et.operators,ws={formatMaximum:{okStr:"<=",ok:Ut.LTE,fail:Ut.GT},formatMinimum:{okStr:">=",ok:Ut.GTE,fail:Ut.LT},formatExclusiveMaximum:{okStr:"<",ok:Ut.LT,fail:Ut.GTE},formatExclusiveMinimum:{okStr:">",ok:Ut.GT,fail:Ut.LTE}},h$={message:({keyword:t,schemaCode:e})=>(0,et.str)`should be ${ws[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,et._)`{comparison: ${ws[t].okStr}, limit: ${e}}`};zr.formatLimitDefinition={keyword:Object.keys(ws),type:"string",schemaType:"string",$data:!0,error:h$,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new m$.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),f=e.const("fmt",(0,et._)`${p}[${c.schemaCode}]`);t.fail$data((0,et.or)((0,et._)`typeof ${f} != "object"`,(0,et._)`${f} instanceof RegExp`,(0,et._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let p=c.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let m=e.scopeValue("formats",{key:p,ref:f,code:i.code.formats?(0,et._)`${i.code.formats}${(0,et.getProperty)(p)}`:void 0});t.fail$data(d(m))}function d(p){return(0,et._)`${p}.compare(${r}, ${n}) ${ws[o].fail} 0`}},dependencies:["format"]};var g$=t=>(t.addKeyword(zr.formatLimitDefinition),t);zr.default=g$});var jg=w((Fn,Dg)=>{"use strict";Object.defineProperty(Fn,"__esModule",{value:!0});var Rr=Ag(),_$=Mg(),eu=A(),Cg=new eu.Name("fullFormats"),y$=new eu.Name("fastFormats"),tu=(t,e={keywords:!0})=>{if(Array.isArray(e))return Ng(t,e,Rr.fullFormats,Cg),t;let[r,n]=e.mode==="fast"?[Rr.fastFormats,y$]:[Rr.fullFormats,Cg],o=e.formats||Rr.formatNames;return Ng(t,o,r,n),e.keywords&&(0,_$.default)(t),t};tu.get=(t,e="full")=>{let n=(e==="fast"?Rr.fastFormats:Rr.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function Ng(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,eu._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}Dg.exports=Fn=tu;Object.defineProperty(Fn,"__esModule",{value:!0});Fn.default=tu});var pt=require("fs"),Du=require("path");var L=require("path"),Ks=require("os"),Ur=require("fs");var Mu=require("url");var ay={};function ey(){return typeof __dirname<"u"?__dirname:(0,L.dirname)((0,Mu.fileURLToPath)(ay.url))}var NP=ey();function no(){if(process.env.CLAUDE_MEM_DATA_DIR)return process.env.CLAUDE_MEM_DATA_DIR;let t=(0,L.join)((0,Ks.homedir)(),".claude-mem"),e=(0,L.join)(t,"settings.json");try{if((0,Ur.existsSync)(e)){let r=JSON.parse((0,Ur.readFileSync)(e,"utf-8")),n=r.env??r;if(n.CLAUDE_MEM_DATA_DIR)return n.CLAUDE_MEM_DATA_DIR}}catch{}return t}var ee=no(),oo=process.env.CLAUDE_CONFIG_DIR||(0,L.join)((0,Ks.homedir)(),".claude"),Gs=(0,L.join)(oo,"plugins","marketplaces","thedotmack"),ty=(0,L.join)(ee,"archives"),ry=(0,L.join)(ee,"logs"),ny=(0,L.join)(ee,"trash"),oy=(0,L.join)(ee,"backups"),sy=(0,L.join)(ee,"modes"),Cu=(0,L.join)(ee,"settings.json"),DP=(0,L.join)(ee,"claude-mem.db"),iy=(0,L.join)(ee,"vector-db"),Nu=(0,L.join)(ee,"observer-sessions"),jP=(0,L.basename)(Nu),LP=(0,L.join)(oo,"settings.json"),UP=(0,L.join)(oo,"commands"),qP=(0,L.join)(oo,"CLAUDE.md");var De={dataDir:()=>ee,workerPid:()=>(0,L.join)(ee,"worker.pid"),serverBetaPid:()=>(0,L.join)(ee,".server-beta.pid"),serverBetaPort:()=>(0,L.join)(ee,".server-beta.port"),serverBetaRuntime:()=>(0,L.join)(ee,".server-beta.runtime.json"),settings:()=>(0,L.join)(ee,"settings.json"),database:()=>(0,L.join)(ee,"claude-mem.db"),chroma:()=>(0,L.join)(ee,"chroma"),combinedCerts:()=>(0,L.join)(ee,"combined_certs.pem"),transcriptsConfig:()=>(0,L.join)(ee,"transcript-watch.json"),transcriptsState:()=>(0,L.join)(ee,"transcript-watch-state.json"),corpora:()=>(0,L.join)(ee,"corpora"),supervisorRegistry:()=>(0,L.join)(ee,"supervisor.json"),envFile:()=>(0,L.join)(ee,".env"),logsDir:()=>ry,archives:()=>ty,trash:()=>ny,backups:()=>oy,modes:()=>sy,vectorDb:()=>iy,observerSessions:()=>Nu};var cy=null;function uy(t){return(cy??process.stderr.write.bind(process.stderr))(t)}function Js(t){uy(t)}var Ys=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(Ys||{}),Xs=class{level=null;useColor;logFilePath=null;logFileInitialized=!1;constructor(){this.useColor=process.stdout.isTTY??!1}ensureLogFileInitialized(){if(!this.logFileInitialized){this.logFileInitialized=!0;try{let e=De.logsDir();(0,pt.existsSync)(e)||(0,pt.mkdirSync)(e,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=(0,Du.join)(e,`claude-mem-${r}.log`)}catch(e){console.error("[LOGGER] Failed to initialize log file:",e instanceof Error?e.message:String(e)),this.logFilePath=null}}}getLevel(){if(this.level===null)try{let e=De.settings();if((0,pt.existsSync)(e)){let r=(0,pt.readFileSync)(e,"utf-8"),o=(JSON.parse(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=Ys[o]??1}else this.level=1}catch(e){console.error("[LOGGER] Failed to load log level from settings:",e instanceof Error?e.message:String(e)),this.level=1}return this.level}correlationId(e,r){return`obs-${e}-${r}`}sessionId(e){return`session-${e}`}formatData(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="object"){if(e instanceof Error)return this.getLevel()===0?`${e.message}
|
|
10
|
-
${e.stack}`:e.message;if(Array.isArray(e))return`[${e.length} items]`;let r=Object.keys(e);return r.length===0?"{}":r.length<=3?JSON.stringify(e):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(e)}formatTool(e,r){if(!r)return e;let n=r;if(typeof r=="string")try{n=JSON.parse(r)}catch{n=r}if(e==="Bash"&&n.command)return`${e}(${n.command})`;if(n.file_path)return`${e}(${n.file_path})`;if(n.notebook_path)return`${e}(${n.notebook_path})`;if(e==="Glob"&&n.pattern)return`${e}(${n.pattern})`;if(e==="Grep"&&n.pattern)return`${e}(${n.pattern})`;if(n.url)return`${e}(${n.url})`;if(n.query)return`${e}(${n.query})`;if(e==="Task"){if(n.subagent_type)return`${e}(${n.subagent_type})`;if(n.description)return`${e}(${n.description})`}return e==="Skill"&&n.skill?`${e}(${n.skill})`:e==="LSP"&&n.operation?`${e}(${n.operation})`:e}formatTimestamp(e){let r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0"),c=String(e.getMilliseconds()).padStart(3,"0");return`${r}-${n}-${o} ${s}:${i}:${a}.${c}`}log(e,r,n,o,s){if(e<this.getLevel())return;this.ensureLogFileInitialized();let i=this.formatTimestamp(new Date),a=
|
|
9
|
+
deps: ${r}}`};var K0={keyword:"dependencies",type:"object",schemaType:"object",error:it.error,code(t){let[e,r]=G0(t);Jh(t,e),Yh(t,r)}};function G0({schema:t}){let e={},r={};for(let n in t){if(n==="__proto__")continue;let o=Array.isArray(t[n])?e:r;o[n]=t[n]}return[e,r]}function Jh(t,e=t.schema){let{gen:r,data:n,it:o}=t;if(Object.keys(e).length===0)return;let s=r.let("missing");for(let i in e){let a=e[i];if(a.length===0)continue;let c=(0,qn.propertyInData)(r,n,i,o.opts.ownProperties);t.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,qn.checkReportMissingProp)(t,u)}):(r.if((0,Rc._)`${c} && (${(0,qn.checkMissingProp)(t,a,s)})`),(0,qn.reportMissingProp)(t,s),r.else())}}it.validatePropertyDeps=Jh;function Yh(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,B0.alwaysValidSchema)(s,e[a])||(r.if((0,qn.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=t.subschema({keyword:o,schemaProp:a},i);t.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),t.ok(i))}it.validateSchemaDeps=Yh;it.default=K0});var eg=w(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var Qh=A(),J0=F(),Y0={message:"property name must be valid",params:({params:t})=>(0,Qh._)`{propertyName: ${t.propertyName}}`},X0={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Y0,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,J0.alwaysValidSchema)(o,r))return;let s=e.name("valid");e.forIn("key",n,i=>{t.setParams({propertyName:i}),t.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),e.if((0,Qh.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};Ic.default=X0});var Ac=w(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});var hs=Ze(),Qe=A(),Q0=yt(),gs=F(),ex={message:"must NOT have additional properties",params:({params:t})=>(0,Qe._)`{additionalProperty: ${t.additionalProperty}}`},tx={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:ex,code(t){let{gen:e,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=t;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,gs.alwaysValidSchema)(i,r))return;let u=(0,hs.allSchemaProperties)(n.properties),l=(0,hs.allSchemaProperties)(n.patternProperties);d(),t.ok((0,Qe._)`${s} === ${Q0.default.errors}`);function d(){e.forIn("key",o,S=>{!u.length&&!l.length?m(S):e.if(p(S),()=>m(S))})}function p(S){let b;if(u.length>8){let E=(0,gs.schemaRefOrVal)(i,n.properties,"properties");b=(0,hs.isOwnProperty)(e,E,S)}else u.length?b=(0,Qe.or)(...u.map(E=>(0,Qe._)`${S} === ${E}`)):b=Qe.nil;return l.length&&(b=(0,Qe.or)(b,...l.map(E=>(0,Qe._)`${(0,hs.usePattern)(t,E)}.test(${S})`))),(0,Qe.not)(b)}function f(S){e.code((0,Qe._)`delete ${o}[${S}]`)}function m(S){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(S);return}if(r===!1){t.setParams({additionalProperty:S}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,gs.alwaysValidSchema)(i,r)){let b=e.name("valid");c.removeAdditional==="failing"?(_(S,b,!1),e.if((0,Qe.not)(b),()=>{t.reset(),f(S)})):(_(S,b),a||e.if((0,Qe.not)(b),()=>e.break()))}}function _(S,b,E){let v={keyword:"additionalProperties",dataProp:S,dataPropType:gs.Type.Str};E===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(v,b)}}};Oc.default=tx});var ng=w(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});var rx=Pn(),tg=Ze(),Mc=F(),rg=Ac(),nx={keyword:"properties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,parentSchema:n,data:o,it:s}=t;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&rg.default.code(new rx.KeywordCxt(s,rg.default,"additionalProperties"));let i=(0,tg.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=Mc.mergeEvaluated.props(e,(0,Mc.toHash)(i),s.props));let a=i.filter(d=>!(0,Mc.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=e.name("valid");for(let d of a)u(d)?l(d):(e.if((0,tg.propertyInData)(e,o,d,s.opts.ownProperties)),l(d),s.allErrors||e.else().var(c,!0),e.endIf()),t.it.definedProperties.add(d),t.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){t.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Cc.default=nx});var ag=w(Nc=>{"use strict";Object.defineProperty(Nc,"__esModule",{value:!0});var og=Ze(),_s=A(),sg=F(),ig=F(),ox={keyword:"patternProperties",type:"object",schemaType:"object",code(t){let{gen:e,schema:r,data:n,parentSchema:o,it:s}=t,{opts:i}=s,a=(0,og.allSchemaProperties)(r),c=a.filter(_=>(0,sg.alwaysValidSchema)(s,r[_]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=e.name("valid");s.props!==!0&&!(s.props instanceof _s.Name)&&(s.props=(0,ig.evaluatedPropsToName)(e,s.props));let{props:d}=s;p();function p(){for(let _ of a)u&&f(_),s.allErrors?m(_):(e.var(l,!0),m(_),e.if(l))}function f(_){for(let S in u)new RegExp(_).test(S)&&(0,sg.checkStrictMode)(s,`property ${S} matches pattern ${_} (use allowMatchingProperties)`)}function m(_){e.forIn("key",n,S=>{e.if((0,_s._)`${(0,og.usePattern)(t,_)}.test(${S})`,()=>{let b=c.includes(_);b||t.subschema({keyword:"patternProperties",schemaProp:_,dataProp:S,dataPropType:ig.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,_s._)`${d}[${S}]`,!0):!b&&!s.allErrors&&e.if((0,_s.not)(l),()=>e.break())})})}}};Nc.default=ox});var cg=w(Dc=>{"use strict";Object.defineProperty(Dc,"__esModule",{value:!0});var sx=F(),ix={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,sx.alwaysValidSchema)(n,r)){t.fail();return}let o=e.name("valid");t.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),t.failResult(o,()=>t.reset(),()=>t.error())},error:{message:"must NOT be valid"}};Dc.default=ix});var ug=w(jc=>{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});var ax=Ze(),cx={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ax.validateUnion,error:{message:"must match a schema in anyOf"}};jc.default=cx});var lg=w(Lc=>{"use strict";Object.defineProperty(Lc,"__esModule",{value:!0});var ys=A(),ux=F(),lx={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,ys._)`{passingSchemas: ${t.passing}}`},dx={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:lx,code(t){let{gen:e,schema:r,parentSchema:n,it:o}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=e.let("valid",!1),a=e.let("passing",null),c=e.name("_valid");t.setParams({passing:a}),e.block(u),t.result(i,()=>t.reset(),()=>t.error(!0));function u(){s.forEach((l,d)=>{let p;(0,ux.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,ys._)`${c} && ${i}`).assign(i,!1).assign(a,(0,ys._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,ys.Name)})})}}};Lc.default=dx});var dg=w(Uc=>{"use strict";Object.defineProperty(Uc,"__esModule",{value:!0});var px=F(),fx={keyword:"allOf",schemaType:"array",code(t){let{gen:e,schema:r,it:n}=t;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=e.name("valid");r.forEach((s,i)=>{if((0,px.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};Uc.default=fx});var mg=w(qc=>{"use strict";Object.defineProperty(qc,"__esModule",{value:!0});var Ss=A(),fg=F(),mx={message:({params:t})=>(0,Ss.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,Ss._)`{failingKeyword: ${t.ifClause}}`},hx={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:mx,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,fg.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=pg(n,"then"),s=pg(n,"else");if(!o&&!s)return;let i=e.let("valid",!0),a=e.name("_valid");if(c(),t.reset(),o&&s){let l=e.let("ifClause");t.setParams({ifClause:l}),e.if(a,u("then",l),u("else",l))}else o?e.if(a,u("then")):e.if((0,Ss.not)(a),u("else"));t.pass(i,()=>t.error(!0));function c(){let l=t.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);t.mergeEvaluated(l)}function u(l,d){return()=>{let p=t.subschema({keyword:l},a);e.assign(i,a),t.mergeValidEvaluated(p,i),d?e.assign(d,(0,Ss._)`${l}`):t.setParams({ifClause:l})}}}};function pg(t,e){let r=t.schema[e];return r!==void 0&&!(0,fg.alwaysValidSchema)(t,r)}qc.default=hx});var hg=w(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});var gx=F(),_x={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,gx.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};Zc.default=_x});var gg=w(Fc=>{"use strict";Object.defineProperty(Fc,"__esModule",{value:!0});var yx=xc(),Sx=Vh(),vx=$c(),bx=Kh(),Ex=Gh(),wx=Xh(),kx=eg(),xx=Ac(),$x=ng(),Px=ag(),Tx=cg(),zx=ug(),Rx=lg(),Ix=dg(),Ox=mg(),Ax=hg();function Mx(t=!1){let e=[Tx.default,zx.default,Rx.default,Ix.default,Ox.default,Ax.default,kx.default,xx.default,wx.default,$x.default,Px.default];return t?e.push(Sx.default,bx.default):e.push(yx.default,vx.default),e.push(Ex.default),e}Fc.default=Mx});var _g=w(Hc=>{"use strict";Object.defineProperty(Hc,"__esModule",{value:!0});var ie=A(),Cx={message:({schemaCode:t})=>(0,ie.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ie._)`{format: ${t}}`},Nx={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:Cx,code(t,e){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=t,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?p():f();function p(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),_=r.const("fDef",(0,ie._)`${m}[${i}]`),S=r.let("fType"),b=r.let("format");r.if((0,ie._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(S,(0,ie._)`${_}.type || "string"`).assign(b,(0,ie._)`${_}.validate`),()=>r.assign(S,(0,ie._)`"string"`).assign(b,_)),t.fail$data((0,ie.or)(E(),v()));function E(){return c.strictSchema===!1?ie.nil:(0,ie._)`${i} && !${b}`}function v(){let $=l.$async?(0,ie._)`(${_}.async ? await ${b}(${n}) : ${b}(${n}))`:(0,ie._)`${b}(${n})`,x=(0,ie._)`(typeof ${b} == "function" ? ${$} : ${b}.test(${n}))`;return(0,ie._)`${b} && ${b} !== true && ${S} === ${e} && !${x}`}}function f(){let m=d.formats[s];if(!m){E();return}if(m===!0)return;let[_,S,b]=v(m);_===e&&t.pass($());function E(){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 v(x){let Se=x instanceof RegExp?(0,ie.regexpCode)(x):c.code.formats?(0,ie._)`${c.code.formats}${(0,ie.getProperty)(s)}`:void 0,we=r.scopeValue("formats",{key:s,ref:x,code:Se});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,ie._)`${we}.validate`]:["string",x,we]}function $(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,ie._)`await ${b}(${n})`}return typeof S=="function"?(0,ie._)`${b}(${n})`:(0,ie._)`${b}.test(${n})`}}}};Hc.default=Nx});var yg=w(Wc=>{"use strict";Object.defineProperty(Wc,"__esModule",{value:!0});var Dx=_g(),jx=[Dx.default];Wc.default=jx});var Sg=w(xr=>{"use strict";Object.defineProperty(xr,"__esModule",{value:!0});xr.contentVocabulary=xr.metadataVocabulary=void 0;xr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];xr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var bg=w(Vc=>{"use strict";Object.defineProperty(Vc,"__esModule",{value:!0});var Lx=Th(),Ux=Zh(),qx=gg(),Zx=yg(),vg=Sg(),Fx=[Lx.default,Ux.default,(0,qx.default)(),Zx.default,vg.metadataVocabulary,vg.contentVocabulary];Vc.default=Fx});var wg=w(vs=>{"use strict";Object.defineProperty(vs,"__esModule",{value:!0});vs.DiscrError=void 0;var Eg;(function(t){t.Tag="tag",t.Mapping="mapping"})(Eg||(vs.DiscrError=Eg={}))});var xg=w(Kc=>{"use strict";Object.defineProperty(Kc,"__esModule",{value:!0});var $r=A(),Bc=wg(),kg=ts(),Hx=Tn(),Wx=F(),Vx={message:({params:{discrError:t,tagName:e}})=>t===Bc.DiscrError.Tag?`tag "${e}" must be string`:`value of tag "${e}" must be in oneOf`,params:({params:{discrError:t,tag:e,tagName:r}})=>(0,$r._)`{error: ${t}, tag: ${r}, tagValue: ${e}}`},Bx={keyword:"discriminator",type:"object",schemaType:"object",error:Vx,code(t){let{gen:e,data:r,schema:n,parentSchema:o,it:s}=t,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=e.let("valid",!1),u=e.const("tag",(0,$r._)`${r}${(0,$r.getProperty)(a)}`);e.if((0,$r._)`typeof ${u} == "string"`,()=>l(),()=>t.error(!1,{discrError:Bc.DiscrError.Tag,tag:u,tagName:a})),t.ok(c);function l(){let f=p();e.if(!1);for(let m in f)e.elseIf((0,$r._)`${u} === ${m}`),e.assign(c,d(f[m]));e.else(),t.error(!1,{discrError:Bc.DiscrError.Mapping,tag:u,tagName:a}),e.endIf()}function d(f){let m=e.name("valid"),_=t.subschema({keyword:"oneOf",schemaProp:f},m);return t.mergeEvaluated(_,$r.Name),m}function p(){var f;let m={},_=b(o),S=!0;for(let $=0;$<i.length;$++){let x=i[$];if(x?.$ref&&!(0,Wx.schemaHasRulesButRef)(x,s.self.RULES)){let we=x.$ref;if(x=kg.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,we),x instanceof kg.SchemaEnv&&(x=x.schema),x===void 0)throw new Hx.default(s.opts.uriResolver,s.baseId,we)}let Se=(f=x?.properties)===null||f===void 0?void 0:f[a];if(typeof Se!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);S=S&&(_||b(x)),E(Se,$)}if(!S)throw new Error(`discriminator: "${a}" must be required`);return m;function b({required:$}){return Array.isArray($)&&$.includes(a)}function E($,x){if($.const)v($.const,x);else if($.enum)for(let Se of $.enum)v(Se,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v($,x){if(typeof $!="string"||$ in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[$]=x}}}};Kc.default=Bx});var $g=w((pC,Kx)=>{Kx.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 Jc=w((Q,Gc)=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.MissingRefError=Q.ValidationError=Q.CodeGen=Q.Name=Q.nil=Q.stringify=Q.str=Q._=Q.KeywordCxt=Q.Ajv=void 0;var Gx=Eh(),Jx=bg(),Yx=xg(),Pg=$g(),Xx=["/properties"],bs="http://json-schema.org/draft-07/schema",Pr=class extends Gx.default{_addVocabularies(){super._addVocabularies(),Jx.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(Yx.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(Pg,Xx):Pg;this.addMetaSchema(e,bs,!1),this.refs["http://json-schema.org/schema"]=bs}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(bs)?bs:void 0)}};Q.Ajv=Pr;Gc.exports=Q=Pr;Gc.exports.Ajv=Pr;Object.defineProperty(Q,"__esModule",{value:!0});Q.default=Pr;var Qx=Pn();Object.defineProperty(Q,"KeywordCxt",{enumerable:!0,get:function(){return Qx.KeywordCxt}});var Tr=A();Object.defineProperty(Q,"_",{enumerable:!0,get:function(){return Tr._}});Object.defineProperty(Q,"str",{enumerable:!0,get:function(){return Tr.str}});Object.defineProperty(Q,"stringify",{enumerable:!0,get:function(){return Tr.stringify}});Object.defineProperty(Q,"nil",{enumerable:!0,get:function(){return Tr.nil}});Object.defineProperty(Q,"Name",{enumerable:!0,get:function(){return Tr.Name}});Object.defineProperty(Q,"CodeGen",{enumerable:!0,get:function(){return Tr.CodeGen}});var e$=Qo();Object.defineProperty(Q,"ValidationError",{enumerable:!0,get:function(){return e$.default}});var t$=Tn();Object.defineProperty(Q,"MissingRefError",{enumerable:!0,get:function(){return t$.default}})});var Cg=w(ct=>{"use strict";Object.defineProperty(ct,"__esModule",{value:!0});ct.formatNames=ct.fastFormats=ct.fullFormats=void 0;function at(t,e){return{validate:t,compare:e}}ct.fullFormats={date:at(Ig,eu),time:at(Xc(!0),tu),"date-time":at(Tg(!0),Ag),"iso-time":at(Xc(),Og),"iso-date-time":at(Tg(),Mg),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:a$,"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:m$,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:c$,int32:{type:"number",validate:d$},int64:{type:"number",validate:p$},float:{type:"number",validate:Rg},double:{type:"number",validate:Rg},password:!0,binary:!0};ct.fastFormats={...ct.fullFormats,date:at(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,eu),time:at(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,tu),"date-time":at(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Ag),"iso-time":at(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Og),"iso-date-time":at(/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Mg),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};ct.formatNames=Object.keys(ct.fullFormats);function r$(t){return t%4===0&&(t%100!==0||t%400===0)}var n$=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,o$=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Ig(t){let e=n$.exec(t);if(!e)return!1;let r=+e[1],n=+e[2],o=+e[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&r$(r)?29:o$[n])}function eu(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Yc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Xc(t){return function(r){let n=Yc.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||t&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,p=o-u*c-(d<0?1:0);return(p===23||p===-1)&&(d===59||d===-1)&&i<61}}function tu(t,e){if(!(t&&e))return;let r=new Date("2020-01-01T"+t).valueOf(),n=new Date("2020-01-01T"+e).valueOf();if(r&&n)return r-n}function Og(t,e){if(!(t&&e))return;let r=Yc.exec(t),n=Yc.exec(e);if(r&&n)return t=r[1]+r[2]+r[3],e=n[1]+n[2]+n[3],t>e?1:t<e?-1:0}var Qc=/t|\s/i;function Tg(t){let e=Xc(t);return function(n){let o=n.split(Qc);return o.length===2&&Ig(o[0])&&e(o[1])}}function Ag(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function Mg(t,e){if(!(t&&e))return;let[r,n]=t.split(Qc),[o,s]=e.split(Qc),i=eu(r,o);if(i!==void 0)return i||tu(n,s)}var s$=/\/|:/,i$=/^(?:[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 a$(t){return s$.test(t)&&i$.test(t)}var zg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function c$(t){return zg.lastIndex=0,zg.test(t)}var u$=-(2**31),l$=2**31-1;function d$(t){return Number.isInteger(t)&&t<=l$&&t>=u$}function p$(t){return Number.isInteger(t)}function Rg(){return!0}var f$=/[^\\]\\Z/;function m$(t){if(f$.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var Ng=w(zr=>{"use strict";Object.defineProperty(zr,"__esModule",{value:!0});zr.formatLimitDefinition=void 0;var h$=Jc(),et=A(),Ut=et.operators,Es={formatMaximum:{okStr:"<=",ok:Ut.LTE,fail:Ut.GT},formatMinimum:{okStr:">=",ok:Ut.GTE,fail:Ut.LT},formatExclusiveMaximum:{okStr:"<",ok:Ut.LT,fail:Ut.GTE},formatExclusiveMinimum:{okStr:">",ok:Ut.GT,fail:Ut.LTE}},g$={message:({keyword:t,schemaCode:e})=>(0,et.str)`should be ${Es[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,et._)`{comparison: ${Es[t].okStr}, limit: ${e}}`};zr.formatLimitDefinition={keyword:Object.keys(Es),type:"string",schemaType:"string",$data:!0,error:g$,code(t){let{gen:e,data:r,schemaCode:n,keyword:o,it:s}=t,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new h$.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let p=e.scopeValue("formats",{ref:a.formats,code:i.code.formats}),f=e.const("fmt",(0,et._)`${p}[${c.schemaCode}]`);t.fail$data((0,et.or)((0,et._)`typeof ${f} != "object"`,(0,et._)`${f} instanceof RegExp`,(0,et._)`typeof ${f}.compare != "function"`,d(f)))}function l(){let p=c.schema,f=a.formats[p];if(!f||f===!0)return;if(typeof f!="object"||f instanceof RegExp||typeof f.compare!="function")throw new Error(`"${o}": format "${p}" does not define "compare" function`);let m=e.scopeValue("formats",{key:p,ref:f,code:i.code.formats?(0,et._)`${i.code.formats}${(0,et.getProperty)(p)}`:void 0});t.fail$data(d(m))}function d(p){return(0,et._)`${p}.compare(${r}, ${n}) ${Es[o].fail} 0`}},dependencies:["format"]};var _$=t=>(t.addKeyword(zr.formatLimitDefinition),t);zr.default=_$});var Ug=w((Zn,Lg)=>{"use strict";Object.defineProperty(Zn,"__esModule",{value:!0});var Rr=Cg(),y$=Ng(),ru=A(),Dg=new ru.Name("fullFormats"),S$=new ru.Name("fastFormats"),nu=(t,e={keywords:!0})=>{if(Array.isArray(e))return jg(t,e,Rr.fullFormats,Dg),t;let[r,n]=e.mode==="fast"?[Rr.fastFormats,S$]:[Rr.fullFormats,Dg],o=e.formats||Rr.formatNames;return jg(t,o,r,n),e.keywords&&(0,y$.default)(t),t};nu.get=(t,e="full")=>{let n=(e==="fast"?Rr.fastFormats:Rr.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function jg(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,ru._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}Lg.exports=Zn=nu;Object.defineProperty(Zn,"__esModule",{value:!0});Zn.default=nu});var dt=require("fs"),Lu=require("path");var L=require("path"),Gs=require("os"),Lr=require("fs");var Nu=require("url");var cy={};function ty(){return typeof __dirname<"u"?__dirname:(0,L.dirname)((0,Nu.fileURLToPath)(cy.url))}var NP=ty();function ro(){if(process.env.CLAUDE_MEM_DATA_DIR)return process.env.CLAUDE_MEM_DATA_DIR;let t=(0,L.join)((0,Gs.homedir)(),".claude-mem"),e=(0,L.join)(t,"settings.json");try{if((0,Lr.existsSync)(e)){let r=JSON.parse((0,Lr.readFileSync)(e,"utf-8")),n=r.env??r;if(n.CLAUDE_MEM_DATA_DIR)return n.CLAUDE_MEM_DATA_DIR}}catch{}return t}var ee=ro(),no=process.env.CLAUDE_CONFIG_DIR||(0,L.join)((0,Gs.homedir)(),".claude"),Js=(0,L.join)(no,"plugins","marketplaces","thedotmack"),ry=(0,L.join)(ee,"archives"),ny=(0,L.join)(ee,"logs"),oy=(0,L.join)(ee,"trash"),sy=(0,L.join)(ee,"backups"),iy=(0,L.join)(ee,"modes"),Du=(0,L.join)(ee,"settings.json"),DP=(0,L.join)(ee,"claude-mem.db"),ay=(0,L.join)(ee,"vector-db"),ju=(0,L.join)(ee,"observer-sessions"),jP=(0,L.basename)(ju),LP=(0,L.join)(no,"settings.json"),UP=(0,L.join)(no,"commands"),qP=(0,L.join)(no,"CLAUDE.md");var De={dataDir:()=>ee,workerPid:()=>(0,L.join)(ee,"worker.pid"),serverBetaPid:()=>(0,L.join)(ee,".server-beta.pid"),serverBetaPort:()=>(0,L.join)(ee,".server-beta.port"),serverBetaRuntime:()=>(0,L.join)(ee,".server-beta.runtime.json"),settings:()=>(0,L.join)(ee,"settings.json"),database:()=>(0,L.join)(ee,"claude-mem.db"),chroma:()=>(0,L.join)(ee,"chroma"),combinedCerts:()=>(0,L.join)(ee,"combined_certs.pem"),transcriptsConfig:()=>(0,L.join)(ee,"transcript-watch.json"),transcriptsState:()=>(0,L.join)(ee,"transcript-watch-state.json"),corpora:()=>(0,L.join)(ee,"corpora"),supervisorRegistry:()=>(0,L.join)(ee,"supervisor.json"),envFile:()=>(0,L.join)(ee,".env"),logsDir:()=>ny,archives:()=>ry,trash:()=>oy,backups:()=>sy,modes:()=>iy,vectorDb:()=>ay,observerSessions:()=>ju};var uy=null;function ly(t){return(uy??process.stderr.write.bind(process.stderr))(t)}function Ys(t){ly(t)}var Qs=(s=>(s[s.DEBUG=0]="DEBUG",s[s.INFO=1]="INFO",s[s.WARN=2]="WARN",s[s.ERROR=3]="ERROR",s[s.SILENT=4]="SILENT",s))(Qs||{}),Xs=null,ei=class{level=null;useColor;logFilePath=null;logFileInitialized=!1;constructor(){this.useColor=process.stdout.isTTY??!1}ensureLogFileInitialized(){if(!this.logFileInitialized){this.logFileInitialized=!0;try{let e=De.logsDir();(0,dt.existsSync)(e)||(0,dt.mkdirSync)(e,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=(0,Lu.join)(e,`claude-mem-${r}.log`)}catch(e){console.error("[LOGGER] Failed to initialize log file:",e instanceof Error?e.message:String(e)),this.logFilePath=null}}}getLevel(){if(this.level===null)try{let e=De.settings();if((0,dt.existsSync)(e)){let r=(0,dt.readFileSync)(e,"utf-8"),o=(JSON.parse(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=Qs[o]??1}else this.level=1}catch(e){console.error("[LOGGER] Failed to load log level from settings:",e instanceof Error?e.message:String(e)),this.level=1}return this.level}formatData(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return e.toString();if(typeof e=="object"){if(e instanceof Error)return this.getLevel()===0?`${e.message}
|
|
10
|
+
${e.stack}`:e.message;if(Array.isArray(e))return`[${e.length} items]`;let r=Object.keys(e);return r.length===0?"{}":r.length<=3?JSON.stringify(e):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(e)}formatTool(e,r){if(!r)return e;let n=r;if(typeof r=="string")try{n=JSON.parse(r)}catch{n=r}if(e==="Bash"&&n.command)return`${e}(${n.command})`;if(n.file_path)return`${e}(${n.file_path})`;if(n.notebook_path)return`${e}(${n.notebook_path})`;if(e==="Glob"&&n.pattern)return`${e}(${n.pattern})`;if(e==="Grep"&&n.pattern)return`${e}(${n.pattern})`;if(n.url)return`${e}(${n.url})`;if(n.query)return`${e}(${n.query})`;if(e==="Task"){if(n.subagent_type)return`${e}(${n.subagent_type})`;if(n.description)return`${e}(${n.description})`}return e==="Skill"&&n.skill?`${e}(${n.skill})`:e==="LSP"&&n.operation?`${e}(${n.operation})`:e}formatTimestamp(e){let r=e.getFullYear(),n=String(e.getMonth()+1).padStart(2,"0"),o=String(e.getDate()).padStart(2,"0"),s=String(e.getHours()).padStart(2,"0"),i=String(e.getMinutes()).padStart(2,"0"),a=String(e.getSeconds()).padStart(2,"0"),c=String(e.getMilliseconds()).padStart(3,"0");return`${r}-${n}-${o} ${s}:${i}:${a}.${c}`}log(e,r,n,o,s){if(e<this.getLevel())return;this.ensureLogFileInitialized();let i=this.formatTimestamp(new Date),a=Qs[e].padEnd(5),c=r.padEnd(6),u="";o?.correlationId?u=`[${o.correlationId}] `:o?.sessionId&&(u=`[session-${o.sessionId}] `);let l="";if(s!=null)if(s instanceof Error)l=this.getLevel()===0?`
|
|
11
11
|
${s.message}
|
|
12
12
|
${s.stack}`:` ${s.message}`;else if(this.getLevel()===0&&typeof s=="object")try{l=`
|
|
13
|
-
`+JSON.stringify(s,null,2)}catch{l=" "+this.formatData(s)}else l=" "+this.formatData(s);let d="";if(o){let{sessionId:f,memorySessionId:m,correlationId:_,...S}=o;Object.keys(S).length>0&&(d=` {${Object.entries(S).map(([E,v])=>`${E}=${v}`).join(", ")}}`)}let p=`[${i}] [${a}] [${c}] ${u}${n}${d}${l}`;if(this.logFilePath)try{(0,
|
|
14
|
-
`,"utf8")}catch(f){
|
|
15
|
-
`)}else
|
|
16
|
-
`)}debug(e,r,n,o){this.log(0,e,r,n,o)}info(e,r,n,o){this.log(1,e,r,n,o)}warn(e,r,n,o){this.log(2,e,r,n,o)}error(e,r,n,o){this.log(3,e,r,n,o)}
|
|
17
|
-
`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),l=u?`${u[1].split("/").pop()}:${u[2]}`:"unknown",d={...n,location:l};return this.warn(e,`[HAPPY-PATH] ${r}`,d,o),s}},y=new Xs;var ju;function g(t,e,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);let u=i.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in a||(a[p]=u[p].bind(a))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var rt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},or=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(ju=globalThis).__zod_globalConfig??(ju.__zod_globalConfig={});var sr=globalThis.__zod_globalConfig;function Ae(t){return t&&Object.assign(sr,t),sr}var U={};Au(U,{BIGINT_FORMAT_RANGES:()=>Zu,Class:()=>ei,NUMBER_FORMAT_RANGES:()=>ii,aborted:()=>Tt,allowsEval:()=>ni,assert:()=>my,assertEqual:()=>ly,assertIs:()=>py,assertNever:()=>fy,assertNotEqual:()=>dy,assignProp:()=>$t,base64ToUint8Array:()=>Hu,base64urlToUint8Array:()=>Iy,cached:()=>ar,captureStackTrace:()=>ao,cleanEnum:()=>Ry,cleanRegex:()=>Hr,clone:()=>Ge,cloneDef:()=>gy,createTransparentProxy:()=>Ey,defineLazy:()=>H,esc:()=>io,escapeRegex:()=>mt,explicitlyAborted:()=>ai,extend:()=>xy,finalizeIssue:()=>je,floatSafeRemainder:()=>ti,getElementAtPath:()=>_y,getEnumValues:()=>Zr,getLengthableOrigin:()=>Wr,getParsedType:()=>by,getSizableOrigin:()=>Fu,hexToUint8Array:()=>Ay,isObject:()=>Ft,isPlainObject:()=>Pt,issue:()=>cr,joinValues:()=>so,jsonStringifyReplacer:()=>ir,merge:()=>Py,mergeDefs:()=>ft,normalizeParams:()=>z,nullish:()=>Fr,numKeys:()=>vy,objectClone:()=>hy,omit:()=>ky,optionalKeys:()=>si,parsedType:()=>ci,partial:()=>Ty,pick:()=>wy,prefixIssues:()=>ht,primitiveTypes:()=>qu,promiseAllObject:()=>yy,propertyKeyTypes:()=>oi,randomString:()=>Sy,required:()=>zy,safeExtend:()=>$y,shallowClone:()=>Uu,slugify:()=>ri,stringifyPrimitive:()=>co,uint8ArrayToBase64:()=>Wu,uint8ArrayToBase64url:()=>Oy,uint8ArrayToHex:()=>My,unwrapMessage:()=>qr});function ly(t){return t}function dy(t){return t}function py(t){}function fy(t){throw new Error("Unexpected value in exhaustive check")}function my(t){}function Zr(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function so(t,e="|"){return t.map(r=>co(r)).join(e)}function ir(t,e){return typeof e=="bigint"?e.toString():e}function ar(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Fr(t){return t==null}function Hr(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function ti(t,e){let r=t/e,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var Lu=Symbol("evaluating");function H(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==Lu)return n===void 0&&(n=Lu,n=r()),n},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function hy(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function $t(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function ft(...t){let e={};for(let r of t){let n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function gy(t){return ft(t._zod.def)}function _y(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function yy(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function Sy(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function io(t){return JSON.stringify(t)}function ri(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var ao="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Ft(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var ni=ar(()=>{if(sr.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Pt(t){if(Ft(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Ft(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Uu(t){return Pt(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function vy(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var by=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},oi=new Set(["string","number","symbol"]),qu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function mt(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function z(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function Ey(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function co(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function si(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var ii={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]},Zu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function wy(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=ft(t._zod.def,{get shape(){let i={};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(i[a]=r.shape[a])}return $t(this,"shape",i),i},checks:[]});return Ge(t,s)}function ky(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=ft(t._zod.def,{get shape(){let i={...t._zod.def.shape};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete i[a]}return $t(this,"shape",i),i},checks:[]});return Ge(t,s)}function xy(t,e){if(!Pt(e))throw new Error("Invalid input to extend: expected a plain object");let r=t._zod.def.checks;if(r&&r.length>0){let s=t._zod.def.shape;for(let i in e)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=ft(t._zod.def,{get shape(){let s={...t._zod.def.shape,...e};return $t(this,"shape",s),s}});return Ge(t,o)}function $y(t,e){if(!Pt(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=ft(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e};return $t(this,"shape",n),n}});return Ge(t,r)}function Py(t,e){if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=ft(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e._zod.def.shape};return $t(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Ge(t,r)}function Ty(t,e,r){let o=e._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=ft(e._zod.def,{get shape(){let a=e._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=t?new t({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)c[u]=t?new t({type:"optional",innerType:a[u]}):a[u];return $t(this,"shape",c),c},checks:[]});return Ge(e,i)}function zy(t,e,r){let n=ft(e._zod.def,{get shape(){let o=e._zod.def.shape,s={...o};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new t({type:"nonoptional",innerType:o[i]}))}else for(let i in o)s[i]=new t({type:"nonoptional",innerType:o[i]});return $t(this,"shape",s),s}});return Ge(e,n)}function Tt(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function ai(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function ht(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function qr(t){return typeof t=="string"?t:t?.message}function je(t,e,r){let n=t.message?t.message:qr(t.inst?._zod.def?.error?.(t))??qr(e?.error?.(t))??qr(r.customError?.(t))??qr(r.localeError?.(t))??"Invalid input",{inst:o,continue:s,input:i,...a}=t;return a.path??(a.path=[]),a.message=n,e?.reportInput&&(a.input=i),a}function Fu(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Wr(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function ci(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let r=t;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function cr(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function Ry(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function Hu(t){let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function Wu(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function Iy(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return Hu(e+r)}function Oy(t){return Wu(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Ay(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)r[n/2]=Number.parseInt(e.slice(n,n+2),16);return r}function My(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var ei=class{constructor(...e){}};var Vu=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,ir,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},uo=g("$ZodError",Vu),ui=g("$ZodError",Vu,{Parent:Error});function Bu(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function Ku(t,e=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(e(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u];u===a.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(e(i))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return n(t),r}var lo=t=>(e,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new rt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>je(c,s,Ae())));throw ao(a,o?.callee),a}return i.value};var po=t=>async(e,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>je(c,s,Ae())));throw ao(a,o?.callee),a}return i.value};var Vr=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new rt;return s.issues.length?{success:!1,error:new(t??uo)(s.issues.map(i=>je(i,o,Ae())))}:{success:!0,data:s.value}},Br=Vr(ui),Kr=t=>async(e,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>je(i,o,Ae())))}:{success:!0,data:s.value}},fo=Kr(ui),Gu=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return lo(t)(e,r,o)};var Ju=t=>(e,r,n)=>lo(t)(e,r,n);var Yu=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return po(t)(e,r,o)};var Xu=t=>async(e,r,n)=>po(t)(e,r,n);var Qu=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Vr(t)(e,r,o)};var el=t=>(e,r,n)=>Vr(t)(e,r,n);var tl=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Kr(t)(e,r,o)};var rl=t=>async(e,r,n)=>Kr(t)(e,r,n);var nl=/^[cC][0-9a-z]{6,}$/,ol=/^[0-9a-z]+$/,sl=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,il=/^[0-9a-vA-V]{20}$/,al=/^[A-Za-z0-9]{27}$/,cl=/^[a-zA-Z0-9_-]{21}$/,ul=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var ll=/^([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})$/,li=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var dl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Ny="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function pl(){return new RegExp(Ny,"u")}var fl=/^(?:(?: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])$/,ml=/^(([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 hl=/^((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])$/,gl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_l=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,di=/^[A-Za-z0-9_-]*$/;var yl=/^https?$/,Sl=/^\+[1-9]\d{6,14}$/,vl="(?:(?:\\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])))",bl=new RegExp(`^${vl}$`);function El(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function wl(t){return new RegExp(`^${El(t)}$`)}function kl(t){let e=El({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${vl}T(?:${n})$`)}var xl=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var $l=/^-?\d+$/,pi=/^-?\d+(?:\.\d+)?$/,Pl=/^(?:true|false)$/i,Tl=/^null$/i;var zl=/^[^A-Z]*$/,Rl=/^[^a-z]*$/;var pe=g("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Il={number:"number",bigint:"bigint",object:"date"},fi=g("$ZodCheckLessThan",(t,e)=>{pe.init(t,e);let r=Il[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),mi=g("$ZodCheckGreaterThan",(t,e)=>{pe.init(t,e);let r=Il[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Ol=g("$ZodCheckMultipleOf",(t,e)=>{pe.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):ti(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),Al=g("$ZodCheckNumberFormat",(t,e)=>{pe.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=ii[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=$l)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}});var Ml=g("$ZodCheckMaxLength",(t,e)=>{var r;pe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Fr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=Wr(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),Cl=g("$ZodCheckMinLength",(t,e)=>{var r;pe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Fr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=Wr(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),Nl=g("$ZodCheckLengthEquals",(t,e)=>{var r;pe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Fr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=Wr(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Gr=g("$ZodCheckStringFormat",(t,e)=>{var r,n;pe.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),Dl=g("$ZodCheckRegex",(t,e)=>{Gr.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),jl=g("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=zl),Gr.init(t,e)}),Ll=g("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Rl),Gr.init(t,e)}),Ul=g("$ZodCheckIncludes",(t,e)=>{pe.init(t,e);let r=mt(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),ql=g("$ZodCheckStartsWith",(t,e)=>{pe.init(t,e);let r=new RegExp(`^${mt(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),Zl=g("$ZodCheckEndsWith",(t,e)=>{pe.init(t,e);let r=new RegExp(`.*${mt(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var Fl=g("$ZodCheckOverwrite",(t,e)=>{pe.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var ho=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
13
|
+
`+JSON.stringify(s,null,2)}catch{l=" "+this.formatData(s)}else l=" "+this.formatData(s);let d="";if(o){let{sessionId:f,memorySessionId:m,correlationId:_,...S}=o;Object.keys(S).length>0&&(d=` {${Object.entries(S).map(([E,v])=>`${E}=${v}`).join(", ")}}`)}let p=`[${i}] [${a}] [${c}] ${u}${n}${d}${l}`;if(this.logFilePath)try{(0,dt.appendFileSync)(this.logFilePath,p+`
|
|
14
|
+
`,"utf8")}catch(f){Ys(`[LOGGER] Failed to write to log file: ${f instanceof Error?f.message:String(f)}
|
|
15
|
+
`)}else Ys(p+`
|
|
16
|
+
`)}debug(e,r,n,o){this.log(0,e,r,n,o)}info(e,r,n,o){this.log(1,e,r,n,o)}warn(e,r,n,o){this.log(2,e,r,n,o)}setErrorSink(e){Xs=e}error(e,r,n,o){this.log(3,e,r,n,o),this.routeErrorToSink(r,n,o)}routeErrorToSink(e,r,n){try{if(!Xs||!(n instanceof Error))return;Xs(n)}catch{}}dataIn(e,r,n,o){this.info(e,`\u2192 ${r}`,n,o)}dataOut(e,r,n,o){this.info(e,`\u2190 ${r}`,n,o)}success(e,r,n,o){this.info(e,`\u2713 ${r}`,n,o)}failure(e,r,n,o){this.error(e,`\u2717 ${r}`,n,o)}happyPathError(e,r,n,o,s=""){let u=((new Error().stack||"").split(`
|
|
17
|
+
`)[2]||"").match(/at\s+(?:.*\s+)?\(?([^:]+):(\d+):(\d+)\)?/),l=u?`${u[1].split("/").pop()}:${u[2]}`:"unknown",d={...n,location:l};return this.warn(e,`[HAPPY-PATH] ${r}`,d,o),s}},y=new ei;var Uu;function g(t,e,r){function n(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:i,traits:new Set},enumerable:!1}),a._zod.traits.has(t))return;a._zod.traits.add(t),e(a,c);let u=i.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in a||(a[p]=u[p].bind(a))}}let o=r?.Parent??Object;class s extends o{}Object.defineProperty(s,"name",{value:t});function i(a){var c;let u=r?.Parent?new s:this;n(u,a),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(i,"init",{value:n}),Object.defineProperty(i,Symbol.hasInstance,{value:a=>r?.Parent&&a instanceof r.Parent?!0:a?._zod?.traits?.has(t)}),Object.defineProperty(i,"name",{value:t}),i}var rt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},or=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(Uu=globalThis).__zod_globalConfig??(Uu.__zod_globalConfig={});var sr=globalThis.__zod_globalConfig;function Ae(t){return t&&Object.assign(sr,t),sr}var U={};Cu(U,{BIGINT_FORMAT_RANGES:()=>Hu,Class:()=>ri,NUMBER_FORMAT_RANGES:()=>ci,aborted:()=>Tt,allowsEval:()=>si,assert:()=>hy,assertEqual:()=>dy,assertIs:()=>fy,assertNever:()=>my,assertNotEqual:()=>py,assignProp:()=>$t,base64ToUint8Array:()=>Vu,base64urlToUint8Array:()=>Oy,cached:()=>ar,captureStackTrace:()=>io,cleanEnum:()=>Iy,cleanRegex:()=>Fr,clone:()=>Ge,cloneDef:()=>_y,createTransparentProxy:()=>wy,defineLazy:()=>H,esc:()=>so,escapeRegex:()=>ft,explicitlyAborted:()=>ui,extend:()=>$y,finalizeIssue:()=>je,floatSafeRemainder:()=>ni,getElementAtPath:()=>yy,getEnumValues:()=>qr,getLengthableOrigin:()=>Hr,getParsedType:()=>Ey,getSizableOrigin:()=>Wu,hexToUint8Array:()=>My,isObject:()=>Ft,isPlainObject:()=>Pt,issue:()=>cr,joinValues:()=>oo,jsonStringifyReplacer:()=>ir,merge:()=>Ty,mergeDefs:()=>pt,normalizeParams:()=>z,nullish:()=>Zr,numKeys:()=>by,objectClone:()=>gy,omit:()=>xy,optionalKeys:()=>ai,parsedType:()=>li,partial:()=>zy,pick:()=>ky,prefixIssues:()=>mt,primitiveTypes:()=>Fu,promiseAllObject:()=>Sy,propertyKeyTypes:()=>ii,randomString:()=>vy,required:()=>Ry,safeExtend:()=>Py,shallowClone:()=>Zu,slugify:()=>oi,stringifyPrimitive:()=>ao,uint8ArrayToBase64:()=>Bu,uint8ArrayToBase64url:()=>Ay,uint8ArrayToHex:()=>Cy,unwrapMessage:()=>Ur});function dy(t){return t}function py(t){return t}function fy(t){}function my(t){throw new Error("Unexpected value in exhaustive check")}function hy(t){}function qr(t){let e=Object.values(t).filter(n=>typeof n=="number");return Object.entries(t).filter(([n,o])=>e.indexOf(+n)===-1).map(([n,o])=>o)}function oo(t,e="|"){return t.map(r=>ao(r)).join(e)}function ir(t,e){return typeof e=="bigint"?e.toString():e}function ar(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function Zr(t){return t==null}function Fr(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function ni(t,e){let r=t/e,n=Math.round(r),o=Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var qu=Symbol("evaluating");function H(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==qu)return n===void 0&&(n=qu,n=r()),n},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function gy(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function $t(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function pt(...t){let e={};for(let r of t){let n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function _y(t){return pt(t._zod.def)}function yy(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function Sy(t){let e=Object.keys(t),r=e.map(n=>t[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<e.length;s++)o[e[s]]=n[s];return o})}function vy(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function so(t){return JSON.stringify(t)}function oi(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var io="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Ft(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var si=ar(()=>{if(sr.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function Pt(t){if(Ft(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Ft(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Zu(t){return Pt(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function by(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var Ey=t=>{let e=typeof t;switch(e){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(t)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},ii=new Set(["string","number","symbol"]),Fu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ft(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ge(t,e,r){let n=new t._zod.constr(e??t._zod.def);return(!e||r?.parent)&&(n._zod.parent=t),n}function z(t){let e=t;if(!e)return{};if(typeof e=="string")return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function wy(t){let e;return new Proxy({},{get(r,n,o){return e??(e=t()),Reflect.get(e,n,o)},set(r,n,o,s){return e??(e=t()),Reflect.set(e,n,o,s)},has(r,n){return e??(e=t()),Reflect.has(e,n)},deleteProperty(r,n){return e??(e=t()),Reflect.deleteProperty(e,n)},ownKeys(r){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(r,n){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,n)},defineProperty(r,n,o){return e??(e=t()),Reflect.defineProperty(e,n,o)}})}function ao(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function ai(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var ci={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]},Hu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function ky(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s=pt(t._zod.def,{get shape(){let i={};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&(i[a]=r.shape[a])}return $t(this,"shape",i),i},checks:[]});return Ge(t,s)}function xy(t,e){let r=t._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=pt(t._zod.def,{get shape(){let i={...t._zod.def.shape};for(let a in e){if(!(a in r.shape))throw new Error(`Unrecognized key: "${a}"`);e[a]&&delete i[a]}return $t(this,"shape",i),i},checks:[]});return Ge(t,s)}function $y(t,e){if(!Pt(e))throw new Error("Invalid input to extend: expected a plain object");let r=t._zod.def.checks;if(r&&r.length>0){let s=t._zod.def.shape;for(let i in e)if(Object.getOwnPropertyDescriptor(s,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let o=pt(t._zod.def,{get shape(){let s={...t._zod.def.shape,...e};return $t(this,"shape",s),s}});return Ge(t,o)}function Py(t,e){if(!Pt(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=pt(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e};return $t(this,"shape",n),n}});return Ge(t,r)}function Ty(t,e){if(t._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=pt(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e._zod.def.shape};return $t(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Ge(t,r)}function zy(t,e,r){let o=e._zod.def.checks;if(o&&o.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let i=pt(e._zod.def,{get shape(){let a=e._zod.def.shape,c={...a};if(r)for(let u in r){if(!(u in a))throw new Error(`Unrecognized key: "${u}"`);r[u]&&(c[u]=t?new t({type:"optional",innerType:a[u]}):a[u])}else for(let u in a)c[u]=t?new t({type:"optional",innerType:a[u]}):a[u];return $t(this,"shape",c),c},checks:[]});return Ge(e,i)}function Ry(t,e,r){let n=pt(e._zod.def,{get shape(){let o=e._zod.def.shape,s={...o};if(r)for(let i in r){if(!(i in s))throw new Error(`Unrecognized key: "${i}"`);r[i]&&(s[i]=new t({type:"nonoptional",innerType:o[i]}))}else for(let i in o)s[i]=new t({type:"nonoptional",innerType:o[i]});return $t(this,"shape",s),s}});return Ge(e,n)}function Tt(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue!==!0)return!0;return!1}function ui(t,e=0){if(t.aborted===!0)return!0;for(let r=e;r<t.issues.length;r++)if(t.issues[r]?.continue===!1)return!0;return!1}function mt(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Ur(t){return typeof t=="string"?t:t?.message}function je(t,e,r){let n=t.message?t.message:Ur(t.inst?._zod.def?.error?.(t))??Ur(e?.error?.(t))??Ur(r.customError?.(t))??Ur(r.localeError?.(t))??"Invalid input",{inst:o,continue:s,input:i,...a}=t;return a.path??(a.path=[]),a.message=n,e?.reportInput&&(a.input=i),a}function Wu(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Hr(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function li(t){let e=typeof t;switch(e){case"number":return Number.isNaN(t)?"nan":"number";case"object":{if(t===null)return"null";if(Array.isArray(t))return"array";let r=t;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return e}function cr(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function Iy(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function Vu(t){let e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function Bu(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function Oy(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return Vu(e+r)}function Ay(t){return Bu(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function My(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(e.length/2);for(let n=0;n<e.length;n+=2)r[n/2]=Number.parseInt(e.slice(n,n+2),16);return r}function Cy(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var ri=class{constructor(...e){}};var Ku=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),t.message=JSON.stringify(e,ir,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},co=g("$ZodError",Ku),di=g("$ZodError",Ku,{Parent:Error});function Gu(t,e=r=>r.message){let r={},n=[];for(let o of t.issues)o.path.length>0?(r[o.path[0]]=r[o.path[0]]||[],r[o.path[0]].push(e(o))):n.push(e(o));return{formErrors:n,fieldErrors:r}}function Ju(t,e=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(e(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u];u===a.length-1?(c[l]=c[l]||{_errors:[]},c[l]._errors.push(e(i))):c[l]=c[l]||{_errors:[]},c=c[l],u++}}}};return n(t),r}var uo=t=>(e,r,n,o)=>{let s=n?{...n,async:!1}:{async:!1},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new rt;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>je(c,s,Ae())));throw io(a,o?.callee),a}return i.value};var lo=t=>async(e,r,n,o)=>{let s=n?{...n,async:!0}:{async:!0},i=e._zod.run({value:r,issues:[]},s);if(i instanceof Promise&&(i=await i),i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>je(c,s,Ae())));throw io(a,o?.callee),a}return i.value};var Wr=t=>(e,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=e._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new rt;return s.issues.length?{success:!1,error:new(t??co)(s.issues.map(i=>je(i,o,Ae())))}:{success:!0,data:s.value}},Vr=Wr(di),Br=t=>async(e,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=e._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?{success:!1,error:new t(s.issues.map(i=>je(i,o,Ae())))}:{success:!0,data:s.value}},po=Br(di),Yu=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return uo(t)(e,r,o)};var Xu=t=>(e,r,n)=>uo(t)(e,r,n);var Qu=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return lo(t)(e,r,o)};var el=t=>async(e,r,n)=>lo(t)(e,r,n);var tl=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Wr(t)(e,r,o)};var rl=t=>(e,r,n)=>Wr(t)(e,r,n);var nl=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Br(t)(e,r,o)};var ol=t=>async(e,r,n)=>Br(t)(e,r,n);var sl=/^[cC][0-9a-z]{6,}$/,il=/^[0-9a-z]+$/,al=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,cl=/^[0-9a-vA-V]{20}$/,ul=/^[A-Za-z0-9]{27}$/,ll=/^[a-zA-Z0-9_-]{21}$/,dl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var pl=/^([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})$/,pi=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var fl=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var Dy="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function ml(){return new RegExp(Dy,"u")}var hl=/^(?:(?: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])$/,gl=/^(([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 _l=/^((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])$/,yl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Sl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,fi=/^[A-Za-z0-9_-]*$/;var vl=/^https?$/,bl=/^\+[1-9]\d{6,14}$/,El="(?:(?:\\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])))",wl=new RegExp(`^${El}$`);function kl(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function xl(t){return new RegExp(`^${kl(t)}$`)}function $l(t){let e=kl({precision:t.precision}),r=["Z"];t.local&&r.push(""),t.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${e}(?:${r.join("|")})`;return new RegExp(`^${El}T(?:${n})$`)}var Pl=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var Tl=/^-?\d+$/,mi=/^-?\d+(?:\.\d+)?$/,zl=/^(?:true|false)$/i,Rl=/^null$/i;var Il=/^[^A-Z]*$/,Ol=/^[^a-z]*$/;var pe=g("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),Al={number:"number",bigint:"bigint",object:"date"},hi=g("$ZodCheckLessThan",(t,e)=>{pe.init(t,e);let r=Al[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.maximum:o.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<s&&(e.inclusive?o.maximum=e.value:o.exclusiveMaximum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value<=e.value:n.value<e.value)||n.issues.push({origin:r,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),gi=g("$ZodCheckGreaterThan",(t,e)=>{pe.init(t,e);let r=Al[typeof e.value];t._zod.onattach.push(n=>{let o=n._zod.bag,s=(e.inclusive?o.minimum:o.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>s&&(e.inclusive?o.minimum=e.value:o.exclusiveMinimum=e.value)}),t._zod.check=n=>{(e.inclusive?n.value>=e.value:n.value>e.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:n.value,inclusive:e.inclusive,inst:t,continue:!e.abort})}}),Ml=g("$ZodCheckMultipleOf",(t,e)=>{pe.init(t,e),t._zod.onattach.push(r=>{var n;(n=r._zod.bag).multipleOf??(n.multipleOf=e.value)}),t._zod.check=r=>{if(typeof r.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%e.value===BigInt(0):ni(r.value,e.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:e.value,input:r.value,inst:t,continue:!e.abort})}}),Cl=g("$ZodCheckNumberFormat",(t,e)=>{pe.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=ci[e.format];t._zod.onattach.push(i=>{let a=i._zod.bag;a.format=e.format,a.minimum=o,a.maximum=s,r&&(a.pattern=Tl)}),t._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:e.format,code:"invalid_type",continue:!1,input:a,inst:t});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:n,inclusive:!0,continue:!e.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:t,continue:!e.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:t,continue:!e.abort})}});var Nl=g("$ZodCheckMaxLength",(t,e)=>{var r;pe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Zr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<o&&(n._zod.bag.maximum=e.maximum)}),t._zod.check=n=>{let o=n.value;if(o.length<=e.maximum)return;let i=Hr(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),Dl=g("$ZodCheckMinLength",(t,e)=>{var r;pe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Zr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>o&&(n._zod.bag.minimum=e.minimum)}),t._zod.check=n=>{let o=n.value;if(o.length>=e.minimum)return;let i=Hr(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),jl=g("$ZodCheckLengthEquals",(t,e)=>{var r;pe.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!Zr(o)&&o.length!==void 0}),t._zod.onattach.push(n=>{let o=n._zod.bag;o.minimum=e.length,o.maximum=e.length,o.length=e.length}),t._zod.check=n=>{let o=n.value,s=o.length;if(s===e.length)return;let i=Hr(o),a=s>e.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:!0,exact:!0,input:n.value,inst:t,continue:!e.abort})}}),Kr=g("$ZodCheckStringFormat",(t,e)=>{var r,n;pe.init(t,e),t._zod.onattach.push(o=>{let s=o._zod.bag;s.format=e.format,e.pattern&&(s.patterns??(s.patterns=new Set),s.patterns.add(e.pattern))}),e.pattern?(r=t._zod).check??(r.check=o=>{e.pattern.lastIndex=0,!e.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:e.format,input:o.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort})}):(n=t._zod).check??(n.check=()=>{})}),Ll=g("$ZodCheckRegex",(t,e)=>{Kr.init(t,e),t._zod.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort})}}),Ul=g("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Il),Kr.init(t,e)}),ql=g("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Ol),Kr.init(t,e)}),Zl=g("$ZodCheckIncludes",(t,e)=>{pe.init(t,e);let r=ft(e.includes),n=new RegExp(typeof e.position=="number"?`^.{${e.position}}${r}`:r);e.pattern=n,t._zod.onattach.push(o=>{let s=o._zod.bag;s.patterns??(s.patterns=new Set),s.patterns.add(n)}),t._zod.check=o=>{o.value.includes(e.includes,e.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:o.value,inst:t,continue:!e.abort})}}),Fl=g("$ZodCheckStartsWith",(t,e)=>{pe.init(t,e);let r=new RegExp(`^${ft(e.prefix)}.*`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.startsWith(e.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:n.value,inst:t,continue:!e.abort})}}),Hl=g("$ZodCheckEndsWith",(t,e)=>{pe.init(t,e);let r=new RegExp(`.*${ft(e.suffix)}$`);e.pattern??(e.pattern=r),t._zod.onattach.push(n=>{let o=n._zod.bag;o.patterns??(o.patterns=new Set),o.patterns.add(r)}),t._zod.check=n=>{n.value.endsWith(e.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:n.value,inst:t,continue:!e.abort})}});var Wl=g("$ZodCheckOverwrite",(t,e)=>{pe.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var mo=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let n=e.split(`
|
|
18
18
|
`).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let e=Function,r=this?.args,o=[...(this?.content??[""]).map(s=>` ${s}`)];return new e(...r,o.join(`
|
|
19
|
-
`))}};var
|
|
19
|
+
`))}};var Bl={major:4,minor:4,patch:3};var G=g("$ZodType",(t,e)=>{var r;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=Bl;let n=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&n.unshift(t);for(let o of n)for(let s of o._zod.onattach)s(t);if(n.length===0)(r=t._zod).deferred??(r.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse});else{let o=(i,a,c)=>{let u=Tt(i),l;for(let d of a){if(d._zod.def.when){if(ui(i)||!d._zod.def.when(i))continue}else if(u)continue;let p=i.issues.length,f=d._zod.check(i);if(f instanceof Promise&&c?.async===!1)throw new rt;if(l||f instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await f,i.issues.length!==p&&(u||(u=Tt(i,p)))});else{if(i.issues.length===p)continue;u||(u=Tt(i,p))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if(Tt(i))return i.aborted=!0,i;let u=o(a,n,c);if(u instanceof Promise){if(c.async===!1)throw new rt;return u.then(l=>t._zod.parse(l,c))}return t._zod.parse(u,c)};t._zod.run=(i,a)=>{if(a.skipChecks)return t._zod.parse(i,a);if(a.direction==="backward"){let u=t._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return u instanceof Promise?u.then(l=>s(l,i,a)):s(u,i,a)}let c=t._zod.parse(i,a);if(c instanceof Promise){if(a.async===!1)throw new rt;return c.then(u=>o(u,n,a))}return o(c,n,a)}}H(t,"~standard",()=>({validate:o=>{try{let s=Vr(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return po(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),_o=g("$ZodString",(t,e)=>{G.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Pl(t._zod.bag),t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:t}),r}}),J=g("$ZodStringFormat",(t,e)=>{Kr.init(t,e),_o.init(t,e)}),rd=g("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=pl),J.init(t,e)}),nd=g("$ZodUUID",(t,e)=>{if(e.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(n===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=pi(n))}else e.pattern??(e.pattern=pi());J.init(t,e)}),od=g("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=fl),J.init(t,e)}),sd=g("$ZodURL",(t,e)=>{J.init(t,e),t._zod.check=r=>{try{let n=r.value.trim();if(!e.normalize&&e.protocol?.source===vl.source&&!/^https?:\/\//i.test(n)){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:t,continue:!e.abort});return}let o=new URL(n);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:r.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:r.value,inst:t,continue:!e.abort})),e.normalize?r.value=o.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:t,continue:!e.abort})}}}),id=g("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=ml()),J.init(t,e)}),ad=g("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=ll),J.init(t,e)}),cd=g("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=sl),J.init(t,e)}),ud=g("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=il),J.init(t,e)}),ld=g("$ZodULID",(t,e)=>{e.pattern??(e.pattern=al),J.init(t,e)}),dd=g("$ZodXID",(t,e)=>{e.pattern??(e.pattern=cl),J.init(t,e)}),pd=g("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=ul),J.init(t,e)}),fd=g("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=$l(e)),J.init(t,e)}),md=g("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=wl),J.init(t,e)}),hd=g("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=xl(e)),J.init(t,e)}),gd=g("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=dl),J.init(t,e)}),_d=g("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=hl),J.init(t,e),t._zod.bag.format="ipv4"}),yd=g("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=gl),J.init(t,e),t._zod.bag.format="ipv6",t._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:t,continue:!e.abort})}}});var Sd=g("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=_l),J.init(t,e)}),vd=g("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=yl),J.init(t,e),t._zod.check=r=>{let n=r.value.split("/");try{if(n.length!==2)throw new Error;let[o,s]=n;if(!s)throw new Error;let i=Number(s);if(`${i}`!==s)throw new Error;if(i<0||i>128)throw new Error;new URL(`http://[${o}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:t,continue:!e.abort})}}});function bd(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var Ed=g("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Sl),J.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=r=>{bd(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function Uy(t){if(!fi.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return bd(r)}var wd=g("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=fi),J.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=r=>{Uy(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),kd=g("$ZodE164",(t,e)=>{e.pattern??(e.pattern=bl),J.init(t,e)});function qy(t,e=null){try{let r=t.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||e&&(!("alg"in o)||o.alg!==e))}catch{return!1}}var xd=g("$ZodJWT",(t,e)=>{J.init(t,e),t._zod.check=r=>{qy(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var yi=g("$ZodNumber",(t,e)=>{G.init(t,e),t._zod.pattern=t._zod.bag.pattern??mi,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:t,...s?{received:s}:{}}),r}}),$d=g("$ZodNumberFormat",(t,e)=>{Cl.init(t,e),yi.init(t,e)}),Pd=g("$ZodBoolean",(t,e)=>{G.init(t,e),t._zod.pattern=zl,t._zod.parse=(r,n)=>{if(e.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:t}),r}});var Td=g("$ZodNull",(t,e)=>{G.init(t,e),t._zod.pattern=Rl,t._zod.values=new Set([null]),t._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:t}),r}});var zd=g("$ZodUnknown",(t,e)=>{G.init(t,e),t._zod.parse=r=>r}),Rd=g("$ZodNever",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function Kl(t,e,r){t.issues.length&&e.issues.push(...mt(r,t.issues)),e.value[r]=t.value}var Id=g("$ZodArray",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:t}),r;r.value=Array(o.length);let s=[];for(let i=0;i<o.length;i++){let a=o[i],c=e.element._zod.run({value:a,issues:[]},n);c instanceof Promise?s.push(c.then(u=>Kl(u,r,i))):Kl(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function go(t,e,r,n,o,s){let i=r in n;if(t.issues.length){if(o&&s&&!i)return;e.issues.push(...mt(r,t.issues))}if(!i&&!o){t.issues.length||e.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}t.value===void 0?i&&(e.value[r]=void 0):e.value[r]=t.value}function Od(t){let e=Object.keys(t.shape);for(let n of e)if(!t.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=ai(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function Ad(t,e,r,n,o,s){let i=[],a=o.keySet,c=o.catchall._zod,u=c.def.type,l=c.optin==="optional",d=c.optout==="optional";for(let p in e){if(p==="__proto__"||a.has(p))continue;if(u==="never"){i.push(p);continue}let f=c.run({value:e[p],issues:[]},n);f instanceof Promise?t.push(f.then(m=>go(m,r,p,e,l,d))):go(f,r,p,e,l,d)}return i.length&&r.issues.push({code:"unrecognized_keys",keys:i,input:e,inst:s}),t.length?Promise.all(t).then(()=>r):r}var Zy=g("$ZodObject",(t,e)=>{if(G.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let a=e.shape;Object.defineProperty(e,"shape",{get:()=>{let c={...a};return Object.defineProperty(e,"shape",{value:c}),c}})}let n=ar(()=>Od(e));H(t._zod,"propValues",()=>{let a=e.shape,c={};for(let u in a){let l=a[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d)}}return c});let o=Ft,s=e.catchall,i;t._zod.parse=(a,c)=>{i??(i=n.value);let u=a.value;if(!o(u))return a.issues.push({expected:"object",code:"invalid_type",input:u,inst:t}),a;a.value={};let l=[],d=i.shape;for(let p of i.keys){let f=d[p],m=f._zod.optin==="optional",_=f._zod.optout==="optional",S=f._zod.run({value:u[p],issues:[]},c);S instanceof Promise?l.push(S.then(b=>go(b,a,p,u,m,_))):go(S,a,p,u,m,_)}return s?Ad(l,u,a,c,n.value,t):l.length?Promise.all(l).then(()=>a):a}}),Md=g("$ZodObjectJIT",(t,e)=>{Zy.init(t,e);let r=t._zod.parse,n=ar(()=>Od(e)),o=p=>{let f=new mo(["shape","payload","ctx"]),m=n.value,_=v=>{let $=so(v);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};f.write("const input = payload.value;");let S=Object.create(null),b=0;for(let v of m.keys)S[v]=`key_${b++}`;f.write("const newResult = {};");for(let v of m.keys){let $=S[v],x=so(v),Se=p[v],we=Se?._zod?.optin==="optional",Zt=Se?._zod?.optout==="optional";f.write(`const ${$} = ${_(v)};`),we&&Zt?f.write(`
|
|
20
20
|
if (${$}.issues.length) {
|
|
21
21
|
if (${x} in input) {
|
|
22
22
|
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
@@ -75,11 +75,11 @@ ${s.stack}`:` ${s.message}`;else if(this.getLevel()===0&&typeof s=="object")try{
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
`)}f.write("payload.value = newResult;"),f.write("return payload;");let E=f.compile();return(v,$)=>E(p,v,$)},s,i=Ft,a=!sr.jitless,u=a&&ni.value,l=e.catchall,d;t._zod.parse=(p,f)=>{d??(d=n.value);let m=p.value;return i(m)?a&&u&&f?.async===!1&&f.jitless!==!0?(s||(s=o(e.shape)),p=s(p,f),l?Id([],m,p,f,d,t):p):r(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),p)}});function Bl(t,e,r,n){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;let o=t.filter(s=>!Tt(s));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(i=>je(i,n,Ae())))}),e)}var _i=g("$ZodUnion",(t,e)=>{G.init(t,e),H(t._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),H(t._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),H(t._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),H(t._zod,"pattern",()=>{if(e.options.every(n=>n._zod.pattern)){let n=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>Hr(o.source)).join("|")})$`)}});let r=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of e.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=>Bl(a,n,t,o)):Bl(i,n,t,o)}});var Ad=g("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,_i.init(t,e);let r=t._zod.parse;H(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=ar(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!Ft(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(n.value.keys()),input:i,path:[e.discriminator],inst:t}),o)}}),Md=g("$ZodIntersection",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Kl(r,c,u)):Kl(r,s,i)}});function hi(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Pt(t)&&Pt(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=hi(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=hi(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 Kl(t,e,r){let n=new Map,o;for(let a of e.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else t.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else t.issues.push(a);let s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&t.issues.push({...o,keys:s}),Tt(t))return t;let i=hi(e.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return t.value=i.data,t}var Cd=g("$ZodRecord",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Pt(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[],i=e.keyType._zod.values;if(i){r.value={};let a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let l=e.keyType._zod.run({value:u,issues:[]},n);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>je(f,n,Ae())),input:u,path:[u],inst:t});continue}let d=l.value,p=e.valueType._zod.run({value:o[u],issues:[]},n);p instanceof Promise?s.push(p.then(f=>{f.issues.length&&r.issues.push(...ht(u,f.issues)),r.value[d]=f.value})):(p.issues.length&&r.issues.push(...ht(u,p.issues)),r.value[d]=p.value)}let c;for(let u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(o)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=e.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&pi.test(a)&&c.issues.length){let d=e.keyType._zod.run({value:Number(a),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){e.mode==="loose"?r.value[a]=o[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>je(d,n,Ae())),input:a,path:[a],inst:t});continue}let l=e.valueType._zod.run({value:o[a],issues:[]},n);l instanceof Promise?s.push(l.then(d=>{d.issues.length&&r.issues.push(...ht(a,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...ht(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}});var Nd=g("$ZodEnum",(t,e)=>{G.init(t,e);let r=Zr(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(o=>oi.has(typeof o)).map(o=>typeof o=="string"?mt(o):o.toString()).join("|")})$`),t._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:t}),o}}),Dd=g("$ZodLiteral",(t,e)=>{if(G.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?mt(n):n?mt(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),n}});var jd=g("$ZodTransform",(t,e)=>{G.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new or(t.constructor.name);let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new rt;return r.value=o,r.fallback=!0,r}});function Gl(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var yi=g("$ZodOptional",(t,e)=>{G.init(t,e),t._zod.optin="optional",t._zod.optout="optional",H(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),H(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Hr(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){let o=r.value,s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Gl(i,o)):Gl(s,o)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),Ld=g("$ZodExactOptional",(t,e)=>{yi.init(t,e),H(t._zod,"values",()=>e.innerType._zod.values),H(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(r,n)=>e.innerType._zod.run(r,n)}),Ud=g("$ZodNullable",(t,e)=>{G.init(t,e),H(t._zod,"optin",()=>e.innerType._zod.optin),H(t._zod,"optout",()=>e.innerType._zod.optout),H(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Hr(r.source)}|null)$`):void 0}),H(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),qd=g("$ZodDefault",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Jl(s,e)):Jl(o,e)}});function Jl(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var Zd=g("$ZodPrefault",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),Fd=g("$ZodNonOptional",(t,e)=>{G.init(t,e),H(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Yl(s,t)):Yl(o,t)}});function Yl(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var Hd=g("$ZodCatch",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"optout",()=>e.innerType._zod.optout),H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>je(i,n,Ae()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>je(s,n,Ae()))},input:r.value}),r.issues=[],r.fallback=!0),r)}});var Si=g("$ZodPipe",(t,e)=>{G.init(t,e),H(t._zod,"values",()=>e.in._zod.values),H(t._zod,"optin",()=>e.in._zod.optin),H(t._zod,"optout",()=>e.out._zod.optout),H(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=e.out._zod.run(r,n);return s instanceof Promise?s.then(i=>go(i,e.in,n)):go(s,e.in,n)}let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>go(s,e.out,n)):go(o,e.out,n)}});function go(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},r)}var Wd=g("$ZodPreprocess",(t,e)=>{Si.init(t,e)}),Vd=g("$ZodReadonly",(t,e)=>{G.init(t,e),H(t._zod,"propValues",()=>e.innerType._zod.propValues),H(t._zod,"values",()=>e.innerType._zod.values),H(t._zod,"optin",()=>e.innerType?._zod?.optin),H(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(Xl):Xl(o)}});function Xl(t){return t.value=Object.freeze(t.value),t}var Bd=g("$ZodCustom",(t,e)=>{pe.init(t,e),G.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>Ql(s,r,n,t));Ql(o,r,n,t)}});function Ql(t,e,r,n){if(!t){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),e.issues.push(cr(o))}}var Zy=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(o){return t[o]??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",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return o=>{switch(o.code){case"invalid_type":{let s=n[o.expected]??o.expected,i=ci(o.input),a=n[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${co(o.values[0])}`:`Invalid option: expected one of ${so(o.values,"|")}`;case"too_big":{let s=o.inclusive?"<=":"<",i=e(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{let s=o.inclusive?">=":">",i=e(o.origin);return i?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{let s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${so(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function Kd(){return{localeError:Zy()}}var Gd;var vi=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Fy(){return new vi}(Gd=globalThis).__zod_globalRegistry??(Gd.__zod_globalRegistry=Fy());var Ht=globalThis.__zod_globalRegistry;function Jd(t,e){return new t({type:"string",...z(e)})}function Yd(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function bi(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function Xd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function Qd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function ep(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function tp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function rp(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function np(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function op(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function sp(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function ip(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function ap(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function cp(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function up(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function lp(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function dp(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function pp(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function fp(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function mp(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function hp(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function gp(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function _p(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function yp(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(e)})}function Sp(t,e){return new t({type:"string",format:"date",check:"string_format",...z(e)})}function vp(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function bp(t,e){return new t({type:"string",format:"duration",check:"string_format",...z(e)})}function Ep(t,e){return new t({type:"number",checks:[],...z(e)})}function wp(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function kp(t,e){return new t({type:"boolean",...z(e)})}function xp(t,e){return new t({type:"null",...z(e)})}function $p(t){return new t({type:"unknown"})}function Pp(t,e){return new t({type:"never",...z(e)})}function So(t,e){return new fi({check:"less_than",...z(e),value:t,inclusive:!1})}function Jr(t,e){return new fi({check:"less_than",...z(e),value:t,inclusive:!0})}function vo(t,e){return new mi({check:"greater_than",...z(e),value:t,inclusive:!1})}function Yr(t,e){return new mi({check:"greater_than",...z(e),value:t,inclusive:!0})}function bo(t,e){return new Ol({check:"multiple_of",...z(e),value:t})}function Eo(t,e){return new Ml({check:"max_length",...z(e),maximum:t})}function ur(t,e){return new Cl({check:"min_length",...z(e),minimum:t})}function wo(t,e){return new Nl({check:"length_equals",...z(e),length:t})}function Ei(t,e){return new Dl({check:"string_format",format:"regex",...z(e),pattern:t})}function wi(t){return new jl({check:"string_format",format:"lowercase",...z(t)})}function ki(t){return new Ll({check:"string_format",format:"uppercase",...z(t)})}function xi(t,e){return new Ul({check:"string_format",format:"includes",...z(e),includes:t})}function $i(t,e){return new ql({check:"string_format",format:"starts_with",...z(e),prefix:t})}function Pi(t,e){return new Zl({check:"string_format",format:"ends_with",...z(e),suffix:t})}function zt(t){return new Fl({check:"overwrite",tx:t})}function Ti(t){return zt(e=>e.normalize(t))}function zi(){return zt(t=>t.trim())}function Ri(){return zt(t=>t.toLowerCase())}function Ii(){return zt(t=>t.toUpperCase())}function Oi(){return zt(t=>ri(t))}function Tp(t,e,r){return new t({type:"array",element:e,...z(r)})}function zp(t,e,r){let n=z(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Rp(t,e,r){return new t({type:"custom",check:"custom",fn:e,...z(r)})}function Ip(t,e){let r=Hy(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(cr(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(cr(s))}},t(n.value,n)),e);return r}function Hy(t,e){let r=new pe({check:"custom",...z(e)});return r._zod.check=t,r}function Ai(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??Ht,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function se(t,e,r={path:[],schemaPath:[]}){var n;let o=t._zod.def,s=e.seen.get(t);if(s)return s.count++,r.schemaPath.includes(t)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(t,i);let a=t._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,i.schema,l);else{let p=i.schema,f=e.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(t,e,p,l)}let d=t._zod.parent;d&&(i.ref||(i.ref=d),se(d,e,l),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(t);return c&&Object.assign(i.schema,c),e.io==="input"&&ke(t)&&(delete i.schema.examples,delete i.schema.default),e.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,e.seen.get(t).schema}function Mi(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let i of t.seen.entries()){let a=t.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=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(i[0])?.id,p=t.external.uri??(m=>m);if(d)return{ref:p(d)};let f=i[1].defId??i[1].schema.id??`schema${t.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${f}`}}if(i[1]===r)return{ref:"#"};let u=`#/${a}/`,l=i[1].schema.id??`__schema${t.counter++}`;return{defId:l,ref:u+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(t.cycles==="throw")for(let i of t.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
78
|
+
`)}f.write("payload.value = newResult;"),f.write("return payload;");let E=f.compile();return(v,$)=>E(p,v,$)},s,i=Ft,a=!sr.jitless,u=a&&si.value,l=e.catchall,d;t._zod.parse=(p,f)=>{d??(d=n.value);let m=p.value;return i(m)?a&&u&&f?.async===!1&&f.jitless!==!0?(s||(s=o(e.shape)),p=s(p,f),l?Ad([],m,p,f,d,t):p):r(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),p)}});function Gl(t,e,r,n){for(let s of t)if(s.issues.length===0)return e.value=s.value,e;let o=t.filter(s=>!Tt(s));return o.length===1?(e.value=o[0].value,o[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:r,errors:t.map(s=>s.issues.map(i=>je(i,n,Ae())))}),e)}var Si=g("$ZodUnion",(t,e)=>{G.init(t,e),H(t._zod,"optin",()=>e.options.some(n=>n._zod.optin==="optional")?"optional":void 0),H(t._zod,"optout",()=>e.options.some(n=>n._zod.optout==="optional")?"optional":void 0),H(t._zod,"values",()=>{if(e.options.every(n=>n._zod.values))return new Set(e.options.flatMap(n=>Array.from(n._zod.values)))}),H(t._zod,"pattern",()=>{if(e.options.every(n=>n._zod.pattern)){let n=e.options.map(o=>o._zod.pattern);return new RegExp(`^(${n.map(o=>Fr(o.source)).join("|")})$`)}});let r=e.options.length===1?e.options[0]._zod.run:null;t._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of e.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=>Gl(a,n,t,o)):Gl(i,n,t,o)}});var Cd=g("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,Si.init(t,e);let r=t._zod.parse;H(t._zod,"propValues",()=>{let o={};for(let s of e.options){let i=s._zod.propValues;if(!i||Object.keys(i).length===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(s)}"`);for(let[a,c]of Object.entries(i)){o[a]||(o[a]=new Set);for(let u of c)o[a].add(u)}}return o});let n=ar(()=>{let o=e.options,s=new Map;for(let i of o){let a=i._zod.propValues?.[e.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(i)}"`);for(let c of a){if(s.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);s.set(c,i)}}return s});t._zod.parse=(o,s)=>{let i=o.value;if(!Ft(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:t}),o;let a=n.value.get(i?.[e.discriminator]);return a?a._zod.run(o,s):e.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:e.discriminator,options:Array.from(n.value.keys()),input:i,path:[e.discriminator],inst:t}),o)}}),Nd=g("$ZodIntersection",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value,s=e.left._zod.run({value:o,issues:[]},n),i=e.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Jl(r,c,u)):Jl(r,s,i)}});function _i(t,e){if(t===e)return{valid:!0,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return{valid:!0,data:t};if(Pt(t)&&Pt(e)){let r=Object.keys(e),n=Object.keys(t).filter(s=>r.indexOf(s)!==-1),o={...t,...e};for(let s of n){let i=_i(t[s],e[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<t.length;n++){let o=t[n],s=e[n],i=_i(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 Jl(t,e,r){let n=new Map,o;for(let a of e.issues)if(a.code==="unrecognized_keys"){o??(o=a);for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).l=!0}else t.issues.push(a);for(let a of r.issues)if(a.code==="unrecognized_keys")for(let c of a.keys)n.has(c)||n.set(c,{}),n.get(c).r=!0;else t.issues.push(a);let s=[...n].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(s.length&&o&&t.issues.push({...o,keys:s}),Tt(t))return t;let i=_i(e.value,r.value);if(!i.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);return t.value=i.data,t}var Dd=g("$ZodRecord",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!Pt(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:t}),r;let s=[],i=e.keyType._zod.values;if(i){r.value={};let a=new Set;for(let u of i)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){a.add(typeof u=="number"?u.toString():u);let l=e.keyType._zod.run({value:u,issues:[]},n);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(f=>je(f,n,Ae())),input:u,path:[u],inst:t});continue}let d=l.value,p=e.valueType._zod.run({value:o[u],issues:[]},n);p instanceof Promise?s.push(p.then(f=>{f.issues.length&&r.issues.push(...mt(u,f.issues)),r.value[d]=f.value})):(p.issues.length&&r.issues.push(...mt(u,p.issues)),r.value[d]=p.value)}let c;for(let u in o)a.has(u)||(c=c??[],c.push(u));c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:t,keys:c})}else{r.value={};for(let a of Reflect.ownKeys(o)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,a))continue;let c=e.keyType._zod.run({value:a,issues:[]},n);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&mi.test(a)&&c.issues.length){let d=e.keyType._zod.run({value:Number(a),issues:[]},n);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");d.issues.length===0&&(c=d)}if(c.issues.length){e.mode==="loose"?r.value[a]=o[a]:r.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(d=>je(d,n,Ae())),input:a,path:[a],inst:t});continue}let l=e.valueType._zod.run({value:o[a],issues:[]},n);l instanceof Promise?s.push(l.then(d=>{d.issues.length&&r.issues.push(...mt(a,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...mt(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}});var jd=g("$ZodEnum",(t,e)=>{G.init(t,e);let r=qr(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(o=>ii.has(typeof o)).map(o=>typeof o=="string"?ft(o):o.toString()).join("|")})$`),t._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:t}),o}}),Ld=g("$ZodLiteral",(t,e)=>{if(G.init(t,e),e.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(e.values);t._zod.values=r,t._zod.pattern=new RegExp(`^(${e.values.map(n=>typeof n=="string"?ft(n):n?ft(n.toString()):String(n)).join("|")})$`),t._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:e.values,input:s,inst:t}),n}});var Ud=g("$ZodTransform",(t,e)=>{G.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new or(t.constructor.name);let o=e.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r.fallback=!0,r));if(o instanceof Promise)throw new rt;return r.value=o,r.fallback=!0,r}});function Yl(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var vi=g("$ZodOptional",(t,e)=>{G.init(t,e),t._zod.optin="optional",t._zod.optout="optional",H(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,void 0]):void 0),H(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Fr(r.source)})?$`):void 0}),t._zod.parse=(r,n)=>{if(e.innerType._zod.optin==="optional"){let o=r.value,s=e.innerType._zod.run(r,n);return s instanceof Promise?s.then(i=>Yl(i,o)):Yl(s,o)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),qd=g("$ZodExactOptional",(t,e)=>{vi.init(t,e),H(t._zod,"values",()=>e.innerType._zod.values),H(t._zod,"pattern",()=>e.innerType._zod.pattern),t._zod.parse=(r,n)=>e.innerType._zod.run(r,n)}),Zd=g("$ZodNullable",(t,e)=>{G.init(t,e),H(t._zod,"optin",()=>e.innerType._zod.optin),H(t._zod,"optout",()=>e.innerType._zod.optout),H(t._zod,"pattern",()=>{let r=e.innerType._zod.pattern;return r?new RegExp(`^(${Fr(r.source)}|null)$`):void 0}),H(t._zod,"values",()=>e.innerType._zod.values?new Set([...e.innerType._zod.values,null]):void 0),t._zod.parse=(r,n)=>r.value===null?r:e.innerType._zod.run(r,n)}),Fd=g("$ZodDefault",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);if(r.value===void 0)return r.value=e.defaultValue,r;let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Xl(s,e)):Xl(o,e)}});function Xl(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var Hd=g("$ZodPrefault",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=e.defaultValue),e.innerType._zod.run(r,n))}),Wd=g("$ZodNonOptional",(t,e)=>{G.init(t,e),H(t._zod,"values",()=>{let r=e.innerType._zod.values;return r?new Set([...r].filter(n=>n!==void 0)):void 0}),t._zod.parse=(r,n)=>{let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Ql(s,t)):Ql(o,t)}});function Ql(t,e){return!t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}var Vd=g("$ZodCatch",(t,e)=>{G.init(t,e),t._zod.optin="optional",H(t._zod,"optout",()=>e.innerType._zod.optout),H(t._zod,"values",()=>e.innerType._zod.values),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>(r.value=s.value,s.issues.length&&(r.value=e.catchValue({...r,error:{issues:s.issues.map(i=>je(i,n,Ae()))},input:r.value}),r.issues=[],r.fallback=!0),r)):(r.value=o.value,o.issues.length&&(r.value=e.catchValue({...r,error:{issues:o.issues.map(s=>je(s,n,Ae()))},input:r.value}),r.issues=[],r.fallback=!0),r)}});var bi=g("$ZodPipe",(t,e)=>{G.init(t,e),H(t._zod,"values",()=>e.in._zod.values),H(t._zod,"optin",()=>e.in._zod.optin),H(t._zod,"optout",()=>e.out._zod.optout),H(t._zod,"propValues",()=>e.in._zod.propValues),t._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=e.out._zod.run(r,n);return s instanceof Promise?s.then(i=>ho(i,e.in,n)):ho(s,e.in,n)}let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>ho(s,e.out,n)):ho(o,e.out,n)}});function ho(t,e,r){return t.issues.length?(t.aborted=!0,t):e._zod.run({value:t.value,issues:t.issues,fallback:t.fallback},r)}var Bd=g("$ZodPreprocess",(t,e)=>{bi.init(t,e)}),Kd=g("$ZodReadonly",(t,e)=>{G.init(t,e),H(t._zod,"propValues",()=>e.innerType._zod.propValues),H(t._zod,"values",()=>e.innerType._zod.values),H(t._zod,"optin",()=>e.innerType?._zod?.optin),H(t._zod,"optout",()=>e.innerType?._zod?.optout),t._zod.parse=(r,n)=>{if(n.direction==="backward")return e.innerType._zod.run(r,n);let o=e.innerType._zod.run(r,n);return o instanceof Promise?o.then(ed):ed(o)}});function ed(t){return t.value=Object.freeze(t.value),t}var Gd=g("$ZodCustom",(t,e)=>{pe.init(t,e),G.init(t,e),t._zod.parse=(r,n)=>r,t._zod.check=r=>{let n=r.value,o=e.fn(n);if(o instanceof Promise)return o.then(s=>td(s,r,n,t));td(o,r,n,t)}});function td(t,e,r,n){if(!t){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),e.issues.push(cr(o))}}var Fy=()=>{let t={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function e(o){return t[o]??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",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};return o=>{switch(o.code){case"invalid_type":{let s=n[o.expected]??o.expected,i=li(o.input),a=n[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${ao(o.values[0])}`:`Invalid option: expected one of ${oo(o.values,"|")}`;case"too_big":{let s=o.inclusive?"<=":"<",i=e(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{let s=o.inclusive?">=":">",i=e(o.origin);return i?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{let s=o;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${r[s.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${oo(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(i=>`'${i}'`).join(" | ")}`:"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function Jd(){return{localeError:Fy()}}var Yd;var Ei=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...r){let n=r[0];return this._map.set(e,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let r=this._map.get(e);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(e),this}get(e){let r=e._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(e)};return Object.keys(o).length?o:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Hy(){return new Ei}(Yd=globalThis).__zod_globalRegistry??(Yd.__zod_globalRegistry=Hy());var Ht=globalThis.__zod_globalRegistry;function Xd(t,e){return new t({type:"string",...z(e)})}function Qd(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function wi(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function ep(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function tp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function rp(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function np(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function op(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function sp(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function ip(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function ap(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function cp(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function up(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function lp(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function dp(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function pp(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function fp(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function mp(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function hp(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function gp(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function _p(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function yp(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function Sp(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function vp(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...z(e)})}function bp(t,e){return new t({type:"string",format:"date",check:"string_format",...z(e)})}function Ep(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function wp(t,e){return new t({type:"string",format:"duration",check:"string_format",...z(e)})}function kp(t,e){return new t({type:"number",checks:[],...z(e)})}function xp(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function $p(t,e){return new t({type:"boolean",...z(e)})}function Pp(t,e){return new t({type:"null",...z(e)})}function Tp(t){return new t({type:"unknown"})}function zp(t,e){return new t({type:"never",...z(e)})}function yo(t,e){return new hi({check:"less_than",...z(e),value:t,inclusive:!1})}function Gr(t,e){return new hi({check:"less_than",...z(e),value:t,inclusive:!0})}function So(t,e){return new gi({check:"greater_than",...z(e),value:t,inclusive:!1})}function Jr(t,e){return new gi({check:"greater_than",...z(e),value:t,inclusive:!0})}function vo(t,e){return new Ml({check:"multiple_of",...z(e),value:t})}function bo(t,e){return new Nl({check:"max_length",...z(e),maximum:t})}function ur(t,e){return new Dl({check:"min_length",...z(e),minimum:t})}function Eo(t,e){return new jl({check:"length_equals",...z(e),length:t})}function ki(t,e){return new Ll({check:"string_format",format:"regex",...z(e),pattern:t})}function xi(t){return new Ul({check:"string_format",format:"lowercase",...z(t)})}function $i(t){return new ql({check:"string_format",format:"uppercase",...z(t)})}function Pi(t,e){return new Zl({check:"string_format",format:"includes",...z(e),includes:t})}function Ti(t,e){return new Fl({check:"string_format",format:"starts_with",...z(e),prefix:t})}function zi(t,e){return new Hl({check:"string_format",format:"ends_with",...z(e),suffix:t})}function zt(t){return new Wl({check:"overwrite",tx:t})}function Ri(t){return zt(e=>e.normalize(t))}function Ii(){return zt(t=>t.trim())}function Oi(){return zt(t=>t.toLowerCase())}function Ai(){return zt(t=>t.toUpperCase())}function Mi(){return zt(t=>oi(t))}function Rp(t,e,r){return new t({type:"array",element:e,...z(r)})}function Ip(t,e,r){let n=z(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function Op(t,e,r){return new t({type:"custom",check:"custom",fn:e,...z(r)})}function Ap(t,e){let r=Wy(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(cr(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(cr(s))}},t(n.value,n)),e);return r}function Wy(t,e){let r=new pe({check:"custom",...z(e)});return r._zod.check=t,r}function Ci(t){let e=t?.target??"draft-2020-12";return e==="draft-4"&&(e="draft-04"),e==="draft-7"&&(e="draft-07"),{processors:t.processors??{},metadataRegistry:t?.metadata??Ht,target:e,unrepresentable:t?.unrepresentable??"throw",override:t?.override??(()=>{}),io:t?.io??"output",counter:0,seen:new Map,cycles:t?.cycles??"ref",reused:t?.reused??"inline",external:t?.external??void 0}}function se(t,e,r={path:[],schemaPath:[]}){var n;let o=t._zod.def,s=e.seen.get(t);if(s)return s.count++,r.schemaPath.includes(t)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};e.seen.set(t,i);let a=t._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,t],path:r.path};if(t._zod.processJSONSchema)t._zod.processJSONSchema(e,i.schema,l);else{let p=i.schema,f=e.processors[o.type];if(!f)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);f(t,e,p,l)}let d=t._zod.parent;d&&(i.ref||(i.ref=d),se(d,e,l),e.seen.get(d).isParent=!0)}let c=e.metadataRegistry.get(t);return c&&Object.assign(i.schema,c),e.io==="input"&&ke(t)&&(delete i.schema.examples,delete i.schema.default),e.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,e.seen.get(t).schema}function Ni(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let i of t.seen.entries()){let a=t.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=t.target==="draft-2020-12"?"$defs":"definitions";if(t.external){let d=t.external.registry.get(i[0])?.id,p=t.external.uri??(m=>m);if(d)return{ref:p(d)};let f=i[1].defId??i[1].schema.id??`schema${t.counter++}`;return i[1].defId=f,{defId:f,ref:`${p("__shared")}#/${a}/${f}`}}if(i[1]===r)return{ref:"#"};let u=`#/${a}/`,l=i[1].schema.id??`__schema${t.counter++}`;return{defId:l,ref:u+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(t.cycles==="throw")for(let i of t.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
79
79
|
|
|
80
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of t.seen.entries()){let a=i[1];if(e===i[0]){s(i);continue}if(t.external){let u=t.external.registry.get(i[0])?.id;if(e!==i[0]&&u){s(i);continue}}if(t.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&t.reused==="ref"){s(i);continue}}}function Ci(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=t.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 f=t.seen.get(d),m=f.schema;if(m.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),a._zod.parent===d)for(let S in u)S==="$ref"||S==="allOf"||S in l||delete u[S];if(m.$ref&&f.def)for(let S in u)S==="$ref"||S==="allOf"||S in f.def&&JSON.stringify(u[S])===JSON.stringify(f.def[S])&&delete u[S]}let p=a._zod.parent;if(p&&p!==d){n(p);let f=t.seen.get(p);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let m in u)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(u[m])===JSON.stringify(f.def[m])&&delete u[m]}t.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...t.seen.entries()].reverse())n(a[0]);let o={};if(t.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=t.external.uri(a)}Object.assign(o,r.def??r.schema);let s=t.metadataRegistry.get(e)?.id;s!==void 0&&o.id===s&&delete o.id;let i=t.external?.defs??{};for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:Xr(e,"input",t.processors),output:Xr(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function ke(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return ke(n.element,r);if(n.type==="set")return ke(n.valueType,r);if(n.type==="lazy")return ke(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")return ke(n.innerType,r);if(n.type==="intersection")return ke(n.left,r)||ke(n.right,r);if(n.type==="record"||n.type==="map")return ke(n.keyType,r)||ke(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:ke(n.in,r)||ke(n.out,r);if(n.type==="object"){for(let o in n.shape)if(ke(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(ke(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(ke(o,r))return!0;return!!(n.rest&&ke(n.rest,r))}return!1}var Op=(t,e={})=>r=>{let n=Ai({...r,processors:e});return se(t,n),Mi(n,t),Ci(n,t)},Xr=(t,e,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=Ai({...o??{},target:s,io:e,processors:r});return se(t,i),Mi(i,t),Ci(i,t)};var Wy={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Ap=(t,e,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=Wy[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Mp=(t,e,r,n)=>{let o=r,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=t._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";let d=typeof l=="number"&&l>=(s??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),f=e.target==="draft-04"||e.target==="openapi-3.0";d?f?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof s=="number"&&(o.minimum=s),p?f?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof c=="number"&&(o.multipleOf=c)},Cp=(t,e,r,n)=>{r.type="boolean"};var Np=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Dp=(t,e,r,n)=>{r.not={}};var jp=(t,e,r,n)=>{};var Lp=(t,e,r,n)=>{let o=t._zod.def,s=Zr(o.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},Up=(t,e,r,n)=>{let o=t._zod.def,s=[];for(let i of o.values)if(i===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");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,e.target==="draft-04"||e.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 qp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var Zp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var Fp=(t,e,r,n)=>{let o=r,s=t._zod.def,{minimum:i,maximum:a}=t._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=se(s.element,e,{...n,path:[...n.path,"items"]})},Hp=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object",o.properties={};let i=s.shape;for(let u in i)o.properties[u]=se(i[u],e,{...n,path:[...n.path,"properties",u]});let a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{let l=s.shape[u]._zod;return e.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=se(s.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(o.additionalProperties=!1)},Wp=(t,e,r,n)=>{let o=t._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>se(a,e,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},Vp=(t,e,r,n)=>{let o=t._zod.def,s=se(o.left,e,{...n,path:[...n.path,"allOf",0]}),i=se(o.right,e,{...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};var Bp=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object";let i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){let l=se(s.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=l}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(o.propertyNames=se(s.keyType,e,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=se(s.valueType,e,{...n,path:[...n.path,"additionalProperties"]});let u=i._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},Kp=(t,e,r,n)=>{let o=t._zod.def,s=se(o.innerType,e,n),i=e.seen.get(t);e.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},Gp=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType},Jp=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Yp=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},Xp=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},Qp=(t,e,r,n)=>{let o=t._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?s?o.out:o.in:o.out;se(i,e,n);let a=e.seen.get(t);a.ref=i},ef=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.readOnly=!0};var Ni=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType};function lr(t){return!!t._zod}function Rt(t,e){return lr(t)?Br(t,e):t.safeParse(e)}function ko(t){if(!t)return;let e;if(lr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function tf(t){if(lr(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var en={};Au(en,{ZodISODate:()=>nf,ZodISODateTime:()=>rf,ZodISODuration:()=>sf,ZodISOTime:()=>of,date:()=>ji,datetime:()=>Di,duration:()=>Ui,time:()=>Li});var rf=g("ZodISODateTime",(t,e)=>{dd.init(t,e),te.init(t,e)});function Di(t){return yp(rf,t)}var nf=g("ZodISODate",(t,e)=>{pd.init(t,e),te.init(t,e)});function ji(t){return Sp(nf,t)}var of=g("ZodISOTime",(t,e)=>{fd.init(t,e),te.init(t,e)});function Li(t){return vp(of,t)}var sf=g("ZodISODuration",(t,e)=>{md.init(t,e),te.init(t,e)});function Ui(t){return bp(sf,t)}var eS=(t,e)=>{uo.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Ku(t,r)},flatten:{value:r=>Bu(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,ir,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,ir,2)}},isEmpty:{get(){return t.issues.length===0}}})};var Me=g("ZodError",eS,{Parent:Error});var af=lo(Me),cf=po(Me),uf=Vr(Me),lf=Kr(Me),df=Gu(Me),pf=Ju(Me),ff=Yu(Me),mf=Xu(Me),hf=Qu(Me),gf=el(Me),_f=tl(Me),yf=rl(Me);var Sf=new WeakMap;function tn(t,e,r){let n=Object.getPrototypeOf(t),o=Sf.get(n);if(o||(o=new Set,Sf.set(n,o)),!o.has(e)){o.add(e);for(let s in r){let i=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var oe=g("ZodType",(t,e)=>(G.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:Xr(t,"input"),output:Xr(t,"output")}}),t.toJSONSchema=Op(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>af(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>uf(t,r,n),t.parseAsync=async(r,n)=>cf(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>lf(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>df(t,r,n),t.decode=(r,n)=>pf(t,r,n),t.encodeAsync=async(r,n)=>ff(t,r,n),t.decodeAsync=async(r,n)=>mf(t,r,n),t.safeEncode=(r,n)=>hf(t,r,n),t.safeDecode=(r,n)=>gf(t,r,n),t.safeEncodeAsync=async(r,n)=>_f(t,r,n),t.safeDecodeAsync=async(r,n)=>yf(t,r,n),tn(t,"ZodType",{check(...r){let n=this.def;return this.clone(U.mergeDefs(n,{checks:[...n.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return Ge(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(HS(r,n))},superRefine(r,n){return this.check(WS(r,n))},overwrite(r){return this.check(zt(r))},optional(){return ne(this)},exactOptional(){return OS(this)},nullable(){return wf(this)},nullish(){return ne(wf(this))},nonoptional(r){return jS(this,r)},array(){return D(this)},or(r){return Y([this,r])},and(r){return $o(this,r)},transform(r){return kf(this,Rf(r))},default(r){return CS(this,r)},prefault(r){return DS(this,r)},catch(r){return US(this,r)},pipe(r){return kf(this,r)},readonly(){return FS(this)},describe(r){let n=this.clone();return Ht.add(n,{description:r}),n},meta(...r){if(r.length===0)return Ht.get(this);let n=this.clone();return Ht.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(t,"description",{get(){return Ht.get(t)?.description},configurable:!0}),t)),xf=g("_ZodString",(t,e)=>{yo.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Ap(t,n,o,s);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,tn(t,"_ZodString",{regex(...n){return this.check(Ei(...n))},includes(...n){return this.check(xi(...n))},startsWith(...n){return this.check($i(...n))},endsWith(...n){return this.check(Pi(...n))},min(...n){return this.check(ur(...n))},max(...n){return this.check(Eo(...n))},length(...n){return this.check(wo(...n))},nonempty(...n){return this.check(ur(1,...n))},lowercase(n){return this.check(wi(n))},uppercase(n){return this.check(ki(n))},trim(){return this.check(zi())},normalize(...n){return this.check(Ti(...n))},toLowerCase(){return this.check(Ri())},toUpperCase(){return this.check(Ii())},slugify(){return this.check(Oi())}})}),rS=g("ZodString",(t,e)=>{yo.init(t,e),xf.init(t,e),t.email=r=>t.check(Yd(nS,r)),t.url=r=>t.check(rp(oS,r)),t.jwt=r=>t.check(_p(SS,r)),t.emoji=r=>t.check(np(sS,r)),t.guid=r=>t.check(bi(vf,r)),t.uuid=r=>t.check(Xd(xo,r)),t.uuidv4=r=>t.check(Qd(xo,r)),t.uuidv6=r=>t.check(ep(xo,r)),t.uuidv7=r=>t.check(tp(xo,r)),t.nanoid=r=>t.check(op(iS,r)),t.guid=r=>t.check(bi(vf,r)),t.cuid=r=>t.check(sp(aS,r)),t.cuid2=r=>t.check(ip(cS,r)),t.ulid=r=>t.check(ap(uS,r)),t.base64=r=>t.check(mp(gS,r)),t.base64url=r=>t.check(hp(_S,r)),t.xid=r=>t.check(cp(lS,r)),t.ksuid=r=>t.check(up(dS,r)),t.ipv4=r=>t.check(lp(pS,r)),t.ipv6=r=>t.check(dp(fS,r)),t.cidrv4=r=>t.check(pp(mS,r)),t.cidrv6=r=>t.check(fp(hS,r)),t.e164=r=>t.check(gp(yS,r)),t.datetime=r=>t.check(Di(r)),t.date=r=>t.check(ji(r)),t.time=r=>t.check(Li(r)),t.duration=r=>t.check(Ui(r))});function h(t){return Jd(rS,t)}var te=g("ZodStringFormat",(t,e)=>{J.init(t,e),xf.init(t,e)}),nS=g("ZodEmail",(t,e)=>{rd.init(t,e),te.init(t,e)});var vf=g("ZodGUID",(t,e)=>{ed.init(t,e),te.init(t,e)});var xo=g("ZodUUID",(t,e)=>{td.init(t,e),te.init(t,e)});var oS=g("ZodURL",(t,e)=>{nd.init(t,e),te.init(t,e)});var sS=g("ZodEmoji",(t,e)=>{od.init(t,e),te.init(t,e)});var iS=g("ZodNanoID",(t,e)=>{sd.init(t,e),te.init(t,e)});var aS=g("ZodCUID",(t,e)=>{id.init(t,e),te.init(t,e)});var cS=g("ZodCUID2",(t,e)=>{ad.init(t,e),te.init(t,e)});var uS=g("ZodULID",(t,e)=>{cd.init(t,e),te.init(t,e)});var lS=g("ZodXID",(t,e)=>{ud.init(t,e),te.init(t,e)});var dS=g("ZodKSUID",(t,e)=>{ld.init(t,e),te.init(t,e)});var pS=g("ZodIPv4",(t,e)=>{hd.init(t,e),te.init(t,e)});var fS=g("ZodIPv6",(t,e)=>{gd.init(t,e),te.init(t,e)});var mS=g("ZodCIDRv4",(t,e)=>{_d.init(t,e),te.init(t,e)});var hS=g("ZodCIDRv6",(t,e)=>{yd.init(t,e),te.init(t,e)});var gS=g("ZodBase64",(t,e)=>{vd.init(t,e),te.init(t,e)});var _S=g("ZodBase64URL",(t,e)=>{bd.init(t,e),te.init(t,e)});var yS=g("ZodE164",(t,e)=>{Ed.init(t,e),te.init(t,e)});var SS=g("ZodJWT",(t,e)=>{wd.init(t,e),te.init(t,e)});var $f=g("ZodNumber",(t,e)=>{gi.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Mp(t,n,o,s),tn(t,"ZodNumber",{gt(n,o){return this.check(vo(n,o))},gte(n,o){return this.check(Yr(n,o))},min(n,o){return this.check(Yr(n,o))},lt(n,o){return this.check(So(n,o))},lte(n,o){return this.check(Jr(n,o))},max(n,o){return this.check(Jr(n,o))},int(n){return this.check(bf(n))},safe(n){return this.check(bf(n))},positive(n){return this.check(vo(0,n))},nonnegative(n){return this.check(Yr(0,n))},negative(n){return this.check(So(0,n))},nonpositive(n){return this.check(Jr(0,n))},multipleOf(n,o){return this.check(bo(n,o))},step(n,o){return this.check(bo(n,o))},finite(){return this}});let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function W(t){return Ep($f,t)}var vS=g("ZodNumberFormat",(t,e)=>{kd.init(t,e),$f.init(t,e)});function bf(t){return wp(vS,t)}var bS=g("ZodBoolean",(t,e)=>{xd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Cp(t,r,n,o)});function de(t){return kp(bS,t)}var ES=g("ZodNull",(t,e)=>{$d.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Np(t,r,n,o)});function Pf(t){return xp(ES,t)}var wS=g("ZodUnknown",(t,e)=>{Pd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>jp(t,r,n,o)});function re(){return $p(wS)}var kS=g("ZodNever",(t,e)=>{Td.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Dp(t,r,n,o)});function xS(t){return Pp(kS,t)}var $S=g("ZodArray",(t,e)=>{zd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Fp(t,r,n,o),t.element=e.element,tn(t,"ZodArray",{min(r,n){return this.check(ur(r,n))},nonempty(r){return this.check(ur(1,r))},max(r,n){return this.check(Eo(r,n))},length(r,n){return this.check(wo(r,n))},unwrap(){return this.element}})});function D(t,e){return Tp($S,t,e)}var Tf=g("ZodObject",(t,e)=>{Od.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Hp(t,r,n,o),U.defineLazy(t,"shape",()=>e.shape),tn(t,"ZodObject",{keyof(){return Te(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:re()})},loose(){return this.clone({...this._zod.def,catchall:re()})},strict(){return this.clone({...this._zod.def,catchall:xS()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return U.extend(this,r)},safeExtend(r){return U.safeExtend(this,r)},merge(r){return U.merge(this,r)},pick(r){return U.pick(this,r)},omit(r){return U.omit(this,r)},partial(...r){return U.partial(If,this,r[0])},required(...r){return U.required(Of,this,r[0])}})});function k(t,e){let r={type:"object",shape:t??{},...U.normalizeParams(e)};return new Tf(r)}function xe(t,e){return new Tf({type:"object",shape:t,catchall:re(),...U.normalizeParams(e)})}var zf=g("ZodUnion",(t,e)=>{_i.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Wp(t,r,n,o),t.options=e.options});function Y(t,e){return new zf({type:"union",options:t,...U.normalizeParams(e)})}var PS=g("ZodDiscriminatedUnion",(t,e)=>{zf.init(t,e),Ad.init(t,e)});function Zi(t,e,r){return new PS({type:"union",options:e,discriminator:t,...U.normalizeParams(r)})}var TS=g("ZodIntersection",(t,e)=>{Md.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Vp(t,r,n,o)});function $o(t,e){return new TS({type:"intersection",left:t,right:e})}var Ef=g("ZodRecord",(t,e)=>{Cd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Bp(t,r,n,o),t.keyType=e.keyType,t.valueType=e.valueType});function K(t,e,r){return!e||!e._zod?new Ef({type:"record",keyType:h(),valueType:t,...U.normalizeParams(e)}):new Ef({type:"record",keyType:t,valueType:e,...U.normalizeParams(r)})}var qi=g("ZodEnum",(t,e)=>{Nd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Lp(t,n,o,s),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new qi({...e,checks:[],...U.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new qi({...e,checks:[],...U.normalizeParams(o),entries:s})}});function Te(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new qi({type:"enum",entries:r,...U.normalizeParams(e)})}var zS=g("ZodLiteral",(t,e)=>{Dd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Up(t,r,n,o),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function P(t,e){return new zS({type:"literal",values:Array.isArray(t)?t:[t],...U.normalizeParams(e)})}var RS=g("ZodTransform",(t,e)=>{jd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Zp(t,r,n,o),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new or(t.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(U.issue(s,r.value,e));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),r.issues.push(U.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=o,r.fallback=!0,r)}});function Rf(t){return new RS({type:"transform",transform:t})}var If=g("ZodOptional",(t,e)=>{yi.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ni(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function ne(t){return new If({type:"optional",innerType:t})}var IS=g("ZodExactOptional",(t,e)=>{Ld.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ni(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function OS(t){return new IS({type:"optional",innerType:t})}var AS=g("ZodNullable",(t,e)=>{Ud.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Kp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function wf(t){return new AS({type:"nullable",innerType:t})}var MS=g("ZodDefault",(t,e)=>{qd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Jp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function CS(t,e){return new MS({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():U.shallowClone(e)}})}var NS=g("ZodPrefault",(t,e)=>{Zd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Yp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function DS(t,e){return new NS({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():U.shallowClone(e)}})}var Of=g("ZodNonOptional",(t,e)=>{Fd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Gp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function jS(t,e){return new Of({type:"nonoptional",innerType:t,...U.normalizeParams(e)})}var LS=g("ZodCatch",(t,e)=>{Hd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Xp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function US(t,e){return new LS({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Af=g("ZodPipe",(t,e)=>{Si.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Qp(t,r,n,o),t.in=e.in,t.out=e.out});function kf(t,e){return new Af({type:"pipe",in:t,out:e})}var qS=g("ZodPreprocess",(t,e)=>{Af.init(t,e),Wd.init(t,e)}),ZS=g("ZodReadonly",(t,e)=>{Vd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ef(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function FS(t){return new ZS({type:"readonly",innerType:t})}var Mf=g("ZodCustom",(t,e)=>{Bd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>qp(t,r,n,o)});function Cf(t,e){return zp(Mf,t??(()=>!0),e)}function HS(t,e={}){return Rp(Mf,t,e)}function WS(t,e){return Ip(t,e)}function Fi(t,e){return new qS({type:"pipe",in:Rf(t),out:e})}Ae(Kd());var Wi="2025-11-25";var Nf=[Wi,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],It="io.modelcontextprotocol/related-task",To="2.0",le=Cf(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Df=Y([h(),W().int()]),jf=h(),pR=xe({ttl:W().optional(),pollInterval:W().optional()}),VS=k({ttl:W().optional()}),BS=k({taskId:h()}),Vi=xe({progressToken:Df.optional(),[It]:BS.optional()}),Ce=k({_meta:Vi.optional()}),rn=Ce.extend({task:VS.optional()}),Lf=t=>rn.safeParse(t).success,fe=k({method:h(),params:Ce.loose().optional()}),Le=k({_meta:Vi.optional()}),Ue=k({method:h(),params:Le.loose().optional()}),me=xe({_meta:Vi.optional()}),zo=Y([h(),W().int()]),Uf=k({jsonrpc:P(To),id:zo,...fe.shape}).strict(),Bi=t=>Uf.safeParse(t).success,qf=k({jsonrpc:P(To),...Ue.shape}).strict(),Zf=t=>qf.safeParse(t).success,Ki=k({jsonrpc:P(To),id:zo,result:me}).strict(),nn=t=>Ki.safeParse(t).success;var N;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(N||(N={}));var Gi=k({jsonrpc:P(To),id:zo.optional(),error:k({code:W().int(),message:h(),data:re().optional()})}).strict();var Ff=t=>Gi.safeParse(t).success;var Hf=Y([Uf,qf,Ki,Gi]),fR=Y([Ki,Gi]),Ro=me.strict(),KS=Le.extend({requestId:zo.optional(),reason:h().optional()}),Io=Ue.extend({method:P("notifications/cancelled"),params:KS}),GS=k({src:h(),mimeType:h().optional(),sizes:D(h()).optional(),theme:Te(["light","dark"]).optional()}),on=k({icons:D(GS).optional()}),dr=k({name:h(),title:h().optional()}),Wf=dr.extend({...dr.shape,...on.shape,version:h(),websiteUrl:h().optional(),description:h().optional()}),JS=$o(k({applyDefaults:de().optional()}),K(h(),re())),YS=Fi(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,$o(k({form:JS.optional(),url:le.optional()}),K(h(),re()).optional())),XS=xe({list:le.optional(),cancel:le.optional(),requests:xe({sampling:xe({createMessage:le.optional()}).optional(),elicitation:xe({create:le.optional()}).optional()}).optional()}),QS=xe({list:le.optional(),cancel:le.optional(),requests:xe({tools:xe({call:le.optional()}).optional()}).optional()}),ev=k({experimental:K(h(),le).optional(),sampling:k({context:le.optional(),tools:le.optional()}).optional(),elicitation:YS.optional(),roots:k({listChanged:de().optional()}).optional(),tasks:XS.optional(),extensions:K(h(),le).optional()}),tv=Ce.extend({protocolVersion:h(),capabilities:ev,clientInfo:Wf}),Ji=fe.extend({method:P("initialize"),params:tv});var rv=k({experimental:K(h(),le).optional(),logging:le.optional(),completions:le.optional(),prompts:k({listChanged:de().optional()}).optional(),resources:k({subscribe:de().optional(),listChanged:de().optional()}).optional(),tools:k({listChanged:de().optional()}).optional(),tasks:QS.optional(),extensions:K(h(),le).optional()}),nv=me.extend({protocolVersion:h(),capabilities:rv,serverInfo:Wf,instructions:h().optional()}),Yi=Ue.extend({method:P("notifications/initialized"),params:Le.optional()});var Oo=fe.extend({method:P("ping"),params:Ce.optional()}),ov=k({progress:W(),total:ne(W()),message:ne(h())}),sv=k({...Le.shape,...ov.shape,progressToken:Df}),Ao=Ue.extend({method:P("notifications/progress"),params:sv}),iv=Ce.extend({cursor:jf.optional()}),sn=fe.extend({params:iv.optional()}),an=me.extend({nextCursor:jf.optional()}),av=Te(["working","input_required","completed","failed","cancelled"]),cn=k({taskId:h(),status:av,ttl:Y([W(),Pf()]),createdAt:h(),lastUpdatedAt:h(),pollInterval:ne(W()),statusMessage:ne(h())}),pr=me.extend({task:cn}),cv=Le.merge(cn),un=Ue.extend({method:P("notifications/tasks/status"),params:cv}),Mo=fe.extend({method:P("tasks/get"),params:Ce.extend({taskId:h()})}),Co=me.merge(cn),No=fe.extend({method:P("tasks/result"),params:Ce.extend({taskId:h()})}),mR=me.loose(),Do=sn.extend({method:P("tasks/list")}),jo=an.extend({tasks:D(cn)}),Lo=fe.extend({method:P("tasks/cancel"),params:Ce.extend({taskId:h()})}),Vf=me.merge(cn),Bf=k({uri:h(),mimeType:ne(h()),_meta:K(h(),re()).optional()}),Kf=Bf.extend({text:h()}),Xi=h().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Gf=Bf.extend({blob:Xi}),ln=Te(["user","assistant"]),fr=k({audience:D(ln).optional(),priority:W().min(0).max(1).optional(),lastModified:en.datetime({offset:!0}).optional()}),Jf=k({...dr.shape,...on.shape,uri:h(),description:ne(h()),mimeType:ne(h()),size:ne(W()),annotations:fr.optional(),_meta:ne(xe({}))}),uv=k({...dr.shape,...on.shape,uriTemplate:h(),description:ne(h()),mimeType:ne(h()),annotations:fr.optional(),_meta:ne(xe({}))}),lv=sn.extend({method:P("resources/list")}),dv=an.extend({resources:D(Jf)}),pv=sn.extend({method:P("resources/templates/list")}),fv=an.extend({resourceTemplates:D(uv)}),Qi=Ce.extend({uri:h()}),mv=Qi,hv=fe.extend({method:P("resources/read"),params:mv}),gv=me.extend({contents:D(Y([Kf,Gf]))}),_v=Ue.extend({method:P("notifications/resources/list_changed"),params:Le.optional()}),yv=Qi,Sv=fe.extend({method:P("resources/subscribe"),params:yv}),vv=Qi,bv=fe.extend({method:P("resources/unsubscribe"),params:vv}),Ev=Le.extend({uri:h()}),wv=Ue.extend({method:P("notifications/resources/updated"),params:Ev}),kv=k({name:h(),description:ne(h()),required:ne(de())}),xv=k({...dr.shape,...on.shape,description:ne(h()),arguments:ne(D(kv)),_meta:ne(xe({}))}),$v=sn.extend({method:P("prompts/list")}),Pv=an.extend({prompts:D(xv)}),Tv=Ce.extend({name:h(),arguments:K(h(),h()).optional()}),zv=fe.extend({method:P("prompts/get"),params:Tv}),ea=k({type:P("text"),text:h(),annotations:fr.optional(),_meta:K(h(),re()).optional()}),ta=k({type:P("image"),data:Xi,mimeType:h(),annotations:fr.optional(),_meta:K(h(),re()).optional()}),ra=k({type:P("audio"),data:Xi,mimeType:h(),annotations:fr.optional(),_meta:K(h(),re()).optional()}),Rv=k({type:P("tool_use"),name:h(),id:h(),input:K(h(),re()),_meta:K(h(),re()).optional()}),Iv=k({type:P("resource"),resource:Y([Kf,Gf]),annotations:fr.optional(),_meta:K(h(),re()).optional()}),Ov=Jf.extend({type:P("resource_link")}),na=Y([ea,ta,ra,Ov,Iv]),Av=k({role:ln,content:na}),Mv=me.extend({description:h().optional(),messages:D(Av)}),Cv=Ue.extend({method:P("notifications/prompts/list_changed"),params:Le.optional()}),Nv=k({title:h().optional(),readOnlyHint:de().optional(),destructiveHint:de().optional(),idempotentHint:de().optional(),openWorldHint:de().optional()}),Dv=k({taskSupport:Te(["required","optional","forbidden"]).optional()}),Yf=k({...dr.shape,...on.shape,description:h().optional(),inputSchema:k({type:P("object"),properties:K(h(),le).optional(),required:D(h()).optional()}).catchall(re()),outputSchema:k({type:P("object"),properties:K(h(),le).optional(),required:D(h()).optional()}).catchall(re()).optional(),annotations:Nv.optional(),execution:Dv.optional(),_meta:K(h(),re()).optional()}),oa=sn.extend({method:P("tools/list")}),jv=an.extend({tools:D(Yf)}),Uo=me.extend({content:D(na).default([]),structuredContent:K(h(),re()).optional(),isError:de().optional()}),hR=Uo.or(me.extend({toolResult:re()})),Lv=rn.extend({name:h(),arguments:K(h(),re()).optional()}),dn=fe.extend({method:P("tools/call"),params:Lv}),Uv=Ue.extend({method:P("notifications/tools/list_changed"),params:Le.optional()}),gR=k({autoRefresh:de().default(!0),debounceMs:W().int().nonnegative().default(300)}),pn=Te(["debug","info","notice","warning","error","critical","alert","emergency"]),qv=Ce.extend({level:pn}),sa=fe.extend({method:P("logging/setLevel"),params:qv}),Zv=Le.extend({level:pn,logger:h().optional(),data:re()}),Fv=Ue.extend({method:P("notifications/message"),params:Zv}),Hv=k({name:h().optional()}),Wv=k({hints:D(Hv).optional(),costPriority:W().min(0).max(1).optional(),speedPriority:W().min(0).max(1).optional(),intelligencePriority:W().min(0).max(1).optional()}),Vv=k({mode:Te(["auto","required","none"]).optional()}),Bv=k({type:P("tool_result"),toolUseId:h().describe("The unique identifier for the corresponding tool call."),content:D(na).default([]),structuredContent:k({}).loose().optional(),isError:de().optional(),_meta:K(h(),re()).optional()}),Kv=Zi("type",[ea,ta,ra]),Po=Zi("type",[ea,ta,ra,Rv,Bv]),Gv=k({role:ln,content:Y([Po,D(Po)]),_meta:K(h(),re()).optional()}),Jv=rn.extend({messages:D(Gv),modelPreferences:Wv.optional(),systemPrompt:h().optional(),includeContext:Te(["none","thisServer","allServers"]).optional(),temperature:W().optional(),maxTokens:W().int(),stopSequences:D(h()).optional(),metadata:le.optional(),tools:D(Yf).optional(),toolChoice:Vv.optional()}),Yv=fe.extend({method:P("sampling/createMessage"),params:Jv}),fn=me.extend({model:h(),stopReason:ne(Te(["endTurn","stopSequence","maxTokens"]).or(h())),role:ln,content:Kv}),ia=me.extend({model:h(),stopReason:ne(Te(["endTurn","stopSequence","maxTokens","toolUse"]).or(h())),role:ln,content:Y([Po,D(Po)])}),Xv=k({type:P("boolean"),title:h().optional(),description:h().optional(),default:de().optional()}),Qv=k({type:P("string"),title:h().optional(),description:h().optional(),minLength:W().optional(),maxLength:W().optional(),format:Te(["email","uri","date","date-time"]).optional(),default:h().optional()}),eb=k({type:Te(["number","integer"]),title:h().optional(),description:h().optional(),minimum:W().optional(),maximum:W().optional(),default:W().optional()}),tb=k({type:P("string"),title:h().optional(),description:h().optional(),enum:D(h()),default:h().optional()}),rb=k({type:P("string"),title:h().optional(),description:h().optional(),oneOf:D(k({const:h(),title:h()})),default:h().optional()}),nb=k({type:P("string"),title:h().optional(),description:h().optional(),enum:D(h()),enumNames:D(h()).optional(),default:h().optional()}),ob=Y([tb,rb]),sb=k({type:P("array"),title:h().optional(),description:h().optional(),minItems:W().optional(),maxItems:W().optional(),items:k({type:P("string"),enum:D(h())}),default:D(h()).optional()}),ib=k({type:P("array"),title:h().optional(),description:h().optional(),minItems:W().optional(),maxItems:W().optional(),items:k({anyOf:D(k({const:h(),title:h()}))}),default:D(h()).optional()}),ab=Y([sb,ib]),cb=Y([nb,ob,ab]),ub=Y([cb,Xv,Qv,eb]),lb=rn.extend({mode:P("form").optional(),message:h(),requestedSchema:k({type:P("object"),properties:K(h(),ub),required:D(h()).optional()})}),db=rn.extend({mode:P("url"),message:h(),elicitationId:h(),url:h().url()}),pb=Y([lb,db]),fb=fe.extend({method:P("elicitation/create"),params:pb}),mb=Le.extend({elicitationId:h()}),hb=Ue.extend({method:P("notifications/elicitation/complete"),params:mb}),mr=me.extend({action:Te(["accept","decline","cancel"]),content:Fi(t=>t===null?void 0:t,K(h(),Y([h(),W(),de(),D(h())])).optional())}),gb=k({type:P("ref/resource"),uri:h()});var _b=k({type:P("ref/prompt"),name:h()}),yb=Ce.extend({ref:Y([_b,gb]),argument:k({name:h(),value:h()}),context:k({arguments:K(h(),h()).optional()}).optional()}),Sb=fe.extend({method:P("completion/complete"),params:yb});var vb=me.extend({completion:xe({values:D(h()).max(100),total:ne(W().int()),hasMore:ne(de())})}),bb=k({uri:h().startsWith("file://"),name:h().optional(),_meta:K(h(),re()).optional()}),Eb=fe.extend({method:P("roots/list"),params:Ce.optional()}),aa=me.extend({roots:D(bb)}),wb=Ue.extend({method:P("notifications/roots/list_changed"),params:Le.optional()}),_R=Y([Oo,Ji,Sb,sa,zv,$v,lv,pv,hv,Sv,bv,dn,oa,Mo,No,Do,Lo]),yR=Y([Io,Ao,Yi,wb,un]),SR=Y([Ro,fn,ia,mr,aa,Co,jo,pr]),vR=Y([Oo,Yv,fb,Eb,Mo,No,Do,Lo]),bR=Y([Io,Ao,Fv,wv,_v,Uv,Cv,un,hb]),ER=Y([Ro,nv,vb,Mv,Pv,dv,fv,gv,Uo,jv,Co,jo,pr]),I=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===N.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Hi(o.elicitations,r)}return new t(e,r,n)}},Hi=class extends I{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(N.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Ot(t){return t==="completed"||t==="failed"||t==="cancelled"}var tI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ca(t){let r=ko(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=tf(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function ua(t,e){let r=Rt(t,e);if(!r.success)throw r.error;return r.data}var zb=6e4,qo=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Io,r=>{this._oncancel(r)}),this.setNotificationHandler(Ao,r=>{this._onprogress(r)}),this.setRequestHandler(Oo,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Mo,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(N.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(No,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new I(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new I(N.InvalidParams,`Task not found: ${s}`);if(!Ot(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Ot(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[It]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Do,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 I(N.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Lo,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(N.InvalidParams,`Task not found: ${r.params.taskId}`);if(Ot(o.status))throw new I(N.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new I(N.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof I?o:new I(N.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),I.fromError(N.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),nn(s)||Ff(s)?this._onresponse(s):Bi(s)?this._onrequest(s,i):Zf(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=I.fromError(N.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[It]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:N.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=Lf(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new I(N.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:e.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});let m=f.relatedTask?.taskId??s;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:N.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),nn(e))n(e);else{let i=new I(e.error.code,e.error.message,e.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(nn(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),nn(e))o(e);else{let i=I.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof I?i:new I(N.InternalError,String(i))}}return}let s;try{let i=await this.request(e,pr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new I(N.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Ot(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new I(N.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new I(N.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 I?i:new I(N.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=E=>{l(E)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(E){d(E);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[It]:c}});let m=E=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(E)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`)));let v=E instanceof I?E:new I(N.RequestTimeout,String(E));l(v)};this._responseHandlers.set(p,E=>{if(!n?.signal?.aborted){if(E instanceof Error)return l(E);try{let v=Rt(r,E.result);v.success?u(v.data):l(v.error)}catch(v){l(v)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let _=n?.timeout??zb,S=()=>m(I.fromError(N.RequestTimeout,"Request timed out",{timeout:_}));this._setupTimeout(p,_,n?.maxTotalTimeout,S,n?.resetTimeoutOnProgress??!1);let b=c?.taskId;if(b){let E=v=>{let $=this._responseHandlers.get(p);$?$(v):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,E),this._enqueueTaskMessage(b,{type:"request",message:f,timestamp:Date.now()}).catch(v=>{this._cleanupTimeout(p),l(v)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(E=>{this._cleanupTimeout(p),l(E)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Co,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},jo,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Vf,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[It]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[It]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[It]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=ca(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=ua(e,o);return Promise.resolve(r(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=ca(e);this._notificationHandlers.set(n,o=>{let s=ua(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&Bi(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new I(N.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new I(N.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new I(N.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new I(N.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=un.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Ot(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 I(N.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Ot(a.status))throw new I(N.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=un.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Ot(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function Xf(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Qf(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];Xf(i)&&Xf(s)?r[o]={...i,...s}:r[o]=s}return r}var Lg=xt(Kc(),1),Ug=xt(jg(),1);function S$(){let t=new Lg.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Ug.default)(t),t}var ks=class{constructor(e){this._ajv=e??S$()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var xs=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},fn,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:s},mr,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function qg(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function Zg(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var $s=class extends qo{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(pn.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 ks,this.setRequestHandler(Ji,n=>this._oninitialize(n)),this.setNotificationHandler(Yi,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(sa,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=pn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new xs(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Qf(this._capabilities,e)}setRequestHandler(e,r){let o=ko(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(lr(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Rt(dn,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new I(N.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let m=Rt(pr,p);if(!m.success){let _=m.error instanceof Error?m.error.message:String(m.error);throw new I(N.InvalidParams,`Invalid task creation result: ${_}`)}return m.data}let f=Rt(Uo,p);if(!f.success){let m=f.error instanceof Error?f.error.message:String(f.error);throw new I(N.InvalidParams,`Invalid tools/call result: ${m}`)}return f.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){Zg(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&qg(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Nf.includes(r)?r:Wi,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"},Ro)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},ia,r):this.request({method:"sampling/createMessage",params:e},fn,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=e;return this.request({method:"elicitation/create",params:o},mr,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:o},mr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new I(N.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof I?i:new I(N.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},aa,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var ru=xt(require("node:process"),1);var Ps=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
81
|
-
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),
|
|
82
|
-
`}var Ts=class{constructor(e=ru.default.stdin,r=ru.default.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new Ps,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=Fg(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Ls=xt(require("path"),1),Mr=require("fs");var Hg=require("node:child_process");function zs(t,e,r){return(0,Hg.spawn)(t,e??[],{windowsHide:!0,...r})}var ae={DEFAULT:3e5,HEALTH_CHECK:3e3,API_REQUEST:3e4,HOOK_READINESS_WAIT:1e4,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,WORKER_STARTUP_WAIT:1e3,PRE_RESTART_SETTLE_DELAY:2e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5};function Et(t){return process.platform==="win32"?Math.round(t*ae.WINDOWS_MULTIPLIER):t}var ut=require("fs"),Hn=require("path"),nu=require("os");var wt=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5-20251001",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:String(37700+(process.getuid?.()??77)%100),CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_API_TIMEOUT_MS:String(Et(ae.API_REQUEST)),CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"subscription",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-2.5-flash-lite",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_GEMINI_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_GEMINI_MAX_TOKENS:"100000",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_BASE_URL:"",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_OPENROUTER_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_OPENROUTER_MAX_TOKENS:"100000",CLAUDE_MEM_DATA_DIR:(0,Hn.join)((0,nu.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_WELCOME_HINT_ENABLED:"true",CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED:"false",CLAUDE_MEM_FOLDER_USE_LOCAL_MD:"false",CLAUDE_MEM_TRANSCRIPTS_ENABLED:"true",CLAUDE_MEM_TRANSCRIPTS_CONFIG_PATH:(0,Hn.join)((0,nu.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_FOLDER_MD_SKELETON_DENYLIST:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_TIER_FAST_MODEL:"haiku",CLAUDE_MEM_TIER_SMART_MODEL:"sonnet",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_CHROMA_MODE:"local",CLAUDE_MEM_CHROMA_HOST:"127.0.0.1",CLAUDE_MEM_CHROMA_PORT:"8000",CLAUDE_MEM_CHROMA_SSL:"false",CLAUDE_MEM_CHROMA_API_KEY:"",CLAUDE_MEM_CHROMA_TENANT:"default_tenant",CLAUDE_MEM_CHROMA_DATABASE:"default_database",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_QUEUE_ENGINE:"sqlite",CLAUDE_MEM_REDIS_URL:"",CLAUDE_MEM_REDIS_HOST:"127.0.0.1",CLAUDE_MEM_REDIS_PORT:"6379",CLAUDE_MEM_REDIS_MODE:"external",CLAUDE_MEM_QUEUE_REDIS_PREFIX:`claude_mem_${process.env.CLAUDE_MEM_WORKER_PORT??String(37700+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_AUTH_MODE:"api-key",CLAUDE_MEM_RUNTIME:"worker",CLAUDE_MEM_SERVER_BETA_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_BETA_API_KEY:"",CLAUDE_MEM_SERVER_BETA_PROJECT_ID:""};static getAllDefaults(){return{...this.DEFAULTS}}static get(e){return process.env[e]??this.DEFAULTS[e]}static getInt(e){let r=this.get(e);return parseInt(r,10)}static getBool(e){let r=this.get(e);return r==="true"||r===!0}static applyEnvOverrides(e){let r={...e};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(e,r=!0){try{if(!(0,ut.existsSync)(e)){let a=this.getAllDefaults();try{let c=(0,Hn.dirname)(e);(0,ut.existsSync)(c)||(0,ut.mkdirSync)(c,{recursive:!0}),(0,ut.writeFileSync)(e,JSON.stringify(a,null,2),"utf-8"),console.warn("[SETTINGS] Created settings file with defaults:",e)}catch(c){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,c instanceof Error?c.message:String(c))}return r?this.applyEnvOverrides(a):a}let n=(0,ut.readFileSync)(e,"utf-8"),o=JSON.parse(n.replace(/^\uFEFF/,"")),s=o;if(o.env&&typeof o.env=="object"){s=o.env;try{(0,ut.writeFileSync)(e,JSON.stringify(s,null,2),"utf-8"),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(a){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,a instanceof Error?a.message:String(a))}}let i={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))s[a]!==void 0&&(i[a]=s[a]);return r?this.applyEnvOverrides(i):i}catch(n){console.warn("[SETTINGS] Failed to load settings, using defaults:",e,n instanceof Error?n.message:String(n));let o=this.getAllDefaults();return r?this.applyEnvOverrides(o):o}}};var Rs=null;function Is(){return Rs!==null||(Rs=wt.loadFromFile(Cu)),Rs}var tr=require("fs");var cu=require("child_process");var dt=require("fs"),iu=xt(require("path"),1);var b$=["CLAUDECODE_","CLAUDE_CODE_"],E$=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),w$=new Set(["HTTP_PROXY","HTTPS_PROXY","ALL_PROXY","NO_PROXY","http_proxy","https_proxy","all_proxy","no_proxy","npm_config_proxy","npm_config_https_proxy"]),k$=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","ANTHROPIC_BEDROCK_BASE_URL","AWS_REGION","AWS_PROFILE","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_SESSION_TOKEN","ANTHROPIC_VERTEX_PROJECT_ID","CLOUD_ML_REGION","GOOGLE_APPLICATION_CREDENTIALS"]);function Wn(t=process.env){let e={};for(let[r,n]of Object.entries(t))if(n!==void 0){if(k$.has(r)){e[r]=n;continue}E$.has(r)||w$.has(r)||b$.some(o=>r.startsWith(o))||(e[r]=n)}return e}var x$=5e3,$$=1e3,P$=De.supervisorRegistry();function lt(t){if(!Number.isInteger(t)||t<0||t===0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;return r==="EPERM"?!0:(y.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return y.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}var T$=5e3,Wg=new Map;function z$(t){let e=Wg.get(t);if(e&&Date.now()-e.capturedAtMs<T$)return e.token;let r=null;try{let n=(0,cu.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${t}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...Wn(process.env),LC_ALL:"C",LANG:"C"}});if(n.status===0){let o=n.stdout.trim();r=o.length>0?o:null}}catch(n){y.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:t,error:n instanceof Error?n.message:String(n)}),r=null}return Wg.set(t,{token:r,capturedAtMs:Date.now()}),r}function Vg(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=(0,dt.readFileSync)(`/proc/${t}/stat`,"utf-8"),r=e.lastIndexOf(") ");if(r<0)return null;let o=e.slice(r+2).split(" ")[19];return o&&/^\d+$/.test(o)?o:null}catch(e){return y.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return z$(t);try{let e=(0,cu.spawnSync)("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...Wn(process.env),LC_ALL:"C",LANG:"C"}});if(e.status!==0)return null;let r=e.stdout.trim();return r.length>0?r:null}catch(e){return y.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function uu(t){if(!t||!lt(t.pid))return!1;if(!t.startToken)return!0;let e=Vg(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||y.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}var au=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=P$){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,dt.mkdirSync)(iu.default.dirname(this.registryPath),{recursive:!0}),!(0,dt.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,dt.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?y.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):y.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&y.info("SYSTEM","Removed dead processes from supervisor registry",{removed:e}),this.persist()}register(e,r,n){this.initialize(),this.entries.set(e,r),n&&this.runtimeProcesses.set(e,n),this.persist()}unregister(e){this.initialize();let r=this.entries.get(e);this.entries.delete(e),this.runtimeProcesses.delete(e),this.persist(),r?.type==="sdk"&&su()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([e,r])=>({id:e,...r})).sort((e,r)=>{let n=Date.parse(e.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(e){let r=String(e);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(e){return this.runtimeProcesses.get(e)}getByPid(e){return this.getAll().filter(r=>r.pid===e)}pruneDeadEntries(){this.initialize();let e=0,r=0;for(let[n,o]of this.entries)lt(o.pid)||(this.entries.delete(n),this.runtimeProcesses.delete(n),e+=1,o.type==="sdk"&&(r+=1));e>0&&this.persist();for(let n=0;n<r;n+=1)su();return e}async reapSession(e){this.initialize();let r=this.getBySession(e);if(r.length===0)return 0;let n=typeof e=="number"?e:Number(e)||void 0;y.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:n,pids:r.map(a=>a.pid)});let o=r.filter(a=>lt(a.pid));for(let a of o)try{typeof a.pgid=="number"&&process.platform!=="win32"?process.kill(-a.pgid,"SIGTERM"):process.kill(a.pid,"SIGTERM")}catch(c){c instanceof Error?c.code!=="ESRCH"&&y.debug("SYSTEM",`Failed to SIGTERM session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):y.warn("SYSTEM",`Failed to SIGTERM session process PID ${a.pid} (non-Error)`,{pid:a.pid,pgid:a.pgid,error:String(c)})}let s=Date.now()+x$;for(;Date.now()<s&&o.filter(c=>lt(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100));let i=o.filter(a=>lt(a.pid));for(let a of i){y.warn("SYSTEM",`Session process PID ${a.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:a.pid,pgid:a.pgid,sessionId:n});try{typeof a.pgid=="number"&&process.platform!=="win32"?process.kill(-a.pgid,"SIGKILL"):process.kill(a.pid,"SIGKILL")}catch(c){c instanceof Error?c.code!=="ESRCH"&&y.debug("SYSTEM",`Failed to SIGKILL session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):y.warn("SYSTEM",`Failed to SIGKILL session process PID ${a.pid} (non-Error)`,{pid:a.pid,pgid:a.pgid,error:String(c)})}}if(i.length>0){let a=Date.now()+$$;for(;Date.now()<a&&i.filter(u=>lt(u.pid)).length!==0;)await new Promise(u=>setTimeout(u,100))}for(let a of r)this.entries.delete(a.id),this.runtimeProcesses.delete(a.id);this.persist();for(let a of r)a.type==="sdk"&&su();return y.info("SYSTEM",`Reaped ${r.length} process(es) for session ${e}`,{sessionId:n,reaped:r.length}),r.length}persist(){let e={processes:Object.fromEntries(this.entries.entries())};(0,dt.mkdirSync)(iu.default.dirname(this.registryPath),{recursive:!0}),(0,dt.writeFileSync)(this.registryPath,JSON.stringify(e,null,2))}},ou=null;function Os(){return ou||(ou=new au),ou}var R$=[];function su(){let t=R$.shift();t&&t()}var Gg=require("child_process"),Ir=require("fs"),Jg=require("util");var I$=(0,Jg.promisify)(Gg.execFile),O$=De.workerPid();async function Yg(t){let e=t.currentPid??process.pid,r=t.pidFilePath??O$,n=t.registry.getAll(),o=[...n].filter(i=>i.pid!==e).sort((i,a)=>Date.parse(a.startedAt)-Date.parse(i.startedAt));for(let i of o){if(!lt(i.pid)){t.registry.unregister(i.id);continue}try{await Kg(i,"SIGTERM")}catch(a){a instanceof Error?y.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):y.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}}await Bg(o,5e3);let s=o.filter(i=>lt(i.pid));for(let i of s)try{await Kg(i,"SIGKILL")}catch(a){a instanceof Error?y.debug("SYSTEM","Failed to force kill child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):y.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}await Bg(s,1e3);for(let i of o)t.registry.unregister(i.id);for(let i of n.filter(a=>a.pid===e))t.registry.unregister(i.id);A$(r,e),t.registry.pruneDeadEntries()}function A$(t,e){if(!(0,Ir.existsSync)(t))return;let r=null;try{let n=JSON.parse((0,Ir.readFileSync)(t,"utf-8"));r=typeof n.pid=="number"?n.pid:null}catch(n){y.debug("SYSTEM","PID file unreadable during shutdown \u2014 leaving it (cannot prove ownership)",{pidFilePath:t,error:n instanceof Error?n.message:String(n)});return}if(r!==e){y.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:t,recordedPid:r,currentPid:e});return}try{(0,Ir.rmSync)(t,{force:!0})}catch(n){n instanceof Error?y.debug("SYSTEM","Failed to remove PID file during shutdown",{pidFilePath:t},n):y.warn("SYSTEM","Failed to remove PID file during shutdown (non-Error)",{pidFilePath:t,error:String(n)})}}async function Bg(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.filter(o=>lt(o.pid)).length===0)return;await new Promise(o=>setTimeout(o,100))}}async function Kg(t,e){let{pid:r,pgid:n}=t;if(process.platform!=="win32"){if(typeof n=="number")try{process.kill(-n,e);return}catch(i){if((i instanceof Error?i.code:void 0)!=="ESRCH")throw i}try{process.kill(r,e)}catch(i){if((i instanceof Error?i.code:void 0)!=="ESRCH")throw i}return}if(e==="SIGTERM"){try{process.kill(r,e)}catch(i){if(i instanceof Error&&i.code==="ESRCH")return;throw i}return}let o=await M$();if(o){await new Promise((i,a)=>{o(r,e,c=>{if(!c){i();return}if(c.code==="ESRCH"){i();return}a(c)})});return}let s=["/PID",String(r),"/T"];e==="SIGKILL"&&s.push("/F"),await I$("taskkill",s,{timeout:ae.POWERSHELL_COMMAND,windowsHide:!0})}async function M$(){let t="tree-kill";try{let e=await import(t);return e.default??e}catch(e){return y.debug("SYSTEM","tree-kill module not available, using fallback",{},e instanceof Error?e:void 0),null}}var Xg=3e4,Or=null;function C$(){let e=Os().pruneDeadEntries();e>0&&y.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function Qg(){Or===null&&(Or=setInterval(C$,Xg),Or.unref(),y.debug("SYSTEM","Health checker started",{intervalMs:Xg}))}function e_(){Or!==null&&(clearInterval(Or),Or=null,y.debug("SYSTEM","Health checker stopped"))}var N$=De.workerPid(),lu=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(e){this.registry=e}async start(){if(this.started)return;if(this.registry.initialize(),As({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,Qg()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){y.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,y.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?y.error("SYSTEM","Error during shutdown",{},o):y.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?y.debug("SYSTEM","Supervisor shutdown fallback failed",{},s):y.debug("SYSTEM","Supervisor shutdown fallback failed",{error:String(s)})}}process.exit(0)};process.on("SIGTERM",()=>{r("SIGTERM")}),process.on("SIGINT",()=>{r("SIGINT")}),process.platform!=="win32"&&(process.argv.includes("--daemon")?process.on("SIGHUP",()=>{y.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}e_(),this.stopPromise=Yg({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(e){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${e}`)}registerProcess(e,r,n){this.registry.register(e,r,n)}unregisterProcess(e){this.registry.unregister(e)}getRegistry(){return this.registry}},D$=new lu(Os());function du(){return D$}function As(t={}){let e=t.pidFilePath??N$;if(!(0,tr.existsSync)(e))return"missing";let r=null;try{r=JSON.parse((0,tr.readFileSync)(e,"utf-8"))}catch(o){return o instanceof Error?y.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},o):y.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(o)}),(0,tr.rmSync)(e,{force:!0}),"invalid"}return uu(r)&&r?((t.logAlive??!0)&&y.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(y.info("SYSTEM","Removing stale PID file (worker process is dead or PID has been reused)",{pid:r?.pid,port:r?.port,startedAt:r?.startedAt}),(0,tr.rmSync)(e,{force:!0}),"stale")}var rr=xt(require("path"),1),n_=require("os"),Ne=require("fs"),Ar=require("child_process");var o_=require("util");var zN=(0,o_.promisify)(Ar.exec),RN=De.dataDir(),t_=De.workerPid();function r_(t){return t?/(^|[\\/])bun(\.exe)?$/i.test(t.trim()):!1}function j$(t,e){let r=e==="win32"?`where ${t}`:`which ${t}`,n;try{n=(0,Ar.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?y.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},s):y.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},new Error(String(s))),null}return n.split(/\r?\n/).map(s=>s.trim()).find(s=>s.length>0)||null}var pu;function s_(t={}){let e=Object.keys(t).length===0;if(e&&pu!==void 0)return pu;let r=L$(t);return e&&r!==null&&(pu=r),r}function L$(t){let e=t.platform??process.platform,r=t.execPath??process.execPath;if(r_(r))return r;let n=t.env??process.env,o=t.homeDirectory??(0,n_.homedir)(),s=t.pathExists??Ne.existsSync,i=t.lookupInPath??j$,a=e==="win32"?[n.BUN,n.BUN_PATH,rr.default.join(o,".bun","bin","bun.exe"),rr.default.join(o,".bun","bin","bun"),n.USERPROFILE?rr.default.join(n.USERPROFILE,".bun","bin","bun.exe"):void 0,n.LOCALAPPDATA?rr.default.join(n.LOCALAPPDATA,"bun","bun.exe"):void 0,n.LOCALAPPDATA?rr.default.join(n.LOCALAPPDATA,"bun","bin","bun.exe"):void 0]:[n.BUN,n.BUN_PATH,rr.default.join(o,".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun","/usr/bin/bun","/snap/bin/bun"];for(let c of a){let u=c?.trim();if(u&&(r_(u)&&s(u)||u.toLowerCase()==="bun"))return u}return i("bun",e)}function qt(t){return process.platform==="win32"?Math.round(t*2):t}function i_(t,e,r={}){du().assertCanSpawn("worker daemon");let n=Wn({...process.env,CLAUDE_MEM_WORKER_PORT:String(e),...r}),o=s_();if(!o){y.error("SYSTEM","Bun runtime not found \u2014 install from https://bun.sh and ensure it is on PATH or set BUN env var. The worker daemon requires Bun because it uses bun:sqlite.");return}if(process.platform==="win32"){let l=`Start-Process -FilePath '${o.replace(/'/g,"''")}' -ArgumentList @('${t.replace(/'/g,"''")}','--daemon') -WindowStyle Hidden`,d=Buffer.from(l,"utf16le").toString("base64");try{return(0,Ar.execSync)(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:n}),0}catch(p){y.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:o},p instanceof Error?p:new Error(String(p)));return}}let s="/usr/bin/setsid",i=(0,Ne.existsSync)(s),u=zs(i?s:o,i?[o,t,"--daemon"]:[t,"--daemon"],{detached:!0,stdio:"ignore",env:n});if(u.pid!==void 0)return u.unref(),u.pid}function a_(){try{if(!(0,Ne.existsSync)(t_))return;let t=new Date;(0,Ne.utimesSync)(t_,t,t)}catch{}}function c_(){return As({logAlive:!1})}var u_=xt(require("net"),1);async function U$(t,e,r="GET"){let n=await fetch(`http://127.0.0.1:${t}${e}`,{method:r}),o="";try{o=await n.text()}catch{}return{ok:n.ok,statusCode:n.status,body:o}}async function l_(t){if(process.platform==="win32")try{return(await fetch(`http://127.0.0.1:${t}/api/health`)).ok}catch(e){return e instanceof Error?y.debug("SYSTEM","Windows health check failed (port not in use)",{},e):y.debug("SYSTEM","Windows health check failed (port not in use)",{error:String(e)}),!1}return new Promise(e=>{let r=u_.default.createServer();r.once("error",n=>{n.code==="EADDRINUSE"?e(!0):e(!1)}),r.once("listening",()=>{r.close(()=>e(!1))}),r.listen(t,"127.0.0.1")})}async function d_(t,e,r,n){let o=Date.now();for(;Date.now()-o<r;){try{if((await U$(t,e)).ok)return!0}catch(s){s instanceof Error?y.debug("SYSTEM",n,{},s):y.debug("SYSTEM",n,{error:String(s)})}await new Promise(s=>setTimeout(s,500))}return!1}function Vn(t,e=3e4){return d_(t,"/api/health",e,"Service not ready yet, will retry")}function Bn(t,e=3e4){return d_(t,"/api/readiness",e,"Worker not ready yet, will retry")}var Ms=require("path"),We=require("fs");var q$=6e4;function p_(){return(0,Ms.join)(no(),"spawn.lock")}function fu(){let t=p_(),e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return(0,We.mkdirSync)((0,Ms.dirname)(t),{recursive:!0}),(0,We.writeFileSync)(t,e,{flag:"wx"}),!0}catch(n){if(n?.code!=="EEXIST")return!0;if(r>0)return!1;let s;try{s=(0,We.statSync)(t).mtimeMs}catch{continue}if(Date.now()-s<=q$)return!1;let i;try{i=(0,We.statSync)(t).mtimeMs}catch{continue}if(i!==s)return!1;try{(0,We.unlinkSync)(t)}catch{return!1}}return!1}function mu(){let t=p_();try{if(JSON.parse((0,We.readFileSync)(t,"utf-8")).pid!==process.pid)return;(0,We.unlinkSync)(t)}catch{}}function hu(t,e,r){let n=process.env[t];if(n){let o=parseInt(n,10);if(Number.isFinite(o)&&o>=r.min&&o<=r.max)return o;y.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max})}return e}var iD=hu("CLAUDE_MEM_HEALTH_TIMEOUT_MS",Et(ae.HEALTH_CHECK),{min:500,max:3e5}),aD=hu("CLAUDE_MEM_API_TIMEOUT_MS",Et(ae.API_REQUEST),{min:500,max:3e5}),cD=hu("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",Et(ae.HOOK_READINESS_WAIT),{min:0,max:3e5}),Z$={min:500,max:3e5};function gu(t,e={},r){return new Promise((n,o)=>{let s=setTimeout(()=>o(new Error(`Request timed out after ${r}ms`)),r);fetch(t,e).then(i=>{clearTimeout(s),n(i)},i=>{clearTimeout(s),o(i)})})}var Cs=null,Ns=null,Ds=null,js=null;function F$(){return Ls.default.join(wt.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function _u(){return Ds!==null||(Ds=wt.loadFromFile(F$())),Ds}function f_(t,e){if(!t)return null;let r=parseInt(t,10);return Number.isFinite(r)&&r>=e.min&&r<=e.max?r:null}function H$(t,e,r){let n=process.env[t];if(n!==void 0){let i=f_(n,r);return i!==null?i:(y.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max}),e)}let o=_u()[t],s=f_(o,r);return s!==null?s:(y.warn("SYSTEM",`Invalid ${t} in settings.json, using default`,{value:o,min:r.min,max:r.max}),e)}function yu(){if(Cs!==null)return Cs;let t=_u();return Cs=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),Cs}function W$(){return Ns!==null||(Ns=_u().CLAUDE_MEM_WORKER_HOST),Ns}function V$(){return js!==null||(js=H$("CLAUDE_MEM_API_TIMEOUT_MS",Et(ae.API_REQUEST),Z$)),js}function B$(t){return`http://${W$()}:${yu()}${t}`}function Us(t,e={}){let r=e.method??"GET",n=e.timeoutMs??V$(),o=B$(t),s={method:r};return e.headers&&(s.headers=e.headers),e.body&&(s.body=e.body),n>0?gu(o,s,n):fetch(o,s)}function m_(){let t=[Ls.default.join(Gs,"plugin","scripts","worker-service.cjs"),Ls.default.join(process.cwd(),"plugin","scripts","worker-service.cjs")];for(let e of t)if((0,Mr.existsSync)(e))return e;return null}var Su=xt(require("path"),1),Ve=require("fs");var K$=120*1e3;function vu(){return Su.default.join(wt.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function G$(){if(process.platform!=="win32")return!1;let t=vu();if(!(0,Ve.existsSync)(t))return!1;try{let e=(0,Ve.statSync)(t).mtimeMs;return Date.now()-e<K$}catch(e){return e instanceof Error?y.debug("SYSTEM","Could not stat worker spawn lock file",{},e):y.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(e)}),!1}}function J$(){if(process.platform==="win32")try{let t=vu();(0,Ve.mkdirSync)(Su.default.dirname(t),{recursive:!0}),(0,Ve.writeFileSync)(t,"","utf-8")}catch{}}function qs(){if(process.platform==="win32")try{let t=vu();(0,Ve.existsSync)(t)&&(0,Ve.unlinkSync)(t)}catch{}}async function h_(t,e){if(!e)return y.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,Ve.existsSync)(e))return y.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:e}),"dead";if(c_()==="alive"){if(y.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await Vn(t,qt(ae.PORT_IN_USE_WAIT))){qs();let a=await Bn(t,qt(ae.READINESS_WAIT));return y.info("SYSTEM","Worker became healthy while waiting on live PID"),a?"ready":"warming"}return y.warn("SYSTEM","Live PID detected but worker did not become healthy before timeout \u2014 likely still starting"),"warming"}if(await Vn(t,1e3)){qs();let i=await Bn(t,qt(ae.READINESS_WAIT));return i||y.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),y.info("SYSTEM","Worker already running and healthy"),i?"ready":"warming"}if(await l_(t)){if(y.info("SYSTEM","Port in use, waiting for worker to become healthy"),await Vn(t,qt(ae.PORT_IN_USE_WAIT))){qs();let a=await Bn(t,qt(ae.READINESS_WAIT));return y.info("SYSTEM","Worker is now healthy"),a?"ready":"warming"}return y.error("SYSTEM","Port in use but worker not responding to health checks"),"dead"}if(G$())return y.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";let o=fu();try{if(o){if(y.info("SYSTEM","Starting worker daemon",{workerScriptPath:e}),J$(),i_(e,t)===void 0)return y.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else y.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");if(!await Vn(t,qt(ae.POST_SPAWN_WAIT)))return y.warn("SYSTEM",o?"Worker spawned but health endpoint not responding within window \u2014 likely still starting in background":"Spawn-lock holder's worker not healthy within window \u2014 likely still starting in background"),"warming"}finally{o&&mu()}let s=await Bn(t,qt(ae.READINESS_WAIT));return s||y.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),qs(),a_(),y.info("SYSTEM",o?"Worker started successfully":"Worker is up (started by another launcher)"),s?"ready":"warming"}var Dr=require("node:fs/promises"),Yn=require("node:path");var y_=require("node:child_process"),ye=require("node:fs"),ue=require("node:path"),$u=require("node:os"),wu=require("node:module");var lP={},ku=typeof __filename<"u"?(0,wu.createRequire)(__filename):(0,wu.createRequire)(lP.url),xu={".js":"javascript",".mjs":"javascript",".cjs":"javascript",".jsx":"tsx",".ts":"typescript",".tsx":"tsx",".py":"python",".pyw":"python",".go":"go",".rs":"rust",".rb":"ruby",".java":"java",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".kt":"kotlin",".kts":"kotlin",".swift":"swift",".php":"php",".ex":"elixir",".exs":"elixir",".lua":"lua",".scala":"scala",".sc":"scala",".sh":"bash",".bash":"bash",".zsh":"bash",".hs":"haskell",".zig":"zig",".css":"css",".scss":"scss",".toml":"toml",".yml":"yaml",".yaml":"yaml",".sql":"sql",".md":"markdown",".mdx":"markdown"};function S_(t,e){let r=t.slice(t.lastIndexOf("."));return xu[r]?xu[r]:e.extensionToLanguage[r]?e.extensionToLanguage[r]:"unknown"}function v_(t,e){return e.languageToQueryKey[t]?e.languageToQueryKey[t]:Q$(t)}var Kn=new Map,Cr={grammars:{},extensionToLanguage:{},languageToQueryKey:{}};function Jn(t){if(Kn.has(t))return Kn.get(t);let e=(0,ue.join)(t,".claude-mem.json"),r;try{let s=(0,ye.readFileSync)(e,"utf-8");r=JSON.parse(s)}catch{return Kn.set(t,Cr),Cr}let n=r.grammars;if(!n||typeof n!="object"||Array.isArray(n))return Kn.set(t,Cr),Cr;let o={grammars:{},extensionToLanguage:{},languageToQueryKey:{}};for(let[s,i]of Object.entries(n)){if(b_[s]||!i||typeof i!="object"||Array.isArray(i))continue;let a=i,c=a.package,u=a.extensions,l=a.query;if(!(typeof c!="string"||!Array.isArray(u))&&u.every(d=>typeof d=="string")){o.grammars[s]={package:c,extensions:u,query:typeof l=="string"?l:void 0};for(let d of u)xu[d]||(o.extensionToLanguage[d]=s);if(typeof l=="string"){let d=(0,ue.join)(t,l);try{let p=(0,ye.readFileSync)(d,"utf-8"),f=`user_${s}`;w_[f]=p,o.languageToQueryKey[s]=f}catch{y.warn("PARSER","Custom query file not found, falling back to generic",{fullQueryPath:d}),o.languageToQueryKey[s]="generic"}}else o.languageToQueryKey[s]="generic"}}return Kn.set(t,o),o}var b_={javascript:"tree-sitter-javascript",typescript:"tree-sitter-typescript/typescript",tsx:"tree-sitter-typescript/tsx",python:"tree-sitter-python",go:"tree-sitter-go",rust:"tree-sitter-rust",ruby:"tree-sitter-ruby",java:"tree-sitter-java",c:"tree-sitter-c",cpp:"tree-sitter-cpp",kotlin:"tree-sitter-kotlin",swift:"tree-sitter-swift",php:"tree-sitter-php/php",elixir:"tree-sitter-elixir",lua:"@tree-sitter-grammars/tree-sitter-lua",scala:"tree-sitter-scala",bash:"tree-sitter-bash",haskell:"tree-sitter-haskell",zig:"@tree-sitter-grammars/tree-sitter-zig",css:"tree-sitter-css",scss:"tree-sitter-scss",toml:"@tree-sitter-grammars/tree-sitter-toml",yaml:"@tree-sitter-grammars/tree-sitter-yaml",sql:"@derekstride/tree-sitter-sql",markdown:"@tree-sitter-grammars/tree-sitter-markdown"},Y$={markdown:"tree-sitter-markdown"};function X$(t){let e=b_[t];if(!e)return null;let r=Y$[t];if(r){try{let n=ku.resolve(e+"/package.json"),o=(0,ue.join)((0,ue.dirname)(n),r);if((0,ye.existsSync)((0,ue.join)(o,"src")))return o}catch{}return null}try{let n=ku.resolve(e+"/package.json");return(0,ue.dirname)(n)}catch{return null}}function E_(t,e){let r=X$(t);if(r)return r;if(!e)return null;let o=Jn(e).grammars[t];if(!o)return null;try{let s=(0,ue.join)(e,"node_modules",o.package,"package.json");if((0,ye.existsSync)(s)){let i=(0,ue.dirname)(s);if((0,ye.existsSync)((0,ue.join)(i,"src")))return i}}catch{}return y.warn("PARSER","Grammar package not found",{language:t,package:o.package}),null}var w_={jsts:`
|
|
80
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of t.seen.entries()){let a=i[1];if(e===i[0]){s(i);continue}if(t.external){let u=t.external.registry.get(i[0])?.id;if(e!==i[0]&&u){s(i);continue}}if(t.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}if(a.count>1&&t.reused==="ref"){s(i);continue}}}function Di(t,e){let r=t.seen.get(e);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=t.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 f=t.seen.get(d),m=f.schema;if(m.$ref&&(t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):Object.assign(u,m),Object.assign(u,l),a._zod.parent===d)for(let S in u)S==="$ref"||S==="allOf"||S in l||delete u[S];if(m.$ref&&f.def)for(let S in u)S==="$ref"||S==="allOf"||S in f.def&&JSON.stringify(u[S])===JSON.stringify(f.def[S])&&delete u[S]}let p=a._zod.parent;if(p&&p!==d){n(p);let f=t.seen.get(p);if(f?.schema.$ref&&(u.$ref=f.schema.$ref,f.def))for(let m in u)m==="$ref"||m==="allOf"||m in f.def&&JSON.stringify(u[m])===JSON.stringify(f.def[m])&&delete u[m]}t.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};for(let a of[...t.seen.entries()].reverse())n(a[0]);let o={};if(t.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":t.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":t.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":t.target,t.external?.uri){let a=t.external.registry.get(e)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=t.external.uri(a)}Object.assign(o,r.def??r.schema);let s=t.metadataRegistry.get(e)?.id;s!==void 0&&o.id===s&&delete o.id;let i=t.external?.defs??{};for(let a of t.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,i[c.defId]=c.def)}t.external||Object.keys(i).length>0&&(t.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...e["~standard"],jsonSchema:{input:Yr(e,"input",t.processors),output:Yr(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function ke(t,e){let r=e??{seen:new Set};if(r.seen.has(t))return!1;r.seen.add(t);let n=t._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return ke(n.element,r);if(n.type==="set")return ke(n.valueType,r);if(n.type==="lazy")return ke(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")return ke(n.innerType,r);if(n.type==="intersection")return ke(n.left,r)||ke(n.right,r);if(n.type==="record"||n.type==="map")return ke(n.keyType,r)||ke(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:ke(n.in,r)||ke(n.out,r);if(n.type==="object"){for(let o in n.shape)if(ke(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(ke(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(ke(o,r))return!0;return!!(n.rest&&ke(n.rest,r))}return!1}var Mp=(t,e={})=>r=>{let n=Ci({...r,processors:e});return se(t,n),Ni(n,t),Di(n,t)},Yr=(t,e,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=Ci({...o??{},target:s,io:e,processors:r});return se(t,i),Ni(i,t),Di(i,t)};var Vy={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Cp=(t,e,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u}=t._zod.bag;if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=Vy[a]??a,o.format===""&&delete o.format,a==="time"&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let l=[...c];l.length===1?o.pattern=l[0].source:l.length>1&&(o.allOf=[...l.map(d=>({...e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},Np=(t,e,r,n)=>{let o=r,{minimum:s,maximum:i,format:a,multipleOf:c,exclusiveMaximum:u,exclusiveMinimum:l}=t._zod.bag;typeof a=="string"&&a.includes("int")?o.type="integer":o.type="number";let d=typeof l=="number"&&l>=(s??Number.NEGATIVE_INFINITY),p=typeof u=="number"&&u<=(i??Number.POSITIVE_INFINITY),f=e.target==="draft-04"||e.target==="openapi-3.0";d?f?(o.minimum=l,o.exclusiveMinimum=!0):o.exclusiveMinimum=l:typeof s=="number"&&(o.minimum=s),p?f?(o.maximum=u,o.exclusiveMaximum=!0):o.exclusiveMaximum=u:typeof i=="number"&&(o.maximum=i),typeof c=="number"&&(o.multipleOf=c)},Dp=(t,e,r,n)=>{r.type="boolean"};var jp=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Lp=(t,e,r,n)=>{r.not={}};var Up=(t,e,r,n)=>{};var qp=(t,e,r,n)=>{let o=t._zod.def,s=qr(o.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},Zp=(t,e,r,n)=>{let o=t._zod.def,s=[];for(let i of o.values)if(i===void 0){if(e.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof i=="bigint"){if(e.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");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,e.target==="draft-04"||e.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 Fp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var Hp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var Wp=(t,e,r,n)=>{let o=r,s=t._zod.def,{minimum:i,maximum:a}=t._zod.bag;typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=se(s.element,e,{...n,path:[...n.path,"items"]})},Vp=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object",o.properties={};let i=s.shape;for(let u in i)o.properties[u]=se(i[u],e,{...n,path:[...n.path,"properties",u]});let a=new Set(Object.keys(i)),c=new Set([...a].filter(u=>{let l=s.shape[u]._zod;return e.io==="input"?l.optin===void 0:l.optout===void 0}));c.size>0&&(o.required=Array.from(c)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=se(s.catchall,e,{...n,path:[...n.path,"additionalProperties"]})):e.io==="output"&&(o.additionalProperties=!1)},Bp=(t,e,r,n)=>{let o=t._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>se(a,e,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},Kp=(t,e,r,n)=>{let o=t._zod.def,s=se(o.left,e,{...n,path:[...n.path,"allOf",0]}),i=se(o.right,e,{...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};var Gp=(t,e,r,n)=>{let o=r,s=t._zod.def;o.type="object";let i=s.keyType,c=i._zod.bag?.patterns;if(s.mode==="loose"&&c&&c.size>0){let l=se(s.valueType,e,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of c)o.patternProperties[d.source]=l}else(e.target==="draft-07"||e.target==="draft-2020-12")&&(o.propertyNames=se(s.keyType,e,{...n,path:[...n.path,"propertyNames"]})),o.additionalProperties=se(s.valueType,e,{...n,path:[...n.path,"additionalProperties"]});let u=i._zod.values;if(u){let l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l)}},Jp=(t,e,r,n)=>{let o=t._zod.def,s=se(o.innerType,e,n),i=e.seen.get(t);e.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},Yp=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType},Xp=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.default=JSON.parse(JSON.stringify(o.defaultValue))},Qp=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,e.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(o.defaultValue)))},ef=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},tf=(t,e,r,n)=>{let o=t._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=e.io==="input"?s?o.out:o.in:o.out;se(i,e,n);let a=e.seen.get(t);a.ref=i},rf=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType,r.readOnly=!0};var ji=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType};function lr(t){return!!t._zod}function Rt(t,e){return lr(t)?Vr(t,e):t.safeParse(e)}function wo(t){if(!t)return;let e;if(lr(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function nf(t){if(lr(t)){let s=t._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=t.value;if(n!==void 0)return n}var Qr={};Cu(Qr,{ZodISODate:()=>sf,ZodISODateTime:()=>of,ZodISODuration:()=>cf,ZodISOTime:()=>af,date:()=>Ui,datetime:()=>Li,duration:()=>Zi,time:()=>qi});var of=g("ZodISODateTime",(t,e)=>{fd.init(t,e),te.init(t,e)});function Li(t){return vp(of,t)}var sf=g("ZodISODate",(t,e)=>{md.init(t,e),te.init(t,e)});function Ui(t){return bp(sf,t)}var af=g("ZodISOTime",(t,e)=>{hd.init(t,e),te.init(t,e)});function qi(t){return Ep(af,t)}var cf=g("ZodISODuration",(t,e)=>{gd.init(t,e),te.init(t,e)});function Zi(t){return wp(cf,t)}var tS=(t,e)=>{co.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Ju(t,r)},flatten:{value:r=>Gu(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,ir,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,ir,2)}},isEmpty:{get(){return t.issues.length===0}}})};var Me=g("ZodError",tS,{Parent:Error});var uf=uo(Me),lf=lo(Me),df=Wr(Me),pf=Br(Me),ff=Yu(Me),mf=Xu(Me),hf=Qu(Me),gf=el(Me),_f=tl(Me),yf=rl(Me),Sf=nl(Me),vf=ol(Me);var bf=new WeakMap;function en(t,e,r){let n=Object.getPrototypeOf(t),o=bf.get(n);if(o||(o=new Set,bf.set(n,o)),!o.has(e)){o.add(e);for(let s in r){let i=r[s];Object.defineProperty(n,s,{configurable:!0,enumerable:!1,get(){let a=i.bind(this);return Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,s,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}var oe=g("ZodType",(t,e)=>(G.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:Yr(t,"input"),output:Yr(t,"output")}}),t.toJSONSchema=Mp(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>uf(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>df(t,r,n),t.parseAsync=async(r,n)=>lf(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>pf(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>ff(t,r,n),t.decode=(r,n)=>mf(t,r,n),t.encodeAsync=async(r,n)=>hf(t,r,n),t.decodeAsync=async(r,n)=>gf(t,r,n),t.safeEncode=(r,n)=>_f(t,r,n),t.safeDecode=(r,n)=>yf(t,r,n),t.safeEncodeAsync=async(r,n)=>Sf(t,r,n),t.safeDecodeAsync=async(r,n)=>vf(t,r,n),en(t,"ZodType",{check(...r){let n=this.def;return this.clone(U.mergeDefs(n,{checks:[...n.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]}),{parent:!0})},with(...r){return this.check(...r)},clone(r,n){return Ge(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(WS(r,n))},superRefine(r,n){return this.check(VS(r,n))},overwrite(r){return this.check(zt(r))},optional(){return ne(this)},exactOptional(){return AS(this)},nullable(){return xf(this)},nullish(){return ne(xf(this))},nonoptional(r){return LS(this,r)},array(){return D(this)},or(r){return Y([this,r])},and(r){return xo(this,r)},transform(r){return $f(this,Of(r))},default(r){return NS(this,r)},prefault(r){return jS(this,r)},catch(r){return qS(this,r)},pipe(r){return $f(this,r)},readonly(){return HS(this)},describe(r){let n=this.clone();return Ht.add(n,{description:r}),n},meta(...r){if(r.length===0)return Ht.get(this);let n=this.clone();return Ht.add(n,r[0]),n},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(r){return r(this)}}),Object.defineProperty(t,"description",{get(){return Ht.get(t)?.description},configurable:!0}),t)),Pf=g("_ZodString",(t,e)=>{_o.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Cp(t,n,o,s);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,en(t,"_ZodString",{regex(...n){return this.check(ki(...n))},includes(...n){return this.check(Pi(...n))},startsWith(...n){return this.check(Ti(...n))},endsWith(...n){return this.check(zi(...n))},min(...n){return this.check(ur(...n))},max(...n){return this.check(bo(...n))},length(...n){return this.check(Eo(...n))},nonempty(...n){return this.check(ur(1,...n))},lowercase(n){return this.check(xi(n))},uppercase(n){return this.check($i(n))},trim(){return this.check(Ii())},normalize(...n){return this.check(Ri(...n))},toLowerCase(){return this.check(Oi())},toUpperCase(){return this.check(Ai())},slugify(){return this.check(Mi())}})}),nS=g("ZodString",(t,e)=>{_o.init(t,e),Pf.init(t,e),t.email=r=>t.check(Qd(oS,r)),t.url=r=>t.check(op(sS,r)),t.jwt=r=>t.check(Sp(vS,r)),t.emoji=r=>t.check(sp(iS,r)),t.guid=r=>t.check(wi(Ef,r)),t.uuid=r=>t.check(ep(ko,r)),t.uuidv4=r=>t.check(tp(ko,r)),t.uuidv6=r=>t.check(rp(ko,r)),t.uuidv7=r=>t.check(np(ko,r)),t.nanoid=r=>t.check(ip(aS,r)),t.guid=r=>t.check(wi(Ef,r)),t.cuid=r=>t.check(ap(cS,r)),t.cuid2=r=>t.check(cp(uS,r)),t.ulid=r=>t.check(up(lS,r)),t.base64=r=>t.check(gp(_S,r)),t.base64url=r=>t.check(_p(yS,r)),t.xid=r=>t.check(lp(dS,r)),t.ksuid=r=>t.check(dp(pS,r)),t.ipv4=r=>t.check(pp(fS,r)),t.ipv6=r=>t.check(fp(mS,r)),t.cidrv4=r=>t.check(mp(hS,r)),t.cidrv6=r=>t.check(hp(gS,r)),t.e164=r=>t.check(yp(SS,r)),t.datetime=r=>t.check(Li(r)),t.date=r=>t.check(Ui(r)),t.time=r=>t.check(qi(r)),t.duration=r=>t.check(Zi(r))});function h(t){return Xd(nS,t)}var te=g("ZodStringFormat",(t,e)=>{J.init(t,e),Pf.init(t,e)}),oS=g("ZodEmail",(t,e)=>{od.init(t,e),te.init(t,e)});var Ef=g("ZodGUID",(t,e)=>{rd.init(t,e),te.init(t,e)});var ko=g("ZodUUID",(t,e)=>{nd.init(t,e),te.init(t,e)});var sS=g("ZodURL",(t,e)=>{sd.init(t,e),te.init(t,e)});var iS=g("ZodEmoji",(t,e)=>{id.init(t,e),te.init(t,e)});var aS=g("ZodNanoID",(t,e)=>{ad.init(t,e),te.init(t,e)});var cS=g("ZodCUID",(t,e)=>{cd.init(t,e),te.init(t,e)});var uS=g("ZodCUID2",(t,e)=>{ud.init(t,e),te.init(t,e)});var lS=g("ZodULID",(t,e)=>{ld.init(t,e),te.init(t,e)});var dS=g("ZodXID",(t,e)=>{dd.init(t,e),te.init(t,e)});var pS=g("ZodKSUID",(t,e)=>{pd.init(t,e),te.init(t,e)});var fS=g("ZodIPv4",(t,e)=>{_d.init(t,e),te.init(t,e)});var mS=g("ZodIPv6",(t,e)=>{yd.init(t,e),te.init(t,e)});var hS=g("ZodCIDRv4",(t,e)=>{Sd.init(t,e),te.init(t,e)});var gS=g("ZodCIDRv6",(t,e)=>{vd.init(t,e),te.init(t,e)});var _S=g("ZodBase64",(t,e)=>{Ed.init(t,e),te.init(t,e)});var yS=g("ZodBase64URL",(t,e)=>{wd.init(t,e),te.init(t,e)});var SS=g("ZodE164",(t,e)=>{kd.init(t,e),te.init(t,e)});var vS=g("ZodJWT",(t,e)=>{xd.init(t,e),te.init(t,e)});var Tf=g("ZodNumber",(t,e)=>{yi.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Np(t,n,o,s),en(t,"ZodNumber",{gt(n,o){return this.check(So(n,o))},gte(n,o){return this.check(Jr(n,o))},min(n,o){return this.check(Jr(n,o))},lt(n,o){return this.check(yo(n,o))},lte(n,o){return this.check(Gr(n,o))},max(n,o){return this.check(Gr(n,o))},int(n){return this.check(wf(n))},safe(n){return this.check(wf(n))},positive(n){return this.check(So(0,n))},nonnegative(n){return this.check(Jr(0,n))},negative(n){return this.check(yo(0,n))},nonpositive(n){return this.check(Gr(0,n))},multipleOf(n,o){return this.check(vo(n,o))},step(n,o){return this.check(vo(n,o))},finite(){return this}});let r=t._zod.bag;t.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,t.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,t.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),t.isFinite=!0,t.format=r.format??null});function W(t){return kp(Tf,t)}var bS=g("ZodNumberFormat",(t,e)=>{$d.init(t,e),Tf.init(t,e)});function wf(t){return xp(bS,t)}var ES=g("ZodBoolean",(t,e)=>{Pd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Dp(t,r,n,o)});function de(t){return $p(ES,t)}var wS=g("ZodNull",(t,e)=>{Td.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>jp(t,r,n,o)});function zf(t){return Pp(wS,t)}var kS=g("ZodUnknown",(t,e)=>{zd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Up(t,r,n,o)});function re(){return Tp(kS)}var xS=g("ZodNever",(t,e)=>{Rd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Lp(t,r,n,o)});function $S(t){return zp(xS,t)}var PS=g("ZodArray",(t,e)=>{Id.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Wp(t,r,n,o),t.element=e.element,en(t,"ZodArray",{min(r,n){return this.check(ur(r,n))},nonempty(r){return this.check(ur(1,r))},max(r,n){return this.check(bo(r,n))},length(r,n){return this.check(Eo(r,n))},unwrap(){return this.element}})});function D(t,e){return Rp(PS,t,e)}var Rf=g("ZodObject",(t,e)=>{Md.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Vp(t,r,n,o),U.defineLazy(t,"shape",()=>e.shape),en(t,"ZodObject",{keyof(){return Te(Object.keys(this._zod.def.shape))},catchall(r){return this.clone({...this._zod.def,catchall:r})},passthrough(){return this.clone({...this._zod.def,catchall:re()})},loose(){return this.clone({...this._zod.def,catchall:re()})},strict(){return this.clone({...this._zod.def,catchall:$S()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(r){return U.extend(this,r)},safeExtend(r){return U.safeExtend(this,r)},merge(r){return U.merge(this,r)},pick(r){return U.pick(this,r)},omit(r){return U.omit(this,r)},partial(...r){return U.partial(Af,this,r[0])},required(...r){return U.required(Mf,this,r[0])}})});function k(t,e){let r={type:"object",shape:t??{},...U.normalizeParams(e)};return new Rf(r)}function xe(t,e){return new Rf({type:"object",shape:t,catchall:re(),...U.normalizeParams(e)})}var If=g("ZodUnion",(t,e)=>{Si.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Bp(t,r,n,o),t.options=e.options});function Y(t,e){return new If({type:"union",options:t,...U.normalizeParams(e)})}var TS=g("ZodDiscriminatedUnion",(t,e)=>{If.init(t,e),Cd.init(t,e)});function Hi(t,e,r){return new TS({type:"union",options:e,discriminator:t,...U.normalizeParams(r)})}var zS=g("ZodIntersection",(t,e)=>{Nd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Kp(t,r,n,o)});function xo(t,e){return new zS({type:"intersection",left:t,right:e})}var kf=g("ZodRecord",(t,e)=>{Dd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Gp(t,r,n,o),t.keyType=e.keyType,t.valueType=e.valueType});function K(t,e,r){return!e||!e._zod?new kf({type:"record",keyType:h(),valueType:t,...U.normalizeParams(e)}):new kf({type:"record",keyType:t,valueType:e,...U.normalizeParams(r)})}var Fi=g("ZodEnum",(t,e)=>{jd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>qp(t,n,o,s),t.enum=e.entries,t.options=Object.values(e.entries);let r=new Set(Object.keys(e.entries));t.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=e.entries[i];else throw new Error(`Key ${i} not found in enum`);return new Fi({...e,checks:[],...U.normalizeParams(o),entries:s})},t.exclude=(n,o)=>{let s={...e.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new Fi({...e,checks:[],...U.normalizeParams(o),entries:s})}});function Te(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new Fi({type:"enum",entries:r,...U.normalizeParams(e)})}var RS=g("ZodLiteral",(t,e)=>{Ld.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Zp(t,r,n,o),t.values=new Set(e.values),Object.defineProperty(t,"value",{get(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function P(t,e){return new RS({type:"literal",values:Array.isArray(t)?t:[t],...U.normalizeParams(e)})}var IS=g("ZodTransform",(t,e)=>{Ud.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Hp(t,r,n,o),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new or(t.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(U.issue(s,r.value,e));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=r.value),i.inst??(i.inst=t),r.issues.push(U.issue(i))}};let o=e.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r.fallback=!0,r)):(r.value=o,r.fallback=!0,r)}});function Of(t){return new IS({type:"transform",transform:t})}var Af=g("ZodOptional",(t,e)=>{vi.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ji(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function ne(t){return new Af({type:"optional",innerType:t})}var OS=g("ZodExactOptional",(t,e)=>{qd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ji(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function AS(t){return new OS({type:"optional",innerType:t})}var MS=g("ZodNullable",(t,e)=>{Zd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Jp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function xf(t){return new MS({type:"nullable",innerType:t})}var CS=g("ZodDefault",(t,e)=>{Fd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Xp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function NS(t,e){return new CS({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():U.shallowClone(e)}})}var DS=g("ZodPrefault",(t,e)=>{Hd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Qp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function jS(t,e){return new DS({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():U.shallowClone(e)}})}var Mf=g("ZodNonOptional",(t,e)=>{Wd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Yp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function LS(t,e){return new Mf({type:"nonoptional",innerType:t,...U.normalizeParams(e)})}var US=g("ZodCatch",(t,e)=>{Vd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ef(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function qS(t,e){return new US({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Cf=g("ZodPipe",(t,e)=>{bi.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>tf(t,r,n,o),t.in=e.in,t.out=e.out});function $f(t,e){return new Cf({type:"pipe",in:t,out:e})}var ZS=g("ZodPreprocess",(t,e)=>{Cf.init(t,e),Bd.init(t,e)}),FS=g("ZodReadonly",(t,e)=>{Kd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>rf(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function HS(t){return new FS({type:"readonly",innerType:t})}var Nf=g("ZodCustom",(t,e)=>{Gd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Fp(t,r,n,o)});function Df(t,e){return Ip(Nf,t??(()=>!0),e)}function WS(t,e={}){return Op(Nf,t,e)}function VS(t,e){return Ap(t,e)}function Wi(t,e){return new ZS({type:"pipe",in:Of(t),out:e})}Ae(Jd());var Bi="2025-11-25";var jf=[Bi,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],It="io.modelcontextprotocol/related-task",Po="2.0",le=Df(t=>t!==null&&(typeof t=="object"||typeof t=="function")),Lf=Y([h(),W().int()]),Uf=h(),pR=xe({ttl:W().optional(),pollInterval:W().optional()}),BS=k({ttl:W().optional()}),KS=k({taskId:h()}),Ki=xe({progressToken:Lf.optional(),[It]:KS.optional()}),Ce=k({_meta:Ki.optional()}),tn=Ce.extend({task:BS.optional()}),qf=t=>tn.safeParse(t).success,fe=k({method:h(),params:Ce.loose().optional()}),Le=k({_meta:Ki.optional()}),Ue=k({method:h(),params:Le.loose().optional()}),me=xe({_meta:Ki.optional()}),To=Y([h(),W().int()]),Zf=k({jsonrpc:P(Po),id:To,...fe.shape}).strict(),Gi=t=>Zf.safeParse(t).success,Ff=k({jsonrpc:P(Po),...Ue.shape}).strict(),Hf=t=>Ff.safeParse(t).success,Ji=k({jsonrpc:P(Po),id:To,result:me}).strict(),rn=t=>Ji.safeParse(t).success;var N;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(N||(N={}));var Yi=k({jsonrpc:P(Po),id:To.optional(),error:k({code:W().int(),message:h(),data:re().optional()})}).strict();var Wf=t=>Yi.safeParse(t).success;var Vf=Y([Zf,Ff,Ji,Yi]),fR=Y([Ji,Yi]),zo=me.strict(),GS=Le.extend({requestId:To.optional(),reason:h().optional()}),Ro=Ue.extend({method:P("notifications/cancelled"),params:GS}),JS=k({src:h(),mimeType:h().optional(),sizes:D(h()).optional(),theme:Te(["light","dark"]).optional()}),nn=k({icons:D(JS).optional()}),dr=k({name:h(),title:h().optional()}),Bf=dr.extend({...dr.shape,...nn.shape,version:h(),websiteUrl:h().optional(),description:h().optional()}),YS=xo(k({applyDefaults:de().optional()}),K(h(),re())),XS=Wi(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,xo(k({form:YS.optional(),url:le.optional()}),K(h(),re()).optional())),QS=xe({list:le.optional(),cancel:le.optional(),requests:xe({sampling:xe({createMessage:le.optional()}).optional(),elicitation:xe({create:le.optional()}).optional()}).optional()}),ev=xe({list:le.optional(),cancel:le.optional(),requests:xe({tools:xe({call:le.optional()}).optional()}).optional()}),tv=k({experimental:K(h(),le).optional(),sampling:k({context:le.optional(),tools:le.optional()}).optional(),elicitation:XS.optional(),roots:k({listChanged:de().optional()}).optional(),tasks:QS.optional(),extensions:K(h(),le).optional()}),rv=Ce.extend({protocolVersion:h(),capabilities:tv,clientInfo:Bf}),Xi=fe.extend({method:P("initialize"),params:rv});var nv=k({experimental:K(h(),le).optional(),logging:le.optional(),completions:le.optional(),prompts:k({listChanged:de().optional()}).optional(),resources:k({subscribe:de().optional(),listChanged:de().optional()}).optional(),tools:k({listChanged:de().optional()}).optional(),tasks:ev.optional(),extensions:K(h(),le).optional()}),ov=me.extend({protocolVersion:h(),capabilities:nv,serverInfo:Bf,instructions:h().optional()}),Qi=Ue.extend({method:P("notifications/initialized"),params:Le.optional()});var Io=fe.extend({method:P("ping"),params:Ce.optional()}),sv=k({progress:W(),total:ne(W()),message:ne(h())}),iv=k({...Le.shape,...sv.shape,progressToken:Lf}),Oo=Ue.extend({method:P("notifications/progress"),params:iv}),av=Ce.extend({cursor:Uf.optional()}),on=fe.extend({params:av.optional()}),sn=me.extend({nextCursor:Uf.optional()}),cv=Te(["working","input_required","completed","failed","cancelled"]),an=k({taskId:h(),status:cv,ttl:Y([W(),zf()]),createdAt:h(),lastUpdatedAt:h(),pollInterval:ne(W()),statusMessage:ne(h())}),pr=me.extend({task:an}),uv=Le.merge(an),cn=Ue.extend({method:P("notifications/tasks/status"),params:uv}),Ao=fe.extend({method:P("tasks/get"),params:Ce.extend({taskId:h()})}),Mo=me.merge(an),Co=fe.extend({method:P("tasks/result"),params:Ce.extend({taskId:h()})}),mR=me.loose(),No=on.extend({method:P("tasks/list")}),Do=sn.extend({tasks:D(an)}),jo=fe.extend({method:P("tasks/cancel"),params:Ce.extend({taskId:h()})}),Kf=me.merge(an),Gf=k({uri:h(),mimeType:ne(h()),_meta:K(h(),re()).optional()}),Jf=Gf.extend({text:h()}),ea=h().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Yf=Gf.extend({blob:ea}),un=Te(["user","assistant"]),fr=k({audience:D(un).optional(),priority:W().min(0).max(1).optional(),lastModified:Qr.datetime({offset:!0}).optional()}),Xf=k({...dr.shape,...nn.shape,uri:h(),description:ne(h()),mimeType:ne(h()),size:ne(W()),annotations:fr.optional(),_meta:ne(xe({}))}),lv=k({...dr.shape,...nn.shape,uriTemplate:h(),description:ne(h()),mimeType:ne(h()),annotations:fr.optional(),_meta:ne(xe({}))}),dv=on.extend({method:P("resources/list")}),pv=sn.extend({resources:D(Xf)}),fv=on.extend({method:P("resources/templates/list")}),mv=sn.extend({resourceTemplates:D(lv)}),ta=Ce.extend({uri:h()}),hv=ta,gv=fe.extend({method:P("resources/read"),params:hv}),_v=me.extend({contents:D(Y([Jf,Yf]))}),yv=Ue.extend({method:P("notifications/resources/list_changed"),params:Le.optional()}),Sv=ta,vv=fe.extend({method:P("resources/subscribe"),params:Sv}),bv=ta,Ev=fe.extend({method:P("resources/unsubscribe"),params:bv}),wv=Le.extend({uri:h()}),kv=Ue.extend({method:P("notifications/resources/updated"),params:wv}),xv=k({name:h(),description:ne(h()),required:ne(de())}),$v=k({...dr.shape,...nn.shape,description:ne(h()),arguments:ne(D(xv)),_meta:ne(xe({}))}),Pv=on.extend({method:P("prompts/list")}),Tv=sn.extend({prompts:D($v)}),zv=Ce.extend({name:h(),arguments:K(h(),h()).optional()}),Rv=fe.extend({method:P("prompts/get"),params:zv}),ra=k({type:P("text"),text:h(),annotations:fr.optional(),_meta:K(h(),re()).optional()}),na=k({type:P("image"),data:ea,mimeType:h(),annotations:fr.optional(),_meta:K(h(),re()).optional()}),oa=k({type:P("audio"),data:ea,mimeType:h(),annotations:fr.optional(),_meta:K(h(),re()).optional()}),Iv=k({type:P("tool_use"),name:h(),id:h(),input:K(h(),re()),_meta:K(h(),re()).optional()}),Ov=k({type:P("resource"),resource:Y([Jf,Yf]),annotations:fr.optional(),_meta:K(h(),re()).optional()}),Av=Xf.extend({type:P("resource_link")}),sa=Y([ra,na,oa,Av,Ov]),Mv=k({role:un,content:sa}),Cv=me.extend({description:h().optional(),messages:D(Mv)}),Nv=Ue.extend({method:P("notifications/prompts/list_changed"),params:Le.optional()}),Dv=k({title:h().optional(),readOnlyHint:de().optional(),destructiveHint:de().optional(),idempotentHint:de().optional(),openWorldHint:de().optional()}),jv=k({taskSupport:Te(["required","optional","forbidden"]).optional()}),Qf=k({...dr.shape,...nn.shape,description:h().optional(),inputSchema:k({type:P("object"),properties:K(h(),le).optional(),required:D(h()).optional()}).catchall(re()),outputSchema:k({type:P("object"),properties:K(h(),le).optional(),required:D(h()).optional()}).catchall(re()).optional(),annotations:Dv.optional(),execution:jv.optional(),_meta:K(h(),re()).optional()}),ia=on.extend({method:P("tools/list")}),Lv=sn.extend({tools:D(Qf)}),Lo=me.extend({content:D(sa).default([]),structuredContent:K(h(),re()).optional(),isError:de().optional()}),hR=Lo.or(me.extend({toolResult:re()})),Uv=tn.extend({name:h(),arguments:K(h(),re()).optional()}),ln=fe.extend({method:P("tools/call"),params:Uv}),qv=Ue.extend({method:P("notifications/tools/list_changed"),params:Le.optional()}),gR=k({autoRefresh:de().default(!0),debounceMs:W().int().nonnegative().default(300)}),dn=Te(["debug","info","notice","warning","error","critical","alert","emergency"]),Zv=Ce.extend({level:dn}),aa=fe.extend({method:P("logging/setLevel"),params:Zv}),Fv=Le.extend({level:dn,logger:h().optional(),data:re()}),Hv=Ue.extend({method:P("notifications/message"),params:Fv}),Wv=k({name:h().optional()}),Vv=k({hints:D(Wv).optional(),costPriority:W().min(0).max(1).optional(),speedPriority:W().min(0).max(1).optional(),intelligencePriority:W().min(0).max(1).optional()}),Bv=k({mode:Te(["auto","required","none"]).optional()}),Kv=k({type:P("tool_result"),toolUseId:h().describe("The unique identifier for the corresponding tool call."),content:D(sa).default([]),structuredContent:k({}).loose().optional(),isError:de().optional(),_meta:K(h(),re()).optional()}),Gv=Hi("type",[ra,na,oa]),$o=Hi("type",[ra,na,oa,Iv,Kv]),Jv=k({role:un,content:Y([$o,D($o)]),_meta:K(h(),re()).optional()}),Yv=tn.extend({messages:D(Jv),modelPreferences:Vv.optional(),systemPrompt:h().optional(),includeContext:Te(["none","thisServer","allServers"]).optional(),temperature:W().optional(),maxTokens:W().int(),stopSequences:D(h()).optional(),metadata:le.optional(),tools:D(Qf).optional(),toolChoice:Bv.optional()}),Xv=fe.extend({method:P("sampling/createMessage"),params:Yv}),pn=me.extend({model:h(),stopReason:ne(Te(["endTurn","stopSequence","maxTokens"]).or(h())),role:un,content:Gv}),ca=me.extend({model:h(),stopReason:ne(Te(["endTurn","stopSequence","maxTokens","toolUse"]).or(h())),role:un,content:Y([$o,D($o)])}),Qv=k({type:P("boolean"),title:h().optional(),description:h().optional(),default:de().optional()}),eb=k({type:P("string"),title:h().optional(),description:h().optional(),minLength:W().optional(),maxLength:W().optional(),format:Te(["email","uri","date","date-time"]).optional(),default:h().optional()}),tb=k({type:Te(["number","integer"]),title:h().optional(),description:h().optional(),minimum:W().optional(),maximum:W().optional(),default:W().optional()}),rb=k({type:P("string"),title:h().optional(),description:h().optional(),enum:D(h()),default:h().optional()}),nb=k({type:P("string"),title:h().optional(),description:h().optional(),oneOf:D(k({const:h(),title:h()})),default:h().optional()}),ob=k({type:P("string"),title:h().optional(),description:h().optional(),enum:D(h()),enumNames:D(h()).optional(),default:h().optional()}),sb=Y([rb,nb]),ib=k({type:P("array"),title:h().optional(),description:h().optional(),minItems:W().optional(),maxItems:W().optional(),items:k({type:P("string"),enum:D(h())}),default:D(h()).optional()}),ab=k({type:P("array"),title:h().optional(),description:h().optional(),minItems:W().optional(),maxItems:W().optional(),items:k({anyOf:D(k({const:h(),title:h()}))}),default:D(h()).optional()}),cb=Y([ib,ab]),ub=Y([ob,sb,cb]),lb=Y([ub,Qv,eb,tb]),db=tn.extend({mode:P("form").optional(),message:h(),requestedSchema:k({type:P("object"),properties:K(h(),lb),required:D(h()).optional()})}),pb=tn.extend({mode:P("url"),message:h(),elicitationId:h(),url:h().url()}),fb=Y([db,pb]),mb=fe.extend({method:P("elicitation/create"),params:fb}),hb=Le.extend({elicitationId:h()}),gb=Ue.extend({method:P("notifications/elicitation/complete"),params:hb}),mr=me.extend({action:Te(["accept","decline","cancel"]),content:Wi(t=>t===null?void 0:t,K(h(),Y([h(),W(),de(),D(h())])).optional())}),_b=k({type:P("ref/resource"),uri:h()});var yb=k({type:P("ref/prompt"),name:h()}),Sb=Ce.extend({ref:Y([yb,_b]),argument:k({name:h(),value:h()}),context:k({arguments:K(h(),h()).optional()}).optional()}),vb=fe.extend({method:P("completion/complete"),params:Sb});var bb=me.extend({completion:xe({values:D(h()).max(100),total:ne(W().int()),hasMore:ne(de())})}),Eb=k({uri:h().startsWith("file://"),name:h().optional(),_meta:K(h(),re()).optional()}),wb=fe.extend({method:P("roots/list"),params:Ce.optional()}),ua=me.extend({roots:D(Eb)}),kb=Ue.extend({method:P("notifications/roots/list_changed"),params:Le.optional()}),_R=Y([Io,Xi,vb,aa,Rv,Pv,dv,fv,gv,vv,Ev,ln,ia,Ao,Co,No,jo]),yR=Y([Ro,Oo,Qi,kb,cn]),SR=Y([zo,pn,ca,mr,ua,Mo,Do,pr]),vR=Y([Io,Xv,mb,wb,Ao,Co,No,jo]),bR=Y([Ro,Oo,Hv,kv,yv,qv,Nv,cn,gb]),ER=Y([zo,ov,bb,Cv,Tv,pv,mv,_v,Lo,Lv,Mo,Do,pr]),I=class t extends Error{constructor(e,r,n){super(`MCP error ${e}: ${r}`),this.code=e,this.data=n,this.name="McpError"}static fromError(e,r,n){if(e===N.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new Vi(o.elicitations,r)}return new t(e,r,n)}},Vi=class extends I{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(N.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Ot(t){return t==="completed"||t==="failed"||t==="cancelled"}var tI=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function la(t){let r=wo(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=nf(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function da(t,e){let r=Rt(t,e);if(!r.success)throw r.error;return r.data}var Rb=6e4,Uo=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Ro,r=>{this._oncancel(r)}),this.setNotificationHandler(Oo,r=>{this._onprogress(r)}),this.setRequestHandler(Io,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ao,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(N.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Co,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,p=new I(d.error.code,d.error.message,d.error.data);l(p)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new I(N.InvalidParams,`Task not found: ${s}`);if(!Ot(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Ot(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[It]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(No,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 I(N.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(jo,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new I(N.InvalidParams,`Task not found: ${r.params.taskId}`);if(Ot(o.status))throw new I(N.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new I(N.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof I?o:new I(N.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,r,n,o,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(e){let r=this._timeoutInfo.get(e);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(e),I.fromError(N.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(e){let r=this._timeoutInfo.get(e);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=e;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),rn(s)||Wf(s)?this._onresponse(s):Gi(s)?this._onrequest(s,i):Hf(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=I.fromError(N.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of e.values())n(r)}_onerror(e){this.onerror?.(e)}_onnotification(e){let r=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(e)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(e,r){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,o=this._transport,s=e.params?._meta?.[It]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:N.MethodNotFound,message:"Method not found"}};s&&this._taskMessageQueue?this._enqueueTaskMessage(s,{type:"error",message:l,timestamp:Date.now()},o?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):o?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a=qf(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:e.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,p)=>{if(i.signal.aborted)throw new I(N.ConnectionClosed,"Request was cancelled");let f={...p,relatedRequestId:e.id};s&&!f.relatedTask&&(f.relatedTask={taskId:s});let m=f.relatedTask?.taskId??s;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,f)},authInfo:r?.authInfo,requestId:e.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"response",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)},async l=>{if(i.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:N.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};s&&this._taskMessageQueue?await this._enqueueTaskMessage(s,{type:"error",message:d,timestamp:Date.now()},o?.sessionId):await o?.send(d)}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===i&&this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:r,...n}=e.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(e){let r=Number(e.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),rn(e))n(e);else{let i=new I(e.error.code,e.error.message,e.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(rn(e)&&e.result&&typeof e.result=="object"){let i=e.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),rn(e))o(e);else{let i=I.fromError(e.error.code,e.error.message,e.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(e,r,n)}}catch(i){yield{type:"error",error:i instanceof I?i:new I(N.InternalError,String(i))}}return}let s;try{let i=await this.request(e,pr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new I(N.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Ot(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new I(N.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new I(N.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 I?i:new I(N.InternalError,String(i))}}}request(e,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=E=>{l(E)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),a&&this.assertTaskCapability(e.method)}catch(E){d(E);return}n?.signal?.throwIfAborted();let p=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:p};n?.onprogress&&(this._progressHandlers.set(p,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),a&&(f.params={...f.params,task:a}),c&&(f.params={...f.params,_meta:{...f.params?._meta||{},[It]:c}});let m=E=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(E)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch($=>this._onerror(new Error(`Failed to send cancellation: ${$}`)));let v=E instanceof I?E:new I(N.RequestTimeout,String(E));l(v)};this._responseHandlers.set(p,E=>{if(!n?.signal?.aborted){if(E instanceof Error)return l(E);try{let v=Rt(r,E.result);v.success?u(v.data):l(v.error)}catch(v){l(v)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let _=n?.timeout??Rb,S=()=>m(I.fromError(N.RequestTimeout,"Request timed out",{timeout:_}));this._setupTimeout(p,_,n?.maxTotalTimeout,S,n?.resetTimeoutOnProgress??!1);let b=c?.taskId;if(b){let E=v=>{let $=this._responseHandlers.get(p);$?$(v):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,E),this._enqueueTaskMessage(b,{type:"request",message:f,timestamp:Date.now()}).catch(v=>{this._cleanupTimeout(p),l(v)})}else this._transport.send(f,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(E=>{this._cleanupTimeout(p),l(E)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},Mo,r)}async getTaskResult(e,r,n){return this.request({method:"tasks/result",params:e},r,n)}async listTasks(e,r){return this.request({method:"tasks/list",params:e},Do,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Kf,r)}async notification(e,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let n=r?.relatedTask?.taskId;if(n){let a={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[It]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let a={...e,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[It]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...e,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[It]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=la(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=da(e,o);return Promise.resolve(r(i,s))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,r){let n=la(e);this._notificationHandlers.set(n,o=>{let s=da(e,o);return Promise.resolve(r(s))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let r=this._taskProgressTokens.get(e);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,r,n,o)}async _clearTaskQueue(e,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,r);for(let o of n)if(o.type==="request"&&Gi(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new I(N.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(e);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new I(N.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new I(N.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(e,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!e)throw new Error("No request provided");return await n.createTask(o,e.id,{method:e.method,params:e.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new I(N.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=cn.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Ot(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 I(N.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Ot(a.status))throw new I(N.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=cn.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Ot(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function em(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function tm(t,e){let r={...t};for(let n in e){let o=n,s=e[o];if(s===void 0)continue;let i=r[o];em(i)&&em(s)?r[o]={...i,...s}:r[o]=s}return r}var qg=xt(Jc(),1),Zg=xt(Ug(),1);function v$(){let t=new qg.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Zg.default)(t),t}var ws=class{constructor(e){this._ajv=e??v$()}getValidator(e){let r="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var ks=class{constructor(e){this._server=e}requestStream(e,r,n){return this._server.requestStream(e,r,n)}createMessageStream(e,r){let n=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(s.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},pn,r)}elicitInputStream(e,r){let n=this._server.getClientCapabilities(),o=e.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:s},mr,r)}async getTask(e,r){return this._server.getTask({taskId:e},r)}async getTaskResult(e,r,n){return this._server.getTaskResult({taskId:e},r,n)}async listTasks(e,r){return this._server.listTasks(e?{cursor:e}:void 0,r)}async cancelTask(e,r){return this._server.cancelTask({taskId:e},r)}};function Fg(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"tools/call":if(!t.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${e})`);break;default:break}}function Hg(t,e,r){if(!t)throw new Error(`${r} does not support task creation (required for ${e})`);switch(e){case"sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${e})`);break;case"elicitation/create":if(!t.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${e})`);break;default:break}}var xs=class extends Uo{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(dn.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 ws,this.setRequestHandler(Xi,n=>this._oninitialize(n)),this.setNotificationHandler(Qi,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(aa,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=dn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new ks(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=tm(this._capabilities,e)}setRequestHandler(e,r){let o=wo(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(lr(o)){let a=o;s=a._zod?.def?.value??a.value}else{let a=o;s=a._def?.value??a.value}if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Rt(ln,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new I(N.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let m=Rt(pr,p);if(!m.success){let _=m.error instanceof Error?m.error.message:String(m.error);throw new I(N.InvalidParams,`Invalid task creation result: ${_}`)}return m.data}let f=Rt(Lo,p);if(!f.success){let m=f.error instanceof Error?f.error.message:String(f.error);throw new I(N.InvalidParams,`Invalid tools/call result: ${m}`)}return f.data};return super.setRequestHandler(e,a)}return super.setRequestHandler(e,r)}assertCapabilityForMethod(e){switch(e){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;case"ping":break}}assertNotificationCapability(e){switch(e){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;case"ping":case"initialize":break}}assertTaskCapability(e){Hg(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&Fg(this._capabilities.tasks?.requests,e,"Server")}async _oninitialize(e){let r=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:jf.includes(r)?r:Bi,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"},zo)}async createMessage(e,r){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let n=e.messages[e.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=e.messages.length>1?e.messages[e.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},ca,r):this.request({method:"sampling/createMessage",params:e},pn,r)}async elicitInput(e,r){switch(e.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=e;return this.request({method:"elicitation/create",params:o},mr,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=e.mode==="form"?e:{...e,mode:"form"},s=await this.request({method:"elicitation/create",params:o},mr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new I(N.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof I?i:new I(N.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(e,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},r)}async listRoots(e,r){return this.request({method:"roots/list",params:e},ua,r)}async sendLoggingMessage(e,r){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,r))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var ou=xt(require("node:process"),1);var $s=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
81
|
+
`);if(e===-1)return null;let r=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),b$(r)}clear(){this._buffer=void 0}};function b$(t){return Vf.parse(JSON.parse(t))}function Wg(t){return JSON.stringify(t)+`
|
|
82
|
+
`}var Ps=class{constructor(e=ou.default.stdin,r=ou.default.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new $s,this._started=!1,this._ondata=n=>{this._readBuffer.append(n),this.processReadBuffer()},this._onerror=n=>{this.onerror?.(n)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e)}catch(e){this.onerror?.(e)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(e){return new Promise(r=>{let n=Wg(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Us=xt(require("path"),1),Ar=require("fs");var Vg=require("node:child_process");function Ts(t,e,r){return(0,Vg.spawn)(t,e??[],{windowsHide:!0,...r})}var ce={DEFAULT:3e5,HEALTH_CHECK:3e3,API_REQUEST:3e4,HOOK_READINESS_WAIT:1e4,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,WORKER_STARTUP_WAIT:1e3,PRE_RESTART_SETTLE_DELAY:2e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5};function bt(t){return process.platform==="win32"?Math.round(t*ce.WINDOWS_MULTIPLIER):t}var ut=require("fs"),Fn=require("path"),su=require("os");var Et=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5-20251001",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:String(37700+(process.getuid?.()??77)%100),CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_API_TIMEOUT_MS:String(bt(ce.API_REQUEST)),CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"subscription",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-2.5-flash-lite",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_GEMINI_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_GEMINI_MAX_TOKENS:"100000",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_BASE_URL:"",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_OPENROUTER_MAX_CONTEXT_MESSAGES:"20",CLAUDE_MEM_OPENROUTER_MAX_TOKENS:"100000",CLAUDE_MEM_DATA_DIR:(0,Fn.join)((0,su.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_MODE:"code",CLAUDE_MEM_CONTEXT_SHOW_READ_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_WORK_TOKENS:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_AMOUNT:"false",CLAUDE_MEM_CONTEXT_SHOW_SAVINGS_PERCENT:"true",CLAUDE_MEM_CONTEXT_FULL_COUNT:"0",CLAUDE_MEM_CONTEXT_FULL_FIELD:"narrative",CLAUDE_MEM_CONTEXT_SESSION_COUNT:"10",CLAUDE_MEM_CONTEXT_SHOW_LAST_SUMMARY:"true",CLAUDE_MEM_CONTEXT_SHOW_LAST_MESSAGE:"false",CLAUDE_MEM_CONTEXT_SHOW_TERMINAL_OUTPUT:"true",CLAUDE_MEM_WELCOME_HINT_ENABLED:"true",CLAUDE_MEM_FOLDER_CLAUDEMD_ENABLED:"false",CLAUDE_MEM_FOLDER_USE_LOCAL_MD:"false",CLAUDE_MEM_TRANSCRIPTS_ENABLED:"true",CLAUDE_MEM_TRANSCRIPTS_CONFIG_PATH:(0,Fn.join)((0,su.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_FOLDER_MD_SKELETON_DENYLIST:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_TIER_FAST_MODEL:"haiku",CLAUDE_MEM_TIER_SMART_MODEL:"sonnet",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_CHROMA_MODE:"local",CLAUDE_MEM_CHROMA_HOST:"127.0.0.1",CLAUDE_MEM_CHROMA_PORT:"8000",CLAUDE_MEM_CHROMA_SSL:"false",CLAUDE_MEM_CHROMA_API_KEY:"",CLAUDE_MEM_CHROMA_TENANT:"default_tenant",CLAUDE_MEM_CHROMA_DATABASE:"default_database",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_QUEUE_ENGINE:"sqlite",CLAUDE_MEM_REDIS_URL:"",CLAUDE_MEM_REDIS_HOST:"127.0.0.1",CLAUDE_MEM_REDIS_PORT:"6379",CLAUDE_MEM_REDIS_MODE:"external",CLAUDE_MEM_QUEUE_REDIS_PREFIX:`claude_mem_${process.env.CLAUDE_MEM_WORKER_PORT??String(37700+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_AUTH_MODE:"api-key",CLAUDE_MEM_RUNTIME:"worker",CLAUDE_MEM_SERVER_BETA_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_BETA_API_KEY:"",CLAUDE_MEM_SERVER_BETA_PROJECT_ID:""};static getAllDefaults(){return{...this.DEFAULTS}}static get(e){return process.env[e]??this.DEFAULTS[e]}static getInt(e){let r=this.get(e);return parseInt(r,10)}static getBool(e){let r=this.get(e);return r==="true"||r===!0}static applyEnvOverrides(e){let r={...e};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(e,r=!0){try{if(!(0,ut.existsSync)(e)){let a=this.getAllDefaults();try{let c=(0,Fn.dirname)(e);(0,ut.existsSync)(c)||(0,ut.mkdirSync)(c,{recursive:!0}),(0,ut.writeFileSync)(e,JSON.stringify(a,null,2),"utf-8"),console.warn("[SETTINGS] Created settings file with defaults:",e)}catch(c){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,c instanceof Error?c.message:String(c))}return r?this.applyEnvOverrides(a):a}let n=(0,ut.readFileSync)(e,"utf-8"),o=JSON.parse(n.replace(/^\uFEFF/,"")),s=o;if(o.env&&typeof o.env=="object"){s=o.env;try{(0,ut.writeFileSync)(e,JSON.stringify(s,null,2),"utf-8"),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(a){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,a instanceof Error?a.message:String(a))}}let i={...this.DEFAULTS};for(let a of Object.keys(this.DEFAULTS))s[a]!==void 0&&(i[a]=s[a]);return r?this.applyEnvOverrides(i):i}catch(n){console.warn("[SETTINGS] Failed to load settings, using defaults:",e,n instanceof Error?n.message:String(n));let o=this.getAllDefaults();return r?this.applyEnvOverrides(o):o}}};var zs=null;function Rs(){return zs!==null||(zs=Et.loadFromFile(Du)),zs}var tr=require("fs");var lu=require("child_process");var lt=require("fs"),cu=xt(require("path"),1);var E$=["CLAUDECODE_","CLAUDE_CODE_"],w$=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID","HTTP_PROXY","HTTPS_PROXY","ALL_PROXY","NO_PROXY","http_proxy","https_proxy","all_proxy","no_proxy","npm_config_proxy","npm_config_https_proxy"]),k$=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","ANTHROPIC_BEDROCK_BASE_URL","AWS_REGION","AWS_PROFILE","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_SESSION_TOKEN","ANTHROPIC_VERTEX_PROJECT_ID","CLOUD_ML_REGION","GOOGLE_APPLICATION_CREDENTIALS"]);function Hn(t=process.env){let e={};for(let[r,n]of Object.entries(t))if(n!==void 0){if(k$.has(r)){e[r]=n;continue}w$.has(r)||E$.some(o=>r.startsWith(o))||(e[r]=n)}return e}var x$=5e3,$$=1e3,P$=De.supervisorRegistry();function wt(t){if(!Number.isInteger(t)||t<0||t===0)return!1;try{return process.kill(t,0),!0}catch(e){if(e instanceof Error){let r=e.code;return r==="EPERM"?!0:(y.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return y.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}async function Is(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.every(n=>!wt(n.pid)))return;await new Promise(n=>setTimeout(n,100))}}var T$=5e3,Bg=new Map;function z$(t){let e=Bg.get(t);if(e&&Date.now()-e.capturedAtMs<T$)return e.token;let r=null;try{let n=(0,lu.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${t}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...Hn(process.env),LC_ALL:"C",LANG:"C"}});if(n.status===0){let o=n.stdout.trim();r=o.length>0?o:null}}catch(n){y.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:t,error:n instanceof Error?n.message:String(n)}),r=null}return Bg.set(t,{token:r,capturedAtMs:Date.now()}),r}function Kg(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=(0,lt.readFileSync)(`/proc/${t}/stat`,"utf-8"),r=e.lastIndexOf(") ");if(r<0)return null;let o=e.slice(r+2).split(" ")[19];return o&&/^\d+$/.test(o)?o:null}catch(e){return y.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return z$(t);try{let e=(0,lu.spawnSync)("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...Hn(process.env),LC_ALL:"C",LANG:"C"}});if(e.status!==0)return null;let r=e.stdout.trim();return r.length>0?r:null}catch(e){return y.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function du(t){if(!t||!wt(t.pid))return!1;if(!t.startToken)return!0;let e=Kg(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||y.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}var uu=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=P$){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,lt.mkdirSync)(cu.default.dirname(this.registryPath),{recursive:!0}),!(0,lt.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,lt.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?y.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):y.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&y.info("SYSTEM","Removed dead processes from supervisor registry",{removed:e}),this.persist()}register(e,r,n){this.initialize(),this.entries.set(e,r),n&&this.runtimeProcesses.set(e,n),this.persist()}unregister(e){this.initialize();let r=this.entries.get(e);this.entries.delete(e),this.runtimeProcesses.delete(e),this.persist(),r?.type==="sdk"&&au()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([e,r])=>({id:e,...r})).sort((e,r)=>{let n=Date.parse(e.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(e){let r=String(e);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(e){return this.runtimeProcesses.get(e)}getByPid(e){return this.getAll().filter(r=>r.pid===e)}pruneDeadEntries(){this.initialize();let e=0,r=0;for(let[n,o]of this.entries)wt(o.pid)||(this.entries.delete(n),this.runtimeProcesses.delete(n),e+=1,o.type==="sdk"&&(r+=1));e>0&&this.persist();for(let n=0;n<r;n+=1)au();return e}async reapSession(e){this.initialize();let r=this.getBySession(e);if(r.length===0)return 0;let n=typeof e=="number"?e:Number(e)||void 0;y.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:n,pids:r.map(i=>i.pid)});let o=r.filter(i=>wt(i.pid));for(let i of o)try{typeof i.pgid=="number"&&process.platform!=="win32"?process.kill(-i.pgid,"SIGTERM"):process.kill(i.pid,"SIGTERM")}catch(a){a instanceof Error?a.code!=="ESRCH"&&y.debug("SYSTEM",`Failed to SIGTERM session process PID ${i.pid}`,{pid:i.pid,pgid:i.pgid},a):y.warn("SYSTEM",`Failed to SIGTERM session process PID ${i.pid} (non-Error)`,{pid:i.pid,pgid:i.pgid,error:String(a)})}await Is(o,x$);let s=o.filter(i=>wt(i.pid));for(let i of s){y.warn("SYSTEM",`Session process PID ${i.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:i.pid,pgid:i.pgid,sessionId:n});try{typeof i.pgid=="number"&&process.platform!=="win32"?process.kill(-i.pgid,"SIGKILL"):process.kill(i.pid,"SIGKILL")}catch(a){a instanceof Error?a.code!=="ESRCH"&&y.debug("SYSTEM",`Failed to SIGKILL session process PID ${i.pid}`,{pid:i.pid,pgid:i.pgid},a):y.warn("SYSTEM",`Failed to SIGKILL session process PID ${i.pid} (non-Error)`,{pid:i.pid,pgid:i.pgid,error:String(a)})}}if(s.length>0){let i=Date.now()+$$;for(;Date.now()<i&&s.filter(c=>wt(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100))}for(let i of r)this.entries.delete(i.id),this.runtimeProcesses.delete(i.id);this.persist();for(let i of r)i.type==="sdk"&&au();return y.info("SYSTEM",`Reaped ${r.length} process(es) for session ${e}`,{sessionId:n,reaped:r.length}),r.length}persist(){let e={processes:Object.fromEntries(this.entries.entries())};(0,lt.mkdirSync)(cu.default.dirname(this.registryPath),{recursive:!0}),(0,lt.writeFileSync)(this.registryPath,JSON.stringify(e,null,2))}},iu=null;function Os(){return iu||(iu=new uu),iu}var R$=[];function au(){let t=R$.shift();t&&t()}var Jg=require("child_process"),Ir=require("fs"),Yg=require("util");var I$=(0,Yg.promisify)(Jg.execFile),O$=De.workerPid();async function Xg(t){let e=t.currentPid??process.pid,r=t.pidFilePath??O$,n=t.registry.getAll(),o=[...n].filter(i=>i.pid!==e).sort((i,a)=>Date.parse(a.startedAt)-Date.parse(i.startedAt));for(let i of o){if(!wt(i.pid)){t.registry.unregister(i.id);continue}try{await Gg(i,"SIGTERM")}catch(a){a instanceof Error?y.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):y.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}}await Is(o,5e3);let s=o.filter(i=>wt(i.pid));for(let i of s)try{await Gg(i,"SIGKILL")}catch(a){a instanceof Error?y.debug("SYSTEM","Failed to force kill child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):y.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}await Is(s,1e3);for(let i of o)t.registry.unregister(i.id);for(let i of n.filter(a=>a.pid===e))t.registry.unregister(i.id);A$(r,e),t.registry.pruneDeadEntries()}function A$(t,e){if(!(0,Ir.existsSync)(t))return;let r=null;try{let n=JSON.parse((0,Ir.readFileSync)(t,"utf-8"));r=typeof n.pid=="number"?n.pid:null}catch(n){y.debug("SYSTEM","PID file unreadable during shutdown \u2014 leaving it (cannot prove ownership)",{pidFilePath:t,error:n instanceof Error?n.message:String(n)});return}if(r!==e){y.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:t,recordedPid:r,currentPid:e});return}try{(0,Ir.rmSync)(t,{force:!0})}catch(n){n instanceof Error?y.debug("SYSTEM","Failed to remove PID file during shutdown",{pidFilePath:t},n):y.warn("SYSTEM","Failed to remove PID file during shutdown (non-Error)",{pidFilePath:t,error:String(n)})}}async function Gg(t,e){let{pid:r,pgid:n}=t;if(process.platform!=="win32"){if(typeof n=="number")try{process.kill(-n,e);return}catch(i){if((i instanceof Error?i.code:void 0)!=="ESRCH")throw i}try{process.kill(r,e)}catch(i){if((i instanceof Error?i.code:void 0)!=="ESRCH")throw i}return}if(e==="SIGTERM"){try{process.kill(r,e)}catch(i){if(i instanceof Error&&i.code==="ESRCH")return;throw i}return}let o=await M$();if(o){await new Promise((i,a)=>{o(r,e,c=>{if(!c){i();return}if(c.code==="ESRCH"){i();return}a(c)})});return}let s=["/PID",String(r),"/T"];e==="SIGKILL"&&s.push("/F"),await I$("taskkill",s,{timeout:ce.POWERSHELL_COMMAND,windowsHide:!0})}async function M$(){let t="tree-kill";try{let e=await import(t);return e.default??e}catch(e){return y.debug("SYSTEM","tree-kill module not available, using fallback",{},e instanceof Error?e:void 0),null}}var Qg=3e4,Or=null;function C$(){let e=Os().pruneDeadEntries();e>0&&y.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function e_(){Or===null&&(Or=setInterval(C$,Qg),Or.unref(),y.debug("SYSTEM","Health checker started",{intervalMs:Qg}))}function t_(){Or!==null&&(clearInterval(Or),Or=null,y.debug("SYSTEM","Health checker stopped"))}var N$=De.workerPid(),pu=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(e){this.registry=e}async start(){if(this.started)return;if(this.registry.initialize(),As({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,e_()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){y.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,y.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?y.error("SYSTEM","Error during shutdown",{},o):y.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?y.debug("SYSTEM","Supervisor shutdown fallback failed",{},s):y.debug("SYSTEM","Supervisor shutdown fallback failed",{error:String(s)})}}process.exit(0)};process.on("SIGTERM",()=>{r("SIGTERM")}),process.on("SIGINT",()=>{r("SIGINT")}),process.platform!=="win32"&&(process.argv.includes("--daemon")?process.on("SIGHUP",()=>{y.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}t_(),this.stopPromise=Xg({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(e){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${e}`)}registerProcess(e,r,n){this.registry.register(e,r,n)}unregisterProcess(e){this.registry.unregister(e)}getRegistry(){return this.registry}},D$=new pu(Os());function fu(){return D$}function As(t={}){let e=t.pidFilePath??N$;if(!(0,tr.existsSync)(e))return"missing";let r=null;try{r=JSON.parse((0,tr.readFileSync)(e,"utf-8"))}catch(o){return o instanceof Error?y.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},o):y.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(o)}),(0,tr.rmSync)(e,{force:!0}),"invalid"}return du(r)&&r?((t.logAlive??!0)&&y.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(y.info("SYSTEM","Removing stale PID file (worker process is dead or PID has been reused)",{pid:r?.pid,port:r?.port,startedAt:r?.startedAt}),(0,tr.rmSync)(e,{force:!0}),"stale")}var rr=xt(require("path"),1),s_=require("os"),Ne=require("fs"),Ms=require("child_process");function r_(t){return t instanceof Error?t:new Error(String(t))}var RN=De.dataDir(),n_=De.workerPid();function o_(t){return t?/(^|[\\/])bun(\.exe)?$/i.test(t.trim()):!1}function j$(t,e){let r=e==="win32"?`where ${t}`:`which ${t}`,n;try{n=(0,Ms.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?y.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},s):y.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},new Error(String(s))),null}return n.split(/\r?\n/).map(s=>s.trim()).find(s=>s.length>0)||null}var mu;function i_(t={}){let e=Object.keys(t).length===0;if(e&&mu!==void 0)return mu;let r=L$(t);return e&&r!==null&&(mu=r),r}function L$(t){let e=t.platform??process.platform,r=t.execPath??process.execPath;if(o_(r))return r;let n=t.env??process.env,o=t.homeDirectory??(0,s_.homedir)(),s=t.pathExists??Ne.existsSync,i=t.lookupInPath??j$,a=e==="win32"?[n.BUN,n.BUN_PATH,rr.default.join(o,".bun","bin","bun.exe"),rr.default.join(o,".bun","bin","bun"),n.USERPROFILE?rr.default.join(n.USERPROFILE,".bun","bin","bun.exe"):void 0,n.LOCALAPPDATA?rr.default.join(n.LOCALAPPDATA,"bun","bun.exe"):void 0,n.LOCALAPPDATA?rr.default.join(n.LOCALAPPDATA,"bun","bin","bun.exe"):void 0]:[n.BUN,n.BUN_PATH,rr.default.join(o,".bun","bin","bun"),"/usr/local/bin/bun","/opt/homebrew/bin/bun","/home/linuxbrew/.linuxbrew/bin/bun","/usr/bin/bun","/snap/bin/bun"];for(let c of a){let u=c?.trim();if(u&&(o_(u)&&s(u)||u.toLowerCase()==="bun"))return u}return i("bun",e)}function qt(t){return process.platform==="win32"?Math.round(t*2):t}function a_(t,e,r={}){fu().assertCanSpawn("worker daemon");let n=Hn({...process.env,CLAUDE_MEM_WORKER_PORT:String(e),...r}),o=i_();if(!o){y.error("SYSTEM","Bun runtime not found \u2014 install from https://bun.sh and ensure it is on PATH or set BUN env var. The worker daemon requires Bun because it uses bun:sqlite.");return}if(process.platform==="win32"){let l=`Start-Process -FilePath '${o.replace(/'/g,"''")}' -ArgumentList @('${t.replace(/'/g,"''")}','--daemon') -WindowStyle Hidden`,d=Buffer.from(l,"utf16le").toString("base64");try{return(0,Ms.execSync)(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:n}),0}catch(p){y.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:o},r_(p));return}}let s="/usr/bin/setsid",i=(0,Ne.existsSync)(s),u=Ts(i?s:o,i?[o,t,"--daemon"]:[t,"--daemon"],{detached:!0,stdio:"ignore",env:n});if(u.pid!==void 0)return u.unref(),u.pid}function c_(){try{if(!(0,Ne.existsSync)(n_))return;let t=new Date;(0,Ne.utimesSync)(n_,t,t)}catch{}}function u_(){return As({logAlive:!1})}var l_=xt(require("net"),1);async function U$(t,e,r="GET"){let n=await fetch(`http://127.0.0.1:${t}${e}`,{method:r}),o="";try{o=await n.text()}catch{}return{ok:n.ok,statusCode:n.status,body:o}}async function d_(t){if(process.platform==="win32")try{return(await fetch(`http://127.0.0.1:${t}/api/health`)).ok}catch(e){return e instanceof Error?y.debug("SYSTEM","Windows health check failed (port not in use)",{},e):y.debug("SYSTEM","Windows health check failed (port not in use)",{error:String(e)}),!1}return new Promise(e=>{let r=l_.default.createServer();r.once("error",n=>{n.code==="EADDRINUSE"?e(!0):e(!1)}),r.once("listening",()=>{r.close(()=>e(!1))}),r.listen(t,"127.0.0.1")})}async function p_(t,e,r,n){let o=Date.now();for(;Date.now()-o<r;){try{if((await U$(t,e)).ok)return!0}catch(s){s instanceof Error?y.debug("SYSTEM",n,{},s):y.debug("SYSTEM",n,{error:String(s)})}await new Promise(s=>setTimeout(s,500))}return!1}function Wn(t,e=3e4){return p_(t,"/api/health",e,"Service not ready yet, will retry")}function Vn(t,e=3e4){return p_(t,"/api/readiness",e,"Worker not ready yet, will retry")}var Cs=require("path"),We=require("fs");var q$=6e4;function f_(){return(0,Cs.join)(ro(),"spawn.lock")}function hu(){let t=f_(),e=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return(0,We.mkdirSync)((0,Cs.dirname)(t),{recursive:!0}),(0,We.writeFileSync)(t,e,{flag:"wx"}),!0}catch(n){if(n?.code!=="EEXIST")return!0;if(r>0)return!1;let s;try{s=(0,We.statSync)(t).mtimeMs}catch{continue}if(Date.now()-s<=q$)return!1;let i;try{i=(0,We.statSync)(t).mtimeMs}catch{continue}if(i!==s)return!1;try{(0,We.unlinkSync)(t)}catch{return!1}}return!1}function gu(){let t=f_();try{if(JSON.parse((0,We.readFileSync)(t,"utf-8")).pid!==process.pid)return;(0,We.unlinkSync)(t)}catch{}}function _u(t,e,r){let n=process.env[t];if(n){let o=parseInt(n,10);if(Number.isFinite(o)&&o>=r.min&&o<=r.max)return o;y.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max})}return e}var iD=_u("CLAUDE_MEM_HEALTH_TIMEOUT_MS",bt(ce.HEALTH_CHECK),{min:500,max:3e5}),aD=_u("CLAUDE_MEM_API_TIMEOUT_MS",bt(ce.API_REQUEST),{min:500,max:3e5}),cD=_u("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",bt(ce.HOOK_READINESS_WAIT),{min:0,max:3e5}),Z$={min:500,max:3e5};async function yu(t,e={},r){try{return await fetch(t,{...e,signal:AbortSignal.timeout(r)})}catch(n){throw n instanceof DOMException&&n.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):n}}var Ns=null,Ds=null,js=null,Ls=null;function F$(){return Us.default.join(Et.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function Su(){return js!==null||(js=Et.loadFromFile(F$())),js}function m_(t,e){if(!t)return null;let r=parseInt(t,10);return Number.isFinite(r)&&r>=e.min&&r<=e.max?r:null}function H$(t,e,r){let n=process.env[t];if(n!==void 0){let i=m_(n,r);return i!==null?i:(y.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max}),e)}let o=Su()[t],s=m_(o,r);return s!==null?s:(y.warn("SYSTEM",`Invalid ${t} in settings.json, using default`,{value:o,min:r.min,max:r.max}),e)}function vu(){if(Ns!==null)return Ns;let t=Su();return Ns=parseInt(t.CLAUDE_MEM_WORKER_PORT,10),Ns}function W$(){return Ds!==null||(Ds=Su().CLAUDE_MEM_WORKER_HOST),Ds}function V$(){return Ls!==null||(Ls=H$("CLAUDE_MEM_API_TIMEOUT_MS",bt(ce.API_REQUEST),Z$)),Ls}function B$(t){return`http://${W$()}:${vu()}${t}`}function qs(t,e={}){let r=e.method??"GET",n=e.timeoutMs??V$(),o=B$(t),s={method:r};return e.headers&&(s.headers=e.headers),e.body&&(s.body=e.body),n>0?yu(o,s,n):fetch(o,s)}function h_(){let t=[Us.default.join(Js,"plugin","scripts","worker-service.cjs"),Us.default.join(process.cwd(),"plugin","scripts","worker-service.cjs")];for(let e of t)if((0,Ar.existsSync)(e))return e;return null}var bu=xt(require("path"),1),Ve=require("fs");var K$=120*1e3;function Eu(){return bu.default.join(Et.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function G$(){if(process.platform!=="win32")return!1;let t=Eu();if(!(0,Ve.existsSync)(t))return!1;try{let e=(0,Ve.statSync)(t).mtimeMs;return Date.now()-e<K$}catch(e){return e instanceof Error?y.debug("SYSTEM","Could not stat worker spawn lock file",{},e):y.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(e)}),!1}}function J$(){if(process.platform==="win32")try{let t=Eu();(0,Ve.mkdirSync)(bu.default.dirname(t),{recursive:!0}),(0,Ve.writeFileSync)(t,"","utf-8")}catch{}}function Zs(){if(process.platform==="win32")try{let t=Eu();(0,Ve.existsSync)(t)&&(0,Ve.unlinkSync)(t)}catch{}}async function g_(t,e){if(!e)return y.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,Ve.existsSync)(e))return y.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:e}),"dead";if(u_()==="alive"){if(y.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await Wn(t,qt(ce.PORT_IN_USE_WAIT))){Zs();let a=await Vn(t,qt(ce.READINESS_WAIT));return y.info("SYSTEM","Worker became healthy while waiting on live PID"),a?"ready":"warming"}return y.warn("SYSTEM","Live PID detected but worker did not become healthy before timeout \u2014 likely still starting"),"warming"}if(await Wn(t,1e3)){Zs();let i=await Vn(t,qt(ce.READINESS_WAIT));return i||y.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),y.info("SYSTEM","Worker already running and healthy"),i?"ready":"warming"}if(await d_(t)){if(y.info("SYSTEM","Port in use, waiting for worker to become healthy"),await Wn(t,qt(ce.PORT_IN_USE_WAIT))){Zs();let a=await Vn(t,qt(ce.READINESS_WAIT));return y.info("SYSTEM","Worker is now healthy"),a?"ready":"warming"}return y.error("SYSTEM","Port in use but worker not responding to health checks"),"dead"}if(G$())return y.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";let o=hu();try{if(o){if(y.info("SYSTEM","Starting worker daemon",{workerScriptPath:e}),J$(),a_(e,t)===void 0)return y.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else y.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");if(!await Wn(t,qt(ce.POST_SPAWN_WAIT)))return y.warn("SYSTEM",o?"Worker spawned but health endpoint not responding within window \u2014 likely still starting in background":"Spawn-lock holder's worker not healthy within window \u2014 likely still starting in background"),"warming"}finally{o&&gu()}let s=await Vn(t,qt(ce.READINESS_WAIT));return s||y.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),Zs(),c_(),y.info("SYSTEM",o?"Worker started successfully":"Worker is up (started by another launcher)"),s?"ready":"warming"}var Nr=require("node:fs/promises"),Jn=require("node:path");var S_=require("node:child_process"),ye=require("node:fs"),ue=require("node:path"),Tu=require("node:os"),xu=require("node:module");var lP={},$u=typeof __filename<"u"?(0,xu.createRequire)(__filename):(0,xu.createRequire)(lP.url),Pu={".js":"javascript",".mjs":"javascript",".cjs":"javascript",".jsx":"tsx",".ts":"typescript",".tsx":"tsx",".py":"python",".pyw":"python",".go":"go",".rs":"rust",".rb":"ruby",".java":"java",".c":"c",".h":"c",".cpp":"cpp",".cc":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".kt":"kotlin",".kts":"kotlin",".swift":"swift",".php":"php",".ex":"elixir",".exs":"elixir",".lua":"lua",".scala":"scala",".sc":"scala",".sh":"bash",".bash":"bash",".zsh":"bash",".hs":"haskell",".zig":"zig",".css":"css",".scss":"scss",".toml":"toml",".yml":"yaml",".yaml":"yaml",".sql":"sql",".md":"markdown",".mdx":"markdown"};function v_(t,e){let r=t.slice(t.lastIndexOf("."));return Pu[r]?Pu[r]:e.extensionToLanguage[r]?e.extensionToLanguage[r]:"unknown"}function b_(t,e){return e.languageToQueryKey[t]?e.languageToQueryKey[t]:Q$(t)}var Bn=new Map,Mr={grammars:{},extensionToLanguage:{},languageToQueryKey:{}};function Gn(t){if(Bn.has(t))return Bn.get(t);let e=(0,ue.join)(t,".claude-mem.json"),r;try{let s=(0,ye.readFileSync)(e,"utf-8");r=JSON.parse(s)}catch{return Bn.set(t,Mr),Mr}let n=r.grammars;if(!n||typeof n!="object"||Array.isArray(n))return Bn.set(t,Mr),Mr;let o={grammars:{},extensionToLanguage:{},languageToQueryKey:{}};for(let[s,i]of Object.entries(n)){if(E_[s]||!i||typeof i!="object"||Array.isArray(i))continue;let a=i,c=a.package,u=a.extensions,l=a.query;if(!(typeof c!="string"||!Array.isArray(u))&&u.every(d=>typeof d=="string")){o.grammars[s]={package:c,extensions:u,query:typeof l=="string"?l:void 0};for(let d of u)Pu[d]||(o.extensionToLanguage[d]=s);if(typeof l=="string"){let d=(0,ue.join)(t,l);try{let p=(0,ye.readFileSync)(d,"utf-8"),f=`user_${s}`;k_[f]=p,o.languageToQueryKey[s]=f}catch{y.warn("PARSER","Custom query file not found, falling back to generic",{fullQueryPath:d}),o.languageToQueryKey[s]="generic"}}else o.languageToQueryKey[s]="generic"}}return Bn.set(t,o),o}var E_={javascript:"tree-sitter-javascript",typescript:"tree-sitter-typescript/typescript",tsx:"tree-sitter-typescript/tsx",python:"tree-sitter-python",go:"tree-sitter-go",rust:"tree-sitter-rust",ruby:"tree-sitter-ruby",java:"tree-sitter-java",c:"tree-sitter-c",cpp:"tree-sitter-cpp",kotlin:"tree-sitter-kotlin",swift:"tree-sitter-swift",php:"tree-sitter-php/php",elixir:"tree-sitter-elixir",lua:"@tree-sitter-grammars/tree-sitter-lua",scala:"tree-sitter-scala",bash:"tree-sitter-bash",haskell:"tree-sitter-haskell",zig:"@tree-sitter-grammars/tree-sitter-zig",css:"tree-sitter-css",scss:"tree-sitter-scss",toml:"@tree-sitter-grammars/tree-sitter-toml",yaml:"@tree-sitter-grammars/tree-sitter-yaml",sql:"@derekstride/tree-sitter-sql",markdown:"@tree-sitter-grammars/tree-sitter-markdown"},Y$={markdown:"tree-sitter-markdown"};function X$(t){let e=E_[t];if(!e)return null;let r=Y$[t];if(r){try{let n=$u.resolve(e+"/package.json"),o=(0,ue.join)((0,ue.dirname)(n),r);if((0,ye.existsSync)((0,ue.join)(o,"src")))return o}catch{}return null}try{let n=$u.resolve(e+"/package.json");return(0,ue.dirname)(n)}catch{return null}}function w_(t,e){let r=X$(t);if(r)return r;if(!e)return null;let o=Gn(e).grammars[t];if(!o)return null;try{let s=(0,ue.join)(e,"node_modules",o.package,"package.json");if((0,ye.existsSync)(s)){let i=(0,ue.dirname)(s);if((0,ye.existsSync)((0,ue.join)(i,"src")))return i}}catch{}return y.warn("PARSER","Grammar package not found",{language:t,package:o.package}),null}var k_={jsts:`
|
|
83
83
|
(function_declaration name: (identifier) @name) @func
|
|
84
84
|
(lexical_declaration (variable_declarator name: (identifier) @name value: [(arrow_function) (function_expression)])) @const_func
|
|
85
85
|
(class_declaration name: (type_identifier) @name) @cls
|
|
@@ -201,25 +201,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
201
201
|
(class_definition name: (identifier) @name) @cls
|
|
202
202
|
(import_statement) @imp
|
|
203
203
|
(import_declaration) @imp
|
|
204
|
-
`};function Q$(t){switch(t){case"javascript":return"js";case"typescript":case"tsx":return"jsts";case"python":return"python";case"go":return"go";case"rust":return"rust";case"ruby":return"ruby";case"java":return"java";case"kotlin":return"kotlin";case"swift":return"swift";case"php":return"php";case"elixir":return"generic";case"lua":return"lua";case"scala":return"scala";case"bash":return"bash";case"haskell":return"haskell";case"zig":return"zig";case"css":return"css";case"scss":return"scss";case"toml":return"toml";case"yaml":return"yaml";case"sql":return"sql";case"markdown":return"markdown";default:return"generic"}}var
|
|
205
|
-
`)){if(o.length>0&&!o.startsWith(" ")&&!o.startsWith(" ")){r=o.trim(),e.has(r)||e.set(r,[]),n=null;continue}if(!r)continue;let s=o.match(/^\s+pattern:\s+(\d+)/);if(s){n={pattern:parseInt(s[1]),captures:[]},e.get(r).push(n);continue}let i=o.match(/^\s+capture:\s+(?:\d+\s*-\s*)?(\w+),\s*start:\s*\((\d+),\s*(\d+)\),\s*end:\s*\((\d+),\s*(\d+)\)(?:,\s*text:\s*`([^`]*)`)?/);i&&n&&n.captures.push({tag:i[1],startRow:parseInt(i[2]),startCol:parseInt(i[3]),endRow:parseInt(i[4]),endCol:parseInt(i[5]),text:i[6]})}return e}var
|
|
204
|
+
`};function Q$(t){switch(t){case"javascript":return"js";case"typescript":case"tsx":return"jsts";case"python":return"python";case"go":return"go";case"rust":return"rust";case"ruby":return"ruby";case"java":return"java";case"kotlin":return"kotlin";case"swift":return"swift";case"php":return"php";case"elixir":return"generic";case"lua":return"lua";case"scala":return"scala";case"bash":return"bash";case"haskell":return"haskell";case"zig":return"zig";case"css":return"css";case"scss":return"scss";case"toml":return"toml";case"yaml":return"yaml";case"sql":return"sql";case"markdown":return"markdown";default:return"generic"}}var wu=null,ku=new Map;function x_(t){if(ku.has(t))return ku.get(t);wu||(wu=(0,ye.mkdtempSync)((0,ue.join)((0,Tu.tmpdir)(),"smart-read-queries-")));let e=(0,ue.join)(wu,`${t}.scm`);return(0,ye.writeFileSync)(e,k_[t]),ku.set(t,e),e}var Kn=null;function eP(){if(Kn)return Kn;try{let t=$u.resolve("tree-sitter-cli/package.json"),e=(0,ue.join)((0,ue.dirname)(t),"tree-sitter");if((0,ye.existsSync)(e))return Kn=e,e}catch{}return Kn="tree-sitter",Kn}function tP(t,e,r){return $_(t,[e],r).get(e)||[]}function $_(t,e,r){if(e.length===0)return new Map;let n=eP(),o=["query","-p",r,t,...e],s;try{s=(0,S_.execFileSync)(n,o,{encoding:"utf-8",timeout:3e4,stdio:["pipe","pipe","pipe"]})}catch(i){return y.debug("WORKER",`tree-sitter query failed for ${e.length} file(s)`,void 0,i instanceof Error?i:void 0),new Map}return rP(s)}function rP(t){let e=new Map,r=null,n=null;for(let o of t.split(`
|
|
205
|
+
`)){if(o.length>0&&!o.startsWith(" ")&&!o.startsWith(" ")){r=o.trim(),e.has(r)||e.set(r,[]),n=null;continue}if(!r)continue;let s=o.match(/^\s+pattern:\s+(\d+)/);if(s){n={pattern:parseInt(s[1]),captures:[]},e.get(r).push(n);continue}let i=o.match(/^\s+capture:\s+(?:\d+\s*-\s*)?(\w+),\s*start:\s*\((\d+),\s*(\d+)\),\s*end:\s*\((\d+),\s*(\d+)\)(?:,\s*text:\s*`([^`]*)`)?/);i&&n&&n.captures.push({tag:i[1],startRow:parseInt(i[2]),startCol:parseInt(i[3]),endRow:parseInt(i[4]),endCol:parseInt(i[5]),text:i[6]})}return e}var __={func:"function",const_func:"function",cls:"class",method:"method",iface:"interface",tdef:"type",enm:"enum",struct_def:"struct",trait_def:"trait",impl_def:"impl",mixin_def:"mixin",heading:"section",code_block:"code",frontmatter:"metadata",ref:"reference"},nP=new Set(["class","struct","impl","trait"]);function oP(t,e,r,n=200){let s=t[e]||"";if(!s.trimEnd().endsWith("{")&&!s.trimEnd().endsWith(":")){let i=t.slice(e,Math.min(e+10,r+1)).join(`
|
|
206
206
|
`),a=i.indexOf("{");a!==-1&&a<500&&(s=i.slice(0,a).replace(/\n/g," ").replace(/\s+/g," ").trim())}return s=s.replace(/\s*[{:]\s*$/,"").trim(),s.length>n&&(s=s.slice(0,n-3)+"..."),s}function sP(t,e){let r=[],n=!1;for(let o=e-1;o>=0;o--){let s=t[o].trim();if(s===""){if(n)break;continue}if(s.startsWith("/**")||s.startsWith("*")||s.startsWith("*/")||s.startsWith("//")||s.startsWith("///")||s.startsWith("//!")||s.startsWith("#")||s.startsWith("@"))r.unshift(t[o]),n=!0;else break}return r.length>0?r.join(`
|
|
207
|
-
`).trim():void 0}function iP(t,e,r){for(let n=e+1;n<=Math.min(e+3,r);n++){let o=t[n]?.trim();if(o){if(o.startsWith('"""')||o.startsWith("'''"))return o;break}}}function aP(t,e,r,n,o,s){switch(s){case"javascript":case"typescript":case"tsx":return n.some(i=>e>=i.startRow&&r<=i.endRow);case"python":return!t.startsWith("_");case"go":return t.length>0&&t[0]===t[0].toUpperCase()&&t[0]!==t[0].toLowerCase();case"rust":return o[e]?.trimStart().startsWith("pub")??!1;default:return!0}}function
|
|
208
|
-
`),i=
|
|
209
|
-
`);r.set(p.relativePath,{filePath:p.relativePath,language:s,symbols:[],imports:[],totalLines:f.length,foldedTokenEstimate:50})}continue}let c=
|
|
210
|
-
`),m=d.get(p.absolutePath)||[],_
|
|
211
|
-
`)}function cP(t){let e=[];e.push(`\u{1F4C4} ${t.filePath} (${t.language}, ${t.totalLines} lines)`);for(let n of t.symbols)if(n.kind==="section"){let o=n.signature.match(/^(#{1,6})\s/),s=o?o[1].length:1,i=" ".repeat(s),a=`L${n.lineStart+1}`,c=`${i}${n.signature}`;e.push(`${c.padEnd(56)}${a}`)}else if(n.kind==="code"){let o=
|
|
212
|
-
`)}function
|
|
213
|
-
`).find(c=>{let u=c.replace(/^[\s*/]+/,"").replace(/^['"`]{3}/,"").trim();return u.length>0&&!u.startsWith("/**")});if(a){let c=a.replace(/^[\s*/]+/,"").replace(/^['"`]{3}/,"").replace(/['"`]{3}$/,"").trim();c&&r.push(`${e} \u{1F4AC} ${c}`)}}if(t.children&&t.children.length>0)for(let i of t.children)r.push(
|
|
214
|
-
`)}function uP(t){return{function:"\u0192",method:"\u0192",class:"\u25C6",interface:"\u25C7",type:"\u25C7",const:"\u25CF",variable:"\u25CB",export:"\u2192",struct:"\u25C6",enum:"\u25A3",trait:"\u25C7",impl:"\u25C8",property:"\u25CB",getter:"\u21E2",setter:"\u21E0",mixin:"\u25C8",section:"\xA7",code:"\u2318",metadata:"\u25CA",reference:"\u2197"}[t]||"\xB7"}function
|
|
207
|
+
`).trim():void 0}function iP(t,e,r){for(let n=e+1;n<=Math.min(e+3,r);n++){let o=t[n]?.trim();if(o){if(o.startsWith('"""')||o.startsWith("'''"))return o;break}}}function aP(t,e,r,n,o,s){switch(s){case"javascript":case"typescript":case"tsx":return n.some(i=>e>=i.startRow&&r<=i.endRow);case"python":return!t.startsWith("_");case"go":return t.length>0&&t[0]===t[0].toUpperCase()&&t[0]!==t[0].toLowerCase();case"rust":return o[e]?.trimStart().startsWith("pub")??!1;default:return!0}}function P_(t,e,r){let n=[],o=[],s=[],i=[];for(let c of t)for(let u of c.captures)u.tag==="exp"&&s.push({startRow:u.startRow,endRow:u.endRow}),u.tag==="imp"&&o.push(u.text||e[u.startRow]?.trim()||"");for(let c of t){let u=c.captures.find(v=>__[v.tag]),l=c.captures.find(v=>v.tag==="name");if(!u)continue;let d=u.startRow,p=u.endRow,f=__[u.tag],m=l?.text||"anonymous",_;if(r==="markdown"&&f==="section"){let $=(e[d]||"").match(/^(#{1,6})\s/),x=$?$[1].length:1;_=`${"#".repeat(x)} ${m}`}else if(r==="markdown"&&f==="code"){let v=m!=="anonymous"?m:"";_=v?"```"+v:"```"}else r==="markdown"&&f==="metadata"?_="---frontmatter---":r==="markdown"&&f==="reference"?_=e[d]?.trim()||m:_=oP(e,d,p);let S=r==="markdown"?void 0:sP(e,d),b=r==="python"?iP(e,d,p):void 0,E={name:m,kind:f,signature:_,jsdoc:S||b,lineStart:d,lineEnd:p,exported:aP(m,d,p,s,e,r)};nP.has(f)&&(E.children=[],i.push({sym:E,startRow:d,endRow:p})),n.push(E)}if(r==="markdown"){let c=new Map,u=new Set;for(let l of n){if(l.kind!=="code")continue;let d=`${l.lineStart}:${l.lineEnd}`,p=c.get(d);p?l.name!=="anonymous"?(u.add(p),c.set(d,l)):u.add(l):c.set(d,l)}if(u.size>0){let l=n.filter(d=>!u.has(d));n.length=0,n.push(...l)}}let a=new Set;for(let c of i)for(let u of n)u!==c.sym&&u.lineStart>c.startRow&&u.lineEnd<=c.endRow&&(u.kind==="function"&&(u.kind="method"),c.sym.children.push(u),a.add(u));return{symbols:n.filter(c=>!a.has(c)),imports:o}}function zu(t){let e=(0,ue.dirname)(t);for(;;){if((0,ye.existsSync)((0,ue.join)(e,".claude-mem.json")))return e;let r=(0,ue.dirname)(e);if(r===e)return;e=r}}function Fs(t,e,r){let n=r?Gn(r):Mr,o=v_(e,n),s=t.split(`
|
|
208
|
+
`),i=w_(o,r);if(!i)return{filePath:e,language:o,symbols:[],imports:[],totalLines:s.length,foldedTokenEstimate:50};let a=b_(o,n),c=x_(a),u=e.slice(e.lastIndexOf("."))||".txt",l=(0,ye.mkdtempSync)((0,ue.join)((0,Tu.tmpdir)(),"smart-src-")),d=(0,ue.join)(l,`source${u}`);(0,ye.writeFileSync)(d,t);try{let p=tP(c,d,i),f=P_(p,s,o),m=Cr({filePath:e,language:o,symbols:f.symbols,imports:f.imports,totalLines:s.length,foldedTokenEstimate:0});return{filePath:e,language:o,symbols:f.symbols,imports:f.imports,totalLines:s.length,foldedTokenEstimate:Math.ceil(m.length/4)}}finally{(0,ye.rmSync)(l,{recursive:!0,force:!0})}}function T_(t,e){let r=new Map,n=e?Gn(e):Mr,o=new Map;for(let s of t){let i=v_(s.relativePath,n);o.has(i)||o.set(i,[]),o.get(i).push(s)}for(let[s,i]of o){let a=w_(s,e);if(!a){for(let p of i){let f=p.content.split(`
|
|
209
|
+
`);r.set(p.relativePath,{filePath:p.relativePath,language:s,symbols:[],imports:[],totalLines:f.length,foldedTokenEstimate:50})}continue}let c=b_(s,n),u=x_(c),l=i.map(p=>p.absolutePath),d=$_(u,l,a);for(let p of i){let f=p.content.split(`
|
|
210
|
+
`),m=d.get(p.absolutePath)||[],_=P_(m,f,s),S=Cr({filePath:p.relativePath,language:s,symbols:_.symbols,imports:_.imports,totalLines:f.length,foldedTokenEstimate:0});r.set(p.relativePath,{filePath:p.relativePath,language:s,symbols:_.symbols,imports:_.imports,totalLines:f.length,foldedTokenEstimate:Math.ceil(S.length/4)})}}return r}function Cr(t){if(t.language==="markdown")return cP(t);let e=[];if(e.push(`\u{1F4C1} ${t.filePath} (${t.language}, ${t.totalLines} lines)`),e.push(""),t.imports.length>0){e.push(` \u{1F4E6} Imports: ${t.imports.length} statements`);for(let r of t.imports.slice(0,10))e.push(` ${r}`);t.imports.length>10&&e.push(` ... +${t.imports.length-10} more`),e.push("")}for(let r of t.symbols)e.push(z_(r," "));return e.join(`
|
|
211
|
+
`)}function cP(t){let e=[];e.push(`\u{1F4C4} ${t.filePath} (${t.language}, ${t.totalLines} lines)`);for(let n of t.symbols)if(n.kind==="section"){let o=n.signature.match(/^(#{1,6})\s/),s=o?o[1].length:1,i=" ".repeat(s),a=`L${n.lineStart+1}`,c=`${i}${n.signature}`;e.push(`${c.padEnd(56)}${a}`)}else if(n.kind==="code"){let o=y_(t.symbols,n.lineStart),s=" ".repeat(o+1),i=n.lineStart===n.lineEnd?`L${n.lineStart+1}`:`L${n.lineStart+1}-${n.lineEnd+1}`,a=`${s}${n.signature}`;e.push(`${a.padEnd(56)}${i}`)}else if(n.kind==="metadata"){let o=n.lineStart===n.lineEnd?`L${n.lineStart+1}`:`L${n.lineStart+1}-${n.lineEnd+1}`,s=` ${n.signature}`;e.push(`${s.padEnd(56)}${o}`)}else if(n.kind==="reference"){let o=y_(t.symbols,n.lineStart),s=" ".repeat(o+1),i=`L${n.lineStart+1}`,a=`${s}\u2197 ${n.name}`;e.push(`${a.padEnd(56)}${i}`)}return e.join(`
|
|
212
|
+
`)}function y_(t,e){let r=0;for(let n of t)if(n.kind==="section"&&n.lineStart<e){let o=n.signature.match(/^(#{1,6})\s/);r=o?o[1].length:1}return r}function z_(t,e){let r=[],n=uP(t.kind),o=t.exported?" [exported]":"",s=t.lineStart===t.lineEnd?`L${t.lineStart+1}`:`L${t.lineStart+1}-${t.lineEnd+1}`;if(r.push(`${e}${n} ${t.name}${o} (${s})`),r.push(`${e} ${t.signature}`),t.jsdoc){let a=t.jsdoc.split(`
|
|
213
|
+
`).find(c=>{let u=c.replace(/^[\s*/]+/,"").replace(/^['"`]{3}/,"").trim();return u.length>0&&!u.startsWith("/**")});if(a){let c=a.replace(/^[\s*/]+/,"").replace(/^['"`]{3}/,"").replace(/['"`]{3}$/,"").trim();c&&r.push(`${e} \u{1F4AC} ${c}`)}}if(t.children&&t.children.length>0)for(let i of t.children)r.push(z_(i,e+" "));return r.join(`
|
|
214
|
+
`)}function uP(t){return{function:"\u0192",method:"\u0192",class:"\u25C6",interface:"\u25C7",type:"\u25C7",const:"\u25CF",variable:"\u25CB",export:"\u2192",struct:"\u25C6",enum:"\u25A3",trait:"\u25C7",impl:"\u25C8",property:"\u25CB",getter:"\u21E2",setter:"\u21E0",mixin:"\u25C8",section:"\xA7",code:"\u2318",metadata:"\u25CA",reference:"\u2197"}[t]||"\xB7"}function R_(t,e,r,n){let o=Fs(t,e,n),s=l=>{for(let d of l){if(d.name===r)return d;if(d.children){let p=s(d.children);if(p)return p}}return null},i=s(o.symbols);if(!i)return null;let a=t.split(`
|
|
215
215
|
`);if(o.language==="markdown"&&i.kind==="section"){let l=i.signature.match(/^(#{1,6})\s/),d=l?l[1].length:1,p=i.lineStart,f=a.length-1;for(let _ of o.symbols)if(_.kind==="section"&&_.lineStart>p){let S=_.signature.match(/^(#{1,6})\s/);if((S?S[1].length:1)<=d){for(f=_.lineStart-1;f>p&&a[f].trim()==="";)f--;break}}let m=a.slice(p,f+1).join(`
|
|
216
216
|
`);return`<!-- \u{1F4CD} ${e} L${p+1}-${f+1} -->
|
|
217
217
|
${m}`}let c=i.lineStart;for(let l=i.lineStart-1;l>=0;l--){let d=a[l].trim();if(d===""||d.startsWith("*")||d.startsWith("/**")||d.startsWith("///")||d.startsWith("//")||d.startsWith("#")||d.startsWith("@")||d==="*/")c=l;else break}let u=a.slice(c,i.lineEnd+1).join(`
|
|
218
218
|
`);return`// \u{1F4CD} ${e} L${c+1}-${i.lineEnd+1}
|
|
219
|
-
${u}`}var
|
|
219
|
+
${u}`}var I_=new Set([".js",".jsx",".ts",".tsx",".mjs",".cjs",".py",".pyw",".go",".rs",".rb",".java",".cs",".cpp",".cc",".cxx",".c",".h",".hpp",".hh",".swift",".kt",".kts",".php",".vue",".svelte",".ex",".exs",".lua",".scala",".sc",".sh",".bash",".zsh",".hs",".zig",".css",".scss",".toml",".yml",".yaml",".sql",".md",".mdx"]),dP=new Set(["node_modules",".git","dist","build",".next","__pycache__",".venv","venv","env",".env","target","vendor",".cache",".turbo","coverage",".nyc_output",".claude",".smart-file-read"]),pP=512*1024;async function*O_(t,e,r=20,n){if(r<=0)return;let o;try{o=await(0,Nr.readdir)(t,{withFileTypes:!0})}catch(s){y.debug("WORKER",`walkDir: failed to read directory ${t}`,void 0,s instanceof Error?s:void 0);return}for(let s of o){if(s.name.startsWith(".")&&s.name!=="."||dP.has(s.name))continue;let i=(0,Jn.join)(t,s.name);if(s.isDirectory())yield*O_(i,e,r-1,n);else if(s.isFile()){let a=s.name.slice(s.name.lastIndexOf("."));(I_.has(a)||n&&n.has(a))&&(yield i)}}}async function fP(t){try{let e=await(0,Nr.stat)(t);if(e.size>pP||e.size===0)return null;let r=await(0,Nr.readFile)(t,"utf-8");return r.slice(0,1e3).includes("\0")?null:r}catch(e){return y.debug("WORKER",`safeReadFile: failed to read ${t}`,void 0,e instanceof Error?e:void 0),null}}async function A_(t,e,r={}){let n=r.maxResults||20,o=e.toLowerCase(),s=o.split(/[\s_\-./]+/).filter(E=>E.length>0),i=r.projectRoot||t,a=Gn(i),c=new Set;for(let E of Object.values(a.grammars))for(let v of E.extensions)I_.has(v)||c.add(v);let u=[];for await(let E of O_(t,t,20,c.size>0?c:void 0)){if(r.filePattern&&!(0,Jn.relative)(t,E).toLowerCase().includes(r.filePattern.toLowerCase()))continue;let v=await fP(E);v&&u.push({absolutePath:E,relativePath:(0,Jn.relative)(t,E),content:v})}let l=T_(u,i),d=[],p=[],f=0;for(let[E,v]of l){f+=mP(v);let x=Hs(E.toLowerCase(),s)>0,Se=[],we=(Zt,nr)=>{for(let ae of Zt){let kt=0,Ke="",jr=Hs(ae.name.toLowerCase(),s);jr>0&&(kt+=jr*3,Ke="name match"),ae.signature.toLowerCase().includes(o)&&(kt+=2,Ke=Ke?`${Ke} + signature`:"signature match"),ae.jsdoc&&ae.jsdoc.toLowerCase().includes(o)&&(kt+=1,Ke=Ke?`${Ke} + jsdoc`:"jsdoc match"),kt>0&&(x=!0,Se.push({filePath:E,symbolName:nr?`${nr}.${ae.name}`:ae.name,kind:ae.kind,signature:ae.signature,jsdoc:ae.jsdoc,lineStart:ae.lineStart,lineEnd:ae.lineEnd,matchReason:Ke})),ae.children&&we(ae.children,ae.name)}};we(v.symbols),x&&(d.push(v),p.push(...Se))}p.sort((E,v)=>{let $=Hs(E.symbolName.toLowerCase(),s);return Hs(v.symbolName.toLowerCase(),s)-$});let m=p.slice(0,n),_=new Set(m.map(E=>E.filePath)),S=d.filter(E=>_.has(E.filePath)).slice(0,n),b=S.reduce((E,v)=>E+v.foldedTokenEstimate,0);return{foldedFiles:S,matchingSymbols:m,totalFilesScanned:u.length,totalSymbolsFound:f,tokenEstimate:b}}function Hs(t,e){let r=0;for(let n of e)if(t===n)r+=10;else if(t.includes(n))r+=5;else{let o=0,s=0;for(let i of n){let a=t.indexOf(i,o);a!==-1&&(s++,o=a+1)}s===n.length&&(r+=1)}return r}function mP(t){let e=t.symbols.length;for(let r of t.symbols)r.children&&(e+=r.children.length);return e}function M_(t,e){let r=[];if(r.push(`\u{1F50D} Smart Search: "${e}"`),r.push(` Scanned ${t.totalFilesScanned} files, found ${t.totalSymbolsFound} symbols`),r.push(` ${t.matchingSymbols.length} matches across ${t.foldedFiles.length} files (~${t.tokenEstimate} tokens for folded view)`),r.push(""),t.matchingSymbols.length===0)return r.push(" No matching symbols found."),r.join(`
|
|
220
220
|
`);r.push("\u2500\u2500 Matching Symbols \u2500\u2500"),r.push("");for(let n of t.matchingSymbols){if(r.push(` ${n.kind} ${n.symbolName} (${n.filePath}:${n.lineStart+1})`),r.push(` ${n.signature}`),n.jsdoc){let o=n.jsdoc.split(`
|
|
221
|
-
`).find(s=>s.replace(/^[\s*/]+/,"").trim().length>0);o&&r.push(` \u{1F4AC} ${o.replace(/^[\s*/]+/,"").trim()}`)}r.push("")}r.push("\u2500\u2500 Folded File Views \u2500\u2500"),r.push("");for(let n of t.foldedFiles)r.push(
|
|
222
|
-
`)}var Ru=require("node:fs/promises"),Ws=require("node:fs"),tt=require("node:path"),q_=require("node:os"),Z_=require("node:url");var hP=Et(ae.API_REQUEST),Be=class extends Error{kind;status;cause;constructor(e,r,n={}){super(r),this.name="ServerBetaClientError",this.kind=e,this.status=n.status??null,this.cause=n.cause}isFallbackEligible(){return this.kind==="transport"||this.kind==="timeout"||this.kind==="missing_api_key"||this.kind==="http_error"&&(this.status!==null&&this.status>=500||this.status===429)}},Hs=class{baseUrl;apiKey;timeoutMs;constructor(e){this.baseUrl=gP(e.serverBaseUrl),this.apiKey=e.apiKey,this.timeoutMs=e.timeoutMs??hP}async startSession(e){let r=this.buildStartSessionPayload(e);return this.request("POST","/v1/sessions/start",r)}async recordEvent(e){let r=this.buildEventPayload(e),n=e.generate===!1?"/v1/events?generate=false":"/v1/events";return this.request("POST",n,r)}async endSession(e){if(!e.sessionId)throw new Be("invalid_response","sessionId is required for endSession");return this.request("POST",`/v1/sessions/${encodeURIComponent(e.sessionId)}/end`,{})}async addObservation(e){return this.request("POST","/v1/memories",this.buildAddObservationPayload(e))}async searchObservations(e){return this.request("POST","/v1/search",this.buildSearchPayload(e))}async contextObservations(e){return this.request("POST","/v1/context",this.buildSearchPayload(e))}async getJobStatus(e){if(!e)throw new Be("invalid_response","jobId is required for getJobStatus");return this.request("GET",`/v1/jobs/${encodeURIComponent(e)}`)}buildAddObservationPayload(e){let r=e.content,n=e.kind??"manual",o=typeof e.metadata?.title=="string"?e.metadata.title:void 0;return{projectId:e.projectId,kind:n,type:n,narrative:r,...o?{title:o}:{},...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}buildSearchPayload(e){return{projectId:e.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{}}}buildStartSessionPayload(e){return{projectId:e.projectId,...e.externalSessionId!==void 0?{externalSessionId:e.externalSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.agentId!==void 0?{agentId:e.agentId}:{},...e.agentType!==void 0?{agentType:e.agentType}:{},...e.platformSource!==void 0?{platformSource:e.platformSource}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}buildEventPayload(e){return{projectId:e.projectId,sourceType:e.sourceType,eventType:e.eventType,occurredAtEpoch:e.occurredAtEpoch,...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.memorySessionId!==void 0?{memorySessionId:e.memorySessionId}:{},...e.payload!==void 0?{payload:e.payload}:{}}}async request(e,r,n){if(!this.apiKey||!this.apiKey.trim())throw new Be("missing_api_key","Server beta API key is not configured (CLAUDE_MEM_SERVER_BETA_API_KEY).");let o=`${this.baseUrl}${r}`,s={method:e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}};n!==void 0&&(s.body=JSON.stringify(n));let i;try{i=await gu(o,s,this.timeoutMs)}catch(c){let u=c instanceof Error?c.message:String(c),l=/timed out|timeout/i.test(u);throw new Be(l?"timeout":"transport",`Server beta ${e} ${r} failed: ${u}`,{cause:c})}if(!i.ok){let c=await i.text().catch(()=>"");throw new Be("http_error",`Server beta ${e} ${r} returned ${i.status}: ${_P(c,200)}`,{status:i.status})}let a=await i.text();if(!a||a.length===0)return{};try{return JSON.parse(a)}catch(c){throw new Be("invalid_response",`Server beta ${e} ${r} returned non-JSON response`,{cause:c})}}};function M_(t){return t instanceof Be}function gP(t){return t.replace(/\/+$/,"")}function _P(t,e){return t.length<=e?t:`${t.slice(0,e)}\u2026`}function Tu(){return(Is().CLAUDE_MEM_RUNTIME??"worker").trim().toLowerCase()==="server-beta"?"server-beta":"worker"}function C_(){let t=Is(),e=(t.CLAUDE_MEM_SERVER_BETA_URL??"").trim(),r=(t.CLAUDE_MEM_SERVER_BETA_API_KEY??"").trim(),n=(t.CLAUDE_MEM_SERVER_BETA_PROJECT_ID??"").trim();if(!e)return y.warn("HOOK","[server-beta-fallback] reason=missing_base_url"),null;if(!r)return y.warn("HOOK","[server-beta-fallback] reason=missing_api_key"),null;if(!n)return y.warn("HOOK","[server-beta-fallback] reason=missing_project_id"),null;let o={serverBaseUrl:e,apiKey:r};return{runtime:"server-beta",client:new Hs(o),projectId:n,serverBaseUrl:e}}var OP={},yP="13.6.2";console.log=(...t)=>{y.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:t})};var F_=!1,H_=(()=>{if(typeof __dirname<"u")return __dirname;try{return(0,tt.dirname)((0,Z_.fileURLToPath)(OP.url))}catch{return F_=!0,process.cwd()}})(),Iu=m_()??(0,tt.resolve)(H_,"worker-service.cjs");function SP(){F_&&((0,Ws.existsSync)(Iu)||y.error("SYSTEM","mcp-server: dirname resolution failed (both __dirname and import.meta.url are unavailable). Fell back to process.cwd() and the resolved WORKER_SCRIPT_PATH does not exist. This is the actual problem \u2014 the worker bundle is fine, but mcp-server cannot locate it. Worker auto-start will fail until the dirname-resolution path is fixed.",{workerScriptPath:Iu,mcpServerDir:H_}))}var N_={search:"/api/search",timeline:"/api/timeline"};async function zu(t,e){y.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:t,params:e});let r=new URLSearchParams;for(let[o,s]of Object.entries(e))s!=null&&r.append(o,String(s));let n=`${t}?${r}`;try{let o=await Us(n);if(!o.ok){let i=await o.text();throw new Error(`Worker API error (${o.status}): ${i}`)}let s=await o.json();return y.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:t}),s}catch(o){return y.error("SYSTEM","\u2190 Worker API error",{endpoint:t},o instanceof Error?o:new Error(String(o))),{content:[{type:"text",text:`Error calling Worker API: ${o instanceof Error?o.message:String(o)}`}],isError:!0}}}async function vP(t,e){let r=await Us(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){let o=await r.text();throw new Error(`Worker API error (${r.status}): ${o}`)}let n=await r.json();return y.debug("HTTP","Worker API success (POST)",void 0,{endpoint:t}),{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}async function jr(t,e){y.debug("HTTP","Worker API request (POST)",void 0,{endpoint:t});try{return await vP(t,e)}catch(r){return y.error("HTTP","Worker API error (POST)",{endpoint:t},r instanceof Error?r:new Error(String(r))),{content:[{type:"text",text:`Error calling Worker API: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}}async function bP(){try{return(await Us("/api/health")).ok}catch(t){return y.debug("SYSTEM","Worker health check failed",{},t instanceof Error?t:new Error(String(t))),!1}}function EP(){if(Tu()!=="server-beta")return null;let e=C_();return e?{...e,available:!0}:{runtime:"server-beta",available:!1,reason:"server-beta is selected but configuration is incomplete (missing url, api key, or project id)"}}function Qn(t){return M_(t)?{content:[{type:"text",text:`Server beta error (${t.kind}${t.status?` ${t.status}`:""}): ${t.message}`}],isError:!0}:{content:[{type:"text",text:`Tool error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}function eo(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function to(t){let e=EP();if(!e)throw new Be("transport",`${t} requires CLAUDE_MEM_RUNTIME=server-beta. Current runtime is "worker"; use the existing search/timeline/get_observations tools for worker-mode memory access.`);if(!e.available)throw new Be("missing_api_key",`${t}: ${e.reason}`);return e}async function D_(t){try{let e=to("observation_add");if(typeof t?.content!="string"||t.content.trim().length===0)throw new Error('observation_add: "content" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,content:t.content,...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.kind!==void 0?{kind:t.kind}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}},o=await e.client.addObservation(n);return eo(o)}catch(e){return Qn(e)}}async function wP(t){try{let e=to("observation_record_event");if(typeof t?.eventType!="string"||t.eventType.trim().length===0)throw new Error('observation_record_event: "eventType" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,sourceType:t.sourceType??"api",eventType:t.eventType,occurredAtEpoch:typeof t.occurredAtEpoch=="number"?t.occurredAtEpoch:Date.now(),...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.memorySessionId!==void 0?{memorySessionId:t.memorySessionId}:{},...t.payload!==void 0?{payload:t.payload}:{},...t.generate!==void 0?{generate:t.generate}:{}},o=await e.client.recordEvent(n);return eo(o)}catch(e){return Qn(e)}}async function j_(t){try{let e=to("observation_search");if(typeof t?.query!="string"||t.query.trim().length===0)throw new Error('observation_search: "query" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{}},o=await e.client.searchObservations(n);return eo(o)}catch(e){return Qn(e)}}async function L_(t){try{let e=to("observation_context");if(typeof t?.query!="string"||t.query.trim().length===0)throw new Error('observation_context: "query" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{}},o=await e.client.contextObservations(n);return eo(o)}catch(e){return Qn(e)}}async function kP(t){try{let e=to("observation_generation_status"),r=(t?.jobId??t?.job_id??"").trim();if(!r)throw new Error('observation_generation_status: "jobId" is required');let n=await e.client.getJobStatus(r);return eo(n)}catch(e){return Qn(e)}}async function xP(){if(await bP())return!0;y.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),SP();try{let t=yu(),e=await h_(t,Iu);return e==="dead"&&y.error("SYSTEM","Worker auto-start failed \u2014 MCP tools that require the worker (search, timeline, get_observations) will fail until the worker is running. Check earlier log lines for the specific failure reason (Bun not found, missing worker bundle, port conflict, etc.)."),e!=="dead"}catch(t){return y.error("SYSTEM","Worker auto-start threw \u2014 MCP tools that require the worker (search, timeline, get_observations) will fail until the worker is running.",void 0,t instanceof Error?t:new Error(String(t))),!1}}var W_=[{name:"__IMPORTANT",description:`3-LAYER WORKFLOW (ALWAYS FOLLOW):
|
|
221
|
+
`).find(s=>s.replace(/^[\s*/]+/,"").trim().length>0);o&&r.push(` \u{1F4AC} ${o.replace(/^[\s*/]+/,"").trim()}`)}r.push("")}r.push("\u2500\u2500 Folded File Views \u2500\u2500"),r.push("");for(let n of t.foldedFiles)r.push(Cr(n)),r.push("");return r.push("\u2500\u2500 Actions \u2500\u2500"),r.push(" To see full implementation: use smart_unfold with file path and symbol name"),r.join(`
|
|
222
|
+
`)}var Ou=require("node:fs/promises"),Vs=require("node:fs"),tt=require("node:path"),Z_=require("node:os"),F_=require("node:url");var hP=bt(ce.API_REQUEST),Be=class extends Error{kind;status;cause;constructor(e,r,n={}){super(r),this.name="ServerBetaClientError",this.kind=e,this.status=n.status??null,this.cause=n.cause}isFallbackEligible(){return this.kind==="transport"||this.kind==="timeout"||this.kind==="missing_api_key"||this.kind==="http_error"&&(this.status!==null&&this.status>=500||this.status===429)}},Ws=class{baseUrl;apiKey;timeoutMs;constructor(e){this.baseUrl=gP(e.serverBaseUrl),this.apiKey=e.apiKey,this.timeoutMs=e.timeoutMs??hP}async startSession(e){let r=this.buildStartSessionPayload(e);return this.request("POST","/v1/sessions/start",r)}async recordEvent(e){let r=this.buildEventPayload(e),n=e.generate===!1?"/v1/events?generate=false":"/v1/events";return this.request("POST",n,r)}async endSession(e){if(!e.sessionId)throw new Be("invalid_response","sessionId is required for endSession");return this.request("POST",`/v1/sessions/${encodeURIComponent(e.sessionId)}/end`,{})}async addObservation(e){return this.request("POST","/v1/memories",this.buildAddObservationPayload(e))}async searchObservations(e){return this.request("POST","/v1/search",this.buildSearchPayload(e))}async contextObservations(e){return this.request("POST","/v1/context",this.buildSearchPayload(e))}async getJobStatus(e){if(!e)throw new Be("invalid_response","jobId is required for getJobStatus");return this.request("GET",`/v1/jobs/${encodeURIComponent(e)}`)}buildAddObservationPayload(e){let r=e.content,n=e.kind??"manual",o=typeof e.metadata?.title=="string"?e.metadata.title:void 0;return{projectId:e.projectId,kind:n,type:n,narrative:r,...o?{title:o}:{},...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}buildSearchPayload(e){return{projectId:e.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{}}}buildStartSessionPayload(e){return{projectId:e.projectId,...e.externalSessionId!==void 0?{externalSessionId:e.externalSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.agentId!==void 0?{agentId:e.agentId}:{},...e.agentType!==void 0?{agentType:e.agentType}:{},...e.platformSource!==void 0?{platformSource:e.platformSource}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}}buildEventPayload(e){return{projectId:e.projectId,sourceType:e.sourceType,eventType:e.eventType,occurredAtEpoch:e.occurredAtEpoch,...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.memorySessionId!==void 0?{memorySessionId:e.memorySessionId}:{},...e.payload!==void 0?{payload:e.payload}:{}}}async request(e,r,n){if(!this.apiKey||!this.apiKey.trim())throw new Be("missing_api_key","Server beta API key is not configured (CLAUDE_MEM_SERVER_BETA_API_KEY).");let o=`${this.baseUrl}${r}`,s={method:e,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}};n!==void 0&&(s.body=JSON.stringify(n));let i;try{i=await yu(o,s,this.timeoutMs)}catch(c){let u=c instanceof Error?c.message:String(c),l=/timed out|timeout/i.test(u);throw new Be(l?"timeout":"transport",`Server beta ${e} ${r} failed: ${u}`,{cause:c})}if(!i.ok){let c=await i.text().catch(()=>"");throw new Be("http_error",`Server beta ${e} ${r} returned ${i.status}: ${_P(c,200)}`,{status:i.status})}let a=await i.text();if(!a||a.length===0)return{};try{return JSON.parse(a)}catch(c){throw new Be("invalid_response",`Server beta ${e} ${r} returned non-JSON response`,{cause:c})}}};function C_(t){return t instanceof Be}function gP(t){return t.replace(/\/+$/,"")}function _P(t,e){return t.length<=e?t:`${t.slice(0,e)}\u2026`}function Ru(){return(Rs().CLAUDE_MEM_RUNTIME??"worker").trim().toLowerCase()==="server-beta"?"server-beta":"worker"}function N_(){let t=Rs(),e=(t.CLAUDE_MEM_SERVER_BETA_URL??"").trim(),r=(t.CLAUDE_MEM_SERVER_BETA_API_KEY??"").trim(),n=(t.CLAUDE_MEM_SERVER_BETA_PROJECT_ID??"").trim();if(!e)return y.warn("HOOK","[server-beta-fallback] reason=missing_base_url"),null;if(!r)return y.warn("HOOK","[server-beta-fallback] reason=missing_api_key"),null;if(!n)return y.warn("HOOK","[server-beta-fallback] reason=missing_project_id"),null;let o={serverBaseUrl:e,apiKey:r};return{runtime:"server-beta",client:new Ws(o),projectId:n,serverBaseUrl:e}}var OP={},yP="13.7.1";console.log=(...t)=>{y.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:t})};var H_=!1,W_=(()=>{if(typeof __dirname<"u")return __dirname;try{return(0,tt.dirname)((0,F_.fileURLToPath)(OP.url))}catch{return H_=!0,process.cwd()}})(),Au=h_()??(0,tt.resolve)(W_,"worker-service.cjs");function SP(){H_&&((0,Vs.existsSync)(Au)||y.error("SYSTEM","mcp-server: dirname resolution failed (both __dirname and import.meta.url are unavailable). Fell back to process.cwd() and the resolved WORKER_SCRIPT_PATH does not exist. This is the actual problem \u2014 the worker bundle is fine, but mcp-server cannot locate it. Worker auto-start will fail until the dirname-resolution path is fixed.",{workerScriptPath:Au,mcpServerDir:W_}))}var D_={search:"/api/search",timeline:"/api/timeline"};async function Iu(t,e){y.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:t,params:e});let r=new URLSearchParams;for(let[o,s]of Object.entries(e))s!=null&&r.append(o,String(s));let n=`${t}?${r}`;try{let o=await qs(n);if(!o.ok){let i=await o.text();throw new Error(`Worker API error (${o.status}): ${i}`)}let s=await o.json();return y.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:t}),s}catch(o){return y.error("SYSTEM","\u2190 Worker API error",{endpoint:t},o instanceof Error?o:new Error(String(o))),{content:[{type:"text",text:`Error calling Worker API: ${o instanceof Error?o.message:String(o)}`}],isError:!0}}}async function vP(t,e){let r=await qs(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok){let o=await r.text();throw new Error(`Worker API error (${r.status}): ${o}`)}let n=await r.json();return y.debug("HTTP","Worker API success (POST)",void 0,{endpoint:t}),{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}async function Dr(t,e){y.debug("HTTP","Worker API request (POST)",void 0,{endpoint:t});try{return await vP(t,e)}catch(r){return y.error("HTTP","Worker API error (POST)",{endpoint:t},r instanceof Error?r:new Error(String(r))),{content:[{type:"text",text:`Error calling Worker API: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}}async function bP(){try{return(await qs("/api/health")).ok}catch(t){return y.debug("SYSTEM","Worker health check failed",{},t instanceof Error?t:new Error(String(t))),!1}}function EP(){if(Ru()!=="server-beta")return null;let e=N_();return e?{...e,available:!0}:{runtime:"server-beta",available:!1,reason:"server-beta is selected but configuration is incomplete (missing url, api key, or project id)"}}function Xn(t){return C_(t)?{content:[{type:"text",text:`Server beta error (${t.kind}${t.status?` ${t.status}`:""}): ${t.message}`}],isError:!0}:{content:[{type:"text",text:`Tool error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}function Qn(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function eo(t){let e=EP();if(!e)throw new Be("transport",`${t} requires CLAUDE_MEM_RUNTIME=server-beta. Current runtime is "worker"; use the existing search/timeline/get_observations tools for worker-mode memory access.`);if(!e.available)throw new Be("missing_api_key",`${t}: ${e.reason}`);return e}async function j_(t){try{let e=eo("observation_add");if(typeof t?.content!="string"||t.content.trim().length===0)throw new Error('observation_add: "content" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,content:t.content,...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.kind!==void 0?{kind:t.kind}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}},o=await e.client.addObservation(n);return Qn(o)}catch(e){return Xn(e)}}async function wP(t){try{let e=eo("observation_record_event");if(typeof t?.eventType!="string"||t.eventType.trim().length===0)throw new Error('observation_record_event: "eventType" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,sourceType:t.sourceType??"api",eventType:t.eventType,occurredAtEpoch:typeof t.occurredAtEpoch=="number"?t.occurredAtEpoch:Date.now(),...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.memorySessionId!==void 0?{memorySessionId:t.memorySessionId}:{},...t.payload!==void 0?{payload:t.payload}:{},...t.generate!==void 0?{generate:t.generate}:{}},o=await e.client.recordEvent(n);return Qn(o)}catch(e){return Xn(e)}}async function L_(t){try{let e=eo("observation_search");if(typeof t?.query!="string"||t.query.trim().length===0)throw new Error('observation_search: "query" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{}},o=await e.client.searchObservations(n);return Qn(o)}catch(e){return Xn(e)}}async function U_(t){try{let e=eo("observation_context");if(typeof t?.query!="string"||t.query.trim().length===0)throw new Error('observation_context: "query" is required');let n={projectId:t.projectId&&t.projectId.trim().length>0?t.projectId:e.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{}},o=await e.client.contextObservations(n);return Qn(o)}catch(e){return Xn(e)}}async function kP(t){try{let e=eo("observation_generation_status"),r=(t?.jobId??t?.job_id??"").trim();if(!r)throw new Error('observation_generation_status: "jobId" is required');let n=await e.client.getJobStatus(r);return Qn(n)}catch(e){return Xn(e)}}async function xP(){if(await bP())return!0;y.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),SP();try{let t=vu(),e=await g_(t,Au);return e==="dead"&&y.error("SYSTEM","Worker auto-start failed \u2014 MCP tools that require the worker (search, timeline, get_observations) will fail until the worker is running. Check earlier log lines for the specific failure reason (Bun not found, missing worker bundle, port conflict, etc.)."),e!=="dead"}catch(t){return y.error("SYSTEM","Worker auto-start threw \u2014 MCP tools that require the worker (search, timeline, get_observations) will fail until the worker is running.",void 0,t instanceof Error?t:new Error(String(t))),!1}}var V_=[{name:"__IMPORTANT",description:`3-LAYER WORKFLOW (ALWAYS FOLLOW):
|
|
223
223
|
1. search(query) \u2192 Get index with IDs (~50-100 tokens/result)
|
|
224
224
|
2. timeline(anchor=ID) \u2192 Get context around interesting results
|
|
225
225
|
3. get_observations([IDs]) \u2192 Fetch full details ONLY for filtered IDs
|
|
@@ -239,8 +239,8 @@ NEVER fetch full details without filtering first. 10x token savings.`,inputSchem
|
|
|
239
239
|
\`get_observations(ids=[...])\` # ALWAYS batch for 2+ items
|
|
240
240
|
Returns: Complete details (~500-1000 tokens/result)
|
|
241
241
|
|
|
242
|
-
**Why:** 10x token savings. Never fetch full details without filtering first.`}]})},{name:"search",description:"Step 1: Search memory. Returns index with IDs. Params: query, limit, project, platformSource, type, obs_type, dateStart, dateEnd, offset, orderBy",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},limit:{type:"number",description:"Max results (default 20)"},project:{type:"string",description:"Filter by project name"},platformSource:{type:"string",description:"Filter by platform source (e.g. claude, codex, cursor) \u2014 restricts results to that agent's own memory"},type:{type:"string",description:"Filter by observation type"},obs_type:{type:"string",description:"Filter by obs_type field"},dateStart:{type:"string",description:"Start date filter (ISO)"},dateEnd:{type:"string",description:"End date filter (ISO)"},offset:{type:"number",description:"Pagination offset"},orderBy:{type:"string",description:"Sort order: date_desc or date_asc"}},additionalProperties:!0},handler:async t=>{let e=
|
|
242
|
+
**Why:** 10x token savings. Never fetch full details without filtering first.`}]})},{name:"search",description:"Step 1: Search memory. Returns index with IDs. Params: query, limit, project, platformSource, type, obs_type, dateStart, dateEnd, offset, orderBy",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},limit:{type:"number",description:"Max results (default 20)"},project:{type:"string",description:"Filter by project name"},platformSource:{type:"string",description:"Filter by platform source (e.g. claude, codex, cursor) \u2014 restricts results to that agent's own memory"},type:{type:"string",description:"Filter by observation type"},obs_type:{type:"string",description:"Filter by obs_type field"},dateStart:{type:"string",description:"Start date filter (ISO)"},dateEnd:{type:"string",description:"End date filter (ISO)"},offset:{type:"number",description:"Pagination offset"},orderBy:{type:"string",description:"Sort order: date_desc or date_asc"}},additionalProperties:!0},handler:async t=>{let e=D_.search;return await Iu(e,t)}},{name:"timeline",description:"Step 2: Get context around results. Params: anchor (observation ID) OR query (finds anchor automatically), depth_before, depth_after, project",inputSchema:{type:"object",properties:{anchor:{type:"number",description:"Observation ID to center the timeline around"},query:{type:"string",description:"Query to find anchor automatically"},depth_before:{type:"number",description:"Items before anchor (default 3)"},depth_after:{type:"number",description:"Items after anchor (default 3)"},project:{type:"string",description:"Filter by project name"}},additionalProperties:!0},handler:async t=>{let e=D_.timeline;return await Iu(e,t)}},{name:"get_observations",description:"Step 3: Fetch full details for filtered IDs. Params: ids (array of observation IDs, required), orderBy, limit, project",inputSchema:{type:"object",properties:{ids:{type:"array",items:{type:"number"},description:"Array of observation IDs to fetch (required)"}},required:["ids"],additionalProperties:!0},handler:async t=>await Dr("/api/observations/batch",t)},{name:"observation_add",description:"Insert a manual observation directly into server-beta storage. Calls /v1/memories \u2014 does NOT enqueue generation. Server-beta runtime only. Params: content (required), projectId (optional, falls back to settings), serverSessionId, kind, metadata.",inputSchema:{type:"object",properties:{projectId:{type:"string",description:"Project id (falls back to CLAUDE_MEM_SERVER_BETA_PROJECT_ID)"},serverSessionId:{type:"string",description:"Optional server_session_id to attach the observation to"},kind:{type:"string",description:"Observation kind (default: manual)"},content:{type:"string",description:"Observation content (required)"},metadata:{type:"object",description:"Free-form metadata object",additionalProperties:!0}},required:["content"],additionalProperties:!1},handler:async t=>j_(t??{})},{name:"observation_record_event",description:"Record an agent event into server-beta. Calls /v1/events \u2014 server inserts the event row, the outbox row, and enqueues a generation job atomically. Server-beta runtime only.",inputSchema:{type:"object",properties:{projectId:{type:"string"},eventType:{type:"string",description:"Event type (required), e.g. PostToolUse, UserPromptSubmit"},sourceType:{type:"string",enum:["hook","worker","provider","server","api"]},serverSessionId:{type:"string"},contentSessionId:{type:"string"},memorySessionId:{type:"string"},payload:{description:"Event payload (any JSON value)"},occurredAtEpoch:{type:"number",description:"Unix epoch millis (defaults to now)"},generate:{type:"boolean",description:"If false, skip generation job (default: true)"}},required:["eventType"],additionalProperties:!1},handler:async t=>wP(t??{})},{name:"observation_search",description:"Full-text search across generated observations using server-beta's GIN tsvector index (Phase 1). Calls /v1/search. Server-beta runtime only. Params: query (required), projectId (optional), limit (default 20, max 100).",inputSchema:{type:"object",properties:{projectId:{type:"string"},query:{type:"string",description:"Search query (required)"},limit:{type:"number",description:"Max results (default 20, max 100)"}},required:["query"],additionalProperties:!1},handler:async t=>L_(t??{})},{name:"observation_context",description:"Get top-N relevant observations for context injection. Returns matched observations AND a pre-joined context string suitable for prompt injection. Calls /v1/context. Server-beta runtime only.",inputSchema:{type:"object",properties:{projectId:{type:"string"},query:{type:"string",description:"Search query (required)"},limit:{type:"number",description:"Max observations (default 10, max 50)"}},required:["query"],additionalProperties:!1},handler:async t=>U_(t??{})},{name:"observation_generation_status",description:"Look up the status of an observation generation job by id. Calls /v1/jobs/:id. Server-beta runtime only. Returns the same payload as REST.",inputSchema:{type:"object",properties:{jobId:{type:"string",description:"Generation job id (required)"}},required:["jobId"],additionalProperties:!1},handler:async t=>kP(t??{})},{name:"memory_add",description:"Compatibility alias for observation_add. Same behavior; same schema modulo the legacy field names.",inputSchema:{type:"object",properties:{projectId:{type:"string"},kind:{type:"string"},content:{type:"string"},narrative:{type:"string",description:"Legacy alias for content; mapped to content if content is missing"},title:{type:"string",description:"Legacy field; appended to metadata.title"},metadata:{type:"object",additionalProperties:!0}},required:["projectId"],additionalProperties:!0},handler:async t=>{let e={projectId:t?.projectId,content:t?.content??t?.narrative??"",kind:t?.kind,metadata:{...t?.metadata??{},...t?.title?{title:t.title}:{}}};return j_(e)}},{name:"memory_search",description:"Compatibility alias for observation_search. Same FTS path; same /v1/search REST endpoint.",inputSchema:{type:"object",properties:{projectId:{type:"string"},query:{type:"string"},limit:{type:"number"}},required:["projectId","query"],additionalProperties:!0},handler:async t=>L_(t??{})},{name:"memory_context",description:"Compatibility alias for observation_context. Same /v1/context REST endpoint.",inputSchema:{type:"object",properties:{projectId:{type:"string"},query:{type:"string"},limit:{type:"number"}},required:["projectId","query"],additionalProperties:!0},handler:async t=>U_(t??{})},{name:"smart_search",description:"Search codebase for symbols, functions, classes using tree-sitter AST parsing. Returns folded structural views with token counts. Use path parameter to scope the search.",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search term \u2014 matches against symbol names, file names, and file content"},path:{type:"string",description:"Root directory to search (default: current working directory)"},max_results:{type:"number",description:"Maximum results to return (default: 20)"},file_pattern:{type:"string",description:'Substring filter for file paths (e.g. ".ts", "src/services")'}},required:["query"]},handler:async t=>{let e=(0,tt.resolve)(t.path||process.cwd()),r=await A_(e,t.query,{maxResults:t.max_results||20,filePattern:t.file_pattern});return{content:[{type:"text",text:M_(r,t.query)}]}}},{name:"smart_unfold",description:"Expand a specific symbol (function, class, method) from a file. Returns the full source code of just that symbol. Use after smart_search or smart_outline to read specific code.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Path to the source file"},symbol_name:{type:"string",description:"Name of the symbol to unfold (function, class, method, etc.)"}},required:["file_path","symbol_name"]},handler:async t=>{let e=(0,tt.resolve)(t.file_path),r=await(0,Ou.readFile)(e,"utf-8"),n=zu(e)??process.cwd(),o=R_(r,e,t.symbol_name,n);if(o)return{content:[{type:"text",text:o}]};let s=Fs(r,e,n);if(s.symbols.length>0){let i=s.symbols.map(a=>` - ${a.name} (${a.kind})`).join(`
|
|
243
243
|
`);return{content:[{type:"text",text:`Symbol "${t.symbol_name}" not found in ${t.file_path}.
|
|
244
244
|
|
|
245
245
|
Available symbols:
|
|
246
|
-
${i}`}]}}return{content:[{type:"text",text:`Could not parse ${t.file_path}. File may be unsupported or empty.`}]}}},{name:"smart_outline",description:"Get structural outline of a file \u2014 shows all symbols (functions, classes, methods, types) with signatures but bodies folded. Much cheaper than reading the full file.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Path to the source file"}},required:["file_path"]},handler:async t=>{let e=(0,tt.resolve)(t.file_path),r=await(0,
|
|
246
|
+
${i}`}]}}return{content:[{type:"text",text:`Could not parse ${t.file_path}. File may be unsupported or empty.`}]}}},{name:"smart_outline",description:"Get structural outline of a file \u2014 shows all symbols (functions, classes, methods, types) with signatures but bodies folded. Much cheaper than reading the full file.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Path to the source file"}},required:["file_path"]},handler:async t=>{let e=(0,tt.resolve)(t.file_path),r=await(0,Ou.readFile)(e,"utf-8"),n=Fs(r,e,zu(e)??process.cwd());return n.symbols.length>0?{content:[{type:"text",text:Cr(n)}]}:{content:[{type:"text",text:`Could not parse ${t.file_path}. File may use an unsupported language or be empty.`}]}}},{name:"build_corpus",description:"Build a knowledge corpus from filtered observations. Creates a queryable knowledge agent. Params: name (required), description, project, types (comma-separated), concepts (comma-separated), files (comma-separated), query, dateStart, dateEnd, limit",inputSchema:{type:"object",properties:{name:{type:"string",description:"Corpus name (used as filename)"},description:{type:"string",description:"What this corpus is about"},project:{type:"string",description:"Filter by project"},types:{type:"string",description:"Comma-separated observation types: decision,bugfix,feature,refactor,discovery,change"},concepts:{type:"string",description:"Comma-separated concepts to filter by"},files:{type:"string",description:"Comma-separated file paths to filter by"},query:{type:"string",description:"Semantic search query"},dateStart:{type:"string",description:"Start date (ISO format)"},dateEnd:{type:"string",description:"End date (ISO format)"},limit:{type:"number",description:"Maximum observations (default 500)"}},required:["name"],additionalProperties:!0},handler:async t=>await Dr("/api/corpus",t)},{name:"list_corpora",description:"List all knowledge corpora with their stats and priming status",inputSchema:{type:"object",properties:{},additionalProperties:!0},handler:async t=>await Iu("/api/corpus",t)},{name:"prime_corpus",description:"Prime a knowledge corpus \u2014 creates an AI session loaded with the corpus knowledge. Must be called before query_corpus.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to prime"}},required:["name"],additionalProperties:!0},handler:async t=>{let{name:e,...r}=t;if(typeof e!="string"||e.trim()==="")throw new Error("Missing required argument: name");return await Dr(`/api/corpus/${encodeURIComponent(e)}/prime`,r)}},{name:"query_corpus",description:"Ask a question to a primed knowledge corpus. The corpus must be primed first with prime_corpus.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to query"},question:{type:"string",description:"The question to ask"}},required:["name","question"],additionalProperties:!0},handler:async t=>{let{name:e,...r}=t;if(typeof e!="string"||e.trim()==="")throw new Error("Missing required argument: name");return await Dr(`/api/corpus/${encodeURIComponent(e)}/query`,r)}},{name:"rebuild_corpus",description:"Rebuild a knowledge corpus from its stored filter \u2014 re-runs the search to refresh with new observations. Does not re-prime the session.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to rebuild"}},required:["name"],additionalProperties:!0},handler:async t=>{let{name:e,...r}=t;if(typeof e!="string"||e.trim()==="")throw new Error("Missing required argument: name");return await Dr(`/api/corpus/${encodeURIComponent(e)}/rebuild`,r)}},{name:"reprime_corpus",description:"Create a fresh knowledge agent session for a corpus, clearing prior Q&A context. Use when conversation has drifted or after rebuilding.",inputSchema:{type:"object",properties:{name:{type:"string",description:"Name of the corpus to reprime"}},required:["name"],additionalProperties:!0},handler:async t=>{let{name:e,...r}=t;if(typeof e!="string"||e.trim()==="")throw new Error("Missing required argument: name");return await Dr(`/api/corpus/${encodeURIComponent(e)}/reprime`,r)}}],Mu=new xs({name:"claude-mem",version:yP},{capabilities:{tools:{}}});Mu.setRequestHandler(ia,async()=>({tools:V_.map(t=>({name:t.name,description:t.description,inputSchema:t.inputSchema}))}));Mu.setRequestHandler(ln,async t=>{let e=V_.find(r=>r.name===t.params.name);if(!e)throw new Error(`Unknown tool: ${t.params.name}`);try{return await e.handler(t.params.arguments||{})}catch(r){return y.error("SYSTEM","Tool execution failed",{tool:t.params.name},r instanceof Error?r:new Error(String(r))),{content:[{type:"text",text:`Tool execution failed: ${r instanceof Error?r.message:String(r)}`}],isError:!0}}});var $P=3e4,Yn=null,q_=!1;function Bs(){to("stdio-closed")}function B_(t){y.warn("SYSTEM","MCP stdio stream errored, shutting down",{message:t.message}),to("stdio-error")}function PP(){process.stdin.on("end",Bs),process.stdin.on("close",Bs),process.stdin.on("error",B_)}function TP(){process.stdin.off("end",Bs),process.stdin.off("close",Bs),process.stdin.off("error",B_)}function zP(){if(process.platform==="win32")return;let t=process.ppid;Yn=setInterval(()=>{(process.ppid===1||process.ppid!==t)&&(y.info("SYSTEM","Parent process died, self-exiting to prevent orphan",{initialPpid:t,currentPpid:process.ppid}),to())},$P),Yn.unref&&Yn.unref()}function to(t="shutdown"){q_||(q_=!0,Yn&&clearInterval(Yn),TP(),y.info("SYSTEM","MCP server shutting down",{reason:t}),process.exit(0))}process.on("SIGTERM",to);process.on("SIGINT",to);function RP(){try{let t=(0,Z_.homedir)(),e=[(0,tt.resolve)(t,".claude","plugins","marketplaces","thedotmack"),(0,tt.resolve)(t,".config","claude","plugins","marketplaces","thedotmack")],r=e.some(i=>i&&(0,Vs.existsSync)(i)),n=[(0,tt.resolve)(t,".claude","plugins","cache","thedotmack","claude-mem"),(0,tt.resolve)(t,".config","claude","plugins","cache","thedotmack","claude-mem")],o=n.some(i=>i&&(0,Vs.existsSync)(i)),s=n[0];!r&&o&&y.error("SYSTEM","claude-mem MCP started but no marketplace directory was found at ~/.claude/plugins/marketplaces/thedotmack or the XDG equivalent. The IDE plugin loader needs that directory to fire claude-mem hooks (SessionStart, PostToolUse, Stop, etc.). Without it, MCP search will work but no new memories will be captured. To self-heal, run: node ~/.claude/plugins/cache/thedotmack/claude-mem/*/scripts/smart-install.js (or reinstall the plugin from the marketplace).",{marketplaceCandidates:e,cacheRoot:s})}catch{}}async function IP(){let t=new Ps;PP(),await Mu.connect(t),y.info("SYSTEM","Claude-mem search server started"),RP(),zP(),setTimeout(async()=>{if(Ru()==="server-beta"){y.info("SYSTEM","MCP runtime=server-beta \u2014 skipping worker auto-start",void 0,{});return}await xP()?y.info("SYSTEM","Worker available",void 0,{}):(y.error("SYSTEM","Worker not available",void 0,{}),y.error("SYSTEM","Tools will fail until Worker is started"),y.error("SYSTEM","Start Worker with: npm run worker:restart"))},0)}IP().catch(t=>{y.error("SYSTEM","Fatal error",void 0,t),process.exit(0)});
|