claude-mem 13.0.1 → 13.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,61 +1,61 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var w_=Object.create;var Rs=Object.defineProperty;var E_=Object.getOwnPropertyDescriptor;var $_=Object.getOwnPropertyNames;var k_=Object.getPrototypeOf,x_=Object.prototype.hasOwnProperty;var E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),uu=(t,e)=>{for(var r in e)Rs(t,r,{get:e[r],enumerable:!0})},P_=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of $_(e))!x_.call(t,o)&&o!==r&&Rs(t,o,{get:()=>e[o],enumerable:!(n=E_(e,o))||n.enumerable});return t};var vt=(t,e,r)=>(r=t!=null?w_(k_(t)):{},P_(e||!t||!t.__esModule?Rs(r,"default",{value:t,enumerable:!0}):r,t));var fn=E(q=>{"use strict";Object.defineProperty(q,"__esModule",{value:!0});q.regexpCode=q.getEsmExportName=q.getProperty=q.safeStringify=q.stringify=q.strConcat=q.addCodeArg=q.str=q._=q.nil=q._Code=q.Name=q.IDENTIFIER=q._CodeOrName=void 0;var dn=class{};q._CodeOrName=dn;q.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var Ut=class extends dn{constructor(e){if(super(),!q.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}}};q.Name=Ut;var Ze=class extends dn{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 Ut&&(r[n.str]=(r[n.str]||0)+1),r),{})}};q._Code=Ze;q.nil=new Ze("");function Rf(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Vi(r,e[n]),r.push(t[++n]);return new Ze(r)}q._=Rf;var Wi=new Ze("+");function Of(t,...e){let r=[pn(t[0])],n=0;for(;n<e.length;)r.push(Wi),Vi(r,e[n]),r.push(Wi,pn(t[++n]));return ob(r),new Ze(r)}q.str=Of;function Vi(t,e){e instanceof Ze?t.push(...e._items):e instanceof Ut?t.push(e):t.push(ab(e))}q.addCodeArg=Vi;function ob(t){let e=1;for(;e<t.length-1;){if(t[e]===Wi){let r=sb(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function sb(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof Ut||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 Ut))return`"${t}${e.slice(1)}`}function ib(t,e){return e.emptyStr()?t:t.emptyStr()?e:Of`${t}${e}`}q.strConcat=ib;function ab(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:pn(Array.isArray(t)?t.join(","):t)}function cb(t){return new Ze(pn(t))}q.stringify=cb;function pn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}q.safeStringify=pn;function ub(t){return typeof t=="string"&&q.IDENTIFIER.test(t)?new Ze(`.${t}`):Rf`[${t}]`}q.getProperty=ub;function lb(t){if(typeof t=="string"&&q.IDENTIFIER.test(t))return new Ze(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}q.getEsmExportName=lb;function db(t){return new Ze(t.toString())}q.regexpCode=db});var Ji=E(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.ValueScope=Re.ValueScopeName=Re.Scope=Re.varKinds=Re.UsedValueState=void 0;var Te=fn(),Gi=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},Ao;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(Ao||(Re.UsedValueState=Ao={}));Re.varKinds={const:new Te.Name("const"),let:new Te.Name("let"),var:new Te.Name("var")};var Mo=class{constructor({prefixes:e,parent:r}={}){this._names={},this._prefixes=e,this._parent=r}toName(e){return e instanceof Te.Name?e:this.name(e)}name(e){return new Te.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=Mo;var Co=class extends Te.Name{constructor(e,r){super(r),this.prefix=e}setValue(e,{property:r,itemIndex:n}){this.value=e,this.scopePath=(0,Te._)`.${new Te.Name(r)}[${n}]`}};Re.ValueScopeName=Co;var pb=(0,Te._)`\n`,Ki=class extends Mo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?pb:Te.nil}}get(){return this._scope}name(e){return new Co(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,Te._)`${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=Te.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,Ao.Started);let l=r(u);if(l){let d=this.opts.es5?Re.varKinds.var:Re.varKinds.const;s=(0,Te._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Te._)`${s}${l}${this.opts._n}`;else throw new Gi(u);c.set(u,Ao.Completed)})}return s}};Re.ValueScope=Ki});var A=E(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 L=fn(),Ke=Ji(),zt=fn();Object.defineProperty(M,"_",{enumerable:!0,get:function(){return zt._}});Object.defineProperty(M,"str",{enumerable:!0,get:function(){return zt.str}});Object.defineProperty(M,"strConcat",{enumerable:!0,get:function(){return zt.strConcat}});Object.defineProperty(M,"nil",{enumerable:!0,get:function(){return zt.nil}});Object.defineProperty(M,"getProperty",{enumerable:!0,get:function(){return zt.getProperty}});Object.defineProperty(M,"stringify",{enumerable:!0,get:function(){return zt.stringify}});Object.defineProperty(M,"regexpCode",{enumerable:!0,get:function(){return zt.regexpCode}});Object.defineProperty(M,"Name",{enumerable:!0,get:function(){return zt.Name}});var jo=Ji();Object.defineProperty(M,"Scope",{enumerable:!0,get:function(){return jo.Scope}});Object.defineProperty(M,"ValueScope",{enumerable:!0,get:function(){return jo.ValueScope}});Object.defineProperty(M,"ValueScopeName",{enumerable:!0,get:function(){return jo.ValueScopeName}});Object.defineProperty(M,"varKinds",{enumerable:!0,get:function(){return jo.varKinds}});M.operators={GT:new L._Code(">"),GTE:new L._Code(">="),LT:new L._Code("<"),LTE:new L._Code("<="),EQ:new L._Code("==="),NEQ:new L._Code("!=="),NOT:new L._Code("!"),OR:new L._Code("||"),AND:new L._Code("&&"),ADD:new L._Code("+")};var ht=class{optimizeNodes(){return this}optimizeNames(e,r){return this}},Bi=class extends ht{constructor(e,r,n){super(),this.varKind=e,this.name=r,this.rhs=n}render({es5:e,_n:r}){let n=e?Ke.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=pr(this.rhs,e,r)),this}get names(){return this.rhs instanceof L._CodeOrName?this.rhs.names:{}}},No=class extends ht{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 L.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=pr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof L.Name?{}:{...this.lhs.names};return Lo(e,this.rhs)}},Yi=class extends No{constructor(e,r,n,o){super(e,n,o),this.op=r}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},Xi=class extends ht{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},Qi=class extends ht{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},ea=class extends ht{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},ta=class extends ht{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=pr(this.code,e,r),this}get names(){return this.code instanceof L._CodeOrName?this.code.names:{}}},mn=class extends ht{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)||(fb(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>qt(e,r.names),{})}},gt=class extends mn{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},ra=class extends mn{},dr=class extends gt{};dr.kind="else";var Zt=class t extends gt{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 dr(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(If(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=pr(this.condition,e,r),this}get names(){let e=super.names;return Lo(e,this.condition),this.else&&qt(e,this.else.names),e}};Zt.kind="if";var Ft=class extends gt{};Ft.kind="for";var na=class extends Ft{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=pr(this.iteration,e,r),this}get names(){return qt(super.names,this.iteration.names)}},oa=class extends Ft{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?Ke.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=Lo(super.names,this.from);return Lo(e,this.to)}},Do=class extends Ft{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=pr(this.iterable,e,r),this}get names(){return qt(super.names,this.iterable.names)}},hn=class extends gt{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)}};hn.kind="func";var gn=class extends mn{render(e){return"return "+super.render(e)}};gn.kind="return";var sa=class extends gt{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&&qt(e,this.catch.names),this.finally&&qt(e,this.finally.names),e}},_n=class extends gt{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};_n.kind="catch";var yn=class extends gt{render(e){return"finally"+super.render(e)}};yn.kind="finally";var ia=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
3
- `:""},this._extScope=e,this._scope=new Ke.Scope({parent:e}),this._nodes=[new ra]}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 Bi(e,s,n)),s}const(e,r,n){return this._def(Ke.varKinds.const,e,r,n)}let(e,r,n){return this._def(Ke.varKinds.let,e,r,n)}var(e,r,n){return this._def(Ke.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new No(e,r,n))}add(e,r){return this._leafNode(new Yi(e,M.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==L.nil&&this._leafNode(new ta(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,L.addCodeArg)(r,o));return r.push("}"),new L._Code(r)}if(e,r,n){if(this._blockNode(new Zt(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 Zt(e))}else(){return this._elseNode(new dr)}endIf(){return this._endBlockNode(Zt,dr)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new na(e),r)}forRange(e,r,n,o,s=this.opts.es5?Ke.varKinds.var:Ke.varKinds.let){let i=this._scope.toName(e);return this._for(new oa(s,i,r,n),()=>o(i))}forOf(e,r,n,o=Ke.varKinds.const){let s=this._scope.toName(e);if(this.opts.es5){let i=r instanceof L.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,L._)`${i}.length`,a=>{this.var(s,(0,L._)`${i}[${a}]`),n(s)})}return this._for(new Do("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?Ke.varKinds.var:Ke.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,L._)`Object.keys(${r})`,n);let s=this._scope.toName(e);return this._for(new Do("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Ft)}label(e){return this._leafNode(new Xi(e))}break(e){return this._leafNode(new Qi(e))}return(e){let r=new gn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(gn)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new sa;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new _n(s),r(s)}return n&&(this._currNode=o.finally=new yn,this.code(n)),this._endBlockNode(_n,yn)}throw(e){return this._leafNode(new ea(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=L.nil,n,o){return this._blockNode(new hn(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(hn)}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 Zt))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=ia;function qt(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Lo(t,e){return e instanceof L._CodeOrName?qt(t,e.names):t}function pr(t,e,r){if(t instanceof L.Name)return n(t);if(!o(t))return t;return new L._Code(t._items.reduce((s,i)=>(i instanceof L.Name&&(i=n(i)),i instanceof L._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 L._Code&&s._items.some(i=>i instanceof L.Name&&e[i.str]===1&&r[i.str]!==void 0)}}function fb(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function If(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,L._)`!${aa(t)}`}M.not=If;var mb=Af(M.operators.AND);function hb(...t){return t.reduce(mb)}M.and=hb;var gb=Af(M.operators.OR);function _b(...t){return t.reduce(gb)}M.or=_b;function Af(t){return(e,r)=>e===L.nil?r:r===L.nil?e:(0,L._)`${aa(e)} ${t} ${aa(r)}`}function aa(t){return t instanceof L.Name?t:(0,L._)`(${t})`}});var Z=E(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 G=A(),yb=fn();function Sb(t){let e={};for(let r of t)e[r]=!0;return e}C.toHash=Sb;function vb(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Nf(t,e),!Df(e,t.self.RULES.all))}C.alwaysValidSchema=vb;function Nf(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]||Uf(t,`unknown keyword: "${s}"`)}C.checkUnknownRules=Nf;function Df(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}C.schemaHasRules=Df;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 wb({topSchemaRef:t,schemaPath:e},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,G._)`${r}`}return(0,G._)`${t}${e}${(0,G.getProperty)(n)}`}C.schemaRefOrVal=wb;function Eb(t){return Lf(decodeURIComponent(t))}C.unescapeFragment=Eb;function $b(t){return encodeURIComponent(ua(t))}C.escapeFragment=$b;function ua(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}C.escapeJsonPointer=ua;function Lf(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}C.unescapeJsonPointer=Lf;function kb(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}C.eachItem=kb;function Mf({mergeNames:t,mergeToName:e,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof G.Name?(s instanceof G.Name?t(o,s,i):e(o,s,i),i):s instanceof G.Name?(e(o,i,s),s):r(s,i);return a===G.Name&&!(c instanceof G.Name)?n(o,c):c}}C.mergeEvaluated={props:Mf({mergeNames:(t,e,r)=>t.if((0,G._)`${r} !== true && ${e} !== undefined`,()=>{t.if((0,G._)`${e} === true`,()=>t.assign(r,!0),()=>t.assign(r,(0,G._)`${r} || {}`).code((0,G._)`Object.assign(${r}, ${e})`))}),mergeToName:(t,e,r)=>t.if((0,G._)`${r} !== true`,()=>{e===!0?t.assign(r,!0):(t.assign(r,(0,G._)`${r} || {}`),la(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:jf}),items:Mf({mergeNames:(t,e,r)=>t.if((0,G._)`${r} !== true && ${e} !== undefined`,()=>t.assign(r,(0,G._)`${e} === true ? true : ${r} > ${e} ? ${r} : ${e}`)),mergeToName:(t,e,r)=>t.if((0,G._)`${r} !== true`,()=>t.assign(r,e===!0?!0:(0,G._)`${r} > ${e} ? ${r} : ${e}`)),mergeValues:(t,e)=>t===!0?!0:Math.max(t,e),resultToName:(t,e)=>t.var("items",e)})};function jf(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,G._)`{}`);return e!==void 0&&la(t,r,e),r}C.evaluatedPropsToName=jf;function la(t,e,r){Object.keys(r).forEach(n=>t.assign((0,G._)`${e}${(0,G.getProperty)(n)}`,!0))}C.setEvaluated=la;var Cf={};function xb(t,e){return t.scopeValue("func",{ref:e,code:Cf[e.code]||(Cf[e.code]=new yb._Code(e.code))})}C.useFunc=xb;var ca;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(ca||(C.Type=ca={}));function Pb(t,e,r){if(t instanceof G.Name){let n=e===ca.Num;return r?n?(0,G._)`"[" + ${t} + "]"`:(0,G._)`"['" + ${t} + "']"`:n?(0,G._)`"/" + ${t}`:(0,G._)`"/" + ${t}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,G.getProperty)(t).toString():"/"+ua(t)}C.getErrorPath=Pb;function Uf(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=Uf});var _t=E(da=>{"use strict";Object.defineProperty(da,"__esModule",{value:!0});var ye=A(),zb={data:new ye.Name("data"),valCxt:new ye.Name("valCxt"),instancePath:new ye.Name("instancePath"),parentData:new ye.Name("parentData"),parentDataProperty:new ye.Name("parentDataProperty"),rootData:new ye.Name("rootData"),dynamicAnchors:new ye.Name("dynamicAnchors"),vErrors:new ye.Name("vErrors"),errors:new ye.Name("errors"),this:new ye.Name("this"),self:new ye.Name("self"),scope:new ye.Name("scope"),json:new ye.Name("json"),jsonPos:new ye.Name("jsonPos"),jsonLen:new ye.Name("jsonLen"),jsonPart:new ye.Name("jsonPart")};da.default=zb});var Sn=E(Se=>{"use strict";Object.defineProperty(Se,"__esModule",{value:!0});Se.extendErrors=Se.resetErrorsCount=Se.reportExtraError=Se.reportError=Se.keyword$DataError=Se.keywordError=void 0;var F=A(),Uo=Z(),xe=_t();Se.keywordError={message:({keyword:t})=>(0,F.str)`must pass "${t}" keyword validation`};Se.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,F.str)`"${t}" keyword must be ${e} ($data)`:(0,F.str)`"${t}" keyword is invalid ($data)`};function Tb(t,e=Se.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=qf(t,e,r);n??(i||a)?Zf(s,c):Ff(o,(0,F._)`[${c}]`)}Se.reportError=Tb;function Rb(t,e=Se.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=qf(t,e,r);Zf(o,a),s||i||Ff(n,xe.default.vErrors)}Se.reportExtraError=Rb;function Ob(t,e){t.assign(xe.default.errors,e),t.if((0,F._)`${xe.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,F._)`${xe.default.vErrors}.length`,e),()=>t.assign(xe.default.vErrors,null)))}Se.resetErrorsCount=Ob;function Ib({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,xe.default.errors,a=>{t.const(i,(0,F._)`${xe.default.vErrors}[${a}]`),t.if((0,F._)`${i}.instancePath === undefined`,()=>t.assign((0,F._)`${i}.instancePath`,(0,F.strConcat)(xe.default.instancePath,s.errorPath))),t.assign((0,F._)`${i}.schemaPath`,(0,F.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,F._)`${i}.schema`,r),t.assign((0,F._)`${i}.data`,n))})}Se.extendErrors=Ib;function Zf(t,e){let r=t.const("err",e);t.if((0,F._)`${xe.default.vErrors} === null`,()=>t.assign(xe.default.vErrors,(0,F._)`[${r}]`),(0,F._)`${xe.default.vErrors}.push(${r})`),t.code((0,F._)`${xe.default.errors}++`)}function Ff(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,F._)`new ${t.ValidationError}(${e})`):(r.assign((0,F._)`${n}.errors`,e),r.return(!1))}var Ht={keyword:new F.Name("keyword"),schemaPath:new F.Name("schemaPath"),params:new F.Name("params"),propertyName:new F.Name("propertyName"),message:new F.Name("message"),schema:new F.Name("schema"),parentSchema:new F.Name("parentSchema")};function qf(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,F._)`{}`:Ab(t,e,r)}function Ab(t,e,r={}){let{gen:n,it:o}=t,s=[Mb(o,r),Cb(t,r)];return Nb(t,e,s),n.object(...s)}function Mb({errorPath:t},{instancePath:e}){let r=e?(0,F.str)`${t}${(0,Uo.getErrorPath)(e,Uo.Type.Str)}`:t;return[xe.default.instancePath,(0,F.strConcat)(xe.default.instancePath,r)]}function Cb({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,F.str)`${e}/${t}`;return r&&(o=(0,F.str)`${o}${(0,Uo.getErrorPath)(r,Uo.Type.Str)}`),[Ht.schemaPath,o]}function Nb(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([Ht.keyword,o],[Ht.params,typeof e=="function"?e(t):e||(0,F._)`{}`]),c.messages&&n.push([Ht.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Ht.schema,i],[Ht.parentSchema,(0,F._)`${l}${d}`],[xe.default.data,s]),u&&n.push([Ht.propertyName,u])}});var Wf=E(fr=>{"use strict";Object.defineProperty(fr,"__esModule",{value:!0});fr.boolOrEmptySchema=fr.topBoolOrEmptySchema=void 0;var Db=Sn(),Lb=A(),jb=_t(),Ub={message:"boolean schema is false"};function Zb(t){let{gen:e,schema:r,validateName:n}=t;r===!1?Hf(t,!1):typeof r=="object"&&r.$async===!0?e.return(jb.default.data):(e.assign((0,Lb._)`${n}.errors`,null),e.return(!0))}fr.topBoolOrEmptySchema=Zb;function Fb(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),Hf(t)):r.var(e,!0)}fr.boolOrEmptySchema=Fb;function Hf(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,Db.reportError)(o,Ub,void 0,e)}});var pa=E(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.getRules=mr.isJSONType=void 0;var qb=["string","number","integer","boolean","null","object","array"],Hb=new Set(qb);function Wb(t){return typeof t=="string"&&Hb.has(t)}mr.isJSONType=Wb;function Vb(){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:{}}}mr.getRules=Vb});var fa=E(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.shouldUseRule=Tt.shouldUseGroup=Tt.schemaHasRulesForType=void 0;function Gb({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&Vf(t,n)}Tt.schemaHasRulesForType=Gb;function Vf(t,e){return e.rules.some(r=>Gf(t,r))}Tt.shouldUseGroup=Vf;function Gf(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))}Tt.shouldUseRule=Gf});var vn=E(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.reportTypeError=ve.checkDataTypes=ve.checkDataType=ve.coerceAndCheckDataType=ve.getJSONTypes=ve.getSchemaTypes=ve.DataType=void 0;var Kb=pa(),Jb=fa(),Bb=Sn(),I=A(),Kf=Z(),hr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(hr||(ve.DataType=hr={}));function Yb(t){let e=Jf(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}ve.getSchemaTypes=Yb;function Jf(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(Kb.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}ve.getJSONTypes=Jf;function Xb(t,e){let{gen:r,data:n,opts:o}=t,s=Qb(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,Jb.schemaHasRulesForType)(t,e[0]));if(i){let a=ha(e,n,o.strictNumbers,hr.Wrong);r.if(a,()=>{s.length?ew(t,e,s):ga(t)})}return i}ve.coerceAndCheckDataType=Xb;var Bf=new Set(["string","number","integer","boolean","null"]);function Qb(t,e){return e?t.filter(r=>Bf.has(r)||e==="array"&&r==="array"):[]}function ew(t,e,r){let{gen:n,data:o,opts:s}=t,i=n.let("dataType",(0,I._)`typeof ${o}`),a=n.let("coerced",(0,I._)`undefined`);s.coerceTypes==="array"&&n.if((0,I._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,I._)`${o}[0]`).assign(i,(0,I._)`typeof ${o}`).if(ha(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,I._)`${a} !== undefined`);for(let u of r)(Bf.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),ga(t),n.endIf(),n.if((0,I._)`${a} !== undefined`,()=>{n.assign(o,a),tw(t,a)});function c(u){switch(u){case"string":n.elseIf((0,I._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,I._)`"" + ${o}`).elseIf((0,I._)`${o} === null`).assign(a,(0,I._)`""`);return;case"number":n.elseIf((0,I._)`${i} == "boolean" || ${o} === null
4
- || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,I._)`+${o}`);return;case"integer":n.elseIf((0,I._)`${i} === "boolean" || ${o} === null
5
- || (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,I._)`+${o}`);return;case"boolean":n.elseIf((0,I._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,I._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,I._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,I._)`${i} === "string" || ${i} === "number"
6
- || ${i} === "boolean" || ${o} === null`).assign(a,(0,I._)`[${o}]`)}}}function tw({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,I._)`${e} !== undefined`,()=>t.assign((0,I._)`${e}[${r}]`,n))}function ma(t,e,r,n=hr.Correct){let o=n===hr.Correct?I.operators.EQ:I.operators.NEQ,s;switch(t){case"null":return(0,I._)`${e} ${o} null`;case"array":s=(0,I._)`Array.isArray(${e})`;break;case"object":s=(0,I._)`${e} && typeof ${e} == "object" && !Array.isArray(${e})`;break;case"integer":s=i((0,I._)`!(${e} % 1) && !isNaN(${e})`);break;case"number":s=i();break;default:return(0,I._)`typeof ${e} ${o} ${t}`}return n===hr.Correct?s:(0,I.not)(s);function i(a=I.nil){return(0,I.and)((0,I._)`typeof ${e} == "number"`,a,r?(0,I._)`isFinite(${e})`:I.nil)}}ve.checkDataType=ma;function ha(t,e,r,n){if(t.length===1)return ma(t[0],e,r,n);let o,s=(0,Kf.toHash)(t);if(s.array&&s.object){let i=(0,I._)`typeof ${e} != "object"`;o=s.null?i:(0,I._)`!${e} || ${i}`,delete s.null,delete s.array,delete s.object}else o=I.nil;s.number&&delete s.integer;for(let i in s)o=(0,I.and)(o,ma(i,e,r,n));return o}ve.checkDataTypes=ha;var rw={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,I._)`{type: ${t}}`:(0,I._)`{type: ${e}}`};function ga(t){let e=nw(t);(0,Bb.reportError)(e,rw)}ve.reportTypeError=ga;function nw(t){let{gen:e,data:r,schema:n}=t,o=(0,Kf.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var Xf=E(Zo=>{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.assignDefaults=void 0;var gr=A(),ow=Z();function sw(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)Yf(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Yf(t,s,o.default))}Zo.assignDefaults=sw;function Yf(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,gr._)`${s}${(0,gr.getProperty)(e)}`;if(o){(0,ow.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,gr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,gr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,gr._)`${a} = ${(0,gr.stringify)(r)}`)}});var Fe=E(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(),_a=Z(),Rt=_t(),iw=Z();function aw(t,e){let{gen:r,data:n,it:o}=t;r.if(Sa(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,X._)`${e}`},!0),t.error()})}V.checkReportMissingProp=aw;function cw({gen:t,data:e,it:{opts:r}},n,o){return(0,X.or)(...n.map(s=>(0,X.and)(Sa(t,e,s,r.ownProperties),(0,X._)`${o} = ${s}`)))}V.checkMissingProp=cw;function uw(t,e){t.setParams({missingProperty:e},!0),t.error()}V.reportMissingProp=uw;function Qf(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,X._)`Object.prototype.hasOwnProperty`})}V.hasPropFunc=Qf;function ya(t,e,r){return(0,X._)`${Qf(t)}.call(${e}, ${r})`}V.isOwnProperty=ya;function lw(t,e,r,n){let o=(0,X._)`${e}${(0,X.getProperty)(r)} !== undefined`;return n?(0,X._)`${o} && ${ya(t,e,r)}`:o}V.propertyInData=lw;function Sa(t,e,r,n){let o=(0,X._)`${e}${(0,X.getProperty)(r)} === undefined`;return n?(0,X.or)(o,(0,X.not)(ya(t,e,r))):o}V.noPropertyInData=Sa;function em(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}V.allSchemaProperties=em;function dw(t,e){return em(e).filter(r=>!(0,_a.alwaysValidSchema)(t,e[r]))}V.schemaProperties=dw;function pw({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=[[Rt.default.instancePath,(0,X.strConcat)(Rt.default.instancePath,s)],[Rt.default.parentData,i.parentData],[Rt.default.parentDataProperty,i.parentDataProperty],[Rt.default.rootData,Rt.default.rootData]];i.opts.dynamicRef&&d.push([Rt.default.dynamicAnchors,Rt.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=pw;var fw=(0,X._)`new RegExp`;function mw({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"?fw:(0,iw.useFunc)(t,o)}(${r}, ${n})`})}V.usePattern=mw;function hw(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:_a.Type.Num},s),e.if((0,X.not)(s),a)})}}V.validateArray=hw;function gw(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,_a.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=gw});var nm=E(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.validateKeywordUsage=tt.validSchemaType=tt.funcKeywordCode=tt.macroKeywordCode=void 0;var Pe=A(),Wt=_t(),_w=Fe(),yw=Sn();function Sw(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=rm(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))}tt.macroKeywordCode=Sw;function vw(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;ww(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=rm(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&&tm(t),y(()=>t.error());else{let b=e.async?f():m();e.modifying&&tm(t),y(()=>bw(t,b))}}function f(){let b=n.let("ruleErrs",null);return n.try(()=>_((0,Pe._)`await `),w=>n.assign(d,!1).if((0,Pe._)`${w} instanceof ${c.ValidationError}`,()=>n.assign(b,(0,Pe._)`${w}.errors`),()=>n.throw(w))),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 w=c.opts.passContext?Wt.default.this:Wt.default.self,v=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,Pe._)`${b}${(0,_w.callValidateCode)(t,l,w,v)}`,e.modifying)}function y(b){var w;n.if((0,Pe.not)((w=e.valid)!==null&&w!==void 0?w:d),b)}}tt.funcKeywordCode=vw;function tm(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Pe._)`${n.parentData}[${n.parentDataProperty}]`))}function bw(t,e){let{gen:r}=t;r.if((0,Pe._)`Array.isArray(${e})`,()=>{r.assign(Wt.default.vErrors,(0,Pe._)`${Wt.default.vErrors} === null ? ${e} : ${Wt.default.vErrors}.concat(${e})`).assign(Wt.default.errors,(0,Pe._)`${Wt.default.vErrors}.length`),(0,yw.extendErrors)(t)},()=>t.error())}function ww({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function rm(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 Ew(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")}tt.validSchemaType=Ew;function $w({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)}}tt.validateKeywordUsage=$w});var sm=E(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.extendSubschemaMode=Ot.extendSubschemaData=Ot.getSubschema=void 0;var rt=A(),om=Z();function kw(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,rt._)`${t.schemaPath}${(0,rt.getProperty)(e)}`,errSchemaPath:`${t.errSchemaPath}/${e}`}:{schema:a[r],schemaPath:(0,rt._)`${t.schemaPath}${(0,rt.getProperty)(e)}${(0,rt.getProperty)(r)}`,errSchemaPath:`${t.errSchemaPath}/${e}/${(0,om.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')}Ot.getSubschema=kw;function xw(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,rt._)`${e.data}${(0,rt.getProperty)(r)}`,!0);c(p),t.errorPath=(0,rt.str)`${u}${(0,om.getErrorPath)(r,n,d.jsPropertySyntax)}`,t.parentDataProperty=(0,rt._)`${r}`,t.dataPathArr=[...l,t.parentDataProperty]}if(o!==void 0){let u=o instanceof rt.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]}}Ot.extendSubschemaData=xw;function Pw(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}Ot.extendSubschemaMode=Pw});var va=E((FA,im)=>{"use strict";im.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 cm=E((qA,am)=>{"use strict";var It=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(){};Fo(e,n,o,t,"",t)};It.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};It.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};It.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};It.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 Fo(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 It.arrayKeywords)for(var p=0;p<d.length;p++)Fo(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in It.propsKeywords){if(d&&typeof d=="object")for(var f in d)Fo(t,e,r,d[f],o+"/"+l+"/"+zw(f),s,o,l,n,f)}else(l in It.keywords||t.allKeys&&!(l in It.skipKeywords))&&Fo(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function zw(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var bn=E(Oe=>{"use strict";Object.defineProperty(Oe,"__esModule",{value:!0});Oe.getSchemaRefs=Oe.resolveUrl=Oe.normalizeId=Oe._getFullPath=Oe.getFullPath=Oe.inlineRef=void 0;var Tw=Z(),Rw=va(),Ow=cm(),Iw=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Aw(t,e=!0){return typeof t=="boolean"?!0:e===!0?!ba(t):e?um(t)<=e:!1}Oe.inlineRef=Aw;var Mw=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function ba(t){for(let e in t){if(Mw.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(ba)||typeof r=="object"&&ba(r))return!0}return!1}function um(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!Iw.has(r)&&(typeof t[r]=="object"&&(0,Tw.eachItem)(t[r],n=>e+=um(n)),e===1/0))return 1/0}return e}function lm(t,e="",r){r!==!1&&(e=_r(e));let n=t.parse(e);return dm(t,n)}Oe.getFullPath=lm;function dm(t,e){return t.serialize(e).split("#")[0]+"#"}Oe._getFullPath=dm;var Cw=/#\/?$/;function _r(t){return t?t.replace(Cw,""):""}Oe.normalizeId=_r;function Nw(t,e,r){return r=_r(r),t.resolve(e,r)}Oe.resolveUrl=Nw;var Dw=/^[a-z_][-a-z0-9._]*$/i;function Lw(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=_r(t[r]||e),s={"":o},i=lm(n,o,!1),a={},c=new Set;return Ow(t,{allKeys:!0},(d,p,f,m)=>{if(m===void 0)return;let _=i+p,y=s[m];typeof d[r]=="string"&&(y=b.call(this,d[r])),w.call(this,d.$anchor),w.call(this,d.$dynamicAnchor),s[p]=y;function b(v){let x=this.opts.uriResolver.resolve;if(v=_r(y?x(y,v):v),c.has(v))throw l(v);c.add(v);let k=this.refs[v];return typeof k=="string"&&(k=this.refs[k]),typeof k=="object"?u(d,k.schema,v):v!==_r(_)&&(v[0]==="#"?(u(d,a[v],v),a[v]=d):this.refs[v]=_),v}function w(v){if(typeof v=="string"){if(!Dw.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`)}}Oe.getSchemaRefs=Lw});var $n=E(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});At.getData=At.KeywordCxt=At.validateFunctionCode=void 0;var gm=Wf(),pm=vn(),Ea=fa(),qo=vn(),jw=Xf(),En=nm(),wa=sm(),z=A(),R=_t(),Uw=bn(),yt=Z(),wn=Sn();function Zw(t){if(Sm(t)&&(vm(t),ym(t))){Hw(t);return}_m(t,()=>(0,gm.topBoolOrEmptySchema)(t))}At.validateFunctionCode=Zw;function _m({gen:t,validateName:e,schema:r,schemaEnv:n,opts:o},s){o.code.es5?t.func(e,(0,z._)`${R.default.data}, ${R.default.valCxt}`,n.$async,()=>{t.code((0,z._)`"use strict"; ${fm(r,o)}`),qw(t,o),t.code(s)}):t.func(e,(0,z._)`${R.default.data}, ${Fw(o)}`,n.$async,()=>t.code(fm(r,o)).code(s))}function Fw(t){return(0,z._)`{${R.default.instancePath}="", ${R.default.parentData}, ${R.default.parentDataProperty}, ${R.default.rootData}=${R.default.data}${t.dynamicRef?(0,z._)`, ${R.default.dynamicAnchors}={}`:z.nil}}={}`}function qw(t,e){t.if(R.default.valCxt,()=>{t.var(R.default.instancePath,(0,z._)`${R.default.valCxt}.${R.default.instancePath}`),t.var(R.default.parentData,(0,z._)`${R.default.valCxt}.${R.default.parentData}`),t.var(R.default.parentDataProperty,(0,z._)`${R.default.valCxt}.${R.default.parentDataProperty}`),t.var(R.default.rootData,(0,z._)`${R.default.valCxt}.${R.default.rootData}`),e.dynamicRef&&t.var(R.default.dynamicAnchors,(0,z._)`${R.default.valCxt}.${R.default.dynamicAnchors}`)},()=>{t.var(R.default.instancePath,(0,z._)`""`),t.var(R.default.parentData,(0,z._)`undefined`),t.var(R.default.parentDataProperty,(0,z._)`undefined`),t.var(R.default.rootData,R.default.data),e.dynamicRef&&t.var(R.default.dynamicAnchors,(0,z._)`{}`)})}function Hw(t){let{schema:e,opts:r,gen:n}=t;_m(t,()=>{r.$comment&&e.$comment&&wm(t),Jw(t),n.let(R.default.vErrors,null),n.let(R.default.errors,0),r.unevaluated&&Ww(t),bm(t),Xw(t)})}function Ww(t){let{gen:e,validateName:r}=t;t.evaluated=e.const("evaluated",(0,z._)`${r}.evaluated`),e.if((0,z._)`${t.evaluated}.dynamicProps`,()=>e.assign((0,z._)`${t.evaluated}.props`,(0,z._)`undefined`)),e.if((0,z._)`${t.evaluated}.dynamicItems`,()=>e.assign((0,z._)`${t.evaluated}.items`,(0,z._)`undefined`))}function fm(t,e){let r=typeof t=="object"&&t[e.schemaId];return r&&(e.code.source||e.code.process)?(0,z._)`/*# sourceURL=${r} */`:z.nil}function Vw(t,e){if(Sm(t)&&(vm(t),ym(t))){Gw(t,e);return}(0,gm.boolOrEmptySchema)(t,e)}function ym({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 Sm(t){return typeof t.schema!="boolean"}function Gw(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&wm(t),Bw(t),Yw(t);let s=n.const("_errs",R.default.errors);bm(t,s),n.var(e,(0,z._)`${s} === ${R.default.errors}`)}function vm(t){(0,yt.checkUnknownRules)(t),Kw(t)}function bm(t,e){if(t.opts.jtd)return mm(t,[],!1,e);let r=(0,pm.getSchemaTypes)(t.schema),n=(0,pm.coerceAndCheckDataType)(t,r);mm(t,r,!n,e)}function Kw(t){let{schema:e,errSchemaPath:r,opts:n,self:o}=t;e.$ref&&n.ignoreKeywordsWithRef&&(0,yt.schemaHasRulesButRef)(e,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Jw(t){let{schema:e,opts:r}=t;e.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,yt.checkStrictMode)(t,"default is ignored in the schema root")}function Bw(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,Uw.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function Yw(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function wm({gen:t,schemaEnv:e,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)t.code((0,z._)`${R.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,z.str)`${n}/$comment`,a=t.scopeValue("root",{ref:e.root});t.code((0,z._)`${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,z._)`${R.default.errors} === 0`,()=>e.return(R.default.data),()=>e.throw((0,z._)`new ${o}(${R.default.vErrors})`)):(e.assign((0,z._)`${n}.errors`,R.default.vErrors),s.unevaluated&&Qw(t),e.return((0,z._)`${R.default.errors} === 0`))}function Qw({gen:t,evaluated:e,props:r,items:n}){r instanceof z.Name&&t.assign((0,z._)`${e}.props`,r),n instanceof z.Name&&t.assign((0,z._)`${e}.items`,n)}function mm(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,yt.schemaHasRulesButRef)(s,l))){o.block(()=>$m(t,"$ref",l.all.$ref.definition));return}c.jtd||eE(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,Ea.shouldUseGroup)(s,p)&&(p.type?(o.if((0,qo.checkDataType)(p.type,i,c.strictNumbers)),hm(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,qo.reportTypeError)(t)),o.endIf()):hm(t,p),a||o.if((0,z._)`${R.default.errors} === ${n||0}`))}}function hm(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,jw.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Ea.shouldUseRule)(n,s)&&$m(t,s.keyword,s.definition,e.type)})}function eE(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(tE(t,e),t.opts.allowUnionTypes||rE(t,e),nE(t,t.dataTypes))}function tE(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Em(t.dataTypes,r)||$a(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),sE(t,e)}}function rE(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&$a(t,"use allowUnionTypes to allow union type keyword")}function nE(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Ea.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>oE(e,i))&&$a(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function oE(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Em(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function sE(t,e){let r=[];for(let n of t.dataTypes)Em(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function $a(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,yt.checkStrictMode)(t,e,t.opts.strictTypes)}var Ho=class{constructor(e,r,n){if((0,En.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,yt.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",km(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,En.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,z.not)(e),r,n)}failResult(e,r,n){this.gen.if(e),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,r){this.failResult((0,z.not)(e),void 0,r)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:r}=this;this.fail((0,z._)`${r} !== undefined && (${(0,z.or)(this.invalid$data(),e)})`)}error(e,r,n){if(r){this.setParams(r),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,r){(e?wn.reportExtraError:wn.reportError)(this,this.def.error,r)}$dataError(){(0,wn.reportError)(this,this.def.$dataError||wn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,wn.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,r){r?Object.assign(this.params,e):this.params=e}block$data(e,r,n=z.nil){this.gen.block(()=>{this.check$data(e,n),r()})}check$data(e=z.nil,r=z.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,z.or)((0,z._)`${o} === undefined`,r)),e!==z.nil&&n.assign(e,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==z.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,z.or)(i(),a());function i(){if(n.length){if(!(r instanceof z.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,z._)`${(0,qo.checkDataTypes)(c,r,s.opts.strictNumbers,qo.DataType.Wrong)}`}return z.nil}function a(){if(o.validateSchema){let c=e.scopeValue("validate$data",{ref:o.validateSchema});return(0,z._)`!${c}(${r})`}return z.nil}}subschema(e,r){let n=(0,wa.getSubschema)(this.it,e);(0,wa.extendSubschemaData)(n,this.it,e),(0,wa.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return Vw(o,r),o}mergeEvaluated(e,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=yt.mergeEvaluated.props(o,e.props,n.props,r)),n.items!==!0&&e.items!==void 0&&(n.items=yt.mergeEvaluated.items(o,e.items,n.items,r)))}mergeValidEvaluated(e,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(e,z.Name)),!0}};At.KeywordCxt=Ho;function $m(t,e,r,n){let o=new Ho(t,r,e);"code"in r?r.code(o,n):o.$data&&r.validate?(0,En.funcKeywordCode)(o,r):"macro"in r?(0,En.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,En.funcKeywordCode)(o,r)}var iE=/^\/(?:[^~]|~0|~1)*$/,aE=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function km(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return R.default.rootData;if(t[0]==="/"){if(!iE.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=R.default.rootData}else{let u=aE.exec(t);if(!u)throw new Error(`Invalid JSON-pointer: ${t}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=e)throw new Error(c("property/index",l));return n[e-l]}if(l>e)throw new Error(c("data",l));if(s=r[e-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,z._)`${s}${(0,z.getProperty)((0,yt.unescapeJsonPointer)(u))}`,i=(0,z._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${e}`}}At.getData=km});var Wo=E(xa=>{"use strict";Object.defineProperty(xa,"__esModule",{value:!0});var ka=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};xa.default=ka});var kn=E(Ta=>{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});var Pa=bn(),za=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Pa.resolveUrl)(e,r,n),this.missingSchema=(0,Pa.normalizeId)((0,Pa.getFullPath)(e,this.missingRef))}};Ta.default=za});var Go=E(qe=>{"use strict";Object.defineProperty(qe,"__esModule",{value:!0});qe.resolveSchema=qe.getCompilingSchema=qe.resolveRef=qe.compileSchema=qe.SchemaEnv=void 0;var Je=A(),cE=Wo(),Vt=_t(),Be=bn(),xm=Z(),uE=$n(),yr=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,Be.normalizeId)(n?.[e.schemaId||"$id"]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=n?.$async,this.refs={}}};qe.SchemaEnv=yr;function Oa(t){let e=Pm.call(this,t);if(e)return e;let r=(0,Be.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new Je.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:cE.default,code:(0,Je._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Vt.default.data,parentData:Vt.default.parentData,parentDataProperty:Vt.default.parentDataProperty,dataNames:[Vt.default.data],dataPathArr:[Je.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Je.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Je.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Je._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,uE.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(Vt.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let f=new Function(`${Vt.default.self}`,`${Vt.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 Je.Name?void 0:m,items:_ instanceof Je.Name?void 0:_,dynamicProps:m instanceof Je.Name,dynamicItems:_ instanceof Je.Name},f.source&&(f.source.evaluated=(0,Je.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)}}qe.compileSchema=Oa;function lE(t,e,r){var n;r=(0,Be.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=fE.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 yr({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=dE.call(this,s)}qe.resolveRef=lE;function dE(t){return(0,Be.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:Oa.call(this,t)}function Pm(t){for(let e of this._compilations)if(pE(e,t))return e}qe.getCompilingSchema=Pm;function pE(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function fE(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Vo.call(this,t,e)}function Vo(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Be._getFullPath)(this.opts.uriResolver,r),o=(0,Be.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return Ra.call(this,r,t);let s=(0,Be.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Vo.call(this,t,i);return typeof a?.schema!="object"?void 0:Ra.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||Oa.call(this,i),s===(0,Be.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Be.resolveUrl)(this.opts.uriResolver,o,u)),new yr({schema:a,schemaId:c,root:t,baseId:o})}return Ra.call(this,r,i)}}qe.resolveSchema=Vo;var mE=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Ra(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];!mE.has(a)&&u&&(e=(0,Be.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,xm.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Be.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=Vo.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new yr({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var zm=E((JA,hE)=>{hE.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 Ma=E((BA,Mm)=>{"use strict";var gE=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Rm=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),Ia=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),Om=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),_E=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Aa(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 yE=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Tm(t){return t.length=0,!0}function SE(t,e,r){if(t.length){let n=Aa(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function vE(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=SE;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=Tm}else{o.push(u);continue}}return o.length&&(a===Tm?r.zone=o.join(""):i?n.push(o.join("")):n.push(Aa(o))),r.address=n.join(""),r}function Im(t){if(bE(t,":")<2)return{host:t,isIPV6:!1};let e=vE(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 bE(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function wE(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var EE={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},$E=/[@/?#:]/g,kE=/[@/?#]/g;function Am(t,e){let r=e?kE:$E;return r.lastIndex=0,t.replace(r,n=>EE[n])}function xE(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let o=t.slice(n+1,n+3);if(Ia(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));e&&Om(i)?r+=i:r+="%"+s,n+=2;continue}}r+=t[n]}return r}function PE(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Ia(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&Om(s)?e+=s:e+="%"+o,r+=2;continue}}_E(t[r])?e+=t[r]:e+=escape(t[r])}return e}function zE(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(Ia(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function TE(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!Rm(r)){let n=Im(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=Am(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}Mm.exports={nonSimpleDomain:yE,recomposeAuthority:TE,reescapeHostDelimiters:Am,normalizePercentEncoding:xE,normalizePathEncoding:PE,escapePreservingEscapes:zE,removeDotSegments:wE,isIPv4:Rm,isUUID:gE,normalizeIPv6:Im,stringArrayToHexStripped:Aa}});var jm=E((YA,Lm)=>{"use strict";var{isUUID:RE}=Ma(),OE=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,IE=["http","https","ws","wss","urn","urn:uuid"];function AE(t){return IE.indexOf(t)!==-1}function Ca(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 Cm(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Nm(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 ME(t){return t.secure=Ca(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function CE(t){if((t.port===(Ca(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 NE(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(OE);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=Na(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function DE(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=Na(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 LE(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!RE(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function jE(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Dm={scheme:"http",domainHost:!0,parse:Cm,serialize:Nm},UE={scheme:"https",domainHost:Dm.domainHost,parse:Cm,serialize:Nm},Ko={scheme:"ws",domainHost:!0,parse:ME,serialize:CE},ZE={scheme:"wss",domainHost:Ko.domainHost,parse:Ko.parse,serialize:Ko.serialize},FE={scheme:"urn",parse:NE,serialize:DE,skipNormalize:!0},qE={scheme:"urn:uuid",parse:LE,serialize:jE,skipNormalize:!0},Jo={http:Dm,https:UE,ws:Ko,wss:ZE,urn:FE,"urn:uuid":qE};Object.setPrototypeOf(Jo,null);function Na(t){return t&&(Jo[t]||Jo[t.toLowerCase()])||void 0}Lm.exports={wsIsSecure:Ca,SCHEMES:Jo,isValidSchemeName:AE,getSchemeHandler:Na}});var Wm=E((XA,Bo)=>{"use strict";var{normalizeIPv6:HE,removeDotSegments:xn,recomposeAuthority:WE,normalizePercentEncoding:VE,normalizePathEncoding:GE,escapePreservingEscapes:KE,reescapeHostDelimiters:JE,isIPv4:BE,nonSimpleDomain:YE}=Ma(),{SCHEMES:XE,getSchemeHandler:Zm}=jm();function QE(t,e){return typeof t=="string"?t=o0(t,e):typeof t=="object"&&(t=Sr(Gt(t,e),e)),t}function e0(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=Fm(Sr(t,n),Sr(e,n),n,!0);return n.skipEscape=!0,Gt(o,n)}function Fm(t,e,r,n){let o={};return n||(t=Sr(Gt(t,r),r),e=Sr(Gt(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=xn(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=xn(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=xn(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=xn(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 t0(t,e,r){let n=Um(t,r),o=Um(e,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function Gt(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=Zm(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=VE(r.path):(r.path=KE(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=WE(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=xn(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 r0=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function n0(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function qm(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(r0);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=n0(n,i);if(a!==void 0&&(n.error=n.error||a,o=!0),n.host)if(BE(n.host)===!1){let l=HE(n.host);n.host=l.host.toLowerCase(),s=l.isIPV6}else s=!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 c=Zm(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&s===!1&&YE(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=JE(unescape(n.host),s))),n.path&&(n.path=GE(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function Sr(t,e){return qm(t,e).parsed}function o0(t,e){return Hm(t,e).normalized}function Hm(t,e){let{parsed:r,malformedAuthorityOrPort:n}=qm(t,e);return{normalized:n?t:Gt(r,e),malformedAuthorityOrPort:n}}function Um(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=Hm(t,e);return n?void 0:r}if(typeof t=="object")return Gt(t,e)}var Da={SCHEMES:XE,normalize:QE,resolve:e0,resolveComponent:Fm,equal:t0,serialize:Gt,parse:Sr};Bo.exports=Da;Bo.exports.default=Da;Bo.exports.fastUri=Da});var Gm=E(La=>{"use strict";Object.defineProperty(La,"__esModule",{value:!0});var Vm=Wm();Vm.code='require("ajv/dist/runtime/uri").default';La.default=Vm});var th=E(me=>{"use strict";Object.defineProperty(me,"__esModule",{value:!0});me.CodeGen=me.Name=me.nil=me.stringify=me.str=me._=me.KeywordCxt=void 0;var s0=$n();Object.defineProperty(me,"KeywordCxt",{enumerable:!0,get:function(){return s0.KeywordCxt}});var vr=A();Object.defineProperty(me,"_",{enumerable:!0,get:function(){return vr._}});Object.defineProperty(me,"str",{enumerable:!0,get:function(){return vr.str}});Object.defineProperty(me,"stringify",{enumerable:!0,get:function(){return vr.stringify}});Object.defineProperty(me,"nil",{enumerable:!0,get:function(){return vr.nil}});Object.defineProperty(me,"Name",{enumerable:!0,get:function(){return vr.Name}});Object.defineProperty(me,"CodeGen",{enumerable:!0,get:function(){return vr.CodeGen}});var i0=Wo(),Xm=kn(),a0=pa(),Pn=Go(),c0=A(),zn=bn(),Yo=vn(),Ua=Z(),Km=zm(),u0=Gm(),Qm=(t,e)=>new RegExp(t,e);Qm.code="new RegExp";var l0=["removeAdditional","useDefaults","coerceTypes"],d0=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),p0={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."},f0={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},Jm=200;function m0(t){var e,r,n,o,s,i,a,c,u,l,d,p,f,m,_,y,b,w,v,x,k,_e,Ee,Dt,Qt;let ae=t.strict,St=(e=t.code)===null||e===void 0?void 0:e.optimize,Ve=St===!0||St===void 0?1:St||0,Cr=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:Qm,b_=(o=t.uriResolver)!==null&&o!==void 0?o:u0.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:Ve,regExp:Cr}:{optimize:Ve,regExp:Cr},loopRequired:(_=t.loopRequired)!==null&&_!==void 0?_:Jm,loopEnum:(y=t.loopEnum)!==null&&y!==void 0?y:Jm,meta:(b=t.meta)!==null&&b!==void 0?b:!0,messages:(w=t.messages)!==null&&w!==void 0?w:!0,inlineRefs:(v=t.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:(x=t.schemaId)!==null&&x!==void 0?x:"$id",addUsedSchema:(k=t.addUsedSchema)!==null&&k!==void 0?k:!0,validateSchema:(_e=t.validateSchema)!==null&&_e!==void 0?_e:!0,validateFormats:(Ee=t.validateFormats)!==null&&Ee!==void 0?Ee:!0,unicodeRegExp:(Dt=t.unicodeRegExp)!==null&&Dt!==void 0?Dt:!0,int32range:(Qt=t.int32range)!==null&&Qt!==void 0?Qt:!0,uriResolver:b_}}var Tn=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...m0(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new c0.ValueScope({scope:{},prefixes:d0,es5:r,lines:n}),this.logger=v0(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,a0.getRules)(),Bm.call(this,p0,e,"NOT SUPPORTED"),Bm.call(this,f0,e,"DEPRECATED","warn"),this._metaOpts=y0.call(this),e.formats&&g0.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&_0.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),h0.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=Km;n==="id"&&(o={...Km},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 Xm.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,zn.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=Ym.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new Pn.SchemaEnv({schema:{},schemaId:n});if(r=Pn.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=Ym.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,zn.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(w0.call(this,n,r),!r)return(0,Ua.eachItem)(n,s=>ja.call(this,s)),this;$0.call(this,r);let o={...r,type:(0,Yo.getJSONTypes)(r.type),schemaType:(0,Yo.getJSONTypes)(r.schemaType)};return(0,Ua.eachItem)(n,o.type.length===0?s=>ja.call(this,s,o):s=>o.type.forEach(i=>ja.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]=eh(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,zn.normalizeId)(i||n);let u=zn.getSchemaRefs.call(this,e,n);return c=new Pn.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):Pn.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{Pn.compileSchema.call(this,e)}finally{this.opts=r}}};Tn.ValidationError=i0.default;Tn.MissingRefError=Xm.default;me.default=Tn;function Bm(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 Ym(t){return t=(0,zn.normalizeId)(t),this.schemas[t]||this.refs[t]}function h0(){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 g0(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function _0(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 y0(){let t={...this.opts};for(let e of l0)delete t[e];return t}var S0={log(){},warn(){},error(){}};function v0(t){if(t===!1)return S0;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 b0=/^[a-z_$][a-z0-9_$:-]*$/i;function w0(t,e){let{RULES:r}=this;if((0,Ua.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!b0.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 ja(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,Yo.getJSONTypes)(e.type),schemaType:(0,Yo.getJSONTypes)(e.schemaType)}};e.before?E0.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 E0(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 $0(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=eh(e)),t.validateSchema=this.compile(e,!0))}var k0={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function eh(t){return{anyOf:[t,k0]}}});var rh=E(Za=>{"use strict";Object.defineProperty(Za,"__esModule",{value:!0});var x0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Za.default=x0});var ih=E(Kt=>{"use strict";Object.defineProperty(Kt,"__esModule",{value:!0});Kt.callRef=Kt.getValidate=void 0;var P0=kn(),nh=Fe(),Ie=A(),br=_t(),oh=Go(),Xo=Z(),z0={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=oh.resolveRef.call(c,u,o,r);if(l===void 0)throw new P0.default(n.opts.uriResolver,o,r);if(l instanceof oh.SchemaEnv)return p(l);return f(l);function d(){if(s===u)return Qo(t,i,s,s.$async);let m=e.scopeValue("root",{ref:u});return Qo(t,(0,Ie._)`${m}.validate`,u,u.$async)}function p(m){let _=sh(t,m);Qo(t,_,m,m.$async)}function f(m){let _=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Ie.stringify)(m)}:{ref:m}),y=e.name("valid"),b=t.subschema({schema:m,dataTypes:[],schemaPath:Ie.nil,topSchemaRef:_,errSchemaPath:r},y);t.mergeEvaluated(b),t.ok(y)}}};function sh(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Ie._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Kt.getValidate=sh;function Qo(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?br.default.this:Ie.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,Ie._)`await ${(0,nh.callValidateCode)(t,e,u)}`),f(e),i||o.assign(m,!0)},_=>{o.if((0,Ie._)`!(${_} instanceof ${s.ValidationError})`,()=>o.throw(_)),p(_),i||o.assign(m,!1)}),t.ok(m)}function d(){t.result((0,nh.callValidateCode)(t,e,u),()=>f(e),()=>p(e))}function p(m){let _=(0,Ie._)`${m}.errors`;o.assign(br.default.vErrors,(0,Ie._)`${br.default.vErrors} === null ? ${_} : ${br.default.vErrors}.concat(${_})`),o.assign(br.default.errors,(0,Ie._)`${br.default.vErrors}.length`)}function f(m){var _;if(!s.opts.unevaluated)return;let y=(_=r?.validate)===null||_===void 0?void 0:_.evaluated;if(s.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(s.props=Xo.mergeEvaluated.props(o,y.props,s.props));else{let b=o.var("props",(0,Ie._)`${m}.evaluated.props`);s.props=Xo.mergeEvaluated.props(o,b,s.props,Ie.Name)}if(s.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(s.items=Xo.mergeEvaluated.items(o,y.items,s.items));else{let b=o.var("items",(0,Ie._)`${m}.evaluated.items`);s.items=Xo.mergeEvaluated.items(o,b,s.items,Ie.Name)}}}Kt.callRef=Qo;Kt.default=z0});var ah=E(Fa=>{"use strict";Object.defineProperty(Fa,"__esModule",{value:!0});var T0=rh(),R0=ih(),O0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",T0.default,R0.default];Fa.default=O0});var ch=E(qa=>{"use strict";Object.defineProperty(qa,"__esModule",{value:!0});var es=A(),Mt=es.operators,ts={maximum:{okStr:"<=",ok:Mt.LTE,fail:Mt.GT},minimum:{okStr:">=",ok:Mt.GTE,fail:Mt.LT},exclusiveMaximum:{okStr:"<",ok:Mt.LT,fail:Mt.GTE},exclusiveMinimum:{okStr:">",ok:Mt.GT,fail:Mt.LTE}},I0={message:({keyword:t,schemaCode:e})=>(0,es.str)`must be ${ts[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,es._)`{comparison: ${ts[t].okStr}, limit: ${e}}`},A0={keyword:Object.keys(ts),type:"number",schemaType:"number",$data:!0,error:I0,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,es._)`${r} ${ts[e].fail} ${n} || isNaN(${r})`)}};qa.default=A0});var uh=E(Ha=>{"use strict";Object.defineProperty(Ha,"__esModule",{value:!0});var Rn=A(),M0={message:({schemaCode:t})=>(0,Rn.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,Rn._)`{multipleOf: ${t}}`},C0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:M0,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,Rn._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,Rn._)`${i} !== parseInt(${i})`;t.fail$data((0,Rn._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Ha.default=C0});var dh=E(Wa=>{"use strict";Object.defineProperty(Wa,"__esModule",{value:!0});function lh(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}Wa.default=lh;lh.code='require("ajv/dist/runtime/ucs2length").default'});var ph=E(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});var Jt=A(),N0=Z(),D0=dh(),L0={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Jt.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Jt._)`{limit: ${t}}`},j0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:L0,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?Jt.operators.GT:Jt.operators.LT,i=o.opts.unicode===!1?(0,Jt._)`${r}.length`:(0,Jt._)`${(0,N0.useFunc)(t.gen,D0.default)}(${r})`;t.fail$data((0,Jt._)`${i} ${s} ${n}`)}};Va.default=j0});var fh=E(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});var U0=Fe(),Z0=Z(),wr=A(),F0={message:({schemaCode:t})=>(0,wr.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,wr._)`{pattern: ${t}}`},q0={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:F0,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,wr._)`new RegExp`:(0,Z0.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,wr._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,wr._)`!${l}`)}else{let c=(0,U0.usePattern)(t,o);t.fail$data((0,wr._)`!${c}.test(${r})`)}}};Ga.default=q0});var mh=E(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});var On=A(),H0={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,On.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,On._)`{limit: ${t}}`},W0={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:H0,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?On.operators.GT:On.operators.LT;t.fail$data((0,On._)`Object.keys(${r}).length ${o} ${n}`)}};Ka.default=W0});var hh=E(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});var In=Fe(),An=A(),V0=Z(),G0={message:({params:{missingProperty:t}})=>(0,An.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,An._)`{missingProperty: ${t}}`},K0={keyword:"required",type:"object",schemaType:"array",$data:!0,error:G0,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 y=i.schemaEnv.baseId+i.errSchemaPath,b=`required property "${_}" is not defined at "${y}" (strictRequired)`;(0,V0.checkStrictMode)(i,b,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(An.nil,d);else for(let f of r)(0,In.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,In.checkMissingProp)(t,r,f)),(0,In.reportMissingProp)(t,f),e.else()}function d(){e.forOf("prop",n,f=>{t.setParams({missingProperty:f}),e.if((0,In.noPropertyInData)(e,o,f,a.ownProperties),()=>t.error())})}function p(f,m){t.setParams({missingProperty:f}),e.forOf(f,n,()=>{e.assign(m,(0,In.propertyInData)(e,o,f,a.ownProperties)),e.if((0,An.not)(m),()=>{t.error(),e.break()})},An.nil)}}};Ja.default=K0});var gh=E(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});var Mn=A(),J0={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Mn.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Mn._)`{limit: ${t}}`},B0={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:J0,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?Mn.operators.GT:Mn.operators.LT;t.fail$data((0,Mn._)`${r}.length ${o} ${n}`)}};Ba.default=B0});var rs=E(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});var _h=va();_h.code='require("ajv/dist/runtime/equal").default';Ya.default=_h});var yh=E(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});var Xa=vn(),he=A(),Y0=Z(),X0=rs(),Q0={message:({params:{i:t,j:e}})=>(0,he.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,he._)`{i: ${t}, j: ${e}}`},e$={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:Q0,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,Xa.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,he._)`${i} === false`),t.ok(c);function l(){let m=e.let("i",(0,he._)`${r}.length`),_=e.let("j");t.setParams({i:m,j:_}),e.assign(c,!0),e.if((0,he._)`${m} > 1`,()=>(d()?p:f)(m,_))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function p(m,_){let y=e.name("item"),b=(0,Xa.checkDataTypes)(u,y,a.opts.strictNumbers,Xa.DataType.Wrong),w=e.const("indices",(0,he._)`{}`);e.for((0,he._)`;${m}--;`,()=>{e.let(y,(0,he._)`${r}[${m}]`),e.if(b,(0,he._)`continue`),u.length>1&&e.if((0,he._)`typeof ${y} == "string"`,(0,he._)`${y} += "_"`),e.if((0,he._)`typeof ${w}[${y}] == "number"`,()=>{e.assign(_,(0,he._)`${w}[${y}]`),t.error(),e.assign(c,!1).break()}).code((0,he._)`${w}[${y}] = ${m}`)})}function f(m,_){let y=(0,Y0.useFunc)(e,X0.default),b=e.name("outer");e.label(b).for((0,he._)`;${m}--;`,()=>e.for((0,he._)`${_} = ${m}; ${_}--;`,()=>e.if((0,he._)`${y}(${r}[${m}], ${r}[${_}])`,()=>{t.error(),e.assign(c,!1).break(b)})))}}};Qa.default=e$});var Sh=E(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});var ec=A(),t$=Z(),r$=rs(),n$={message:"must be equal to constant",params:({schemaCode:t})=>(0,ec._)`{allowedValue: ${t}}`},o$={keyword:"const",$data:!0,error:n$,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,ec._)`!${(0,t$.useFunc)(e,r$.default)}(${r}, ${o})`):t.fail((0,ec._)`${s} !== ${r}`)}};tc.default=o$});var vh=E(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});var Cn=A(),s$=Z(),i$=rs(),a$={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Cn._)`{allowedValues: ${t}}`},c$={keyword:"enum",schemaType:"array",$data:!0,error:a$,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,s$.useFunc)(e,i$.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,Cn.or)(...o.map((m,_)=>p(f,_)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,f=>e.if((0,Cn._)`${u()}(${r}, ${f})`,()=>e.assign(l,!0).break()))}function p(f,m){let _=o[m];return typeof _=="object"&&_!==null?(0,Cn._)`${u()}(${r}, ${f}[${m}])`:(0,Cn._)`${r} === ${_}`}}};rc.default=c$});var bh=E(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});var u$=ch(),l$=uh(),d$=ph(),p$=fh(),f$=mh(),m$=hh(),h$=gh(),g$=yh(),_$=Sh(),y$=vh(),S$=[u$.default,l$.default,d$.default,p$.default,f$.default,m$.default,h$.default,g$.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},_$.default,y$.default];nc.default=S$});var sc=E(Nn=>{"use strict";Object.defineProperty(Nn,"__esModule",{value:!0});Nn.validateAdditionalItems=void 0;var Bt=A(),oc=Z(),v$={message:({params:{len:t}})=>(0,Bt.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Bt._)`{limit: ${t}}`},b$={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:v$,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,oc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}wh(t,n)}};function wh(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,Bt._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Bt._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,oc.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,Bt._)`${a} <= ${e.length}`);r.if((0,Bt.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:oc.Type.Num},u),i.allErrors||r.if((0,Bt.not)(u),()=>r.break())})}}Nn.validateAdditionalItems=wh;Nn.default=b$});var ic=E(Dn=>{"use strict";Object.defineProperty(Dn,"__esModule",{value:!0});Dn.validateTuple=void 0;var Eh=A(),ns=Z(),w$=Fe(),E$={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return $h(t,"additionalItems",e);r.items=!0,!(0,ns.alwaysValidSchema)(r,e)&&t.ok((0,w$.validateArray)(t))}};function $h(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=ns.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Eh._)`${s}.length`);r.forEach((d,p)=>{(0,ns.alwaysValidSchema)(a,d)||(n.if((0,Eh._)`${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 y=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${f}"`;(0,ns.checkStrictMode)(a,y,p.strictTuples)}}}Dn.validateTuple=$h;Dn.default=E$});var kh=E(ac=>{"use strict";Object.defineProperty(ac,"__esModule",{value:!0});var $$=ic(),k$={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,$$.validateTuple)(t,"items")};ac.default=k$});var Ph=E(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var xh=A(),x$=Z(),P$=Fe(),z$=sc(),T$={message:({params:{len:t}})=>(0,xh.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,xh._)`{limit: ${t}}`},R$={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:T$,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,x$.alwaysValidSchema)(n,e)&&(o?(0,z$.validateAdditionalItems)(t,o):t.ok((0,P$.validateArray)(t)))}};cc.default=R$});var zh=E(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});var He=A(),os=Z(),O$={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}}`},I$={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:O$,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,os.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,os.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,os.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"),y=e.let("count",0);f(_,()=>e.if(_,()=>m(y)))}function f(_,y){e.forRange("i",0,l,b=>{t.subschema({keyword:"contains",dataProp:b,dataPropType:os.Type.Num,compositeRule:!0},_),y()})}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)))}}};uc.default=I$});var Oh=E(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.validateSchemaDeps=nt.validatePropertyDeps=nt.error=void 0;var lc=A(),A$=Z(),Ln=Fe();nt.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,lc.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,lc._)`{property: ${t},
2
+ "use strict";var D_=Object.create;var Ds=Object.defineProperty;var j_=Object.getOwnPropertyDescriptor;var L_=Object.getOwnPropertyNames;var U_=Object.getPrototypeOf,q_=Object.prototype.hasOwnProperty;var w=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),yu=(t,e)=>{for(var r in e)Ds(t,r,{get:e[r],enumerable:!0})},Z_=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of L_(e))!q_.call(t,o)&&o!==r&&Ds(t,o,{get:()=>e[o],enumerable:!(n=j_(e,o))||n.enumerable});return t};var bt=(t,e,r)=>(r=t!=null?D_(U_(t)):{},Z_(e||!t||!t.__esModule?Ds(r,"default",{value:t,enumerable:!0}):r,t));var hn=w(F=>{"use strict";Object.defineProperty(F,"__esModule",{value:!0});F.regexpCode=F.getEsmExportName=F.getProperty=F.safeStringify=F.stringify=F.strConcat=F.addCodeArg=F.str=F._=F.nil=F._Code=F.Name=F.IDENTIFIER=F._CodeOrName=void 0;var fn=class{};F._CodeOrName=fn;F.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var qt=class extends fn{constructor(e){if(super(),!F.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}}};F.Name=qt;var qe=class extends fn{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 qt&&(r[n.str]=(r[n.str]||0)+1),r),{})}};F._Code=qe;F.nil=new qe("");function Uf(t,...e){let r=[t[0]],n=0;for(;n<e.length;)Qi(r,e[n]),r.push(t[++n]);return new qe(r)}F._=Uf;var Xi=new qe("+");function qf(t,...e){let r=[mn(t[0])],n=0;for(;n<e.length;)r.push(Xi),Qi(r,e[n]),r.push(Xi,mn(t[++n]));return yb(r),new qe(r)}F.str=qf;function Qi(t,e){e instanceof qe?t.push(...e._items):e instanceof qt?t.push(e):t.push(bb(e))}F.addCodeArg=Qi;function yb(t){let e=1;for(;e<t.length-1;){if(t[e]===Xi){let r=Sb(t[e-1],t[e+1]);if(r!==void 0){t.splice(e-1,3,r);continue}t[e++]="+"}e++}}function Sb(t,e){if(e==='""')return t;if(t==='""')return e;if(typeof t=="string")return e instanceof qt||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 qt))return`"${t}${e.slice(1)}`}function vb(t,e){return e.emptyStr()?t:t.emptyStr()?e:qf`${t}${e}`}F.strConcat=vb;function bb(t){return typeof t=="number"||typeof t=="boolean"||t===null?t:mn(Array.isArray(t)?t.join(","):t)}function Eb(t){return new qe(mn(t))}F.stringify=Eb;function mn(t){return JSON.stringify(t).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}F.safeStringify=mn;function wb(t){return typeof t=="string"&&F.IDENTIFIER.test(t)?new qe(`.${t}`):Uf`[${t}]`}F.getProperty=wb;function kb(t){if(typeof t=="string"&&F.IDENTIFIER.test(t))return new qe(`${t}`);throw new Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}F.getEsmExportName=kb;function $b(t){return new qe(t.toString())}F.regexpCode=$b});var ra=w(Re=>{"use strict";Object.defineProperty(Re,"__esModule",{value:!0});Re.ValueScope=Re.ValueScopeName=Re.Scope=Re.varKinds=Re.UsedValueState=void 0;var ze=hn(),ea=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},jo;(function(t){t[t.Started=0]="Started",t[t.Completed=1]="Completed"})(jo||(Re.UsedValueState=jo={}));Re.varKinds={const:new ze.Name("const"),let:new ze.Name("let"),var:new ze.Name("var")};var Lo=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=Lo;var Uo=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=Uo;var xb=(0,ze._)`\n`,ta=class extends Lo{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?xb:ze.nil}}get(){return this._scope}name(e){return new Uo(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,jo.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 ea(u);c.set(u,jo.Completed)})}return s}};Re.ValueScope=ta});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=hn(),Ge=ra(),zt=hn();Object.defineProperty(M,"_",{enumerable:!0,get:function(){return zt._}});Object.defineProperty(M,"str",{enumerable:!0,get:function(){return zt.str}});Object.defineProperty(M,"strConcat",{enumerable:!0,get:function(){return zt.strConcat}});Object.defineProperty(M,"nil",{enumerable:!0,get:function(){return zt.nil}});Object.defineProperty(M,"getProperty",{enumerable:!0,get:function(){return zt.getProperty}});Object.defineProperty(M,"stringify",{enumerable:!0,get:function(){return zt.stringify}});Object.defineProperty(M,"regexpCode",{enumerable:!0,get:function(){return zt.regexpCode}});Object.defineProperty(M,"Name",{enumerable:!0,get:function(){return zt.Name}});var Ho=ra();Object.defineProperty(M,"Scope",{enumerable:!0,get:function(){return Ho.Scope}});Object.defineProperty(M,"ValueScope",{enumerable:!0,get:function(){return Ho.ValueScope}});Object.defineProperty(M,"ValueScopeName",{enumerable:!0,get:function(){return Ho.ValueScopeName}});Object.defineProperty(M,"varKinds",{enumerable:!0,get:function(){return Ho.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}},na=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?Ge.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=fr(this.rhs,e,r)),this}get names(){return this.rhs instanceof j._CodeOrName?this.rhs.names:{}}},qo=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=fr(this.rhs,e,r),this}get names(){let e=this.lhs instanceof j.Name?{}:{...this.lhs.names};return Fo(e,this.rhs)}},oa=class extends qo{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}},ia=class extends gt{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:""};`+e}},aa=class extends gt{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},ca=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=fr(this.code,e,r),this}get names(){return this.code instanceof j._CodeOrName?this.code.names:{}}},gn=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)||(Pb(e,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,r)=>Ht(e,r.names),{})}},_t=class extends gn{render(e){return"{"+e._n+super.render(e)+"}"+e._n}},ua=class extends gn{},pr=class extends _t{};pr.kind="else";var Zt=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 pr(n):n}if(r)return e===!1?r instanceof t?r:r.nodes:this.nodes.length?this:new t(Zf(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=fr(this.condition,e,r),this}get names(){let e=super.names;return Fo(e,this.condition),this.else&&Ht(e,this.else.names),e}};Zt.kind="if";var Ft=class extends _t{};Ft.kind="for";var la=class extends Ft{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=fr(this.iteration,e,r),this}get names(){return Ht(super.names,this.iteration.names)}},da=class extends Ft{constructor(e,r,n,o){super(),this.varKind=e,this.name=r,this.from=n,this.to=o}render(e){let r=e.es5?Ge.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=Fo(super.names,this.from);return Fo(e,this.to)}},Zo=class extends Ft{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=fr(this.iterable,e,r),this}get names(){return Ht(super.names,this.iterable.names)}},_n=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)}};_n.kind="func";var yn=class extends gn{render(e){return"return "+super.render(e)}};yn.kind="return";var pa=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&&Ht(e,this.catch.names),this.finally&&Ht(e,this.finally.names),e}},Sn=class extends _t{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};Sn.kind="catch";var vn=class extends _t{render(e){return"finally"+super.render(e)}};vn.kind="finally";var fa=class{constructor(e,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
3
+ `:""},this._extScope=e,this._scope=new Ge.Scope({parent:e}),this._nodes=[new ua]}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 na(e,s,n)),s}const(e,r,n){return this._def(Ge.varKinds.const,e,r,n)}let(e,r,n){return this._def(Ge.varKinds.let,e,r,n)}var(e,r,n){return this._def(Ge.varKinds.var,e,r,n)}assign(e,r,n){return this._leafNode(new qo(e,r,n))}add(e,r){return this._leafNode(new oa(e,M.operators.ADD,r))}code(e){return typeof e=="function"?e():e!==j.nil&&this._leafNode(new ca(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 Zt(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 Zt(e))}else(){return this._elseNode(new pr)}endIf(){return this._endBlockNode(Zt,pr)}_for(e,r){return this._blockNode(e),r&&this.code(r).endFor(),this}for(e,r){return this._for(new la(e),r)}forRange(e,r,n,o,s=this.opts.es5?Ge.varKinds.var:Ge.varKinds.let){let i=this._scope.toName(e);return this._for(new da(s,i,r,n),()=>o(i))}forOf(e,r,n,o=Ge.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 Zo("of",o,s,r),()=>n(s))}forIn(e,r,n,o=this.opts.es5?Ge.varKinds.var:Ge.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 Zo("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(Ft)}label(e){return this._leafNode(new sa(e))}break(e){return this._leafNode(new ia(e))}return(e){let r=new yn;if(this._blockNode(r),this.code(e),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(yn)}try(e,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new pa;if(this._blockNode(o),this.code(e),r){let s=this.name("e");this._currNode=o.catch=new Sn(s),r(s)}return n&&(this._currNode=o.finally=new vn,this.code(n)),this._endBlockNode(Sn,vn)}throw(e){return this._leafNode(new aa(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 _n(e,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(_n)}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 Zt))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=fa;function Ht(t,e){for(let r in e)t[r]=(t[r]||0)+(e[r]||0);return t}function Fo(t,e){return e instanceof j._CodeOrName?Ht(t,e.names):t}function fr(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 Pb(t,e){for(let r in e)t[r]=(t[r]||0)-(e[r]||0)}function Zf(t){return typeof t=="boolean"||typeof t=="number"||t===null?!t:(0,j._)`!${ma(t)}`}M.not=Zf;var Tb=Ff(M.operators.AND);function zb(...t){return t.reduce(Tb)}M.and=zb;var Rb=Ff(M.operators.OR);function Ib(...t){return t.reduce(Rb)}M.or=Ib;function Ff(t){return(e,r)=>e===j.nil?r:r===j.nil?e:(0,j._)`${ma(e)} ${t} ${ma(r)}`}function ma(t){return t instanceof j.Name?t:(0,j._)`(${t})`}});var q=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(),Ob=hn();function Ab(t){let e={};for(let r of t)e[r]=!0;return e}C.toHash=Ab;function Mb(t,e){return typeof e=="boolean"?e:Object.keys(e).length===0?!0:(Wf(t,e),!Bf(e,t.self.RULES.all))}C.alwaysValidSchema=Mb;function Wf(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]||Jf(t,`unknown keyword: "${s}"`)}C.checkUnknownRules=Wf;function Bf(t,e){if(typeof t=="boolean")return!t;for(let r in t)if(e[r])return!0;return!1}C.schemaHasRules=Bf;function Cb(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=Cb;function Nb({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=Nb;function Db(t){return Kf(decodeURIComponent(t))}C.unescapeFragment=Db;function jb(t){return encodeURIComponent(ga(t))}C.escapeFragment=jb;function ga(t){return typeof t=="number"?`${t}`:t.replace(/~/g,"~0").replace(/\//g,"~1")}C.escapeJsonPointer=ga;function Kf(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")}C.unescapeJsonPointer=Kf;function Lb(t,e){if(Array.isArray(t))for(let r of t)e(r);else e(t)}C.eachItem=Lb;function Hf({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:Hf({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} || {}`),_a(t,r,e))}),mergeValues:(t,e)=>t===!0?!0:{...t,...e},resultToName:Gf}),items:Hf({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 Gf(t,e){if(e===!0)return t.var("props",!0);let r=t.var("props",(0,B._)`{}`);return e!==void 0&&_a(t,r,e),r}C.evaluatedPropsToName=Gf;function _a(t,e,r){Object.keys(r).forEach(n=>t.assign((0,B._)`${e}${(0,B.getProperty)(n)}`,!0))}C.setEvaluated=_a;var Vf={};function Ub(t,e){return t.scopeValue("func",{ref:e,code:Vf[e.code]||(Vf[e.code]=new Ob._Code(e.code))})}C.useFunc=Ub;var ha;(function(t){t[t.Num=0]="Num",t[t.Str=1]="Str"})(ha||(C.Type=ha={}));function qb(t,e,r){if(t instanceof B.Name){let n=e===ha.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():"/"+ga(t)}C.getErrorPath=qb;function Jf(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=Jf});var yt=w(ya=>{"use strict";Object.defineProperty(ya,"__esModule",{value:!0});var Se=A(),Zb={data:new Se.Name("data"),valCxt:new Se.Name("valCxt"),instancePath:new Se.Name("instancePath"),parentData:new Se.Name("parentData"),parentDataProperty:new Se.Name("parentDataProperty"),rootData:new Se.Name("rootData"),dynamicAnchors:new Se.Name("dynamicAnchors"),vErrors:new Se.Name("vErrors"),errors:new Se.Name("errors"),this:new Se.Name("this"),self:new Se.Name("self"),scope:new Se.Name("scope"),json:new Se.Name("json"),jsonPos:new Se.Name("jsonPos"),jsonLen:new Se.Name("jsonLen"),jsonPart:new Se.Name("jsonPart")};ya.default=Zb});var bn=w(ve=>{"use strict";Object.defineProperty(ve,"__esModule",{value:!0});ve.extendErrors=ve.resetErrorsCount=ve.reportExtraError=ve.reportError=ve.keyword$DataError=ve.keywordError=void 0;var Z=A(),Vo=q(),xe=yt();ve.keywordError={message:({keyword:t})=>(0,Z.str)`must pass "${t}" keyword validation`};ve.keyword$DataError={message:({keyword:t,schemaType:e})=>e?(0,Z.str)`"${t}" keyword must be ${e} ($data)`:(0,Z.str)`"${t}" keyword is invalid ($data)`};function Fb(t,e=ve.keywordError,r,n){let{it:o}=t,{gen:s,compositeRule:i,allErrors:a}=o,c=Qf(t,e,r);n??(i||a)?Yf(s,c):Xf(o,(0,Z._)`[${c}]`)}ve.reportError=Fb;function Hb(t,e=ve.keywordError,r){let{it:n}=t,{gen:o,compositeRule:s,allErrors:i}=n,a=Qf(t,e,r);Yf(o,a),s||i||Xf(n,xe.default.vErrors)}ve.reportExtraError=Hb;function Vb(t,e){t.assign(xe.default.errors,e),t.if((0,Z._)`${xe.default.vErrors} !== null`,()=>t.if(e,()=>t.assign((0,Z._)`${xe.default.vErrors}.length`,e),()=>t.assign(xe.default.vErrors,null)))}ve.resetErrorsCount=Vb;function Wb({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,xe.default.errors,a=>{t.const(i,(0,Z._)`${xe.default.vErrors}[${a}]`),t.if((0,Z._)`${i}.instancePath === undefined`,()=>t.assign((0,Z._)`${i}.instancePath`,(0,Z.strConcat)(xe.default.instancePath,s.errorPath))),t.assign((0,Z._)`${i}.schemaPath`,(0,Z.str)`${s.errSchemaPath}/${e}`),s.opts.verbose&&(t.assign((0,Z._)`${i}.schema`,r),t.assign((0,Z._)`${i}.data`,n))})}ve.extendErrors=Wb;function Yf(t,e){let r=t.const("err",e);t.if((0,Z._)`${xe.default.vErrors} === null`,()=>t.assign(xe.default.vErrors,(0,Z._)`[${r}]`),(0,Z._)`${xe.default.vErrors}.push(${r})`),t.code((0,Z._)`${xe.default.errors}++`)}function Xf(t,e){let{gen:r,validateName:n,schemaEnv:o}=t;o.$async?r.throw((0,Z._)`new ${t.ValidationError}(${e})`):(r.assign((0,Z._)`${n}.errors`,e),r.return(!1))}var Vt={keyword:new Z.Name("keyword"),schemaPath:new Z.Name("schemaPath"),params:new Z.Name("params"),propertyName:new Z.Name("propertyName"),message:new Z.Name("message"),schema:new Z.Name("schema"),parentSchema:new Z.Name("parentSchema")};function Qf(t,e,r){let{createErrors:n}=t.it;return n===!1?(0,Z._)`{}`:Bb(t,e,r)}function Bb(t,e,r={}){let{gen:n,it:o}=t,s=[Kb(o,r),Gb(t,r)];return Jb(t,e,s),n.object(...s)}function Kb({errorPath:t},{instancePath:e}){let r=e?(0,Z.str)`${t}${(0,Vo.getErrorPath)(e,Vo.Type.Str)}`:t;return[xe.default.instancePath,(0,Z.strConcat)(xe.default.instancePath,r)]}function Gb({keyword:t,it:{errSchemaPath:e}},{schemaPath:r,parentSchema:n}){let o=n?e:(0,Z.str)`${e}/${t}`;return r&&(o=(0,Z.str)`${o}${(0,Vo.getErrorPath)(r,Vo.Type.Str)}`),[Vt.schemaPath,o]}function Jb(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([Vt.keyword,o],[Vt.params,typeof e=="function"?e(t):e||(0,Z._)`{}`]),c.messages&&n.push([Vt.message,typeof r=="function"?r(t):r]),c.verbose&&n.push([Vt.schema,i],[Vt.parentSchema,(0,Z._)`${l}${d}`],[xe.default.data,s]),u&&n.push([Vt.propertyName,u])}});var tm=w(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});mr.boolOrEmptySchema=mr.topBoolOrEmptySchema=void 0;var Yb=bn(),Xb=A(),Qb=yt(),eE={message:"boolean schema is false"};function tE(t){let{gen:e,schema:r,validateName:n}=t;r===!1?em(t,!1):typeof r=="object"&&r.$async===!0?e.return(Qb.default.data):(e.assign((0,Xb._)`${n}.errors`,null),e.return(!0))}mr.topBoolOrEmptySchema=tE;function rE(t,e){let{gen:r,schema:n}=t;n===!1?(r.var(e,!1),em(t)):r.var(e,!0)}mr.boolOrEmptySchema=rE;function em(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,Yb.reportError)(o,eE,void 0,e)}});var Sa=w(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});hr.getRules=hr.isJSONType=void 0;var nE=["string","number","integer","boolean","null","object","array"],oE=new Set(nE);function sE(t){return typeof t=="string"&&oE.has(t)}hr.isJSONType=sE;function iE(){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:{}}}hr.getRules=iE});var va=w(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Rt.shouldUseRule=Rt.shouldUseGroup=Rt.schemaHasRulesForType=void 0;function aE({schema:t,self:e},r){let n=e.RULES.types[r];return n&&n!==!0&&rm(t,n)}Rt.schemaHasRulesForType=aE;function rm(t,e){return e.rules.some(r=>nm(t,r))}Rt.shouldUseGroup=rm;function nm(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))}Rt.shouldUseRule=nm});var En=w(be=>{"use strict";Object.defineProperty(be,"__esModule",{value:!0});be.reportTypeError=be.checkDataTypes=be.checkDataType=be.coerceAndCheckDataType=be.getJSONTypes=be.getSchemaTypes=be.DataType=void 0;var cE=Sa(),uE=va(),lE=bn(),O=A(),om=q(),gr;(function(t){t[t.Correct=0]="Correct",t[t.Wrong=1]="Wrong"})(gr||(be.DataType=gr={}));function dE(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}be.getSchemaTypes=dE;function sm(t){let e=Array.isArray(t)?t:t?[t]:[];if(e.every(cE.isJSONType))return e;throw new Error("type must be JSONType or JSONType[]: "+e.join(","))}be.getJSONTypes=sm;function pE(t,e){let{gen:r,data:n,opts:o}=t,s=fE(e,o.coerceTypes),i=e.length>0&&!(s.length===0&&e.length===1&&(0,uE.schemaHasRulesForType)(t,e[0]));if(i){let a=Ea(e,n,o.strictNumbers,gr.Wrong);r.if(a,()=>{s.length?mE(t,e,s):wa(t)})}return i}be.coerceAndCheckDataType=pE;var im=new Set(["string","number","integer","boolean","null"]);function fE(t,e){return e?t.filter(r=>im.has(r)||e==="array"&&r==="array"):[]}function mE(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(Ea(e,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,O._)`${a} !== undefined`);for(let u of r)(im.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),wa(t),n.endIf(),n.if((0,O._)`${a} !== undefined`,()=>{n.assign(o,a),hE(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
+ || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,O._)`+${o}`);return;case"integer":n.elseIf((0,O._)`${i} === "boolean" || ${o} === null
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 hE({gen:t,parentData:e,parentDataProperty:r},n){t.if((0,O._)`${e} !== undefined`,()=>t.assign((0,O._)`${e}[${r}]`,n))}function ba(t,e,r,n=gr.Correct){let o=n===gr.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===gr.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)}}be.checkDataType=ba;function Ea(t,e,r,n){if(t.length===1)return ba(t[0],e,r,n);let o,s=(0,om.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,ba(i,e,r,n));return o}be.checkDataTypes=Ea;var gE={message:({schema:t})=>`must be ${t}`,params:({schema:t,schemaValue:e})=>typeof t=="string"?(0,O._)`{type: ${t}}`:(0,O._)`{type: ${e}}`};function wa(t){let e=_E(t);(0,lE.reportError)(e,gE)}be.reportTypeError=wa;function _E(t){let{gen:e,data:r,schema:n}=t,o=(0,om.schemaRefOrVal)(t,n,"type");return{gen:e,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:t}}});var cm=w(Wo=>{"use strict";Object.defineProperty(Wo,"__esModule",{value:!0});Wo.assignDefaults=void 0;var _r=A(),yE=q();function SE(t,e){let{properties:r,items:n}=t.schema;if(e==="object"&&r)for(let o in r)am(t,o,r[o].default);else e==="array"&&Array.isArray(n)&&n.forEach((o,s)=>am(t,s,o.default))}Wo.assignDefaults=SE;function am(t,e,r){let{gen:n,compositeRule:o,data:s,opts:i}=t;if(r===void 0)return;let a=(0,_r._)`${s}${(0,_r.getProperty)(e)}`;if(o){(0,yE.checkStrictMode)(t,`default is ignored for: ${a}`);return}let c=(0,_r._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,_r._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,_r._)`${a} = ${(0,_r.stringify)(r)}`)}});var Ze=w(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.validateUnion=W.validateArray=W.usePattern=W.callValidateCode=W.schemaProperties=W.allSchemaProperties=W.noPropertyInData=W.propertyInData=W.isOwnProperty=W.hasPropFunc=W.reportMissingProp=W.checkMissingProp=W.checkReportMissingProp=void 0;var X=A(),ka=q(),It=yt(),vE=q();function bE(t,e){let{gen:r,data:n,it:o}=t;r.if(xa(r,n,e,o.opts.ownProperties),()=>{t.setParams({missingProperty:(0,X._)`${e}`},!0),t.error()})}W.checkReportMissingProp=bE;function EE({gen:t,data:e,it:{opts:r}},n,o){return(0,X.or)(...n.map(s=>(0,X.and)(xa(t,e,s,r.ownProperties),(0,X._)`${o} = ${s}`)))}W.checkMissingProp=EE;function wE(t,e){t.setParams({missingProperty:e},!0),t.error()}W.reportMissingProp=wE;function um(t){return t.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,X._)`Object.prototype.hasOwnProperty`})}W.hasPropFunc=um;function $a(t,e,r){return(0,X._)`${um(t)}.call(${e}, ${r})`}W.isOwnProperty=$a;function kE(t,e,r,n){let o=(0,X._)`${e}${(0,X.getProperty)(r)} !== undefined`;return n?(0,X._)`${o} && ${$a(t,e,r)}`:o}W.propertyInData=kE;function xa(t,e,r,n){let o=(0,X._)`${e}${(0,X.getProperty)(r)} === undefined`;return n?(0,X.or)(o,(0,X.not)($a(t,e,r))):o}W.noPropertyInData=xa;function lm(t){return t?Object.keys(t).filter(e=>e!=="__proto__"):[]}W.allSchemaProperties=lm;function $E(t,e){return lm(e).filter(r=>!(0,ka.alwaysValidSchema)(t,e[r]))}W.schemaProperties=$E;function xE({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=[[It.default.instancePath,(0,X.strConcat)(It.default.instancePath,s)],[It.default.parentData,i.parentData],[It.default.parentDataProperty,i.parentDataProperty],[It.default.rootData,It.default.rootData]];i.opts.dynamicRef&&d.push([It.default.dynamicAnchors,It.default.dynamicAnchors]);let p=(0,X._)`${l}, ${r.object(...d)}`;return c!==X.nil?(0,X._)`${a}.call(${c}, ${p})`:(0,X._)`${a}(${p})`}W.callValidateCode=xE;var PE=(0,X._)`new RegExp`;function TE({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"?PE:(0,vE.useFunc)(t,o)}(${r}, ${n})`})}W.usePattern=TE;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:ka.Type.Num},s),e.if((0,X.not)(s),a)})}}W.validateArray=zE;function RE(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,ka.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))}W.validateUnion=RE});var fm=w(nt=>{"use strict";Object.defineProperty(nt,"__esModule",{value:!0});nt.validateKeywordUsage=nt.validSchemaType=nt.funcKeywordCode=nt.macroKeywordCode=void 0;var Pe=A(),Wt=yt(),IE=Ze(),OE=bn();function AE(t,e){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=t,a=e.macro.call(i.self,o,s,i),c=pm(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=AE;function ME(t,e){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=t;NE(c,e);let u=!a&&e.compile?e.compile.call(c.self,s,i,c):e.validate,l=pm(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&&dm(t),y(()=>t.error());else{let b=e.async?f():m();e.modifying&&dm(t),y(()=>CE(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?Wt.default.this:Wt.default.self,v=!("compile"in e&&!a||e.schema===!1);n.assign(d,(0,Pe._)`${b}${(0,IE.callValidateCode)(t,l,E,v)}`,e.modifying)}function y(b){var E;n.if((0,Pe.not)((E=e.valid)!==null&&E!==void 0?E:d),b)}}nt.funcKeywordCode=ME;function dm(t){let{gen:e,data:r,it:n}=t;e.if(n.parentData,()=>e.assign(r,(0,Pe._)`${n.parentData}[${n.parentDataProperty}]`))}function CE(t,e){let{gen:r}=t;r.if((0,Pe._)`Array.isArray(${e})`,()=>{r.assign(Wt.default.vErrors,(0,Pe._)`${Wt.default.vErrors} === null ? ${e} : ${Wt.default.vErrors}.concat(${e})`).assign(Wt.default.errors,(0,Pe._)`${Wt.default.vErrors}.length`),(0,OE.extendErrors)(t)},()=>t.error())}function NE({schemaEnv:t},e){if(e.async&&!t.$async)throw new Error("async keyword in sync schema")}function pm(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 DE(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=DE;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 hm=w(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Ot.extendSubschemaMode=Ot.extendSubschemaData=Ot.getSubschema=void 0;var ot=A(),mm=q();function LE(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,mm.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')}Ot.getSubschema=LE;function UE(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,mm.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]}}Ot.extendSubschemaData=UE;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}Ot.extendSubschemaMode=qE});var Pa=w((aM,gm)=>{"use strict";gm.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 ym=w((cM,_m)=>{"use strict";var At=_m.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(){};Bo(e,n,o,t,"",t)};At.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};At.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};At.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};At.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function Bo(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 At.arrayKeywords)for(var p=0;p<d.length;p++)Bo(t,e,r,d[p],o+"/"+l+"/"+p,s,o,l,n,p)}else if(l in At.propsKeywords){if(d&&typeof d=="object")for(var f in d)Bo(t,e,r,d[f],o+"/"+l+"/"+ZE(f),s,o,l,n,f)}else(l in At.keywords||t.allKeys&&!(l in At.skipKeywords))&&Bo(t,e,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function ZE(t){return t.replace(/~/g,"~0").replace(/\//g,"~1")}});var wn=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 FE=q(),HE=Pa(),VE=ym(),WE=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function BE(t,e=!0){return typeof t=="boolean"?!0:e===!0?!Ta(t):e?Sm(t)<=e:!1}Ie.inlineRef=BE;var KE=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Ta(t){for(let e in t){if(KE.has(e))return!0;let r=t[e];if(Array.isArray(r)&&r.some(Ta)||typeof r=="object"&&Ta(r))return!0}return!1}function Sm(t){let e=0;for(let r in t){if(r==="$ref")return 1/0;if(e++,!WE.has(r)&&(typeof t[r]=="object"&&(0,FE.eachItem)(t[r],n=>e+=Sm(n)),e===1/0))return 1/0}return e}function vm(t,e="",r){r!==!1&&(e=yr(e));let n=t.parse(e);return bm(t,n)}Ie.getFullPath=vm;function bm(t,e){return t.serialize(e).split("#")[0]+"#"}Ie._getFullPath=bm;var GE=/#\/?$/;function yr(t){return t?t.replace(GE,""):""}Ie.normalizeId=yr;function JE(t,e,r){return r=yr(r),t.resolve(e,r)}Ie.resolveUrl=JE;var YE=/^[a-z_][-a-z0-9._]*$/i;function XE(t,e){if(typeof t=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=yr(t[r]||e),s={"":o},i=vm(n,o,!1),a={},c=new Set;return VE(t,{allKeys:!0},(d,p,f,m)=>{if(m===void 0)return;let _=i+p,y=s[m];typeof d[r]=="string"&&(y=b.call(this,d[r])),E.call(this,d.$anchor),E.call(this,d.$dynamicAnchor),s[p]=y;function b(v){let x=this.opts.uriResolver.resolve;if(v=yr(y?x(y,v):v),c.has(v))throw l(v);c.add(v);let $=this.refs[v];return typeof $=="string"&&($=this.refs[$]),typeof $=="object"?u(d,$.schema,v):v!==yr(_)&&(v[0]==="#"?(u(d,a[v],v),a[v]=d):this.refs[v]=_),v}function E(v){if(typeof v=="string"){if(!YE.test(v))throw new Error(`invalid anchor "${v}"`);b.call(this,`#${v}`)}}}),a;function u(d,p,f){if(p!==void 0&&!HE(d,p))throw l(f)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ie.getSchemaRefs=XE});var xn=w(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Mt.getData=Mt.KeywordCxt=Mt.validateFunctionCode=void 0;var xm=tm(),Em=En(),Ra=va(),Ko=En(),QE=cm(),$n=fm(),za=hm(),T=A(),R=yt(),ew=wn(),St=q(),kn=bn();function tw(t){if(zm(t)&&(Rm(t),Tm(t))){ow(t);return}Pm(t,()=>(0,xm.topBoolOrEmptySchema)(t))}Mt.validateFunctionCode=tw;function Pm({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"; ${wm(r,o)}`),nw(t,o),t.code(s)}):t.func(e,(0,T._)`${R.default.data}, ${rw(o)}`,n.$async,()=>t.code(wm(r,o)).code(s))}function rw(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 nw(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 ow(t){let{schema:e,opts:r,gen:n}=t;Pm(t,()=>{r.$comment&&e.$comment&&Om(t),uw(t),n.let(R.default.vErrors,null),n.let(R.default.errors,0),r.unevaluated&&sw(t),Im(t),pw(t)})}function sw(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 wm(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 iw(t,e){if(zm(t)&&(Rm(t),Tm(t))){aw(t,e);return}(0,xm.boolOrEmptySchema)(t,e)}function Tm({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 zm(t){return typeof t.schema!="boolean"}function aw(t,e){let{schema:r,gen:n,opts:o}=t;o.$comment&&r.$comment&&Om(t),lw(t),dw(t);let s=n.const("_errs",R.default.errors);Im(t,s),n.var(e,(0,T._)`${s} === ${R.default.errors}`)}function Rm(t){(0,St.checkUnknownRules)(t),cw(t)}function Im(t,e){if(t.opts.jtd)return km(t,[],!1,e);let r=(0,Em.getSchemaTypes)(t.schema),n=(0,Em.coerceAndCheckDataType)(t,r);km(t,r,!n,e)}function cw(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 uw(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 lw(t){let e=t.schema[t.opts.schemaId];e&&(t.baseId=(0,ew.resolveUrl)(t.opts.uriResolver,t.baseId,e))}function dw(t){if(t.schema.$async&&!t.schemaEnv.$async)throw new Error("async schema in sync schema")}function Om({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 pw(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&&fw(t),e.return((0,T._)`${R.default.errors} === 0`))}function fw({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 km(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(()=>Mm(t,"$ref",l.all.$ref.definition));return}c.jtd||mw(t,e),o.block(()=>{for(let p of l.rules)d(p);d(l.post)});function d(p){(0,Ra.shouldUseGroup)(s,p)&&(p.type?(o.if((0,Ko.checkDataType)(p.type,i,c.strictNumbers)),$m(t,p),e.length===1&&e[0]===p.type&&r&&(o.else(),(0,Ko.reportTypeError)(t)),o.endIf()):$m(t,p),a||o.if((0,T._)`${R.default.errors} === ${n||0}`))}}function $m(t,e){let{gen:r,schema:n,opts:{useDefaults:o}}=t;o&&(0,QE.assignDefaults)(t,e.type),r.block(()=>{for(let s of e.rules)(0,Ra.shouldUseRule)(n,s)&&Mm(t,s.keyword,s.definition,e.type)})}function mw(t,e){t.schemaEnv.meta||!t.opts.strictTypes||(hw(t,e),t.opts.allowUnionTypes||gw(t,e),_w(t,t.dataTypes))}function hw(t,e){if(e.length){if(!t.dataTypes.length){t.dataTypes=e;return}e.forEach(r=>{Am(t.dataTypes,r)||Ia(t,`type "${r}" not allowed by context "${t.dataTypes.join(",")}"`)}),Sw(t,e)}}function gw(t,e){e.length>1&&!(e.length===2&&e.includes("null"))&&Ia(t,"use allowUnionTypes to allow union type keyword")}function _w(t,e){let r=t.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,Ra.shouldUseRule)(t.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>yw(e,i))&&Ia(t,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function yw(t,e){return t.includes(e)||e==="number"&&t.includes("integer")}function Am(t,e){return t.includes(e)||e==="integer"&&t.includes("number")}function Sw(t,e){let r=[];for(let n of t.dataTypes)Am(e,n)?r.push(n):e.includes("integer")&&n==="number"&&r.push("integer");t.dataTypes=r}function Ia(t,e){let r=t.schemaEnv.baseId+t.errSchemaPath;e+=` at "${r}" (strictTypes)`,(0,St.checkStrictMode)(t,e,t.opts.strictTypes)}var Go=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",Cm(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?kn.reportExtraError:kn.reportError)(this,this.def.error,r)}$dataError(){(0,kn.reportError)(this,this.def.$dataError||kn.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,kn.resetErrorsCount)(this.gen,this.errsCount)}ok(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,Ko.checkDataTypes)(c,r,s.opts.strictNumbers,Ko.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,za.getSubschema)(this.it,e);(0,za.extendSubschemaData)(n,this.it,e),(0,za.extendSubschemaMode)(n,e);let o={...this.it,...n,items:void 0,props:void 0};return iw(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}};Mt.KeywordCxt=Go;function Mm(t,e,r,n){let o=new Go(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 vw=/^\/(?:[^~]|~0|~1)*$/,bw=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Cm(t,{dataLevel:e,dataNames:r,dataPathArr:n}){let o,s;if(t==="")return R.default.rootData;if(t[0]==="/"){if(!vw.test(t))throw new Error(`Invalid JSON-pointer: ${t}`);o=t,s=R.default.rootData}else{let u=bw.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}`}}Mt.getData=Cm});var Jo=w(Aa=>{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});var Oa=class extends Error{constructor(e){super("validation failed"),this.errors=e,this.ajv=this.validation=!0}};Aa.default=Oa});var Pn=w(Na=>{"use strict";Object.defineProperty(Na,"__esModule",{value:!0});var Ma=wn(),Ca=class extends Error{constructor(e,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,Ma.resolveUrl)(e,r,n),this.missingSchema=(0,Ma.normalizeId)((0,Ma.getFullPath)(e,this.missingRef))}};Na.default=Ca});var Xo=w(Fe=>{"use strict";Object.defineProperty(Fe,"__esModule",{value:!0});Fe.resolveSchema=Fe.getCompilingSchema=Fe.resolveRef=Fe.compileSchema=Fe.SchemaEnv=void 0;var Je=A(),Ew=Jo(),Bt=yt(),Ye=wn(),Nm=q(),ww=xn(),Sr=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,Ye.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=Sr;function ja(t){let e=Dm.call(this,t);if(e)return e;let r=(0,Ye.getFullPath)(this.opts.uriResolver,t.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new Je.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;t.$async&&(a=i.scopeValue("Error",{ref:Ew.default,code:(0,Je._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");t.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:Bt.default.data,parentData:Bt.default.parentData,parentDataProperty:Bt.default.parentDataProperty,dataNames:[Bt.default.data],dataPathArr:[Je.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:t.schema,code:(0,Je.stringify)(t.schema)}:{ref:t.schema}),validateName:c,ValidationError:a,schema:t.schema,schemaEnv:t,rootId:r,baseId:t.baseId||r,schemaPath:Je.nil,errSchemaPath:t.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,Je._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(t),(0,ww.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(Bt.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,t));let f=new Function(`${Bt.default.self}`,`${Bt.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 Je.Name?void 0:m,items:_ instanceof Je.Name?void 0:_,dynamicProps:m instanceof Je.Name,dynamicItems:_ instanceof Je.Name},f.source&&(f.source.evaluated=(0,Je.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 kw(t,e,r){var n;r=(0,Ye.resolveUrl)(this.opts.uriResolver,e,r);let o=t.refs[r];if(o)return o;let s=Pw.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 Sr({schema:i,schemaId:a,root:t,baseId:e}))}if(s!==void 0)return t.refs[r]=$w.call(this,s)}Fe.resolveRef=kw;function $w(t){return(0,Ye.inlineRef)(t.schema,this.opts.inlineRefs)?t.schema:t.validate?t:ja.call(this,t)}function Dm(t){for(let e of this._compilations)if(xw(e,t))return e}Fe.getCompilingSchema=Dm;function xw(t,e){return t.schema===e.schema&&t.root===e.root&&t.baseId===e.baseId}function Pw(t,e){let r;for(;typeof(r=this.refs[e])=="string";)e=r;return r||this.schemas[e]||Yo.call(this,t,e)}function Yo(t,e){let r=this.opts.uriResolver.parse(e),n=(0,Ye._getFullPath)(this.opts.uriResolver,r),o=(0,Ye.getFullPath)(this.opts.uriResolver,t.baseId,void 0);if(Object.keys(t.schema).length>0&&n===o)return Da.call(this,r,t);let s=(0,Ye.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Yo.call(this,t,i);return typeof a?.schema!="object"?void 0:Da.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||ja.call(this,i),s===(0,Ye.normalizeId)(e)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,Ye.resolveUrl)(this.opts.uriResolver,o,u)),new Sr({schema:a,schemaId:c,root:t,baseId:o})}return Da.call(this,r,i)}}Fe.resolveSchema=Yo;var Tw=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function Da(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,Nm.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!Tw.has(a)&&u&&(e=(0,Ye.resolveUrl)(this.opts.uriResolver,e,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,Nm.schemaHasRulesButRef)(r,this.RULES)){let a=(0,Ye.resolveUrl)(this.opts.uriResolver,e,r.$ref);s=Yo.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Sr({schema:r,schemaId:i,root:n,baseId:e}),s.schema!==s.root.schema)return s}});var jm=w((mM,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 qa=w((hM,Hm)=>{"use strict";var Rw=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),Um=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),La=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),qm=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),Iw=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function Ua(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 Ow=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function Lm(t){return t.length=0,!0}function Aw(t,e,r){if(t.length){let n=Ua(t);if(n!=="")e.push(n);else return r.error=!0,!1;t.length=0}return!0}function Mw(t){let e=0,r={error:!1,address:"",zone:""},n=[],o=[],s=!1,i=!1,a=Aw;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=Lm}else{o.push(u);continue}}return o.length&&(a===Lm?r.zone=o.join(""):i?n.push(o.join("")):n.push(Ua(o))),r.address=n.join(""),r}function Zm(t){if(Cw(t,":")<2)return{host:t,isIPV6:!1};let e=Mw(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 Cw(t,e){let r=0;for(let n=0;n<t.length;n++)t[n]===e&&r++;return r}function Nw(t){let e=t,r=[],n=-1,o=0;for(;o=e.length;){if(o===1){if(e===".")break;if(e==="/"){r.push("/");break}else{r.push(e);break}}else if(o===2){if(e[0]==="."){if(e[1]===".")break;if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&(e[1]==="."||e[1]==="/")){r.push("/");break}}else if(o===3&&e==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(e[0]==="."){if(e[1]==="."){if(e[2]==="/"){e=e.slice(3);continue}}else if(e[1]==="/"){e=e.slice(2);continue}}else if(e[0]==="/"&&e[1]==="."){if(e[2]==="/"){e=e.slice(2);continue}else if(e[2]==="."&&e[3]==="/"){e=e.slice(3),r.length!==0&&r.pop();continue}}if((n=e.indexOf("/",1))===-1){r.push(e);break}else r.push(e.slice(0,n)),e=e.slice(n)}return r.join("")}var Dw={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},jw=/[@/?#:]/g,Lw=/[@/?#]/g;function Fm(t,e){let r=e?Lw:jw;return r.lastIndex=0,t.replace(r,n=>Dw[n])}function Uw(t,e=!1){if(t.indexOf("%")===-1)return t;let r="";for(let n=0;n<t.length;n++){if(t[n]==="%"&&n+2<t.length){let o=t.slice(n+1,n+3);if(La(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));e&&qm(i)?r+=i:r+="%"+s,n+=2;continue}}r+=t[n]}return r}function qw(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(La(n)){let o=n.toUpperCase(),s=String.fromCharCode(parseInt(o,16));s!=="."&&qm(s)?e+=s:e+="%"+o,r+=2;continue}}Iw(t[r])?e+=t[r]:e+=escape(t[r])}return e}function Zw(t){let e="";for(let r=0;r<t.length;r++){if(t[r]==="%"&&r+2<t.length){let n=t.slice(r+1,r+3);if(La(n)){e+="%"+n.toUpperCase(),r+=2;continue}}e+=escape(t[r])}return e}function Fw(t){let e=[];if(t.userinfo!==void 0&&(e.push(t.userinfo),e.push("@")),t.host!==void 0){let r=unescape(t.host);if(!Um(r)){let n=Zm(r);n.isIPV6===!0?r=`[${n.escapedHost}]`:r=Fm(r,!1)}e.push(r)}return(typeof t.port=="number"||typeof t.port=="string")&&(e.push(":"),e.push(String(t.port))),e.length?e.join(""):void 0}Hm.exports={nonSimpleDomain:Ow,recomposeAuthority:Fw,reescapeHostDelimiters:Fm,normalizePercentEncoding:Uw,normalizePathEncoding:qw,escapePreservingEscapes:Zw,removeDotSegments:Nw,isIPv4:Um,isUUID:Rw,normalizeIPv6:Zm,stringArrayToHexStripped:Ua}});var Gm=w((gM,Km)=>{"use strict";var{isUUID:Hw}=qa(),Vw=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,Ww=["http","https","ws","wss","urn","urn:uuid"];function Bw(t){return Ww.indexOf(t)!==-1}function Za(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 Vm(t){return t.host||(t.error=t.error||"HTTP URIs must have a host."),t}function Wm(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 Kw(t){return t.secure=Za(t),t.resourceName=(t.path||"/")+(t.query?"?"+t.query:""),t.path=void 0,t.query=void 0,t}function Gw(t){if((t.port===(Za(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 Jw(t,e){if(!t.path)return t.error="URN can not be parsed",t;let r=t.path.match(Vw);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=Fa(o);t.path=void 0,s&&(t=s.parse(t,e))}else t.error=t.error||"URN can not be parsed.";return t}function Yw(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=Fa(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 Xw(t,e){let r=t;return r.uuid=r.nss,r.nss=void 0,!e.tolerant&&(!r.uuid||!Hw(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function Qw(t){let e=t;return e.nss=(t.uuid||"").toLowerCase(),e}var Bm={scheme:"http",domainHost:!0,parse:Vm,serialize:Wm},e0={scheme:"https",domainHost:Bm.domainHost,parse:Vm,serialize:Wm},Qo={scheme:"ws",domainHost:!0,parse:Kw,serialize:Gw},t0={scheme:"wss",domainHost:Qo.domainHost,parse:Qo.parse,serialize:Qo.serialize},r0={scheme:"urn",parse:Jw,serialize:Yw,skipNormalize:!0},n0={scheme:"urn:uuid",parse:Xw,serialize:Qw,skipNormalize:!0},es={http:Bm,https:e0,ws:Qo,wss:t0,urn:r0,"urn:uuid":n0};Object.setPrototypeOf(es,null);function Fa(t){return t&&(es[t]||es[t.toLowerCase()])||void 0}Km.exports={wsIsSecure:Za,SCHEMES:es,isValidSchemeName:Bw,getSchemeHandler:Fa}});var th=w((_M,ts)=>{"use strict";var{normalizeIPv6:o0,removeDotSegments:Tn,recomposeAuthority:s0,normalizePercentEncoding:i0,normalizePathEncoding:a0,escapePreservingEscapes:c0,reescapeHostDelimiters:u0,isIPv4:l0,nonSimpleDomain:d0}=qa(),{SCHEMES:p0,getSchemeHandler:Ym}=Gm();function f0(t,e){return typeof t=="string"?t=y0(t,e):typeof t=="object"&&(t=vr(Kt(t,e),e)),t}function m0(t,e,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},o=Xm(vr(t,n),vr(e,n),n,!0);return n.skipEscape=!0,Kt(o,n)}function Xm(t,e,r,n){let o={};return n||(t=vr(Kt(t,r),r),e=vr(Kt(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=Tn(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=Tn(e.path||""),o.query=e.query):(e.path?(e.path[0]==="/"?o.path=Tn(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=Tn(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 h0(t,e,r){let n=Jm(t,r),o=Jm(e,r);return n!==void 0&&o!==void 0&&n.toLowerCase()===o.toLowerCase()}function Kt(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=Ym(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n),r.path!==void 0&&(n.skipEscape?r.path=i0(r.path):(r.path=c0(r.path),r.scheme!==void 0&&(r.path=r.path.split("%3A").join(":")))),n.reference!=="suffix"&&r.scheme&&o.push(r.scheme,":");let i=s0(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=Tn(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 g0=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function _0(t,e){if(e[2]!==void 0&&t.path&&t.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof t.port=="number"&&(t.port<0||t.port>65535))return"URI port is malformed."}function Qm(t,e){let r=Object.assign({},e),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1;r.reference==="suffix"&&(r.scheme?t=r.scheme+":"+t:t="//"+t);let i=t.match(g0);if(i){n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||"",n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5]);let a=_0(n,i);if(a!==void 0&&(n.error=n.error||a,o=!0),n.host)if(l0(n.host)===!1){let l=o0(n.host);n.host=l.host.toLowerCase(),s=l.isIPV6}else s=!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 c=Ym(r.scheme||n.scheme);if(!r.unicodeSupport&&(!c||!c.unicodeSupport)&&n.host&&(r.domainHost||c&&c.domainHost)&&s===!1&&d0(n.host))try{n.host=URL.domainToASCII(n.host.toLowerCase())}catch(u){n.error=n.error||"Host's domain name can not be converted to ASCII: "+u}if((!c||c&&!c.skipNormalize)&&(t.indexOf("%")!==-1&&(n.scheme!==void 0&&(n.scheme=unescape(n.scheme)),n.host!==void 0&&(n.host=u0(unescape(n.host),s))),n.path&&(n.path=a0(n.path)),n.fragment))try{n.fragment=encodeURI(decodeURIComponent(n.fragment))}catch{n.error=n.error||"URI malformed"}c&&c.parse&&c.parse(n,r)}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o}}function vr(t,e){return Qm(t,e).parsed}function y0(t,e){return eh(t,e).normalized}function eh(t,e){let{parsed:r,malformedAuthorityOrPort:n}=Qm(t,e);return{normalized:n?t:Kt(r,e),malformedAuthorityOrPort:n}}function Jm(t,e){if(typeof t=="string"){let{normalized:r,malformedAuthorityOrPort:n}=eh(t,e);return n?void 0:r}if(typeof t=="object")return Kt(t,e)}var Ha={SCHEMES:p0,normalize:f0,resolve:m0,resolveComponent:Xm,equal:h0,serialize:Kt,parse:vr};ts.exports=Ha;ts.exports.default=Ha;ts.exports.fastUri=Ha});var nh=w(Va=>{"use strict";Object.defineProperty(Va,"__esModule",{value:!0});var rh=th();rh.code='require("ajv/dist/runtime/uri").default';Va.default=rh});var dh=w(he=>{"use strict";Object.defineProperty(he,"__esModule",{value:!0});he.CodeGen=he.Name=he.nil=he.stringify=he.str=he._=he.KeywordCxt=void 0;var S0=xn();Object.defineProperty(he,"KeywordCxt",{enumerable:!0,get:function(){return S0.KeywordCxt}});var br=A();Object.defineProperty(he,"_",{enumerable:!0,get:function(){return br._}});Object.defineProperty(he,"str",{enumerable:!0,get:function(){return br.str}});Object.defineProperty(he,"stringify",{enumerable:!0,get:function(){return br.stringify}});Object.defineProperty(he,"nil",{enumerable:!0,get:function(){return br.nil}});Object.defineProperty(he,"Name",{enumerable:!0,get:function(){return br.Name}});Object.defineProperty(he,"CodeGen",{enumerable:!0,get:function(){return br.CodeGen}});var v0=Jo(),ch=Pn(),b0=Sa(),zn=Xo(),E0=A(),Rn=wn(),rs=En(),Ba=q(),oh=jm(),w0=nh(),uh=(t,e)=>new RegExp(t,e);uh.code="new RegExp";var k0=["removeAdditional","useDefaults","coerceTypes"],$0=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),x0={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."},P0={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},sh=200;function T0(t){var e,r,n,o,s,i,a,c,u,l,d,p,f,m,_,y,b,E,v,x,$,ye,we,jt,er;let ae=t.strict,vt=(e=t.code)===null||e===void 0?void 0:e.optimize,Be=vt===!0||vt===void 0?1:vt||0,Dr=(n=(r=t.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:uh,N_=(o=t.uriResolver)!==null&&o!==void 0?o:w0.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:Be,regExp:Dr}:{optimize:Be,regExp:Dr},loopRequired:(_=t.loopRequired)!==null&&_!==void 0?_:sh,loopEnum:(y=t.loopEnum)!==null&&y!==void 0?y:sh,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:(x=t.schemaId)!==null&&x!==void 0?x:"$id",addUsedSchema:($=t.addUsedSchema)!==null&&$!==void 0?$:!0,validateSchema:(ye=t.validateSchema)!==null&&ye!==void 0?ye:!0,validateFormats:(we=t.validateFormats)!==null&&we!==void 0?we:!0,unicodeRegExp:(jt=t.unicodeRegExp)!==null&&jt!==void 0?jt:!0,int32range:(er=t.int32range)!==null&&er!==void 0?er:!0,uriResolver:N_}}var In=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...T0(e)};let{es5:r,lines:n}=this.opts.code;this.scope=new E0.ValueScope({scope:{},prefixes:$0,es5:r,lines:n}),this.logger=M0(e.logger);let o=e.validateFormats;e.validateFormats=!1,this.RULES=(0,b0.getRules)(),ih.call(this,x0,e,"NOT SUPPORTED"),ih.call(this,P0,e,"DEPRECATED","warn"),this._metaOpts=O0.call(this),e.formats&&R0.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&I0.call(this,e.keywords),typeof e.meta=="object"&&this.addMetaSchema(e.meta),z0.call(this),e.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:e,meta:r,schemaId:n}=this.opts,o=oh;n==="id"&&(o={...oh},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 ch.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,Rn.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=ah.call(this,e))=="string";)e=r;if(r===void 0){let{schemaId:n}=this.opts,o=new zn.SchemaEnv({schema:{},schemaId:n});if(r=zn.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=ah.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,Rn.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(N0.call(this,n,r),!r)return(0,Ba.eachItem)(n,s=>Wa.call(this,s)),this;j0.call(this,r);let o={...r,type:(0,rs.getJSONTypes)(r.type),schemaType:(0,rs.getJSONTypes)(r.schemaType)};return(0,Ba.eachItem)(n,o.type.length===0?s=>Wa.call(this,s,o):s=>o.type.forEach(i=>Wa.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]=lh(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,Rn.normalizeId)(i||n);let u=Rn.getSchemaRefs.call(this,e,n);return c=new zn.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):zn.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{zn.compileSchema.call(this,e)}finally{this.opts=r}}};In.ValidationError=v0.default;In.MissingRefError=ch.default;he.default=In;function ih(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 ah(t){return t=(0,Rn.normalizeId)(t),this.schemas[t]||this.refs[t]}function z0(){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 R0(){for(let t in this.opts.formats){let e=this.opts.formats[t];e&&this.addFormat(t,e)}}function I0(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 O0(){let t={...this.opts};for(let e of k0)delete t[e];return t}var A0={log(){},warn(){},error(){}};function M0(t){if(t===!1)return A0;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 C0=/^[a-z_$][a-z0-9_$:-]*$/i;function N0(t,e){let{RULES:r}=this;if((0,Ba.eachItem)(t,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!C0.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 Wa(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,rs.getJSONTypes)(e.type),schemaType:(0,rs.getJSONTypes)(e.schemaType)}};e.before?D0.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 D0(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 j0(t){let{metaSchema:e}=t;e!==void 0&&(t.$data&&this.opts.$data&&(e=lh(e)),t.validateSchema=this.compile(e,!0))}var L0={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function lh(t){return{anyOf:[t,L0]}}});var ph=w(Ka=>{"use strict";Object.defineProperty(Ka,"__esModule",{value:!0});var U0={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ka.default=U0});var gh=w(Gt=>{"use strict";Object.defineProperty(Gt,"__esModule",{value:!0});Gt.callRef=Gt.getValidate=void 0;var q0=Pn(),fh=Ze(),Oe=A(),Er=yt(),mh=Xo(),ns=q(),Z0={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=mh.resolveRef.call(c,u,o,r);if(l===void 0)throw new q0.default(n.opts.uriResolver,o,r);if(l instanceof mh.SchemaEnv)return p(l);return f(l);function d(){if(s===u)return os(t,i,s,s.$async);let m=e.scopeValue("root",{ref:u});return os(t,(0,Oe._)`${m}.validate`,u,u.$async)}function p(m){let _=hh(t,m);os(t,_,m,m.$async)}function f(m){let _=e.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Oe.stringify)(m)}:{ref:m}),y=e.name("valid"),b=t.subschema({schema:m,dataTypes:[],schemaPath:Oe.nil,topSchemaRef:_,errSchemaPath:r},y);t.mergeEvaluated(b),t.ok(y)}}};function hh(t,e){let{gen:r}=t;return e.validate?r.scopeValue("validate",{ref:e.validate}):(0,Oe._)`${r.scopeValue("wrapper",{ref:e})}.validate`}Gt.getValidate=hh;function os(t,e,r,n){let{gen:o,it:s}=t,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Er.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,fh.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,fh.callValidateCode)(t,e,u),()=>f(e),()=>p(e))}function p(m){let _=(0,Oe._)`${m}.errors`;o.assign(Er.default.vErrors,(0,Oe._)`${Er.default.vErrors} === null ? ${_} : ${Er.default.vErrors}.concat(${_})`),o.assign(Er.default.errors,(0,Oe._)`${Er.default.vErrors}.length`)}function f(m){var _;if(!s.opts.unevaluated)return;let y=(_=r?.validate)===null||_===void 0?void 0:_.evaluated;if(s.props!==!0)if(y&&!y.dynamicProps)y.props!==void 0&&(s.props=ns.mergeEvaluated.props(o,y.props,s.props));else{let b=o.var("props",(0,Oe._)`${m}.evaluated.props`);s.props=ns.mergeEvaluated.props(o,b,s.props,Oe.Name)}if(s.items!==!0)if(y&&!y.dynamicItems)y.items!==void 0&&(s.items=ns.mergeEvaluated.items(o,y.items,s.items));else{let b=o.var("items",(0,Oe._)`${m}.evaluated.items`);s.items=ns.mergeEvaluated.items(o,b,s.items,Oe.Name)}}}Gt.callRef=os;Gt.default=Z0});var _h=w(Ga=>{"use strict";Object.defineProperty(Ga,"__esModule",{value:!0});var F0=ph(),H0=gh(),V0=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",F0.default,H0.default];Ga.default=V0});var yh=w(Ja=>{"use strict";Object.defineProperty(Ja,"__esModule",{value:!0});var ss=A(),Ct=ss.operators,is={maximum:{okStr:"<=",ok:Ct.LTE,fail:Ct.GT},minimum:{okStr:">=",ok:Ct.GTE,fail:Ct.LT},exclusiveMaximum:{okStr:"<",ok:Ct.LT,fail:Ct.GTE},exclusiveMinimum:{okStr:">",ok:Ct.GT,fail:Ct.LTE}},W0={message:({keyword:t,schemaCode:e})=>(0,ss.str)`must be ${is[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,ss._)`{comparison: ${is[t].okStr}, limit: ${e}}`},B0={keyword:Object.keys(is),type:"number",schemaType:"number",$data:!0,error:W0,code(t){let{keyword:e,data:r,schemaCode:n}=t;t.fail$data((0,ss._)`${r} ${is[e].fail} ${n} || isNaN(${r})`)}};Ja.default=B0});var Sh=w(Ya=>{"use strict";Object.defineProperty(Ya,"__esModule",{value:!0});var On=A(),K0={message:({schemaCode:t})=>(0,On.str)`must be multiple of ${t}`,params:({schemaCode:t})=>(0,On._)`{multipleOf: ${t}}`},G0={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:K0,code(t){let{gen:e,data:r,schemaCode:n,it:o}=t,s=o.opts.multipleOfPrecision,i=e.let("res"),a=s?(0,On._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,On._)`${i} !== parseInt(${i})`;t.fail$data((0,On._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Ya.default=G0});var bh=w(Xa=>{"use strict";Object.defineProperty(Xa,"__esModule",{value:!0});function vh(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}Xa.default=vh;vh.code='require("ajv/dist/runtime/ucs2length").default'});var Eh=w(Qa=>{"use strict";Object.defineProperty(Qa,"__esModule",{value:!0});var Jt=A(),J0=q(),Y0=bh(),X0={message({keyword:t,schemaCode:e}){let r=t==="maxLength"?"more":"fewer";return(0,Jt.str)`must NOT have ${r} than ${e} characters`},params:({schemaCode:t})=>(0,Jt._)`{limit: ${t}}`},Q0={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:X0,code(t){let{keyword:e,data:r,schemaCode:n,it:o}=t,s=e==="maxLength"?Jt.operators.GT:Jt.operators.LT,i=o.opts.unicode===!1?(0,Jt._)`${r}.length`:(0,Jt._)`${(0,J0.useFunc)(t.gen,Y0.default)}(${r})`;t.fail$data((0,Jt._)`${i} ${s} ${n}`)}};Qa.default=Q0});var wh=w(ec=>{"use strict";Object.defineProperty(ec,"__esModule",{value:!0});var ek=Ze(),tk=q(),wr=A(),rk={message:({schemaCode:t})=>(0,wr.str)`must match pattern "${t}"`,params:({schemaCode:t})=>(0,wr._)`{pattern: ${t}}`},nk={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:rk,code(t){let{gen:e,data:r,$data:n,schema:o,schemaCode:s,it:i}=t,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,wr._)`new RegExp`:(0,tk.useFunc)(e,c),l=e.let("valid");e.try(()=>e.assign(l,(0,wr._)`${u}(${s}, ${a}).test(${r})`),()=>e.assign(l,!1)),t.fail$data((0,wr._)`!${l}`)}else{let c=(0,ek.usePattern)(t,o);t.fail$data((0,wr._)`!${c}.test(${r})`)}}};ec.default=nk});var kh=w(tc=>{"use strict";Object.defineProperty(tc,"__esModule",{value:!0});var An=A(),ok={message({keyword:t,schemaCode:e}){let r=t==="maxProperties"?"more":"fewer";return(0,An.str)`must NOT have ${r} than ${e} properties`},params:({schemaCode:t})=>(0,An._)`{limit: ${t}}`},sk={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:ok,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxProperties"?An.operators.GT:An.operators.LT;t.fail$data((0,An._)`Object.keys(${r}).length ${o} ${n}`)}};tc.default=sk});var $h=w(rc=>{"use strict";Object.defineProperty(rc,"__esModule",{value:!0});var Mn=Ze(),Cn=A(),ik=q(),ak={message:({params:{missingProperty:t}})=>(0,Cn.str)`must have required property '${t}'`,params:({params:{missingProperty:t}})=>(0,Cn._)`{missingProperty: ${t}}`},ck={keyword:"required",type:"object",schemaType:"array",$data:!0,error:ak,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 y=i.schemaEnv.baseId+i.errSchemaPath,b=`required property "${_}" is not defined at "${y}" (strictRequired)`;(0,ik.checkStrictMode)(i,b,i.opts.strictRequired)}}function u(){if(c||s)t.block$data(Cn.nil,d);else for(let f of r)(0,Mn.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,Mn.checkMissingProp)(t,r,f)),(0,Mn.reportMissingProp)(t,f),e.else()}function d(){e.forOf("prop",n,f=>{t.setParams({missingProperty:f}),e.if((0,Mn.noPropertyInData)(e,o,f,a.ownProperties),()=>t.error())})}function p(f,m){t.setParams({missingProperty:f}),e.forOf(f,n,()=>{e.assign(m,(0,Mn.propertyInData)(e,o,f,a.ownProperties)),e.if((0,Cn.not)(m),()=>{t.error(),e.break()})},Cn.nil)}}};rc.default=ck});var xh=w(nc=>{"use strict";Object.defineProperty(nc,"__esModule",{value:!0});var Nn=A(),uk={message({keyword:t,schemaCode:e}){let r=t==="maxItems"?"more":"fewer";return(0,Nn.str)`must NOT have ${r} than ${e} items`},params:({schemaCode:t})=>(0,Nn._)`{limit: ${t}}`},lk={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:uk,code(t){let{keyword:e,data:r,schemaCode:n}=t,o=e==="maxItems"?Nn.operators.GT:Nn.operators.LT;t.fail$data((0,Nn._)`${r}.length ${o} ${n}`)}};nc.default=lk});var as=w(oc=>{"use strict";Object.defineProperty(oc,"__esModule",{value:!0});var Ph=Pa();Ph.code='require("ajv/dist/runtime/equal").default';oc.default=Ph});var Th=w(ic=>{"use strict";Object.defineProperty(ic,"__esModule",{value:!0});var sc=En(),ge=A(),dk=q(),pk=as(),fk={message:({params:{i:t,j:e}})=>(0,ge.str)`must NOT have duplicate items (items ## ${e} and ${t} are identical)`,params:({params:{i:t,j:e}})=>(0,ge._)`{i: ${t}, j: ${e}}`},mk={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:fk,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,sc.getSchemaTypes)(s.items):[];t.block$data(c,l,(0,ge._)`${i} === false`),t.ok(c);function l(){let m=e.let("i",(0,ge._)`${r}.length`),_=e.let("j");t.setParams({i:m,j:_}),e.assign(c,!0),e.if((0,ge._)`${m} > 1`,()=>(d()?p:f)(m,_))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function p(m,_){let y=e.name("item"),b=(0,sc.checkDataTypes)(u,y,a.opts.strictNumbers,sc.DataType.Wrong),E=e.const("indices",(0,ge._)`{}`);e.for((0,ge._)`;${m}--;`,()=>{e.let(y,(0,ge._)`${r}[${m}]`),e.if(b,(0,ge._)`continue`),u.length>1&&e.if((0,ge._)`typeof ${y} == "string"`,(0,ge._)`${y} += "_"`),e.if((0,ge._)`typeof ${E}[${y}] == "number"`,()=>{e.assign(_,(0,ge._)`${E}[${y}]`),t.error(),e.assign(c,!1).break()}).code((0,ge._)`${E}[${y}] = ${m}`)})}function f(m,_){let y=(0,dk.useFunc)(e,pk.default),b=e.name("outer");e.label(b).for((0,ge._)`;${m}--;`,()=>e.for((0,ge._)`${_} = ${m}; ${_}--;`,()=>e.if((0,ge._)`${y}(${r}[${m}], ${r}[${_}])`,()=>{t.error(),e.assign(c,!1).break(b)})))}}};ic.default=mk});var zh=w(cc=>{"use strict";Object.defineProperty(cc,"__esModule",{value:!0});var ac=A(),hk=q(),gk=as(),_k={message:"must be equal to constant",params:({schemaCode:t})=>(0,ac._)`{allowedValue: ${t}}`},yk={keyword:"const",$data:!0,error:_k,code(t){let{gen:e,data:r,$data:n,schemaCode:o,schema:s}=t;n||s&&typeof s=="object"?t.fail$data((0,ac._)`!${(0,hk.useFunc)(e,gk.default)}(${r}, ${o})`):t.fail((0,ac._)`${s} !== ${r}`)}};cc.default=yk});var Rh=w(uc=>{"use strict";Object.defineProperty(uc,"__esModule",{value:!0});var Dn=A(),Sk=q(),vk=as(),bk={message:"must be equal to one of the allowed values",params:({schemaCode:t})=>(0,Dn._)`{allowedValues: ${t}}`},Ek={keyword:"enum",schemaType:"array",$data:!0,error:bk,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,Sk.useFunc)(e,vk.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,Dn.or)(...o.map((m,_)=>p(f,_)))}t.pass(l);function d(){e.assign(l,!1),e.forOf("v",s,f=>e.if((0,Dn._)`${u()}(${r}, ${f})`,()=>e.assign(l,!0).break()))}function p(f,m){let _=o[m];return typeof _=="object"&&_!==null?(0,Dn._)`${u()}(${r}, ${f}[${m}])`:(0,Dn._)`${r} === ${_}`}}};uc.default=Ek});var Ih=w(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var wk=yh(),kk=Sh(),$k=Eh(),xk=wh(),Pk=kh(),Tk=$h(),zk=xh(),Rk=Th(),Ik=zh(),Ok=Rh(),Ak=[wk.default,kk.default,$k.default,xk.default,Pk.default,Tk.default,zk.default,Rk.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},Ik.default,Ok.default];lc.default=Ak});var pc=w(jn=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});jn.validateAdditionalItems=void 0;var Yt=A(),dc=q(),Mk={message:({params:{len:t}})=>(0,Yt.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Yt._)`{limit: ${t}}`},Ck={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:Mk,code(t){let{parentSchema:e,it:r}=t,{items:n}=e;if(!Array.isArray(n)){(0,dc.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}Oh(t,n)}};function Oh(t,e){let{gen:r,schema:n,data:o,keyword:s,it:i}=t;i.items=!0;let a=r.const("len",(0,Yt._)`${o}.length`);if(n===!1)t.setParams({len:e.length}),t.pass((0,Yt._)`${a} <= ${e.length}`);else if(typeof n=="object"&&!(0,dc.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,Yt._)`${a} <= ${e.length}`);r.if((0,Yt.not)(u),()=>c(u)),t.ok(u)}function c(u){r.forRange("i",e.length,a,l=>{t.subschema({keyword:s,dataProp:l,dataPropType:dc.Type.Num},u),i.allErrors||r.if((0,Yt.not)(u),()=>r.break())})}}jn.validateAdditionalItems=Oh;jn.default=Ck});var fc=w(Ln=>{"use strict";Object.defineProperty(Ln,"__esModule",{value:!0});Ln.validateTuple=void 0;var Ah=A(),cs=q(),Nk=Ze(),Dk={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(t){let{schema:e,it:r}=t;if(Array.isArray(e))return Mh(t,"additionalItems",e);r.items=!0,!(0,cs.alwaysValidSchema)(r,e)&&t.ok((0,Nk.validateArray)(t))}};function Mh(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=cs.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,Ah._)`${s}.length`);r.forEach((d,p)=>{(0,cs.alwaysValidSchema)(a,d)||(n.if((0,Ah._)`${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 y=`"${i}" is ${m}-tuple, but minItems or maxItems/${e} are not specified or different at path "${f}"`;(0,cs.checkStrictMode)(a,y,p.strictTuples)}}}Ln.validateTuple=Mh;Ln.default=Dk});var Ch=w(mc=>{"use strict";Object.defineProperty(mc,"__esModule",{value:!0});var jk=fc(),Lk={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:t=>(0,jk.validateTuple)(t,"items")};mc.default=Lk});var Dh=w(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});var Nh=A(),Uk=q(),qk=Ze(),Zk=pc(),Fk={message:({params:{len:t}})=>(0,Nh.str)`must NOT have more than ${t} items`,params:({params:{len:t}})=>(0,Nh._)`{limit: ${t}}`},Hk={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:Fk,code(t){let{schema:e,parentSchema:r,it:n}=t,{prefixItems:o}=r;n.items=!0,!(0,Uk.alwaysValidSchema)(n,e)&&(o?(0,Zk.validateAdditionalItems)(t,o):t.ok((0,qk.validateArray)(t)))}};hc.default=Hk});var jh=w(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});var He=A(),us=q(),Vk={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}}`},Wk={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:Vk,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,us.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,us.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),t.fail();return}if((0,us.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"),y=e.let("count",0);f(_,()=>e.if(_,()=>m(y)))}function f(_,y){e.forRange("i",0,l,b=>{t.subschema({keyword:"contains",dataProp:b,dataPropType:us.Type.Num,compositeRule:!0},_),y()})}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)))}}};gc.default=Wk});var qh=w(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.validateSchemaDeps=st.validatePropertyDeps=st.error=void 0;var _c=A(),Bk=q(),Un=Ze();st.error={message:({params:{property:t,depsCount:e,deps:r}})=>{let n=e===1?"property":"properties";return(0,_c.str)`must have ${n} ${r} when property ${t} is present`},params:({params:{property:t,depsCount:e,deps:r,missingProperty:n}})=>(0,_c._)`{property: ${t},
7
7
  missingProperty: ${n},
8
8
  depsCount: ${e},
9
- deps: ${r}}`};var M$={keyword:"dependencies",type:"object",schemaType:"object",error:nt.error,code(t){let[e,r]=C$(t);Th(t,e),Rh(t,r)}};function C$({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 Th(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,Ln.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,Ln.checkReportMissingProp)(t,u)}):(r.if((0,lc._)`${c} && (${(0,Ln.checkMissingProp)(t,a,s)})`),(0,Ln.reportMissingProp)(t,s),r.else())}}nt.validatePropertyDeps=Th;function Rh(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,A$.alwaysValidSchema)(s,e[a])||(r.if((0,Ln.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))}nt.validateSchemaDeps=Rh;nt.default=M$});var Ah=E(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var Ih=A(),N$=Z(),D$={message:"property name must be valid",params:({params:t})=>(0,Ih._)`{propertyName: ${t.propertyName}}`},L$={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:D$,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,N$.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,Ih.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};dc.default=L$});var fc=E(pc=>{"use strict";Object.defineProperty(pc,"__esModule",{value:!0});var ss=Fe(),Ye=A(),j$=_t(),is=Z(),U$={message:"must NOT have additional properties",params:({params:t})=>(0,Ye._)`{additionalProperty: ${t.additionalProperty}}`},Z$={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:U$,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,is.alwaysValidSchema)(i,r))return;let u=(0,ss.allSchemaProperties)(n.properties),l=(0,ss.allSchemaProperties)(n.patternProperties);d(),t.ok((0,Ye._)`${s} === ${j$.default.errors}`);function d(){e.forIn("key",o,y=>{!u.length&&!l.length?m(y):e.if(p(y),()=>m(y))})}function p(y){let b;if(u.length>8){let w=(0,is.schemaRefOrVal)(i,n.properties,"properties");b=(0,ss.isOwnProperty)(e,w,y)}else u.length?b=(0,Ye.or)(...u.map(w=>(0,Ye._)`${y} === ${w}`)):b=Ye.nil;return l.length&&(b=(0,Ye.or)(b,...l.map(w=>(0,Ye._)`${(0,ss.usePattern)(t,w)}.test(${y})`))),(0,Ye.not)(b)}function f(y){e.code((0,Ye._)`delete ${o}[${y}]`)}function m(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(y);return}if(r===!1){t.setParams({additionalProperty:y}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,is.alwaysValidSchema)(i,r)){let b=e.name("valid");c.removeAdditional==="failing"?(_(y,b,!1),e.if((0,Ye.not)(b),()=>{t.reset(),f(y)})):(_(y,b),a||e.if((0,Ye.not)(b),()=>e.break()))}}function _(y,b,w){let v={keyword:"additionalProperties",dataProp:y,dataPropType:is.Type.Str};w===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(v,b)}}};pc.default=Z$});var Nh=E(hc=>{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});var F$=$n(),Mh=Fe(),mc=Z(),Ch=fc(),q$={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&&Ch.default.code(new F$.KeywordCxt(s,Ch.default,"additionalProperties"));let i=(0,Mh.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,Mh.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)}}};hc.default=q$});var Uh=E(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});var Dh=Fe(),as=A(),Lh=Z(),jh=Z(),H$={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,Dh.allSchemaProperties)(r),c=a.filter(_=>(0,Lh.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 as.Name)&&(s.props=(0,jh.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 y in u)new RegExp(_).test(y)&&(0,Lh.checkStrictMode)(s,`property ${y} matches pattern ${_} (use allowMatchingProperties)`)}function m(_){e.forIn("key",n,y=>{e.if((0,as._)`${(0,Dh.usePattern)(t,_)}.test(${y})`,()=>{let b=c.includes(_);b||t.subschema({keyword:"patternProperties",schemaProp:_,dataProp:y,dataPropType:jh.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,as._)`${d}[${y}]`,!0):!b&&!s.allErrors&&e.if((0,as.not)(l),()=>e.break())})})}}};gc.default=H$});var Zh=E(_c=>{"use strict";Object.defineProperty(_c,"__esModule",{value:!0});var W$=Z(),V$={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,W$.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"}};_c.default=V$});var Fh=E(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});var G$=Fe(),K$={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:G$.validateUnion,error:{message:"must match a schema in anyOf"}};yc.default=K$});var qh=E(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var cs=A(),J$=Z(),B$={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,cs._)`{passingSchemas: ${t.passing}}`},Y$={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:B$,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,J$.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,cs._)`${c} && ${i}`).assign(i,!1).assign(a,(0,cs._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,cs.Name)})})}}};Sc.default=Y$});var Hh=E(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var X$=Z(),Q$={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,X$.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};vc.default=Q$});var Gh=E(bc=>{"use strict";Object.defineProperty(bc,"__esModule",{value:!0});var us=A(),Vh=Z(),ek={message:({params:t})=>(0,us.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,us._)`{failingKeyword: ${t.ifClause}}`},tk={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:ek,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,Vh.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Wh(n,"then"),s=Wh(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,us.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,us._)`${l}`):t.setParams({ifClause:l})}}}};function Wh(t,e){let r=t.schema[e];return r!==void 0&&!(0,Vh.alwaysValidSchema)(t,r)}bc.default=tk});var Kh=E(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});var rk=Z(),nk={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,rk.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};wc.default=nk});var Jh=E(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});var ok=sc(),sk=kh(),ik=ic(),ak=Ph(),ck=zh(),uk=Oh(),lk=Ah(),dk=fc(),pk=Nh(),fk=Uh(),mk=Zh(),hk=Fh(),gk=qh(),_k=Hh(),yk=Gh(),Sk=Kh();function vk(t=!1){let e=[mk.default,hk.default,gk.default,_k.default,yk.default,Sk.default,lk.default,dk.default,uk.default,pk.default,fk.default];return t?e.push(sk.default,ak.default):e.push(ok.default,ik.default),e.push(ck.default),e}Ec.default=vk});var Bh=E($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});var ie=A(),bk={message:({schemaCode:t})=>(0,ie.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ie._)`{format: ${t}}`},wk={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:bk,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}]`),y=r.let("fType"),b=r.let("format");r.if((0,ie._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(y,(0,ie._)`${_}.type || "string"`).assign(b,(0,ie._)`${_}.validate`),()=>r.assign(y,(0,ie._)`"string"`).assign(b,_)),t.fail$data((0,ie.or)(w(),v()));function w(){return c.strictSchema===!1?ie.nil:(0,ie._)`${i} && !${b}`}function v(){let x=l.$async?(0,ie._)`(${_}.async ? await ${b}(${n}) : ${b}(${n}))`:(0,ie._)`${b}(${n})`,k=(0,ie._)`(typeof ${b} == "function" ? ${x} : ${b}.test(${n}))`;return(0,ie._)`${b} && ${b} !== true && ${y} === ${e} && !${k}`}}function f(){let m=d.formats[s];if(!m){w();return}if(m===!0)return;let[_,y,b]=v(m);_===e&&t.pass(x());function w(){if(c.strictSchema===!1){d.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function v(k){let _e=k instanceof RegExp?(0,ie.regexpCode)(k):c.code.formats?(0,ie._)`${c.code.formats}${(0,ie.getProperty)(s)}`:void 0,Ee=r.scopeValue("formats",{key:s,ref:k,code:_e});return typeof k=="object"&&!(k instanceof RegExp)?[k.type||"string",k.validate,(0,ie._)`${Ee}.validate`]:["string",k,Ee]}function x(){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 y=="function"?(0,ie._)`${b}(${n})`:(0,ie._)`${b}.test(${n})`}}}};$c.default=wk});var Yh=E(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});var Ek=Bh(),$k=[Ek.default];kc.default=$k});var Xh=E(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});Er.contentVocabulary=Er.metadataVocabulary=void 0;Er.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Er.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var eg=E(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var kk=ah(),xk=bh(),Pk=Jh(),zk=Yh(),Qh=Xh(),Tk=[kk.default,xk.default,(0,Pk.default)(),zk.default,Qh.metadataVocabulary,Qh.contentVocabulary];xc.default=Tk});var rg=E(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});ls.DiscrError=void 0;var tg;(function(t){t.Tag="tag",t.Mapping="mapping"})(tg||(ls.DiscrError=tg={}))});var og=E(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var $r=A(),Pc=rg(),ng=Go(),Rk=kn(),Ok=Z(),Ik={message:({params:{discrError:t,tagName:e}})=>t===Pc.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}}`},Ak={keyword:"discriminator",type:"object",schemaType:"object",error:Ik,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:Pc.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:Pc.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),y=!0;for(let x=0;x<i.length;x++){let k=i[x];if(k?.$ref&&!(0,Ok.schemaHasRulesButRef)(k,s.self.RULES)){let Ee=k.$ref;if(k=ng.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,Ee),k instanceof ng.SchemaEnv&&(k=k.schema),k===void 0)throw new Rk.default(s.opts.uriResolver,s.baseId,Ee)}let _e=(f=k?.properties)===null||f===void 0?void 0:f[a];if(typeof _e!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(_||b(k)),w(_e,x)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return m;function b({required:x}){return Array.isArray(x)&&x.includes(a)}function w(x,k){if(x.const)v(x.const,k);else if(x.enum)for(let _e of x.enum)v(_e,k);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(x,k){if(typeof x!="string"||x in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[x]=k}}}};zc.default=Ak});var sg=E((UM,Mk)=>{Mk.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 Rc=E((Q,Tc)=>{"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 Ck=th(),Nk=eg(),Dk=og(),ig=sg(),Lk=["/properties"],ds="http://json-schema.org/draft-07/schema",kr=class extends Ck.default{_addVocabularies(){super._addVocabularies(),Nk.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(Dk.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(ig,Lk):ig;this.addMetaSchema(e,ds,!1),this.refs["http://json-schema.org/schema"]=ds}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(ds)?ds:void 0)}};Q.Ajv=kr;Tc.exports=Q=kr;Tc.exports.Ajv=kr;Object.defineProperty(Q,"__esModule",{value:!0});Q.default=kr;var jk=$n();Object.defineProperty(Q,"KeywordCxt",{enumerable:!0,get:function(){return jk.KeywordCxt}});var xr=A();Object.defineProperty(Q,"_",{enumerable:!0,get:function(){return xr._}});Object.defineProperty(Q,"str",{enumerable:!0,get:function(){return xr.str}});Object.defineProperty(Q,"stringify",{enumerable:!0,get:function(){return xr.stringify}});Object.defineProperty(Q,"nil",{enumerable:!0,get:function(){return xr.nil}});Object.defineProperty(Q,"Name",{enumerable:!0,get:function(){return xr.Name}});Object.defineProperty(Q,"CodeGen",{enumerable:!0,get:function(){return xr.CodeGen}});var Uk=Wo();Object.defineProperty(Q,"ValidationError",{enumerable:!0,get:function(){return Uk.default}});var Zk=kn();Object.defineProperty(Q,"MissingRefError",{enumerable:!0,get:function(){return Zk.default}})});var mg=E(st=>{"use strict";Object.defineProperty(st,"__esModule",{value:!0});st.formatNames=st.fastFormats=st.fullFormats=void 0;function ot(t,e){return{validate:t,compare:e}}st.fullFormats={date:ot(lg,Mc),time:ot(Ic(!0),Cc),"date-time":ot(ag(!0),pg),"iso-time":ot(Ic(),dg),"iso-date-time":ot(ag(),fg),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:Gk,"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:ex,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:Kk,int32:{type:"number",validate:Yk},int64:{type:"number",validate:Xk},float:{type:"number",validate:ug},double:{type:"number",validate:ug},password:!0,binary:!0};st.fastFormats={...st.fullFormats,date:ot(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Mc),time:ot(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Cc),"date-time":ot(/^\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,pg),"iso-time":ot(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,dg),"iso-date-time":ot(/^\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,fg),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};st.formatNames=Object.keys(st.fullFormats);function Fk(t){return t%4===0&&(t%100!==0||t%400===0)}var qk=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,Hk=[0,31,28,31,30,31,30,31,31,30,31,30,31];function lg(t){let e=qk.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&&Fk(r)?29:Hk[n])}function Mc(t,e){if(t&&e)return t>e?1:t<e?-1:0}var Oc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Ic(t){return function(r){let n=Oc.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 Cc(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 dg(t,e){if(!(t&&e))return;let r=Oc.exec(t),n=Oc.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 Ac=/t|\s/i;function ag(t){let e=Ic(t);return function(n){let o=n.split(Ac);return o.length===2&&lg(o[0])&&e(o[1])}}function pg(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function fg(t,e){if(!(t&&e))return;let[r,n]=t.split(Ac),[o,s]=e.split(Ac),i=Mc(r,o);if(i!==void 0)return i||Cc(n,s)}var Wk=/\/|:/,Vk=/^(?:[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 Gk(t){return Wk.test(t)&&Vk.test(t)}var cg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function Kk(t){return cg.lastIndex=0,cg.test(t)}var Jk=-(2**31),Bk=2**31-1;function Yk(t){return Number.isInteger(t)&&t<=Bk&&t>=Jk}function Xk(t){return Number.isInteger(t)}function ug(){return!0}var Qk=/[^\\]\\Z/;function ex(t){if(Qk.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var hg=E(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Pr.formatLimitDefinition=void 0;var tx=Rc(),Xe=A(),Ct=Xe.operators,ps={formatMaximum:{okStr:"<=",ok:Ct.LTE,fail:Ct.GT},formatMinimum:{okStr:">=",ok:Ct.GTE,fail:Ct.LT},formatExclusiveMaximum:{okStr:"<",ok:Ct.LT,fail:Ct.GTE},formatExclusiveMinimum:{okStr:">",ok:Ct.GT,fail:Ct.LTE}},rx={message:({keyword:t,schemaCode:e})=>(0,Xe.str)`should be ${ps[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Xe._)`{comparison: ${ps[t].okStr}, limit: ${e}}`};Pr.formatLimitDefinition={keyword:Object.keys(ps),type:"string",schemaType:"string",$data:!0,error:rx,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 tx.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,Xe._)`${p}[${c.schemaCode}]`);t.fail$data((0,Xe.or)((0,Xe._)`typeof ${f} != "object"`,(0,Xe._)`${f} instanceof RegExp`,(0,Xe._)`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,Xe._)`${i.code.formats}${(0,Xe.getProperty)(p)}`:void 0});t.fail$data(d(m))}function d(p){return(0,Xe._)`${p}.compare(${r}, ${n}) ${ps[o].fail} 0`}},dependencies:["format"]};var nx=t=>(t.addKeyword(Pr.formatLimitDefinition),t);Pr.default=nx});var Sg=E((jn,yg)=>{"use strict";Object.defineProperty(jn,"__esModule",{value:!0});var zr=mg(),ox=hg(),Nc=A(),gg=new Nc.Name("fullFormats"),sx=new Nc.Name("fastFormats"),Dc=(t,e={keywords:!0})=>{if(Array.isArray(e))return _g(t,e,zr.fullFormats,gg),t;let[r,n]=e.mode==="fast"?[zr.fastFormats,sx]:[zr.fullFormats,gg],o=e.formats||zr.formatNames;return _g(t,o,r,n),e.keywords&&(0,ox.default)(t),t};Dc.get=(t,e="full")=>{let n=(e==="fast"?zr.fastFormats:zr.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function _g(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,Nc._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}yg.exports=jn=Dc;Object.defineProperty(jn,"__esModule",{value:!0});jn.default=Dc});var lt=require("fs"),fu=require("path");var j=require("path"),Os=require("os"),Nr=require("fs");var lu=require("url");var D_={};function z_(){return typeof __dirname<"u"?__dirname:(0,j.dirname)((0,lu.fileURLToPath)(D_.url))}var pP=z_();function T_(){if(process.env.CLAUDE_MEM_DATA_DIR)return process.env.CLAUDE_MEM_DATA_DIR;let t=(0,j.join)((0,Os.homedir)(),".claude-mem"),e=(0,j.join)(t,"settings.json");try{if((0,Nr.existsSync)(e)){let r=JSON.parse((0,Nr.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=T_(),Jn=process.env.CLAUDE_CONFIG_DIR||(0,j.join)((0,Os.homedir)(),".claude"),du=(0,j.join)(Jn,"plugins","marketplaces","thedotmack"),R_=(0,j.join)(ee,"archives"),O_=(0,j.join)(ee,"logs"),I_=(0,j.join)(ee,"trash"),A_=(0,j.join)(ee,"backups"),M_=(0,j.join)(ee,"modes"),C_=(0,j.join)(ee,"settings.json"),fP=(0,j.join)(ee,"claude-mem.db"),N_=(0,j.join)(ee,"vector-db"),pu=(0,j.join)(ee,"observer-sessions"),mP=(0,j.basename)(pu),hP=(0,j.join)(Jn,"settings.json"),gP=(0,j.join)(Jn,"commands"),_P=(0,j.join)(Jn,"CLAUDE.md");var De={dataDir:()=>ee,workerPid:()=>(0,j.join)(ee,"worker.pid"),serverBetaPid:()=>(0,j.join)(ee,".server-beta.pid"),serverBetaPort:()=>(0,j.join)(ee,".server-beta.port"),serverBetaRuntime:()=>(0,j.join)(ee,".server-beta.runtime.json"),settings:()=>(0,j.join)(ee,"settings.json"),database:()=>(0,j.join)(ee,"claude-mem.db"),chroma:()=>(0,j.join)(ee,"chroma"),combinedCerts:()=>(0,j.join)(ee,"combined_certs.pem"),transcriptsConfig:()=>(0,j.join)(ee,"transcript-watch.json"),transcriptsState:()=>(0,j.join)(ee,"transcript-watch-state.json"),corpora:()=>(0,j.join)(ee,"corpora"),supervisorRegistry:()=>(0,j.join)(ee,"supervisor.json"),envFile:()=>(0,j.join)(ee,".env"),logsDir:()=>O_,archives:()=>R_,trash:()=>I_,backups:()=>A_,modes:()=>M_,vectorDb:()=>N_,observerSessions:()=>pu};var Is=(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))(Is||{}),As=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,lt.existsSync)(e)||(0,lt.mkdirSync)(e,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=(0,fu.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,lt.existsSync)(e)){let r=(0,lt.readFileSync)(e,"utf-8"),o=(JSON.parse(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=Is[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=Is[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?`
9
+ deps: ${r}}`};var Kk={keyword:"dependencies",type:"object",schemaType:"object",error:st.error,code(t){let[e,r]=Gk(t);Lh(t,e),Uh(t,r)}};function Gk({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 Lh(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,Un.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,Un.checkReportMissingProp)(t,u)}):(r.if((0,_c._)`${c} && (${(0,Un.checkMissingProp)(t,a,s)})`),(0,Un.reportMissingProp)(t,s),r.else())}}st.validatePropertyDeps=Lh;function Uh(t,e=t.schema){let{gen:r,data:n,keyword:o,it:s}=t,i=r.name("valid");for(let a in e)(0,Bk.alwaysValidSchema)(s,e[a])||(r.if((0,Un.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))}st.validateSchemaDeps=Uh;st.default=Kk});var Fh=w(yc=>{"use strict";Object.defineProperty(yc,"__esModule",{value:!0});var Zh=A(),Jk=q(),Yk={message:"property name must be valid",params:({params:t})=>(0,Zh._)`{propertyName: ${t.propertyName}}`},Xk={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:Yk,code(t){let{gen:e,schema:r,data:n,it:o}=t;if((0,Jk.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,Zh.not)(s),()=>{t.error(!0),o.allErrors||e.break()})}),t.ok(s)}};yc.default=Xk});var vc=w(Sc=>{"use strict";Object.defineProperty(Sc,"__esModule",{value:!0});var ls=Ze(),Xe=A(),Qk=yt(),ds=q(),e$={message:"must NOT have additional properties",params:({params:t})=>(0,Xe._)`{additionalProperty: ${t.additionalProperty}}`},t$={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:e$,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,ds.alwaysValidSchema)(i,r))return;let u=(0,ls.allSchemaProperties)(n.properties),l=(0,ls.allSchemaProperties)(n.patternProperties);d(),t.ok((0,Xe._)`${s} === ${Qk.default.errors}`);function d(){e.forIn("key",o,y=>{!u.length&&!l.length?m(y):e.if(p(y),()=>m(y))})}function p(y){let b;if(u.length>8){let E=(0,ds.schemaRefOrVal)(i,n.properties,"properties");b=(0,ls.isOwnProperty)(e,E,y)}else u.length?b=(0,Xe.or)(...u.map(E=>(0,Xe._)`${y} === ${E}`)):b=Xe.nil;return l.length&&(b=(0,Xe.or)(b,...l.map(E=>(0,Xe._)`${(0,ls.usePattern)(t,E)}.test(${y})`))),(0,Xe.not)(b)}function f(y){e.code((0,Xe._)`delete ${o}[${y}]`)}function m(y){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){f(y);return}if(r===!1){t.setParams({additionalProperty:y}),t.error(),a||e.break();return}if(typeof r=="object"&&!(0,ds.alwaysValidSchema)(i,r)){let b=e.name("valid");c.removeAdditional==="failing"?(_(y,b,!1),e.if((0,Xe.not)(b),()=>{t.reset(),f(y)})):(_(y,b),a||e.if((0,Xe.not)(b),()=>e.break()))}}function _(y,b,E){let v={keyword:"additionalProperties",dataProp:y,dataPropType:ds.Type.Str};E===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),t.subschema(v,b)}}};Sc.default=t$});var Wh=w(Ec=>{"use strict";Object.defineProperty(Ec,"__esModule",{value:!0});var r$=xn(),Hh=Ze(),bc=q(),Vh=vc(),n$={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&&Vh.default.code(new r$.KeywordCxt(s,Vh.default,"additionalProperties"));let i=(0,Hh.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=bc.mergeEvaluated.props(e,(0,bc.toHash)(i),s.props));let a=i.filter(d=>!(0,bc.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,Hh.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)}}};Ec.default=n$});var Jh=w(wc=>{"use strict";Object.defineProperty(wc,"__esModule",{value:!0});var Bh=Ze(),ps=A(),Kh=q(),Gh=q(),o$={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,Bh.allSchemaProperties)(r),c=a.filter(_=>(0,Kh.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 ps.Name)&&(s.props=(0,Gh.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 y in u)new RegExp(_).test(y)&&(0,Kh.checkStrictMode)(s,`property ${y} matches pattern ${_} (use allowMatchingProperties)`)}function m(_){e.forIn("key",n,y=>{e.if((0,ps._)`${(0,Bh.usePattern)(t,_)}.test(${y})`,()=>{let b=c.includes(_);b||t.subschema({keyword:"patternProperties",schemaProp:_,dataProp:y,dataPropType:Gh.Type.Str},l),s.opts.unevaluated&&d!==!0?e.assign((0,ps._)`${d}[${y}]`,!0):!b&&!s.allErrors&&e.if((0,ps.not)(l),()=>e.break())})})}}};wc.default=o$});var Yh=w(kc=>{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});var s$=q(),i$={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(t){let{gen:e,schema:r,it:n}=t;if((0,s$.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"}};kc.default=i$});var Xh=w($c=>{"use strict";Object.defineProperty($c,"__esModule",{value:!0});var a$=Ze(),c$={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:a$.validateUnion,error:{message:"must match a schema in anyOf"}};$c.default=c$});var Qh=w(xc=>{"use strict";Object.defineProperty(xc,"__esModule",{value:!0});var fs=A(),u$=q(),l$={message:"must match exactly one schema in oneOf",params:({params:t})=>(0,fs._)`{passingSchemas: ${t.passing}}`},d$={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:l$,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,u$.alwaysValidSchema)(o,l)?e.var(c,!0):p=t.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&e.if((0,fs._)`${c} && ${i}`).assign(i,!1).assign(a,(0,fs._)`[${a}, ${d}]`).else(),e.if(c,()=>{e.assign(i,!0),e.assign(a,d),p&&t.mergeEvaluated(p,fs.Name)})})}}};xc.default=d$});var eg=w(Pc=>{"use strict";Object.defineProperty(Pc,"__esModule",{value:!0});var p$=q(),f$={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,p$.alwaysValidSchema)(n,s))return;let a=t.subschema({keyword:"allOf",schemaProp:i},o);t.ok(o),t.mergeEvaluated(a)})}};Pc.default=f$});var ng=w(Tc=>{"use strict";Object.defineProperty(Tc,"__esModule",{value:!0});var ms=A(),rg=q(),m$={message:({params:t})=>(0,ms.str)`must match "${t.ifClause}" schema`,params:({params:t})=>(0,ms._)`{failingKeyword: ${t.ifClause}}`},h$={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:m$,code(t){let{gen:e,parentSchema:r,it:n}=t;r.then===void 0&&r.else===void 0&&(0,rg.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=tg(n,"then"),s=tg(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,ms.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,ms._)`${l}`):t.setParams({ifClause:l})}}}};function tg(t,e){let r=t.schema[e];return r!==void 0&&!(0,rg.alwaysValidSchema)(t,r)}Tc.default=h$});var og=w(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});var g$=q(),_$={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:t,parentSchema:e,it:r}){e.if===void 0&&(0,g$.checkStrictMode)(r,`"${t}" without "if" is ignored`)}};zc.default=_$});var sg=w(Rc=>{"use strict";Object.defineProperty(Rc,"__esModule",{value:!0});var y$=pc(),S$=Ch(),v$=fc(),b$=Dh(),E$=jh(),w$=qh(),k$=Fh(),$$=vc(),x$=Wh(),P$=Jh(),T$=Yh(),z$=Xh(),R$=Qh(),I$=eg(),O$=ng(),A$=og();function M$(t=!1){let e=[T$.default,z$.default,R$.default,I$.default,O$.default,A$.default,k$.default,$$.default,w$.default,x$.default,P$.default];return t?e.push(S$.default,b$.default):e.push(y$.default,v$.default),e.push(E$.default),e}Rc.default=M$});var ig=w(Ic=>{"use strict";Object.defineProperty(Ic,"__esModule",{value:!0});var ie=A(),C$={message:({schemaCode:t})=>(0,ie.str)`must match format "${t}"`,params:({schemaCode:t})=>(0,ie._)`{format: ${t}}`},N$={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:C$,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}]`),y=r.let("fType"),b=r.let("format");r.if((0,ie._)`typeof ${_} == "object" && !(${_} instanceof RegExp)`,()=>r.assign(y,(0,ie._)`${_}.type || "string"`).assign(b,(0,ie._)`${_}.validate`),()=>r.assign(y,(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 x=l.$async?(0,ie._)`(${_}.async ? await ${b}(${n}) : ${b}(${n}))`:(0,ie._)`${b}(${n})`,$=(0,ie._)`(typeof ${b} == "function" ? ${x} : ${b}.test(${n}))`;return(0,ie._)`${b} && ${b} !== true && ${y} === ${e} && !${$}`}}function f(){let m=d.formats[s];if(!m){E();return}if(m===!0)return;let[_,y,b]=v(m);_===e&&t.pass(x());function E(){if(c.strictSchema===!1){d.logger.warn($());return}throw new Error($());function $(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function v($){let ye=$ instanceof RegExp?(0,ie.regexpCode)($):c.code.formats?(0,ie._)`${c.code.formats}${(0,ie.getProperty)(s)}`:void 0,we=r.scopeValue("formats",{key:s,ref:$,code:ye});return typeof $=="object"&&!($ instanceof RegExp)?[$.type||"string",$.validate,(0,ie._)`${we}.validate`]:["string",$,we]}function x(){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 y=="function"?(0,ie._)`${b}(${n})`:(0,ie._)`${b}.test(${n})`}}}};Ic.default=N$});var ag=w(Oc=>{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});var D$=ig(),j$=[D$.default];Oc.default=j$});var cg=w(kr=>{"use strict";Object.defineProperty(kr,"__esModule",{value:!0});kr.contentVocabulary=kr.metadataVocabulary=void 0;kr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];kr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var lg=w(Ac=>{"use strict";Object.defineProperty(Ac,"__esModule",{value:!0});var L$=_h(),U$=Ih(),q$=sg(),Z$=ag(),ug=cg(),F$=[L$.default,U$.default,(0,q$.default)(),Z$.default,ug.metadataVocabulary,ug.contentVocabulary];Ac.default=F$});var pg=w(hs=>{"use strict";Object.defineProperty(hs,"__esModule",{value:!0});hs.DiscrError=void 0;var dg;(function(t){t.Tag="tag",t.Mapping="mapping"})(dg||(hs.DiscrError=dg={}))});var mg=w(Cc=>{"use strict";Object.defineProperty(Cc,"__esModule",{value:!0});var $r=A(),Mc=pg(),fg=Xo(),H$=Pn(),V$=q(),W$={message:({params:{discrError:t,tagName:e}})=>t===Mc.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}}`},B$={keyword:"discriminator",type:"object",schemaType:"object",error:W$,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:Mc.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:Mc.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),y=!0;for(let x=0;x<i.length;x++){let $=i[x];if($?.$ref&&!(0,V$.schemaHasRulesButRef)($,s.self.RULES)){let we=$.$ref;if($=fg.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,we),$ instanceof fg.SchemaEnv&&($=$.schema),$===void 0)throw new H$.default(s.opts.uriResolver,s.baseId,we)}let ye=(f=$?.properties)===null||f===void 0?void 0:f[a];if(typeof ye!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);y=y&&(_||b($)),E(ye,x)}if(!y)throw new Error(`discriminator: "${a}" must be required`);return m;function b({required:x}){return Array.isArray(x)&&x.includes(a)}function E(x,$){if(x.const)v(x.const,$);else if(x.enum)for(let ye of x.enum)v(ye,$);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(x,$){if(typeof x!="string"||x in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[x]=$}}}};Cc.default=B$});var hg=w((sC,K$)=>{K$.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 Dc=w((Q,Nc)=>{"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 G$=dh(),J$=lg(),Y$=mg(),gg=hg(),X$=["/properties"],gs="http://json-schema.org/draft-07/schema",xr=class extends G$.default{_addVocabularies(){super._addVocabularies(),J$.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(Y$.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(gg,X$):gg;this.addMetaSchema(e,gs,!1),this.refs["http://json-schema.org/schema"]=gs}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(gs)?gs:void 0)}};Q.Ajv=xr;Nc.exports=Q=xr;Nc.exports.Ajv=xr;Object.defineProperty(Q,"__esModule",{value:!0});Q.default=xr;var Q$=xn();Object.defineProperty(Q,"KeywordCxt",{enumerable:!0,get:function(){return Q$.KeywordCxt}});var Pr=A();Object.defineProperty(Q,"_",{enumerable:!0,get:function(){return Pr._}});Object.defineProperty(Q,"str",{enumerable:!0,get:function(){return Pr.str}});Object.defineProperty(Q,"stringify",{enumerable:!0,get:function(){return Pr.stringify}});Object.defineProperty(Q,"nil",{enumerable:!0,get:function(){return Pr.nil}});Object.defineProperty(Q,"Name",{enumerable:!0,get:function(){return Pr.Name}});Object.defineProperty(Q,"CodeGen",{enumerable:!0,get:function(){return Pr.CodeGen}});var ex=Jo();Object.defineProperty(Q,"ValidationError",{enumerable:!0,get:function(){return ex.default}});var tx=Pn();Object.defineProperty(Q,"MissingRefError",{enumerable:!0,get:function(){return tx.default}})});var kg=w(at=>{"use strict";Object.defineProperty(at,"__esModule",{value:!0});at.formatNames=at.fastFormats=at.fullFormats=void 0;function it(t,e){return{validate:t,compare:e}}at.fullFormats={date:it(vg,qc),time:it(Lc(!0),Zc),"date-time":it(_g(!0),Eg),"iso-time":it(Lc(),bg),"iso-date-time":it(_g(),wg),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:ax,"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:mx,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:cx,int32:{type:"number",validate:dx},int64:{type:"number",validate:px},float:{type:"number",validate:Sg},double:{type:"number",validate:Sg},password:!0,binary:!0};at.fastFormats={...at.fullFormats,date:it(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,qc),time:it(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Zc),"date-time":it(/^\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,Eg),"iso-time":it(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,bg),"iso-date-time":it(/^\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,wg),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};at.formatNames=Object.keys(at.fullFormats);function rx(t){return t%4===0&&(t%100!==0||t%400===0)}var nx=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,ox=[0,31,28,31,30,31,30,31,31,30,31,30,31];function vg(t){let e=nx.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&&rx(r)?29:ox[n])}function qc(t,e){if(t&&e)return t>e?1:t<e?-1:0}var jc=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Lc(t){return function(r){let n=jc.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 Zc(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 bg(t,e){if(!(t&&e))return;let r=jc.exec(t),n=jc.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 Uc=/t|\s/i;function _g(t){let e=Lc(t);return function(n){let o=n.split(Uc);return o.length===2&&vg(o[0])&&e(o[1])}}function Eg(t,e){if(!(t&&e))return;let r=new Date(t).valueOf(),n=new Date(e).valueOf();if(r&&n)return r-n}function wg(t,e){if(!(t&&e))return;let[r,n]=t.split(Uc),[o,s]=e.split(Uc),i=qc(r,o);if(i!==void 0)return i||Zc(n,s)}var sx=/\/|:/,ix=/^(?:[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 ax(t){return sx.test(t)&&ix.test(t)}var yg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function cx(t){return yg.lastIndex=0,yg.test(t)}var ux=-(2**31),lx=2**31-1;function dx(t){return Number.isInteger(t)&&t<=lx&&t>=ux}function px(t){return Number.isInteger(t)}function Sg(){return!0}var fx=/[^\\]\\Z/;function mx(t){if(fx.test(t))return!1;try{return new RegExp(t),!0}catch{return!1}}});var $g=w(Tr=>{"use strict";Object.defineProperty(Tr,"__esModule",{value:!0});Tr.formatLimitDefinition=void 0;var hx=Dc(),Qe=A(),Nt=Qe.operators,_s={formatMaximum:{okStr:"<=",ok:Nt.LTE,fail:Nt.GT},formatMinimum:{okStr:">=",ok:Nt.GTE,fail:Nt.LT},formatExclusiveMaximum:{okStr:"<",ok:Nt.LT,fail:Nt.GTE},formatExclusiveMinimum:{okStr:">",ok:Nt.GT,fail:Nt.LTE}},gx={message:({keyword:t,schemaCode:e})=>(0,Qe.str)`should be ${_s[t].okStr} ${e}`,params:({keyword:t,schemaCode:e})=>(0,Qe._)`{comparison: ${_s[t].okStr}, limit: ${e}}`};Tr.formatLimitDefinition={keyword:Object.keys(_s),type:"string",schemaType:"string",$data:!0,error:gx,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 hx.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,Qe._)`${p}[${c.schemaCode}]`);t.fail$data((0,Qe.or)((0,Qe._)`typeof ${f} != "object"`,(0,Qe._)`${f} instanceof RegExp`,(0,Qe._)`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,Qe._)`${i.code.formats}${(0,Qe.getProperty)(p)}`:void 0});t.fail$data(d(m))}function d(p){return(0,Qe._)`${p}.compare(${r}, ${n}) ${_s[o].fail} 0`}},dependencies:["format"]};var _x=t=>(t.addKeyword(Tr.formatLimitDefinition),t);Tr.default=_x});var zg=w((qn,Tg)=>{"use strict";Object.defineProperty(qn,"__esModule",{value:!0});var zr=kg(),yx=$g(),Fc=A(),xg=new Fc.Name("fullFormats"),Sx=new Fc.Name("fastFormats"),Hc=(t,e={keywords:!0})=>{if(Array.isArray(e))return Pg(t,e,zr.fullFormats,xg),t;let[r,n]=e.mode==="fast"?[zr.fastFormats,Sx]:[zr.fullFormats,xg],o=e.formats||zr.formatNames;return Pg(t,o,r,n),e.keywords&&(0,yx.default)(t),t};Hc.get=(t,e="full")=>{let n=(e==="fast"?zr.fastFormats:zr.fullFormats)[t];if(!n)throw new Error(`Unknown format "${t}"`);return n};function Pg(t,e,r,n){var o,s;(o=(s=t.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,Fc._)`require("ajv-formats/dist/formats").${n}`);for(let i of e)t.addFormat(i,r[i])}Tg.exports=qn=Hc;Object.defineProperty(qn,"__esModule",{value:!0});qn.default=Hc});var dt=require("fs"),wu=require("path");var L=require("path"),js=require("os"),jr=require("fs");var Su=require("url");var Y_={};function F_(){return typeof __dirname<"u"?__dirname:(0,L.dirname)((0,Su.fileURLToPath)(Y_.url))}var IP=F_();function H_(){if(process.env.CLAUDE_MEM_DATA_DIR)return process.env.CLAUDE_MEM_DATA_DIR;let t=(0,L.join)((0,js.homedir)(),".claude-mem"),e=(0,L.join)(t,"settings.json");try{if((0,jr.existsSync)(e)){let r=JSON.parse((0,jr.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=H_(),eo=process.env.CLAUDE_CONFIG_DIR||(0,L.join)((0,js.homedir)(),".claude"),vu=(0,L.join)(eo,"plugins","marketplaces","thedotmack"),V_=(0,L.join)(ee,"archives"),W_=(0,L.join)(ee,"logs"),B_=(0,L.join)(ee,"trash"),K_=(0,L.join)(ee,"backups"),G_=(0,L.join)(ee,"modes"),bu=(0,L.join)(ee,"settings.json"),OP=(0,L.join)(ee,"claude-mem.db"),J_=(0,L.join)(ee,"vector-db"),Eu=(0,L.join)(ee,"observer-sessions"),AP=(0,L.basename)(Eu),MP=(0,L.join)(eo,"settings.json"),CP=(0,L.join)(eo,"commands"),NP=(0,L.join)(eo,"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:()=>W_,archives:()=>V_,trash:()=>B_,backups:()=>K_,modes:()=>G_,vectorDb:()=>J_,observerSessions:()=>Eu};var Ls=(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))(Ls||{}),Us=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,wu.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=Ls[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=Ls[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:_,...y}=o;Object.keys(y).length>0&&(d=` {${Object.entries(y).map(([w,v])=>`${w}=${v}`).join(", ")}}`)}let p=`[${i}] [${a}] [${c}] ${u}${n}${d}${l}`;if(this.logFilePath)try{(0,lt.appendFileSync)(this.logFilePath,p+`
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:_,...y}=o;Object.keys(y).length>0&&(d=` {${Object.entries(y).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
14
  `,"utf8")}catch(f){process.stderr.write(`[LOGGER] Failed to write to log file: ${f instanceof Error?f.message:String(f)}
15
15
  `)}else process.stderr.write(p+`
16
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)}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)}timing(e,r,n,o){this.info(e,`\u23F1 ${r}`,o,{duration:`${n}ms`})}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}},S=new As;var mu;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 et=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},er=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(mu=globalThis).__zod_globalConfig??(mu.__zod_globalConfig={});var tr=globalThis.__zod_globalConfig;function Ae(t){return t&&Object.assign(tr,t),tr}var U={};uu(U,{BIGINT_FORMAT_RANGES:()=>yu,Class:()=>Cs,NUMBER_FORMAT_RANGES:()=>Zs,aborted:()=>Et,allowsEval:()=>Ls,assert:()=>F_,assertEqual:()=>L_,assertIs:()=>U_,assertNever:()=>Z_,assertNotEqual:()=>j_,assignProp:()=>bt,base64ToUint8Array:()=>vu,base64urlToUint8Array:()=>sy,cached:()=>nr,captureStackTrace:()=>Xn,cleanEnum:()=>oy,cleanRegex:()=>Ur,clone:()=>Ge,cloneDef:()=>H_,createTransparentProxy:()=>B_,defineLazy:()=>H,esc:()=>Yn,escapeRegex:()=>pt,explicitlyAborted:()=>Fs,extend:()=>Q_,finalizeIssue:()=>Le,floatSafeRemainder:()=>Ns,getElementAtPath:()=>W_,getEnumValues:()=>Lr,getLengthableOrigin:()=>Zr,getParsedType:()=>J_,getSizableOrigin:()=>Su,hexToUint8Array:()=>ay,isObject:()=>Lt,isPlainObject:()=>wt,issue:()=>or,joinValues:()=>Bn,jsonStringifyReplacer:()=>rr,merge:()=>ty,mergeDefs:()=>dt,normalizeParams:()=>T,nullish:()=>jr,numKeys:()=>K_,objectClone:()=>q_,omit:()=>X_,optionalKeys:()=>Us,parsedType:()=>qs,partial:()=>ry,pick:()=>Y_,prefixIssues:()=>ft,primitiveTypes:()=>_u,promiseAllObject:()=>V_,propertyKeyTypes:()=>js,randomString:()=>G_,required:()=>ny,safeExtend:()=>ey,shallowClone:()=>gu,slugify:()=>Ds,stringifyPrimitive:()=>Qn,uint8ArrayToBase64:()=>bu,uint8ArrayToBase64url:()=>iy,uint8ArrayToHex:()=>cy,unwrapMessage:()=>Dr});function L_(t){return t}function j_(t){return t}function U_(t){}function Z_(t){throw new Error("Unexpected value in exhaustive check")}function F_(t){}function Lr(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 Bn(t,e="|"){return t.map(r=>Qn(r)).join(e)}function rr(t,e){return typeof e=="bigint"?e.toString():e}function nr(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function jr(t){return t==null}function Ur(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Ns(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 hu=Symbol("evaluating");function H(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==hu)return n===void 0&&(n=hu,n=r()),n},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function q_(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function bt(t,e,r){Object.defineProperty(t,e,{value:r,writable:!0,enumerable:!0,configurable:!0})}function dt(...t){let e={};for(let r of t){let n=Object.getOwnPropertyDescriptors(r);Object.assign(e,n)}return Object.defineProperties({},e)}function H_(t){return dt(t._zod.def)}function W_(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function V_(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 G_(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function Yn(t){return JSON.stringify(t)}function Ds(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Xn="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Lt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Ls=nr(()=>{if(tr.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function wt(t){if(Lt(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Lt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function gu(t){return wt(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function K_(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var J_=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}`)}},js=new Set(["string","number","symbol"]),_u=new Set(["string","number","bigint","boolean","symbol","undefined"]);function pt(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 T(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 B_(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 Qn(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function Us(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var Zs={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]},yu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Y_(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=dt(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 bt(this,"shape",i),i},checks:[]});return Ge(t,s)}function X_(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=dt(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 bt(this,"shape",i),i},checks:[]});return Ge(t,s)}function Q_(t,e){if(!wt(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=dt(t._zod.def,{get shape(){let s={...t._zod.def.shape,...e};return bt(this,"shape",s),s}});return Ge(t,o)}function ey(t,e){if(!wt(e))throw new Error("Invalid input to safeExtend: expected a plain object");let r=dt(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e};return bt(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=dt(t._zod.def,{get shape(){let n={...t._zod.def.shape,...e._zod.def.shape};return bt(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Ge(t,r)}function ry(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=dt(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 bt(this,"shape",c),c},checks:[]});return Ge(e,i)}function ny(t,e,r){let n=dt(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 bt(this,"shape",s),s}});return Ge(e,n)}function Et(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 Fs(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 ft(t,e){return e.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(t),r})}function Dr(t){return typeof t=="string"?t:t?.message}function Le(t,e,r){let n=t.message?t.message:Dr(t.inst?._zod.def?.error?.(t))??Dr(e?.error?.(t))??Dr(r.customError?.(t))??Dr(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 Su(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Zr(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function qs(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 or(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function oy(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 sy(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return vu(e+r)}function iy(t){return bu(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 cy(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var Cs=class{constructor(...e){}};var wu=(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,rr,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},eo=g("$ZodError",wu),Hs=g("$ZodError",wu,{Parent:Error});function Eu(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 $u(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 to=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 et;if(i.issues.length){let a=new(o?.Err??t)(i.issues.map(c=>Le(c,s,Ae())));throw Xn(a,o?.callee),a}return i.value};var ro=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=>Le(c,s,Ae())));throw Xn(a,o?.callee),a}return i.value};var Fr=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 et;return s.issues.length?{success:!1,error:new(t??eo)(s.issues.map(i=>Le(i,o,Ae())))}:{success:!0,data:s.value}},qr=Fr(Hs),Hr=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=>Le(i,o,Ae())))}:{success:!0,data:s.value}},no=Hr(Hs),ku=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return to(t)(e,r,o)};var xu=t=>(e,r,n)=>to(t)(e,r,n);var Pu=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return ro(t)(e,r,o)};var zu=t=>async(e,r,n)=>ro(t)(e,r,n);var Tu=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Fr(t)(e,r,o)};var Ru=t=>(e,r,n)=>Fr(t)(e,r,n);var Ou=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Hr(t)(e,r,o)};var Iu=t=>async(e,r,n)=>Hr(t)(e,r,n);var Au=/^[cC][0-9a-z]{6,}$/,Mu=/^[0-9a-z]+$/,Cu=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Nu=/^[0-9a-vA-V]{20}$/,Du=/^[A-Za-z0-9]{27}$/,Lu=/^[a-zA-Z0-9_-]{21}$/,ju=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Uu=/^([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})$/,Ws=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 Zu=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var ly="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Fu(){return new RegExp(ly,"u")}var qu=/^(?:(?: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])$/,Hu=/^(([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 Wu=/^((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])$/,Vu=/^(([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])$/,Gu=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Vs=/^[A-Za-z0-9_-]*$/;var Ku=/^https?$/,Ju=/^\+[1-9]\d{6,14}$/,Bu="(?:(?:\\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])))",Yu=new RegExp(`^${Bu}$`);function Xu(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 Qu(t){return new RegExp(`^${Xu(t)}$`)}function el(t){let e=Xu({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(`^${Bu}T(?:${n})$`)}var tl=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var rl=/^-?\d+$/,Gs=/^-?\d+(?:\.\d+)?$/,nl=/^(?:true|false)$/i,ol=/^null$/i;var sl=/^[^A-Z]*$/,il=/^[^a-z]*$/;var le=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"},Ks=g("$ZodCheckLessThan",(t,e)=>{le.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})}}),Js=g("$ZodCheckGreaterThan",(t,e)=>{le.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})}}),cl=g("$ZodCheckMultipleOf",(t,e)=>{le.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):Ns(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})}}),ul=g("$ZodCheckNumberFormat",(t,e)=>{le.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=Zs[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=rl)}),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 ll=g("$ZodCheckMaxLength",(t,e)=>{var r;le.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!jr(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=Zr(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;le.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!jr(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=Zr(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),pl=g("$ZodCheckLengthEquals",(t,e)=>{var r;le.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!jr(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=Zr(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})}}),Wr=g("$ZodCheckStringFormat",(t,e)=>{var r,n;le.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=()=>{})}),fl=g("$ZodCheckRegex",(t,e)=>{Wr.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})}}),ml=g("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=sl),Wr.init(t,e)}),hl=g("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=il),Wr.init(t,e)}),gl=g("$ZodCheckIncludes",(t,e)=>{le.init(t,e);let r=pt(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})}}),_l=g("$ZodCheckStartsWith",(t,e)=>{le.init(t,e);let r=new RegExp(`^${pt(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})}}),yl=g("$ZodCheckEndsWith",(t,e)=>{le.init(t,e);let r=new RegExp(`.*${pt(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 Sl=g("$ZodCheckOverwrite",(t,e)=>{le.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var so=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(`
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}},S=new Us;var ku;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.")}},tr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}};(ku=globalThis).__zod_globalConfig??(ku.__zod_globalConfig={});var rr=globalThis.__zod_globalConfig;function Ae(t){return t&&Object.assign(rr,t),rr}var U={};yu(U,{BIGINT_FORMAT_RANGES:()=>Tu,Class:()=>Zs,NUMBER_FORMAT_RANGES:()=>Ks,aborted:()=>kt,allowsEval:()=>Vs,assert:()=>ry,assertEqual:()=>X_,assertIs:()=>ey,assertNever:()=>ty,assertNotEqual:()=>Q_,assignProp:()=>Et,base64ToUint8Array:()=>Ru,base64urlToUint8Array:()=>Sy,cached:()=>or,captureStackTrace:()=>no,cleanEnum:()=>yy,cleanRegex:()=>Zr,clone:()=>Ke,cloneDef:()=>oy,createTransparentProxy:()=>ly,defineLazy:()=>H,esc:()=>ro,escapeRegex:()=>ft,explicitlyAborted:()=>Gs,extend:()=>fy,finalizeIssue:()=>je,floatSafeRemainder:()=>Fs,getElementAtPath:()=>sy,getEnumValues:()=>Ur,getLengthableOrigin:()=>Fr,getParsedType:()=>uy,getSizableOrigin:()=>zu,hexToUint8Array:()=>by,isObject:()=>Lt,isPlainObject:()=>wt,issue:()=>sr,joinValues:()=>to,jsonStringifyReplacer:()=>nr,merge:()=>hy,mergeDefs:()=>pt,normalizeParams:()=>z,nullish:()=>qr,numKeys:()=>cy,objectClone:()=>ny,omit:()=>py,optionalKeys:()=>Bs,parsedType:()=>Js,partial:()=>gy,pick:()=>dy,prefixIssues:()=>mt,primitiveTypes:()=>Pu,promiseAllObject:()=>iy,propertyKeyTypes:()=>Ws,randomString:()=>ay,required:()=>_y,safeExtend:()=>my,shallowClone:()=>xu,slugify:()=>Hs,stringifyPrimitive:()=>oo,uint8ArrayToBase64:()=>Iu,uint8ArrayToBase64url:()=>vy,uint8ArrayToHex:()=>Ey,unwrapMessage:()=>Lr});function X_(t){return t}function Q_(t){return t}function ey(t){}function ty(t){throw new Error("Unexpected value in exhaustive check")}function ry(t){}function Ur(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 to(t,e="|"){return t.map(r=>oo(r)).join(e)}function nr(t,e){return typeof e=="bigint"?e.toString():e}function or(t){return{get value(){{let r=t();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}function qr(t){return t==null}function Zr(t){let e=t.startsWith("^")?1:0,r=t.endsWith("$")?t.length-1:t.length;return t.slice(e,r)}function Fs(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 $u=Symbol("evaluating");function H(t,e,r){let n;Object.defineProperty(t,e,{get(){if(n!==$u)return n===void 0&&(n=$u,n=r()),n},set(o){Object.defineProperty(t,e,{value:o})},configurable:!0})}function ny(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function Et(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 oy(t){return pt(t._zod.def)}function sy(t,e){return e?e.reduce((r,n)=>r?.[n],t):t}function iy(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 ay(t=10){let e="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<t;n++)r+=e[Math.floor(Math.random()*e.length)];return r}function ro(t){return JSON.stringify(t)}function Hs(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var no="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};function Lt(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}var Vs=or(()=>{if(rr.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let t=Function;return new t(""),!0}catch{return!1}});function wt(t){if(Lt(t)===!1)return!1;let e=t.constructor;if(e===void 0||typeof e!="function")return!0;let r=e.prototype;return!(Lt(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function xu(t){return wt(t)?{...t}:Array.isArray(t)?[...t]:t instanceof Map?new Map(t):t instanceof Set?new Set(t):t}function cy(t){let e=0;for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&e++;return e}var uy=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}`)}},Ws=new Set(["string","number","symbol"]),Pu=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ft(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ke(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 ly(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 oo(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function Bs(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}var Ks={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]},Tu={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function dy(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 Et(this,"shape",i),i},checks:[]});return Ke(t,s)}function py(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 Et(this,"shape",i),i},checks:[]});return Ke(t,s)}function fy(t,e){if(!wt(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 Et(this,"shape",s),s}});return Ke(t,o)}function my(t,e){if(!wt(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 Et(this,"shape",n),n}});return Ke(t,r)}function hy(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 Et(this,"shape",n),n},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return Ke(t,r)}function gy(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 Et(this,"shape",c),c},checks:[]});return Ke(e,i)}function _y(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 Et(this,"shape",s),s}});return Ke(e,n)}function kt(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 Gs(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 Lr(t){return typeof t=="string"?t:t?.message}function je(t,e,r){let n=t.message?t.message:Lr(t.inst?._zod.def?.error?.(t))??Lr(e?.error?.(t))??Lr(r.customError?.(t))??Lr(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 zu(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Fr(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function Js(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 sr(...t){let[e,r,n]=t;return typeof e=="string"?{message:e,code:"custom",input:r,inst:n}:{...e}}function yy(t){return Object.entries(t).filter(([e,r])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function Ru(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 Iu(t){let e="";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return btoa(e)}function Sy(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-e.length%4)%4);return Ru(e+r)}function vy(t){return Iu(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function by(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 Ey(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var Zs=class{constructor(...e){}};var Ou=(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,nr,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},so=g("$ZodError",Ou),Ys=g("$ZodError",Ou,{Parent:Error});function Au(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 Mu(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 io=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 no(a,o?.callee),a}return i.value};var ao=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 no(a,o?.callee),a}return i.value};var Hr=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??so)(s.issues.map(i=>je(i,o,Ae())))}:{success:!0,data:s.value}},Vr=Hr(Ys),Wr=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}},co=Wr(Ys),Cu=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return io(t)(e,r,o)};var Nu=t=>(e,r,n)=>io(t)(e,r,n);var Du=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return ao(t)(e,r,o)};var ju=t=>async(e,r,n)=>ao(t)(e,r,n);var Lu=t=>(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Hr(t)(e,r,o)};var Uu=t=>(e,r,n)=>Hr(t)(e,r,n);var qu=t=>async(e,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Wr(t)(e,r,o)};var Zu=t=>async(e,r,n)=>Wr(t)(e,r,n);var Fu=/^[cC][0-9a-z]{6,}$/,Hu=/^[0-9a-z]+$/,Vu=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Wu=/^[0-9a-vA-V]{20}$/,Bu=/^[A-Za-z0-9]{27}$/,Ku=/^[a-zA-Z0-9_-]{21}$/,Gu=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var Ju=/^([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})$/,Xs=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 Yu=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var ky="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Xu(){return new RegExp(ky,"u")}var Qu=/^(?:(?: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])$/,el=/^(([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 tl=/^((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])$/,rl=/^(([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])$/,nl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Qs=/^[A-Za-z0-9_-]*$/;var ol=/^https?$/,sl=/^\+[1-9]\d{6,14}$/,il="(?:(?:\\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])))",al=new RegExp(`^${il}$`);function cl(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 ul(t){return new RegExp(`^${cl(t)}$`)}function ll(t){let e=cl({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(`^${il}T(?:${n})$`)}var dl=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)};var pl=/^-?\d+$/,ei=/^-?\d+(?:\.\d+)?$/,fl=/^(?:true|false)$/i,ml=/^null$/i;var hl=/^[^A-Z]*$/,gl=/^[^a-z]*$/;var de=g("$ZodCheck",(t,e)=>{var r;t._zod??(t._zod={}),t._zod.def=e,(r=t._zod).onattach??(r.onattach=[])}),_l={number:"number",bigint:"bigint",object:"date"},ti=g("$ZodCheckLessThan",(t,e)=>{de.init(t,e);let r=_l[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})}}),ri=g("$ZodCheckGreaterThan",(t,e)=>{de.init(t,e);let r=_l[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})}}),yl=g("$ZodCheckMultipleOf",(t,e)=>{de.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):Fs(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})}}),Sl=g("$ZodCheckNumberFormat",(t,e)=>{de.init(t,e),e.format=e.format||"float64";let r=e.format?.includes("int"),n=r?"int":"number",[o,s]=Ks[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=pl)}),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 vl=g("$ZodCheckMaxLength",(t,e)=>{var r;de.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!qr(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=Fr(o);n.issues.push({origin:i,code:"too_big",maximum:e.maximum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),bl=g("$ZodCheckMinLength",(t,e)=>{var r;de.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!qr(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=Fr(o);n.issues.push({origin:i,code:"too_small",minimum:e.minimum,inclusive:!0,input:o,inst:t,continue:!e.abort})}}),El=g("$ZodCheckLengthEquals",(t,e)=>{var r;de.init(t,e),(r=t._zod.def).when??(r.when=n=>{let o=n.value;return!qr(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=Fr(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})}}),Br=g("$ZodCheckStringFormat",(t,e)=>{var r,n;de.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=()=>{})}),wl=g("$ZodCheckRegex",(t,e)=>{Br.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})}}),kl=g("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=hl),Br.init(t,e)}),$l=g("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=gl),Br.init(t,e)}),xl=g("$ZodCheckIncludes",(t,e)=>{de.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})}}),Pl=g("$ZodCheckStartsWith",(t,e)=>{de.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})}}),Tl=g("$ZodCheckEndsWith",(t,e)=>{de.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 zl=g("$ZodCheckOverwrite",(t,e)=>{de.init(t,e),t._zod.check=r=>{r.value=e.tx(r.value)}});var lo=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 bl={major:4,minor:4,patch:3};var J=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=Et(i),l;for(let d of a){if(d._zod.def.when){if(Fs(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 et;if(l||f instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await f,i.issues.length!==p&&(u||(u=Et(i,p)))});else{if(i.issues.length===p)continue;u||(u=Et(i,p))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if(Et(i))return i.aborted=!0,i;let u=o(a,n,c);if(u instanceof Promise){if(c.async===!1)throw new et;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 et;return c.then(u=>o(u,n,a))}return o(c,n,a)}}H(t,"~standard",()=>({validate:o=>{try{let s=qr(t,o);return s.success?{value:s.data}:{issues:s.error?.issues}}catch{return no(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),co=g("$ZodString",(t,e)=>{J.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??tl(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}}),B=g("$ZodStringFormat",(t,e)=>{Wr.init(t,e),co.init(t,e)}),Rl=g("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Uu),B.init(t,e)}),Ol=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=Ws(n))}else e.pattern??(e.pattern=Ws());B.init(t,e)}),Il=g("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Zu),B.init(t,e)}),Al=g("$ZodURL",(t,e)=>{B.init(t,e),t._zod.check=r=>{try{let n=r.value.trim();if(!e.normalize&&e.protocol?.source===Ku.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})}}}),Ml=g("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Fu()),B.init(t,e)}),Cl=g("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Lu),B.init(t,e)}),Nl=g("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Au),B.init(t,e)}),Dl=g("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Mu),B.init(t,e)}),Ll=g("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Cu),B.init(t,e)}),jl=g("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Nu),B.init(t,e)}),Ul=g("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Du),B.init(t,e)}),Zl=g("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=el(e)),B.init(t,e)}),Fl=g("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Yu),B.init(t,e)}),ql=g("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Qu(e)),B.init(t,e)}),Hl=g("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=ju),B.init(t,e)}),Wl=g("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=qu),B.init(t,e),t._zod.bag.format="ipv4"}),Vl=g("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=Hu),B.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 Gl=g("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Wu),B.init(t,e)}),Kl=g("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Vu),B.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 Jl(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var Bl=g("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Gu),B.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=r=>{Jl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function fy(t){if(!Vs.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return Jl(r)}var Yl=g("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Vs),B.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=r=>{fy(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),Xl=g("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Ju),B.init(t,e)});function my(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 Ql=g("$ZodJWT",(t,e)=>{B.init(t,e),t._zod.check=r=>{my(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var Ys=g("$ZodNumber",(t,e)=>{J.init(t,e),t._zod.pattern=t._zod.bag.pattern??Gs,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}}),ed=g("$ZodNumberFormat",(t,e)=>{ul.init(t,e),Ys.init(t,e)}),td=g("$ZodBoolean",(t,e)=>{J.init(t,e),t._zod.pattern=nl,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 rd=g("$ZodNull",(t,e)=>{J.init(t,e),t._zod.pattern=ol,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 nd=g("$ZodUnknown",(t,e)=>{J.init(t,e),t._zod.parse=r=>r}),od=g("$ZodNever",(t,e)=>{J.init(t,e),t._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:t}),r)});function wl(t,e,r){t.issues.length&&e.issues.push(...ft(r,t.issues)),e.value[r]=t.value}var sd=g("$ZodArray",(t,e)=>{J.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=>wl(u,r,i))):wl(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function ao(t,e,r,n,o,s){let i=r in n;if(t.issues.length){if(o&&s&&!i)return;e.issues.push(...ft(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 id(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=Us(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=>ao(m,r,p,e,l,d))):ao(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 hy=g("$ZodObject",(t,e)=>{if(J.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=nr(()=>id(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=Lt,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",y=f._zod.run({value:u[p],issues:[]},c);y instanceof Promise?l.push(y.then(b=>ao(b,a,p,u,m,_))):ao(y,a,p,u,m,_)}return s?ad(l,u,a,c,n.value,t):l.length?Promise.all(l).then(()=>a):a}}),cd=g("$ZodObjectJIT",(t,e)=>{hy.init(t,e);let r=t._zod.parse,n=nr(()=>id(e)),o=p=>{let f=new so(["shape","payload","ctx"]),m=n.value,_=v=>{let x=Yn(v);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};f.write("const input = payload.value;");let y=Object.create(null),b=0;for(let v of m.keys)y[v]=`key_${b++}`;f.write("const newResult = {};");for(let v of m.keys){let x=y[v],k=Yn(v),_e=p[v],Ee=_e?._zod?.optin==="optional",Dt=_e?._zod?.optout==="optional";f.write(`const ${x} = ${_(v)};`),Ee&&Dt?f.write(`
19
+ `))}};var Il={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=Il;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=kt(i),l;for(let d of a){if(d._zod.def.when){if(Gs(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=kt(i,p)))});else{if(i.issues.length===p)continue;u||(u=kt(i,p))}}return l?l.then(()=>i):i},s=(i,a,c)=>{if(kt(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 co(t,o).then(i=>i.success?{value:i.data}:{issues:i.error?.issues})}},vendor:"zod",version:1}))}),mo=g("$ZodString",(t,e)=>{G.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??dl(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)=>{Br.init(t,e),mo.init(t,e)}),Ul=g("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Ju),J.init(t,e)}),ql=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=Xs(n))}else e.pattern??(e.pattern=Xs());J.init(t,e)}),Zl=g("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Yu),J.init(t,e)}),Fl=g("$ZodURL",(t,e)=>{J.init(t,e),t._zod.check=r=>{try{let n=r.value.trim();if(!e.normalize&&e.protocol?.source===ol.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})}}}),Hl=g("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=Xu()),J.init(t,e)}),Vl=g("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=Ku),J.init(t,e)}),Wl=g("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=Fu),J.init(t,e)}),Bl=g("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=Hu),J.init(t,e)}),Kl=g("$ZodULID",(t,e)=>{e.pattern??(e.pattern=Vu),J.init(t,e)}),Gl=g("$ZodXID",(t,e)=>{e.pattern??(e.pattern=Wu),J.init(t,e)}),Jl=g("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=Bu),J.init(t,e)}),Yl=g("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=ll(e)),J.init(t,e)}),Xl=g("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=al),J.init(t,e)}),Ql=g("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=ul(e)),J.init(t,e)}),ed=g("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Gu),J.init(t,e)}),td=g("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Qu),J.init(t,e),t._zod.bag.format="ipv4"}),rd=g("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=el),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 nd=g("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=tl),J.init(t,e)}),od=g("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=rl),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 sd(t){if(t==="")return!0;if(/\s/.test(t)||t.length%4!==0)return!1;try{return atob(t),!0}catch{return!1}}var id=g("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=nl),J.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=r=>{sd(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:t,continue:!e.abort})}});function Py(t){if(!Qs.test(t))return!1;let e=t.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=e.padEnd(Math.ceil(e.length/4)*4,"=");return sd(r)}var ad=g("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=Qs),J.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=r=>{Py(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:t,continue:!e.abort})}}),cd=g("$ZodE164",(t,e)=>{e.pattern??(e.pattern=sl),J.init(t,e)});function Ty(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 ud=g("$ZodJWT",(t,e)=>{J.init(t,e),t._zod.check=r=>{Ty(r.value,e.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:t,continue:!e.abort})}});var oi=g("$ZodNumber",(t,e)=>{G.init(t,e),t._zod.pattern=t._zod.bag.pattern??ei,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}}),ld=g("$ZodNumberFormat",(t,e)=>{Sl.init(t,e),oi.init(t,e)}),dd=g("$ZodBoolean",(t,e)=>{G.init(t,e),t._zod.pattern=fl,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 pd=g("$ZodNull",(t,e)=>{G.init(t,e),t._zod.pattern=ml,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 fd=g("$ZodUnknown",(t,e)=>{G.init(t,e),t._zod.parse=r=>r}),md=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 Ol(t,e,r){t.issues.length&&e.issues.push(...mt(r,t.issues)),e.value[r]=t.value}var hd=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=>Ol(u,r,i))):Ol(c,r,i)}return s.length?Promise.all(s).then(()=>r):r}});function fo(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 gd(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=Bs(t.shape);return{...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(r)}}function _d(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=>fo(m,r,p,e,l,d))):fo(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=or(()=>gd(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=Lt,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",y=f._zod.run({value:u[p],issues:[]},c);y instanceof Promise?l.push(y.then(b=>fo(b,a,p,u,m,_))):fo(y,a,p,u,m,_)}return s?_d(l,u,a,c,n.value,t):l.length?Promise.all(l).then(()=>a):a}}),yd=g("$ZodObjectJIT",(t,e)=>{zy.init(t,e);let r=t._zod.parse,n=or(()=>gd(e)),o=p=>{let f=new lo(["shape","payload","ctx"]),m=n.value,_=v=>{let x=ro(v);return`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`};f.write("const input = payload.value;");let y=Object.create(null),b=0;for(let v of m.keys)y[v]=`key_${b++}`;f.write("const newResult = {};");for(let v of m.keys){let x=y[v],$=ro(v),ye=p[v],we=ye?._zod?.optin==="optional",jt=ye?._zod?.optout==="optional";f.write(`const ${x} = ${_(v)};`),we&&jt?f.write(`
20
20
  if (${x}.issues.length) {
21
- if (${k} in input) {
21
+ if (${$} in input) {
22
22
  payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
23
23
  ...iss,
24
- path: iss.path ? [${k}, ...iss.path] : [${k}]
24
+ path: iss.path ? [${$}, ...iss.path] : [${$}]
25
25
  })));
26
26
  }
27
27
  }
28
28
 
29
29
  if (${x}.value === undefined) {
30
- if (${k} in input) {
31
- newResult[${k}] = undefined;
30
+ if (${$} in input) {
31
+ newResult[${$}] = undefined;
32
32
  }
33
33
  } else {
34
- newResult[${k}] = ${x}.value;
34
+ newResult[${$}] = ${x}.value;
35
35
  }
36
36
 
37
- `):Ee?f.write(`
37
+ `):we?f.write(`
38
38
  if (${x}.issues.length) {
39
39
  payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
40
40
  ...iss,
41
- path: iss.path ? [${k}, ...iss.path] : [${k}]
41
+ path: iss.path ? [${$}, ...iss.path] : [${$}]
42
42
  })));
43
43
  }
44
44
 
45
45
  if (${x}.value === undefined) {
46
- if (${k} in input) {
47
- newResult[${k}] = undefined;
46
+ if (${$} in input) {
47
+ newResult[${$}] = undefined;
48
48
  }
49
49
  } else {
50
- newResult[${k}] = ${x}.value;
50
+ newResult[${$}] = ${x}.value;
51
51
  }
52
52
 
53
53
  `):f.write(`
54
- const ${x}_present = ${k} in input;
54
+ const ${x}_present = ${$} in input;
55
55
  if (${x}.issues.length) {
56
56
  payload.issues = payload.issues.concat(${x}.issues.map(iss => ({
57
57
  ...iss,
58
- path: iss.path ? [${k}, ...iss.path] : [${k}]
58
+ path: iss.path ? [${$}, ...iss.path] : [${$}]
59
59
  })));
60
60
  }
61
61
  if (!${x}_present && !${x}.issues.length) {
@@ -63,23 +63,23 @@ ${s.stack}`:` ${s.message}`;else if(this.getLevel()===0&&typeof s=="object")try{
63
63
  code: "invalid_type",
64
64
  expected: "nonoptional",
65
65
  input: undefined,
66
- path: [${k}]
66
+ path: [${$}]
67
67
  });
68
68
  }
69
69
 
70
70
  if (${x}_present) {
71
71
  if (${x}.value === undefined) {
72
- newResult[${k}] = undefined;
72
+ newResult[${$}] = undefined;
73
73
  } else {
74
- newResult[${k}] = ${x}.value;
74
+ newResult[${$}] = ${x}.value;
75
75
  }
76
76
  }
77
77
 
78
- `)}f.write("payload.value = newResult;"),f.write("return payload;");let w=f.compile();return(v,x)=>w(p,v,x)},s,i=Lt,a=!tr.jitless,u=a&&Ls.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 El(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=>!Et(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=>Le(i,n,Ae())))}),e)}var Xs=g("$ZodUnion",(t,e)=>{J.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=>Ur(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=>El(a,n,t,o)):El(i,n,t,o)}});var ud=g("$ZodDiscriminatedUnion",(t,e)=>{e.inclusive=!1,Xs.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=nr(()=>{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(!Lt(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)}}),ld=g("$ZodIntersection",(t,e)=>{J.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])=>$l(r,c,u)):$l(r,s,i)}});function Bs(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(wt(t)&&wt(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=Bs(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=Bs(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 $l(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}),Et(t))return t;let i=Bs(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)=>{J.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!wt(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=>Le(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(...ft(u,f.issues)),r.value[d]=f.value})):(p.issues.length&&r.issues.push(...ft(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"&&Gs.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=>Le(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(...ft(a,d.issues)),r.value[c.value]=d.value})):(l.issues.length&&r.issues.push(...ft(a,l.issues)),r.value[c.value]=l.value)}}return s.length?Promise.all(s).then(()=>r):r}});var pd=g("$ZodEnum",(t,e)=>{J.init(t,e);let r=Lr(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(o=>js.has(typeof o)).map(o=>typeof o=="string"?pt(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}}),fd=g("$ZodLiteral",(t,e)=>{if(J.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"?pt(n):n?pt(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 md=g("$ZodTransform",(t,e)=>{J.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new er(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 et;return r.value=o,r.fallback=!0,r}});function kl(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var Qs=g("$ZodOptional",(t,e)=>{J.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(`^(${Ur(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=>kl(i,o)):kl(s,o)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),hd=g("$ZodExactOptional",(t,e)=>{Qs.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)}),gd=g("$ZodNullable",(t,e)=>{J.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(`^(${Ur(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)}),_d=g("$ZodDefault",(t,e)=>{J.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 yd=g("$ZodPrefault",(t,e)=>{J.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))}),Sd=g("$ZodNonOptional",(t,e)=>{J.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=>Pl(s,t)):Pl(o,t)}});function Pl(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)=>{J.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=>Le(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=>Le(s,n,Ae()))},input:r.value}),r.issues=[],r.fallback=!0),r)}});var ei=g("$ZodPipe",(t,e)=>{J.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=>io(i,e.in,n)):io(s,e.in,n)}let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>io(s,e.out,n)):io(o,e.out,n)}});function io(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)=>{ei.init(t,e)}),wd=g("$ZodReadonly",(t,e)=>{J.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(zl):zl(o)}});function zl(t){return t.value=Object.freeze(t.value),t}var Ed=g("$ZodCustom",(t,e)=>{le.init(t,e),J.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=>Tl(s,r,n,t));Tl(o,r,n,t)}});function Tl(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(or(o))}}var gy=()=>{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=qs(o.input),a=n[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${Qn(o.values[0])}`:`Invalid option: expected one of ${Bn(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":""}: ${Bn(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 $d(){return{localeError:gy()}}var kd;var ti=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 _y(){return new ti}(kd=globalThis).__zod_globalRegistry??(kd.__zod_globalRegistry=_y());var jt=globalThis.__zod_globalRegistry;function xd(t,e){return new t({type:"string",...T(e)})}function Pd(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...T(e)})}function ri(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...T(e)})}function zd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...T(e)})}function Td(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(e)})}function Rd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(e)})}function Od(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(e)})}function Id(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...T(e)})}function Ad(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...T(e)})}function Md(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(e)})}function Cd(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...T(e)})}function Nd(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(e)})}function Dd(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...T(e)})}function Ld(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...T(e)})}function jd(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(e)})}function Ud(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(e)})}function Zd(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(e)})}function Fd(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(e)})}function qd(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(e)})}function Hd(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...T(e)})}function Wd(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...T(e)})}function Vd(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...T(e)})}function Gd(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...T(e)})}function Kd(t,e){return new t({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(e)})}function Jd(t,e){return new t({type:"string",format:"date",check:"string_format",...T(e)})}function Bd(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...T(e)})}function Yd(t,e){return new t({type:"string",format:"duration",check:"string_format",...T(e)})}function Xd(t,e){return new t({type:"number",checks:[],...T(e)})}function Qd(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...T(e)})}function ep(t,e){return new t({type:"boolean",...T(e)})}function tp(t,e){return new t({type:"null",...T(e)})}function rp(t){return new t({type:"unknown"})}function np(t,e){return new t({type:"never",...T(e)})}function uo(t,e){return new Ks({check:"less_than",...T(e),value:t,inclusive:!1})}function Vr(t,e){return new Ks({check:"less_than",...T(e),value:t,inclusive:!0})}function lo(t,e){return new Js({check:"greater_than",...T(e),value:t,inclusive:!1})}function Gr(t,e){return new Js({check:"greater_than",...T(e),value:t,inclusive:!0})}function po(t,e){return new cl({check:"multiple_of",...T(e),value:t})}function fo(t,e){return new ll({check:"max_length",...T(e),maximum:t})}function sr(t,e){return new dl({check:"min_length",...T(e),minimum:t})}function mo(t,e){return new pl({check:"length_equals",...T(e),length:t})}function ni(t,e){return new fl({check:"string_format",format:"regex",...T(e),pattern:t})}function oi(t){return new ml({check:"string_format",format:"lowercase",...T(t)})}function si(t){return new hl({check:"string_format",format:"uppercase",...T(t)})}function ii(t,e){return new gl({check:"string_format",format:"includes",...T(e),includes:t})}function ai(t,e){return new _l({check:"string_format",format:"starts_with",...T(e),prefix:t})}function ci(t,e){return new yl({check:"string_format",format:"ends_with",...T(e),suffix:t})}function $t(t){return new Sl({check:"overwrite",tx:t})}function ui(t){return $t(e=>e.normalize(t))}function li(){return $t(t=>t.trim())}function di(){return $t(t=>t.toLowerCase())}function pi(){return $t(t=>t.toUpperCase())}function fi(){return $t(t=>Ds(t))}function op(t,e,r){return new t({type:"array",element:e,...T(r)})}function sp(t,e,r){let n=T(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function ip(t,e,r){return new t({type:"custom",check:"custom",fn:e,...T(r)})}function ap(t,e){let r=yy(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(or(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(or(s))}},t(n.value,n)),e);return r}function yy(t,e){let r=new le({check:"custom",...T(e)});return r._zod.check=t,r}function mi(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??jt,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"&&$e(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 hi(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,x)=>E(p,v,x)},s,i=Lt,a=!rr.jitless,u=a&&Vs.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?_d([],m,p,f,d,t):p):r(p,f):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:t}),p)}});function Al(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=>!kt(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=>Zr(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=>Al(a,n,t,o)):Al(i,n,t,o)}});var Sd=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=or(()=>{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(!Lt(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)}}),vd=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])=>Ml(r,c,u)):Ml(r,s,i)}});function ni(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(wt(t)&&wt(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=ni(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=ni(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 Ml(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}),kt(t))return t;let i=ni(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 bd=g("$ZodRecord",(t,e)=>{G.init(t,e),t._zod.parse=(r,n)=>{let o=r.value;if(!wt(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"&&ei.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 Ed=g("$ZodEnum",(t,e)=>{G.init(t,e);let r=Ur(e.entries),n=new Set(r);t._zod.values=n,t._zod.pattern=new RegExp(`^(${r.filter(o=>Ws.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}}),wd=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 kd=g("$ZodTransform",(t,e)=>{G.init(t,e),t._zod.optin="optional",t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new tr(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 Cl(t,e){return e===void 0&&(t.issues.length||t.fallback)?{issues:[],value:void 0}:t}var ii=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(`^(${Zr(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=>Cl(i,o)):Cl(s,o)}return r.value===void 0?r:e.innerType._zod.run(r,n)}}),$d=g("$ZodExactOptional",(t,e)=>{ii.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)}),xd=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(`^(${Zr(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)}),Pd=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=>Nl(s,e)):Nl(o,e)}});function Nl(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}var Td=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))}),zd=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=>Dl(s,t)):Dl(o,t)}});function Dl(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 Rd=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 ai=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=>po(i,e.in,n)):po(s,e.in,n)}let o=e.in._zod.run(r,n);return o instanceof Promise?o.then(s=>po(s,e.out,n)):po(o,e.out,n)}});function po(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 Id=g("$ZodPreprocess",(t,e)=>{ai.init(t,e)}),Od=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(jl):jl(o)}});function jl(t){return t.value=Object.freeze(t.value),t}var Ad=g("$ZodCustom",(t,e)=>{de.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=>Ll(s,r,n,t));Ll(o,r,n,t)}});function Ll(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(sr(o))}}var Ry=()=>{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=Js(o.input),a=n[i]??i;return`Invalid input: expected ${s}, received ${a}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${oo(o.values[0])}`:`Invalid option: expected one of ${to(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":""}: ${to(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 Md(){return{localeError:Ry()}}var Cd;var ci=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 Iy(){return new ci}(Cd=globalThis).__zod_globalRegistry??(Cd.__zod_globalRegistry=Iy());var Ut=globalThis.__zod_globalRegistry;function Nd(t,e){return new t({type:"string",...z(e)})}function Dd(t,e){return new t({type:"string",format:"email",check:"string_format",abort:!1,...z(e)})}function ui(t,e){return new t({type:"string",format:"guid",check:"string_format",abort:!1,...z(e)})}function jd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,...z(e)})}function Ld(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...z(e)})}function Ud(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...z(e)})}function qd(t,e){return new t({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...z(e)})}function Zd(t,e){return new t({type:"string",format:"url",check:"string_format",abort:!1,...z(e)})}function Fd(t,e){return new t({type:"string",format:"emoji",check:"string_format",abort:!1,...z(e)})}function Hd(t,e){return new t({type:"string",format:"nanoid",check:"string_format",abort:!1,...z(e)})}function Vd(t,e){return new t({type:"string",format:"cuid",check:"string_format",abort:!1,...z(e)})}function Wd(t,e){return new t({type:"string",format:"cuid2",check:"string_format",abort:!1,...z(e)})}function Bd(t,e){return new t({type:"string",format:"ulid",check:"string_format",abort:!1,...z(e)})}function Kd(t,e){return new t({type:"string",format:"xid",check:"string_format",abort:!1,...z(e)})}function Gd(t,e){return new t({type:"string",format:"ksuid",check:"string_format",abort:!1,...z(e)})}function Jd(t,e){return new t({type:"string",format:"ipv4",check:"string_format",abort:!1,...z(e)})}function Yd(t,e){return new t({type:"string",format:"ipv6",check:"string_format",abort:!1,...z(e)})}function Xd(t,e){return new t({type:"string",format:"cidrv4",check:"string_format",abort:!1,...z(e)})}function Qd(t,e){return new t({type:"string",format:"cidrv6",check:"string_format",abort:!1,...z(e)})}function ep(t,e){return new t({type:"string",format:"base64",check:"string_format",abort:!1,...z(e)})}function tp(t,e){return new t({type:"string",format:"base64url",check:"string_format",abort:!1,...z(e)})}function rp(t,e){return new t({type:"string",format:"e164",check:"string_format",abort:!1,...z(e)})}function np(t,e){return new t({type:"string",format:"jwt",check:"string_format",abort:!1,...z(e)})}function op(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 ip(t,e){return new t({type:"string",format:"time",check:"string_format",precision:null,...z(e)})}function ap(t,e){return new t({type:"string",format:"duration",check:"string_format",...z(e)})}function cp(t,e){return new t({type:"number",checks:[],...z(e)})}function up(t,e){return new t({type:"number",check:"number_format",abort:!1,format:"safeint",...z(e)})}function lp(t,e){return new t({type:"boolean",...z(e)})}function dp(t,e){return new t({type:"null",...z(e)})}function pp(t){return new t({type:"unknown"})}function fp(t,e){return new t({type:"never",...z(e)})}function ho(t,e){return new ti({check:"less_than",...z(e),value:t,inclusive:!1})}function Kr(t,e){return new ti({check:"less_than",...z(e),value:t,inclusive:!0})}function go(t,e){return new ri({check:"greater_than",...z(e),value:t,inclusive:!1})}function Gr(t,e){return new ri({check:"greater_than",...z(e),value:t,inclusive:!0})}function _o(t,e){return new yl({check:"multiple_of",...z(e),value:t})}function yo(t,e){return new vl({check:"max_length",...z(e),maximum:t})}function ir(t,e){return new bl({check:"min_length",...z(e),minimum:t})}function So(t,e){return new El({check:"length_equals",...z(e),length:t})}function li(t,e){return new wl({check:"string_format",format:"regex",...z(e),pattern:t})}function di(t){return new kl({check:"string_format",format:"lowercase",...z(t)})}function pi(t){return new $l({check:"string_format",format:"uppercase",...z(t)})}function fi(t,e){return new xl({check:"string_format",format:"includes",...z(e),includes:t})}function mi(t,e){return new Pl({check:"string_format",format:"starts_with",...z(e),prefix:t})}function hi(t,e){return new Tl({check:"string_format",format:"ends_with",...z(e),suffix:t})}function $t(t){return new zl({check:"overwrite",tx:t})}function gi(t){return $t(e=>e.normalize(t))}function _i(){return $t(t=>t.trim())}function yi(){return $t(t=>t.toLowerCase())}function Si(){return $t(t=>t.toUpperCase())}function vi(){return $t(t=>Hs(t))}function mp(t,e,r){return new t({type:"array",element:e,...z(r)})}function hp(t,e,r){let n=z(r);return n.abort??(n.abort=!0),new t({type:"custom",check:"custom",fn:e,...n})}function gp(t,e,r){return new t({type:"custom",check:"custom",fn:e,...z(r)})}function _p(t,e){let r=Oy(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(sr(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(sr(s))}},t(n.value,n)),e);return r}function Oy(t,e){let r=new de({check:"custom",...z(e)});return r._zod.check=t,r}function bi(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??Ut,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 Ei(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 gi(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 y in u)y==="$ref"||y==="allOf"||y in l||delete u[y];if(m.$ref&&f.def)for(let y in u)y==="$ref"||y==="allOf"||y in f.def&&JSON.stringify(u[y])===JSON.stringify(f.def[y])&&delete u[y]}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:Kr(e,"input",t.processors),output:Kr(e,"output",t.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function $e(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 $e(n.element,r);if(n.type==="set")return $e(n.valueType,r);if(n.type==="lazy")return $e(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 $e(n.innerType,r);if(n.type==="intersection")return $e(n.left,r)||$e(n.right,r);if(n.type==="record"||n.type==="map")return $e(n.keyType,r)||$e(n.valueType,r);if(n.type==="pipe")return t._zod.traits.has("$ZodCodec")?!0:$e(n.in,r)||$e(n.out,r);if(n.type==="object"){for(let o in n.shape)if($e(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if($e(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if($e(o,r))return!0;return!!(n.rest&&$e(n.rest,r))}return!1}var cp=(t,e={})=>r=>{let n=mi({...r,processors:e});return se(t,n),hi(n,t),gi(n,t)},Kr=(t,e,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=mi({...o??{},target:s,io:e,processors:r});return se(t,i),hi(i,t),gi(i,t)};var Sy={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},up=(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=Sy[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}))])}},lp=(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 pp=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var fp=(t,e,r,n)=>{r.not={}};var mp=(t,e,r,n)=>{};var hp=(t,e,r,n)=>{let o=t._zod.def,s=Lr(o.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},gp=(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 _p=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var yp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var Sp=(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},wp=(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 Ep=(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)}},$p=(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"}]},kp=(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))},Pp=(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)))},zp=(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},Tp=(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},Rp=(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 _i=(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 ir(t){return!!t._zod}function kt(t,e){return ir(t)?qr(t,e):t.safeParse(e)}function ho(t){if(!t)return;let e;if(ir(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Op(t){if(ir(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 Br={};uu(Br,{ZodISODate:()=>Ap,ZodISODateTime:()=>Ip,ZodISODuration:()=>Cp,ZodISOTime:()=>Mp,date:()=>Si,datetime:()=>yi,duration:()=>bi,time:()=>vi});var Ip=g("ZodISODateTime",(t,e)=>{Zl.init(t,e),te.init(t,e)});function yi(t){return Kd(Ip,t)}var Ap=g("ZodISODate",(t,e)=>{Fl.init(t,e),te.init(t,e)});function Si(t){return Jd(Ap,t)}var Mp=g("ZodISOTime",(t,e)=>{ql.init(t,e),te.init(t,e)});function vi(t){return Bd(Mp,t)}var Cp=g("ZodISODuration",(t,e)=>{Hl.init(t,e),te.init(t,e)});function bi(t){return Yd(Cp,t)}var zy=(t,e)=>{eo.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>$u(t,r)},flatten:{value:r=>Eu(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,rr,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,rr,2)}},isEmpty:{get(){return t.issues.length===0}}})};var Me=g("ZodError",zy,{Parent:Error});var Np=to(Me),Dp=ro(Me),Lp=Fr(Me),jp=Hr(Me),Up=ku(Me),Zp=xu(Me),Fp=Pu(Me),qp=zu(Me),Hp=Tu(Me),Wp=Ru(Me),Vp=Ou(Me),Gp=Iu(Me);var Kp=new WeakMap;function Yr(t,e,r){let n=Object.getPrototypeOf(t),o=Kp.get(n);if(o||(o=new Set,Kp.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)=>(J.init(t,e),Object.assign(t["~standard"],{jsonSchema:{input:Kr(t,"input"),output:Kr(t,"output")}}),t.toJSONSchema=cp(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>Np(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Lp(t,r,n),t.parseAsync=async(r,n)=>Dp(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>jp(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>Up(t,r,n),t.decode=(r,n)=>Zp(t,r,n),t.encodeAsync=async(r,n)=>Fp(t,r,n),t.decodeAsync=async(r,n)=>qp(t,r,n),t.safeEncode=(r,n)=>Hp(t,r,n),t.safeDecode=(r,n)=>Wp(t,r,n),t.safeEncodeAsync=async(r,n)=>Vp(t,r,n),t.safeDecodeAsync=async(r,n)=>Gp(t,r,n),Yr(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(yS(r,n))},superRefine(r,n){return this.check(SS(r,n))},overwrite(r){return this.check($t(r))},optional(){return ne(this)},exactOptional(){return iS(this)},nullable(){return Xp(this)},nullish(){return ne(Xp(this))},nonoptional(r){return pS(this,r)},array(){return D(this)},or(r){return Y([this,r])},and(r){return _o(this,r)},transform(r){return Qp(this,sf(r))},default(r){return uS(this,r)},prefault(r){return dS(this,r)},catch(r){return mS(this,r)},pipe(r){return Qp(this,r)},readonly(){return _S(this)},describe(r){let n=this.clone();return jt.add(n,{description:r}),n},meta(...r){if(r.length===0)return jt.get(this);let n=this.clone();return jt.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 jt.get(t)?.description},configurable:!0}),t)),ef=g("_ZodString",(t,e)=>{co.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>up(t,n,o,s);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,Yr(t,"_ZodString",{regex(...n){return this.check(ni(...n))},includes(...n){return this.check(ii(...n))},startsWith(...n){return this.check(ai(...n))},endsWith(...n){return this.check(ci(...n))},min(...n){return this.check(sr(...n))},max(...n){return this.check(fo(...n))},length(...n){return this.check(mo(...n))},nonempty(...n){return this.check(sr(1,...n))},lowercase(n){return this.check(oi(n))},uppercase(n){return this.check(si(n))},trim(){return this.check(li())},normalize(...n){return this.check(ui(...n))},toLowerCase(){return this.check(di())},toUpperCase(){return this.check(pi())},slugify(){return this.check(fi())}})}),Ry=g("ZodString",(t,e)=>{co.init(t,e),ef.init(t,e),t.email=r=>t.check(Pd(Oy,r)),t.url=r=>t.check(Id(Iy,r)),t.jwt=r=>t.check(Gd(Gy,r)),t.emoji=r=>t.check(Ad(Ay,r)),t.guid=r=>t.check(ri(Jp,r)),t.uuid=r=>t.check(zd(go,r)),t.uuidv4=r=>t.check(Td(go,r)),t.uuidv6=r=>t.check(Rd(go,r)),t.uuidv7=r=>t.check(Od(go,r)),t.nanoid=r=>t.check(Md(My,r)),t.guid=r=>t.check(ri(Jp,r)),t.cuid=r=>t.check(Cd(Cy,r)),t.cuid2=r=>t.check(Nd(Ny,r)),t.ulid=r=>t.check(Dd(Dy,r)),t.base64=r=>t.check(Hd(Hy,r)),t.base64url=r=>t.check(Wd(Wy,r)),t.xid=r=>t.check(Ld(Ly,r)),t.ksuid=r=>t.check(jd(jy,r)),t.ipv4=r=>t.check(Ud(Uy,r)),t.ipv6=r=>t.check(Zd(Zy,r)),t.cidrv4=r=>t.check(Fd(Fy,r)),t.cidrv6=r=>t.check(qd(qy,r)),t.e164=r=>t.check(Vd(Vy,r)),t.datetime=r=>t.check(yi(r)),t.date=r=>t.check(Si(r)),t.time=r=>t.check(vi(r)),t.duration=r=>t.check(bi(r))});function h(t){return xd(Ry,t)}var te=g("ZodStringFormat",(t,e)=>{B.init(t,e),ef.init(t,e)}),Oy=g("ZodEmail",(t,e)=>{Il.init(t,e),te.init(t,e)});var Jp=g("ZodGUID",(t,e)=>{Rl.init(t,e),te.init(t,e)});var go=g("ZodUUID",(t,e)=>{Ol.init(t,e),te.init(t,e)});var Iy=g("ZodURL",(t,e)=>{Al.init(t,e),te.init(t,e)});var Ay=g("ZodEmoji",(t,e)=>{Ml.init(t,e),te.init(t,e)});var My=g("ZodNanoID",(t,e)=>{Cl.init(t,e),te.init(t,e)});var Cy=g("ZodCUID",(t,e)=>{Nl.init(t,e),te.init(t,e)});var Ny=g("ZodCUID2",(t,e)=>{Dl.init(t,e),te.init(t,e)});var Dy=g("ZodULID",(t,e)=>{Ll.init(t,e),te.init(t,e)});var Ly=g("ZodXID",(t,e)=>{jl.init(t,e),te.init(t,e)});var jy=g("ZodKSUID",(t,e)=>{Ul.init(t,e),te.init(t,e)});var Uy=g("ZodIPv4",(t,e)=>{Wl.init(t,e),te.init(t,e)});var Zy=g("ZodIPv6",(t,e)=>{Vl.init(t,e),te.init(t,e)});var Fy=g("ZodCIDRv4",(t,e)=>{Gl.init(t,e),te.init(t,e)});var qy=g("ZodCIDRv6",(t,e)=>{Kl.init(t,e),te.init(t,e)});var Hy=g("ZodBase64",(t,e)=>{Bl.init(t,e),te.init(t,e)});var Wy=g("ZodBase64URL",(t,e)=>{Yl.init(t,e),te.init(t,e)});var Vy=g("ZodE164",(t,e)=>{Xl.init(t,e),te.init(t,e)});var Gy=g("ZodJWT",(t,e)=>{Ql.init(t,e),te.init(t,e)});var tf=g("ZodNumber",(t,e)=>{Ys.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>lp(t,n,o,s),Yr(t,"ZodNumber",{gt(n,o){return this.check(lo(n,o))},gte(n,o){return this.check(Gr(n,o))},min(n,o){return this.check(Gr(n,o))},lt(n,o){return this.check(uo(n,o))},lte(n,o){return this.check(Vr(n,o))},max(n,o){return this.check(Vr(n,o))},int(n){return this.check(Bp(n))},safe(n){return this.check(Bp(n))},positive(n){return this.check(lo(0,n))},nonnegative(n){return this.check(Gr(0,n))},negative(n){return this.check(uo(0,n))},nonpositive(n){return this.check(Vr(0,n))},multipleOf(n,o){return this.check(po(n,o))},step(n,o){return this.check(po(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 Xd(tf,t)}var Ky=g("ZodNumberFormat",(t,e)=>{ed.init(t,e),tf.init(t,e)});function Bp(t){return Qd(Ky,t)}var Jy=g("ZodBoolean",(t,e)=>{td.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>dp(t,r,n,o)});function ue(t){return ep(Jy,t)}var By=g("ZodNull",(t,e)=>{rd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>pp(t,r,n,o)});function rf(t){return tp(By,t)}var Yy=g("ZodUnknown",(t,e)=>{nd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>mp(t,r,n,o)});function re(){return rp(Yy)}var Xy=g("ZodNever",(t,e)=>{od.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>fp(t,r,n,o)});function Qy(t){return np(Xy,t)}var eS=g("ZodArray",(t,e)=>{sd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Sp(t,r,n,o),t.element=e.element,Yr(t,"ZodArray",{min(r,n){return this.check(sr(r,n))},nonempty(r){return this.check(sr(1,r))},max(r,n){return this.check(fo(r,n))},length(r,n){return this.check(mo(r,n))},unwrap(){return this.element}})});function D(t,e){return op(eS,t,e)}var nf=g("ZodObject",(t,e)=>{cd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>vp(t,r,n,o),U.defineLazy(t,"shape",()=>e.shape),Yr(t,"ZodObject",{keyof(){return ze(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:Qy()})},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(cf,this,r[0])}})});function $(t,e){let r={type:"object",shape:t??{},...U.normalizeParams(e)};return new nf(r)}function ke(t,e){return new nf({type:"object",shape:t,catchall:re(),...U.normalizeParams(e)})}var of=g("ZodUnion",(t,e)=>{Xs.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 of({type:"union",options:t,...U.normalizeParams(e)})}var tS=g("ZodDiscriminatedUnion",(t,e)=>{of.init(t,e),ud.init(t,e)});function Ei(t,e,r){return new tS({type:"union",options:e,discriminator:t,...U.normalizeParams(r)})}var rS=g("ZodIntersection",(t,e)=>{ld.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>wp(t,r,n,o)});function _o(t,e){return new rS({type:"intersection",left:t,right:e})}var Yp=g("ZodRecord",(t,e)=>{dd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ep(t,r,n,o),t.keyType=e.keyType,t.valueType=e.valueType});function K(t,e,r){return!e||!e._zod?new Yp({type:"record",keyType:h(),valueType:t,...U.normalizeParams(e)}):new Yp({type:"record",keyType:t,valueType:e,...U.normalizeParams(r)})}var wi=g("ZodEnum",(t,e)=>{pd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>hp(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 wi({...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 wi({...e,checks:[],...U.normalizeParams(o),entries:s})}});function ze(t,e){let r=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new wi({type:"enum",entries:r,...U.normalizeParams(e)})}var nS=g("ZodLiteral",(t,e)=>{fd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>gp(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 nS({type:"literal",values:Array.isArray(t)?t:[t],...U.normalizeParams(e)})}var oS=g("ZodTransform",(t,e)=>{md.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>yp(t,r,n,o),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new er(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 sf(t){return new oS({type:"transform",transform:t})}var af=g("ZodOptional",(t,e)=>{Qs.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>_i(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function ne(t){return new af({type:"optional",innerType:t})}var sS=g("ZodExactOptional",(t,e)=>{hd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>_i(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function iS(t){return new sS({type:"optional",innerType:t})}var aS=g("ZodNullable",(t,e)=>{gd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>$p(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function Xp(t){return new aS({type:"nullable",innerType:t})}var cS=g("ZodDefault",(t,e)=>{_d.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 uS(t,e){return new cS({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():U.shallowClone(e)}})}var lS=g("ZodPrefault",(t,e)=>{yd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Pp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function dS(t,e){return new lS({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():U.shallowClone(e)}})}var cf=g("ZodNonOptional",(t,e)=>{Sd.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 pS(t,e){return new cf({type:"nonoptional",innerType:t,...U.normalizeParams(e)})}var fS=g("ZodCatch",(t,e)=>{vd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>zp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeCatch=t.unwrap});function mS(t,e){return new fS({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var uf=g("ZodPipe",(t,e)=>{ei.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Tp(t,r,n,o),t.in=e.in,t.out=e.out});function Qp(t,e){return new uf({type:"pipe",in:t,out:e})}var hS=g("ZodPreprocess",(t,e)=>{uf.init(t,e),bd.init(t,e)}),gS=g("ZodReadonly",(t,e)=>{wd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Rp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function _S(t){return new gS({type:"readonly",innerType:t})}var lf=g("ZodCustom",(t,e)=>{Ed.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>_p(t,r,n,o)});function df(t,e){return sp(lf,t??(()=>!0),e)}function yS(t,e={}){return ip(lf,t,e)}function SS(t,e){return ap(t,e)}function $i(t,e){return new hS({type:"pipe",in:sf(t),out:e})}Ae($d());var xi="2025-11-25";var pf=[xi,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],xt="io.modelcontextprotocol/related-task",So="2.0",ce=df(t=>t!==null&&(typeof t=="object"||typeof t=="function")),ff=Y([h(),W().int()]),mf=h(),UT=ke({ttl:W().optional(),pollInterval:W().optional()}),vS=$({ttl:W().optional()}),bS=$({taskId:h()}),Pi=ke({progressToken:ff.optional(),[xt]:bS.optional()}),Ce=$({_meta:Pi.optional()}),Xr=Ce.extend({task:vS.optional()}),hf=t=>Xr.safeParse(t).success,de=$({method:h(),params:Ce.loose().optional()}),je=$({_meta:Pi.optional()}),Ue=$({method:h(),params:je.loose().optional()}),pe=ke({_meta:Pi.optional()}),vo=Y([h(),W().int()]),gf=$({jsonrpc:P(So),id:vo,...de.shape}).strict(),zi=t=>gf.safeParse(t).success,_f=$({jsonrpc:P(So),...Ue.shape}).strict(),yf=t=>_f.safeParse(t).success,Ti=$({jsonrpc:P(So),id:vo,result:pe}).strict(),Qr=t=>Ti.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 Ri=$({jsonrpc:P(So),id:vo.optional(),error:$({code:W().int(),message:h(),data:re().optional()})}).strict();var Sf=t=>Ri.safeParse(t).success;var vf=Y([gf,_f,Ti,Ri]),ZT=Y([Ti,Ri]),bo=pe.strict(),wS=je.extend({requestId:vo.optional(),reason:h().optional()}),wo=Ue.extend({method:P("notifications/cancelled"),params:wS}),ES=$({src:h(),mimeType:h().optional(),sizes:D(h()).optional(),theme:ze(["light","dark"]).optional()}),en=$({icons:D(ES).optional()}),ar=$({name:h(),title:h().optional()}),bf=ar.extend({...ar.shape,...en.shape,version:h(),websiteUrl:h().optional(),description:h().optional()}),$S=_o($({applyDefaults:ue().optional()}),K(h(),re())),kS=$i(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,_o($({form:$S.optional(),url:ce.optional()}),K(h(),re()).optional())),xS=ke({list:ce.optional(),cancel:ce.optional(),requests:ke({sampling:ke({createMessage:ce.optional()}).optional(),elicitation:ke({create:ce.optional()}).optional()}).optional()}),PS=ke({list:ce.optional(),cancel:ce.optional(),requests:ke({tools:ke({call:ce.optional()}).optional()}).optional()}),zS=$({experimental:K(h(),ce).optional(),sampling:$({context:ce.optional(),tools:ce.optional()}).optional(),elicitation:kS.optional(),roots:$({listChanged:ue().optional()}).optional(),tasks:xS.optional(),extensions:K(h(),ce).optional()}),TS=Ce.extend({protocolVersion:h(),capabilities:zS,clientInfo:bf}),Oi=de.extend({method:P("initialize"),params:TS});var RS=$({experimental:K(h(),ce).optional(),logging:ce.optional(),completions:ce.optional(),prompts:$({listChanged:ue().optional()}).optional(),resources:$({subscribe:ue().optional(),listChanged:ue().optional()}).optional(),tools:$({listChanged:ue().optional()}).optional(),tasks:PS.optional(),extensions:K(h(),ce).optional()}),OS=pe.extend({protocolVersion:h(),capabilities:RS,serverInfo:bf,instructions:h().optional()}),Ii=Ue.extend({method:P("notifications/initialized"),params:je.optional()});var Eo=de.extend({method:P("ping"),params:Ce.optional()}),IS=$({progress:W(),total:ne(W()),message:ne(h())}),AS=$({...je.shape,...IS.shape,progressToken:ff}),$o=Ue.extend({method:P("notifications/progress"),params:AS}),MS=Ce.extend({cursor:mf.optional()}),tn=de.extend({params:MS.optional()}),rn=pe.extend({nextCursor:mf.optional()}),CS=ze(["working","input_required","completed","failed","cancelled"]),nn=$({taskId:h(),status:CS,ttl:Y([W(),rf()]),createdAt:h(),lastUpdatedAt:h(),pollInterval:ne(W()),statusMessage:ne(h())}),cr=pe.extend({task:nn}),NS=je.merge(nn),on=Ue.extend({method:P("notifications/tasks/status"),params:NS}),ko=de.extend({method:P("tasks/get"),params:Ce.extend({taskId:h()})}),xo=pe.merge(nn),Po=de.extend({method:P("tasks/result"),params:Ce.extend({taskId:h()})}),FT=pe.loose(),zo=tn.extend({method:P("tasks/list")}),To=rn.extend({tasks:D(nn)}),Ro=de.extend({method:P("tasks/cancel"),params:Ce.extend({taskId:h()})}),wf=pe.merge(nn),Ef=$({uri:h(),mimeType:ne(h()),_meta:K(h(),re()).optional()}),$f=Ef.extend({text:h()}),Ai=h().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),kf=Ef.extend({blob:Ai}),sn=ze(["user","assistant"]),ur=$({audience:D(sn).optional(),priority:W().min(0).max(1).optional(),lastModified:Br.datetime({offset:!0}).optional()}),xf=$({...ar.shape,...en.shape,uri:h(),description:ne(h()),mimeType:ne(h()),size:ne(W()),annotations:ur.optional(),_meta:ne(ke({}))}),DS=$({...ar.shape,...en.shape,uriTemplate:h(),description:ne(h()),mimeType:ne(h()),annotations:ur.optional(),_meta:ne(ke({}))}),LS=tn.extend({method:P("resources/list")}),jS=rn.extend({resources:D(xf)}),US=tn.extend({method:P("resources/templates/list")}),ZS=rn.extend({resourceTemplates:D(DS)}),Mi=Ce.extend({uri:h()}),FS=Mi,qS=de.extend({method:P("resources/read"),params:FS}),HS=pe.extend({contents:D(Y([$f,kf]))}),WS=Ue.extend({method:P("notifications/resources/list_changed"),params:je.optional()}),VS=Mi,GS=de.extend({method:P("resources/subscribe"),params:VS}),KS=Mi,JS=de.extend({method:P("resources/unsubscribe"),params:KS}),BS=je.extend({uri:h()}),YS=Ue.extend({method:P("notifications/resources/updated"),params:BS}),XS=$({name:h(),description:ne(h()),required:ne(ue())}),QS=$({...ar.shape,...en.shape,description:ne(h()),arguments:ne(D(XS)),_meta:ne(ke({}))}),ev=tn.extend({method:P("prompts/list")}),tv=rn.extend({prompts:D(QS)}),rv=Ce.extend({name:h(),arguments:K(h(),h()).optional()}),nv=de.extend({method:P("prompts/get"),params:rv}),Ci=$({type:P("text"),text:h(),annotations:ur.optional(),_meta:K(h(),re()).optional()}),Ni=$({type:P("image"),data:Ai,mimeType:h(),annotations:ur.optional(),_meta:K(h(),re()).optional()}),Di=$({type:P("audio"),data:Ai,mimeType:h(),annotations:ur.optional(),_meta:K(h(),re()).optional()}),ov=$({type:P("tool_use"),name:h(),id:h(),input:K(h(),re()),_meta:K(h(),re()).optional()}),sv=$({type:P("resource"),resource:Y([$f,kf]),annotations:ur.optional(),_meta:K(h(),re()).optional()}),iv=xf.extend({type:P("resource_link")}),Li=Y([Ci,Ni,Di,iv,sv]),av=$({role:sn,content:Li}),cv=pe.extend({description:h().optional(),messages:D(av)}),uv=Ue.extend({method:P("notifications/prompts/list_changed"),params:je.optional()}),lv=$({title:h().optional(),readOnlyHint:ue().optional(),destructiveHint:ue().optional(),idempotentHint:ue().optional(),openWorldHint:ue().optional()}),dv=$({taskSupport:ze(["required","optional","forbidden"]).optional()}),Pf=$({...ar.shape,...en.shape,description:h().optional(),inputSchema:$({type:P("object"),properties:K(h(),ce).optional(),required:D(h()).optional()}).catchall(re()),outputSchema:$({type:P("object"),properties:K(h(),ce).optional(),required:D(h()).optional()}).catchall(re()).optional(),annotations:lv.optional(),execution:dv.optional(),_meta:K(h(),re()).optional()}),ji=tn.extend({method:P("tools/list")}),pv=rn.extend({tools:D(Pf)}),Oo=pe.extend({content:D(Li).default([]),structuredContent:K(h(),re()).optional(),isError:ue().optional()}),qT=Oo.or(pe.extend({toolResult:re()})),fv=Xr.extend({name:h(),arguments:K(h(),re()).optional()}),an=de.extend({method:P("tools/call"),params:fv}),mv=Ue.extend({method:P("notifications/tools/list_changed"),params:je.optional()}),HT=$({autoRefresh:ue().default(!0),debounceMs:W().int().nonnegative().default(300)}),cn=ze(["debug","info","notice","warning","error","critical","alert","emergency"]),hv=Ce.extend({level:cn}),Ui=de.extend({method:P("logging/setLevel"),params:hv}),gv=je.extend({level:cn,logger:h().optional(),data:re()}),_v=Ue.extend({method:P("notifications/message"),params:gv}),yv=$({name:h().optional()}),Sv=$({hints:D(yv).optional(),costPriority:W().min(0).max(1).optional(),speedPriority:W().min(0).max(1).optional(),intelligencePriority:W().min(0).max(1).optional()}),vv=$({mode:ze(["auto","required","none"]).optional()}),bv=$({type:P("tool_result"),toolUseId:h().describe("The unique identifier for the corresponding tool call."),content:D(Li).default([]),structuredContent:$({}).loose().optional(),isError:ue().optional(),_meta:K(h(),re()).optional()}),wv=Ei("type",[Ci,Ni,Di]),yo=Ei("type",[Ci,Ni,Di,ov,bv]),Ev=$({role:sn,content:Y([yo,D(yo)]),_meta:K(h(),re()).optional()}),$v=Xr.extend({messages:D(Ev),modelPreferences:Sv.optional(),systemPrompt:h().optional(),includeContext:ze(["none","thisServer","allServers"]).optional(),temperature:W().optional(),maxTokens:W().int(),stopSequences:D(h()).optional(),metadata:ce.optional(),tools:D(Pf).optional(),toolChoice:vv.optional()}),kv=de.extend({method:P("sampling/createMessage"),params:$v}),un=pe.extend({model:h(),stopReason:ne(ze(["endTurn","stopSequence","maxTokens"]).or(h())),role:sn,content:wv}),Zi=pe.extend({model:h(),stopReason:ne(ze(["endTurn","stopSequence","maxTokens","toolUse"]).or(h())),role:sn,content:Y([yo,D(yo)])}),xv=$({type:P("boolean"),title:h().optional(),description:h().optional(),default:ue().optional()}),Pv=$({type:P("string"),title:h().optional(),description:h().optional(),minLength:W().optional(),maxLength:W().optional(),format:ze(["email","uri","date","date-time"]).optional(),default:h().optional()}),zv=$({type:ze(["number","integer"]),title:h().optional(),description:h().optional(),minimum:W().optional(),maximum:W().optional(),default:W().optional()}),Tv=$({type:P("string"),title:h().optional(),description:h().optional(),enum:D(h()),default:h().optional()}),Rv=$({type:P("string"),title:h().optional(),description:h().optional(),oneOf:D($({const:h(),title:h()})),default:h().optional()}),Ov=$({type:P("string"),title:h().optional(),description:h().optional(),enum:D(h()),enumNames:D(h()).optional(),default:h().optional()}),Iv=Y([Tv,Rv]),Av=$({type:P("array"),title:h().optional(),description:h().optional(),minItems:W().optional(),maxItems:W().optional(),items:$({type:P("string"),enum:D(h())}),default:D(h()).optional()}),Mv=$({type:P("array"),title:h().optional(),description:h().optional(),minItems:W().optional(),maxItems:W().optional(),items:$({anyOf:D($({const:h(),title:h()}))}),default:D(h()).optional()}),Cv=Y([Av,Mv]),Nv=Y([Ov,Iv,Cv]),Dv=Y([Nv,xv,Pv,zv]),Lv=Xr.extend({mode:P("form").optional(),message:h(),requestedSchema:$({type:P("object"),properties:K(h(),Dv),required:D(h()).optional()})}),jv=Xr.extend({mode:P("url"),message:h(),elicitationId:h(),url:h().url()}),Uv=Y([Lv,jv]),Zv=de.extend({method:P("elicitation/create"),params:Uv}),Fv=je.extend({elicitationId:h()}),qv=Ue.extend({method:P("notifications/elicitation/complete"),params:Fv}),lr=pe.extend({action:ze(["accept","decline","cancel"]),content:$i(t=>t===null?void 0:t,K(h(),Y([h(),W(),ue(),D(h())])).optional())}),Hv=$({type:P("ref/resource"),uri:h()});var Wv=$({type:P("ref/prompt"),name:h()}),Vv=Ce.extend({ref:Y([Wv,Hv]),argument:$({name:h(),value:h()}),context:$({arguments:K(h(),h()).optional()}).optional()}),Gv=de.extend({method:P("completion/complete"),params:Vv});var Kv=pe.extend({completion:ke({values:D(h()).max(100),total:ne(W().int()),hasMore:ne(ue())})}),Jv=$({uri:h().startsWith("file://"),name:h().optional(),_meta:K(h(),re()).optional()}),Bv=de.extend({method:P("roots/list"),params:Ce.optional()}),Fi=pe.extend({roots:D(Jv)}),Yv=Ue.extend({method:P("notifications/roots/list_changed"),params:je.optional()}),WT=Y([Eo,Oi,Gv,Ui,nv,ev,LS,US,qS,GS,JS,an,ji,ko,Po,zo,Ro]),VT=Y([wo,$o,Ii,Yv,on]),GT=Y([bo,un,Zi,lr,Fi,xo,To,cr]),KT=Y([Eo,kv,Zv,Bv,ko,Po,zo,Ro]),JT=Y([wo,$o,_v,YS,WS,mv,uv,on,qv]),BT=Y([bo,OS,Kv,cv,tv,jS,ZS,HS,Oo,pv,xo,To,cr]),O=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 ki(o.elicitations,r)}return new t(e,r,n)}},ki=class extends O{constructor(e,r=`URL elicitation${e.length>1?"s":""} required`){super(N.UrlElicitationRequired,r,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Pt(t){return t==="completed"||t==="failed"||t==="cancelled"}var TR=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function qi(t){let r=ho(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=Op(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Hi(t,e){let r=kt(t,e);if(!r.success)throw r.error;return r.data}var nb=6e4,Io=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(wo,r=>{this._oncancel(r)}),this.setNotificationHandler($o,r=>{this._onprogress(r)}),this.setRequestHandler(Eo,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ko,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new O(N.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(Po,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 O(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 O(N.InvalidParams,`Task not found: ${s}`);if(!Pt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Pt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[xt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(zo,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 O(N.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ro,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new O(N.InvalidParams,`Task not found: ${r.params.taskId}`);if(Pt(o.status))throw new O(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 O(N.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof O?o:new O(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),O.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),Qr(s)||Sf(s)?this._onresponse(s):zi(s)?this._onrequest(s,i):yf(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=O.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?.[xt]?.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=hf(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 O(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),Qr(e))n(e);else{let i=new O(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(Qr(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),Qr(e))o(e);else{let i=O.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 O?i:new O(N.InternalError,String(i))}}return}let s;try{let i=await this.request(e,cr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new O(N.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Pt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new O(N.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new O(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 O?i:new O(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=w=>{l(w)};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(w){d(w);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||{},[xt]:c}});let m=w=>{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(w)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));let v=w instanceof O?w:new O(N.RequestTimeout,String(w));l(v)};this._responseHandlers.set(p,w=>{if(!n?.signal?.aborted){if(w instanceof Error)return l(w);try{let v=kt(r,w.result);v.success?u(v.data):l(v.error)}catch(v){l(v)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let _=n?.timeout??nb,y=()=>m(O.fromError(N.RequestTimeout,"Request timed out",{timeout:_}));this._setupTimeout(p,_,n?.maxTotalTimeout,y,n?.resetTimeoutOnProgress??!1);let b=c?.taskId;if(b){let w=v=>{let x=this._responseHandlers.get(p);x?x(v):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`))};this._requestResolvers.set(p,w),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(w=>{this._cleanupTimeout(p),l(w)})})}async getTask(e,r){return this.request({method:"tasks/get",params:e},xo,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},To,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},wf,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||{},[xt]: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||{},[xt]: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||{},[xt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=qi(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=Hi(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=qi(e);this._notificationHandlers.set(n,o=>{let s=Hi(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"&&zi(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new O(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 O(N.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new O(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 O(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=on.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Pt(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 O(N.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Pt(a.status))throw new O(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=on.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Pt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function zf(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Tf(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];zf(i)&&zf(s)?r[o]={...i,...s}:r[o]=s}return r}var vg=vt(Rc(),1),bg=vt(Sg(),1);function ix(){let t=new vg.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,bg.default)(t),t}var fs=class{constructor(e){this._ajv=e??ix()}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 ms=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},un,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},lr,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 wg(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 Eg(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 hs=class extends Io{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(cn.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 fs,this.setRequestHandler(Oi,n=>this._oninitialize(n)),this.setNotificationHandler(Ii,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Ui,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=cn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new ms(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Tf(this._capabilities,e)}setRequestHandler(e,r){let o=ho(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(ir(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=kt(an,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new O(N.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,p=await Promise.resolve(r(c,u));if(d.task){let m=kt(cr,p);if(!m.success){let _=m.error instanceof Error?m.error.message:String(m.error);throw new O(N.InvalidParams,`Invalid task creation result: ${_}`)}return m.data}let f=kt(Oo,p);if(!f.success){let m=f.error instanceof Error?f.error.message:String(f.error);throw new O(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){Eg(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&wg(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:pf.includes(r)?r:xi,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"},bo)}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},Zi,r):this.request({method:"sampling/createMessage",params:e},un,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},lr,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},lr,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new O(N.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof O?i:new O(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},Fi,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 Lc=vt(require("node:process"),1);var gs=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),ax(r)}clear(){this._buffer=void 0}};function ax(t){return vf.parse(JSON.parse(t))}function $g(t){return JSON.stringify(t)+`
82
- `}var _s=class{constructor(e=Lc.default.stdin,r=Lc.default.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new gs,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=$g(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Gc=vt(require("path"),1);var kg=require("node:child_process");function ys(t,e,r){return(0,kg.spawn)(t,e??[],{windowsHide:!0,...r})}var be={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 Ss(t){return process.platform==="win32"?Math.round(t*be.WINDOWS_MULTIPLIER):t}var it=require("fs"),Un=require("path"),jc=require("os"),at=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_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_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,Un.join)((0,jc.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,Un.join)((0,jc.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",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_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"};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){try{if(!(0,it.existsSync)(e)){let i=this.getAllDefaults();try{let a=(0,Un.dirname)(e);(0,it.existsSync)(a)||(0,it.mkdirSync)(a,{recursive:!0}),(0,it.writeFileSync)(e,JSON.stringify(i,null,2),"utf-8"),console.log("[SETTINGS] Created settings file with defaults:",e)}catch(a){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,a instanceof Error?a.message:String(a))}return this.applyEnvOverrides(i)}let r=(0,it.readFileSync)(e,"utf-8"),n=JSON.parse(r),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{(0,it.writeFileSync)(e,JSON.stringify(o,null,2),"utf-8"),console.log("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(i){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,i instanceof Error?i.message:String(i))}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))o[i]!==void 0&&(s[i]=o[i]);return this.applyEnvOverrides(s)}catch(r){return console.warn("[SETTINGS] Failed to load settings, using defaults:",e,r instanceof Error?r.message:String(r)),this.applyEnvOverrides(this.getAllDefaults())}}};var Yt=require("fs");var xg=require("child_process");var ut=require("fs"),qc=vt(require("path"),1);var cx=["CLAUDECODE_","CLAUDE_CODE_"],ux=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),lx=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"]),dx=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 Uc(t=process.env){let e={};for(let[r,n]of Object.entries(t))if(n!==void 0){if(dx.has(r)){e[r]=n;continue}ux.has(r)||lx.has(r)||cx.some(o=>r.startsWith(o))||(e[r]=n)}return e}var px=5e3,fx=1e3,mx=De.supervisorRegistry();function ct(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:(S.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return S.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}function Pg(t){if(!Number.isInteger(t)||t<=0)return null;if(process.platform==="linux")try{let e=(0,ut.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 S.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return null;try{let e=(0,xg.spawnSync)("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...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 S.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function Wc(t){if(!t||!ct(t.pid))return!1;if(!t.startToken)return!0;let e=Pg(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||S.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}var Hc=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=mx){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,ut.mkdirSync)(qc.default.dirname(this.registryPath),{recursive:!0}),!(0,ut.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,ut.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?S.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):S.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&S.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"&&Fc()}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)ct(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)Fc();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;S.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:n,pids:r.map(a=>a.pid)});let o=r.filter(a=>ct(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"&&S.debug("SYSTEM",`Failed to SIGTERM session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):S.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()+px;for(;Date.now()<s&&o.filter(c=>ct(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100));let i=o.filter(a=>ct(a.pid));for(let a of i){S.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"&&S.debug("SYSTEM",`Failed to SIGKILL session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):S.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()+fx;for(;Date.now()<a&&i.filter(u=>ct(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"&&Fc();return S.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,ut.mkdirSync)(qc.default.dirname(this.registryPath),{recursive:!0}),(0,ut.writeFileSync)(this.registryPath,JSON.stringify(e,null,2))}},Zc=null;function vs(){return Zc||(Zc=new Hc),Zc}var hx=[];function Fc(){let t=hx.shift();t&&t()}var Rg=require("child_process"),Og=require("fs"),Ig=require("util");var gx=(0,Ig.promisify)(Rg.execFile),_x=De.workerPid();async function Ag(t){let e=t.currentPid??process.pid,r=t.pidFilePath??_x,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(!ct(i.pid)){t.registry.unregister(i.id);continue}try{await Tg(i,"SIGTERM")}catch(a){a instanceof Error?S.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):S.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}}await zg(o,5e3);let s=o.filter(i=>ct(i.pid));for(let i of s)try{await Tg(i,"SIGKILL")}catch(a){a instanceof Error?S.debug("SYSTEM","Failed to force kill child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):S.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}await zg(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);try{(0,Og.rmSync)(r,{force:!0})}catch(i){i instanceof Error?S.debug("SYSTEM","Failed to remove PID file during shutdown",{pidFilePath:r},i):S.warn("SYSTEM","Failed to remove PID file during shutdown (non-Error)",{pidFilePath:r,error:String(i)})}t.registry.pruneDeadEntries()}async function zg(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.filter(o=>ct(o.pid)).length===0)return;await new Promise(o=>setTimeout(o,100))}}async function Tg(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 yx();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 gx("taskkill",s,{timeout:be.POWERSHELL_COMMAND,windowsHide:!0})}async function yx(){let t="tree-kill";try{let e=await import(t);return e.default??e}catch(e){return S.debug("SYSTEM","tree-kill module not available, using fallback",{},e instanceof Error?e:void 0),null}}var Mg=3e4,Tr=null;function Sx(){let e=vs().pruneDeadEntries();e>0&&S.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function Cg(){Tr===null&&(Tr=setInterval(Sx,Mg),Tr.unref(),S.debug("SYSTEM","Health checker started",{intervalMs:Mg}))}function Ng(){Tr!==null&&(clearInterval(Tr),Tr=null,S.debug("SYSTEM","Health checker stopped"))}var vx=De.workerPid(),Vc=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(),bs({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,Cg()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){S.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,S.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?S.error("SYSTEM","Error during shutdown",{},o):S.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?S.debug("SYSTEM","Supervisor shutdown fallback failed",{},s):S.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",()=>{S.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}Ng(),this.stopPromise=Ag({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}},bx=new Vc(vs());function Dg(){return bx}function bs(t={}){let e=t.pidFilePath??vx;if(!(0,Yt.existsSync)(e))return"missing";let r=null;try{r=JSON.parse((0,Yt.readFileSync)(e,"utf-8"))}catch(o){return o instanceof Error?S.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},o):S.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(o)}),(0,Yt.rmSync)(e,{force:!0}),"invalid"}return Wc(r)&&r?((t.logAlive??!0)&&S.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(S.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,Yt.rmSync)(e,{force:!0}),"stale")}function Kc(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;S.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max})}return e}var UC=Kc("CLAUDE_MEM_HEALTH_TIMEOUT_MS",Ss(be.HEALTH_CHECK),{min:500,max:3e5}),wx=Kc("CLAUDE_MEM_API_TIMEOUT_MS",Ss(be.API_REQUEST),{min:500,max:3e5}),ZC=Kc("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",Ss(be.HOOK_READINESS_WAIT),{min:0,max:3e5});function Ex(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 ws=null,Es=null;function Jc(){if(ws!==null)return ws;let t=Gc.default.join(at.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),e=at.loadFromFile(t);return ws=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),ws}function $x(){if(Es!==null)return Es;let t=Gc.default.join(at.get("CLAUDE_MEM_DATA_DIR"),"settings.json");return Es=at.loadFromFile(t).CLAUDE_MEM_WORKER_HOST,Es}function kx(t){return`http://${$x()}:${Jc()}${t}`}function $s(t,e={}){let r=e.method??"GET",n=e.timeoutMs??wx,o=kx(t),s={method:r};return e.headers&&(s.headers=e.headers),e.body&&(s.body=e.body),n>0?Ex(o,s,n):fetch(o,s)}var Yc=vt(require("path"),1),We=require("fs");var Xt=vt(require("path"),1),Ug=require("os"),Ne=require("fs"),Rr=require("child_process");var Zg=require("util");var JC=(0,Zg.promisify)(Rr.exec),BC=De.dataDir(),Lg=De.workerPid();function jg(t){return t?/(^|[\\/])bun(\.exe)?$/i.test(t.trim()):!1}function xx(t,e){let r=e==="win32"?`where ${t}`:`which ${t}`,n;try{n=(0,Rr.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?S.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},s):S.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 Bc;function Px(t={}){let e=Object.keys(t).length===0;if(e&&Bc!==void 0)return Bc;let r=zx(t);return e&&r!==null&&(Bc=r),r}function zx(t){let e=t.platform??process.platform,r=t.execPath??process.execPath;if(jg(r))return r;let n=t.env??process.env,o=t.homeDirectory??(0,Ug.homedir)(),s=t.pathExists??Ne.existsSync,i=t.lookupInPath??xx,a=e==="win32"?[n.BUN,n.BUN_PATH,Xt.default.join(o,".bun","bin","bun.exe"),Xt.default.join(o,".bun","bin","bun"),n.USERPROFILE?Xt.default.join(n.USERPROFILE,".bun","bin","bun.exe"):void 0,n.LOCALAPPDATA?Xt.default.join(n.LOCALAPPDATA,"bun","bun.exe"):void 0,n.LOCALAPPDATA?Xt.default.join(n.LOCALAPPDATA,"bun","bin","bun.exe"):void 0]:[n.BUN,n.BUN_PATH,Xt.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&&(jg(u)&&s(u)||u.toLowerCase()==="bun"))return u}return i("bun",e)}function Nt(t){return process.platform==="win32"?Math.round(t*2):t}function Fg(t,e,r={}){Dg().assertCanSpawn("worker daemon");let n=Uc({...process.env,CLAUDE_MEM_WORKER_PORT:String(e),...r}),o=Px();if(!o){S.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,Rr.execSync)(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:n}),0}catch(p){S.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=ys(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 qg(){try{if(!(0,Ne.existsSync)(Lg))return;let t=new Date;(0,Ne.utimesSync)(Lg,t,t)}catch{}}function Hg(){return bs({logAlive:!1})}var Wg=vt(require("net"),1);async function Tx(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 Vg(t){if(process.platform==="win32")try{return(await fetch(`http://127.0.0.1:${t}/api/health`)).ok}catch(e){return e instanceof Error?S.debug("SYSTEM","Windows health check failed (port not in use)",{},e):S.debug("SYSTEM","Windows health check failed (port not in use)",{error:String(e)}),!1}return new Promise(e=>{let r=Wg.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 Gg(t,e,r,n){let o=Date.now();for(;Date.now()-o<r;){try{if((await Tx(t,e)).ok)return!0}catch(s){s instanceof Error?S.debug("SYSTEM",n,{},s):S.debug("SYSTEM",n,{error:String(s)})}await new Promise(s=>setTimeout(s,500))}return!1}function Zn(t,e=3e4){return Gg(t,"/api/health",e,"Service not ready yet, will retry")}function Fn(t,e=3e4){return Gg(t,"/api/readiness",e,"Worker not ready yet, will retry")}var Rx=120*1e3;function Xc(){return Yc.default.join(at.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function Ox(){if(process.platform!=="win32")return!1;let t=Xc();if(!(0,We.existsSync)(t))return!1;try{let e=(0,We.statSync)(t).mtimeMs;return Date.now()-e<Rx}catch(e){return e instanceof Error?S.debug("SYSTEM","Could not stat worker spawn lock file",{},e):S.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(e)}),!1}}function Ix(){if(process.platform==="win32")try{let t=Xc();(0,We.mkdirSync)(Yc.default.dirname(t),{recursive:!0}),(0,We.writeFileSync)(t,"","utf-8")}catch{}}function ks(){if(process.platform==="win32")try{let t=Xc();(0,We.existsSync)(t)&&(0,We.unlinkSync)(t)}catch{}}async function Kg(t,e){if(!e)return S.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,We.existsSync)(e))return S.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:e}),"dead";if(Hg()==="alive"){if(S.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await Zn(t,Nt(be.PORT_IN_USE_WAIT))){ks();let c=await Fn(t,Nt(be.READINESS_WAIT));return S.info("SYSTEM","Worker became healthy while waiting on live PID"),c?"ready":"warming"}return S.warn("SYSTEM","Live PID detected but worker did not become healthy before timeout \u2014 likely still starting"),"warming"}if(await Zn(t,1e3)){ks();let a=await Fn(t,Nt(be.READINESS_WAIT));return a||S.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),S.info("SYSTEM","Worker already running and healthy"),a?"ready":"warming"}if(await Vg(t)){if(S.info("SYSTEM","Port in use, waiting for worker to become healthy"),await Zn(t,Nt(be.PORT_IN_USE_WAIT))){ks();let c=await Fn(t,Nt(be.READINESS_WAIT));return S.info("SYSTEM","Worker is now healthy"),c?"ready":"warming"}return S.error("SYSTEM","Port in use but worker not responding to health checks"),"dead"}if(Ox())return S.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";if(S.info("SYSTEM","Starting worker daemon",{workerScriptPath:e}),Ix(),Fg(e,t)===void 0)return S.error("SYSTEM","Failed to spawn worker daemon"),"dead";if(!await Zn(t,Nt(be.POST_SPAWN_WAIT)))return S.warn("SYSTEM","Worker spawned but health endpoint not responding within window \u2014 likely still starting in background"),"warming";let i=await Fn(t,Nt(be.READINESS_WAIT));return i||S.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),ks(),qg(),S.info("SYSTEM","Worker started successfully"),i?"ready":"warming"}var Ar=require("node:fs/promises"),Vn=require("node:path");var Yg=require("node:child_process"),we=require("node:fs"),ge=require("node:path"),ou=require("node:os"),tu=require("node:module");var Vx={},ru=typeof __filename<"u"?(0,tu.createRequire)(__filename):(0,tu.createRequire)(Vx.url),nu={".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 Xg(t,e){let r=t.slice(t.lastIndexOf("."));return nu[r]?nu[r]:e.extensionToLanguage[r]?e.extensionToLanguage[r]:"unknown"}function Qg(t,e){return e.languageToQueryKey[t]?e.languageToQueryKey[t]:Cx(t)}var qn=new Map,Or={grammars:{},extensionToLanguage:{},languageToQueryKey:{}};function Wn(t){if(qn.has(t))return qn.get(t);let e=(0,ge.join)(t,".claude-mem.json"),r;try{let s=(0,we.readFileSync)(e,"utf-8");r=JSON.parse(s)}catch{return qn.set(t,Or),Or}let n=r.grammars;if(!n||typeof n!="object"||Array.isArray(n))return qn.set(t,Or),Or;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)nu[d]||(o.extensionToLanguage[d]=s);if(typeof l=="string"){let d=(0,ge.join)(t,l);try{let p=(0,we.readFileSync)(d,"utf-8"),f=`user_${s}`;r_[f]=p,o.languageToQueryKey[s]=f}catch{console.error(`[smart-file-read] Custom query file not found: ${d}, falling back to generic`),o.languageToQueryKey[s]="generic"}}else o.languageToQueryKey[s]="generic"}}return qn.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"},Ax={markdown:"tree-sitter-markdown"};function Mx(t){let e=e_[t];if(!e)return null;let r=Ax[t];if(r){try{let n=ru.resolve(e+"/package.json"),o=(0,ge.join)((0,ge.dirname)(n),r);if((0,we.existsSync)((0,ge.join)(o,"src")))return o}catch{}return null}try{let n=ru.resolve(e+"/package.json");return(0,ge.dirname)(n)}catch{return null}}function t_(t,e){let r=Mx(t);if(r)return r;if(!e)return null;let o=Wn(e).grammars[t];if(!o)return null;try{let s=(0,ge.join)(e,"node_modules",o.package,"package.json");if((0,we.existsSync)(s)){let i=(0,ge.dirname)(s);if((0,we.existsSync)((0,ge.join)(i,"src")))return i}}catch{}return console.error(`[smart-file-read] Grammar package not found for "${t}": ${o.package} (install it in your project's node_modules)`),null}var r_={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 wi(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 y in u)y==="$ref"||y==="allOf"||y in l||delete u[y];if(m.$ref&&f.def)for(let y in u)y==="$ref"||y==="allOf"||y in f.def&&JSON.stringify(u[y])===JSON.stringify(f.def[y])&&delete u[y]}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:Jr(e,"input",t.processors),output:Jr(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 yp=(t,e={})=>r=>{let n=bi({...r,processors:e});return se(t,n),Ei(n,t),wi(n,t)},Jr=(t,e,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=bi({...o??{},target:s,io:e,processors:r});return se(t,i),Ei(i,t),wi(i,t)};var Ay={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Sp=(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=Ay[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}))])}},vp=(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)},bp=(t,e,r,n)=>{r.type="boolean"};var Ep=(t,e,r,n)=>{e.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var wp=(t,e,r,n)=>{r.not={}};var kp=(t,e,r,n)=>{};var $p=(t,e,r,n)=>{let o=t._zod.def,s=Ur(o.entries);s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},xp=(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 Pp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")};var Tp=(t,e,r,n)=>{if(e.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")};var zp=(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"]})},Rp=(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)},Ip=(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},Op=(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 Ap=(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)}},Mp=(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"}]},Cp=(t,e,r,n)=>{let o=t._zod.def;se(o.innerType,e,n);let s=e.seen.get(t);s.ref=o.innerType},Np=(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))},Dp=(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)))},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;let i;try{i=o.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=i},Lp=(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},Up=(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 ki=(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 ar(t){return!!t._zod}function xt(t,e){return ar(t)?Vr(t,e):t.safeParse(e)}function vo(t){if(!t)return;let e;if(ar(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function qp(t){if(ar(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 Xr={};yu(Xr,{ZodISODate:()=>Fp,ZodISODateTime:()=>Zp,ZodISODuration:()=>Vp,ZodISOTime:()=>Hp,date:()=>xi,datetime:()=>$i,duration:()=>Ti,time:()=>Pi});var Zp=g("ZodISODateTime",(t,e)=>{Yl.init(t,e),te.init(t,e)});function $i(t){return op(Zp,t)}var Fp=g("ZodISODate",(t,e)=>{Xl.init(t,e),te.init(t,e)});function xi(t){return sp(Fp,t)}var Hp=g("ZodISOTime",(t,e)=>{Ql.init(t,e),te.init(t,e)});function Pi(t){return ip(Hp,t)}var Vp=g("ZodISODuration",(t,e)=>{ed.init(t,e),te.init(t,e)});function Ti(t){return ap(Vp,t)}var Zy=(t,e)=>{so.init(t,e),t.name="ZodError",Object.defineProperties(t,{format:{value:r=>Mu(t,r)},flatten:{value:r=>Au(t,r)},addIssue:{value:r=>{t.issues.push(r),t.message=JSON.stringify(t.issues,nr,2)}},addIssues:{value:r=>{t.issues.push(...r),t.message=JSON.stringify(t.issues,nr,2)}},isEmpty:{get(){return t.issues.length===0}}})};var Me=g("ZodError",Zy,{Parent:Error});var Wp=io(Me),Bp=ao(Me),Kp=Hr(Me),Gp=Wr(Me),Jp=Cu(Me),Yp=Nu(Me),Xp=Du(Me),Qp=ju(Me),ef=Lu(Me),tf=Uu(Me),rf=qu(Me),nf=Zu(Me);var of=new WeakMap;function Qr(t,e,r){let n=Object.getPrototypeOf(t),o=of.get(n);if(o||(o=new Set,of.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:Jr(t,"input"),output:Jr(t,"output")}}),t.toJSONSchema=yp(t,{}),t.def=e,t.type=e.type,Object.defineProperty(t,"_def",{value:e}),t.parse=(r,n)=>Wp(t,r,n,{callee:t.parse}),t.safeParse=(r,n)=>Kp(t,r,n),t.parseAsync=async(r,n)=>Bp(t,r,n,{callee:t.parseAsync}),t.safeParseAsync=async(r,n)=>Gp(t,r,n),t.spa=t.safeParseAsync,t.encode=(r,n)=>Jp(t,r,n),t.decode=(r,n)=>Yp(t,r,n),t.encodeAsync=async(r,n)=>Xp(t,r,n),t.decodeAsync=async(r,n)=>Qp(t,r,n),t.safeEncode=(r,n)=>ef(t,r,n),t.safeDecode=(r,n)=>tf(t,r,n),t.safeEncodeAsync=async(r,n)=>rf(t,r,n),t.safeDecodeAsync=async(r,n)=>nf(t,r,n),Qr(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 Ke(this,r,n)},brand(){return this},register(r,n){return r.add(this,n),this},refine(r,n){return this.check(OS(r,n))},superRefine(r,n){return this.check(AS(r,n))},overwrite(r){return this.check($t(r))},optional(){return ne(this)},exactOptional(){return vS(this)},nullable(){return uf(this)},nullish(){return ne(uf(this))},nonoptional(r){return xS(this,r)},array(){return D(this)},or(r){return Y([this,r])},and(r){return Eo(this,r)},transform(r){return lf(this,gf(r))},default(r){return wS(this,r)},prefault(r){return $S(this,r)},catch(r){return TS(this,r)},pipe(r){return lf(this,r)},readonly(){return IS(this)},describe(r){let n=this.clone();return Ut.add(n,{description:r}),n},meta(...r){if(r.length===0)return Ut.get(this);let n=this.clone();return Ut.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 Ut.get(t)?.description},configurable:!0}),t)),df=g("_ZodString",(t,e)=>{mo.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>Sp(t,n,o,s);let r=t._zod.bag;t.format=r.format??null,t.minLength=r.minimum??null,t.maxLength=r.maximum??null,Qr(t,"_ZodString",{regex(...n){return this.check(li(...n))},includes(...n){return this.check(fi(...n))},startsWith(...n){return this.check(mi(...n))},endsWith(...n){return this.check(hi(...n))},min(...n){return this.check(ir(...n))},max(...n){return this.check(yo(...n))},length(...n){return this.check(So(...n))},nonempty(...n){return this.check(ir(1,...n))},lowercase(n){return this.check(di(n))},uppercase(n){return this.check(pi(n))},trim(){return this.check(_i())},normalize(...n){return this.check(gi(...n))},toLowerCase(){return this.check(yi())},toUpperCase(){return this.check(Si())},slugify(){return this.check(vi())}})}),Hy=g("ZodString",(t,e)=>{mo.init(t,e),df.init(t,e),t.email=r=>t.check(Dd(Vy,r)),t.url=r=>t.check(Zd(Wy,r)),t.jwt=r=>t.check(np(aS,r)),t.emoji=r=>t.check(Fd(By,r)),t.guid=r=>t.check(ui(sf,r)),t.uuid=r=>t.check(jd(bo,r)),t.uuidv4=r=>t.check(Ld(bo,r)),t.uuidv6=r=>t.check(Ud(bo,r)),t.uuidv7=r=>t.check(qd(bo,r)),t.nanoid=r=>t.check(Hd(Ky,r)),t.guid=r=>t.check(ui(sf,r)),t.cuid=r=>t.check(Vd(Gy,r)),t.cuid2=r=>t.check(Wd(Jy,r)),t.ulid=r=>t.check(Bd(Yy,r)),t.base64=r=>t.check(ep(oS,r)),t.base64url=r=>t.check(tp(sS,r)),t.xid=r=>t.check(Kd(Xy,r)),t.ksuid=r=>t.check(Gd(Qy,r)),t.ipv4=r=>t.check(Jd(eS,r)),t.ipv6=r=>t.check(Yd(tS,r)),t.cidrv4=r=>t.check(Xd(rS,r)),t.cidrv6=r=>t.check(Qd(nS,r)),t.e164=r=>t.check(rp(iS,r)),t.datetime=r=>t.check($i(r)),t.date=r=>t.check(xi(r)),t.time=r=>t.check(Pi(r)),t.duration=r=>t.check(Ti(r))});function h(t){return Nd(Hy,t)}var te=g("ZodStringFormat",(t,e)=>{J.init(t,e),df.init(t,e)}),Vy=g("ZodEmail",(t,e)=>{Zl.init(t,e),te.init(t,e)});var sf=g("ZodGUID",(t,e)=>{Ul.init(t,e),te.init(t,e)});var bo=g("ZodUUID",(t,e)=>{ql.init(t,e),te.init(t,e)});var Wy=g("ZodURL",(t,e)=>{Fl.init(t,e),te.init(t,e)});var By=g("ZodEmoji",(t,e)=>{Hl.init(t,e),te.init(t,e)});var Ky=g("ZodNanoID",(t,e)=>{Vl.init(t,e),te.init(t,e)});var Gy=g("ZodCUID",(t,e)=>{Wl.init(t,e),te.init(t,e)});var Jy=g("ZodCUID2",(t,e)=>{Bl.init(t,e),te.init(t,e)});var Yy=g("ZodULID",(t,e)=>{Kl.init(t,e),te.init(t,e)});var Xy=g("ZodXID",(t,e)=>{Gl.init(t,e),te.init(t,e)});var Qy=g("ZodKSUID",(t,e)=>{Jl.init(t,e),te.init(t,e)});var eS=g("ZodIPv4",(t,e)=>{td.init(t,e),te.init(t,e)});var tS=g("ZodIPv6",(t,e)=>{rd.init(t,e),te.init(t,e)});var rS=g("ZodCIDRv4",(t,e)=>{nd.init(t,e),te.init(t,e)});var nS=g("ZodCIDRv6",(t,e)=>{od.init(t,e),te.init(t,e)});var oS=g("ZodBase64",(t,e)=>{id.init(t,e),te.init(t,e)});var sS=g("ZodBase64URL",(t,e)=>{ad.init(t,e),te.init(t,e)});var iS=g("ZodE164",(t,e)=>{cd.init(t,e),te.init(t,e)});var aS=g("ZodJWT",(t,e)=>{ud.init(t,e),te.init(t,e)});var pf=g("ZodNumber",(t,e)=>{oi.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>vp(t,n,o,s),Qr(t,"ZodNumber",{gt(n,o){return this.check(go(n,o))},gte(n,o){return this.check(Gr(n,o))},min(n,o){return this.check(Gr(n,o))},lt(n,o){return this.check(ho(n,o))},lte(n,o){return this.check(Kr(n,o))},max(n,o){return this.check(Kr(n,o))},int(n){return this.check(af(n))},safe(n){return this.check(af(n))},positive(n){return this.check(go(0,n))},nonnegative(n){return this.check(Gr(0,n))},negative(n){return this.check(ho(0,n))},nonpositive(n){return this.check(Kr(0,n))},multipleOf(n,o){return this.check(_o(n,o))},step(n,o){return this.check(_o(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 V(t){return cp(pf,t)}var cS=g("ZodNumberFormat",(t,e)=>{ld.init(t,e),pf.init(t,e)});function af(t){return up(cS,t)}var uS=g("ZodBoolean",(t,e)=>{dd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>bp(t,r,n,o)});function ue(t){return lp(uS,t)}var lS=g("ZodNull",(t,e)=>{pd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ep(t,r,n,o)});function ff(t){return dp(lS,t)}var dS=g("ZodUnknown",(t,e)=>{fd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>kp(t,r,n,o)});function re(){return pp(dS)}var pS=g("ZodNever",(t,e)=>{md.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>wp(t,r,n,o)});function fS(t){return fp(pS,t)}var mS=g("ZodArray",(t,e)=>{hd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>zp(t,r,n,o),t.element=e.element,Qr(t,"ZodArray",{min(r,n){return this.check(ir(r,n))},nonempty(r){return this.check(ir(1,r))},max(r,n){return this.check(yo(r,n))},length(r,n){return this.check(So(r,n))},unwrap(){return this.element}})});function D(t,e){return mp(mS,t,e)}var mf=g("ZodObject",(t,e)=>{yd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Rp(t,r,n,o),U.defineLazy(t,"shape",()=>e.shape),Qr(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:fS()})},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(_f,this,r[0])},required(...r){return U.required(yf,this,r[0])}})});function k(t,e){let r={type:"object",shape:t??{},...U.normalizeParams(e)};return new mf(r)}function $e(t,e){return new mf({type:"object",shape:t,catchall:re(),...U.normalizeParams(e)})}var hf=g("ZodUnion",(t,e)=>{si.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ip(t,r,n,o),t.options=e.options});function Y(t,e){return new hf({type:"union",options:t,...U.normalizeParams(e)})}var hS=g("ZodDiscriminatedUnion",(t,e)=>{hf.init(t,e),Sd.init(t,e)});function Ri(t,e,r){return new hS({type:"union",options:e,discriminator:t,...U.normalizeParams(r)})}var gS=g("ZodIntersection",(t,e)=>{vd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Op(t,r,n,o)});function Eo(t,e){return new gS({type:"intersection",left:t,right:e})}var cf=g("ZodRecord",(t,e)=>{bd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Ap(t,r,n,o),t.keyType=e.keyType,t.valueType=e.valueType});function K(t,e,r){return!e||!e._zod?new cf({type:"record",keyType:h(),valueType:t,...U.normalizeParams(e)}):new cf({type:"record",keyType:t,valueType:e,...U.normalizeParams(r)})}var zi=g("ZodEnum",(t,e)=>{Ed.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(n,o,s)=>$p(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 zi({...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 zi({...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 zi({type:"enum",entries:r,...U.normalizeParams(e)})}var _S=g("ZodLiteral",(t,e)=>{wd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>xp(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 _S({type:"literal",values:Array.isArray(t)?t:[t],...U.normalizeParams(e)})}var yS=g("ZodTransform",(t,e)=>{kd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Tp(t,r,n,o),t._zod.parse=(r,n)=>{if(n.direction==="backward")throw new tr(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 gf(t){return new yS({type:"transform",transform:t})}var _f=g("ZodOptional",(t,e)=>{ii.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ki(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function ne(t){return new _f({type:"optional",innerType:t})}var SS=g("ZodExactOptional",(t,e)=>{$d.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>ki(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function vS(t){return new SS({type:"optional",innerType:t})}var bS=g("ZodNullable",(t,e)=>{xd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Mp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function uf(t){return new bS({type:"nullable",innerType:t})}var ES=g("ZodDefault",(t,e)=>{Pd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Np(t,r,n,o),t.unwrap=()=>t._zod.def.innerType,t.removeDefault=t.unwrap});function wS(t,e){return new ES({type:"default",innerType:t,get defaultValue(){return typeof e=="function"?e():U.shallowClone(e)}})}var kS=g("ZodPrefault",(t,e)=>{Td.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Dp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function $S(t,e){return new kS({type:"prefault",innerType:t,get defaultValue(){return typeof e=="function"?e():U.shallowClone(e)}})}var yf=g("ZodNonOptional",(t,e)=>{zd.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Cp(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function xS(t,e){return new yf({type:"nonoptional",innerType:t,...U.normalizeParams(e)})}var PS=g("ZodCatch",(t,e)=>{Rd.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.removeCatch=t.unwrap});function TS(t,e){return new PS({type:"catch",innerType:t,catchValue:typeof e=="function"?e:()=>e})}var Sf=g("ZodPipe",(t,e)=>{ai.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Lp(t,r,n,o),t.in=e.in,t.out=e.out});function lf(t,e){return new Sf({type:"pipe",in:t,out:e})}var zS=g("ZodPreprocess",(t,e)=>{Sf.init(t,e),Id.init(t,e)}),RS=g("ZodReadonly",(t,e)=>{Od.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Up(t,r,n,o),t.unwrap=()=>t._zod.def.innerType});function IS(t){return new RS({type:"readonly",innerType:t})}var vf=g("ZodCustom",(t,e)=>{Ad.init(t,e),oe.init(t,e),t._zod.processJSONSchema=(r,n,o)=>Pp(t,r,n,o)});function bf(t,e){return hp(vf,t??(()=>!0),e)}function OS(t,e={}){return gp(vf,t,e)}function AS(t,e){return _p(t,e)}function Ii(t,e){return new zS({type:"pipe",in:gf(t),out:e})}Ae(Md());var Ai="2025-11-25";var Ef=[Ai,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Pt="io.modelcontextprotocol/related-task",ko="2.0",ce=bf(t=>t!==null&&(typeof t=="object"||typeof t=="function")),wf=Y([h(),V().int()]),kf=h(),sR=$e({ttl:V().optional(),pollInterval:V().optional()}),MS=k({ttl:V().optional()}),CS=k({taskId:h()}),Mi=$e({progressToken:wf.optional(),[Pt]:CS.optional()}),Ce=k({_meta:Mi.optional()}),en=Ce.extend({task:MS.optional()}),$f=t=>en.safeParse(t).success,pe=k({method:h(),params:Ce.loose().optional()}),Le=k({_meta:Mi.optional()}),Ue=k({method:h(),params:Le.loose().optional()}),fe=$e({_meta:Mi.optional()}),$o=Y([h(),V().int()]),xf=k({jsonrpc:P(ko),id:$o,...pe.shape}).strict(),Ci=t=>xf.safeParse(t).success,Pf=k({jsonrpc:P(ko),...Ue.shape}).strict(),Tf=t=>Pf.safeParse(t).success,Ni=k({jsonrpc:P(ko),id:$o,result:fe}).strict(),tn=t=>Ni.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 Di=k({jsonrpc:P(ko),id:$o.optional(),error:k({code:V().int(),message:h(),data:re().optional()})}).strict();var zf=t=>Di.safeParse(t).success;var Rf=Y([xf,Pf,Ni,Di]),iR=Y([Ni,Di]),xo=fe.strict(),NS=Le.extend({requestId:$o.optional(),reason:h().optional()}),Po=Ue.extend({method:P("notifications/cancelled"),params:NS}),DS=k({src:h(),mimeType:h().optional(),sizes:D(h()).optional(),theme:Te(["light","dark"]).optional()}),rn=k({icons:D(DS).optional()}),cr=k({name:h(),title:h().optional()}),If=cr.extend({...cr.shape,...rn.shape,version:h(),websiteUrl:h().optional(),description:h().optional()}),jS=Eo(k({applyDefaults:ue().optional()}),K(h(),re())),LS=Ii(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,Eo(k({form:jS.optional(),url:ce.optional()}),K(h(),re()).optional())),US=$e({list:ce.optional(),cancel:ce.optional(),requests:$e({sampling:$e({createMessage:ce.optional()}).optional(),elicitation:$e({create:ce.optional()}).optional()}).optional()}),qS=$e({list:ce.optional(),cancel:ce.optional(),requests:$e({tools:$e({call:ce.optional()}).optional()}).optional()}),ZS=k({experimental:K(h(),ce).optional(),sampling:k({context:ce.optional(),tools:ce.optional()}).optional(),elicitation:LS.optional(),roots:k({listChanged:ue().optional()}).optional(),tasks:US.optional(),extensions:K(h(),ce).optional()}),FS=Ce.extend({protocolVersion:h(),capabilities:ZS,clientInfo:If}),ji=pe.extend({method:P("initialize"),params:FS});var HS=k({experimental:K(h(),ce).optional(),logging:ce.optional(),completions:ce.optional(),prompts:k({listChanged:ue().optional()}).optional(),resources:k({subscribe:ue().optional(),listChanged:ue().optional()}).optional(),tools:k({listChanged:ue().optional()}).optional(),tasks:qS.optional(),extensions:K(h(),ce).optional()}),VS=fe.extend({protocolVersion:h(),capabilities:HS,serverInfo:If,instructions:h().optional()}),Li=Ue.extend({method:P("notifications/initialized"),params:Le.optional()});var To=pe.extend({method:P("ping"),params:Ce.optional()}),WS=k({progress:V(),total:ne(V()),message:ne(h())}),BS=k({...Le.shape,...WS.shape,progressToken:wf}),zo=Ue.extend({method:P("notifications/progress"),params:BS}),KS=Ce.extend({cursor:kf.optional()}),nn=pe.extend({params:KS.optional()}),on=fe.extend({nextCursor:kf.optional()}),GS=Te(["working","input_required","completed","failed","cancelled"]),sn=k({taskId:h(),status:GS,ttl:Y([V(),ff()]),createdAt:h(),lastUpdatedAt:h(),pollInterval:ne(V()),statusMessage:ne(h())}),ur=fe.extend({task:sn}),JS=Le.merge(sn),an=Ue.extend({method:P("notifications/tasks/status"),params:JS}),Ro=pe.extend({method:P("tasks/get"),params:Ce.extend({taskId:h()})}),Io=fe.merge(sn),Oo=pe.extend({method:P("tasks/result"),params:Ce.extend({taskId:h()})}),aR=fe.loose(),Ao=nn.extend({method:P("tasks/list")}),Mo=on.extend({tasks:D(sn)}),Co=pe.extend({method:P("tasks/cancel"),params:Ce.extend({taskId:h()})}),Of=fe.merge(sn),Af=k({uri:h(),mimeType:ne(h()),_meta:K(h(),re()).optional()}),Mf=Af.extend({text:h()}),Ui=h().refine(t=>{try{return atob(t),!0}catch{return!1}},{message:"Invalid Base64 string"}),Cf=Af.extend({blob:Ui}),cn=Te(["user","assistant"]),lr=k({audience:D(cn).optional(),priority:V().min(0).max(1).optional(),lastModified:Xr.datetime({offset:!0}).optional()}),Nf=k({...cr.shape,...rn.shape,uri:h(),description:ne(h()),mimeType:ne(h()),size:ne(V()),annotations:lr.optional(),_meta:ne($e({}))}),YS=k({...cr.shape,...rn.shape,uriTemplate:h(),description:ne(h()),mimeType:ne(h()),annotations:lr.optional(),_meta:ne($e({}))}),XS=nn.extend({method:P("resources/list")}),QS=on.extend({resources:D(Nf)}),ev=nn.extend({method:P("resources/templates/list")}),tv=on.extend({resourceTemplates:D(YS)}),qi=Ce.extend({uri:h()}),rv=qi,nv=pe.extend({method:P("resources/read"),params:rv}),ov=fe.extend({contents:D(Y([Mf,Cf]))}),sv=Ue.extend({method:P("notifications/resources/list_changed"),params:Le.optional()}),iv=qi,av=pe.extend({method:P("resources/subscribe"),params:iv}),cv=qi,uv=pe.extend({method:P("resources/unsubscribe"),params:cv}),lv=Le.extend({uri:h()}),dv=Ue.extend({method:P("notifications/resources/updated"),params:lv}),pv=k({name:h(),description:ne(h()),required:ne(ue())}),fv=k({...cr.shape,...rn.shape,description:ne(h()),arguments:ne(D(pv)),_meta:ne($e({}))}),mv=nn.extend({method:P("prompts/list")}),hv=on.extend({prompts:D(fv)}),gv=Ce.extend({name:h(),arguments:K(h(),h()).optional()}),_v=pe.extend({method:P("prompts/get"),params:gv}),Zi=k({type:P("text"),text:h(),annotations:lr.optional(),_meta:K(h(),re()).optional()}),Fi=k({type:P("image"),data:Ui,mimeType:h(),annotations:lr.optional(),_meta:K(h(),re()).optional()}),Hi=k({type:P("audio"),data:Ui,mimeType:h(),annotations:lr.optional(),_meta:K(h(),re()).optional()}),yv=k({type:P("tool_use"),name:h(),id:h(),input:K(h(),re()),_meta:K(h(),re()).optional()}),Sv=k({type:P("resource"),resource:Y([Mf,Cf]),annotations:lr.optional(),_meta:K(h(),re()).optional()}),vv=Nf.extend({type:P("resource_link")}),Vi=Y([Zi,Fi,Hi,vv,Sv]),bv=k({role:cn,content:Vi}),Ev=fe.extend({description:h().optional(),messages:D(bv)}),wv=Ue.extend({method:P("notifications/prompts/list_changed"),params:Le.optional()}),kv=k({title:h().optional(),readOnlyHint:ue().optional(),destructiveHint:ue().optional(),idempotentHint:ue().optional(),openWorldHint:ue().optional()}),$v=k({taskSupport:Te(["required","optional","forbidden"]).optional()}),Df=k({...cr.shape,...rn.shape,description:h().optional(),inputSchema:k({type:P("object"),properties:K(h(),ce).optional(),required:D(h()).optional()}).catchall(re()),outputSchema:k({type:P("object"),properties:K(h(),ce).optional(),required:D(h()).optional()}).catchall(re()).optional(),annotations:kv.optional(),execution:$v.optional(),_meta:K(h(),re()).optional()}),Wi=nn.extend({method:P("tools/list")}),xv=on.extend({tools:D(Df)}),No=fe.extend({content:D(Vi).default([]),structuredContent:K(h(),re()).optional(),isError:ue().optional()}),cR=No.or(fe.extend({toolResult:re()})),Pv=en.extend({name:h(),arguments:K(h(),re()).optional()}),un=pe.extend({method:P("tools/call"),params:Pv}),Tv=Ue.extend({method:P("notifications/tools/list_changed"),params:Le.optional()}),uR=k({autoRefresh:ue().default(!0),debounceMs:V().int().nonnegative().default(300)}),ln=Te(["debug","info","notice","warning","error","critical","alert","emergency"]),zv=Ce.extend({level:ln}),Bi=pe.extend({method:P("logging/setLevel"),params:zv}),Rv=Le.extend({level:ln,logger:h().optional(),data:re()}),Iv=Ue.extend({method:P("notifications/message"),params:Rv}),Ov=k({name:h().optional()}),Av=k({hints:D(Ov).optional(),costPriority:V().min(0).max(1).optional(),speedPriority:V().min(0).max(1).optional(),intelligencePriority:V().min(0).max(1).optional()}),Mv=k({mode:Te(["auto","required","none"]).optional()}),Cv=k({type:P("tool_result"),toolUseId:h().describe("The unique identifier for the corresponding tool call."),content:D(Vi).default([]),structuredContent:k({}).loose().optional(),isError:ue().optional(),_meta:K(h(),re()).optional()}),Nv=Ri("type",[Zi,Fi,Hi]),wo=Ri("type",[Zi,Fi,Hi,yv,Cv]),Dv=k({role:cn,content:Y([wo,D(wo)]),_meta:K(h(),re()).optional()}),jv=en.extend({messages:D(Dv),modelPreferences:Av.optional(),systemPrompt:h().optional(),includeContext:Te(["none","thisServer","allServers"]).optional(),temperature:V().optional(),maxTokens:V().int(),stopSequences:D(h()).optional(),metadata:ce.optional(),tools:D(Df).optional(),toolChoice:Mv.optional()}),Lv=pe.extend({method:P("sampling/createMessage"),params:jv}),dn=fe.extend({model:h(),stopReason:ne(Te(["endTurn","stopSequence","maxTokens"]).or(h())),role:cn,content:Nv}),Ki=fe.extend({model:h(),stopReason:ne(Te(["endTurn","stopSequence","maxTokens","toolUse"]).or(h())),role:cn,content:Y([wo,D(wo)])}),Uv=k({type:P("boolean"),title:h().optional(),description:h().optional(),default:ue().optional()}),qv=k({type:P("string"),title:h().optional(),description:h().optional(),minLength:V().optional(),maxLength:V().optional(),format:Te(["email","uri","date","date-time"]).optional(),default:h().optional()}),Zv=k({type:Te(["number","integer"]),title:h().optional(),description:h().optional(),minimum:V().optional(),maximum:V().optional(),default:V().optional()}),Fv=k({type:P("string"),title:h().optional(),description:h().optional(),enum:D(h()),default:h().optional()}),Hv=k({type:P("string"),title:h().optional(),description:h().optional(),oneOf:D(k({const:h(),title:h()})),default:h().optional()}),Vv=k({type:P("string"),title:h().optional(),description:h().optional(),enum:D(h()),enumNames:D(h()).optional(),default:h().optional()}),Wv=Y([Fv,Hv]),Bv=k({type:P("array"),title:h().optional(),description:h().optional(),minItems:V().optional(),maxItems:V().optional(),items:k({type:P("string"),enum:D(h())}),default:D(h()).optional()}),Kv=k({type:P("array"),title:h().optional(),description:h().optional(),minItems:V().optional(),maxItems:V().optional(),items:k({anyOf:D(k({const:h(),title:h()}))}),default:D(h()).optional()}),Gv=Y([Bv,Kv]),Jv=Y([Vv,Wv,Gv]),Yv=Y([Jv,Uv,qv,Zv]),Xv=en.extend({mode:P("form").optional(),message:h(),requestedSchema:k({type:P("object"),properties:K(h(),Yv),required:D(h()).optional()})}),Qv=en.extend({mode:P("url"),message:h(),elicitationId:h(),url:h().url()}),eb=Y([Xv,Qv]),tb=pe.extend({method:P("elicitation/create"),params:eb}),rb=Le.extend({elicitationId:h()}),nb=Ue.extend({method:P("notifications/elicitation/complete"),params:rb}),dr=fe.extend({action:Te(["accept","decline","cancel"]),content:Ii(t=>t===null?void 0:t,K(h(),Y([h(),V(),ue(),D(h())])).optional())}),ob=k({type:P("ref/resource"),uri:h()});var sb=k({type:P("ref/prompt"),name:h()}),ib=Ce.extend({ref:Y([sb,ob]),argument:k({name:h(),value:h()}),context:k({arguments:K(h(),h()).optional()}).optional()}),ab=pe.extend({method:P("completion/complete"),params:ib});var cb=fe.extend({completion:$e({values:D(h()).max(100),total:ne(V().int()),hasMore:ne(ue())})}),ub=k({uri:h().startsWith("file://"),name:h().optional(),_meta:K(h(),re()).optional()}),lb=pe.extend({method:P("roots/list"),params:Ce.optional()}),Gi=fe.extend({roots:D(ub)}),db=Ue.extend({method:P("notifications/roots/list_changed"),params:Le.optional()}),lR=Y([To,ji,ab,Bi,_v,mv,XS,ev,nv,av,uv,un,Wi,Ro,Oo,Ao,Co]),dR=Y([Po,zo,Li,db,an]),pR=Y([xo,dn,Ki,dr,Gi,Io,Mo,ur]),fR=Y([To,Lv,tb,lb,Ro,Oo,Ao,Co]),mR=Y([Po,zo,Iv,dv,sv,Tv,wv,an,nb]),hR=Y([xo,VS,cb,Ev,hv,QS,tv,ov,No,xv,Io,Mo,ur]),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 Oi(o.elicitations,r)}return new t(e,r,n)}},Oi=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 Tt(t){return t==="completed"||t==="failed"||t==="cancelled"}var KR=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Ji(t){let r=vo(t)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=qp(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function Yi(t,e){let r=xt(t,e);if(!r.success)throw r.error;return r.data}var _b=6e4,Do=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(Po,r=>{this._oncancel(r)}),this.setNotificationHandler(zo,r=>{this._onprogress(r)}),this.setRequestHandler(To,r=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Ro,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(Oo,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(!Tt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Tt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Pt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Ao,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(Co,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(Tt(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),tn(s)||zf(s)?this._onresponse(s):Ci(s)?this._onrequest(s,i):Tf(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?.[Pt]?.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=$f(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),tn(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(tn(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),tn(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,ur,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},Tt(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||{},[Pt]: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(x=>this._onerror(new Error(`Failed to send cancellation: ${x}`)));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=xt(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??_b,y=()=>m(I.fromError(N.RequestTimeout,"Request timed out",{timeout:_}));this._setupTimeout(p,_,n?.maxTotalTimeout,y,n?.resetTimeoutOnProgress??!1);let b=c?.taskId;if(b){let E=v=>{let x=this._responseHandlers.get(p);x?x(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},Io,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},Mo,r)}async cancelTask(e,r){return this.request({method:"tasks/cancel",params:e},Of,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||{},[Pt]: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||{},[Pt]: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||{},[Pt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(e,r){let n=Ji(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=Yi(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=Ji(e);this._notificationHandlers.set(n,o=>{let s=Yi(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"&&Ci(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=an.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Tt(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(Tt(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=an.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Tt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function jf(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Lf(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];jf(i)&&jf(s)?r[o]={...i,...s}:r[o]=s}return r}var Rg=bt(Dc(),1),Ig=bt(zg(),1);function vx(){let t=new Rg.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,Ig.default)(t),t}var ys=class{constructor(e){this._ajv=e??vx()}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 Ss=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},dn,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},dr,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 Og(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 Ag(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 vs=class extends Do{constructor(e,r){super(r),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(ln.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 ys,this.setRequestHandler(ji,n=>this._oninitialize(n)),this.setNotificationHandler(Li,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Bi,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=ln.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Ss(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Lf(this._capabilities,e)}setRequestHandler(e,r){let o=vo(e)?.method;if(!o)throw new Error("Schema is missing a method literal");let s;if(ar(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=xt(un,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=xt(ur,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=xt(No,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){Ag(this._clientCapabilities?.tasks?.requests,e,"Client")}assertTaskHandlerCapability(e){this._capabilities&&Og(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:Ef.includes(r)?r:Ai,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"},xo)}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},Ki,r):this.request({method:"sampling/createMessage",params:e},dn,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},dr,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},dr,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},Gi,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 Vc=bt(require("node:process"),1);var bs=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),bx(r)}clear(){this._buffer=void 0}};function bx(t){return Rf.parse(JSON.parse(t))}function Mg(t){return JSON.stringify(t)+`
82
+ `}var Es=class{constructor(e=Vc.default.stdin,r=Vc.default.stdout){this._stdin=e,this._stdout=r,this._readBuffer=new bs,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=Mg(e);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var eu=bt(require("path"),1);var Cg=require("node:child_process");function ws(t,e,r){return(0,Cg.spawn)(t,e??[],{windowsHide:!0,...r})}var le={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 Rr(t){return process.platform==="win32"?Math.round(t*le.WINDOWS_MULTIPLIER):t}var ct=require("fs"),Zn=require("path"),Wc=require("os"),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_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_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,Zn.join)((0,Wc.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,Zn.join)((0,Wc.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",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_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){try{if(!(0,ct.existsSync)(e)){let i=this.getAllDefaults();try{let a=(0,Zn.dirname)(e);(0,ct.existsSync)(a)||(0,ct.mkdirSync)(a,{recursive:!0}),(0,ct.writeFileSync)(e,JSON.stringify(i,null,2),"utf-8"),console.log("[SETTINGS] Created settings file with defaults:",e)}catch(a){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",e,a instanceof Error?a.message:String(a))}return this.applyEnvOverrides(i)}let r=(0,ct.readFileSync)(e,"utf-8"),n=JSON.parse(r),o=n;if(n.env&&typeof n.env=="object"){o=n.env;try{(0,ct.writeFileSync)(e,JSON.stringify(o,null,2),"utf-8"),console.log("[SETTINGS] Migrated settings file from nested to flat schema:",e)}catch(i){console.warn("[SETTINGS] Failed to auto-migrate settings file:",e,i instanceof Error?i.message:String(i))}}let s={...this.DEFAULTS};for(let i of Object.keys(this.DEFAULTS))o[i]!==void 0&&(s[i]=o[i]);return this.applyEnvOverrides(s)}catch(r){return console.warn("[SETTINGS] Failed to load settings, using defaults:",e,r instanceof Error?r.message:String(r)),this.applyEnvOverrides(this.getAllDefaults())}}};var ks=null;function $s(){return ks!==null||(ks=et.loadFromFile(bu)),ks}var Xt=require("fs");var Ng=require("child_process");var lt=require("fs"),Jc=bt(require("path"),1);var Ex=["CLAUDECODE_","CLAUDE_CODE_"],wx=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),kx=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"]),$x=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 Bc(t=process.env){let e={};for(let[r,n]of Object.entries(t))if(n!==void 0){if($x.has(r)){e[r]=n;continue}wx.has(r)||kx.has(r)||Ex.some(o=>r.startsWith(o))||(e[r]=n)}return e}var xx=5e3,Px=1e3,Tx=De.supervisorRegistry();function ut(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:(S.debug("SYSTEM","PID check failed",{pid:t,code:r}),!1)}return S.warn("SYSTEM","PID check threw non-Error",{pid:t,error:String(e)}),!1}}function Dg(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 S.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}if(process.platform==="win32")return null;try{let e=(0,Ng.spawnSync)("ps",["-p",String(t),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...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 S.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:t,error:e instanceof Error?e.message:String(e)}),null}}function Xc(t){if(!t||!ut(t.pid))return!1;if(!t.startToken)return!0;let e=Dg(t.pid);if(e===null)return!0;let r=e===t.startToken;return r||S.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:t.pid,stored:t.startToken,current:e}),r}var Yc=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(e=Tx){this.registryPath=e}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,lt.mkdirSync)(Jc.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?S.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):S.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let e=this.pruneDeadEntries();e>0&&S.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"&&Gc()}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)ut(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)Gc();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;S.info("SYSTEM",`Reaping ${r.length} process(es) for session ${e}`,{sessionId:n,pids:r.map(a=>a.pid)});let o=r.filter(a=>ut(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"&&S.debug("SYSTEM",`Failed to SIGTERM session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):S.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()+xx;for(;Date.now()<s&&o.filter(c=>ut(c.pid)).length!==0;)await new Promise(c=>setTimeout(c,100));let i=o.filter(a=>ut(a.pid));for(let a of i){S.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"&&S.debug("SYSTEM",`Failed to SIGKILL session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):S.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()+Px;for(;Date.now()<a&&i.filter(u=>ut(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"&&Gc();return S.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)(Jc.default.dirname(this.registryPath),{recursive:!0}),(0,lt.writeFileSync)(this.registryPath,JSON.stringify(e,null,2))}},Kc=null;function xs(){return Kc||(Kc=new Yc),Kc}var zx=[];function Gc(){let t=zx.shift();t&&t()}var Ug=require("child_process"),qg=require("fs"),Zg=require("util");var Rx=(0,Zg.promisify)(Ug.execFile),Ix=De.workerPid();async function Fg(t){let e=t.currentPid??process.pid,r=t.pidFilePath??Ix,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(!ut(i.pid)){t.registry.unregister(i.id);continue}try{await Lg(i,"SIGTERM")}catch(a){a instanceof Error?S.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):S.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}}await jg(o,5e3);let s=o.filter(i=>ut(i.pid));for(let i of s)try{await Lg(i,"SIGKILL")}catch(a){a instanceof Error?S.debug("SYSTEM","Failed to force kill child process",{pid:i.pid,pgid:i.pgid,type:i.type},a):S.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:i.pid,pgid:i.pgid,type:i.type,error:String(a)})}await jg(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);try{(0,qg.rmSync)(r,{force:!0})}catch(i){i instanceof Error?S.debug("SYSTEM","Failed to remove PID file during shutdown",{pidFilePath:r},i):S.warn("SYSTEM","Failed to remove PID file during shutdown (non-Error)",{pidFilePath:r,error:String(i)})}t.registry.pruneDeadEntries()}async function jg(t,e){let r=Date.now()+e;for(;Date.now()<r;){if(t.filter(o=>ut(o.pid)).length===0)return;await new Promise(o=>setTimeout(o,100))}}async function Lg(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 Ox();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 Rx("taskkill",s,{timeout:le.POWERSHELL_COMMAND,windowsHide:!0})}async function Ox(){let t="tree-kill";try{let e=await import(t);return e.default??e}catch(e){return S.debug("SYSTEM","tree-kill module not available, using fallback",{},e instanceof Error?e:void 0),null}}var Hg=3e4,Ir=null;function Ax(){let e=xs().pruneDeadEntries();e>0&&S.info("SYSTEM",`Health check: pruned ${e} dead process(es) from registry`)}function Vg(){Ir===null&&(Ir=setInterval(Ax,Hg),Ir.unref(),S.debug("SYSTEM","Health checker started",{intervalMs:Hg}))}function Wg(){Ir!==null&&(clearInterval(Ir),Ir=null,S.debug("SYSTEM","Health checker stopped"))}var Mx=De.workerPid(),Qc=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(),Ps({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,Vg()}configureSignalHandlers(e){if(this.shutdownHandler=e,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){S.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,S.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?S.error("SYSTEM","Error during shutdown",{},o):S.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?S.debug("SYSTEM","Supervisor shutdown fallback failed",{},s):S.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",()=>{S.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}Wg(),this.stopPromise=Fg({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}},Cx=new Qc(xs());function Bg(){return Cx}function Ps(t={}){let e=t.pidFilePath??Mx;if(!(0,Xt.existsSync)(e))return"missing";let r=null;try{r=JSON.parse((0,Xt.readFileSync)(e,"utf-8"))}catch(o){return o instanceof Error?S.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e},o):S.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:e,error:String(o)}),(0,Xt.rmSync)(e,{force:!0}),"invalid"}return Xc(r)&&r?((t.logAlive??!0)&&S.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(S.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,Xt.rmSync)(e,{force:!0}),"stale")}function tu(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;S.warn("SYSTEM",`Invalid ${t}, using default`,{value:n,min:r.min,max:r.max})}return e}var oN=tu("CLAUDE_MEM_HEALTH_TIMEOUT_MS",Rr(le.HEALTH_CHECK),{min:500,max:3e5}),Nx=tu("CLAUDE_MEM_API_TIMEOUT_MS",Rr(le.API_REQUEST),{min:500,max:3e5}),sN=tu("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",Rr(le.HOOK_READINESS_WAIT),{min:0,max:3e5});function ru(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 Ts=null,zs=null;function nu(){if(Ts!==null)return Ts;let t=eu.default.join(et.get("CLAUDE_MEM_DATA_DIR"),"settings.json"),e=et.loadFromFile(t);return Ts=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),Ts}function Dx(){if(zs!==null)return zs;let t=eu.default.join(et.get("CLAUDE_MEM_DATA_DIR"),"settings.json");return zs=et.loadFromFile(t).CLAUDE_MEM_WORKER_HOST,zs}function jx(t){return`http://${Dx()}:${nu()}${t}`}function Rs(t,e={}){let r=e.method??"GET",n=e.timeoutMs??Nx,o=jx(t),s={method:r};return e.headers&&(s.headers=e.headers),e.body&&(s.body=e.body),n>0?ru(o,s,n):fetch(o,s)}var su=bt(require("path"),1),Ve=require("fs");var Qt=bt(require("path"),1),Jg=require("os"),Ne=require("fs"),Or=require("child_process");var Yg=require("util");var fN=(0,Yg.promisify)(Or.exec),mN=De.dataDir(),Kg=De.workerPid();function Gg(t){return t?/(^|[\\/])bun(\.exe)?$/i.test(t.trim()):!1}function Lx(t,e){let r=e==="win32"?`where ${t}`:`which ${t}`,n;try{n=(0,Or.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?S.debug("SYSTEM",`Binary lookup failed for ${t}`,{command:r},s):S.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 ou;function Ux(t={}){let e=Object.keys(t).length===0;if(e&&ou!==void 0)return ou;let r=qx(t);return e&&r!==null&&(ou=r),r}function qx(t){let e=t.platform??process.platform,r=t.execPath??process.execPath;if(Gg(r))return r;let n=t.env??process.env,o=t.homeDirectory??(0,Jg.homedir)(),s=t.pathExists??Ne.existsSync,i=t.lookupInPath??Lx,a=e==="win32"?[n.BUN,n.BUN_PATH,Qt.default.join(o,".bun","bin","bun.exe"),Qt.default.join(o,".bun","bin","bun"),n.USERPROFILE?Qt.default.join(n.USERPROFILE,".bun","bin","bun.exe"):void 0,n.LOCALAPPDATA?Qt.default.join(n.LOCALAPPDATA,"bun","bun.exe"):void 0,n.LOCALAPPDATA?Qt.default.join(n.LOCALAPPDATA,"bun","bin","bun.exe"):void 0]:[n.BUN,n.BUN_PATH,Qt.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&&(Gg(u)&&s(u)||u.toLowerCase()==="bun"))return u}return i("bun",e)}function Dt(t){return process.platform==="win32"?Math.round(t*2):t}function Xg(t,e,r={}){Bg().assertCanSpawn("worker daemon");let n=Bc({...process.env,CLAUDE_MEM_WORKER_PORT:String(e),...r}),o=Ux();if(!o){S.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,Or.execSync)(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:n}),0}catch(p){S.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=ws(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 Qg(){try{if(!(0,Ne.existsSync)(Kg))return;let t=new Date;(0,Ne.utimesSync)(Kg,t,t)}catch{}}function e_(){return Ps({logAlive:!1})}var t_=bt(require("net"),1);async function Zx(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 r_(t){if(process.platform==="win32")try{return(await fetch(`http://127.0.0.1:${t}/api/health`)).ok}catch(e){return e instanceof Error?S.debug("SYSTEM","Windows health check failed (port not in use)",{},e):S.debug("SYSTEM","Windows health check failed (port not in use)",{error:String(e)}),!1}return new Promise(e=>{let r=t_.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 n_(t,e,r,n){let o=Date.now();for(;Date.now()-o<r;){try{if((await Zx(t,e)).ok)return!0}catch(s){s instanceof Error?S.debug("SYSTEM",n,{},s):S.debug("SYSTEM",n,{error:String(s)})}await new Promise(s=>setTimeout(s,500))}return!1}function Fn(t,e=3e4){return n_(t,"/api/health",e,"Service not ready yet, will retry")}function Hn(t,e=3e4){return n_(t,"/api/readiness",e,"Worker not ready yet, will retry")}var Fx=120*1e3;function iu(){return su.default.join(et.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function Hx(){if(process.platform!=="win32")return!1;let t=iu();if(!(0,Ve.existsSync)(t))return!1;try{let e=(0,Ve.statSync)(t).mtimeMs;return Date.now()-e<Fx}catch(e){return e instanceof Error?S.debug("SYSTEM","Could not stat worker spawn lock file",{},e):S.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(e)}),!1}}function Vx(){if(process.platform==="win32")try{let t=iu();(0,Ve.mkdirSync)(su.default.dirname(t),{recursive:!0}),(0,Ve.writeFileSync)(t,"","utf-8")}catch{}}function Is(){if(process.platform==="win32")try{let t=iu();(0,Ve.existsSync)(t)&&(0,Ve.unlinkSync)(t)}catch{}}async function o_(t,e){if(!e)return S.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,Ve.existsSync)(e))return S.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:e}),"dead";if(e_()==="alive"){if(S.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await Fn(t,Dt(le.PORT_IN_USE_WAIT))){Is();let c=await Hn(t,Dt(le.READINESS_WAIT));return S.info("SYSTEM","Worker became healthy while waiting on live PID"),c?"ready":"warming"}return S.warn("SYSTEM","Live PID detected but worker did not become healthy before timeout \u2014 likely still starting"),"warming"}if(await Fn(t,1e3)){Is();let a=await Hn(t,Dt(le.READINESS_WAIT));return a||S.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),S.info("SYSTEM","Worker already running and healthy"),a?"ready":"warming"}if(await r_(t)){if(S.info("SYSTEM","Port in use, waiting for worker to become healthy"),await Fn(t,Dt(le.PORT_IN_USE_WAIT))){Is();let c=await Hn(t,Dt(le.READINESS_WAIT));return S.info("SYSTEM","Worker is now healthy"),c?"ready":"warming"}return S.error("SYSTEM","Port in use but worker not responding to health checks"),"dead"}if(Hx())return S.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";if(S.info("SYSTEM","Starting worker daemon",{workerScriptPath:e}),Vx(),Xg(e,t)===void 0)return S.error("SYSTEM","Failed to spawn worker daemon"),"dead";if(!await Fn(t,Dt(le.POST_SPAWN_WAIT)))return S.warn("SYSTEM","Worker spawned but health endpoint not responding within window \u2014 likely still starting in background"),"warming";let i=await Hn(t,Dt(le.READINESS_WAIT));return i||S.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),Is(),Qg(),S.info("SYSTEM","Worker started successfully"),i?"ready":"warming"}var Cr=require("node:fs/promises"),Kn=require("node:path");var a_=require("node:child_process"),Ee=require("node:fs"),_e=require("node:path"),pu=require("node:os"),uu=require("node:module");var sP={},lu=typeof __filename<"u"?(0,uu.createRequire)(__filename):(0,uu.createRequire)(sP.url),du={".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 c_(t,e){let r=t.slice(t.lastIndexOf("."));return du[r]?du[r]:e.extensionToLanguage[r]?e.extensionToLanguage[r]:"unknown"}function u_(t,e){return e.languageToQueryKey[t]?e.languageToQueryKey[t]:Kx(t)}var Vn=new Map,Ar={grammars:{},extensionToLanguage:{},languageToQueryKey:{}};function Bn(t){if(Vn.has(t))return Vn.get(t);let e=(0,_e.join)(t,".claude-mem.json"),r;try{let s=(0,Ee.readFileSync)(e,"utf-8");r=JSON.parse(s)}catch{return Vn.set(t,Ar),Ar}let n=r.grammars;if(!n||typeof n!="object"||Array.isArray(n))return Vn.set(t,Ar),Ar;let o={grammars:{},extensionToLanguage:{},languageToQueryKey:{}};for(let[s,i]of Object.entries(n)){if(l_[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)du[d]||(o.extensionToLanguage[d]=s);if(typeof l=="string"){let d=(0,_e.join)(t,l);try{let p=(0,Ee.readFileSync)(d,"utf-8"),f=`user_${s}`;p_[f]=p,o.languageToQueryKey[s]=f}catch{console.error(`[smart-file-read] Custom query file not found: ${d}, falling back to generic`),o.languageToQueryKey[s]="generic"}}else o.languageToQueryKey[s]="generic"}}return Vn.set(t,o),o}var l_={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"},Wx={markdown:"tree-sitter-markdown"};function Bx(t){let e=l_[t];if(!e)return null;let r=Wx[t];if(r){try{let n=lu.resolve(e+"/package.json"),o=(0,_e.join)((0,_e.dirname)(n),r);if((0,Ee.existsSync)((0,_e.join)(o,"src")))return o}catch{}return null}try{let n=lu.resolve(e+"/package.json");return(0,_e.dirname)(n)}catch{return null}}function d_(t,e){let r=Bx(t);if(r)return r;if(!e)return null;let o=Bn(e).grammars[t];if(!o)return null;try{let s=(0,_e.join)(e,"node_modules",o.package,"package.json");if((0,Ee.existsSync)(s)){let i=(0,_e.dirname)(s);if((0,Ee.existsSync)((0,_e.join)(i,"src")))return i}}catch{}return console.error(`[smart-file-read] Grammar package not found for "${t}": ${o.package} (install it in your project's node_modules)`),null}var p_={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
@@ -194,25 +194,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
194
194
  (class_definition name: (identifier) @name) @cls
195
195
  (import_statement) @imp
196
196
  (import_declaration) @imp
197
- `};function Cx(t){switch(t){case"javascript":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 Qc=null,eu=new Map;function n_(t){if(eu.has(t))return eu.get(t);Qc||(Qc=(0,we.mkdtempSync)((0,ge.join)((0,ou.tmpdir)(),"smart-read-queries-")));let e=(0,ge.join)(Qc,`${t}.scm`);return(0,we.writeFileSync)(e,r_[t]),eu.set(t,e),e}var Hn=null;function Nx(){if(Hn)return Hn;try{let t=ru.resolve("tree-sitter-cli/package.json"),e=(0,ge.join)((0,ge.dirname)(t),"tree-sitter");if((0,we.existsSync)(e))return Hn=e,e}catch{}return Hn="tree-sitter",Hn}function Dx(t,e,r){return o_(t,[e],r).get(e)||[]}function o_(t,e,r){if(e.length===0)return new Map;let n=Nx(),o=["query","-p",r,t,...e],s;try{s=(0,Yg.execFileSync)(n,o,{encoding:"utf-8",timeout:3e4,stdio:["pipe","pipe","pipe"]})}catch(i){return S.debug("WORKER",`tree-sitter query failed for ${e.length} file(s)`,void 0,i instanceof Error?i:void 0),new Map}return Lx(s)}function Lx(t){let e=new Map,r=null,n=null;for(let o of t.split(`
198
- `)){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 Jg={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"},jx=new Set(["class","struct","impl","trait"]);function Ux(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(`
199
- `),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 Zx(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(`
200
- `).trim():void 0}function Fx(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 qx(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 s_(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=>Jg[v.tag]),l=c.captures.find(v=>v.tag==="name");if(!u)continue;let d=u.startRow,p=u.endRow,f=Jg[u.tag],m=l?.text||"anonymous",_;if(r==="markdown"&&f==="section"){let x=(e[d]||"").match(/^(#{1,6})\s/),k=x?x[1].length:1;_=`${"#".repeat(k)} ${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:_=Ux(e,d,p);let y=r==="markdown"?void 0:Zx(e,d),b=r==="python"?Fx(e,d,p):void 0,w={name:m,kind:f,signature:_,jsdoc:y||b,lineStart:d,lineEnd:p,exported:qx(m,d,p,s,e,r)};jx.has(f)&&(w.children=[],i.push({sym:w,startRow:d,endRow:p})),n.push(w)}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 xs(t,e,r){let n=r?Wn(r):Or,o=Xg(e,n),s=t.split(`
201
- `),i=t_(o,r);if(!i)return{filePath:e,language:o,symbols:[],imports:[],totalLines:s.length,foldedTokenEstimate:50};let a=Qg(o,n),c=n_(a),u=e.slice(e.lastIndexOf("."))||".txt",l=(0,we.mkdtempSync)((0,ge.join)((0,ou.tmpdir)(),"smart-src-")),d=(0,ge.join)(l,`source${u}`);(0,we.writeFileSync)(d,t);try{let p=Dx(c,d,i),f=s_(p,s,o),m=Ir({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,we.rmSync)(l,{recursive:!0,force:!0})}}function i_(t,e){let r=new Map,n=e?Wn(e):Or,o=new Map;for(let s of t){let i=Xg(s.relativePath,n);o.has(i)||o.set(i,[]),o.get(i).push(s)}for(let[s,i]of o){let a=t_(s,e);if(!a){for(let p of i){let f=p.content.split(`
202
- `);r.set(p.relativePath,{filePath:p.relativePath,language:s,symbols:[],imports:[],totalLines:f.length,foldedTokenEstimate:50})}continue}let c=Qg(s,n),u=n_(c),l=i.map(p=>p.absolutePath),d=o_(u,l,a);for(let p of i){let f=p.content.split(`
203
- `),m=d.get(p.absolutePath)||[],_=s_(m,f,s),y=Ir({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(y.length/4)})}}return r}function Ir(t){if(t.language==="markdown")return Hx(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(a_(r," "));return e.join(`
204
- `)}function Hx(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=Bg(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=Bg(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(`
205
- `)}function Bg(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 a_(t,e){let r=[],n=Wx(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(`
206
- `).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(a_(i,e+" "));return r.join(`
207
- `)}function Wx(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 c_(t,e,r){let n=xs(t,e),o=u=>{for(let l of u){if(l.name===r)return l;if(l.children){let d=o(l.children);if(d)return d}}return null},s=o(n.symbols);if(!s)return null;let i=t.split(`
197
+ `};function Kx(t){switch(t){case"javascript":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 au=null,cu=new Map;function f_(t){if(cu.has(t))return cu.get(t);au||(au=(0,Ee.mkdtempSync)((0,_e.join)((0,pu.tmpdir)(),"smart-read-queries-")));let e=(0,_e.join)(au,`${t}.scm`);return(0,Ee.writeFileSync)(e,p_[t]),cu.set(t,e),e}var Wn=null;function Gx(){if(Wn)return Wn;try{let t=lu.resolve("tree-sitter-cli/package.json"),e=(0,_e.join)((0,_e.dirname)(t),"tree-sitter");if((0,Ee.existsSync)(e))return Wn=e,e}catch{}return Wn="tree-sitter",Wn}function Jx(t,e,r){return m_(t,[e],r).get(e)||[]}function m_(t,e,r){if(e.length===0)return new Map;let n=Gx(),o=["query","-p",r,t,...e],s;try{s=(0,a_.execFileSync)(n,o,{encoding:"utf-8",timeout:3e4,stdio:["pipe","pipe","pipe"]})}catch(i){return S.debug("WORKER",`tree-sitter query failed for ${e.length} file(s)`,void 0,i instanceof Error?i:void 0),new Map}return Yx(s)}function Yx(t){let e=new Map,r=null,n=null;for(let o of t.split(`
198
+ `)){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 s_={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"},Xx=new Set(["class","struct","impl","trait"]);function Qx(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(`
199
+ `),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 eP(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(`
200
+ `).trim():void 0}function tP(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 rP(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 h_(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=>s_[v.tag]),l=c.captures.find(v=>v.tag==="name");if(!u)continue;let d=u.startRow,p=u.endRow,f=s_[u.tag],m=l?.text||"anonymous",_;if(r==="markdown"&&f==="section"){let x=(e[d]||"").match(/^(#{1,6})\s/),$=x?x[1].length:1;_=`${"#".repeat($)} ${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:_=Qx(e,d,p);let y=r==="markdown"?void 0:eP(e,d),b=r==="python"?tP(e,d,p):void 0,E={name:m,kind:f,signature:_,jsdoc:y||b,lineStart:d,lineEnd:p,exported:rP(m,d,p,s,e,r)};Xx.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 Os(t,e,r){let n=r?Bn(r):Ar,o=c_(e,n),s=t.split(`
201
+ `),i=d_(o,r);if(!i)return{filePath:e,language:o,symbols:[],imports:[],totalLines:s.length,foldedTokenEstimate:50};let a=u_(o,n),c=f_(a),u=e.slice(e.lastIndexOf("."))||".txt",l=(0,Ee.mkdtempSync)((0,_e.join)((0,pu.tmpdir)(),"smart-src-")),d=(0,_e.join)(l,`source${u}`);(0,Ee.writeFileSync)(d,t);try{let p=Jx(c,d,i),f=h_(p,s,o),m=Mr({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,Ee.rmSync)(l,{recursive:!0,force:!0})}}function g_(t,e){let r=new Map,n=e?Bn(e):Ar,o=new Map;for(let s of t){let i=c_(s.relativePath,n);o.has(i)||o.set(i,[]),o.get(i).push(s)}for(let[s,i]of o){let a=d_(s,e);if(!a){for(let p of i){let f=p.content.split(`
202
+ `);r.set(p.relativePath,{filePath:p.relativePath,language:s,symbols:[],imports:[],totalLines:f.length,foldedTokenEstimate:50})}continue}let c=u_(s,n),u=f_(c),l=i.map(p=>p.absolutePath),d=m_(u,l,a);for(let p of i){let f=p.content.split(`
203
+ `),m=d.get(p.absolutePath)||[],_=h_(m,f,s),y=Mr({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(y.length/4)})}}return r}function Mr(t){if(t.language==="markdown")return nP(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(__(r," "));return e.join(`
204
+ `)}function nP(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=i_(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=i_(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(`
205
+ `)}function i_(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 __(t,e){let r=[],n=oP(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(`
206
+ `).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(__(i,e+" "));return r.join(`
207
+ `)}function oP(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 y_(t,e,r){let n=Os(t,e),o=u=>{for(let l of u){if(l.name===r)return l;if(l.children){let d=o(l.children);if(d)return d}}return null},s=o(n.symbols);if(!s)return null;let i=t.split(`
208
208
  `);if(n.language==="markdown"&&s.kind==="section"){let u=s.signature.match(/^(#{1,6})\s/),l=u?u[1].length:1,d=s.lineStart,p=i.length-1;for(let m of n.symbols)if(m.kind==="section"&&m.lineStart>d){let _=m.signature.match(/^(#{1,6})\s/);if((_?_[1].length:1)<=l){for(p=m.lineStart-1;p>d&&i[p].trim()==="";)p--;break}}let f=i.slice(d,p+1).join(`
209
209
  `);return`<!-- \u{1F4CD} ${e} L${d+1}-${p+1} -->
210
210
  ${f}`}let a=s.lineStart;for(let u=s.lineStart-1;u>=0;u--){let l=i[u].trim();if(l===""||l.startsWith("*")||l.startsWith("/**")||l.startsWith("///")||l.startsWith("//")||l.startsWith("#")||l.startsWith("@")||l==="*/")a=u;else break}let c=i.slice(a,s.lineEnd+1).join(`
211
211
  `);return`// \u{1F4CD} ${e} L${a+1}-${s.lineEnd+1}
212
- ${c}`}var u_=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"]),Gx=new Set(["node_modules",".git","dist","build",".next","__pycache__",".venv","venv","env",".env","target","vendor",".cache",".turbo","coverage",".nyc_output",".claude",".smart-file-read"]),Kx=512*1024;async function*l_(t,e,r=20,n){if(r<=0)return;let o;try{o=await(0,Ar.readdir)(t,{withFileTypes:!0})}catch(s){S.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!=="."||Gx.has(s.name))continue;let i=(0,Vn.join)(t,s.name);if(s.isDirectory())yield*l_(i,e,r-1,n);else if(s.isFile()){let a=s.name.slice(s.name.lastIndexOf("."));(u_.has(a)||n&&n.has(a))&&(yield i)}}}async function Jx(t){try{let e=await(0,Ar.stat)(t);if(e.size>Kx||e.size===0)return null;let r=await(0,Ar.readFile)(t,"utf-8");return r.slice(0,1e3).includes("\0")?null:r}catch(e){return S.debug("WORKER",`safeReadFile: failed to read ${t}`,void 0,e instanceof Error?e:void 0),null}}async function d_(t,e,r={}){let n=r.maxResults||20,o=e.toLowerCase(),s=o.split(/[\s_\-./]+/).filter(w=>w.length>0),i=r.projectRoot||t,a=Wn(i),c=new Set;for(let w of Object.values(a.grammars))for(let v of w.extensions)u_.has(v)||c.add(v);let u=[];for await(let w of l_(t,t,20,c.size>0?c:void 0)){if(r.filePattern&&!(0,Vn.relative)(t,w).toLowerCase().includes(r.filePattern.toLowerCase()))continue;let v=await Jx(w);v&&u.push({absolutePath:w,relativePath:(0,Vn.relative)(t,w),content:v})}let l=i_(u,i),d=[],p=[],f=0;for(let[w,v]of l){f+=Bx(v);let k=Ps(w.toLowerCase(),s)>0,_e=[],Ee=(Dt,Qt)=>{for(let ae of Dt){let St=0,Ve="",Cr=Ps(ae.name.toLowerCase(),s);Cr>0&&(St+=Cr*3,Ve="name match"),ae.signature.toLowerCase().includes(o)&&(St+=2,Ve=Ve?`${Ve} + signature`:"signature match"),ae.jsdoc&&ae.jsdoc.toLowerCase().includes(o)&&(St+=1,Ve=Ve?`${Ve} + jsdoc`:"jsdoc match"),St>0&&(k=!0,_e.push({filePath:w,symbolName:Qt?`${Qt}.${ae.name}`:ae.name,kind:ae.kind,signature:ae.signature,jsdoc:ae.jsdoc,lineStart:ae.lineStart,lineEnd:ae.lineEnd,matchReason:Ve})),ae.children&&Ee(ae.children,ae.name)}};Ee(v.symbols),k&&(d.push(v),p.push(..._e))}p.sort((w,v)=>{let x=Ps(w.symbolName.toLowerCase(),s);return Ps(v.symbolName.toLowerCase(),s)-x});let m=p.slice(0,n),_=new Set(m.map(w=>w.filePath)),y=d.filter(w=>_.has(w.filePath)).slice(0,n),b=y.reduce((w,v)=>w+v.foldedTokenEstimate,0);return{foldedFiles:y,matchingSymbols:m,totalFilesScanned:u.length,totalSymbolsFound:f,tokenEstimate:b}}function Ps(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 Bx(t){let e=t.symbols.length;for(let r of t.symbols)r.children&&(e+=r.children.length);return e}function p_(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(`
212
+ ${c}`}var S_=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"]),iP=new Set(["node_modules",".git","dist","build",".next","__pycache__",".venv","venv","env",".env","target","vendor",".cache",".turbo","coverage",".nyc_output",".claude",".smart-file-read"]),aP=512*1024;async function*v_(t,e,r=20,n){if(r<=0)return;let o;try{o=await(0,Cr.readdir)(t,{withFileTypes:!0})}catch(s){S.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!=="."||iP.has(s.name))continue;let i=(0,Kn.join)(t,s.name);if(s.isDirectory())yield*v_(i,e,r-1,n);else if(s.isFile()){let a=s.name.slice(s.name.lastIndexOf("."));(S_.has(a)||n&&n.has(a))&&(yield i)}}}async function cP(t){try{let e=await(0,Cr.stat)(t);if(e.size>aP||e.size===0)return null;let r=await(0,Cr.readFile)(t,"utf-8");return r.slice(0,1e3).includes("\0")?null:r}catch(e){return S.debug("WORKER",`safeReadFile: failed to read ${t}`,void 0,e instanceof Error?e:void 0),null}}async function b_(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=Bn(i),c=new Set;for(let E of Object.values(a.grammars))for(let v of E.extensions)S_.has(v)||c.add(v);let u=[];for await(let E of v_(t,t,20,c.size>0?c:void 0)){if(r.filePattern&&!(0,Kn.relative)(t,E).toLowerCase().includes(r.filePattern.toLowerCase()))continue;let v=await cP(E);v&&u.push({absolutePath:E,relativePath:(0,Kn.relative)(t,E),content:v})}let l=g_(u,i),d=[],p=[],f=0;for(let[E,v]of l){f+=uP(v);let $=As(E.toLowerCase(),s)>0,ye=[],we=(jt,er)=>{for(let ae of jt){let vt=0,Be="",Dr=As(ae.name.toLowerCase(),s);Dr>0&&(vt+=Dr*3,Be="name match"),ae.signature.toLowerCase().includes(o)&&(vt+=2,Be=Be?`${Be} + signature`:"signature match"),ae.jsdoc&&ae.jsdoc.toLowerCase().includes(o)&&(vt+=1,Be=Be?`${Be} + jsdoc`:"jsdoc match"),vt>0&&($=!0,ye.push({filePath:E,symbolName:er?`${er}.${ae.name}`:ae.name,kind:ae.kind,signature:ae.signature,jsdoc:ae.jsdoc,lineStart:ae.lineStart,lineEnd:ae.lineEnd,matchReason:Be})),ae.children&&we(ae.children,ae.name)}};we(v.symbols),$&&(d.push(v),p.push(...ye))}p.sort((E,v)=>{let x=As(E.symbolName.toLowerCase(),s);return As(v.symbolName.toLowerCase(),s)-x});let m=p.slice(0,n),_=new Set(m.map(E=>E.filePath)),y=d.filter(E=>_.has(E.filePath)).slice(0,n),b=y.reduce((E,v)=>E+v.foldedTokenEstimate,0);return{foldedFiles:y,matchingSymbols:m,totalFilesScanned:u.length,totalSymbolsFound:f,tokenEstimate:b}}function As(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 uP(t){let e=t.symbols.length;for(let r of t.symbols)r.children&&(e+=r.children.length);return e}function E_(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(`
213
213
  `);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(`
214
- `).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(Ir(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(`
215
- `)}var iu=require("node:fs/promises"),zs=require("node:fs"),Qe=require("node:path"),h_=require("node:os"),g_=require("node:url"),cP={},Yx="13.0.1";console.log=(...t)=>{S.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:t})};var __=!1,y_=(()=>{if(typeof __dirname<"u")return __dirname;try{return(0,Qe.dirname)((0,g_.fileURLToPath)(cP.url))}catch{return __=!0,process.cwd()}})(),au=(0,Qe.resolve)(y_,"worker-service.cjs");function Xx(){__&&((0,zs.existsSync)(au)||S.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:y_}))}var f_={search:"/api/search",timeline:"/api/timeline"};async function su(t,e){S.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 $s(n);if(!o.ok){let i=await o.text();throw new Error(`Worker API error (${o.status}): ${i}`)}let s=await o.json();return S.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:t}),s}catch(o){return S.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 Qx(t,e){let r=await $s(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 S.debug("HTTP","Worker API success (POST)",void 0,{endpoint:t}),{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}async function Mr(t,e){S.debug("HTTP","Worker API request (POST)",void 0,{endpoint:t});try{return await Qx(t,e)}catch(r){return S.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 eP(){try{return(await $s("/api/health")).ok}catch(t){return S.debug("SYSTEM","Worker health check failed",{},t instanceof Error?t:new Error(String(t))),!1}}async function tP(){if(await eP())return!0;S.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),Xx();try{let t=Jc(),e=await Kg(t,au);return e==="dead"&&S.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 S.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 S_=[{name:"__IMPORTANT",description:`3-LAYER WORKFLOW (ALWAYS FOLLOW):
214
+ `).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(Mr(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(`
215
+ `)}var hu=require("node:fs/promises"),Cs=require("node:fs"),tt=require("node:path"),R_=require("node:os"),I_=require("node:url");var lP=Rr(le.API_REQUEST),We=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)}},Ms=class{baseUrl;apiKey;timeoutMs;constructor(e){this.baseUrl=dP(e.serverBaseUrl),this.apiKey=e.apiKey,this.timeoutMs=e.timeoutMs??lP}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 We("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 We("invalid_response","jobId is required for getJobStatus");return this.request("GET",`/v1/jobs/${encodeURIComponent(e)}`)}buildAddObservationPayload(e){return{projectId:e.projectId,content:e.content,...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.kind!==void 0?{kind:e.kind}:{},...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 We("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 ru(o,s,this.timeoutMs)}catch(c){let u=c instanceof Error?c.message:String(c),l=/timed out|timeout/i.test(u);throw new We(l?"timeout":"transport",`Server beta ${e} ${r} failed: ${u}`,{cause:c})}if(!i.ok){let c=await i.text().catch(()=>"");throw new We("http_error",`Server beta ${e} ${r} returned ${i.status}: ${pP(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 We("invalid_response",`Server beta ${e} ${r} returned non-JSON response`,{cause:c})}}};function w_(t){return t instanceof We}function dP(t){return t.replace(/\/+$/,"")}function pP(t,e){return t.length<=e?t:`${t.slice(0,e)}\u2026`}function fu(){return($s().CLAUDE_MEM_RUNTIME??"worker").trim().toLowerCase()==="server-beta"?"server-beta":"worker"}function k_(){let t=$s(),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 S.warn("HOOK","[server-beta-fallback] reason=missing_base_url"),null;if(!r)return S.warn("HOOK","[server-beta-fallback] reason=missing_api_key"),null;if(!n)return S.warn("HOOK","[server-beta-fallback] reason=missing_project_id"),null;let o={serverBaseUrl:e,apiKey:r};return{runtime:"server-beta",client:new Ms(o),projectId:n,serverBaseUrl:e}}var PP={},fP="13.2.0";console.log=(...t)=>{S.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:t})};var O_=!1,A_=(()=>{if(typeof __dirname<"u")return __dirname;try{return(0,tt.dirname)((0,I_.fileURLToPath)(PP.url))}catch{return O_=!0,process.cwd()}})(),gu=(0,tt.resolve)(A_,"worker-service.cjs");function mP(){O_&&((0,Cs.existsSync)(gu)||S.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:gu,mcpServerDir:A_}))}var $_={search:"/api/search",timeline:"/api/timeline"};async function mu(t,e){S.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 Rs(n);if(!o.ok){let i=await o.text();throw new Error(`Worker API error (${o.status}): ${i}`)}let s=await o.json();return S.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:t}),s}catch(o){return S.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 hP(t,e){let r=await Rs(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 S.debug("HTTP","Worker API success (POST)",void 0,{endpoint:t}),{content:[{type:"text",text:JSON.stringify(n,null,2)}]}}async function Nr(t,e){S.debug("HTTP","Worker API request (POST)",void 0,{endpoint:t});try{return await hP(t,e)}catch(r){return S.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 gP(){try{return(await Rs("/api/health")).ok}catch(t){return S.debug("SYSTEM","Worker health check failed",{},t instanceof Error?t:new Error(String(t))),!1}}function _P(){if(fu()!=="server-beta")return null;let e=k_();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 Jn(t){return w_(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 Yn(t){return{content:[{type:"text",text:JSON.stringify(t,null,2)}]}}function Xn(t){let e=_P();if(!e)throw new We("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 We("missing_api_key",`${t}: ${e.reason}`);return e}async function x_(t){try{let e=Xn("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 Yn(o)}catch(e){return Jn(e)}}async function yP(t){try{let e=Xn("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 Yn(o)}catch(e){return Jn(e)}}async function P_(t){try{let e=Xn("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 Yn(o)}catch(e){return Jn(e)}}async function T_(t){try{let e=Xn("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 Yn(o)}catch(e){return Jn(e)}}async function SP(t){try{let e=Xn("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 Yn(n)}catch(e){return Jn(e)}}async function vP(){if(await gP())return!0;S.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),mP();try{let t=nu(),e=await o_(t,gu);return e==="dead"&&S.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 S.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 M_=[{name:"__IMPORTANT",description:`3-LAYER WORKFLOW (ALWAYS FOLLOW):
216
216
  1. search(query) \u2192 Get index with IDs (~50-100 tokens/result)
217
217
  2. timeline(anchor=ID) \u2192 Get context around interesting results
218
218
  3. get_observations([IDs]) \u2192 Fetch full details ONLY for filtered IDs
@@ -232,8 +232,8 @@ NEVER fetch full details without filtering first. 10x token savings.`,inputSchem
232
232
  \`get_observations(ids=[...])\` # ALWAYS batch for 2+ items
233
233
  Returns: Complete details (~500-1000 tokens/result)
234
234
 
235
- **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, 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"},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=f_.search;return await su(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=f_.timeline;return await su(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 Mr("/api/observations/batch",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,Qe.resolve)(t.path||process.cwd()),r=await d_(e,t.query,{maxResults:t.max_results||20,filePattern:t.file_pattern});return{content:[{type:"text",text:p_(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,Qe.resolve)(t.file_path),r=await(0,iu.readFile)(e,"utf-8"),n=c_(r,e,t.symbol_name);if(n)return{content:[{type:"text",text:n}]};let o=xs(r,e);if(o.symbols.length>0){let s=o.symbols.map(i=>` - ${i.name} (${i.kind})`).join(`
235
+ **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, 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"},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=$_.search;return await mu(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=$_.timeline;return await mu(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 Nr("/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=>x_(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=>yP(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=>P_(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=>T_(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=>SP(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 x_(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=>P_(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=>T_(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 b_(e,t.query,{maxResults:t.max_results||20,filePattern:t.file_pattern});return{content:[{type:"text",text:E_(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,hu.readFile)(e,"utf-8"),n=y_(r,e,t.symbol_name);if(n)return{content:[{type:"text",text:n}]};let o=Os(r,e);if(o.symbols.length>0){let s=o.symbols.map(i=>` - ${i.name} (${i.kind})`).join(`
236
236
  `);return{content:[{type:"text",text:`Symbol "${t.symbol_name}" not found in ${t.file_path}.
237
237
 
238
238
  Available symbols:
239
- ${s}`}]}}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,Qe.resolve)(t.file_path),r=await(0,iu.readFile)(e,"utf-8"),n=xs(r,e);return n.symbols.length>0?{content:[{type:"text",text:Ir(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 Mr("/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 su("/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 Mr(`/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 Mr(`/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 Mr(`/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 Mr(`/api/corpus/${encodeURIComponent(e)}/reprime`,r)}}],cu=new hs({name:"claude-mem",version:Yx},{capabilities:{tools:{}}});cu.setRequestHandler(ji,async()=>({tools:S_.map(t=>({name:t.name,description:t.description,inputSchema:t.inputSchema}))}));cu.setRequestHandler(an,async t=>{let e=S_.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 S.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 rP=3e4,Gn=null,m_=!1;function Ts(){Kn("stdio-closed")}function v_(t){S.warn("SYSTEM","MCP stdio stream errored, shutting down",{message:t.message}),Kn("stdio-error")}function nP(){process.stdin.on("end",Ts),process.stdin.on("close",Ts),process.stdin.on("error",v_)}function oP(){process.stdin.off("end",Ts),process.stdin.off("close",Ts),process.stdin.off("error",v_)}function sP(){if(process.platform==="win32")return;let t=process.ppid;Gn=setInterval(()=>{(process.ppid===1||process.ppid!==t)&&(S.info("SYSTEM","Parent process died, self-exiting to prevent orphan",{initialPpid:t,currentPpid:process.ppid}),Kn())},rP),Gn.unref&&Gn.unref()}function Kn(t="shutdown"){m_||(m_=!0,Gn&&clearInterval(Gn),oP(),S.info("SYSTEM","MCP server shutting down",{reason:t}),process.exit(0))}process.on("SIGTERM",Kn);process.on("SIGINT",Kn);function iP(){try{let t=(0,h_.homedir)(),e=[(0,Qe.resolve)(t,".claude","plugins","marketplaces","thedotmack"),(0,Qe.resolve)(t,".config","claude","plugins","marketplaces","thedotmack")],r=e.some(i=>i&&(0,zs.existsSync)(i)),n=[(0,Qe.resolve)(t,".claude","plugins","cache","thedotmack","claude-mem"),(0,Qe.resolve)(t,".config","claude","plugins","cache","thedotmack","claude-mem")],o=n.some(i=>i&&(0,zs.existsSync)(i)),s=n[0];!r&&o&&S.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 aP(){let t=new _s;nP(),await cu.connect(t),S.info("SYSTEM","Claude-mem search server started"),iP(),sP(),setTimeout(async()=>{await tP()?S.info("SYSTEM","Worker available",void 0,{}):(S.error("SYSTEM","Worker not available",void 0,{}),S.error("SYSTEM","Tools will fail until Worker is started"),S.error("SYSTEM","Start Worker with: npm run worker:restart"))},0)}aP().catch(t=>{S.error("SYSTEM","Fatal error",void 0,t),process.exit(0)});
239
+ ${s}`}]}}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,hu.readFile)(e,"utf-8"),n=Os(r,e);return n.symbols.length>0?{content:[{type:"text",text:Mr(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 Nr("/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 mu("/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 Nr(`/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 Nr(`/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 Nr(`/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 Nr(`/api/corpus/${encodeURIComponent(e)}/reprime`,r)}}],_u=new vs({name:"claude-mem",version:fP},{capabilities:{tools:{}}});_u.setRequestHandler(Wi,async()=>({tools:M_.map(t=>({name:t.name,description:t.description,inputSchema:t.inputSchema}))}));_u.setRequestHandler(un,async t=>{let e=M_.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 S.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 bP=3e4,Gn=null,z_=!1;function Ns(){Qn("stdio-closed")}function C_(t){S.warn("SYSTEM","MCP stdio stream errored, shutting down",{message:t.message}),Qn("stdio-error")}function EP(){process.stdin.on("end",Ns),process.stdin.on("close",Ns),process.stdin.on("error",C_)}function wP(){process.stdin.off("end",Ns),process.stdin.off("close",Ns),process.stdin.off("error",C_)}function kP(){if(process.platform==="win32")return;let t=process.ppid;Gn=setInterval(()=>{(process.ppid===1||process.ppid!==t)&&(S.info("SYSTEM","Parent process died, self-exiting to prevent orphan",{initialPpid:t,currentPpid:process.ppid}),Qn())},bP),Gn.unref&&Gn.unref()}function Qn(t="shutdown"){z_||(z_=!0,Gn&&clearInterval(Gn),wP(),S.info("SYSTEM","MCP server shutting down",{reason:t}),process.exit(0))}process.on("SIGTERM",Qn);process.on("SIGINT",Qn);function $P(){try{let t=(0,R_.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,Cs.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,Cs.existsSync)(i)),s=n[0];!r&&o&&S.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 xP(){let t=new Es;EP(),await _u.connect(t),S.info("SYSTEM","Claude-mem search server started"),$P(),kP(),setTimeout(async()=>{if(fu()==="server-beta"){S.info("SYSTEM","MCP runtime=server-beta \u2014 skipping worker auto-start",void 0,{});return}await vP()?S.info("SYSTEM","Worker available",void 0,{}):(S.error("SYSTEM","Worker not available",void 0,{}),S.error("SYSTEM","Tools will fail until Worker is started"),S.error("SYSTEM","Start Worker with: npm run worker:restart"))},0)}xP().catch(t=>{S.error("SYSTEM","Fatal error",void 0,t),process.exit(0)});