claude-mem 13.24.21 → 13.24.23

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,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  var __CM_FILENAME__ = typeof __filename !== "undefined" ? __filename : require("node:path").resolve(process.argv[1] || "");
3
3
  var __CM_DIRNAME__ = typeof __dirname !== "undefined" ? __dirname : require("node:path").dirname(__CM_FILENAME__);
4
- "use strict";var Pb=Object.create;var Qi=Object.defineProperty;var $b=Object.getOwnPropertyDescriptor;var Tb=Object.getOwnPropertyNames;var Rb=Object.getPrototypeOf,Ob=Object.prototype.hasOwnProperty;var ln=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var w=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},dd=(e,t)=>{for(var r in t)Qi(e,r,{get:t[r],enumerable:!0})},Ib=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Tb(t))!Ob.call(e,o)&&o!==r&&Qi(e,o,{get:()=>t[o],enumerable:!(n=$b(t,o))||n.enumerable});return e};var Lt=(e,t,r)=>(r=e!=null?Pb(Rb(e)):{},Ib(t||!e||!e.__esModule?Qi(r,"default",{value:e,enumerable:!0}):r,e));function Cb(e){return(Ab??process.stderr.write.bind(process.stderr))(e)}function jt(e){Cb(e)}var Ab,Co=ln(()=>{"use strict";Ab=null});function zb(e){return e.replace(/^\uFEFF/,"")}function or(e){return JSON.parse(zb(e))}function Db(e){(0,V.existsSync)(e)||(0,V.mkdirSync)(e,{recursive:!0})}function dn(e,t){let r=e;try{if((0,V.lstatSync)(e).isSymbolicLink())try{r=(0,V.realpathSync)(e)}catch(u){let l=u instanceof Error?u:new Error(String(u));jt(`claude-mem: realpathSync failed for ${e}, resolving symlink manually: ${l.message}
5
- `);let d=(0,V.readlinkSync)(e);r=(0,yt.resolve)((0,yt.dirname)(e),d)}}catch(u){let l=u.code;if(l!=="ENOENT"&&l!=="ENOTDIR")throw u}Db((0,yt.dirname)(r));let n=(0,yt.dirname)(r),o=(0,yt.basename)(r),s=(0,yt.join)(n,`.${o}.${process.pid}.${(0,fd.randomBytes)(6).toString("hex")}.tmp`),i=Buffer.from(JSON.stringify(t,null,2)+`
6
- `,"utf-8"),a;try{a=(0,V.statSync)(r).mode&511}catch{}let c;try{c=a!==void 0?(0,V.openSync)(s,"w",a):(0,V.openSync)(s,"w");let u=0;for(;u<i.length;){let l=(0,V.writeSync)(c,i,u,i.length-u);if(l===0)throw new Error(`writeSync stalled at ${u}/${i.length} bytes`);u+=l}if((0,V.fsyncSync)(c),(0,V.closeSync)(c),c=void 0,(0,V.renameSync)(s,r),!Mb){let l;try{l=(0,V.openSync)(n,"r"),(0,V.fsyncSync)(l)}catch(d){let f=d instanceof Error?d:new Error(String(d));jt(`claude-mem: directory fsync failed for ${n}: ${f.message}
7
- `)}finally{if(l!==void 0)try{(0,V.closeSync)(l)}catch{}}}}catch(u){if(c!==void 0)try{(0,V.closeSync)(c)}catch{}try{(0,V.unlinkSync)(s)}catch{}throw u}}var V,fd,yt,Mb,Pr=ln(()=>{"use strict";V=require("fs"),fd=require("crypto"),yt=require("path");Co();Mb=process.platform==="win32"});function Mo(e,t=process.platform,r=(0,pd.homedir)()){return typeof e!="string"||e.length===0?e:e==="~"?r:e.startsWith("~/")||t==="win32"&&e.startsWith("~\\")?(0,md.join)(r,e.slice(2)):e}var pd,md,ea=ln(()=>{"use strict";pd=require("os"),md=require("path")});function Nb(){return typeof __CM_DIRNAME__<"u"?__CM_DIRNAME__:(0,Y.dirname)((0,hd.fileURLToPath)(qb.url))}function sr(){if(process.env.CLAUDE_MEM_DATA_DIR)return Mo(process.env.CLAUDE_MEM_DATA_DIR);let e=(0,Y.join)((0,ta.homedir)(),".claude-mem"),t=(0,Y.join)(e,"settings.json");try{if((0,fn.existsSync)(t)){let r=or((0,fn.readFileSync)(t,"utf-8")),n=r.env??r;if(n.CLAUDE_MEM_DATA_DIR)return Mo(n.CLAUDE_MEM_DATA_DIR)}}catch{}return e}var Y,ta,fn,hd,qb,_A,ce,Lb,jb,zo,Ub,Do,gd,yA,Fb,SA,qe,Ze=ln(()=>{"use strict";Y=require("path"),ta=require("os"),fn=require("fs"),hd=require("url");Pr();ea();ea();qb={};_A=Nb();ce=sr(),Lb=(0,Y.join)((0,ta.homedir)(),".claude"),jb=process.env.CLAUDE_CONFIG_DIR||Lb,zo=(0,Y.join)(jb,"plugins","marketplaces","thedotmack"),Ub=(0,Y.join)(ce,"logs"),Do=(0,Y.join)(ce,"settings.json"),gd="claude-mem.db",yA=(0,Y.join)(ce,gd),Fb=(0,Y.join)(ce,"observer-sessions"),SA=(0,Y.basename)(Fb),qe={dataDir:()=>ce,workerPid:()=>(0,Y.join)(ce,"worker.pid"),serverPid:()=>(0,Y.join)(ce,".server-beta.pid"),serverPort:()=>(0,Y.join)(ce,".server-beta.port"),serverRuntime:()=>(0,Y.join)(ce,".server-beta.runtime.json"),settings:()=>(0,Y.join)(ce,"settings.json"),database:()=>(0,Y.join)(ce,gd),chroma:()=>(0,Y.join)(ce,"chroma"),combinedCerts:()=>(0,Y.join)(ce,"combined_certs.pem"),transcriptsConfig:()=>(0,Y.join)(ce,"transcript-watch.json"),transcriptsState:()=>(0,Y.join)(ce,"transcript-watch-state.json"),corpora:()=>(0,Y.join)(ce,"corpora"),supervisorRegistry:()=>(0,Y.join)(ce,"supervisor.json"),envFile:()=>(0,Y.join)(ce,".env"),logsDir:()=>Ub}});var kt,_d,na,ra,oa,_,ne=ln(()=>{"use strict";kt=require("fs"),_d=require("path");Ze();Co();Pr();na=(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))(na||{}),ra=null,oa=class{level=null;useColor;logFilePath=null;logFileInitialized=!1;constructor(){this.useColor=process.stdout.isTTY??!1}ensureLogFileInitialized(){if(!this.logFileInitialized){this.logFileInitialized=!0;try{let t=qe.logsDir();(0,kt.existsSync)(t)||(0,kt.mkdirSync)(t,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=(0,_d.join)(t,`claude-mem-${r}.log`)}catch(t){console.error("[LOGGER] Failed to initialize log file:",t instanceof Error?t.message:String(t)),this.logFilePath=null}}}getLevel(){if(this.level===null)try{let t=qe.settings();if((0,kt.existsSync)(t)){let r=(0,kt.readFileSync)(t,"utf-8"),o=(or(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=na[o]??1}else this.level=1}catch(t){console.error("[LOGGER] Failed to load log level from settings:",t instanceof Error?t.message:String(t)),this.level=1}return this.level}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message}
4
+ "use strict";var $b=Object.create;var Qi=Object.defineProperty;var Tb=Object.getOwnPropertyDescriptor;var Rb=Object.getOwnPropertyNames;var Ob=Object.getPrototypeOf,Ib=Object.prototype.hasOwnProperty;var ln=(e,t,r)=>()=>{if(r)throw r[0];try{return e&&(t=e(e=0)),t}catch(n){throw r=[n],n}};var w=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},dd=(e,t)=>{for(var r in t)Qi(e,r,{get:t[r],enumerable:!0})},Ab=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Rb(t))!Ib.call(e,o)&&o!==r&&Qi(e,o,{get:()=>t[o],enumerable:!(n=Tb(t,o))||n.enumerable});return e};var Lt=(e,t,r)=>(r=e!=null?$b(Ob(e)):{},Ab(t||!e||!e.__esModule?Qi(r,"default",{value:e,enumerable:!0}):r,e));function Mb(e){return(Cb??process.stderr.write.bind(process.stderr))(e)}function jt(e){Mb(e)}var Cb,Co=ln(()=>{"use strict";Cb=null});function Db(e){return e.replace(/^\uFEFF/,"")}function or(e){return JSON.parse(Db(e))}function Nb(e){(0,V.existsSync)(e)||(0,V.mkdirSync)(e,{recursive:!0})}function dn(e,t){let r=e;try{if((0,V.lstatSync)(e).isSymbolicLink())try{r=(0,V.realpathSync)(e)}catch(u){let l=u instanceof Error?u:new Error(String(u));jt(`claude-mem: realpathSync failed for ${e}, resolving symlink manually: ${l.message}
5
+ `);let d=(0,V.readlinkSync)(e);r=(0,yt.resolve)((0,yt.dirname)(e),d)}}catch(u){let l=u.code;if(l!=="ENOENT"&&l!=="ENOTDIR")throw u}Nb((0,yt.dirname)(r));let n=(0,yt.dirname)(r),o=(0,yt.basename)(r),s=(0,yt.join)(n,`.${o}.${process.pid}.${(0,fd.randomBytes)(6).toString("hex")}.tmp`),i=Buffer.from(JSON.stringify(t,null,2)+`
6
+ `,"utf-8"),a;try{a=(0,V.statSync)(r).mode&511}catch{}let c;try{c=a!==void 0?(0,V.openSync)(s,"w",a):(0,V.openSync)(s,"w");let u=0;for(;u<i.length;){let l=(0,V.writeSync)(c,i,u,i.length-u);if(l===0)throw new Error(`writeSync stalled at ${u}/${i.length} bytes`);u+=l}if((0,V.fsyncSync)(c),(0,V.closeSync)(c),c=void 0,(0,V.renameSync)(s,r),!zb){let l;try{l=(0,V.openSync)(n,"r"),(0,V.fsyncSync)(l)}catch(d){let f=d instanceof Error?d:new Error(String(d));jt(`claude-mem: directory fsync failed for ${n}: ${f.message}
7
+ `)}finally{if(l!==void 0)try{(0,V.closeSync)(l)}catch{}}}}catch(u){if(c!==void 0)try{(0,V.closeSync)(c)}catch{}try{(0,V.unlinkSync)(s)}catch{}throw u}}var V,fd,yt,zb,Pr=ln(()=>{"use strict";V=require("fs"),fd=require("crypto"),yt=require("path");Co();zb=process.platform==="win32"});function Mo(e,t=process.platform,r=(0,pd.homedir)()){return typeof e!="string"||e.length===0?e:e==="~"?r:e.startsWith("~/")||t==="win32"&&e.startsWith("~\\")?(0,md.join)(r,e.slice(2)):e}var pd,md,ea=ln(()=>{"use strict";pd=require("os"),md=require("path")});function Lb(){return typeof __CM_DIRNAME__<"u"?__CM_DIRNAME__:(0,Y.dirname)((0,hd.fileURLToPath)(qb.url))}function sr(){if(process.env.CLAUDE_MEM_DATA_DIR)return Mo(process.env.CLAUDE_MEM_DATA_DIR);let e=(0,Y.join)((0,ta.homedir)(),".claude-mem"),t=(0,Y.join)(e,"settings.json");try{if((0,fn.existsSync)(t)){let r=or((0,fn.readFileSync)(t,"utf-8")),n=r.env??r;if(n.CLAUDE_MEM_DATA_DIR)return Mo(n.CLAUDE_MEM_DATA_DIR)}}catch{}return e}var Y,ta,fn,hd,qb,_A,ce,jb,Ub,zo,Fb,Do,gd,yA,_d,SA,qe,Ze=ln(()=>{"use strict";Y=require("path"),ta=require("os"),fn=require("fs"),hd=require("url");Pr();ea();ea();qb={};_A=Lb();ce=sr(),jb=(0,Y.join)((0,ta.homedir)(),".claude"),Ub=process.env.CLAUDE_CONFIG_DIR||jb,zo=(0,Y.join)(Ub,"plugins","marketplaces","thedotmack"),Fb=(0,Y.join)(ce,"logs"),Do=(0,Y.join)(ce,"settings.json"),gd="claude-mem.db",yA=(0,Y.join)(ce,gd),_d=(0,Y.join)(ce,"observer-sessions"),SA=(0,Y.basename)(_d),qe={dataDir:()=>ce,workerPid:()=>(0,Y.join)(ce,"worker.pid"),serverPid:()=>(0,Y.join)(ce,".server-beta.pid"),serverPort:()=>(0,Y.join)(ce,".server-beta.port"),serverRuntime:()=>(0,Y.join)(ce,".server-beta.runtime.json"),settings:()=>(0,Y.join)(ce,"settings.json"),database:()=>(0,Y.join)(ce,gd),chroma:()=>(0,Y.join)(ce,"chroma"),combinedCerts:()=>(0,Y.join)(ce,"combined_certs.pem"),transcriptsConfig:()=>(0,Y.join)(ce,"transcript-watch.json"),transcriptsState:()=>(0,Y.join)(ce,"transcript-watch-state.json"),corpora:()=>(0,Y.join)(ce,"corpora"),supervisorRegistry:()=>(0,Y.join)(ce,"supervisor.json"),envFile:()=>(0,Y.join)(ce,".env"),logsDir:()=>Fb}});var kt,yd,na,ra,oa,_,ne=ln(()=>{"use strict";kt=require("fs"),yd=require("path");Ze();Co();Pr();na=(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))(na||{}),ra=null,oa=class{level=null;useColor;logFilePath=null;logFileInitialized=!1;constructor(){this.useColor=process.stdout.isTTY??!1}ensureLogFileInitialized(){if(!this.logFileInitialized){this.logFileInitialized=!0;try{let t=qe.logsDir();(0,kt.existsSync)(t)||(0,kt.mkdirSync)(t,{recursive:!0});let r=new Date().toISOString().split("T")[0];this.logFilePath=(0,yd.join)(t,`claude-mem-${r}.log`)}catch(t){console.error("[LOGGER] Failed to initialize log file:",t instanceof Error?t.message:String(t)),this.logFilePath=null}}}getLevel(){if(this.level===null)try{let t=qe.settings();if((0,kt.existsSync)(t)){let r=(0,kt.readFileSync)(t,"utf-8"),o=(or(r).CLAUDE_MEM_LOG_LEVEL||"INFO").toUpperCase();this.level=na[o]??1}else this.level=1}catch(t){console.error("[LOGGER] Failed to load log level from settings:",t instanceof Error?t.message:String(t)),this.level=1}return this.level}formatData(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return t.toString();if(typeof t=="object"){if(t instanceof Error)return this.getLevel()===0?`${t.message}
8
8
  ${t.stack}`:t.message;if(Array.isArray(t))return`[${t.length} items]`;let r=Object.keys(t);return r.length===0?"{}":r.length<=3?JSON.stringify(t):`{${r.length} keys: ${r.slice(0,3).join(", ")}...}`}return String(t)}formatTool(t,r){if(!r)return t;let n=r;if(typeof r=="string")try{n=JSON.parse(r)}catch{n=r}if(t==="Bash"&&n.command)return`${t}(${n.command})`;if(n.file_path)return`${t}(${n.file_path})`;if(n.notebook_path)return`${t}(${n.notebook_path})`;if(t==="Glob"&&n.pattern)return`${t}(${n.pattern})`;if(t==="Grep"&&n.pattern)return`${t}(${n.pattern})`;if(n.url)return`${t}(${n.url})`;if(n.query)return`${t}(${n.query})`;if(t==="Task"){if(n.subagent_type)return`${t}(${n.subagent_type})`;if(n.description)return`${t}(${n.description})`}return t==="Skill"&&n.skill?`${t}(${n.skill})`:t==="LSP"&&n.operation?`${t}(${n.operation})`:t}formatTimestamp(t){let r=t.getFullYear(),n=String(t.getMonth()+1).padStart(2,"0"),o=String(t.getDate()).padStart(2,"0"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),a=String(t.getSeconds()).padStart(2,"0"),c=String(t.getMilliseconds()).padStart(3,"0");return`${r}-${n}-${o} ${s}:${i}:${a}.${c}`}log(t,r,n,o,s){if(t<this.getLevel())return;this.ensureLogFileInitialized();let i=this.formatTimestamp(new Date),a=na[t].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
9
  ${s.message}
10
10
  ${s.stack}`:` ${s.message}`;else if(this.getLevel()===0&&typeof s=="object")try{l=`
@@ -12,18 +12,18 @@ ${s.stack}`:` ${s.message}`;else if(this.getLevel()===0&&typeof s=="object")try{
12
12
  `,"utf8")}catch(p){let m=p instanceof Error?p:new Error(String(p));jt(`[LOGGER] Failed to write to log file: ${m.message}
13
13
  ${m.stack??""}
14
14
  `)}else jt(f+`
15
- `)}debug(t,r,n,o){this.log(0,t,r,n,o)}info(t,r,n,o){this.log(1,t,r,n,o)}warn(t,r,n,o){this.log(2,t,r,n,o)}setErrorSink(t){ra=t}error(t,r,n,o){this.log(3,t,r,n,o),this.routeErrorToSink(r,n,o)}routeErrorToSink(t,r,n){try{if(!ra||!(n instanceof Error))return;ra(n)}catch{}}dataIn(t,r,n,o){this.info(t,`\u2192 ${r}`,n,o)}dataOut(t,r,n,o){this.info(t,`\u2190 ${r}`,n,o)}success(t,r,n,o){this.info(t,`\u2713 ${r}`,n,o)}failure(t,r,n,o){this.error(t,`\u2717 ${r}`,n,o)}},_=new oa});var Vn=w(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.regexpCode=W.getEsmExportName=W.getProperty=W.safeStringify=W.stringify=W.strConcat=W.addCodeArg=W.str=W._=W.nil=W._Code=W.Name=W.IDENTIFIER=W._CodeOrName=void 0;var Hn=class{};W._CodeOrName=Hn;W.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ur=class extends Hn{constructor(t){if(super(),!W.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};W.Name=ur;var Qe=class extends Hn{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof ur&&(r[n.str]=(r[n.str]||0)+1),r),{})}};W._Code=Qe;W.nil=new Qe("");function ig(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Rc(r,t[n]),r.push(e[++n]);return new Qe(r)}W._=ig;var Tc=new Qe("+");function ag(e,...t){let r=[Wn(e[0])],n=0;for(;n<t.length;)r.push(Tc),Rc(r,t[n]),r.push(Tc,Wn(e[++n]));return V0(r),new Qe(r)}W.str=ag;function Rc(e,t){t instanceof Qe?e.push(...t._items):t instanceof ur?e.push(t):e.push(G0(t))}W.addCodeArg=Rc;function V0(e){let t=1;for(;t<e.length-1;){if(e[t]===Tc){let r=K0(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function K0(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof ur||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof ur))return`"${e}${t.slice(1)}`}function B0(e,t){return t.emptyStr()?e:e.emptyStr()?t:ag`${e}${t}`}W.strConcat=B0;function G0(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Wn(Array.isArray(e)?e.join(","):e)}function Y0(e){return new Qe(Wn(e))}W.stringify=Y0;function Wn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}W.safeStringify=Wn;function J0(e){return typeof e=="string"&&W.IDENTIFIER.test(e)?new Qe(`.${e}`):ig`[${e}]`}W.getProperty=J0;function X0(e){if(typeof e=="string"&&W.IDENTIFIER.test(e))return new Qe(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}W.getEsmExportName=X0;function Q0(e){return new Qe(e.toString())}W.regexpCode=Q0});var Ac=w(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.ValueScope=Le.ValueScopeName=Le.Scope=Le.varKinds=Le.UsedValueState=void 0;var Ne=Vn(),Oc=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Ls;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Ls||(Le.UsedValueState=Ls={}));Le.varKinds={const:new Ne.Name("const"),let:new Ne.Name("let"),var:new Ne.Name("var")};var js=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ne.Name?t:this.name(t)}name(t){return new Ne.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Le.Scope=js;var Us=class extends Ne.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ne._)`.${new Ne.Name(r)}[${n}]`}};Le.ValueScopeName=Us;var ek=(0,Ne._)`\n`,Ic=class extends js{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?ek:Ne.nil}}get(){return this._scope}name(t){return new Us(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ne._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Ne.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Ls.Started);let l=r(u);if(l){let d=this.opts.es5?Le.varKinds.var:Le.varKinds.const;s=(0,Ne._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Ne._)`${s}${l}${this.opts._n}`;else throw new Oc(u);c.set(u,Ls.Completed)})}return s}};Le.ValueScope=Ic});var M=w(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.or=D.and=D.not=D.CodeGen=D.operators=D.varKinds=D.ValueScopeName=D.ValueScope=D.Scope=D.Name=D.regexpCode=D.stringify=D.getProperty=D.nil=D.strConcat=D.str=D._=void 0;var F=Vn(),lt=Ac(),Kt=Vn();Object.defineProperty(D,"_",{enumerable:!0,get:function(){return Kt._}});Object.defineProperty(D,"str",{enumerable:!0,get:function(){return Kt.str}});Object.defineProperty(D,"strConcat",{enumerable:!0,get:function(){return Kt.strConcat}});Object.defineProperty(D,"nil",{enumerable:!0,get:function(){return Kt.nil}});Object.defineProperty(D,"getProperty",{enumerable:!0,get:function(){return Kt.getProperty}});Object.defineProperty(D,"stringify",{enumerable:!0,get:function(){return Kt.stringify}});Object.defineProperty(D,"regexpCode",{enumerable:!0,get:function(){return Kt.regexpCode}});Object.defineProperty(D,"Name",{enumerable:!0,get:function(){return Kt.Name}});var Hs=Ac();Object.defineProperty(D,"Scope",{enumerable:!0,get:function(){return Hs.Scope}});Object.defineProperty(D,"ValueScope",{enumerable:!0,get:function(){return Hs.ValueScope}});Object.defineProperty(D,"ValueScopeName",{enumerable:!0,get:function(){return Hs.ValueScopeName}});Object.defineProperty(D,"varKinds",{enumerable:!0,get:function(){return Hs.varKinds}});D.operators={GT:new F._Code(">"),GTE:new F._Code(">="),LT:new F._Code("<"),LTE:new F._Code("<="),EQ:new F._Code("==="),NEQ:new F._Code("!=="),NOT:new F._Code("!"),OR:new F._Code("||"),AND:new F._Code("&&"),ADD:new F._Code("+")};var It=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Cc=class extends It{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?lt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=qr(this.rhs,t,r)),this}get names(){return this.rhs instanceof F._CodeOrName?this.rhs.names:{}}},Fs=class extends It{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof F.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=qr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof F.Name?{}:{...this.lhs.names};return Zs(t,this.rhs)}},Mc=class extends Fs{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},zc=class extends It{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Dc=class extends It{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},Nc=class extends It{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},Lc=class extends It{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=qr(this.code,t,r),this}get names(){return this.code instanceof F._CodeOrName?this.code.names:{}}},Kn=class extends It{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(tk(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>fr(t,r.names),{})}},At=class extends Kn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},jc=class extends Kn{},Fr=class extends At{};Fr.kind="else";var lr=class e extends At{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Fr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(cg(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=qr(this.condition,t,r),this}get names(){let t=super.names;return Zs(t,this.condition),this.else&&fr(t,this.else.names),t}};lr.kind="if";var dr=class extends At{};dr.kind="for";var Uc=class extends dr{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=qr(this.iteration,t,r),this}get names(){return fr(super.names,this.iteration.names)}},Fc=class extends dr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?lt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Zs(super.names,this.from);return Zs(t,this.to)}},qs=class extends dr{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=qr(this.iterable,t,r),this}get names(){return fr(super.names,this.iterable.names)}},Bn=class extends At{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};Bn.kind="func";var Gn=class extends Kn{render(t){return"return "+super.render(t)}};Gn.kind="return";var qc=class extends At{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&fr(t,this.catch.names),this.finally&&fr(t,this.finally.names),t}},Yn=class extends At{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Yn.kind="catch";var Jn=class extends At{render(t){return"finally"+super.render(t)}};Jn.kind="finally";var Zc=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
16
- `:""},this._extScope=t,this._scope=new lt.Scope({parent:t}),this._nodes=[new jc]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Cc(t,s,n)),s}const(t,r,n){return this._def(lt.varKinds.const,t,r,n)}let(t,r,n){return this._def(lt.varKinds.let,t,r,n)}var(t,r,n){return this._def(lt.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Fs(t,r,n))}add(t,r){return this._leafNode(new Mc(t,D.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==F.nil&&this._leafNode(new Lc(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,F.addCodeArg)(r,o));return r.push("}"),new F._Code(r)}if(t,r,n){if(this._blockNode(new lr(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new lr(t))}else(){return this._elseNode(new Fr)}endIf(){return this._endBlockNode(lr,Fr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Uc(t),r)}forRange(t,r,n,o,s=this.opts.es5?lt.varKinds.var:lt.varKinds.let){let i=this._scope.toName(t);return this._for(new Fc(s,i,r,n),()=>o(i))}forOf(t,r,n,o=lt.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof F.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,F._)`${i}.length`,a=>{this.var(s,(0,F._)`${i}[${a}]`),n(s)})}return this._for(new qs("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?lt.varKinds.var:lt.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,F._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new qs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(dr)}label(t){return this._leafNode(new zc(t))}break(t){return this._leafNode(new Dc(t))}return(t){let r=new Gn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Gn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new qc;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Yn(s),r(s)}return n&&(this._currNode=o.finally=new Jn,this.code(n)),this._endBlockNode(Yn,Jn)}throw(t){return this._leafNode(new Nc(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=F.nil,n,o){return this._blockNode(new Bn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Bn)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof lr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};D.CodeGen=Zc;function fr(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Zs(e,t){return t instanceof F._CodeOrName?fr(e,t.names):e}function qr(e,t,r){if(e instanceof F.Name)return n(e);if(!o(e))return e;return new F._Code(e._items.reduce((s,i)=>(i instanceof F.Name&&(i=n(i)),i instanceof F._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof F._Code&&s._items.some(i=>i instanceof F.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function tk(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function cg(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,F._)`!${Hc(e)}`}D.not=cg;var rk=ug(D.operators.AND);function nk(...e){return e.reduce(rk)}D.and=nk;var ok=ug(D.operators.OR);function sk(...e){return e.reduce(ok)}D.or=sk;function ug(e){return(t,r)=>t===F.nil?r:r===F.nil?t:(0,F._)`${Hc(t)} ${e} ${Hc(r)}`}function Hc(e){return e instanceof F.Name?e:(0,F._)`(${e})`}});var q=w(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.checkStrictMode=N.getErrorPath=N.Type=N.useFunc=N.setEvaluated=N.evaluatedPropsToName=N.mergeEvaluated=N.eachItem=N.unescapeJsonPointer=N.escapeJsonPointer=N.escapeFragment=N.unescapeFragment=N.schemaRefOrVal=N.schemaHasRulesButRef=N.schemaHasRules=N.checkUnknownRules=N.alwaysValidSchema=N.toHash=void 0;var G=M(),ik=Vn();function ak(e){let t={};for(let r of e)t[r]=!0;return t}N.toHash=ak;function ck(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(fg(e,t),!pg(t,e.self.RULES.all))}N.alwaysValidSchema=ck;function fg(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||gg(e,`unknown keyword: "${s}"`)}N.checkUnknownRules=fg;function pg(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}N.schemaHasRules=pg;function uk(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}N.schemaHasRulesButRef=uk;function lk({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,G._)`${r}`}return(0,G._)`${e}${t}${(0,G.getProperty)(n)}`}N.schemaRefOrVal=lk;function dk(e){return mg(decodeURIComponent(e))}N.unescapeFragment=dk;function fk(e){return encodeURIComponent(Vc(e))}N.escapeFragment=fk;function Vc(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}N.escapeJsonPointer=Vc;function mg(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}N.unescapeJsonPointer=mg;function pk(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}N.eachItem=pk;function lg({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof G.Name?(s instanceof G.Name?e(o,s,i):t(o,s,i),i):s instanceof G.Name?(t(o,i,s),s):r(s,i);return a===G.Name&&!(c instanceof G.Name)?n(o,c):c}}N.mergeEvaluated={props:lg({mergeNames:(e,t,r)=>e.if((0,G._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,G._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,G._)`${r} || {}`).code((0,G._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,G._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,G._)`${r} || {}`),Kc(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:hg}),items:lg({mergeNames:(e,t,r)=>e.if((0,G._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,G._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,G._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,G._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function hg(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,G._)`{}`);return t!==void 0&&Kc(e,r,t),r}N.evaluatedPropsToName=hg;function Kc(e,t,r){Object.keys(r).forEach(n=>e.assign((0,G._)`${t}${(0,G.getProperty)(n)}`,!0))}N.setEvaluated=Kc;var dg={};function mk(e,t){return e.scopeValue("func",{ref:t,code:dg[t.code]||(dg[t.code]=new ik._Code(t.code))})}N.useFunc=mk;var Wc;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Wc||(N.Type=Wc={}));function hk(e,t,r){if(e instanceof G.Name){let n=t===Wc.Num;return r?n?(0,G._)`"[" + ${e} + "]"`:(0,G._)`"['" + ${e} + "']"`:n?(0,G._)`"/" + ${e}`:(0,G._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,G.getProperty)(e).toString():"/"+Vc(e)}N.getErrorPath=hk;function gg(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}N.checkStrictMode=gg});var Ct=w(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});var ve=M(),gk={data:new ve.Name("data"),valCxt:new ve.Name("valCxt"),instancePath:new ve.Name("instancePath"),parentData:new ve.Name("parentData"),parentDataProperty:new ve.Name("parentDataProperty"),rootData:new ve.Name("rootData"),dynamicAnchors:new ve.Name("dynamicAnchors"),vErrors:new ve.Name("vErrors"),errors:new ve.Name("errors"),this:new ve.Name("this"),self:new ve.Name("self"),scope:new ve.Name("scope"),json:new ve.Name("json"),jsonPos:new ve.Name("jsonPos"),jsonLen:new ve.Name("jsonLen"),jsonPart:new ve.Name("jsonPart")};Bc.default=gk});var Xn=w(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.extendErrors=we.resetErrorsCount=we.reportExtraError=we.reportError=we.keyword$DataError=we.keywordError=void 0;var Z=M(),Ws=q(),Te=Ct();we.keywordError={message:({keyword:e})=>(0,Z.str)`must pass "${e}" keyword validation`};we.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,Z.str)`"${e}" keyword must be ${t} ($data)`:(0,Z.str)`"${e}" keyword is invalid ($data)`};function _k(e,t=we.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=Sg(e,t,r);n??(i||a)?_g(s,c):yg(o,(0,Z._)`[${c}]`)}we.reportError=_k;function yk(e,t=we.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=Sg(e,t,r);_g(o,a),s||i||yg(n,Te.default.vErrors)}we.reportExtraError=yk;function Sk(e,t){e.assign(Te.default.errors,t),e.if((0,Z._)`${Te.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,Z._)`${Te.default.vErrors}.length`,t),()=>e.assign(Te.default.vErrors,null)))}we.resetErrorsCount=Sk;function bk({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,Te.default.errors,a=>{e.const(i,(0,Z._)`${Te.default.vErrors}[${a}]`),e.if((0,Z._)`${i}.instancePath === undefined`,()=>e.assign((0,Z._)`${i}.instancePath`,(0,Z.strConcat)(Te.default.instancePath,s.errorPath))),e.assign((0,Z._)`${i}.schemaPath`,(0,Z.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,Z._)`${i}.schema`,r),e.assign((0,Z._)`${i}.data`,n))})}we.extendErrors=bk;function _g(e,t){let r=e.const("err",t);e.if((0,Z._)`${Te.default.vErrors} === null`,()=>e.assign(Te.default.vErrors,(0,Z._)`[${r}]`),(0,Z._)`${Te.default.vErrors}.push(${r})`),e.code((0,Z._)`${Te.default.errors}++`)}function yg(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,Z._)`new ${e.ValidationError}(${t})`):(r.assign((0,Z._)`${n}.errors`,t),r.return(!1))}var pr={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 Sg(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,Z._)`{}`:Ek(e,t,r)}function Ek(e,t,r={}){let{gen:n,it:o}=e,s=[vk(o,r),wk(e,r)];return kk(e,t,s),n.object(...s)}function vk({errorPath:e},{instancePath:t}){let r=t?(0,Z.str)`${e}${(0,Ws.getErrorPath)(t,Ws.Type.Str)}`:e;return[Te.default.instancePath,(0,Z.strConcat)(Te.default.instancePath,r)]}function wk({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,Z.str)`${t}/${e}`;return r&&(o=(0,Z.str)`${o}${(0,Ws.getErrorPath)(r,Ws.Type.Str)}`),[pr.schemaPath,o]}function kk(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([pr.keyword,o],[pr.params,typeof t=="function"?t(e):t||(0,Z._)`{}`]),c.messages&&n.push([pr.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([pr.schema,i],[pr.parentSchema,(0,Z._)`${l}${d}`],[Te.default.data,s]),u&&n.push([pr.propertyName,u])}});var Eg=w(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.boolOrEmptySchema=Zr.topBoolOrEmptySchema=void 0;var xk=Xn(),Pk=M(),$k=Ct(),Tk={message:"boolean schema is false"};function Rk(e){let{gen:t,schema:r,validateName:n}=e;r===!1?bg(e,!1):typeof r=="object"&&r.$async===!0?t.return($k.default.data):(t.assign((0,Pk._)`${n}.errors`,null),t.return(!0))}Zr.topBoolOrEmptySchema=Rk;function Ok(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),bg(e)):r.var(t,!0)}Zr.boolOrEmptySchema=Ok;function bg(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,xk.reportError)(o,Tk,void 0,t)}});var Gc=w(Hr=>{"use strict";Object.defineProperty(Hr,"__esModule",{value:!0});Hr.getRules=Hr.isJSONType=void 0;var Ik=["string","number","integer","boolean","null","object","array"],Ak=new Set(Ik);function Ck(e){return typeof e=="string"&&Ak.has(e)}Hr.isJSONType=Ck;function Mk(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Hr.getRules=Mk});var Yc=w(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.shouldUseRule=Bt.shouldUseGroup=Bt.schemaHasRulesForType=void 0;function zk({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&vg(e,n)}Bt.schemaHasRulesForType=zk;function vg(e,t){return t.rules.some(r=>wg(e,r))}Bt.shouldUseGroup=vg;function wg(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Bt.shouldUseRule=wg});var Qn=w(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.reportTypeError=ke.checkDataTypes=ke.checkDataType=ke.coerceAndCheckDataType=ke.getJSONTypes=ke.getSchemaTypes=ke.DataType=void 0;var Dk=Gc(),Nk=Yc(),Lk=Xn(),C=M(),kg=q(),Wr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Wr||(ke.DataType=Wr={}));function jk(e){let t=xg(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}ke.getSchemaTypes=jk;function xg(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Dk.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}ke.getJSONTypes=xg;function Uk(e,t){let{gen:r,data:n,opts:o}=e,s=Fk(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,Nk.schemaHasRulesForType)(e,t[0]));if(i){let a=Xc(t,n,o.strictNumbers,Wr.Wrong);r.if(a,()=>{s.length?qk(e,t,s):Qc(e)})}return i}ke.coerceAndCheckDataType=Uk;var Pg=new Set(["string","number","integer","boolean","null"]);function Fk(e,t){return t?e.filter(r=>Pg.has(r)||t==="array"&&r==="array"):[]}function qk(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,C._)`typeof ${o}`),a=n.let("coerced",(0,C._)`undefined`);s.coerceTypes==="array"&&n.if((0,C._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,C._)`${o}[0]`).assign(i,(0,C._)`typeof ${o}`).if(Xc(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,C._)`${a} !== undefined`);for(let u of r)(Pg.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Qc(e),n.endIf(),n.if((0,C._)`${a} !== undefined`,()=>{n.assign(o,a),Zk(e,a)});function c(u){switch(u){case"string":n.elseIf((0,C._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,C._)`"" + ${o}`).elseIf((0,C._)`${o} === null`).assign(a,(0,C._)`""`);return;case"number":n.elseIf((0,C._)`${i} == "boolean" || ${o} === null
15
+ `)}debug(t,r,n,o){this.log(0,t,r,n,o)}info(t,r,n,o){this.log(1,t,r,n,o)}warn(t,r,n,o){this.log(2,t,r,n,o)}setErrorSink(t){ra=t}error(t,r,n,o){this.log(3,t,r,n,o),this.routeErrorToSink(r,n,o)}routeErrorToSink(t,r,n){try{if(!ra||!(n instanceof Error))return;ra(n)}catch{}}dataIn(t,r,n,o){this.info(t,`\u2192 ${r}`,n,o)}dataOut(t,r,n,o){this.info(t,`\u2190 ${r}`,n,o)}success(t,r,n,o){this.info(t,`\u2713 ${r}`,n,o)}failure(t,r,n,o){this.error(t,`\u2717 ${r}`,n,o)}},_=new oa});var Vn=w(W=>{"use strict";Object.defineProperty(W,"__esModule",{value:!0});W.regexpCode=W.getEsmExportName=W.getProperty=W.safeStringify=W.stringify=W.strConcat=W.addCodeArg=W.str=W._=W.nil=W._Code=W.Name=W.IDENTIFIER=W._CodeOrName=void 0;var Hn=class{};W._CodeOrName=Hn;W.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var ur=class extends Hn{constructor(t){if(super(),!W.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};W.Name=ur;var Qe=class extends Hn{constructor(t){super(),this._items=typeof t=="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let t=this._items[0];return t===""||t==='""'}get str(){var t;return(t=this._str)!==null&&t!==void 0?t:this._str=this._items.reduce((r,n)=>`${r}${n}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,n)=>(n instanceof ur&&(r[n.str]=(r[n.str]||0)+1),r),{})}};W._Code=Qe;W.nil=new Qe("");function ag(e,...t){let r=[e[0]],n=0;for(;n<t.length;)Rc(r,t[n]),r.push(e[++n]);return new Qe(r)}W._=ag;var Tc=new Qe("+");function cg(e,...t){let r=[Wn(e[0])],n=0;for(;n<t.length;)r.push(Tc),Rc(r,t[n]),r.push(Tc,Wn(e[++n]));return V0(r),new Qe(r)}W.str=cg;function Rc(e,t){t instanceof Qe?e.push(...t._items):t instanceof ur?e.push(t):e.push(G0(t))}W.addCodeArg=Rc;function V0(e){let t=1;for(;t<e.length-1;){if(e[t]===Tc){let r=K0(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function K0(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string")return t instanceof ur||e[e.length-1]!=='"'?void 0:typeof t!="string"?`${e.slice(0,-1)}${t}"`:t[0]==='"'?e.slice(0,-1)+t.slice(1):void 0;if(typeof t=="string"&&t[0]==='"'&&!(e instanceof ur))return`"${e}${t.slice(1)}`}function B0(e,t){return t.emptyStr()?e:e.emptyStr()?t:cg`${e}${t}`}W.strConcat=B0;function G0(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:Wn(Array.isArray(e)?e.join(","):e)}function Y0(e){return new Qe(Wn(e))}W.stringify=Y0;function Wn(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}W.safeStringify=Wn;function J0(e){return typeof e=="string"&&W.IDENTIFIER.test(e)?new Qe(`.${e}`):ag`[${e}]`}W.getProperty=J0;function X0(e){if(typeof e=="string"&&W.IDENTIFIER.test(e))return new Qe(`${e}`);throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}W.getEsmExportName=X0;function Q0(e){return new Qe(e.toString())}W.regexpCode=Q0});var Ac=w(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});Le.ValueScope=Le.ValueScopeName=Le.Scope=Le.varKinds=Le.UsedValueState=void 0;var Ne=Vn(),Oc=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`),this.value=t.value}},Ls;(function(e){e[e.Started=0]="Started",e[e.Completed=1]="Completed"})(Ls||(Le.UsedValueState=Ls={}));Le.varKinds={const:new Ne.Name("const"),let:new Ne.Name("let"),var:new Ne.Name("var")};var js=class{constructor({prefixes:t,parent:r}={}){this._names={},this._prefixes=t,this._parent=r}toName(t){return t instanceof Ne.Name?t:this.name(t)}name(t){return new Ne.Name(this._newName(t))}_newName(t){let r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,n;if(!((n=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||n===void 0)&&n.has(t)||this._prefixes&&!this._prefixes.has(t))throw new Error(`CodeGen: prefix "${t}" is not allowed in this scope`);return this._names[t]={prefix:t,index:0}}};Le.Scope=js;var Us=class extends Ne.Name{constructor(t,r){super(r),this.prefix=t}setValue(t,{property:r,itemIndex:n}){this.value=t,this.scopePath=(0,Ne._)`.${new Ne.Name(r)}[${n}]`}};Le.ValueScopeName=Us;var ek=(0,Ne._)`\n`,Ic=class extends js{constructor(t){super(t),this._values={},this._scope=t.scope,this.opts={...t,_n:t.lines?ek:Ne.nil}}get(){return this._scope}name(t){return new Us(t,this._newName(t))}value(t,r){var n;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");let o=this.toName(t),{prefix:s}=o,i=(n=r.key)!==null&&n!==void 0?n:r.ref,a=this._values[s];if(a){let l=a.get(i);if(l)return l}else a=this._values[s]=new Map;a.set(i,o);let c=this._scope[s]||(this._scope[s]=[]),u=c.length;return c[u]=r.ref,o.setValue(r,{property:s,itemIndex:u}),o}getValue(t,r){let n=this._values[t];if(n)return n.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,n=>{if(n.scopePath===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return(0,Ne._)`${t}${n.scopePath}`})}scopeCode(t=this._values,r,n){return this._reduceValues(t,o=>{if(o.value===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return o.value.code},r,n)}_reduceValues(t,r,n={},o){let s=Ne.nil;for(let i in t){let a=t[i];if(!a)continue;let c=n[i]=n[i]||new Map;a.forEach(u=>{if(c.has(u))return;c.set(u,Ls.Started);let l=r(u);if(l){let d=this.opts.es5?Le.varKinds.var:Le.varKinds.const;s=(0,Ne._)`${s}${d} ${u} = ${l};${this.opts._n}`}else if(l=o?.(u))s=(0,Ne._)`${s}${l}${this.opts._n}`;else throw new Oc(u);c.set(u,Ls.Completed)})}return s}};Le.ValueScope=Ic});var M=w(D=>{"use strict";Object.defineProperty(D,"__esModule",{value:!0});D.or=D.and=D.not=D.CodeGen=D.operators=D.varKinds=D.ValueScopeName=D.ValueScope=D.Scope=D.Name=D.regexpCode=D.stringify=D.getProperty=D.nil=D.strConcat=D.str=D._=void 0;var F=Vn(),lt=Ac(),Kt=Vn();Object.defineProperty(D,"_",{enumerable:!0,get:function(){return Kt._}});Object.defineProperty(D,"str",{enumerable:!0,get:function(){return Kt.str}});Object.defineProperty(D,"strConcat",{enumerable:!0,get:function(){return Kt.strConcat}});Object.defineProperty(D,"nil",{enumerable:!0,get:function(){return Kt.nil}});Object.defineProperty(D,"getProperty",{enumerable:!0,get:function(){return Kt.getProperty}});Object.defineProperty(D,"stringify",{enumerable:!0,get:function(){return Kt.stringify}});Object.defineProperty(D,"regexpCode",{enumerable:!0,get:function(){return Kt.regexpCode}});Object.defineProperty(D,"Name",{enumerable:!0,get:function(){return Kt.Name}});var Hs=Ac();Object.defineProperty(D,"Scope",{enumerable:!0,get:function(){return Hs.Scope}});Object.defineProperty(D,"ValueScope",{enumerable:!0,get:function(){return Hs.ValueScope}});Object.defineProperty(D,"ValueScopeName",{enumerable:!0,get:function(){return Hs.ValueScopeName}});Object.defineProperty(D,"varKinds",{enumerable:!0,get:function(){return Hs.varKinds}});D.operators={GT:new F._Code(">"),GTE:new F._Code(">="),LT:new F._Code("<"),LTE:new F._Code("<="),EQ:new F._Code("==="),NEQ:new F._Code("!=="),NOT:new F._Code("!"),OR:new F._Code("||"),AND:new F._Code("&&"),ADD:new F._Code("+")};var It=class{optimizeNodes(){return this}optimizeNames(t,r){return this}},Cc=class extends It{constructor(t,r,n){super(),this.varKind=t,this.name=r,this.rhs=n}render({es5:t,_n:r}){let n=t?lt.varKinds.var:this.varKind,o=this.rhs===void 0?"":` = ${this.rhs}`;return`${n} ${this.name}${o};`+r}optimizeNames(t,r){if(t[this.name.str])return this.rhs&&(this.rhs=qr(this.rhs,t,r)),this}get names(){return this.rhs instanceof F._CodeOrName?this.rhs.names:{}}},Fs=class extends It{constructor(t,r,n){super(),this.lhs=t,this.rhs=r,this.sideEffects=n}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(!(this.lhs instanceof F.Name&&!t[this.lhs.str]&&!this.sideEffects))return this.rhs=qr(this.rhs,t,r),this}get names(){let t=this.lhs instanceof F.Name?{}:{...this.lhs.names};return Zs(t,this.rhs)}},Mc=class extends Fs{constructor(t,r,n,o){super(t,n,o),this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}},zc=class extends It{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`${this.label}:`+t}},Dc=class extends It{constructor(t){super(),this.label=t,this.names={}}render({_n:t}){return`break${this.label?` ${this.label}`:""};`+t}},Nc=class extends It{constructor(t){super(),this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}},Lc=class extends It{constructor(t){super(),this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){return this.code=qr(this.code,t,r),this}get names(){return this.code instanceof F._CodeOrName?this.code.names:{}}},Kn=class extends It{constructor(t=[]){super(),this.nodes=t}render(t){return this.nodes.reduce((r,n)=>r+n.render(t),"")}optimizeNodes(){let{nodes:t}=this,r=t.length;for(;r--;){let n=t[r].optimizeNodes();Array.isArray(n)?t.splice(r,1,...n):n?t[r]=n:t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){let{nodes:n}=this,o=n.length;for(;o--;){let s=n[o];s.optimizeNames(t,r)||(tk(t,s.names),n.splice(o,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>fr(t,r.names),{})}},At=class extends Kn{render(t){return"{"+t._n+super.render(t)+"}"+t._n}},jc=class extends Kn{},Fr=class extends At{};Fr.kind="else";var lr=class e extends At{constructor(t,r){super(r),this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);return this.else&&(r+="else "+this.else.render(t)),r}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let r=this.else;if(r){let n=r.optimizeNodes();r=this.else=Array.isArray(n)?new Fr(n):n}if(r)return t===!1?r instanceof e?r:r.nodes:this.nodes.length?this:new e(ug(t),r instanceof e?[r]:r.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(t,r){var n;if(this.else=(n=this.else)===null||n===void 0?void 0:n.optimizeNames(t,r),!!(super.optimizeNames(t,r)||this.else))return this.condition=qr(this.condition,t,r),this}get names(){let t=super.names;return Zs(t,this.condition),this.else&&fr(t,this.else.names),t}};lr.kind="if";var dr=class extends At{};dr.kind="for";var Uc=class extends dr{constructor(t){super(),this.iteration=t}render(t){return`for(${this.iteration})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iteration=qr(this.iteration,t,r),this}get names(){return fr(super.names,this.iteration.names)}},Fc=class extends dr{constructor(t,r,n,o){super(),this.varKind=t,this.name=r,this.from=n,this.to=o}render(t){let r=t.es5?lt.varKinds.var:this.varKind,{name:n,from:o,to:s}=this;return`for(${r} ${n}=${o}; ${n}<${s}; ${n}++)`+super.render(t)}get names(){let t=Zs(super.names,this.from);return Zs(t,this.to)}},qs=class extends dr{constructor(t,r,n,o){super(),this.loop=t,this.varKind=r,this.name=n,this.iterable=o}render(t){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(t)}optimizeNames(t,r){if(super.optimizeNames(t,r))return this.iterable=qr(this.iterable,t,r),this}get names(){return fr(super.names,this.iterable.names)}},Bn=class extends At{constructor(t,r,n){super(),this.name=t,this.args=r,this.async=n}render(t){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(t)}};Bn.kind="func";var Gn=class extends Kn{render(t){return"return "+super.render(t)}};Gn.kind="return";var qc=class extends At{render(t){let r="try"+super.render(t);return this.catch&&(r+=this.catch.render(t)),this.finally&&(r+=this.finally.render(t)),r}optimizeNodes(){var t,r;return super.optimizeNodes(),(t=this.catch)===null||t===void 0||t.optimizeNodes(),(r=this.finally)===null||r===void 0||r.optimizeNodes(),this}optimizeNames(t,r){var n,o;return super.optimizeNames(t,r),(n=this.catch)===null||n===void 0||n.optimizeNames(t,r),(o=this.finally)===null||o===void 0||o.optimizeNames(t,r),this}get names(){let t=super.names;return this.catch&&fr(t,this.catch.names),this.finally&&fr(t,this.finally.names),t}},Yn=class extends At{constructor(t){super(),this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};Yn.kind="catch";var Jn=class extends At{render(t){return"finally"+super.render(t)}};Jn.kind="finally";var Zc=class{constructor(t,r={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...r,_n:r.lines?`
16
+ `:""},this._extScope=t,this._scope=new lt.Scope({parent:t}),this._nodes=[new jc]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){let n=this._extScope.value(t,r);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(t,r){return this._extScope.getValue(t,r)}scopeRefs(t){return this._extScope.scopeRefs(t,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(t,r,n,o){let s=this._scope.toName(r);return n!==void 0&&o&&(this._constants[s.str]=n),this._leafNode(new Cc(t,s,n)),s}const(t,r,n){return this._def(lt.varKinds.const,t,r,n)}let(t,r,n){return this._def(lt.varKinds.let,t,r,n)}var(t,r,n){return this._def(lt.varKinds.var,t,r,n)}assign(t,r,n){return this._leafNode(new Fs(t,r,n))}add(t,r){return this._leafNode(new Mc(t,D.operators.ADD,r))}code(t){return typeof t=="function"?t():t!==F.nil&&this._leafNode(new Lc(t)),this}object(...t){let r=["{"];for(let[n,o]of t)r.length>1&&r.push(","),r.push(n),(n!==o||this.opts.es5)&&(r.push(":"),(0,F.addCodeArg)(r,o));return r.push("}"),new F._Code(r)}if(t,r,n){if(this._blockNode(new lr(t)),r&&n)this.code(r).else().code(n).endIf();else if(r)this.code(r).endIf();else if(n)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(t){return this._elseNode(new lr(t))}else(){return this._elseNode(new Fr)}endIf(){return this._endBlockNode(lr,Fr)}_for(t,r){return this._blockNode(t),r&&this.code(r).endFor(),this}for(t,r){return this._for(new Uc(t),r)}forRange(t,r,n,o,s=this.opts.es5?lt.varKinds.var:lt.varKinds.let){let i=this._scope.toName(t);return this._for(new Fc(s,i,r,n),()=>o(i))}forOf(t,r,n,o=lt.varKinds.const){let s=this._scope.toName(t);if(this.opts.es5){let i=r instanceof F.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,F._)`${i}.length`,a=>{this.var(s,(0,F._)`${i}[${a}]`),n(s)})}return this._for(new qs("of",o,s,r),()=>n(s))}forIn(t,r,n,o=this.opts.es5?lt.varKinds.var:lt.varKinds.const){if(this.opts.ownProperties)return this.forOf(t,(0,F._)`Object.keys(${r})`,n);let s=this._scope.toName(t);return this._for(new qs("in",o,s,r),()=>n(s))}endFor(){return this._endBlockNode(dr)}label(t){return this._leafNode(new zc(t))}break(t){return this._leafNode(new Dc(t))}return(t){let r=new Gn;if(this._blockNode(r),this.code(t),r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(Gn)}try(t,r,n){if(!r&&!n)throw new Error('CodeGen: "try" without "catch" and "finally"');let o=new qc;if(this._blockNode(o),this.code(t),r){let s=this.name("e");this._currNode=o.catch=new Yn(s),r(s)}return n&&(this._currNode=o.finally=new Jn,this.code(n)),this._endBlockNode(Yn,Jn)}throw(t){return this._leafNode(new Nc(t))}block(t,r){return this._blockStarts.push(this._nodes.length),t&&this.code(t).endBlock(r),this}endBlock(t){let r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");let n=this._nodes.length-r;if(n<0||t!==void 0&&n!==t)throw new Error(`CodeGen: wrong number of nodes: ${n} vs ${t} expected`);return this._nodes.length=r,this}func(t,r=F.nil,n,o){return this._blockNode(new Bn(t,r,n)),o&&this.code(o).endFunc(),this}endFunc(){return this._endBlockNode(Bn)}optimize(t=1){for(;t-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(t){return this._currNode.nodes.push(t),this}_blockNode(t){this._currNode.nodes.push(t),this._nodes.push(t)}_endBlockNode(t,r){let n=this._currNode;if(n instanceof t||r&&n instanceof r)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){let r=this._currNode;if(!(r instanceof lr))throw new Error('CodeGen: "else" without "if"');return this._currNode=r.else=t,this}get _root(){return this._nodes[0]}get _currNode(){let t=this._nodes;return t[t.length-1]}set _currNode(t){let r=this._nodes;r[r.length-1]=t}};D.CodeGen=Zc;function fr(e,t){for(let r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function Zs(e,t){return t instanceof F._CodeOrName?fr(e,t.names):e}function qr(e,t,r){if(e instanceof F.Name)return n(e);if(!o(e))return e;return new F._Code(e._items.reduce((s,i)=>(i instanceof F.Name&&(i=n(i)),i instanceof F._Code?s.push(...i._items):s.push(i),s),[]));function n(s){let i=r[s.str];return i===void 0||t[s.str]!==1?s:(delete t[s.str],i)}function o(s){return s instanceof F._Code&&s._items.some(i=>i instanceof F.Name&&t[i.str]===1&&r[i.str]!==void 0)}}function tk(e,t){for(let r in t)e[r]=(e[r]||0)-(t[r]||0)}function ug(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,F._)`!${Hc(e)}`}D.not=ug;var rk=lg(D.operators.AND);function nk(...e){return e.reduce(rk)}D.and=nk;var ok=lg(D.operators.OR);function sk(...e){return e.reduce(ok)}D.or=sk;function lg(e){return(t,r)=>t===F.nil?r:r===F.nil?t:(0,F._)`${Hc(t)} ${e} ${Hc(r)}`}function Hc(e){return e instanceof F.Name?e:(0,F._)`(${e})`}});var q=w(N=>{"use strict";Object.defineProperty(N,"__esModule",{value:!0});N.checkStrictMode=N.getErrorPath=N.Type=N.useFunc=N.setEvaluated=N.evaluatedPropsToName=N.mergeEvaluated=N.eachItem=N.unescapeJsonPointer=N.escapeJsonPointer=N.escapeFragment=N.unescapeFragment=N.schemaRefOrVal=N.schemaHasRulesButRef=N.schemaHasRules=N.checkUnknownRules=N.alwaysValidSchema=N.toHash=void 0;var G=M(),ik=Vn();function ak(e){let t={};for(let r of e)t[r]=!0;return t}N.toHash=ak;function ck(e,t){return typeof t=="boolean"?t:Object.keys(t).length===0?!0:(pg(e,t),!mg(t,e.self.RULES.all))}N.alwaysValidSchema=ck;function pg(e,t=e.schema){let{opts:r,self:n}=e;if(!r.strictSchema||typeof t=="boolean")return;let o=n.RULES.keywords;for(let s in t)o[s]||_g(e,`unknown keyword: "${s}"`)}N.checkUnknownRules=pg;function mg(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(t[r])return!0;return!1}N.schemaHasRules=mg;function uk(e,t){if(typeof e=="boolean")return!e;for(let r in e)if(r!=="$ref"&&t.all[r])return!0;return!1}N.schemaHasRulesButRef=uk;function lk({topSchemaRef:e,schemaPath:t},r,n,o){if(!o){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,G._)`${r}`}return(0,G._)`${e}${t}${(0,G.getProperty)(n)}`}N.schemaRefOrVal=lk;function dk(e){return hg(decodeURIComponent(e))}N.unescapeFragment=dk;function fk(e){return encodeURIComponent(Vc(e))}N.escapeFragment=fk;function Vc(e){return typeof e=="number"?`${e}`:e.replace(/~/g,"~0").replace(/\//g,"~1")}N.escapeJsonPointer=Vc;function hg(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}N.unescapeJsonPointer=hg;function pk(e,t){if(Array.isArray(e))for(let r of e)t(r);else t(e)}N.eachItem=pk;function dg({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:n}){return(o,s,i,a)=>{let c=i===void 0?s:i instanceof G.Name?(s instanceof G.Name?e(o,s,i):t(o,s,i),i):s instanceof G.Name?(t(o,i,s),s):r(s,i);return a===G.Name&&!(c instanceof G.Name)?n(o,c):c}}N.mergeEvaluated={props:dg({mergeNames:(e,t,r)=>e.if((0,G._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,G._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,G._)`${r} || {}`).code((0,G._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,G._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,G._)`${r} || {}`),Kc(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:gg}),items:dg({mergeNames:(e,t,r)=>e.if((0,G._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,G._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,G._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,G._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function gg(e,t){if(t===!0)return e.var("props",!0);let r=e.var("props",(0,G._)`{}`);return t!==void 0&&Kc(e,r,t),r}N.evaluatedPropsToName=gg;function Kc(e,t,r){Object.keys(r).forEach(n=>e.assign((0,G._)`${t}${(0,G.getProperty)(n)}`,!0))}N.setEvaluated=Kc;var fg={};function mk(e,t){return e.scopeValue("func",{ref:t,code:fg[t.code]||(fg[t.code]=new ik._Code(t.code))})}N.useFunc=mk;var Wc;(function(e){e[e.Num=0]="Num",e[e.Str=1]="Str"})(Wc||(N.Type=Wc={}));function hk(e,t,r){if(e instanceof G.Name){let n=t===Wc.Num;return r?n?(0,G._)`"[" + ${e} + "]"`:(0,G._)`"['" + ${e} + "']"`:n?(0,G._)`"/" + ${e}`:(0,G._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,G.getProperty)(e).toString():"/"+Vc(e)}N.getErrorPath=hk;function _g(e,t,r=e.opts.strictSchema){if(r){if(t=`strict mode: ${t}`,r===!0)throw new Error(t);e.self.logger.warn(t)}}N.checkStrictMode=_g});var Ct=w(Bc=>{"use strict";Object.defineProperty(Bc,"__esModule",{value:!0});var ve=M(),gk={data:new ve.Name("data"),valCxt:new ve.Name("valCxt"),instancePath:new ve.Name("instancePath"),parentData:new ve.Name("parentData"),parentDataProperty:new ve.Name("parentDataProperty"),rootData:new ve.Name("rootData"),dynamicAnchors:new ve.Name("dynamicAnchors"),vErrors:new ve.Name("vErrors"),errors:new ve.Name("errors"),this:new ve.Name("this"),self:new ve.Name("self"),scope:new ve.Name("scope"),json:new ve.Name("json"),jsonPos:new ve.Name("jsonPos"),jsonLen:new ve.Name("jsonLen"),jsonPart:new ve.Name("jsonPart")};Bc.default=gk});var Xn=w(we=>{"use strict";Object.defineProperty(we,"__esModule",{value:!0});we.extendErrors=we.resetErrorsCount=we.reportExtraError=we.reportError=we.keyword$DataError=we.keywordError=void 0;var Z=M(),Ws=q(),Te=Ct();we.keywordError={message:({keyword:e})=>(0,Z.str)`must pass "${e}" keyword validation`};we.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,Z.str)`"${e}" keyword must be ${t} ($data)`:(0,Z.str)`"${e}" keyword is invalid ($data)`};function _k(e,t=we.keywordError,r,n){let{it:o}=e,{gen:s,compositeRule:i,allErrors:a}=o,c=bg(e,t,r);n??(i||a)?yg(s,c):Sg(o,(0,Z._)`[${c}]`)}we.reportError=_k;function yk(e,t=we.keywordError,r){let{it:n}=e,{gen:o,compositeRule:s,allErrors:i}=n,a=bg(e,t,r);yg(o,a),s||i||Sg(n,Te.default.vErrors)}we.reportExtraError=yk;function Sk(e,t){e.assign(Te.default.errors,t),e.if((0,Z._)`${Te.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,Z._)`${Te.default.vErrors}.length`,t),()=>e.assign(Te.default.vErrors,null)))}we.resetErrorsCount=Sk;function bk({gen:e,keyword:t,schemaValue:r,data:n,errsCount:o,it:s}){if(o===void 0)throw new Error("ajv implementation error");let i=e.name("err");e.forRange("i",o,Te.default.errors,a=>{e.const(i,(0,Z._)`${Te.default.vErrors}[${a}]`),e.if((0,Z._)`${i}.instancePath === undefined`,()=>e.assign((0,Z._)`${i}.instancePath`,(0,Z.strConcat)(Te.default.instancePath,s.errorPath))),e.assign((0,Z._)`${i}.schemaPath`,(0,Z.str)`${s.errSchemaPath}/${t}`),s.opts.verbose&&(e.assign((0,Z._)`${i}.schema`,r),e.assign((0,Z._)`${i}.data`,n))})}we.extendErrors=bk;function yg(e,t){let r=e.const("err",t);e.if((0,Z._)`${Te.default.vErrors} === null`,()=>e.assign(Te.default.vErrors,(0,Z._)`[${r}]`),(0,Z._)`${Te.default.vErrors}.push(${r})`),e.code((0,Z._)`${Te.default.errors}++`)}function Sg(e,t){let{gen:r,validateName:n,schemaEnv:o}=e;o.$async?r.throw((0,Z._)`new ${e.ValidationError}(${t})`):(r.assign((0,Z._)`${n}.errors`,t),r.return(!1))}var pr={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 bg(e,t,r){let{createErrors:n}=e.it;return n===!1?(0,Z._)`{}`:Ek(e,t,r)}function Ek(e,t,r={}){let{gen:n,it:o}=e,s=[vk(o,r),wk(e,r)];return kk(e,t,s),n.object(...s)}function vk({errorPath:e},{instancePath:t}){let r=t?(0,Z.str)`${e}${(0,Ws.getErrorPath)(t,Ws.Type.Str)}`:e;return[Te.default.instancePath,(0,Z.strConcat)(Te.default.instancePath,r)]}function wk({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:n}){let o=n?t:(0,Z.str)`${t}/${e}`;return r&&(o=(0,Z.str)`${o}${(0,Ws.getErrorPath)(r,Ws.Type.Str)}`),[pr.schemaPath,o]}function kk(e,{params:t,message:r},n){let{keyword:o,data:s,schemaValue:i,it:a}=e,{opts:c,propertyName:u,topSchemaRef:l,schemaPath:d}=a;n.push([pr.keyword,o],[pr.params,typeof t=="function"?t(e):t||(0,Z._)`{}`]),c.messages&&n.push([pr.message,typeof r=="function"?r(e):r]),c.verbose&&n.push([pr.schema,i],[pr.parentSchema,(0,Z._)`${l}${d}`],[Te.default.data,s]),u&&n.push([pr.propertyName,u])}});var vg=w(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Zr.boolOrEmptySchema=Zr.topBoolOrEmptySchema=void 0;var xk=Xn(),Pk=M(),$k=Ct(),Tk={message:"boolean schema is false"};function Rk(e){let{gen:t,schema:r,validateName:n}=e;r===!1?Eg(e,!1):typeof r=="object"&&r.$async===!0?t.return($k.default.data):(t.assign((0,Pk._)`${n}.errors`,null),t.return(!0))}Zr.topBoolOrEmptySchema=Rk;function Ok(e,t){let{gen:r,schema:n}=e;n===!1?(r.var(t,!1),Eg(e)):r.var(t,!0)}Zr.boolOrEmptySchema=Ok;function Eg(e,t){let{gen:r,data:n}=e,o={gen:r,keyword:"false schema",data:n,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,xk.reportError)(o,Tk,void 0,t)}});var Gc=w(Hr=>{"use strict";Object.defineProperty(Hr,"__esModule",{value:!0});Hr.getRules=Hr.isJSONType=void 0;var Ik=["string","number","integer","boolean","null","object","array"],Ak=new Set(Ik);function Ck(e){return typeof e=="string"&&Ak.has(e)}Hr.isJSONType=Ck;function Mk(){let e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}Hr.getRules=Mk});var Yc=w(Bt=>{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Bt.shouldUseRule=Bt.shouldUseGroup=Bt.schemaHasRulesForType=void 0;function zk({schema:e,self:t},r){let n=t.RULES.types[r];return n&&n!==!0&&wg(e,n)}Bt.schemaHasRulesForType=zk;function wg(e,t){return t.rules.some(r=>kg(e,r))}Bt.shouldUseGroup=wg;function kg(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(n=>e[n]!==void 0))}Bt.shouldUseRule=kg});var Qn=w(ke=>{"use strict";Object.defineProperty(ke,"__esModule",{value:!0});ke.reportTypeError=ke.checkDataTypes=ke.checkDataType=ke.coerceAndCheckDataType=ke.getJSONTypes=ke.getSchemaTypes=ke.DataType=void 0;var Dk=Gc(),Nk=Yc(),Lk=Xn(),C=M(),xg=q(),Wr;(function(e){e[e.Correct=0]="Correct",e[e.Wrong=1]="Wrong"})(Wr||(ke.DataType=Wr={}));function jk(e){let t=Pg(e.type);if(t.includes("null")){if(e.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!t.length&&e.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');e.nullable===!0&&t.push("null")}return t}ke.getSchemaTypes=jk;function Pg(e){let t=Array.isArray(e)?e:e?[e]:[];if(t.every(Dk.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}ke.getJSONTypes=Pg;function Uk(e,t){let{gen:r,data:n,opts:o}=e,s=Fk(t,o.coerceTypes),i=t.length>0&&!(s.length===0&&t.length===1&&(0,Nk.schemaHasRulesForType)(e,t[0]));if(i){let a=Xc(t,n,o.strictNumbers,Wr.Wrong);r.if(a,()=>{s.length?qk(e,t,s):Qc(e)})}return i}ke.coerceAndCheckDataType=Uk;var $g=new Set(["string","number","integer","boolean","null"]);function Fk(e,t){return t?e.filter(r=>$g.has(r)||t==="array"&&r==="array"):[]}function qk(e,t,r){let{gen:n,data:o,opts:s}=e,i=n.let("dataType",(0,C._)`typeof ${o}`),a=n.let("coerced",(0,C._)`undefined`);s.coerceTypes==="array"&&n.if((0,C._)`${i} == 'object' && Array.isArray(${o}) && ${o}.length == 1`,()=>n.assign(o,(0,C._)`${o}[0]`).assign(i,(0,C._)`typeof ${o}`).if(Xc(t,o,s.strictNumbers),()=>n.assign(a,o))),n.if((0,C._)`${a} !== undefined`);for(let u of r)($g.has(u)||u==="array"&&s.coerceTypes==="array")&&c(u);n.else(),Qc(e),n.endIf(),n.if((0,C._)`${a} !== undefined`,()=>{n.assign(o,a),Zk(e,a)});function c(u){switch(u){case"string":n.elseIf((0,C._)`${i} == "number" || ${i} == "boolean"`).assign(a,(0,C._)`"" + ${o}`).elseIf((0,C._)`${o} === null`).assign(a,(0,C._)`""`);return;case"number":n.elseIf((0,C._)`${i} == "boolean" || ${o} === null
17
17
  || (${i} == "string" && ${o} && ${o} == +${o})`).assign(a,(0,C._)`+${o}`);return;case"integer":n.elseIf((0,C._)`${i} === "boolean" || ${o} === null
18
18
  || (${i} === "string" && ${o} && ${o} == +${o} && !(${o} % 1))`).assign(a,(0,C._)`+${o}`);return;case"boolean":n.elseIf((0,C._)`${o} === "false" || ${o} === 0 || ${o} === null`).assign(a,!1).elseIf((0,C._)`${o} === "true" || ${o} === 1`).assign(a,!0);return;case"null":n.elseIf((0,C._)`${o} === "" || ${o} === 0 || ${o} === false`),n.assign(a,null);return;case"array":n.elseIf((0,C._)`${i} === "string" || ${i} === "number"
19
- || ${i} === "boolean" || ${o} === null`).assign(a,(0,C._)`[${o}]`)}}}function Zk({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,C._)`${t} !== undefined`,()=>e.assign((0,C._)`${t}[${r}]`,n))}function Jc(e,t,r,n=Wr.Correct){let o=n===Wr.Correct?C.operators.EQ:C.operators.NEQ,s;switch(e){case"null":return(0,C._)`${t} ${o} null`;case"array":s=(0,C._)`Array.isArray(${t})`;break;case"object":s=(0,C._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,C._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,C._)`typeof ${t} ${o} ${e}`}return n===Wr.Correct?s:(0,C.not)(s);function i(a=C.nil){return(0,C.and)((0,C._)`typeof ${t} == "number"`,a,r?(0,C._)`isFinite(${t})`:C.nil)}}ke.checkDataType=Jc;function Xc(e,t,r,n){if(e.length===1)return Jc(e[0],t,r,n);let o,s=(0,kg.toHash)(e);if(s.array&&s.object){let i=(0,C._)`typeof ${t} != "object"`;o=s.null?i:(0,C._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=C.nil;s.number&&delete s.integer;for(let i in s)o=(0,C.and)(o,Jc(i,t,r,n));return o}ke.checkDataTypes=Xc;var Hk={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,C._)`{type: ${e}}`:(0,C._)`{type: ${t}}`};function Qc(e){let t=Wk(e);(0,Lk.reportError)(t,Hk)}ke.reportTypeError=Qc;function Wk(e){let{gen:t,data:r,schema:n}=e,o=(0,kg.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Tg=w(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.assignDefaults=void 0;var Vr=M(),Vk=q();function Kk(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)$g(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>$g(e,s,o.default))}Vs.assignDefaults=Kk;function $g(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Vr._)`${s}${(0,Vr.getProperty)(t)}`;if(o){(0,Vk.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Vr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Vr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Vr._)`${a} = ${(0,Vr.stringify)(r)}`)}});var et=w(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.validateUnion=B.validateArray=B.usePattern=B.callValidateCode=B.schemaProperties=B.allSchemaProperties=B.noPropertyInData=B.propertyInData=B.isOwnProperty=B.hasPropFunc=B.reportMissingProp=B.checkMissingProp=B.checkReportMissingProp=void 0;var te=M(),eu=q(),Gt=Ct(),Bk=q();function Gk(e,t){let{gen:r,data:n,it:o}=e;r.if(ru(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,te._)`${t}`},!0),e.error()})}B.checkReportMissingProp=Gk;function Yk({gen:e,data:t,it:{opts:r}},n,o){return(0,te.or)(...n.map(s=>(0,te.and)(ru(e,t,s,r.ownProperties),(0,te._)`${o} = ${s}`)))}B.checkMissingProp=Yk;function Jk(e,t){e.setParams({missingProperty:t},!0),e.error()}B.reportMissingProp=Jk;function Rg(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,te._)`Object.prototype.hasOwnProperty`})}B.hasPropFunc=Rg;function tu(e,t,r){return(0,te._)`${Rg(e)}.call(${t}, ${r})`}B.isOwnProperty=tu;function Xk(e,t,r,n){let o=(0,te._)`${t}${(0,te.getProperty)(r)} !== undefined`;return n?(0,te._)`${o} && ${tu(e,t,r)}`:o}B.propertyInData=Xk;function ru(e,t,r,n){let o=(0,te._)`${t}${(0,te.getProperty)(r)} === undefined`;return n?(0,te.or)(o,(0,te.not)(tu(e,t,r))):o}B.noPropertyInData=ru;function Og(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}B.allSchemaProperties=Og;function Qk(e,t){return Og(t).filter(r=>!(0,eu.alwaysValidSchema)(e,t[r]))}B.schemaProperties=Qk;function ex({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,te._)`${e}, ${t}, ${n}${o}`:t,d=[[Gt.default.instancePath,(0,te.strConcat)(Gt.default.instancePath,s)],[Gt.default.parentData,i.parentData],[Gt.default.parentDataProperty,i.parentDataProperty],[Gt.default.rootData,Gt.default.rootData]];i.opts.dynamicRef&&d.push([Gt.default.dynamicAnchors,Gt.default.dynamicAnchors]);let f=(0,te._)`${l}, ${r.object(...d)}`;return c!==te.nil?(0,te._)`${a}.call(${c}, ${f})`:(0,te._)`${a}(${f})`}B.callValidateCode=ex;var tx=(0,te._)`new RegExp`;function rx({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,te._)`${o.code==="new RegExp"?tx:(0,Bk.useFunc)(e,o)}(${r}, ${n})`})}B.usePattern=rx;function nx(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,te._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:eu.Type.Num},s),t.if((0,te.not)(s),a)})}}B.validateArray=nx;function ox(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,eu.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,te._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,te.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}B.validateUnion=ox});var Cg=w(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.validateKeywordUsage=St.validSchemaType=St.funcKeywordCode=St.macroKeywordCode=void 0;var Re=M(),mr=Ct(),sx=et(),ix=Xn();function ax(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=Ag(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:Re.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}St.macroKeywordCode=ax;function cx(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;lx(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=Ag(n,o,u),d=n.let("valid");e.block$data(d,f),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function f(){if(t.errors===!1)h(),t.modifying&&Ig(e),g(()=>e.error());else{let y=t.async?p():m();t.modifying&&Ig(e),g(()=>ux(e,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,Re._)`await `),E=>n.assign(d,!1).if((0,Re._)`${E} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,Re._)`${E}.errors`),()=>n.throw(E))),y}function m(){let y=(0,Re._)`${l}.errors`;return n.assign(y,null),h(Re.nil),y}function h(y=t.async?(0,Re._)`await `:Re.nil){let E=c.opts.passContext?mr.default.this:mr.default.self,v=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Re._)`${y}${(0,sx.callValidateCode)(e,l,E,v)}`,t.modifying)}function g(y){var E;n.if((0,Re.not)((E=t.valid)!==null&&E!==void 0?E:d),y)}}St.funcKeywordCode=cx;function Ig(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Re._)`${n.parentData}[${n.parentDataProperty}]`))}function ux(e,t){let{gen:r}=e;r.if((0,Re._)`Array.isArray(${t})`,()=>{r.assign(mr.default.vErrors,(0,Re._)`${mr.default.vErrors} === null ? ${t} : ${mr.default.vErrors}.concat(${t})`).assign(mr.default.errors,(0,Re._)`${mr.default.vErrors}.length`),(0,ix.extendErrors)(e)},()=>e.error())}function lx({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Ag(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Re.stringify)(r)})}function dx(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}St.validSchemaType=dx;function fx({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}St.validateKeywordUsage=fx});var zg=w(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.extendSubschemaMode=Yt.extendSubschemaData=Yt.getSubschema=void 0;var bt=M(),Mg=q();function px(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,bt._)`${e.schemaPath}${(0,bt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,bt._)`${e.schemaPath}${(0,bt.getProperty)(t)}${(0,bt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Mg.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')}Yt.getSubschema=px;function mx(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,f=a.let("data",(0,bt._)`${t.data}${(0,bt.getProperty)(r)}`,!0);c(f),e.errorPath=(0,bt.str)`${u}${(0,Mg.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,bt._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof bt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Yt.extendSubschemaData=mx;function hx(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Yt.extendSubschemaMode=hx});var nu=w((fj,Dg)=>{"use strict";Dg.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var Lg=w((pj,Ng)=>{"use strict";var Jt=Ng.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Ks(t,n,o,e,"",e)};Jt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Jt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Jt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Jt.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 Ks(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Jt.arrayKeywords)for(var f=0;f<d.length;f++)Ks(e,t,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in Jt.propsKeywords){if(d&&typeof d=="object")for(var p in d)Ks(e,t,r,d[p],o+"/"+l+"/"+gx(p),s,o,l,n,p)}else(l in Jt.keywords||e.allKeys&&!(l in Jt.skipKeywords))&&Ks(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function gx(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var eo=w(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.getSchemaRefs=je.resolveUrl=je.normalizeId=je._getFullPath=je.getFullPath=je.inlineRef=void 0;var _x=q(),yx=nu(),Sx=Lg(),bx=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Ex(e,t=!0){return typeof e=="boolean"?!0:t===!0?!ou(e):t?jg(e)<=t:!1}je.inlineRef=Ex;var vx=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function ou(e){for(let t in e){if(vx.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(ou)||typeof r=="object"&&ou(r))return!0}return!1}function jg(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!bx.has(r)&&(typeof e[r]=="object"&&(0,_x.eachItem)(e[r],n=>t+=jg(n)),t===1/0))return 1/0}return t}function Ug(e,t="",r){r!==!1&&(t=Kr(t));let n=e.parse(t);return Fg(e,n)}je.getFullPath=Ug;function Fg(e,t){return e.serialize(t).split("#")[0]+"#"}je._getFullPath=Fg;var wx=/#\/?$/;function Kr(e){return e?e.replace(wx,""):""}je.normalizeId=Kr;function kx(e,t,r){return r=Kr(r),e.resolve(t,r)}je.resolveUrl=kx;var xx=/^[a-z_][-a-z0-9._]*$/i;function Px(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Kr(e[r]||t),s={"":o},i=Ug(n,o,!1),a={},c=new Set;return Sx(e,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=i+f,g=s[m];typeof d[r]=="string"&&(g=y.call(this,d[r])),E.call(this,d.$anchor),E.call(this,d.$dynamicAnchor),s[f]=g;function y(v){let I=this.opts.uriResolver.resolve;if(v=Kr(g?I(g,v):v),c.has(v))throw l(v);c.add(v);let x=this.refs[v];return typeof x=="string"&&(x=this.refs[x]),typeof x=="object"?u(d,x.schema,v):v!==Kr(h)&&(v[0]==="#"?(u(d,a[v],v),a[v]=d):this.refs[v]=h),v}function E(v){if(typeof v=="string"){if(!xx.test(v))throw new Error(`invalid anchor "${v}"`);y.call(this,`#${v}`)}}}),a;function u(d,f,p){if(f!==void 0&&!yx(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}je.getSchemaRefs=Px});var no=w(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.getData=Xt.KeywordCxt=Xt.validateFunctionCode=void 0;var Vg=Eg(),qg=Qn(),iu=Yc(),Bs=Qn(),$x=Tg(),ro=Cg(),su=zg(),$=M(),O=Ct(),Tx=eo(),Mt=q(),to=Xn();function Rx(e){if(Gg(e)&&(Yg(e),Bg(e))){Ax(e);return}Kg(e,()=>(0,Vg.topBoolOrEmptySchema)(e))}Xt.validateFunctionCode=Rx;function Kg({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,$._)`${O.default.data}, ${O.default.valCxt}`,n.$async,()=>{e.code((0,$._)`"use strict"; ${Zg(r,o)}`),Ix(e,o),e.code(s)}):e.func(t,(0,$._)`${O.default.data}, ${Ox(o)}`,n.$async,()=>e.code(Zg(r,o)).code(s))}function Ox(e){return(0,$._)`{${O.default.instancePath}="", ${O.default.parentData}, ${O.default.parentDataProperty}, ${O.default.rootData}=${O.default.data}${e.dynamicRef?(0,$._)`, ${O.default.dynamicAnchors}={}`:$.nil}}={}`}function Ix(e,t){e.if(O.default.valCxt,()=>{e.var(O.default.instancePath,(0,$._)`${O.default.valCxt}.${O.default.instancePath}`),e.var(O.default.parentData,(0,$._)`${O.default.valCxt}.${O.default.parentData}`),e.var(O.default.parentDataProperty,(0,$._)`${O.default.valCxt}.${O.default.parentDataProperty}`),e.var(O.default.rootData,(0,$._)`${O.default.valCxt}.${O.default.rootData}`),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0,$._)`${O.default.valCxt}.${O.default.dynamicAnchors}`)},()=>{e.var(O.default.instancePath,(0,$._)`""`),e.var(O.default.parentData,(0,$._)`undefined`),e.var(O.default.parentDataProperty,(0,$._)`undefined`),e.var(O.default.rootData,O.default.data),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0,$._)`{}`)})}function Ax(e){let{schema:t,opts:r,gen:n}=e;Kg(e,()=>{r.$comment&&t.$comment&&Xg(e),Nx(e),n.let(O.default.vErrors,null),n.let(O.default.errors,0),r.unevaluated&&Cx(e),Jg(e),Ux(e)})}function Cx(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,$._)`${r}.evaluated`),t.if((0,$._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,$._)`${e.evaluated}.props`,(0,$._)`undefined`)),t.if((0,$._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,$._)`${e.evaluated}.items`,(0,$._)`undefined`))}function Zg(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,$._)`/*# sourceURL=${r} */`:$.nil}function Mx(e,t){if(Gg(e)&&(Yg(e),Bg(e))){zx(e,t);return}(0,Vg.boolOrEmptySchema)(e,t)}function Bg({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function Gg(e){return typeof e.schema!="boolean"}function zx(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&Xg(e),Lx(e),jx(e);let s=n.const("_errs",O.default.errors);Jg(e,s),n.var(t,(0,$._)`${s} === ${O.default.errors}`)}function Yg(e){(0,Mt.checkUnknownRules)(e),Dx(e)}function Jg(e,t){if(e.opts.jtd)return Hg(e,[],!1,t);let r=(0,qg.getSchemaTypes)(e.schema),n=(0,qg.coerceAndCheckDataType)(e,r);Hg(e,r,!n,t)}function Dx(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Mt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Nx(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Mt.checkStrictMode)(e,"default is ignored in the schema root")}function Lx(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Tx.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function jx(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Xg({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,$._)`${O.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,$.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,$._)`${O.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function Ux(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,$._)`${O.default.errors} === 0`,()=>t.return(O.default.data),()=>t.throw((0,$._)`new ${o}(${O.default.vErrors})`)):(t.assign((0,$._)`${n}.errors`,O.default.vErrors),s.unevaluated&&Fx(e),t.return((0,$._)`${O.default.errors} === 0`))}function Fx({gen:e,evaluated:t,props:r,items:n}){r instanceof $.Name&&e.assign((0,$._)`${t}.props`,r),n instanceof $.Name&&e.assign((0,$._)`${t}.items`,n)}function Hg(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Mt.schemaHasRulesButRef)(s,l))){o.block(()=>e_(e,"$ref",l.all.$ref.definition));return}c.jtd||qx(e,t),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,iu.shouldUseGroup)(s,f)&&(f.type?(o.if((0,Bs.checkDataType)(f.type,i,c.strictNumbers)),Wg(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,Bs.reportTypeError)(e)),o.endIf()):Wg(e,f),a||o.if((0,$._)`${O.default.errors} === ${n||0}`))}}function Wg(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,$x.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,iu.shouldUseRule)(n,s)&&e_(e,s.keyword,s.definition,t.type)})}function qx(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Zx(e,t),e.opts.allowUnionTypes||Hx(e,t),Wx(e,e.dataTypes))}function Zx(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{Qg(e.dataTypes,r)||au(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Kx(e,t)}}function Hx(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&au(e,"use allowUnionTypes to allow union type keyword")}function Wx(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,iu.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Vx(t,i))&&au(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Vx(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function Qg(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Kx(e,t){let r=[];for(let n of e.dataTypes)Qg(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function au(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Mt.checkStrictMode)(e,t,e.opts.strictTypes)}var Gs=class{constructor(t,r,n){if((0,ro.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Mt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",t_(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,ro.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",O.default.errors))}result(t,r,n){this.failResult((0,$.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,$.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,$._)`${r} !== undefined && (${(0,$.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?to.reportExtraError:to.reportError)(this,this.def.error,r)}$dataError(){(0,to.reportError)(this,this.def.$dataError||to.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,to.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=$.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=$.nil,r=$.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,$.or)((0,$._)`${o} === undefined`,r)),t!==$.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==$.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,$.or)(i(),a());function i(){if(n.length){if(!(r instanceof $.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,$._)`${(0,Bs.checkDataTypes)(c,r,s.opts.strictNumbers,Bs.DataType.Wrong)}`}return $.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,$._)`!${c}(${r})`}return $.nil}}subschema(t,r){let n=(0,su.getSubschema)(this.it,t);(0,su.extendSubschemaData)(n,this.it,t),(0,su.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return Mx(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Mt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Mt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,$.Name)),!0}};Xt.KeywordCxt=Gs;function e_(e,t,r,n){let o=new Gs(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,ro.funcKeywordCode)(o,r):"macro"in r?(0,ro.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,ro.funcKeywordCode)(o,r)}var Bx=/^\/(?:[^~]|~0|~1)*$/,Gx=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function t_(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return O.default.rootData;if(e[0]==="/"){if(!Bx.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=O.default.rootData}else{let u=Gx.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,$._)`${s}${(0,$.getProperty)((0,Mt.unescapeJsonPointer)(u))}`,i=(0,$._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Xt.getData=t_});var Ys=w(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});var cu=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};uu.default=cu});var oo=w(fu=>{"use strict";Object.defineProperty(fu,"__esModule",{value:!0});var lu=eo(),du=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,lu.resolveUrl)(t,r,n),this.missingSchema=(0,lu.normalizeId)((0,lu.getFullPath)(t,this.missingRef))}};fu.default=du});var Xs=w(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.resolveSchema=tt.getCompilingSchema=tt.resolveRef=tt.compileSchema=tt.SchemaEnv=void 0;var dt=M(),Yx=Ys(),hr=Ct(),ft=eo(),r_=q(),Jx=no(),Br=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,ft.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};tt.SchemaEnv=Br;function mu(e){let t=n_.call(this,e);if(t)return t;let r=(0,ft.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new dt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:Yx.default,code:(0,dt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:hr.default.data,parentData:hr.default.parentData,parentDataProperty:hr.default.parentDataProperty,dataNames:[hr.default.data],dataPathArr:[dt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,dt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:dt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,dt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,Jx.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(hr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let p=new Function(`${hr.default.self}`,`${hr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=u;p.evaluated={props:m instanceof dt.Name?void 0:m,items:h instanceof dt.Name?void 0:h,dynamicProps:m instanceof dt.Name,dynamicItems:h instanceof dt.Name},p.source&&(p.source.evaluated=(0,dt.stringify)(p.evaluated))}return e.validate=p,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}tt.compileSchema=mu;function Xx(e,t,r){var n;r=(0,ft.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=tP.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Br({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=Qx.call(this,s)}tt.resolveRef=Xx;function Qx(e){return(0,ft.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:mu.call(this,e)}function n_(e){for(let t of this._compilations)if(eP(t,e))return t}tt.getCompilingSchema=n_;function eP(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function tP(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Js.call(this,e,t)}function Js(e,t){let r=this.opts.uriResolver.parse(t),n=(0,ft._getFullPath)(this.opts.uriResolver,r),o=(0,ft.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return pu.call(this,r,e);let s=(0,ft.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Js.call(this,e,i);return typeof a?.schema!="object"?void 0:pu.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||mu.call(this,i),s===(0,ft.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,ft.resolveUrl)(this.opts.uriResolver,o,u)),new Br({schema:a,schemaId:c,root:e,baseId:o})}return pu.call(this,r,i)}}tt.resolveSchema=Js;var rP=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function pu(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,r_.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!rP.has(a)&&u&&(t=(0,ft.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,r_.schemaHasRulesButRef)(r,this.RULES)){let a=(0,ft.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Js.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Br({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var o_=w((Sj,nP)=>{nP.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 bu=w((bj,d_)=>{"use strict";var oP=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),gu=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),sP=RegExp.prototype.test.bind(/^\d*$/u),gr=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),_u=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),i_=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),yu=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),iP=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Ue=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Ue[t]="%"+e[t>>4]+e[t&15]}function xe(e){return e<2048?Ue[192|e>>6]+Ue[128|e&63]:e<65536?Ue[224|e>>12]+Ue[128|e>>6&63]+Ue[128|e&63]:Ue[240|e>>18]+Ue[128|e>>12&63]+Ue[128|e>>6&63]+Ue[128|e&63]}function aP(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var cP=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),uP=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),lP=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),dP=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function fP(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!lP(e[t])){if(e[t]==="%"&&t+2<e.length&&gr(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function s_(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function pP(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||t!==-1&&n.length===0||!gu(c))return;s+=2;continue}if(!cP(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:s_(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return s_(i)}function hu(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&uP(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(mP(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!fP(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=pP(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function mP(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function hP(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}var gP={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},_P=/[@/?#:]/g,yP=/[@/?#]/g;function a_(e,t){let r=t?yP:_P;return r.lastIndex=0,e.replace(r,n=>gP[n])}function c_(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&_u(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function SP(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&_u(i)?t+=i:t+="%"+s,r+=2;continue}}if(i_(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=l_(o)?n:Ue[o];else if(o<55296||o>57343)t+=xe(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=xe(65536+(o-55296<<10)+(s-56320)),r++):t+=xe(65533)}else t+=xe(65533)}}return t}function bP(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(gr(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),i_(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Ue[i];else if(i<55296||i>57343)r+=xe(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=xe(65536+(i-55296<<10)+(a-56320)),o++):r+=xe(65533)}else r+=xe(65533)}}return r}function Su(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(gr(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Ue[s];else if(s<55296||s>57343)r+=xe(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=xe(65536+(s-55296<<10)+(i-56320)),n++):r+=xe(65533)}else r+=xe(65533)}}return r}function u_(e){return Su(e,iP)}function EP(e){return Su(e,yu)}function vP(e){return Su(e,yu)}function l_(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function wP(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));_u(i)?t+=i:t+="%"+s,r+=2;continue}}if(yu(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=l_(o)?n:Ue[o];else if(o<55296||o>57343)t+=xe(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=xe(65536+(o-55296<<10)+(s-56320)),r++):t+=xe(65533)}else t+=xe(65533)}}return t}function kP(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(gr(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function xP(e){let t=[];if(e.userinfo!==void 0&&(t.push(u_(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!gu(r)){let n=hu(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=c_(r,!0),n=hu(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=a_(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!sP(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}d_.exports={nonSimpleDomain:dP,recomposeAuthority:xP,reescapeHostDelimiters:a_,normalizePercentEncoding:c_,normalizePathEncoding:SP,serializePathEncoding:bP,normalizeQueryFragmentEncoding:wP,encodeUserinfo:u_,encodeQuery:EP,encodeFragment:vP,escapePreservingEscapes:kP,removeDotSegments:hP,isIPv4:gu,isUUID:oP,normalizeIPv6:hu,stringArrayToHexStripped:aP}});var g_=w((Ej,h_)=>{"use strict";var{isUUID:PP}=bu(),$P=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,TP=["http","https","ws","wss","urn","urn:uuid"];function RP(e){return TP.indexOf(e)!==-1}function Eu(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function f_(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function p_(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function OP(e){return e.secure=Eu(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function IP(e){if((e.port===(Eu(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function AP(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match($P);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=vu(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function CP(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=vu(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function MP(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!PP(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function zP(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var m_={scheme:"http",domainHost:!0,parse:f_,serialize:p_},DP={scheme:"https",domainHost:m_.domainHost,parse:f_,serialize:p_},Qs={scheme:"ws",domainHost:!0,parse:OP,serialize:IP},NP={scheme:"wss",domainHost:Qs.domainHost,parse:Qs.parse,serialize:Qs.serialize},LP={scheme:"urn",parse:AP,serialize:CP,skipNormalize:!0},jP={scheme:"urn:uuid",parse:MP,serialize:zP,skipNormalize:!0},ei={http:m_,https:DP,ws:Qs,wss:NP,urn:LP,"urn:uuid":jP};Object.setPrototypeOf(ei,null);function vu(e){return e&&(ei[e]||ei[e.toLowerCase()])||void 0}h_.exports={wsIsSecure:Eu,SCHEMES:ei,isValidSchemeName:RP,getSchemeHandler:vu}});var O_=w((vj,ni)=>{"use strict";var{normalizeIPv6:E_,removeDotSegments:io,recomposeAuthority:UP,normalizePercentEncoding:v_,normalizePathEncoding:FP,serializePathEncoding:__,normalizeQueryFragmentEncoding:y_,encodeQuery:qP,encodeFragment:ZP,reescapeHostDelimiters:HP,isIPv4:w_,nonSimpleDomain:WP}=bu(),{SCHEMES:k_,getSchemeHandler:wu}=g_(),x_=/^[A-Za-z][A-Za-z0-9+.-]*$/u,P_="URI scheme is malformed.";function S_(e){let t=unescape(String(e));if(!x_.test(t))throw new TypeError(P_);return t}function VP(e,t){return typeof e=="string"?e=e$(e,t):typeof e=="object"&&(e=ri(_r(e,t),t)),e}function KP(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=ti(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:f,malformedSchemeSpecific:p,malformedHost:m,malformedScheme:h}=ti(t,n);if(s||d||i||f||a||p||c||m||u||h)throw new Error(o.error||l.error||"URI is malformed.");let g=$_(o,l,n,!0),y=wu(r&&r.scheme||g.scheme),E=g.host,v=E!==void 0&&E!==""&&(w_(E)||E_(E).isIPV6);T_(g,r||{},y,v);let I=E&&E.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(E);if(g.error&&!I)throw new Error(g.error);return n.skipEscape=!0,_r(g,n)}function $_(e,t,r,n){let o={};return n||(e=ri(_r(e,r),r),t=ri(_r(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=io(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=io(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=io(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=io(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function BP(e,t,r){let n=b_(e,r),o=b_(t,r);return n!==void 0&&o!==void 0&&n===o}function _r(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=S_(r.scheme));let s=wu(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!n.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(n.skipEscape?r.path=v_(r.path):r.path=__(r.path,a)),n.reference!=="suffix"&&r.scheme&&(r.scheme=S_(r.scheme),o.push(r.scheme,":"));let c=UP(r);if(c!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(c),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=io(u)),a&&(u=__(u,!0)),c===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",qP(r.query)),r.fragment!==void 0&&o.push("#",ZP(r.fragment)),o.join("")}var GP=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,YP=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,JP=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function XP(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function so(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function ku(e){return e[0]==="["&&e[e.length-1]==="]"}function QP(e){let t=e[4];return so(e[3])||t!==void 0&&!ku(t)&&so(t)||so(e[6])||so(e[7])||so(e[8])}function T_(e,t,r,n){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!ku(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&WP(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function ti(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(YP);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let f=e.match(JP);if(f!==null){let m=f[1],h=m.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):m.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let p=e.match(GP);if(p){if(n.scheme=p[1],n.userinfo=p[3],n.host=p[4],n.port=parseInt(p[5],10),n.path=p[6]||"",n.query=p[7],n.fragment=p[8],n.scheme!==void 0){let g=unescape(n.scheme);x_.test(g)?n.scheme=g.toLowerCase():(n.error=n.error||P_,u=!0)}s=QP(p),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=p[5]);let m=XP(n,p);if(m!==void 0&&(n.error=n.error||m,o=!0),n.host)if(w_(n.host)===!1){let y=ku(n.host),E=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,v=E_(n.host);l=v.isIPV6||v.isIPVFuture===!0,c=E&&(!y||v.error===!0),n.host=l?v.host:v.host.toLowerCase(),c&&(n.error=n.error||"URI host is malformed.",o=!0)}else l=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let h=wu(r.scheme||n.scheme);if(c||(a=T_(n,r,h,l)),!h||h&&!h.skipNormalize){if(e.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:v_(n.host,!0);n.host=HP(g,l)}n.path&&(n.path=FP(n.path)),n.query&&(n.query=y_(n.query)),n.fragment&&(n.fragment=y_(n.fragment))}h&&h.parse&&(h.parse(n,r),h===k_.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function ri(e,t){return ti(e,t).parsed}function e$(e,t){return R_(e,t).normalized}function R_(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=ti(e,t);return{normalized:n||o||s||i||a?e:_r(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function b_(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:_r(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=R_(r,t);return o||s||i||a||c?void 0:n}var xu={SCHEMES:k_,normalize:VP,resolve:KP,resolveComponent:$_,equal:BP,serialize:_r,parse:ri};ni.exports=xu;ni.exports.default=xu;ni.exports.fastUri=xu});var A_=w(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});var I_=O_();I_.code='require("ajv/dist/runtime/uri").default';Pu.default=I_});var U_=w(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.CodeGen=ye.Name=ye.nil=ye.stringify=ye.str=ye._=ye.KeywordCxt=void 0;var t$=no();Object.defineProperty(ye,"KeywordCxt",{enumerable:!0,get:function(){return t$.KeywordCxt}});var Gr=M();Object.defineProperty(ye,"_",{enumerable:!0,get:function(){return Gr._}});Object.defineProperty(ye,"str",{enumerable:!0,get:function(){return Gr.str}});Object.defineProperty(ye,"stringify",{enumerable:!0,get:function(){return Gr.stringify}});Object.defineProperty(ye,"nil",{enumerable:!0,get:function(){return Gr.nil}});Object.defineProperty(ye,"Name",{enumerable:!0,get:function(){return Gr.Name}});Object.defineProperty(ye,"CodeGen",{enumerable:!0,get:function(){return Gr.CodeGen}});var r$=Ys(),N_=oo(),n$=Gc(),ao=Xs(),o$=M(),co=eo(),oi=Qn(),Tu=q(),C_=o_(),s$=A_(),L_=(e,t)=>new RegExp(e,t);L_.code="new RegExp";var i$=["removeAdditional","useDefaults","coerceTypes"],a$=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),c$={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."},u$={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},M_=200;function l$(e){var t,r,n,o,s,i,a,c,u,l,d,f,p,m,h,g,y,E,v,I,x,z,j,Be,Pe;let Ge=e.strict,xr=(t=e.code)===null||t===void 0?void 0:t.optimize,Io=xr===!0||xr===void 0?1:xr||0,Ao=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:L_,xb=(o=e.uriResolver)!==null&&o!==void 0?o:s$.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:Ge)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:Ge)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:Ge)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:Ge)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=e.strictRequired)!==null&&p!==void 0?p:Ge)!==null&&m!==void 0?m:!1,code:e.code?{...e.code,optimize:Io,regExp:Ao}:{optimize:Io,regExp:Ao},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:M_,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:M_,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(E=e.messages)!==null&&E!==void 0?E:!0,inlineRefs:(v=e.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:(I=e.schemaId)!==null&&I!==void 0?I:"$id",addUsedSchema:(x=e.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(z=e.validateSchema)!==null&&z!==void 0?z:!0,validateFormats:(j=e.validateFormats)!==null&&j!==void 0?j:!0,unicodeRegExp:(Be=e.unicodeRegExp)!==null&&Be!==void 0?Be:!0,int32range:(Pe=e.int32range)!==null&&Pe!==void 0?Pe:!0,uriResolver:xb}}var uo=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...l$(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new o$.ValueScope({scope:{},prefixes:a$,es5:r,lines:n}),this.logger=g$(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,n$.getRules)(),z_.call(this,c$,t,"NOT SUPPORTED"),z_.call(this,u$,t,"DEPRECATED","warn"),this._metaOpts=m$.call(this),t.formats&&f$.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&p$.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),d$.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=C_;n==="id"&&(o={...C_},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(l,d){await s.call(this,l.$schema);let f=this._addSchema(l,d);return f.validate||i.call(this,f)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof N_.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,co.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=D_.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new ao.SchemaEnv({schema:{},schemaId:n});if(r=ao.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=D_.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,co.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(y$.call(this,n,r),!r)return(0,Tu.eachItem)(n,s=>$u.call(this,s)),this;b$.call(this,r);let o={...r,type:(0,oi.getJSONTypes)(r.type),schemaType:(0,oi.getJSONTypes)(r.schemaType)};return(0,Tu.eachItem)(n,o.type.length===0?s=>$u.call(this,s,o):s=>o.type.forEach(i=>$u.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=j_(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,co.normalizeId)(i||n);let u=co.getSchemaRefs.call(this,t,n);return c=new ao.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):ao.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{ao.compileSchema.call(this,t)}finally{this.opts=r}}};uo.ValidationError=r$.default;uo.MissingRefError=N_.default;ye.default=uo;function z_(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function D_(e){return e=(0,co.normalizeId)(e),this.schemas[e]||this.refs[e]}function d$(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function f$(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function p$(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function m$(){let e={...this.opts};for(let t of i$)delete e[t];return e}var h$={log(){},warn(){},error(){}};function g$(e){if(e===!1)return h$;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var _$=/^[a-z_$][a-z0-9_$:-]*$/i;function y$(e,t){let{RULES:r}=this;if((0,Tu.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!_$.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function $u(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,oi.getJSONTypes)(t.type),schemaType:(0,oi.getJSONTypes)(t.schemaType)}};t.before?S$.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function S$(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function b$(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=j_(t)),e.validateSchema=this.compile(t,!0))}var E$={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function j_(e){return{anyOf:[e,E$]}}});var F_=w(Ru=>{"use strict";Object.defineProperty(Ru,"__esModule",{value:!0});var v$={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ru.default=v$});var W_=w(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.callRef=yr.getValidate=void 0;var w$=oo(),q_=et(),Fe=M(),Yr=Ct(),Z_=Xs(),si=q(),k$={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=Z_.resolveRef.call(c,u,o,r);if(l===void 0)throw new w$.default(n.opts.uriResolver,o,r);if(l instanceof Z_.SchemaEnv)return f(l);return p(l);function d(){if(s===u)return ii(e,i,s,s.$async);let m=t.scopeValue("root",{ref:u});return ii(e,(0,Fe._)`${m}.validate`,u,u.$async)}function f(m){let h=H_(e,m);ii(e,h,m,m.$async)}function p(m){let h=t.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Fe.stringify)(m)}:{ref:m}),g=t.name("valid"),y=e.subschema({schema:m,dataTypes:[],schemaPath:Fe.nil,topSchemaRef:h,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function H_(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Fe._)`${r.scopeValue("wrapper",{ref:t})}.validate`}yr.getValidate=H_;function ii(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Yr.default.this:Fe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Fe._)`await ${(0,q_.callValidateCode)(e,t,u)}`),p(t),i||o.assign(m,!0)},h=>{o.if((0,Fe._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),f(h),i||o.assign(m,!1)}),e.ok(m)}function d(){e.result((0,q_.callValidateCode)(e,t,u),()=>p(t),()=>f(t))}function f(m){let h=(0,Fe._)`${m}.errors`;o.assign(Yr.default.vErrors,(0,Fe._)`${Yr.default.vErrors} === null ? ${h} : ${Yr.default.vErrors}.concat(${h})`),o.assign(Yr.default.errors,(0,Fe._)`${Yr.default.vErrors}.length`)}function p(m){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=si.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,Fe._)`${m}.evaluated.props`);s.props=si.mergeEvaluated.props(o,y,s.props,Fe.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=si.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,Fe._)`${m}.evaluated.items`);s.items=si.mergeEvaluated.items(o,y,s.items,Fe.Name)}}}yr.callRef=ii;yr.default=k$});var V_=w(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});var x$=F_(),P$=W_(),$$=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",x$.default,P$.default];Ou.default=$$});var K_=w(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});var ai=M(),Qt=ai.operators,ci={maximum:{okStr:"<=",ok:Qt.LTE,fail:Qt.GT},minimum:{okStr:">=",ok:Qt.GTE,fail:Qt.LT},exclusiveMaximum:{okStr:"<",ok:Qt.LT,fail:Qt.GTE},exclusiveMinimum:{okStr:">",ok:Qt.GT,fail:Qt.LTE}},T$={message:({keyword:e,schemaCode:t})=>(0,ai.str)`must be ${ci[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ai._)`{comparison: ${ci[e].okStr}, limit: ${t}}`},R$={keyword:Object.keys(ci),type:"number",schemaType:"number",$data:!0,error:T$,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ai._)`${r} ${ci[t].fail} ${n} || isNaN(${r})`)}};Iu.default=R$});var B_=w(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});var lo=M(),O$={message:({schemaCode:e})=>(0,lo.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,lo._)`{multipleOf: ${e}}`},I$={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:O$,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,lo._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,lo._)`${i} !== parseInt(${i})`;e.fail$data((0,lo._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Au.default=I$});var Y_=w(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});function G_(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}Cu.default=G_;G_.code='require("ajv/dist/runtime/ucs2length").default'});var J_=w(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});var Sr=M(),A$=q(),C$=Y_(),M$={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Sr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Sr._)`{limit: ${e}}`},z$={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:M$,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?Sr.operators.GT:Sr.operators.LT,i=o.opts.unicode===!1?(0,Sr._)`${r}.length`:(0,Sr._)`${(0,A$.useFunc)(e.gen,C$.default)}(${r})`;e.fail$data((0,Sr._)`${i} ${s} ${n}`)}};Mu.default=z$});var X_=w(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});var D$=et(),N$=q(),Jr=M(),L$={message:({schemaCode:e})=>(0,Jr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Jr._)`{pattern: ${e}}`},j$={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:L$,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Jr._)`new RegExp`:(0,N$.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Jr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Jr._)`!${l}`)}else{let c=(0,D$.usePattern)(e,o);e.fail$data((0,Jr._)`!${c}.test(${r})`)}}};zu.default=j$});var Q_=w(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var fo=M(),U$={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,fo.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,fo._)`{limit: ${e}}`},F$={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:U$,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?fo.operators.GT:fo.operators.LT;e.fail$data((0,fo._)`Object.keys(${r}).length ${o} ${n}`)}};Du.default=F$});var ey=w(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});var po=et(),mo=M(),q$=q(),Z$={message:({params:{missingProperty:e}})=>(0,mo.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,mo._)`{missingProperty: ${e}}`},H$={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Z$,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let p=e.parentSchema.properties,{definedProperties:m}=e.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,q$.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(mo.nil,d);else for(let p of r)(0,po.checkReportMissingProp)(e,p)}function l(){let p=t.let("missing");if(c||s){let m=t.let("valid",!0);e.block$data(m,()=>f(p,m)),e.ok(m)}else t.if((0,po.checkMissingProp)(e,r,p)),(0,po.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",n,p=>{e.setParams({missingProperty:p}),t.if((0,po.noPropertyInData)(t,o,p,a.ownProperties),()=>e.error())})}function f(p,m){e.setParams({missingProperty:p}),t.forOf(p,n,()=>{t.assign(m,(0,po.propertyInData)(t,o,p,a.ownProperties)),t.if((0,mo.not)(m),()=>{e.error(),t.break()})},mo.nil)}}};Nu.default=H$});var ty=w(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});var ho=M(),W$={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,ho.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,ho._)`{limit: ${e}}`},V$={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:W$,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?ho.operators.GT:ho.operators.LT;e.fail$data((0,ho._)`${r}.length ${o} ${n}`)}};Lu.default=V$});var ui=w(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var ry=nu();ry.code='require("ajv/dist/runtime/equal").default';ju.default=ry});var ny=w(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var Uu=Qn(),Se=M(),K$=q(),B$=ui(),G$={message:({params:{i:e,j:t}})=>(0,Se.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Se._)`{i: ${e}, j: ${t}}`},Y$={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:G$,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,Uu.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,Se._)`${i} === false`),e.ok(c);function l(){let m=t.let("i",(0,Se._)`${r}.length`),h=t.let("j");e.setParams({i:m,j:h}),t.assign(c,!0),t.if((0,Se._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function f(m,h){let g=t.name("item"),y=(0,Uu.checkDataTypes)(u,g,a.opts.strictNumbers,Uu.DataType.Wrong),E=t.const("indices",(0,Se._)`{}`);t.for((0,Se._)`;${m}--;`,()=>{t.let(g,(0,Se._)`${r}[${m}]`),t.if(y,(0,Se._)`continue`),u.length>1&&t.if((0,Se._)`typeof ${g} == "string"`,(0,Se._)`${g} += "_"`),t.if((0,Se._)`typeof ${E}[${g}] == "number"`,()=>{t.assign(h,(0,Se._)`${E}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,Se._)`${E}[${g}] = ${m}`)})}function p(m,h){let g=(0,K$.useFunc)(t,B$.default),y=t.name("outer");t.label(y).for((0,Se._)`;${m}--;`,()=>t.for((0,Se._)`${h} = ${m}; ${h}--;`,()=>t.if((0,Se._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{e.error(),t.assign(c,!1).break(y)})))}}};Fu.default=Y$});var oy=w(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});var qu=M(),J$=q(),X$=ui(),Q$={message:"must be equal to constant",params:({schemaCode:e})=>(0,qu._)`{allowedValue: ${e}}`},eT={keyword:"const",$data:!0,error:Q$,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,qu._)`!${(0,J$.useFunc)(t,X$.default)}(${r}, ${o})`):e.fail((0,qu._)`${s} !== ${r}`)}};Zu.default=eT});var sy=w(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});var go=M(),tT=q(),rT=ui(),nT={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,go._)`{allowedValues: ${e}}`},oT={keyword:"enum",schemaType:"array",$data:!0,error:nT,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,tT.useFunc)(t,rT.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let p=t.const("vSchema",s);l=(0,go.or)(...o.map((m,h)=>f(p,h)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,p=>t.if((0,go._)`${u()}(${r}, ${p})`,()=>t.assign(l,!0).break()))}function f(p,m){let h=o[m];return typeof h=="object"&&h!==null?(0,go._)`${u()}(${r}, ${p}[${m}])`:(0,go._)`${r} === ${h}`}}};Hu.default=oT});var iy=w(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});var sT=K_(),iT=B_(),aT=J_(),cT=X_(),uT=Q_(),lT=ey(),dT=ty(),fT=ny(),pT=oy(),mT=sy(),hT=[sT.default,iT.default,aT.default,cT.default,uT.default,lT.default,dT.default,fT.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},pT.default,mT.default];Wu.default=hT});var Ku=w(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.validateAdditionalItems=void 0;var br=M(),Vu=q(),gT={message:({params:{len:e}})=>(0,br.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,br._)`{limit: ${e}}`},_T={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:gT,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Vu.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}ay(e,n)}};function ay(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,br._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,br._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Vu.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,br._)`${a} <= ${t.length}`);r.if((0,br.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:Vu.Type.Num},u),i.allErrors||r.if((0,br.not)(u),()=>r.break())})}}_o.validateAdditionalItems=ay;_o.default=_T});var Bu=w(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.validateTuple=void 0;var cy=M(),li=q(),yT=et(),ST={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return uy(e,"additionalItems",t);r.items=!0,!(0,li.alwaysValidSchema)(r,t)&&e.ok((0,yT.validateArray)(e))}};function uy(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=li.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,cy._)`${s}.length`);r.forEach((d,f)=>{(0,li.alwaysValidSchema)(a,d)||(n.if((0,cy._)`${u} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function l(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[t]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,li.checkStrictMode)(a,g,f.strictTuples)}}}yo.validateTuple=uy;yo.default=ST});var ly=w(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});var bT=Bu(),ET={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,bT.validateTuple)(e,"items")};Gu.default=ET});var fy=w(Yu=>{"use strict";Object.defineProperty(Yu,"__esModule",{value:!0});var dy=M(),vT=q(),wT=et(),kT=Ku(),xT={message:({params:{len:e}})=>(0,dy.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,dy._)`{limit: ${e}}`},PT={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:xT,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,vT.alwaysValidSchema)(n,t)&&(o?(0,kT.validateAdditionalItems)(e,o):e.ok((0,wT.validateArray)(e)))}};Yu.default=PT});var py=w(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});var rt=M(),di=q(),$T={message:({params:{min:e,max:t}})=>t===void 0?(0,rt.str)`must contain at least ${e} valid item(s)`:(0,rt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,rt._)`{minContains: ${e}}`:(0,rt._)`{minContains: ${e}, maxContains: ${t}}`},TT={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:$T,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,rt._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,di.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,di.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,di.alwaysValidSchema)(s,r)){let h=(0,rt._)`${l} >= ${i}`;a!==void 0&&(h=(0,rt._)`${h} && ${l} <= ${a}`),e.pass(h);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?p(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,rt._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let h=t.name("_valid"),g=t.let("count",0);p(h,()=>t.if(h,()=>m(g)))}function p(h,g){t.forRange("i",0,l,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:di.Type.Num,compositeRule:!0},h),g()})}function m(h){t.code((0,rt._)`${h}++`),a===void 0?t.if((0,rt._)`${h} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,rt._)`${h} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,rt._)`${h} >= ${i}`,()=>t.assign(d,!0)))}}};Ju.default=TT});var gy=w(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.validateSchemaDeps=Et.validatePropertyDeps=Et.error=void 0;var Xu=M(),RT=q(),So=et();Et.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Xu.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Xu._)`{property: ${e},
19
+ || ${i} === "boolean" || ${o} === null`).assign(a,(0,C._)`[${o}]`)}}}function Zk({gen:e,parentData:t,parentDataProperty:r},n){e.if((0,C._)`${t} !== undefined`,()=>e.assign((0,C._)`${t}[${r}]`,n))}function Jc(e,t,r,n=Wr.Correct){let o=n===Wr.Correct?C.operators.EQ:C.operators.NEQ,s;switch(e){case"null":return(0,C._)`${t} ${o} null`;case"array":s=(0,C._)`Array.isArray(${t})`;break;case"object":s=(0,C._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":s=i((0,C._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":s=i();break;default:return(0,C._)`typeof ${t} ${o} ${e}`}return n===Wr.Correct?s:(0,C.not)(s);function i(a=C.nil){return(0,C.and)((0,C._)`typeof ${t} == "number"`,a,r?(0,C._)`isFinite(${t})`:C.nil)}}ke.checkDataType=Jc;function Xc(e,t,r,n){if(e.length===1)return Jc(e[0],t,r,n);let o,s=(0,xg.toHash)(e);if(s.array&&s.object){let i=(0,C._)`typeof ${t} != "object"`;o=s.null?i:(0,C._)`!${t} || ${i}`,delete s.null,delete s.array,delete s.object}else o=C.nil;s.number&&delete s.integer;for(let i in s)o=(0,C.and)(o,Jc(i,t,r,n));return o}ke.checkDataTypes=Xc;var Hk={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,C._)`{type: ${e}}`:(0,C._)`{type: ${t}}`};function Qc(e){let t=Wk(e);(0,Lk.reportError)(t,Hk)}ke.reportTypeError=Qc;function Wk(e){let{gen:t,data:r,schema:n}=e,o=(0,xg.schemaRefOrVal)(e,n,"type");return{gen:t,keyword:"type",data:r,schema:n.type,schemaCode:o,schemaValue:o,parentSchema:n,params:{},it:e}}});var Rg=w(Vs=>{"use strict";Object.defineProperty(Vs,"__esModule",{value:!0});Vs.assignDefaults=void 0;var Vr=M(),Vk=q();function Kk(e,t){let{properties:r,items:n}=e.schema;if(t==="object"&&r)for(let o in r)Tg(e,o,r[o].default);else t==="array"&&Array.isArray(n)&&n.forEach((o,s)=>Tg(e,s,o.default))}Vs.assignDefaults=Kk;function Tg(e,t,r){let{gen:n,compositeRule:o,data:s,opts:i}=e;if(r===void 0)return;let a=(0,Vr._)`${s}${(0,Vr.getProperty)(t)}`;if(o){(0,Vk.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,Vr._)`${a} === undefined`;i.useDefaults==="empty"&&(c=(0,Vr._)`${c} || ${a} === null || ${a} === ""`),n.if(c,(0,Vr._)`${a} = ${(0,Vr.stringify)(r)}`)}});var et=w(B=>{"use strict";Object.defineProperty(B,"__esModule",{value:!0});B.validateUnion=B.validateArray=B.usePattern=B.callValidateCode=B.schemaProperties=B.allSchemaProperties=B.noPropertyInData=B.propertyInData=B.isOwnProperty=B.hasPropFunc=B.reportMissingProp=B.checkMissingProp=B.checkReportMissingProp=void 0;var te=M(),eu=q(),Gt=Ct(),Bk=q();function Gk(e,t){let{gen:r,data:n,it:o}=e;r.if(ru(r,n,t,o.opts.ownProperties),()=>{e.setParams({missingProperty:(0,te._)`${t}`},!0),e.error()})}B.checkReportMissingProp=Gk;function Yk({gen:e,data:t,it:{opts:r}},n,o){return(0,te.or)(...n.map(s=>(0,te.and)(ru(e,t,s,r.ownProperties),(0,te._)`${o} = ${s}`)))}B.checkMissingProp=Yk;function Jk(e,t){e.setParams({missingProperty:t},!0),e.error()}B.reportMissingProp=Jk;function Og(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,te._)`Object.prototype.hasOwnProperty`})}B.hasPropFunc=Og;function tu(e,t,r){return(0,te._)`${Og(e)}.call(${t}, ${r})`}B.isOwnProperty=tu;function Xk(e,t,r,n){let o=(0,te._)`${t}${(0,te.getProperty)(r)} !== undefined`;return n?(0,te._)`${o} && ${tu(e,t,r)}`:o}B.propertyInData=Xk;function ru(e,t,r,n){let o=(0,te._)`${t}${(0,te.getProperty)(r)} === undefined`;return n?(0,te.or)(o,(0,te.not)(tu(e,t,r))):o}B.noPropertyInData=ru;function Ig(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}B.allSchemaProperties=Ig;function Qk(e,t){return Ig(t).filter(r=>!(0,eu.alwaysValidSchema)(e,t[r]))}B.schemaProperties=Qk;function ex({schemaCode:e,data:t,it:{gen:r,topSchemaRef:n,schemaPath:o,errorPath:s},it:i},a,c,u){let l=u?(0,te._)`${e}, ${t}, ${n}${o}`:t,d=[[Gt.default.instancePath,(0,te.strConcat)(Gt.default.instancePath,s)],[Gt.default.parentData,i.parentData],[Gt.default.parentDataProperty,i.parentDataProperty],[Gt.default.rootData,Gt.default.rootData]];i.opts.dynamicRef&&d.push([Gt.default.dynamicAnchors,Gt.default.dynamicAnchors]);let f=(0,te._)`${l}, ${r.object(...d)}`;return c!==te.nil?(0,te._)`${a}.call(${c}, ${f})`:(0,te._)`${a}(${f})`}B.callValidateCode=ex;var tx=(0,te._)`new RegExp`;function rx({gen:e,it:{opts:t}},r){let n=t.unicodeRegExp?"u":"",{regExp:o}=t.code,s=o(r,n);return e.scopeValue("pattern",{key:s.toString(),ref:s,code:(0,te._)`${o.code==="new RegExp"?tx:(0,Bk.useFunc)(e,o)}(${r}, ${n})`})}B.usePattern=rx;function nx(e){let{gen:t,data:r,keyword:n,it:o}=e,s=t.name("valid");if(o.allErrors){let a=t.let("valid",!0);return i(()=>t.assign(a,!1)),a}return t.var(s,!0),i(()=>t.break()),s;function i(a){let c=t.const("len",(0,te._)`${r}.length`);t.forRange("i",0,c,u=>{e.subschema({keyword:n,dataProp:u,dataPropType:eu.Type.Num},s),t.if((0,te.not)(s),a)})}}B.validateArray=nx;function ox(e){let{gen:t,schema:r,keyword:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(r.some(c=>(0,eu.alwaysValidSchema)(o,c))&&!o.opts.unevaluated)return;let i=t.let("valid",!1),a=t.name("_valid");t.block(()=>r.forEach((c,u)=>{let l=e.subschema({keyword:n,schemaProp:u,compositeRule:!0},a);t.assign(i,(0,te._)`${i} || ${a}`),e.mergeValidEvaluated(l,a)||t.if((0,te.not)(i))})),e.result(i,()=>e.reset(),()=>e.error(!0))}B.validateUnion=ox});var Mg=w(St=>{"use strict";Object.defineProperty(St,"__esModule",{value:!0});St.validateKeywordUsage=St.validSchemaType=St.funcKeywordCode=St.macroKeywordCode=void 0;var Re=M(),mr=Ct(),sx=et(),ix=Xn();function ax(e,t){let{gen:r,keyword:n,schema:o,parentSchema:s,it:i}=e,a=t.macro.call(i.self,o,s,i),c=Cg(r,n,a);i.opts.validateSchema!==!1&&i.self.validateSchema(a,!0);let u=r.name("valid");e.subschema({schema:a,schemaPath:Re.nil,errSchemaPath:`${i.errSchemaPath}/${n}`,topSchemaRef:c,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}St.macroKeywordCode=ax;function cx(e,t){var r;let{gen:n,keyword:o,schema:s,parentSchema:i,$data:a,it:c}=e;lx(c,t);let u=!a&&t.compile?t.compile.call(c.self,s,i,c):t.validate,l=Cg(n,o,u),d=n.let("valid");e.block$data(d,f),e.ok((r=t.valid)!==null&&r!==void 0?r:d);function f(){if(t.errors===!1)h(),t.modifying&&Ag(e),g(()=>e.error());else{let y=t.async?p():m();t.modifying&&Ag(e),g(()=>ux(e,y))}}function p(){let y=n.let("ruleErrs",null);return n.try(()=>h((0,Re._)`await `),E=>n.assign(d,!1).if((0,Re._)`${E} instanceof ${c.ValidationError}`,()=>n.assign(y,(0,Re._)`${E}.errors`),()=>n.throw(E))),y}function m(){let y=(0,Re._)`${l}.errors`;return n.assign(y,null),h(Re.nil),y}function h(y=t.async?(0,Re._)`await `:Re.nil){let E=c.opts.passContext?mr.default.this:mr.default.self,v=!("compile"in t&&!a||t.schema===!1);n.assign(d,(0,Re._)`${y}${(0,sx.callValidateCode)(e,l,E,v)}`,t.modifying)}function g(y){var E;n.if((0,Re.not)((E=t.valid)!==null&&E!==void 0?E:d),y)}}St.funcKeywordCode=cx;function Ag(e){let{gen:t,data:r,it:n}=e;t.if(n.parentData,()=>t.assign(r,(0,Re._)`${n.parentData}[${n.parentDataProperty}]`))}function ux(e,t){let{gen:r}=e;r.if((0,Re._)`Array.isArray(${t})`,()=>{r.assign(mr.default.vErrors,(0,Re._)`${mr.default.vErrors} === null ? ${t} : ${mr.default.vErrors}.concat(${t})`).assign(mr.default.errors,(0,Re._)`${mr.default.vErrors}.length`),(0,ix.extendErrors)(e)},()=>e.error())}function lx({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function Cg(e,t,r){if(r===void 0)throw new Error(`keyword "${t}" failed to compile`);return e.scopeValue("keyword",typeof r=="function"?{ref:r}:{ref:r,code:(0,Re.stringify)(r)})}function dx(e,t,r=!1){return!t.length||t.some(n=>n==="array"?Array.isArray(e):n==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==n||r&&typeof e>"u")}St.validSchemaType=dx;function fx({schema:e,opts:t,self:r,errSchemaPath:n},o,s){if(Array.isArray(o.keyword)?!o.keyword.includes(s):o.keyword!==s)throw new Error("ajv implementation error");let i=o.dependencies;if(i?.some(a=>!Object.prototype.hasOwnProperty.call(e,a)))throw new Error(`parent schema must have dependencies of ${s}: ${i.join(",")}`);if(o.validateSchema&&!o.validateSchema(e[s])){let c=`keyword "${s}" value is invalid at path "${n}": `+r.errorsText(o.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}St.validateKeywordUsage=fx});var Dg=w(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Yt.extendSubschemaMode=Yt.extendSubschemaData=Yt.getSubschema=void 0;var bt=M(),zg=q();function px(e,{keyword:t,schemaProp:r,schema:n,schemaPath:o,errSchemaPath:s,topSchemaRef:i}){if(t!==void 0&&n!==void 0)throw new Error('both "keyword" and "schema" passed, only one allowed');if(t!==void 0){let a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,bt._)`${e.schemaPath}${(0,bt.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,bt._)`${e.schemaPath}${(0,bt.getProperty)(t)}${(0,bt.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,zg.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')}Yt.getSubschema=px;function mx(e,t,{dataProp:r,dataPropType:n,data:o,dataTypes:s,propertyName:i}){if(o!==void 0&&r!==void 0)throw new Error('both "data" and "dataProp" passed, only one allowed');let{gen:a}=t;if(r!==void 0){let{errorPath:u,dataPathArr:l,opts:d}=t,f=a.let("data",(0,bt._)`${t.data}${(0,bt.getProperty)(r)}`,!0);c(f),e.errorPath=(0,bt.str)`${u}${(0,zg.getErrorPath)(r,n,d.jsPropertySyntax)}`,e.parentDataProperty=(0,bt._)`${r}`,e.dataPathArr=[...l,e.parentDataProperty]}if(o!==void 0){let u=o instanceof bt.Name?o:a.let("data",o,!0);c(u),i!==void 0&&(e.propertyName=i)}s&&(e.dataTypes=s);function c(u){e.data=u,e.dataLevel=t.dataLevel+1,e.dataTypes=[],t.definedProperties=new Set,e.parentData=t.data,e.dataNames=[...t.dataNames,u]}}Yt.extendSubschemaData=mx;function hx(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:n,createErrors:o,allErrors:s}){n!==void 0&&(e.compositeRule=n),o!==void 0&&(e.createErrors=o),s!==void 0&&(e.allErrors=s),e.jtdDiscriminator=t,e.jtdMetadata=r}Yt.extendSubschemaMode=hx});var nu=w((fj,Ng)=>{"use strict";Ng.exports=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,s;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(s=Object.keys(t),n=s.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,s[o]))return!1;for(o=n;o--!==0;){var i=s[o];if(!e(t[i],r[i]))return!1}return!0}return t!==t&&r!==r}});var jg=w((pj,Lg)=>{"use strict";var Jt=Lg.exports=function(e,t,r){typeof t=="function"&&(r=t,t={}),r=t.cb||r;var n=typeof r=="function"?r:r.pre||function(){},o=r.post||function(){};Ks(t,n,o,e,"",e)};Jt.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0};Jt.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0};Jt.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0};Jt.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 Ks(e,t,r,n,o,s,i,a,c,u){if(n&&typeof n=="object"&&!Array.isArray(n)){t(n,o,s,i,a,c,u);for(var l in n){var d=n[l];if(Array.isArray(d)){if(l in Jt.arrayKeywords)for(var f=0;f<d.length;f++)Ks(e,t,r,d[f],o+"/"+l+"/"+f,s,o,l,n,f)}else if(l in Jt.propsKeywords){if(d&&typeof d=="object")for(var p in d)Ks(e,t,r,d[p],o+"/"+l+"/"+gx(p),s,o,l,n,p)}else(l in Jt.keywords||e.allKeys&&!(l in Jt.skipKeywords))&&Ks(e,t,r,d,o+"/"+l,s,o,l,n)}r(n,o,s,i,a,c,u)}}function gx(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var eo=w(je=>{"use strict";Object.defineProperty(je,"__esModule",{value:!0});je.getSchemaRefs=je.resolveUrl=je.normalizeId=je._getFullPath=je.getFullPath=je.inlineRef=void 0;var _x=q(),yx=nu(),Sx=jg(),bx=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function Ex(e,t=!0){return typeof e=="boolean"?!0:t===!0?!ou(e):t?Ug(e)<=t:!1}je.inlineRef=Ex;var vx=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function ou(e){for(let t in e){if(vx.has(t))return!0;let r=e[t];if(Array.isArray(r)&&r.some(ou)||typeof r=="object"&&ou(r))return!0}return!1}function Ug(e){let t=0;for(let r in e){if(r==="$ref")return 1/0;if(t++,!bx.has(r)&&(typeof e[r]=="object"&&(0,_x.eachItem)(e[r],n=>t+=Ug(n)),t===1/0))return 1/0}return t}function Fg(e,t="",r){r!==!1&&(t=Kr(t));let n=e.parse(t);return qg(e,n)}je.getFullPath=Fg;function qg(e,t){return e.serialize(t).split("#")[0]+"#"}je._getFullPath=qg;var wx=/#\/?$/;function Kr(e){return e?e.replace(wx,""):""}je.normalizeId=Kr;function kx(e,t,r){return r=Kr(r),e.resolve(t,r)}je.resolveUrl=kx;var xx=/^[a-z_][-a-z0-9._]*$/i;function Px(e,t){if(typeof e=="boolean")return{};let{schemaId:r,uriResolver:n}=this.opts,o=Kr(e[r]||t),s={"":o},i=Fg(n,o,!1),a={},c=new Set;return Sx(e,{allKeys:!0},(d,f,p,m)=>{if(m===void 0)return;let h=i+f,g=s[m];typeof d[r]=="string"&&(g=y.call(this,d[r])),E.call(this,d.$anchor),E.call(this,d.$dynamicAnchor),s[f]=g;function y(v){let I=this.opts.uriResolver.resolve;if(v=Kr(g?I(g,v):v),c.has(v))throw l(v);c.add(v);let x=this.refs[v];return typeof x=="string"&&(x=this.refs[x]),typeof x=="object"?u(d,x.schema,v):v!==Kr(h)&&(v[0]==="#"?(u(d,a[v],v),a[v]=d):this.refs[v]=h),v}function E(v){if(typeof v=="string"){if(!xx.test(v))throw new Error(`invalid anchor "${v}"`);y.call(this,`#${v}`)}}}),a;function u(d,f,p){if(f!==void 0&&!yx(d,f))throw l(p)}function l(d){return new Error(`reference "${d}" resolves to more than one schema`)}}je.getSchemaRefs=Px});var no=w(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.getData=Xt.KeywordCxt=Xt.validateFunctionCode=void 0;var Kg=vg(),Zg=Qn(),iu=Yc(),Bs=Qn(),$x=Rg(),ro=Mg(),su=Dg(),$=M(),O=Ct(),Tx=eo(),Mt=q(),to=Xn();function Rx(e){if(Yg(e)&&(Jg(e),Gg(e))){Ax(e);return}Bg(e,()=>(0,Kg.topBoolOrEmptySchema)(e))}Xt.validateFunctionCode=Rx;function Bg({gen:e,validateName:t,schema:r,schemaEnv:n,opts:o},s){o.code.es5?e.func(t,(0,$._)`${O.default.data}, ${O.default.valCxt}`,n.$async,()=>{e.code((0,$._)`"use strict"; ${Hg(r,o)}`),Ix(e,o),e.code(s)}):e.func(t,(0,$._)`${O.default.data}, ${Ox(o)}`,n.$async,()=>e.code(Hg(r,o)).code(s))}function Ox(e){return(0,$._)`{${O.default.instancePath}="", ${O.default.parentData}, ${O.default.parentDataProperty}, ${O.default.rootData}=${O.default.data}${e.dynamicRef?(0,$._)`, ${O.default.dynamicAnchors}={}`:$.nil}}={}`}function Ix(e,t){e.if(O.default.valCxt,()=>{e.var(O.default.instancePath,(0,$._)`${O.default.valCxt}.${O.default.instancePath}`),e.var(O.default.parentData,(0,$._)`${O.default.valCxt}.${O.default.parentData}`),e.var(O.default.parentDataProperty,(0,$._)`${O.default.valCxt}.${O.default.parentDataProperty}`),e.var(O.default.rootData,(0,$._)`${O.default.valCxt}.${O.default.rootData}`),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0,$._)`${O.default.valCxt}.${O.default.dynamicAnchors}`)},()=>{e.var(O.default.instancePath,(0,$._)`""`),e.var(O.default.parentData,(0,$._)`undefined`),e.var(O.default.parentDataProperty,(0,$._)`undefined`),e.var(O.default.rootData,O.default.data),t.dynamicRef&&e.var(O.default.dynamicAnchors,(0,$._)`{}`)})}function Ax(e){let{schema:t,opts:r,gen:n}=e;Bg(e,()=>{r.$comment&&t.$comment&&Qg(e),Nx(e),n.let(O.default.vErrors,null),n.let(O.default.errors,0),r.unevaluated&&Cx(e),Xg(e),Ux(e)})}function Cx(e){let{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,$._)`${r}.evaluated`),t.if((0,$._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,$._)`${e.evaluated}.props`,(0,$._)`undefined`)),t.if((0,$._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,$._)`${e.evaluated}.items`,(0,$._)`undefined`))}function Hg(e,t){let r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,$._)`/*# sourceURL=${r} */`:$.nil}function Mx(e,t){if(Yg(e)&&(Jg(e),Gg(e))){zx(e,t);return}(0,Kg.boolOrEmptySchema)(e,t)}function Gg({schema:e,self:t}){if(typeof e=="boolean")return!e;for(let r in e)if(t.RULES.all[r])return!0;return!1}function Yg(e){return typeof e.schema!="boolean"}function zx(e,t){let{schema:r,gen:n,opts:o}=e;o.$comment&&r.$comment&&Qg(e),Lx(e),jx(e);let s=n.const("_errs",O.default.errors);Xg(e,s),n.var(t,(0,$._)`${s} === ${O.default.errors}`)}function Jg(e){(0,Mt.checkUnknownRules)(e),Dx(e)}function Xg(e,t){if(e.opts.jtd)return Wg(e,[],!1,t);let r=(0,Zg.getSchemaTypes)(e.schema),n=(0,Zg.coerceAndCheckDataType)(e,r);Wg(e,r,!n,t)}function Dx(e){let{schema:t,errSchemaPath:r,opts:n,self:o}=e;t.$ref&&n.ignoreKeywordsWithRef&&(0,Mt.schemaHasRulesButRef)(t,o.RULES)&&o.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}function Nx(e){let{schema:t,opts:r}=e;t.default!==void 0&&r.useDefaults&&r.strictSchema&&(0,Mt.checkStrictMode)(e,"default is ignored in the schema root")}function Lx(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,Tx.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function jx(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function Qg({gen:e,schemaEnv:t,schema:r,errSchemaPath:n,opts:o}){let s=r.$comment;if(o.$comment===!0)e.code((0,$._)`${O.default.self}.logger.log(${s})`);else if(typeof o.$comment=="function"){let i=(0,$.str)`${n}/$comment`,a=e.scopeValue("root",{ref:t.root});e.code((0,$._)`${O.default.self}.opts.$comment(${s}, ${i}, ${a}.schema)`)}}function Ux(e){let{gen:t,schemaEnv:r,validateName:n,ValidationError:o,opts:s}=e;r.$async?t.if((0,$._)`${O.default.errors} === 0`,()=>t.return(O.default.data),()=>t.throw((0,$._)`new ${o}(${O.default.vErrors})`)):(t.assign((0,$._)`${n}.errors`,O.default.vErrors),s.unevaluated&&Fx(e),t.return((0,$._)`${O.default.errors} === 0`))}function Fx({gen:e,evaluated:t,props:r,items:n}){r instanceof $.Name&&e.assign((0,$._)`${t}.props`,r),n instanceof $.Name&&e.assign((0,$._)`${t}.items`,n)}function Wg(e,t,r,n){let{gen:o,schema:s,data:i,allErrors:a,opts:c,self:u}=e,{RULES:l}=u;if(s.$ref&&(c.ignoreKeywordsWithRef||!(0,Mt.schemaHasRulesButRef)(s,l))){o.block(()=>t_(e,"$ref",l.all.$ref.definition));return}c.jtd||qx(e,t),o.block(()=>{for(let f of l.rules)d(f);d(l.post)});function d(f){(0,iu.shouldUseGroup)(s,f)&&(f.type?(o.if((0,Bs.checkDataType)(f.type,i,c.strictNumbers)),Vg(e,f),t.length===1&&t[0]===f.type&&r&&(o.else(),(0,Bs.reportTypeError)(e)),o.endIf()):Vg(e,f),a||o.if((0,$._)`${O.default.errors} === ${n||0}`))}}function Vg(e,t){let{gen:r,schema:n,opts:{useDefaults:o}}=e;o&&(0,$x.assignDefaults)(e,t.type),r.block(()=>{for(let s of t.rules)(0,iu.shouldUseRule)(n,s)&&t_(e,s.keyword,s.definition,t.type)})}function qx(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(Zx(e,t),e.opts.allowUnionTypes||Hx(e,t),Wx(e,e.dataTypes))}function Zx(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{e_(e.dataTypes,r)||au(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}),Kx(e,t)}}function Hx(e,t){t.length>1&&!(t.length===2&&t.includes("null"))&&au(e,"use allowUnionTypes to allow union type keyword")}function Wx(e,t){let r=e.self.RULES.all;for(let n in r){let o=r[n];if(typeof o=="object"&&(0,iu.shouldUseRule)(e.schema,o)){let{type:s}=o.definition;s.length&&!s.some(i=>Vx(t,i))&&au(e,`missing type "${s.join(",")}" for keyword "${n}"`)}}}function Vx(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function e_(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function Kx(e,t){let r=[];for(let n of e.dataTypes)e_(t,n)?r.push(n):t.includes("integer")&&n==="number"&&r.push("integer");e.dataTypes=r}function au(e,t){let r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`,(0,Mt.checkStrictMode)(e,t,e.opts.strictTypes)}var Gs=class{constructor(t,r,n){if((0,ro.validateKeywordUsage)(t,r,n),this.gen=t.gen,this.allErrors=t.allErrors,this.keyword=n,this.data=t.data,this.schema=t.schema[n],this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,Mt.schemaRefOrVal)(t,this.schema,n,this.$data),this.schemaType=r.schemaType,this.parentSchema=t.schema,this.params={},this.it=t,this.def=r,this.$data)this.schemaCode=t.gen.const("vSchema",r_(this.$data,t));else if(this.schemaCode=this.schemaValue,!(0,ro.validSchemaType)(this.schema,r.schemaType,r.allowUndefined))throw new Error(`${n} value must be ${JSON.stringify(r.schemaType)}`);("code"in r?r.trackErrors:r.errors!==!1)&&(this.errsCount=t.gen.const("_errs",O.default.errors))}result(t,r,n){this.failResult((0,$.not)(t),r,n)}failResult(t,r,n){this.gen.if(t),n?n():this.error(),r?(this.gen.else(),r(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(t,r){this.failResult((0,$.not)(t),void 0,r)}fail(t){if(t===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(t),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);let{schemaCode:r}=this;this.fail((0,$._)`${r} !== undefined && (${(0,$.or)(this.invalid$data(),t)})`)}error(t,r,n){if(r){this.setParams(r),this._error(t,n),this.setParams({});return}this._error(t,n)}_error(t,r){(t?to.reportExtraError:to.reportError)(this,this.def.error,r)}$dataError(){(0,to.reportError)(this,this.def.$dataError||to.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,to.resetErrorsCount)(this.gen,this.errsCount)}ok(t){this.allErrors||this.gen.if(t)}setParams(t,r){r?Object.assign(this.params,t):this.params=t}block$data(t,r,n=$.nil){this.gen.block(()=>{this.check$data(t,n),r()})}check$data(t=$.nil,r=$.nil){if(!this.$data)return;let{gen:n,schemaCode:o,schemaType:s,def:i}=this;n.if((0,$.or)((0,$._)`${o} === undefined`,r)),t!==$.nil&&n.assign(t,!0),(s.length||i.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),t!==$.nil&&n.assign(t,!1)),n.else()}invalid$data(){let{gen:t,schemaCode:r,schemaType:n,def:o,it:s}=this;return(0,$.or)(i(),a());function i(){if(n.length){if(!(r instanceof $.Name))throw new Error("ajv implementation error");let c=Array.isArray(n)?n:[n];return(0,$._)`${(0,Bs.checkDataTypes)(c,r,s.opts.strictNumbers,Bs.DataType.Wrong)}`}return $.nil}function a(){if(o.validateSchema){let c=t.scopeValue("validate$data",{ref:o.validateSchema});return(0,$._)`!${c}(${r})`}return $.nil}}subschema(t,r){let n=(0,su.getSubschema)(this.it,t);(0,su.extendSubschemaData)(n,this.it,t),(0,su.extendSubschemaMode)(n,t);let o={...this.it,...n,items:void 0,props:void 0};return Mx(o,r),o}mergeEvaluated(t,r){let{it:n,gen:o}=this;n.opts.unevaluated&&(n.props!==!0&&t.props!==void 0&&(n.props=Mt.mergeEvaluated.props(o,t.props,n.props,r)),n.items!==!0&&t.items!==void 0&&(n.items=Mt.mergeEvaluated.items(o,t.items,n.items,r)))}mergeValidEvaluated(t,r){let{it:n,gen:o}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return o.if(r,()=>this.mergeEvaluated(t,$.Name)),!0}};Xt.KeywordCxt=Gs;function t_(e,t,r,n){let o=new Gs(e,r,t);"code"in r?r.code(o,n):o.$data&&r.validate?(0,ro.funcKeywordCode)(o,r):"macro"in r?(0,ro.macroKeywordCode)(o,r):(r.compile||r.validate)&&(0,ro.funcKeywordCode)(o,r)}var Bx=/^\/(?:[^~]|~0|~1)*$/,Gx=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function r_(e,{dataLevel:t,dataNames:r,dataPathArr:n}){let o,s;if(e==="")return O.default.rootData;if(e[0]==="/"){if(!Bx.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);o=e,s=O.default.rootData}else{let u=Gx.exec(e);if(!u)throw new Error(`Invalid JSON-pointer: ${e}`);let l=+u[1];if(o=u[2],o==="#"){if(l>=t)throw new Error(c("property/index",l));return n[t-l]}if(l>t)throw new Error(c("data",l));if(s=r[t-l],!o)return s}let i=s,a=o.split("/");for(let u of a)u&&(s=(0,$._)`${s}${(0,$.getProperty)((0,Mt.unescapeJsonPointer)(u))}`,i=(0,$._)`${i} && ${s}`);return i;function c(u,l){return`Cannot access ${u} ${l} levels up, current level is ${t}`}}Xt.getData=r_});var Ys=w(uu=>{"use strict";Object.defineProperty(uu,"__esModule",{value:!0});var cu=class extends Error{constructor(t){super("validation failed"),this.errors=t,this.ajv=this.validation=!0}};uu.default=cu});var oo=w(fu=>{"use strict";Object.defineProperty(fu,"__esModule",{value:!0});var lu=eo(),du=class extends Error{constructor(t,r,n,o){super(o||`can't resolve reference ${n} from id ${r}`),this.missingRef=(0,lu.resolveUrl)(t,r,n),this.missingSchema=(0,lu.normalizeId)((0,lu.getFullPath)(t,this.missingRef))}};fu.default=du});var Xs=w(tt=>{"use strict";Object.defineProperty(tt,"__esModule",{value:!0});tt.resolveSchema=tt.getCompilingSchema=tt.resolveRef=tt.compileSchema=tt.SchemaEnv=void 0;var dt=M(),Yx=Ys(),hr=Ct(),ft=eo(),n_=q(),Jx=no(),Br=class{constructor(t){var r;this.refs={},this.dynamicAnchors={};let n;typeof t.schema=="object"&&(n=t.schema),this.schema=t.schema,this.schemaId=t.schemaId,this.root=t.root||this,this.baseId=(r=t.baseId)!==null&&r!==void 0?r:(0,ft.normalizeId)(n?.[t.schemaId||"$id"]),this.schemaPath=t.schemaPath,this.localRefs=t.localRefs,this.meta=t.meta,this.$async=n?.$async,this.refs={}}};tt.SchemaEnv=Br;function mu(e){let t=o_.call(this,e);if(t)return t;let r=(0,ft.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:n,lines:o}=this.opts.code,{ownProperties:s}=this.opts,i=new dt.CodeGen(this.scope,{es5:n,lines:o,ownProperties:s}),a;e.$async&&(a=i.scopeValue("Error",{ref:Yx.default,code:(0,dt._)`require("ajv/dist/runtime/validation_error").default`}));let c=i.scopeName("validate");e.validateName=c;let u={gen:i,allErrors:this.opts.allErrors,data:hr.default.data,parentData:hr.default.parentData,parentDataProperty:hr.default.parentDataProperty,dataNames:[hr.default.data],dataPathArr:[dt.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:i.scopeValue("schema",this.opts.code.source===!0?{ref:e.schema,code:(0,dt.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:dt.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,dt._)`""`,opts:this.opts,self:this},l;try{this._compilations.add(e),(0,Jx.validateFunctionCode)(u),i.optimize(this.opts.code.optimize);let d=i.toString();l=`${i.scopeRefs(hr.default.scope)}return ${d}`,this.opts.code.process&&(l=this.opts.code.process(l,e));let p=new Function(`${hr.default.self}`,`${hr.default.scope}`,l)(this,this.scope.get());if(this.scope.value(c,{ref:p}),p.errors=null,p.schema=e.schema,p.schemaEnv=e,e.$async&&(p.$async=!0),this.opts.code.source===!0&&(p.source={validateName:c,validateCode:d,scopeValues:i._values}),this.opts.unevaluated){let{props:m,items:h}=u;p.evaluated={props:m instanceof dt.Name?void 0:m,items:h instanceof dt.Name?void 0:h,dynamicProps:m instanceof dt.Name,dynamicItems:h instanceof dt.Name},p.source&&(p.source.evaluated=(0,dt.stringify)(p.evaluated))}return e.validate=p,e}catch(d){throw delete e.validate,delete e.validateName,l&&this.logger.error("Error compiling schema, function code:",l),d}finally{this._compilations.delete(e)}}tt.compileSchema=mu;function Xx(e,t,r){var n;r=(0,ft.resolveUrl)(this.opts.uriResolver,t,r);let o=e.refs[r];if(o)return o;let s=tP.call(this,e,r);if(s===void 0){let i=(n=e.localRefs)===null||n===void 0?void 0:n[r],{schemaId:a}=this.opts;i&&(s=new Br({schema:i,schemaId:a,root:e,baseId:t}))}if(s!==void 0)return e.refs[r]=Qx.call(this,s)}tt.resolveRef=Xx;function Qx(e){return(0,ft.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:mu.call(this,e)}function o_(e){for(let t of this._compilations)if(eP(t,e))return t}tt.getCompilingSchema=o_;function eP(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function tP(e,t){let r;for(;typeof(r=this.refs[t])=="string";)t=r;return r||this.schemas[t]||Js.call(this,e,t)}function Js(e,t){let r=this.opts.uriResolver.parse(t),n=(0,ft._getFullPath)(this.opts.uriResolver,r),o=(0,ft.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&n===o)return pu.call(this,r,e);let s=(0,ft.normalizeId)(n),i=this.refs[s]||this.schemas[s];if(typeof i=="string"){let a=Js.call(this,e,i);return typeof a?.schema!="object"?void 0:pu.call(this,r,a)}if(typeof i?.schema=="object"){if(i.validate||mu.call(this,i),s===(0,ft.normalizeId)(t)){let{schema:a}=i,{schemaId:c}=this.opts,u=a[c];return u&&(o=(0,ft.resolveUrl)(this.opts.uriResolver,o,u)),new Br({schema:a,schemaId:c,root:e,baseId:o})}return pu.call(this,r,i)}}tt.resolveSchema=Js;var rP=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function pu(e,{baseId:t,schema:r,root:n}){var o;if(((o=e.fragment)===null||o===void 0?void 0:o[0])!=="/")return;for(let a of e.fragment.slice(1).split("/")){if(typeof r=="boolean")return;let c=r[(0,n_.unescapeFragment)(a)];if(c===void 0)return;r=c;let u=typeof r=="object"&&r[this.opts.schemaId];!rP.has(a)&&u&&(t=(0,ft.resolveUrl)(this.opts.uriResolver,t,u))}let s;if(typeof r!="boolean"&&r.$ref&&!(0,n_.schemaHasRulesButRef)(r,this.RULES)){let a=(0,ft.resolveUrl)(this.opts.uriResolver,t,r.$ref);s=Js.call(this,n,a)}let{schemaId:i}=this.opts;if(s=s||new Br({schema:r,schemaId:i,root:n,baseId:t}),s.schema!==s.root.schema)return s}});var s_=w((Sj,nP)=>{nP.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 bu=w((bj,f_)=>{"use strict";var oP=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),gu=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),sP=RegExp.prototype.test.bind(/^\d*$/u),gr=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),_u=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),a_=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u),yu=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u),iP=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u),Ue=new Array(256);{let e="0123456789ABCDEF";for(let t=0;t<256;t++)Ue[t]="%"+e[t>>4]+e[t&15]}function xe(e){return e<2048?Ue[192|e>>6]+Ue[128|e&63]:e<65536?Ue[224|e>>12]+Ue[128|e>>6&63]+Ue[128|e&63]:Ue[240|e>>18]+Ue[128|e>>12&63]+Ue[128|e>>6&63]+Ue[128|e&63]}function aP(e){let t="",r=0,n=0;for(n=0;n<e.length;n++)if(r=e[n].charCodeAt(0),r!==48){if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n];break}for(n+=1;n<e.length;n++){if(r=e[n].charCodeAt(0),!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102))return"";t+=e[n]}return t}var cP=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/),uP=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/),lP=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/),dP=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function fP(e){if(e.length===0)return!1;for(let t=0;t<e.length;t++)if(!lP(e[t])){if(e[t]==="%"&&t+2<e.length&&gr(e.slice(t+1,t+3))){t+=2;continue}return!1}return!0}function i_(e){let t=-1,r=0,n=-1,o=0;for(let a=0;a<e.length;a++)e[a]==="0"?(n===-1&&(n=a),o++,o>r&&(r=o,t=n)):(n=-1,o=0);if(r<2)return e.join(":");let s=e.slice(0,t).join(":"),i=e.slice(t+r).join(":");return s+"::"+i}function pP(e){let t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return;let r=t===-1?e.split(":"):e.slice(0,t).split(":"),n=t===-1?[]:e.slice(t+2).split(":");t!==-1&&(r.length===1&&r[0]===""&&(r.length=0),n.length===1&&n[0]===""&&(n.length=0));let o=r.concat(n),s=0;for(let a=0;a<o.length;a++){let c=o[a];if(c==="")return;if(c.indexOf(".")!==-1){if(a!==o.length-1||t!==-1&&n.length===0||!gu(c))return;s+=2;continue}if(!cP(c))return;o[a]=parseInt(c,16).toString(16),s++}if(t===-1)return s!==8?void 0:i_(o);if(s>=8)return;let i=o.slice(0,r.length);for(let a=s;a<8;a++)i.push("0");for(let a=r.length;a<o.length;a++)i.push(o[a]);return i_(i)}function hu(e){let t=e[0]==="["&&e[e.length-1]==="]";if((e[0]==="["||e[e.length-1]==="]")&&!t)return{host:e,isIPV6:!1,error:!0};let n=t?e.slice(1,-1):e;if(t&&uP(n))return n=n.toLowerCase(),{host:`[${n}]`,escapedHost:n,isIPV6:!1,isIPVFuture:!0};if(mP(n,":")<2)return{host:e,isIPV6:!1,error:t};let o="",s=n.indexOf("%");if(s!==-1){let a=n.slice(s,s+3).toLowerCase()==="%25"?3:1;if(o=n.slice(s+a),!fP(o))return{host:e,isIPV6:!1,error:!0};n=n.slice(0,s)}let i=pP(n);return i===void 0?{host:e,isIPV6:!1,error:!0}:{host:i+(o?"%"+o:""),escapedHost:i+(o?"%25"+o:""),isIPV6:!0}}function mP(e,t){let r=0;for(let n=0;n<e.length;n++)e[n]===t&&r++;return r}function hP(e){let t=e,r=[],n=-1,o=0;for(;o=t.length;){if(o===1){if(t===".")break;if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(o===2){if(t[0]==="."){if(t[1]===".")break;if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&(t[1]==="."||t[1]==="/")){r.push("/");break}}else if(o===3&&t==="/.."){r.length!==0&&r.pop(),r.push("/");break}if(t[0]==="."){if(t[1]==="."){if(t[2]==="/"){t=t.slice(3);continue}}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"&&t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."&&t[3]==="/"){t=t.slice(3),r.length!==0&&r.pop();continue}}if((n=t.indexOf("/",1))===-1){r.push(t);break}else r.push(t.slice(0,n)),t=t.slice(n)}return r.join("")}var gP={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"},_P=/[@/?#:]/g,yP=/[@/?#]/g;function c_(e,t){let r=t?yP:_P;return r.lastIndex=0,e.replace(r,n=>gP[n])}function u_(e,t=!1){if(e.indexOf("%")===-1)return e;let r="";for(let n=0;n<e.length;n++){if(e[n]==="%"&&n+2<e.length){let o=e.slice(n+1,n+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));t&&_u(i)?r+=i:r+="%"+s,n+=2;continue}}r+=e[n]}return r}function SP(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));i!=="."&&_u(i)?t+=i:t+="%"+s,r+=2;continue}}if(a_(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=d_(o)?n:Ue[o];else if(o<55296||o>57343)t+=xe(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=xe(65536+(o-55296<<10)+(s-56320)),r++):t+=xe(65533)}else t+=xe(65533)}}return t}function bP(e,t=!1){let r="",n=t&&e[0]!=="/";for(let o=0;o<e.length;o++){let s=e[o];if(s==="%"&&o+2<e.length){let i=e.slice(o+1,o+3);if(gr(i)){r+="%"+i.toUpperCase(),o+=2;continue}}if(s==="/"&&(n=!1),a_(s)&&(s!==":"||!n))r+=s;else{let i=e.charCodeAt(o);if(i<128)r+=Ue[i];else if(i<55296||i>57343)r+=xe(i);else if(i<=56319&&o+1<e.length){let a=e.charCodeAt(o+1);a>=56320&&a<=57343?(r+=xe(65536+(i-55296<<10)+(a-56320)),o++):r+=xe(65533)}else r+=xe(65533)}}return r}function Su(e,t){let r="";for(let n=0;n<e.length;n++){let o=e[n];if(o==="%"&&n+2<e.length){let s=e.slice(n+1,n+3);if(gr(s)){r+="%"+s.toUpperCase(),n+=2;continue}}if(t(o))r+=o;else{let s=e.charCodeAt(n);if(s<128)r+=Ue[s];else if(s<55296||s>57343)r+=xe(s);else if(s<=56319&&n+1<e.length){let i=e.charCodeAt(n+1);i>=56320&&i<=57343?(r+=xe(65536+(s-55296<<10)+(i-56320)),n++):r+=xe(65533)}else r+=xe(65533)}}return r}function l_(e){return Su(e,iP)}function EP(e){return Su(e,yu)}function vP(e){return Su(e,yu)}function d_(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===42||e===43||e===45||e===46||e===47||e===64||e===95}function wP(e){let t="";for(let r=0;r<e.length;r++){let n=e[r];if(n==="%"&&r+2<e.length){let o=e.slice(r+1,r+3);if(gr(o)){let s=o.toUpperCase(),i=String.fromCharCode(parseInt(s,16));_u(i)?t+=i:t+="%"+s,r+=2;continue}}if(yu(n))t+=n;else{let o=e.charCodeAt(r);if(o<128)t+=d_(o)?n:Ue[o];else if(o<55296||o>57343)t+=xe(o);else if(o<=56319&&r+1<e.length){let s=e.charCodeAt(r+1);s>=56320&&s<=57343?(t+=xe(65536+(o-55296<<10)+(s-56320)),r++):t+=xe(65533)}else t+=xe(65533)}}return t}function kP(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){let n=e.slice(r+1,r+3);if(gr(n)){t+="%"+n.toUpperCase(),r+=2;continue}}t+=escape(e[r])}return t}function xP(e){let t=[];if(e.userinfo!==void 0&&(t.push(l_(e.userinfo)),t.push("@")),e.host!==void 0){let r=e.host;if(!gu(r)){let n=hu(r);n.isIPV6!==!0&&n.isIPVFuture!==!0&&(r=u_(r,!0),n=hu(r)),n.isIPV6===!0||n.isIPVFuture===!0?r=`[${n.escapedHost}]`:r=c_(r,!1)}t.push(r)}if(typeof e.port=="number"||typeof e.port=="string"){let r=String(e.port);if(!sP(r))throw new TypeError("URI port is malformed.");t.push(":"),t.push(r)}return t.length?t.join(""):void 0}f_.exports={nonSimpleDomain:dP,recomposeAuthority:xP,reescapeHostDelimiters:c_,normalizePercentEncoding:u_,normalizePathEncoding:SP,serializePathEncoding:bP,normalizeQueryFragmentEncoding:wP,encodeUserinfo:l_,encodeQuery:EP,encodeFragment:vP,escapePreservingEscapes:kP,removeDotSegments:hP,isIPv4:gu,isUUID:oP,normalizeIPv6:hu,stringArrayToHexStripped:aP}});var __=w((Ej,g_)=>{"use strict";var{isUUID:PP}=bu(),$P=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu,TP=["http","https","ws","wss","urn","urn:uuid"];function RP(e){return TP.indexOf(e)!==-1}function Eu(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]==="w"||e.scheme[0]==="W")&&(e.scheme[1]==="s"||e.scheme[1]==="S")&&(e.scheme[2]==="s"||e.scheme[2]==="S"):!1}function p_(e){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e}function m_(e){let t=String(e.scheme).toLowerCase()==="https";return(e.port===(t?443:80)||e.port==="")&&(e.port=void 0),e.path||(e.path="/"),e}function OP(e){return e.secure=Eu(e),e.resourceName=(e.path||"/")+(e.query?"?"+e.query:""),e.path=void 0,e.query=void 0,e}function IP(e){if((e.port===(Eu(e)?443:80)||e.port==="")&&(e.port=void 0),typeof e.secure=="boolean"&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){let t=e.resourceName.indexOf("?"),r=t===-1?e.resourceName:e.resourceName.slice(0,t);e.path=r&&r!=="/"?r:void 0,e.query=t===-1?void 0:e.resourceName.slice(t+1),e.resourceName=void 0}return e.fragment=void 0,e}function AP(e,t){if(!e.path)return e.error="URN can not be parsed",e;let r=e.path.match($P);if(r&&r[0]===e.path){let n=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase(),e.nss=r[2];let o=`${n}:${t.nid||e.nid}`,s=vu(o);e.path=void 0,s&&(e=s.parse(e,t))}else e.error=e.error||"URN can not be parsed.";return e}function CP(e,t){if(e.nid===void 0)throw new Error("URN without nid cannot be serialized");let r=t.scheme||e.scheme||"urn",n=e.nid.toLowerCase(),o=`${r}:${t.nid||n}`,s=vu(o);s&&(e=s.serialize(e,t));let i=e,a=e.nss;return i.path=`${n||t.nid}:${a}`,t.skipEscape=!0,i}function MP(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!PP(r.uuid))&&(r.error=r.error||"UUID is not valid."),r}function zP(e){let t=e;return t.nss=(e.uuid||"").toLowerCase(),t}var h_={scheme:"http",domainHost:!0,parse:p_,serialize:m_},DP={scheme:"https",domainHost:h_.domainHost,parse:p_,serialize:m_},Qs={scheme:"ws",domainHost:!0,parse:OP,serialize:IP},NP={scheme:"wss",domainHost:Qs.domainHost,parse:Qs.parse,serialize:Qs.serialize},LP={scheme:"urn",parse:AP,serialize:CP,skipNormalize:!0},jP={scheme:"urn:uuid",parse:MP,serialize:zP,skipNormalize:!0},ei={http:h_,https:DP,ws:Qs,wss:NP,urn:LP,"urn:uuid":jP};Object.setPrototypeOf(ei,null);function vu(e){return e&&(ei[e]||ei[e.toLowerCase()])||void 0}g_.exports={wsIsSecure:Eu,SCHEMES:ei,isValidSchemeName:RP,getSchemeHandler:vu}});var I_=w((vj,ni)=>{"use strict";var{normalizeIPv6:v_,removeDotSegments:io,recomposeAuthority:UP,normalizePercentEncoding:w_,normalizePathEncoding:FP,serializePathEncoding:y_,normalizeQueryFragmentEncoding:S_,encodeQuery:qP,encodeFragment:ZP,reescapeHostDelimiters:HP,isIPv4:k_,nonSimpleDomain:WP}=bu(),{SCHEMES:x_,getSchemeHandler:wu}=__(),P_=/^[A-Za-z][A-Za-z0-9+.-]*$/u,$_="URI scheme is malformed.";function b_(e){let t=unescape(String(e));if(!P_.test(t))throw new TypeError($_);return t}function VP(e,t){return typeof e=="string"?e=e$(e,t):typeof e=="object"&&(e=ri(_r(e,t),t)),e}function KP(e,t,r){let n=r?Object.assign({scheme:"null"},r):{scheme:"null"},{parsed:o,malformedAuthorityOrPort:s,malformedPercentEncoding:i,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:u}=ti(e,n),{parsed:l,malformedAuthorityOrPort:d,malformedPercentEncoding:f,malformedSchemeSpecific:p,malformedHost:m,malformedScheme:h}=ti(t,n);if(s||d||i||f||a||p||c||m||u||h)throw new Error(o.error||l.error||"URI is malformed.");let g=T_(o,l,n,!0),y=wu(r&&r.scheme||g.scheme),E=g.host,v=E!==void 0&&E!==""&&(k_(E)||v_(E).isIPV6);R_(g,r||{},y,v);let I=E&&E.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(E);if(g.error&&!I)throw new Error(g.error);return n.skipEscape=!0,_r(g,n)}function T_(e,t,r,n){let o={};return n||(e=ri(_r(e,r),r),t=ri(_r(t,r),r)),r=r||{},!r.tolerant&&t.scheme?(o.scheme=t.scheme,o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=io(t.path||""),o.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(o.userinfo=t.userinfo,o.host=t.host,o.port=t.port,o.path=io(t.path||""),o.query=t.query):(t.path?(t.path[0]==="/"?o.path=io(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?o.path="/"+t.path:e.path?o.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:o.path=t.path,o.path=io(o.path)),o.query=t.query):(o.path=e.path,t.query!==void 0?o.query=t.query:o.query=e.query),o.userinfo=e.userinfo,o.host=e.host,o.port=e.port),o.scheme=e.scheme),o.fragment=t.fragment,o}function BP(e,t,r){let n=E_(e,r),o=E_(t,r);return n!==void 0&&o!==void 0&&n===o}function _r(e,t){let r={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:""},n=Object.assign({},t),o=[];r.scheme&&(r.scheme=b_(r.scheme));let s=wu(n.scheme||r.scheme);s&&s.serialize&&s.serialize(r,n);let i=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0,a=!n.skipEscape&&r.scheme===void 0&&!i;r.path!==void 0&&(n.skipEscape?r.path=w_(r.path):r.path=y_(r.path,a)),n.reference!=="suffix"&&r.scheme&&(r.scheme=b_(r.scheme),o.push(r.scheme,":"));let c=UP(r);if(c!==void 0&&(n.reference!=="suffix"&&o.push("//"),o.push(c),r.path&&r.path[0]!=="/"&&o.push("/")),r.path!==void 0){let u=r.path;!n.absolutePath&&(!s||!s.absolutePath)&&(u=io(u)),a&&(u=y_(u,!0)),c===void 0&&u[0]==="/"&&u[1]==="/"&&(u="/%2F"+u.slice(2)),o.push(u)}return r.query!==void 0&&o.push("?",qP(r.query)),r.fragment!==void 0&&o.push("#",ZP(r.fragment)),o.join("")}var GP=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u,YP=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/,JP=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function XP(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!=="/")return'URI path must start with "/" when authority is present.';if(typeof e.port=="number"&&(e.port<0||e.port>65535))return"URI port is malformed."}function so(e){if(e===void 0)return!1;let t=e.indexOf("%");for(;t!==-1;){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3)))return!0;t=e.indexOf("%",t+3)}return!1}function ku(e){return e[0]==="["&&e[e.length-1]==="]"}function QP(e){let t=e[4];return so(e[3])||t!==void 0&&!ku(t)&&so(t)||so(e[6])||so(e[7])||so(e[8])}function R_(e,t,r,n){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&!ku(e.host)&&(t.domainHost||r&&r.domainHost)&&n===!1&&WP(e.host))try{e.host=new URL("http://"+e.host).hostname}catch(o){return e.error=e.error||"Host's domain name can not be converted to ASCII: "+o,!0}return!1}function ti(e,t){let r=Object.assign({},t),n={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0},o=!1,s=!1,i=!1,a=!1,c=!1,u=!1,l=!1;r.reference==="suffix"&&(r.scheme?e=r.scheme+":"+e:e="//"+e);let d=e.match(YP);d!==null&&d[1].indexOf("\\")!==-1&&(n.error="URI authority must not contain a literal backslash.",o=!0);let f=e.match(JP);if(f!==null){let m=f[1],h=m.replace(/[\t\n\r]/g,"");h.length>=2&&(h.slice(0,2)!=="//"?(n.error=n.error||"URI authority must not contain a literal backslash.",o=!0):m.length!==h.length&&(n.error=n.error||"URI authority introducer must not contain whitespace.",o=!0))}let p=e.match(GP);if(p){if(n.scheme=p[1],n.userinfo=p[3],n.host=p[4],n.port=parseInt(p[5],10),n.path=p[6]||"",n.query=p[7],n.fragment=p[8],n.scheme!==void 0){let g=unescape(n.scheme);P_.test(g)?n.scheme=g.toLowerCase():(n.error=n.error||$_,u=!0)}s=QP(p),s&&(n.error=n.error||"URI contains malformed percent-encoding."),isNaN(n.port)&&(n.port=p[5]);let m=XP(n,p);if(m!==void 0&&(n.error=n.error||m,o=!0),n.host)if(k_(n.host)===!1){let y=ku(n.host),E=n.host.indexOf("[")!==-1||n.host.indexOf("]")!==-1,v=v_(n.host);l=v.isIPV6||v.isIPVFuture===!0,c=E&&(!y||v.error===!0),n.host=l?v.host:v.host.toLowerCase(),c&&(n.error=n.error||"URI host is malformed.",o=!0)}else l=!0;n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&n.query===void 0&&!n.path?n.reference="same-document":n.scheme===void 0?n.reference="relative":n.fragment===void 0?n.reference="absolute":n.reference="uri",r.reference&&r.reference!=="suffix"&&r.reference!==n.reference&&(n.error=n.error||"URI is not a "+r.reference+" reference.");let h=wu(r.scheme||n.scheme);if(c||(a=R_(n,r,h,l)),!h||h&&!h.skipNormalize){if(e.indexOf("%")!==-1&&n.host!==void 0&&!c){let g=l?n.host:w_(n.host,!0);n.host=HP(g,l)}n.path&&(n.path=FP(n.path)),n.query&&(n.query=S_(n.query)),n.fragment&&(n.fragment=S_(n.fragment))}h&&h.parse&&(h.parse(n,r),h===x_.urn&&n.nid===void 0&&(i=!0))}else n.error=n.error||"URI can not be parsed.";return{parsed:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:u}}function ri(e,t){return ti(e,t).parsed}function e$(e,t){return O_(e,t).normalized}function O_(e,t){let{parsed:r,malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}=ti(e,t);return{normalized:n||o||s||i||a?e:_r(r,t),malformedAuthorityOrPort:n,malformedPercentEncoding:o,malformedSchemeSpecific:s,malformedHost:i,malformedScheme:a}}function E_(e,t){if(typeof e!="string"&&typeof e!="object")return;let r;try{r=typeof e=="string"?e:_r(e,t)}catch{return}let{normalized:n,malformedAuthorityOrPort:o,malformedPercentEncoding:s,malformedSchemeSpecific:i,malformedHost:a,malformedScheme:c}=O_(r,t);return o||s||i||a||c?void 0:n}var xu={SCHEMES:x_,normalize:VP,resolve:KP,resolveComponent:T_,equal:BP,serialize:_r,parse:ri};ni.exports=xu;ni.exports.default=xu;ni.exports.fastUri=xu});var C_=w(Pu=>{"use strict";Object.defineProperty(Pu,"__esModule",{value:!0});var A_=I_();A_.code='require("ajv/dist/runtime/uri").default';Pu.default=A_});var F_=w(ye=>{"use strict";Object.defineProperty(ye,"__esModule",{value:!0});ye.CodeGen=ye.Name=ye.nil=ye.stringify=ye.str=ye._=ye.KeywordCxt=void 0;var t$=no();Object.defineProperty(ye,"KeywordCxt",{enumerable:!0,get:function(){return t$.KeywordCxt}});var Gr=M();Object.defineProperty(ye,"_",{enumerable:!0,get:function(){return Gr._}});Object.defineProperty(ye,"str",{enumerable:!0,get:function(){return Gr.str}});Object.defineProperty(ye,"stringify",{enumerable:!0,get:function(){return Gr.stringify}});Object.defineProperty(ye,"nil",{enumerable:!0,get:function(){return Gr.nil}});Object.defineProperty(ye,"Name",{enumerable:!0,get:function(){return Gr.Name}});Object.defineProperty(ye,"CodeGen",{enumerable:!0,get:function(){return Gr.CodeGen}});var r$=Ys(),L_=oo(),n$=Gc(),ao=Xs(),o$=M(),co=eo(),oi=Qn(),Tu=q(),M_=s_(),s$=C_(),j_=(e,t)=>new RegExp(e,t);j_.code="new RegExp";var i$=["removeAdditional","useDefaults","coerceTypes"],a$=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]),c$={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."},u$={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'},z_=200;function l$(e){var t,r,n,o,s,i,a,c,u,l,d,f,p,m,h,g,y,E,v,I,x,z,j,Be,Pe;let Ge=e.strict,xr=(t=e.code)===null||t===void 0?void 0:t.optimize,Io=xr===!0||xr===void 0?1:xr||0,Ao=(n=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&n!==void 0?n:j_,Pb=(o=e.uriResolver)!==null&&o!==void 0?o:s$.default;return{strictSchema:(i=(s=e.strictSchema)!==null&&s!==void 0?s:Ge)!==null&&i!==void 0?i:!0,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:Ge)!==null&&c!==void 0?c:!0,strictTypes:(l=(u=e.strictTypes)!==null&&u!==void 0?u:Ge)!==null&&l!==void 0?l:"log",strictTuples:(f=(d=e.strictTuples)!==null&&d!==void 0?d:Ge)!==null&&f!==void 0?f:"log",strictRequired:(m=(p=e.strictRequired)!==null&&p!==void 0?p:Ge)!==null&&m!==void 0?m:!1,code:e.code?{...e.code,optimize:Io,regExp:Ao}:{optimize:Io,regExp:Ao},loopRequired:(h=e.loopRequired)!==null&&h!==void 0?h:z_,loopEnum:(g=e.loopEnum)!==null&&g!==void 0?g:z_,meta:(y=e.meta)!==null&&y!==void 0?y:!0,messages:(E=e.messages)!==null&&E!==void 0?E:!0,inlineRefs:(v=e.inlineRefs)!==null&&v!==void 0?v:!0,schemaId:(I=e.schemaId)!==null&&I!==void 0?I:"$id",addUsedSchema:(x=e.addUsedSchema)!==null&&x!==void 0?x:!0,validateSchema:(z=e.validateSchema)!==null&&z!==void 0?z:!0,validateFormats:(j=e.validateFormats)!==null&&j!==void 0?j:!0,unicodeRegExp:(Be=e.unicodeRegExp)!==null&&Be!==void 0?Be:!0,int32range:(Pe=e.int32range)!==null&&Pe!==void 0?Pe:!0,uriResolver:Pb}}var uo=class{constructor(t={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,t=this.opts={...t,...l$(t)};let{es5:r,lines:n}=this.opts.code;this.scope=new o$.ValueScope({scope:{},prefixes:a$,es5:r,lines:n}),this.logger=g$(t.logger);let o=t.validateFormats;t.validateFormats=!1,this.RULES=(0,n$.getRules)(),D_.call(this,c$,t,"NOT SUPPORTED"),D_.call(this,u$,t,"DEPRECATED","warn"),this._metaOpts=m$.call(this),t.formats&&f$.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),t.keywords&&p$.call(this,t.keywords),typeof t.meta=="object"&&this.addMetaSchema(t.meta),d$.call(this),t.validateFormats=o}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){let{$data:t,meta:r,schemaId:n}=this.opts,o=M_;n==="id"&&(o={...M_},o.id=o.$id,delete o.$id),r&&t&&this.addMetaSchema(o,o[n],!1)}defaultMeta(){let{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let n;if(typeof t=="string"){if(n=this.getSchema(t),!n)throw new Error(`no schema with key or ref "${t}"`)}else n=this.compile(t);let o=n(r);return"$async"in n||(this.errors=n.errors),o}compile(t,r){let n=this._addSchema(t,r);return n.validate||this._compileSchemaEnv(n)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function")throw new Error("options.loadSchema should be a function");let{loadSchema:n}=this.opts;return o.call(this,t,r);async function o(l,d){await s.call(this,l.$schema);let f=this._addSchema(l,d);return f.validate||i.call(this,f)}async function s(l){l&&!this.getSchema(l)&&await o.call(this,{$ref:l},!0)}async function i(l){try{return this._compileSchemaEnv(l)}catch(d){if(!(d instanceof L_.default))throw d;return a.call(this,d),await c.call(this,d.missingSchema),i.call(this,l)}}function a({missingSchema:l,missingRef:d}){if(this.refs[l])throw new Error(`AnySchema ${l} is loaded but ${d} cannot be resolved`)}async function c(l){let d=await u.call(this,l);this.refs[l]||await s.call(this,d.$schema),this.refs[l]||this.addSchema(d,l,r)}async function u(l){let d=this._loading[l];if(d)return d;try{return await(this._loading[l]=n(l))}finally{delete this._loading[l]}}}addSchema(t,r,n,o=this.opts.validateSchema){if(Array.isArray(t)){for(let i of t)this.addSchema(i,void 0,n,o);return this}let s;if(typeof t=="object"){let{schemaId:i}=this.opts;if(s=t[i],s!==void 0&&typeof s!="string")throw new Error(`schema ${i} must be string`)}return r=(0,co.normalizeId)(r||s),this._checkUnique(r),this.schemas[r]=this._addSchema(t,n,r,o,!0),this}addMetaSchema(t,r,n=this.opts.validateSchema){return this.addSchema(t,r,!0,n),this}validateSchema(t,r){if(typeof t=="boolean")return!0;let n;if(n=t.$schema,n!==void 0&&typeof n!="string")throw new Error("$schema must be a string");if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn("meta-schema not available"),this.errors=null,!0;let o=this.validate(n,t);if(!o&&r){let s="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(s);else throw new Error(s)}return o}getSchema(t){let r;for(;typeof(r=N_.call(this,t))=="string";)t=r;if(r===void 0){let{schemaId:n}=this.opts,o=new ao.SchemaEnv({schema:{},schemaId:n});if(r=ao.resolveSchema.call(this,o,t),!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp)return this._removeAllSchemas(this.schemas,t),this._removeAllSchemas(this.refs,t),this;switch(typeof t){case"undefined":return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case"string":{let r=N_.call(this,t);return typeof r=="object"&&this._cache.delete(r.schema),delete this.schemas[t],delete this.refs[t],this}case"object":{let r=t;this._cache.delete(r);let n=t[this.opts.schemaId];return n&&(n=(0,co.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(let r of t)this.addKeyword(r);return this}addKeyword(t,r){let n;if(typeof t=="string")n=t,typeof r=="object"&&(this.logger.warn("these parameters are deprecated, see docs for addKeyword"),r.keyword=n);else if(typeof t=="object"&&r===void 0){if(r=t,n=r.keyword,Array.isArray(n)&&!n.length)throw new Error("addKeywords: keyword must be string or non-empty array")}else throw new Error("invalid addKeywords parameters");if(y$.call(this,n,r),!r)return(0,Tu.eachItem)(n,s=>$u.call(this,s)),this;b$.call(this,r);let o={...r,type:(0,oi.getJSONTypes)(r.type),schemaType:(0,oi.getJSONTypes)(r.schemaType)};return(0,Tu.eachItem)(n,o.type.length===0?s=>$u.call(this,s,o):s=>o.type.forEach(i=>$u.call(this,s,o,i))),this}getKeyword(t){let r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){let{RULES:r}=this;delete r.keywords[t],delete r.all[t];for(let n of r.rules){let o=n.rules.findIndex(s=>s.keyword===t);o>=0&&n.rules.splice(o,1)}return this}addFormat(t,r){return typeof r=="string"&&(r=new RegExp(r)),this.formats[t]=r,this}errorsText(t=this.errors,{separator:r=", ",dataVar:n="data"}={}){return!t||t.length===0?"No errors":t.map(o=>`${n}${o.instancePath} ${o.message}`).reduce((o,s)=>o+r+s)}$dataMetaSchema(t,r){let n=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(let o of r){let s=o.split("/").slice(1),i=t;for(let a of s)i=i[a];for(let a in n){let c=n[a];if(typeof c!="object")continue;let{$data:u}=c.definition,l=i[a];u&&l&&(i[a]=U_(l))}}return t}_removeAllSchemas(t,r){for(let n in t){let o=t[n];(!r||r.test(n))&&(typeof o=="string"?delete t[n]:o&&!o.meta&&(this._cache.delete(o.schema),delete t[n]))}}_addSchema(t,r,n,o=this.opts.validateSchema,s=this.opts.addUsedSchema){let i,{schemaId:a}=this.opts;if(typeof t=="object")i=t[a];else{if(this.opts.jtd)throw new Error("schema must be object");if(typeof t!="boolean")throw new Error("schema must be object or boolean")}let c=this._cache.get(t);if(c!==void 0)return c;n=(0,co.normalizeId)(i||n);let u=co.getSchemaRefs.call(this,t,n);return c=new ao.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:n,localRefs:u}),this._cache.set(c.schema,c),s&&!n.startsWith("#")&&(n&&this._checkUnique(n),this.refs[n]=c),o&&this.validateSchema(t,!0),c}_checkUnique(t){if(this.schemas[t]||this.refs[t])throw new Error(`schema with key or id "${t}" already exists`)}_compileSchemaEnv(t){if(t.meta?this._compileMetaSchema(t):ao.compileSchema.call(this,t),!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){let r=this.opts;this.opts=this._metaOpts;try{ao.compileSchema.call(this,t)}finally{this.opts=r}}};uo.ValidationError=r$.default;uo.MissingRefError=L_.default;ye.default=uo;function D_(e,t,r,n="error"){for(let o in e){let s=o;s in t&&this.logger[n](`${r}: option ${o}. ${e[s]}`)}}function N_(e){return e=(0,co.normalizeId)(e),this.schemas[e]||this.refs[e]}function d$(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function f$(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function p$(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(let t in e){let r=e[t];r.keyword||(r.keyword=t),this.addKeyword(r)}}function m$(){let e={...this.opts};for(let t of i$)delete e[t];return e}var h$={log(){},warn(){},error(){}};function g$(e){if(e===!1)return h$;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw new Error("logger must implement log, warn and error methods")}var _$=/^[a-z_$][a-z0-9_$:-]*$/i;function y$(e,t){let{RULES:r}=this;if((0,Tu.eachItem)(e,n=>{if(r.keywords[n])throw new Error(`Keyword ${n} is already defined`);if(!_$.test(n))throw new Error(`Keyword ${n} has invalid name`)}),!!t&&t.$data&&!("code"in t||"validate"in t))throw new Error('$data keyword must have "code" or "validate" function')}function $u(e,t,r){var n;let o=t?.post;if(r&&o)throw new Error('keyword with "post" flag cannot have "type"');let{RULES:s}=this,i=o?s.post:s.rules.find(({type:c})=>c===r);if(i||(i={type:r,rules:[]},s.rules.push(i)),s.keywords[e]=!0,!t)return;let a={keyword:e,definition:{...t,type:(0,oi.getJSONTypes)(t.type),schemaType:(0,oi.getJSONTypes)(t.schemaType)}};t.before?S$.call(this,i,a,t.before):i.rules.push(a),s.all[e]=a,(n=t.implements)===null||n===void 0||n.forEach(c=>this.addKeyword(c))}function S$(e,t,r){let n=e.rules.findIndex(o=>o.keyword===r);n>=0?e.rules.splice(n,0,t):(e.rules.push(t),this.logger.warn(`rule ${r} is not defined`))}function b$(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=U_(t)),e.validateSchema=this.compile(t,!0))}var E$={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function U_(e){return{anyOf:[e,E$]}}});var q_=w(Ru=>{"use strict";Object.defineProperty(Ru,"__esModule",{value:!0});var v$={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Ru.default=v$});var V_=w(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});yr.callRef=yr.getValidate=void 0;var w$=oo(),Z_=et(),Fe=M(),Yr=Ct(),H_=Xs(),si=q(),k$={keyword:"$ref",schemaType:"string",code(e){let{gen:t,schema:r,it:n}=e,{baseId:o,schemaEnv:s,validateName:i,opts:a,self:c}=n,{root:u}=s;if((r==="#"||r==="#/")&&o===u.baseId)return d();let l=H_.resolveRef.call(c,u,o,r);if(l===void 0)throw new w$.default(n.opts.uriResolver,o,r);if(l instanceof H_.SchemaEnv)return f(l);return p(l);function d(){if(s===u)return ii(e,i,s,s.$async);let m=t.scopeValue("root",{ref:u});return ii(e,(0,Fe._)`${m}.validate`,u,u.$async)}function f(m){let h=W_(e,m);ii(e,h,m,m.$async)}function p(m){let h=t.scopeValue("schema",a.code.source===!0?{ref:m,code:(0,Fe.stringify)(m)}:{ref:m}),g=t.name("valid"),y=e.subschema({schema:m,dataTypes:[],schemaPath:Fe.nil,topSchemaRef:h,errSchemaPath:r},g);e.mergeEvaluated(y),e.ok(g)}}};function W_(e,t){let{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,Fe._)`${r.scopeValue("wrapper",{ref:t})}.validate`}yr.getValidate=W_;function ii(e,t,r,n){let{gen:o,it:s}=e,{allErrors:i,schemaEnv:a,opts:c}=s,u=c.passContext?Yr.default.this:Fe.nil;n?l():d();function l(){if(!a.$async)throw new Error("async schema referenced by sync schema");let m=o.let("valid");o.try(()=>{o.code((0,Fe._)`await ${(0,Z_.callValidateCode)(e,t,u)}`),p(t),i||o.assign(m,!0)},h=>{o.if((0,Fe._)`!(${h} instanceof ${s.ValidationError})`,()=>o.throw(h)),f(h),i||o.assign(m,!1)}),e.ok(m)}function d(){e.result((0,Z_.callValidateCode)(e,t,u),()=>p(t),()=>f(t))}function f(m){let h=(0,Fe._)`${m}.errors`;o.assign(Yr.default.vErrors,(0,Fe._)`${Yr.default.vErrors} === null ? ${h} : ${Yr.default.vErrors}.concat(${h})`),o.assign(Yr.default.errors,(0,Fe._)`${Yr.default.vErrors}.length`)}function p(m){var h;if(!s.opts.unevaluated)return;let g=(h=r?.validate)===null||h===void 0?void 0:h.evaluated;if(s.props!==!0)if(g&&!g.dynamicProps)g.props!==void 0&&(s.props=si.mergeEvaluated.props(o,g.props,s.props));else{let y=o.var("props",(0,Fe._)`${m}.evaluated.props`);s.props=si.mergeEvaluated.props(o,y,s.props,Fe.Name)}if(s.items!==!0)if(g&&!g.dynamicItems)g.items!==void 0&&(s.items=si.mergeEvaluated.items(o,g.items,s.items));else{let y=o.var("items",(0,Fe._)`${m}.evaluated.items`);s.items=si.mergeEvaluated.items(o,y,s.items,Fe.Name)}}}yr.callRef=ii;yr.default=k$});var K_=w(Ou=>{"use strict";Object.defineProperty(Ou,"__esModule",{value:!0});var x$=q_(),P$=V_(),$$=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",x$.default,P$.default];Ou.default=$$});var B_=w(Iu=>{"use strict";Object.defineProperty(Iu,"__esModule",{value:!0});var ai=M(),Qt=ai.operators,ci={maximum:{okStr:"<=",ok:Qt.LTE,fail:Qt.GT},minimum:{okStr:">=",ok:Qt.GTE,fail:Qt.LT},exclusiveMaximum:{okStr:"<",ok:Qt.LT,fail:Qt.GTE},exclusiveMinimum:{okStr:">",ok:Qt.GT,fail:Qt.LTE}},T$={message:({keyword:e,schemaCode:t})=>(0,ai.str)`must be ${ci[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,ai._)`{comparison: ${ci[e].okStr}, limit: ${t}}`},R$={keyword:Object.keys(ci),type:"number",schemaType:"number",$data:!0,error:T$,code(e){let{keyword:t,data:r,schemaCode:n}=e;e.fail$data((0,ai._)`${r} ${ci[t].fail} ${n} || isNaN(${r})`)}};Iu.default=R$});var G_=w(Au=>{"use strict";Object.defineProperty(Au,"__esModule",{value:!0});var lo=M(),O$={message:({schemaCode:e})=>(0,lo.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,lo._)`{multipleOf: ${e}}`},I$={keyword:"multipleOf",type:"number",schemaType:"number",$data:!0,error:O$,code(e){let{gen:t,data:r,schemaCode:n,it:o}=e,s=o.opts.multipleOfPrecision,i=t.let("res"),a=s?(0,lo._)`Math.abs(Math.round(${i}) - ${i}) > 1e-${s}`:(0,lo._)`${i} !== parseInt(${i})`;e.fail$data((0,lo._)`(${n} === 0 || (${i} = ${r}/${n}, ${a}))`)}};Au.default=I$});var J_=w(Cu=>{"use strict";Object.defineProperty(Cu,"__esModule",{value:!0});function Y_(e){let t=e.length,r=0,n=0,o;for(;n<t;)r++,o=e.charCodeAt(n++),o>=55296&&o<=56319&&n<t&&(o=e.charCodeAt(n),(o&64512)===56320&&n++);return r}Cu.default=Y_;Y_.code='require("ajv/dist/runtime/ucs2length").default'});var X_=w(Mu=>{"use strict";Object.defineProperty(Mu,"__esModule",{value:!0});var Sr=M(),A$=q(),C$=J_(),M$={message({keyword:e,schemaCode:t}){let r=e==="maxLength"?"more":"fewer";return(0,Sr.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,Sr._)`{limit: ${e}}`},z$={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:!0,error:M$,code(e){let{keyword:t,data:r,schemaCode:n,it:o}=e,s=t==="maxLength"?Sr.operators.GT:Sr.operators.LT,i=o.opts.unicode===!1?(0,Sr._)`${r}.length`:(0,Sr._)`${(0,A$.useFunc)(e.gen,C$.default)}(${r})`;e.fail$data((0,Sr._)`${i} ${s} ${n}`)}};Mu.default=z$});var Q_=w(zu=>{"use strict";Object.defineProperty(zu,"__esModule",{value:!0});var D$=et(),N$=q(),Jr=M(),L$={message:({schemaCode:e})=>(0,Jr.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,Jr._)`{pattern: ${e}}`},j$={keyword:"pattern",type:"string",schemaType:"string",$data:!0,error:L$,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e,a=i.opts.unicodeRegExp?"u":"";if(n){let{regExp:c}=i.opts.code,u=c.code==="new RegExp"?(0,Jr._)`new RegExp`:(0,N$.useFunc)(t,c),l=t.let("valid");t.try(()=>t.assign(l,(0,Jr._)`${u}(${s}, ${a}).test(${r})`),()=>t.assign(l,!1)),e.fail$data((0,Jr._)`!${l}`)}else{let c=(0,D$.usePattern)(e,o);e.fail$data((0,Jr._)`!${c}.test(${r})`)}}};zu.default=j$});var ey=w(Du=>{"use strict";Object.defineProperty(Du,"__esModule",{value:!0});var fo=M(),U$={message({keyword:e,schemaCode:t}){let r=e==="maxProperties"?"more":"fewer";return(0,fo.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,fo._)`{limit: ${e}}`},F$={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:!0,error:U$,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxProperties"?fo.operators.GT:fo.operators.LT;e.fail$data((0,fo._)`Object.keys(${r}).length ${o} ${n}`)}};Du.default=F$});var ty=w(Nu=>{"use strict";Object.defineProperty(Nu,"__esModule",{value:!0});var po=et(),mo=M(),q$=q(),Z$={message:({params:{missingProperty:e}})=>(0,mo.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,mo._)`{missingProperty: ${e}}`},H$={keyword:"required",type:"object",schemaType:"array",$data:!0,error:Z$,code(e){let{gen:t,schema:r,schemaCode:n,data:o,$data:s,it:i}=e,{opts:a}=i;if(!s&&r.length===0)return;let c=r.length>=a.loopRequired;if(i.allErrors?u():l(),a.strictRequired){let p=e.parentSchema.properties,{definedProperties:m}=e.it;for(let h of r)if(p?.[h]===void 0&&!m.has(h)){let g=i.schemaEnv.baseId+i.errSchemaPath,y=`required property "${h}" is not defined at "${g}" (strictRequired)`;(0,q$.checkStrictMode)(i,y,i.opts.strictRequired)}}function u(){if(c||s)e.block$data(mo.nil,d);else for(let p of r)(0,po.checkReportMissingProp)(e,p)}function l(){let p=t.let("missing");if(c||s){let m=t.let("valid",!0);e.block$data(m,()=>f(p,m)),e.ok(m)}else t.if((0,po.checkMissingProp)(e,r,p)),(0,po.reportMissingProp)(e,p),t.else()}function d(){t.forOf("prop",n,p=>{e.setParams({missingProperty:p}),t.if((0,po.noPropertyInData)(t,o,p,a.ownProperties),()=>e.error())})}function f(p,m){e.setParams({missingProperty:p}),t.forOf(p,n,()=>{t.assign(m,(0,po.propertyInData)(t,o,p,a.ownProperties)),t.if((0,mo.not)(m),()=>{e.error(),t.break()})},mo.nil)}}};Nu.default=H$});var ry=w(Lu=>{"use strict";Object.defineProperty(Lu,"__esModule",{value:!0});var ho=M(),W$={message({keyword:e,schemaCode:t}){let r=e==="maxItems"?"more":"fewer";return(0,ho.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,ho._)`{limit: ${e}}`},V$={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:!0,error:W$,code(e){let{keyword:t,data:r,schemaCode:n}=e,o=t==="maxItems"?ho.operators.GT:ho.operators.LT;e.fail$data((0,ho._)`${r}.length ${o} ${n}`)}};Lu.default=V$});var ui=w(ju=>{"use strict";Object.defineProperty(ju,"__esModule",{value:!0});var ny=nu();ny.code='require("ajv/dist/runtime/equal").default';ju.default=ny});var oy=w(Fu=>{"use strict";Object.defineProperty(Fu,"__esModule",{value:!0});var Uu=Qn(),Se=M(),K$=q(),B$=ui(),G$={message:({params:{i:e,j:t}})=>(0,Se.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,Se._)`{i: ${e}, j: ${t}}`},Y$={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:!0,error:G$,code(e){let{gen:t,data:r,$data:n,schema:o,parentSchema:s,schemaCode:i,it:a}=e;if(!n&&!o)return;let c=t.let("valid"),u=s.items?(0,Uu.getSchemaTypes)(s.items):[];e.block$data(c,l,(0,Se._)`${i} === false`),e.ok(c);function l(){let m=t.let("i",(0,Se._)`${r}.length`),h=t.let("j");e.setParams({i:m,j:h}),t.assign(c,!0),t.if((0,Se._)`${m} > 1`,()=>(d()?f:p)(m,h))}function d(){return u.length>0&&!u.some(m=>m==="object"||m==="array")}function f(m,h){let g=t.name("item"),y=(0,Uu.checkDataTypes)(u,g,a.opts.strictNumbers,Uu.DataType.Wrong),E=t.const("indices",(0,Se._)`{}`);t.for((0,Se._)`;${m}--;`,()=>{t.let(g,(0,Se._)`${r}[${m}]`),t.if(y,(0,Se._)`continue`),u.length>1&&t.if((0,Se._)`typeof ${g} == "string"`,(0,Se._)`${g} += "_"`),t.if((0,Se._)`typeof ${E}[${g}] == "number"`,()=>{t.assign(h,(0,Se._)`${E}[${g}]`),e.error(),t.assign(c,!1).break()}).code((0,Se._)`${E}[${g}] = ${m}`)})}function p(m,h){let g=(0,K$.useFunc)(t,B$.default),y=t.name("outer");t.label(y).for((0,Se._)`;${m}--;`,()=>t.for((0,Se._)`${h} = ${m}; ${h}--;`,()=>t.if((0,Se._)`${g}(${r}[${m}], ${r}[${h}])`,()=>{e.error(),t.assign(c,!1).break(y)})))}}};Fu.default=Y$});var sy=w(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});var qu=M(),J$=q(),X$=ui(),Q$={message:"must be equal to constant",params:({schemaCode:e})=>(0,qu._)`{allowedValue: ${e}}`},eT={keyword:"const",$data:!0,error:Q$,code(e){let{gen:t,data:r,$data:n,schemaCode:o,schema:s}=e;n||s&&typeof s=="object"?e.fail$data((0,qu._)`!${(0,J$.useFunc)(t,X$.default)}(${r}, ${o})`):e.fail((0,qu._)`${s} !== ${r}`)}};Zu.default=eT});var iy=w(Hu=>{"use strict";Object.defineProperty(Hu,"__esModule",{value:!0});var go=M(),tT=q(),rT=ui(),nT={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,go._)`{allowedValues: ${e}}`},oT={keyword:"enum",schemaType:"array",$data:!0,error:nT,code(e){let{gen:t,data:r,$data:n,schema:o,schemaCode:s,it:i}=e;if(!n&&o.length===0)throw new Error("enum must have non-empty array");let a=o.length>=i.opts.loopEnum,c,u=()=>c??(c=(0,tT.useFunc)(t,rT.default)),l;if(a||n)l=t.let("valid"),e.block$data(l,d);else{if(!Array.isArray(o))throw new Error("ajv implementation error");let p=t.const("vSchema",s);l=(0,go.or)(...o.map((m,h)=>f(p,h)))}e.pass(l);function d(){t.assign(l,!1),t.forOf("v",s,p=>t.if((0,go._)`${u()}(${r}, ${p})`,()=>t.assign(l,!0).break()))}function f(p,m){let h=o[m];return typeof h=="object"&&h!==null?(0,go._)`${u()}(${r}, ${p}[${m}])`:(0,go._)`${r} === ${h}`}}};Hu.default=oT});var ay=w(Wu=>{"use strict";Object.defineProperty(Wu,"__esModule",{value:!0});var sT=B_(),iT=G_(),aT=X_(),cT=Q_(),uT=ey(),lT=ty(),dT=ry(),fT=oy(),pT=sy(),mT=iy(),hT=[sT.default,iT.default,aT.default,cT.default,uT.default,lT.default,dT.default,fT.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},pT.default,mT.default];Wu.default=hT});var Ku=w(_o=>{"use strict";Object.defineProperty(_o,"__esModule",{value:!0});_o.validateAdditionalItems=void 0;var br=M(),Vu=q(),gT={message:({params:{len:e}})=>(0,br.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,br._)`{limit: ${e}}`},_T={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:gT,code(e){let{parentSchema:t,it:r}=e,{items:n}=t;if(!Array.isArray(n)){(0,Vu.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}cy(e,n)}};function cy(e,t){let{gen:r,schema:n,data:o,keyword:s,it:i}=e;i.items=!0;let a=r.const("len",(0,br._)`${o}.length`);if(n===!1)e.setParams({len:t.length}),e.pass((0,br._)`${a} <= ${t.length}`);else if(typeof n=="object"&&!(0,Vu.alwaysValidSchema)(i,n)){let u=r.var("valid",(0,br._)`${a} <= ${t.length}`);r.if((0,br.not)(u),()=>c(u)),e.ok(u)}function c(u){r.forRange("i",t.length,a,l=>{e.subschema({keyword:s,dataProp:l,dataPropType:Vu.Type.Num},u),i.allErrors||r.if((0,br.not)(u),()=>r.break())})}}_o.validateAdditionalItems=cy;_o.default=_T});var Bu=w(yo=>{"use strict";Object.defineProperty(yo,"__esModule",{value:!0});yo.validateTuple=void 0;var uy=M(),li=q(),yT=et(),ST={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return ly(e,"additionalItems",t);r.items=!0,!(0,li.alwaysValidSchema)(r,t)&&e.ok((0,yT.validateArray)(e))}};function ly(e,t,r=e.schema){let{gen:n,parentSchema:o,data:s,keyword:i,it:a}=e;l(o),a.opts.unevaluated&&r.length&&a.items!==!0&&(a.items=li.mergeEvaluated.items(n,r.length,a.items));let c=n.name("valid"),u=n.const("len",(0,uy._)`${s}.length`);r.forEach((d,f)=>{(0,li.alwaysValidSchema)(a,d)||(n.if((0,uy._)`${u} > ${f}`,()=>e.subschema({keyword:i,schemaProp:f,dataProp:f},c)),e.ok(c))});function l(d){let{opts:f,errSchemaPath:p}=a,m=r.length,h=m===d.minItems&&(m===d.maxItems||d[t]===!1);if(f.strictTuples&&!h){let g=`"${i}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${p}"`;(0,li.checkStrictMode)(a,g,f.strictTuples)}}}yo.validateTuple=ly;yo.default=ST});var dy=w(Gu=>{"use strict";Object.defineProperty(Gu,"__esModule",{value:!0});var bT=Bu(),ET={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,bT.validateTuple)(e,"items")};Gu.default=ET});var py=w(Yu=>{"use strict";Object.defineProperty(Yu,"__esModule",{value:!0});var fy=M(),vT=q(),wT=et(),kT=Ku(),xT={message:({params:{len:e}})=>(0,fy.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,fy._)`{limit: ${e}}`},PT={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:xT,code(e){let{schema:t,parentSchema:r,it:n}=e,{prefixItems:o}=r;n.items=!0,!(0,vT.alwaysValidSchema)(n,t)&&(o?(0,kT.validateAdditionalItems)(e,o):e.ok((0,wT.validateArray)(e)))}};Yu.default=PT});var my=w(Ju=>{"use strict";Object.defineProperty(Ju,"__esModule",{value:!0});var rt=M(),di=q(),$T={message:({params:{min:e,max:t}})=>t===void 0?(0,rt.str)`must contain at least ${e} valid item(s)`:(0,rt.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,rt._)`{minContains: ${e}}`:(0,rt._)`{minContains: ${e}, maxContains: ${t}}`},TT={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:!0,error:$T,code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e,i,a,{minContains:c,maxContains:u}=n;s.opts.next?(i=c===void 0?1:c,a=u):i=1;let l=t.const("len",(0,rt._)`${o}.length`);if(e.setParams({min:i,max:a}),a===void 0&&i===0){(0,di.checkStrictMode)(s,'"minContains" == 0 without "maxContains": "contains" keyword ignored');return}if(a!==void 0&&i>a){(0,di.checkStrictMode)(s,'"minContains" > "maxContains" is always invalid'),e.fail();return}if((0,di.alwaysValidSchema)(s,r)){let h=(0,rt._)`${l} >= ${i}`;a!==void 0&&(h=(0,rt._)`${h} && ${l} <= ${a}`),e.pass(h);return}s.items=!0;let d=t.name("valid");a===void 0&&i===1?p(d,()=>t.if(d,()=>t.break())):i===0?(t.let(d,!0),a!==void 0&&t.if((0,rt._)`${o}.length > 0`,f)):(t.let(d,!1),f()),e.result(d,()=>e.reset());function f(){let h=t.name("_valid"),g=t.let("count",0);p(h,()=>t.if(h,()=>m(g)))}function p(h,g){t.forRange("i",0,l,y=>{e.subschema({keyword:"contains",dataProp:y,dataPropType:di.Type.Num,compositeRule:!0},h),g()})}function m(h){t.code((0,rt._)`${h}++`),a===void 0?t.if((0,rt._)`${h} >= ${i}`,()=>t.assign(d,!0).break()):(t.if((0,rt._)`${h} > ${a}`,()=>t.assign(d,!1).break()),i===1?t.assign(d,!0):t.if((0,rt._)`${h} >= ${i}`,()=>t.assign(d,!0)))}}};Ju.default=TT});var _y=w(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Et.validateSchemaDeps=Et.validatePropertyDeps=Et.error=void 0;var Xu=M(),RT=q(),So=et();Et.error={message:({params:{property:e,depsCount:t,deps:r}})=>{let n=t===1?"property":"properties";return(0,Xu.str)`must have ${n} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:n}})=>(0,Xu._)`{property: ${e},
20
20
  missingProperty: ${n},
21
21
  depsCount: ${t},
22
- deps: ${r}}`};var OT={keyword:"dependencies",type:"object",schemaType:"object",error:Et.error,code(e){let[t,r]=IT(e);my(e,t),hy(e,r)}};function IT({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function my(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,So.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,So.checkReportMissingProp)(e,u)}):(r.if((0,Xu._)`${c} && (${(0,So.checkMissingProp)(e,a,s)})`),(0,So.reportMissingProp)(e,s),r.else())}}Et.validatePropertyDeps=my;function hy(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,RT.alwaysValidSchema)(s,t[a])||(r.if((0,So.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}Et.validateSchemaDeps=hy;Et.default=OT});var yy=w(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});var _y=M(),AT=q(),CT={message:"property name must be valid",params:({params:e})=>(0,_y._)`{propertyName: ${e.propertyName}}`},MT={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:CT,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,AT.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,_y.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Qu.default=MT});var tl=w(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});var fi=et(),pt=M(),zT=Ct(),pi=q(),DT={message:"must NOT have additional properties",params:({params:e})=>(0,pt._)`{additionalProperty: ${e.additionalProperty}}`},NT={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:DT,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,pi.alwaysValidSchema)(i,r))return;let u=(0,fi.allSchemaProperties)(n.properties),l=(0,fi.allSchemaProperties)(n.patternProperties);d(),e.ok((0,pt._)`${s} === ${zT.default.errors}`);function d(){t.forIn("key",o,g=>{!u.length&&!l.length?m(g):t.if(f(g),()=>m(g))})}function f(g){let y;if(u.length>8){let E=(0,pi.schemaRefOrVal)(i,n.properties,"properties");y=(0,fi.isOwnProperty)(t,E,g)}else u.length?y=(0,pt.or)(...u.map(E=>(0,pt._)`${g} === ${E}`)):y=pt.nil;return l.length&&(y=(0,pt.or)(y,...l.map(E=>(0,pt._)`${(0,fi.usePattern)(e,E)}.test(${g})`))),(0,pt.not)(y)}function p(g){t.code((0,pt._)`delete ${o}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,pi.alwaysValidSchema)(i,r)){let y=t.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),t.if((0,pt.not)(y),()=>{e.reset(),p(g)})):(h(g,y),a||t.if((0,pt.not)(y),()=>t.break()))}}function h(g,y,E){let v={keyword:"additionalProperties",dataProp:g,dataPropType:pi.Type.Str};E===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(v,y)}}};el.default=NT});var Ey=w(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});var LT=no(),Sy=et(),rl=q(),by=tl(),jT={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&by.default.code(new LT.KeywordCxt(s,by.default,"additionalProperties"));let i=(0,Sy.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=rl.mergeEvaluated.props(t,(0,rl.toHash)(i),s.props));let a=i.filter(d=>!(0,rl.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,Sy.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};nl.default=jT});var xy=w(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});var vy=et(),mi=M(),wy=q(),ky=q(),UT={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,vy.allSchemaProperties)(r),c=a.filter(h=>(0,wy.alwaysValidSchema)(s,r[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof mi.Name)&&(s.props=(0,ky.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let h of a)u&&p(h),s.allErrors?m(h):(t.var(l,!0),m(h),t.if(l))}function p(h){for(let g in u)new RegExp(h).test(g)&&(0,wy.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){t.forIn("key",n,g=>{t.if((0,mi._)`${(0,vy.usePattern)(e,h)}.test(${g})`,()=>{let y=c.includes(h);y||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:ky.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,mi._)`${d}[${g}]`,!0):!y&&!s.allErrors&&t.if((0,mi.not)(l),()=>t.break())})})}}};ol.default=UT});var Py=w(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});var FT=q(),qT={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,FT.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};sl.default=qT});var $y=w(il=>{"use strict";Object.defineProperty(il,"__esModule",{value:!0});var ZT=et(),HT={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ZT.validateUnion,error:{message:"must match a schema in anyOf"}};il.default=HT});var Ty=w(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});var hi=M(),WT=q(),VT={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,hi._)`{passingSchemas: ${e.passing}}`},KT={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:VT,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let f;(0,WT.alwaysValidSchema)(o,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,hi._)`${c} && ${i}`).assign(i,!1).assign(a,(0,hi._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,hi.Name)})})}}};al.default=KT});var Ry=w(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});var BT=q(),GT={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,BT.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};cl.default=GT});var Ay=w(ul=>{"use strict";Object.defineProperty(ul,"__esModule",{value:!0});var gi=M(),Iy=q(),YT={message:({params:e})=>(0,gi.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,gi._)`{failingKeyword: ${e.ifClause}}`},JT={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:YT,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Iy.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Oy(n,"then"),s=Oy(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,gi.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let f=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,gi._)`${l}`):e.setParams({ifClause:l})}}}};function Oy(e,t){let r=e.schema[t];return r!==void 0&&!(0,Iy.alwaysValidSchema)(e,r)}ul.default=JT});var Cy=w(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});var XT=q(),QT={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,XT.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};ll.default=QT});var My=w(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});var eR=Ku(),tR=ly(),rR=Bu(),nR=fy(),oR=py(),sR=gy(),iR=yy(),aR=tl(),cR=Ey(),uR=xy(),lR=Py(),dR=$y(),fR=Ty(),pR=Ry(),mR=Ay(),hR=Cy();function gR(e=!1){let t=[lR.default,dR.default,fR.default,pR.default,mR.default,hR.default,iR.default,aR.default,sR.default,cR.default,uR.default];return e?t.push(tR.default,nR.default):t.push(eR.default,rR.default),t.push(oR.default),t}dl.default=gR});var zy=w(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});var le=M(),_R={message:({schemaCode:e})=>(0,le.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,le._)`{format: ${e}}`},yR={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:_R,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,le._)`${m}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,le._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,le._)`${h}.type || "string"`).assign(y,(0,le._)`${h}.validate`),()=>r.assign(g,(0,le._)`"string"`).assign(y,h)),e.fail$data((0,le.or)(E(),v()));function E(){return c.strictSchema===!1?le.nil:(0,le._)`${i} && !${y}`}function v(){let I=l.$async?(0,le._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,le._)`${y}(${n})`,x=(0,le._)`(typeof ${y} == "function" ? ${I} : ${y}.test(${n}))`;return(0,le._)`${y} && ${y} !== true && ${g} === ${t} && !${x}`}}function p(){let m=d.formats[s];if(!m){E();return}if(m===!0)return;let[h,g,y]=v(m);h===t&&e.pass(I());function E(){if(c.strictSchema===!1){d.logger.warn(x());return}throw new Error(x());function x(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function v(x){let z=x instanceof RegExp?(0,le.regexpCode)(x):c.code.formats?(0,le._)`${c.code.formats}${(0,le.getProperty)(s)}`:void 0,j=r.scopeValue("formats",{key:s,ref:x,code:z});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,le._)`${j}.validate`]:["string",x,j]}function I(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,le._)`await ${y}(${n})`}return typeof g=="function"?(0,le._)`${y}(${n})`:(0,le._)`${y}.test(${n})`}}}};fl.default=yR});var Dy=w(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});var SR=zy(),bR=[SR.default];pl.default=bR});var Ny=w(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.contentVocabulary=Xr.metadataVocabulary=void 0;Xr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Xr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var jy=w(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});var ER=V_(),vR=iy(),wR=My(),kR=Dy(),Ly=Ny(),xR=[ER.default,vR.default,(0,wR.default)(),kR.default,Ly.metadataVocabulary,Ly.contentVocabulary];ml.default=xR});var Fy=w(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.DiscrError=void 0;var Uy;(function(e){e.Tag="tag",e.Mapping="mapping"})(Uy||(_i.DiscrError=Uy={}))});var Zy=w(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});var Qr=M(),hl=Fy(),qy=Xs(),PR=oo(),$R=q(),TR={message:({params:{discrError:e,tagName:t}})=>e===hl.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Qr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},RR={keyword:"discriminator",type:"object",schemaType:"object",error:TR,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,Qr._)`${r}${(0,Qr.getProperty)(a)}`);t.if((0,Qr._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:hl.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let p=f();t.if(!1);for(let m in p)t.elseIf((0,Qr._)`${u} === ${m}`),t.assign(c,d(p[m]));t.else(),e.error(!1,{discrError:hl.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(p){let m=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:p},m);return e.mergeEvaluated(h,Qr.Name),m}function f(){var p;let m={},h=y(o),g=!0;for(let I=0;I<i.length;I++){let x=i[I];if(x?.$ref&&!(0,$R.schemaHasRulesButRef)(x,s.self.RULES)){let j=x.$ref;if(x=qy.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,j),x instanceof qy.SchemaEnv&&(x=x.schema),x===void 0)throw new PR.default(s.opts.uriResolver,s.baseId,j)}let z=(p=x?.properties)===null||p===void 0?void 0:p[a];if(typeof z!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(x)),E(z,I)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:I}){return Array.isArray(I)&&I.includes(a)}function E(I,x){if(I.const)v(I.const,x);else if(I.enum)for(let z of I.enum)v(z,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(I,x){if(typeof I!="string"||I in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[I]=x}}}};gl.default=RR});var Hy=w((l1,OR)=>{OR.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 yl=w((re,_l)=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.MissingRefError=re.ValidationError=re.CodeGen=re.Name=re.nil=re.stringify=re.str=re._=re.KeywordCxt=re.Ajv=void 0;var IR=U_(),AR=jy(),CR=Zy(),Wy=Hy(),MR=["/properties"],yi="http://json-schema.org/draft-07/schema",en=class extends IR.default{_addVocabularies(){super._addVocabularies(),AR.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(CR.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Wy,MR):Wy;this.addMetaSchema(t,yi,!1),this.refs["http://json-schema.org/schema"]=yi}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(yi)?yi:void 0)}};re.Ajv=en;_l.exports=re=en;_l.exports.Ajv=en;Object.defineProperty(re,"__esModule",{value:!0});re.default=en;var zR=no();Object.defineProperty(re,"KeywordCxt",{enumerable:!0,get:function(){return zR.KeywordCxt}});var tn=M();Object.defineProperty(re,"_",{enumerable:!0,get:function(){return tn._}});Object.defineProperty(re,"str",{enumerable:!0,get:function(){return tn.str}});Object.defineProperty(re,"stringify",{enumerable:!0,get:function(){return tn.stringify}});Object.defineProperty(re,"nil",{enumerable:!0,get:function(){return tn.nil}});Object.defineProperty(re,"Name",{enumerable:!0,get:function(){return tn.Name}});Object.defineProperty(re,"CodeGen",{enumerable:!0,get:function(){return tn.CodeGen}});var DR=Ys();Object.defineProperty(re,"ValidationError",{enumerable:!0,get:function(){return DR.default}});var NR=oo();Object.defineProperty(re,"MissingRefError",{enumerable:!0,get:function(){return NR.default}})});var Qy=w(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.formatNames=wt.fastFormats=wt.fullFormats=void 0;function vt(e,t){return{validate:e,compare:t}}wt.fullFormats={date:vt(Gy,vl),time:vt(bl(!0),wl),"date-time":vt(Vy(!0),Jy),"iso-time":vt(bl(),Yy),"iso-date-time":vt(Vy(),Xy),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:ZR,"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:YR,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:HR,int32:{type:"number",validate:KR},int64:{type:"number",validate:BR},float:{type:"number",validate:By},double:{type:"number",validate:By},password:!0,binary:!0};wt.fastFormats={...wt.fullFormats,date:vt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,vl),time:vt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,wl),"date-time":vt(/^\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,Jy),"iso-time":vt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Yy),"iso-date-time":vt(/^\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,Xy),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};wt.formatNames=Object.keys(wt.fullFormats);function LR(e){return e%4===0&&(e%100!==0||e%400===0)}var jR=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,UR=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Gy(e){let t=jR.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&LR(r)?29:UR[n])}function vl(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Sl=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function bl(e){return function(r){let n=Sl.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,f=o-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function wl(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function Yy(e,t){if(!(e&&t))return;let r=Sl.exec(e),n=Sl.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var El=/t|\s/i;function Vy(e){let t=bl(e);return function(n){let o=n.split(El);return o.length===2&&Gy(o[0])&&t(o[1])}}function Jy(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function Xy(e,t){if(!(e&&t))return;let[r,n]=e.split(El),[o,s]=t.split(El),i=vl(r,o);if(i!==void 0)return i||wl(n,s)}var FR=/\/|:/,qR=/^(?:[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 ZR(e){return FR.test(e)&&qR.test(e)}var Ky=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function HR(e){return Ky.lastIndex=0,Ky.test(e)}var WR=-(2**31),VR=2**31-1;function KR(e){return Number.isInteger(e)&&e<=VR&&e>=WR}function BR(e){return Number.isInteger(e)}function By(){return!0}var GR=/[^\\]\\Z/;function YR(e){if(GR.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var eS=w(rn=>{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});rn.formatLimitDefinition=void 0;var JR=yl(),mt=M(),er=mt.operators,Si={formatMaximum:{okStr:"<=",ok:er.LTE,fail:er.GT},formatMinimum:{okStr:">=",ok:er.GTE,fail:er.LT},formatExclusiveMaximum:{okStr:"<",ok:er.LT,fail:er.GTE},formatExclusiveMinimum:{okStr:">",ok:er.GT,fail:er.LTE}},XR={message:({keyword:e,schemaCode:t})=>(0,mt.str)`should be ${Si[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,mt._)`{comparison: ${Si[e].okStr}, limit: ${t}}`};rn.formatLimitDefinition={keyword:Object.keys(Si),type:"string",schemaType:"string",$data:!0,error:XR,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new JR.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=t.const("fmt",(0,mt._)`${f}[${c.schemaCode}]`);e.fail$data((0,mt.or)((0,mt._)`typeof ${p} != "object"`,(0,mt._)`${p} instanceof RegExp`,(0,mt._)`typeof ${p}.compare != "function"`,d(p)))}function l(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${o}": format "${f}" does not define "compare" function`);let m=t.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,mt._)`${i.code.formats}${(0,mt.getProperty)(f)}`:void 0});e.fail$data(d(m))}function d(f){return(0,mt._)`${f}.compare(${r}, ${n}) ${Si[o].fail} 0`}},dependencies:["format"]};var QR=e=>(e.addKeyword(rn.formatLimitDefinition),e);rn.default=QR});var oS=w((bo,nS)=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});var nn=Qy(),eO=eS(),kl=M(),tS=new kl.Name("fullFormats"),tO=new kl.Name("fastFormats"),xl=(e,t={keywords:!0})=>{if(Array.isArray(t))return rS(e,t,nn.fullFormats,tS),e;let[r,n]=t.mode==="fast"?[nn.fastFormats,tO]:[nn.fullFormats,tS],o=t.formats||nn.formatNames;return rS(e,o,r,n),t.keywords&&(0,eO.default)(e),e};xl.get=(e,t="full")=>{let n=(t==="fast"?nn.fastFormats:nn.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function rS(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,kl._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}nS.exports=bo=xl;Object.defineProperty(bo,"__esModule",{value:!0});bo.default=xl});ne();var R={};dd(R,{BIGINT_FORMAT_RANGES:()=>Uo,CONSTANT_CATCH:()=>Rd,Class:()=>aa,NUMBER_FORMAT_RANGES:()=>mn,aborted:()=>at,allowsEval:()=>fa,assert:()=>Bb,assertEqual:()=>Zb,assertIs:()=>Vb,assertNever:()=>Kb,assertNotEqual:()=>Hb,assignProp:()=>He,attachSchema:()=>qo,base64ToUint8Array:()=>$d,base64urlToUint8Array:()=>pE,cached:()=>Or,captureStackTrace:()=>Lo,cleanEnum:()=>fE,cleanRegex:()=>pn,clone:()=>it,cloneDef:()=>Jb,codePointLength:()=>hn,constantCatch:()=>Od,createTransparentProxy:()=>nE,defineLazy:()=>bd,defineLazyInternal:()=>H,derived:()=>_E,esc:()=>la,escapeRegex:()=>$t,explicitlyAborted:()=>ha,extend:()=>iE,finalizeIssue:()=>ct,floatSafeRemainder:()=>ua,getElementAtPath:()=>Xb,getEnumValues:()=>Tr,getLengthableOrigin:()=>gn,getParsedType:()=>rE,getSizableOrigin:()=>Pd,hexToUint8Array:()=>hE,hide:()=>ya,installLazyProp:()=>bE,isObject:()=>ar,isPlainObject:()=>qt,issue:()=>Ar,joinValues:()=>No,jsonStringifyReplacer:()=>Rr,members:()=>_a,merge:()=>cE,mergeDefs:()=>Pt,normalizeParams:()=>T,nullish:()=>ca,numKeys:()=>tE,objectClone:()=>Gb,omit:()=>sE,optionalKeys:()=>ma,own:()=>Ft,parsedType:()=>ga,partial:()=>uE,pick:()=>oE,prefixIssues:()=>Tt,primitiveTypes:()=>kd,promiseAllObject:()=>Qb,propertyKeyTypes:()=>pa,randomString:()=>eE,rawShape:()=>Ir,required:()=>lE,safeExtend:()=>aE,shallowClone:()=>wd,slugify:()=>da,stringifyPrimitive:()=>jo,toZod:()=>Wb,uint8ArrayToBase64:()=>Td,uint8ArrayToBase64url:()=>mE,uint8ArrayToHex:()=>gE,unwrapMessage:()=>$r});function Zb(e){return e}function Hb(e){return e}function Wb(){return e=>e}function Vb(e){}function Kb(e){throw new Error("Unexpected value in exhaustive check")}function Bb(e){}function Tr(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function No(e,t="|"){return e.map(r=>jo(r)).join(t)}function Rr(e,t){return typeof t=="bigint"?t.toString():t}var ia=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Or(e){return new ia(e)}function ca(e){return e==null}function pn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function ua(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var yd=Symbol("evaluating");function bd(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==yd)return n===void 0&&(n=yd,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Gb(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function He(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ir(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function xt(e){return Ir(e._zod.def)??e._zod.def.shape}function Ed(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return He(this,t,n),n},enumerable:!0,configurable:!0})}function vd(e,t,r){t in e?He(e,t,r):e[t]=r}function ir(e,t,r,n){let o=xt(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?Ed(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):vd(e,s,n?n(i.value,s):i.value))}}function Yb(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?Ed(e,r,()=>t[r]):vd(e,r,n.value))}}function Pt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Jb(e){return Pt(e._zod.def)}function Xb(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Qb(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function eE(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function la(e){return JSON.stringify(e)}function da(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Lo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ar(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var fa=Or(()=>{if(ze.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function qt(e){if(ar(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(ar(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function wd(e){return qt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function tE(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var rE=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},pa=new Set(["string","number","symbol"]),kd=new Set(["string","number","bigint","boolean","symbol","undefined"]);function $t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function it(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function T(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function nE(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function jo(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ma(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var mn={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]},Uo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function oE(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return ir(s,e,Fo(e,t)),it(e,Pt(r,{shape:s,checks:[]}))}function Fo(e,t){let r=xt(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function sE(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Fo(e,t)),i={};return ir(i,e,Reflect.ownKeys(xt(e)).filter(a=>!s.has(a))),it(e,Pt(r,{shape:i,checks:[]}))}function iE(e,t){if(!qt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=xt(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return it(e,Pt(e._zod.def,{shape:xd(e,t)}))}function xd(e,t){let r={};return ir(r,e,Reflect.ownKeys(xt(e))),Yb(r,t),r}function aE(e,t){if(!qt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return it(e,Pt(e._zod.def,{shape:xd(e,t)}))}function cE(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};ir(r,e,Reflect.ownKeys(xt(e))),ir(r,t,Reflect.ownKeys(xt(t)));let n=Pt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return it(e,n)}function uE(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(Fo(t,r)):void 0,c={};return ir(c,t,Reflect.ownKeys(xt(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),it(t,Pt(t._zod.def,{shape:c,checks:[]}))}function lE(e,t,r){let n=r?new Set(Fo(t,r)):void 0,o={};return ir(o,t,Reflect.ownKeys(xt(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),it(t,Pt(t._zod.def,{shape:o}))}function at(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function ha(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Tt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function $r(e){return typeof e=="string"?e:e?.message}function qo(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function ct(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:$r(e.inst?._zod.def?.error?.(e))??$r(s?.(e))??$r(t?.error?.(e))??$r(r.customError?.(e))??$r(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function Pd(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var dE=/[\uD800-\uDBFF]/;function hn(e){let t=e.length;if(!dE.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function gn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ga(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Ar(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function fE(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function $d(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Td(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function pE(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return $d(t+r)}function mE(e){return Td(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function hE(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function gE(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var aa=class{constructor(...t){}};function _a(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):Sd(e,r,n.value)}for(let r of Object.getOwnPropertySymbols(t))Sd(e,r,t[r])}function Ft(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function ya(e,t,r){return Ft(e,t,r,!1)}function _E(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Ft(this,r,n(this))},set(o){Ft(this,r,o)}})}return t}function Sd(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Ft(this,t,r.bind(this))},set(n){Ft(this,t,n)}})}function yE(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var sa,Ut=!1,SE={configurable:!0,get(){Ut=!0}};function H(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&sa!==e._zod){sa=void 0;return}sa=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,SE);let o=Ut;Ut=!1;try{let s=r(this);return Ut?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Ut=Ut||o,s}catch(s){throw delete this[t],Ut=Ut||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function bE(e,t,r,n){let o=yE(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var Rd="~constantCatch";function Od(e){let t=()=>e;return t[Rd]=!0,t}var Id;var Sa={value:void 0,enumerable:!1},Ad="captureStackTrace"in Error?Error:null;function EE(e){let t=Ad;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Ad=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function b(e,t,r,n){let o={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(f,p){if(!f._zod){Sa.value=new s(p);try{Object.defineProperty(f,"_zod",Sa)}finally{Sa.value=void 0}}if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,p),a){let h=Object.getPrototypeOf(f),g=f._zod.constr.prototype,y=h;for(;y&&y!==g;)y=Object.getPrototypeOf(y);let E=y??h;a.has(E)||(a.add(E),_a(E,i))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in f||(f[h]=m[h].bind(f)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let p=n?.Parent?EE(l):this;c(p,f);let m=p._zod.deferred;if(m){for(let g of m)g();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var ut=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Cr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Id=globalThis).__zod_globalConfig??(Id.__zod_globalConfig={});var ze=globalThis.__zod_globalConfig;function We(e){return e&&Object.assign(ze,e),ze}function vE(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Rr,2)),e.message}function wE(e){this._zod.message=e}var kE={get:vE,set:wE,enumerable:!0,configurable:!0},Ea={value:void 0,enumerable:!1},Cd=new WeakSet([Object.prototype,Error.prototype]),Md=(e,t)=>{e.name="$ZodError",Ea.value=t,Object.defineProperty(e,"issues",Ea),Ea.value=void 0,Object.defineProperty(e,"message",kE);let r=Object.getPrototypeOf(e);Cd.has(r)||(Cd.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},zd=b("$ZodError",Md),Dd=b("$ZodError",Md,void 0,{Parent:Error});function xE(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Nd(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?xE(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function Ld(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[l];d&&f._errors.push(t(i)),c=f,u++}}}};return n(e),r}function Zo(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ho=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ut;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ct(u,i,We())));throw Lo(c,s?.callee??t),c}return a.value};return t};var Wo=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ct(u,i,We())));throw Lo(c,s?.callee??t),c}return a.value};return t};var _n=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ut;return s.issues.length?jd(e,s.issues,o):{success:!0,data:s.value}},va=_n(Dd);function jd(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>ct(o,r,We()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var Vo=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?jd(e,s.issues,o):{success:!0,data:s.value}};var $E=Symbol.for("zod.compile.invalid"),TE=Symbol.for("zod.compile.fallback"),Ko=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==$E)return!0;if(n.definite===!0&&r===void 0)return!1}return RE(e,t,r)});function RE(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[TE]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new ut;return s.issues.length===0}var Bo=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Ud=e=>{let t=Ho(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Zo(r,i))};return r};var Fd=e=>{let t=Ho(e),r=(n,o,s,i)=>t(n,o,s,Zo(r,i));return r};var qd=e=>{let t=Wo(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Zo(r,i))};return r};var Zd=e=>{let t=Wo(e),r=async(n,o,s,i)=>await t(n,o,s,Zo(r,i));return r};var Hd=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return _n(e)(t,r,o)};var Wd=e=>(t,r,n)=>_n(e)(t,r,n);var Vd=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Vo(e)(t,r,o)};var Kd=e=>async(t,r,n)=>Vo(e)(t,r,n);var Bd=/^[cC][0-9a-z]{6,}$/,Gd=/^[0-9a-z]+$/,Yd=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Jd=/^[0-9a-vA-V]{20}$/,Xd=/^[A-Za-z0-9]{27}$/,Qd=/^[a-zA-Z0-9_-]{21}$/;function ef(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var tf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var rf=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ka=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var nf=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var OE="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function of(){return new RegExp(OE,"u")}var sf=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,af=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){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 cf=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,uf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,lf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,df=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var ff=/^https?$/,pf=/^\+[1-9]\d{6,14}$/;var mf="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function IE(e){return new RegExp(`^${e}$`)}var hf=IE(mf);function wa(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function gf(e){return new RegExp(`^${wa(e)}$`)}function _f(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${wa({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${wa({precision:e.precision})}`:r;return new RegExp(`^${mf}T(?:${n})$`)}var yf=/^[\s\S]{0,}$/;var xa=/^-?\d+$/,yn=/^-?\d+(?:\.\d+)?$/,Sf=/^(?:true|false)$/i,bf=/^null$/i;var Ef=/^[^A-Z]*$/,vf=/^[^a-z]*$/;var me=b("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Pa=e=>{let t=e.value;return!ca(t)&&t.length!==void 0},Go={number:"number",bigint:"bigint",object:"date"},$a=b("$ZodCheckLessThan",(e,t)=>{me.init(e,t);let r=Go[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:Go[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ta=b("$ZodCheckGreaterThan",(e,t)=>{me.init(e,t);let r=Go[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:Go[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),wf=b("$ZodCheckMultipleOf",(e,t)=>{me.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):ua(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),kf=b("$ZodCheckNumberFormat",(e,t)=>{me.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=mn[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var xf=b("$ZodCheckMaxLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Pa),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?hn(o):s)<=t.maximum)return;let a=gn(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Pf=b("$ZodCheckMinLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Pa),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?hn(o):s)>=t.minimum)return;let a=gn(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),$f=b("$ZodCheckLengthEquals",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Pa),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?hn(o):s;if(i===t.length)return;let a=gn(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),bn=b("$ZodCheckStringFormat",(e,t)=>{var r,n;me.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Tf=b("$ZodCheckRegex",(e,t)=>{bn.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Rf=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Ef),bn.init(e,t)}),Of=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=vf),bn.init(e,t)}),If=b("$ZodCheckIncludes",(e,t)=>{me.init(e,t);let r=$t(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Af=b("$ZodCheckStartsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`^${$t(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Cf=b("$ZodCheckEndsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`.*${$t(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var Mf=b("$ZodCheckOverwrite",(e,t)=>{me.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Yo=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
22
+ deps: ${r}}`};var OT={keyword:"dependencies",type:"object",schemaType:"object",error:Et.error,code(e){let[t,r]=IT(e);hy(e,t),gy(e,r)}};function IT({schema:e}){let t={},r={};for(let n in e){if(n==="__proto__")continue;let o=Array.isArray(e[n])?t:r;o[n]=e[n]}return[t,r]}function hy(e,t=e.schema){let{gen:r,data:n,it:o}=e;if(Object.keys(t).length===0)return;let s=r.let("missing");for(let i in t){let a=t[i];if(a.length===0)continue;let c=(0,So.propertyInData)(r,n,i,o.opts.ownProperties);e.setParams({property:i,depsCount:a.length,deps:a.join(", ")}),o.allErrors?r.if(c,()=>{for(let u of a)(0,So.checkReportMissingProp)(e,u)}):(r.if((0,Xu._)`${c} && (${(0,So.checkMissingProp)(e,a,s)})`),(0,So.reportMissingProp)(e,s),r.else())}}Et.validatePropertyDeps=hy;function gy(e,t=e.schema){let{gen:r,data:n,keyword:o,it:s}=e,i=r.name("valid");for(let a in t)(0,RT.alwaysValidSchema)(s,t[a])||(r.if((0,So.propertyInData)(r,n,a,s.opts.ownProperties),()=>{let c=e.subschema({keyword:o,schemaProp:a},i);e.mergeValidEvaluated(c,i)},()=>r.var(i,!0)),e.ok(i))}Et.validateSchemaDeps=gy;Et.default=OT});var Sy=w(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});var yy=M(),AT=q(),CT={message:"property name must be valid",params:({params:e})=>(0,yy._)`{propertyName: ${e.propertyName}}`},MT={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:CT,code(e){let{gen:t,schema:r,data:n,it:o}=e;if((0,AT.alwaysValidSchema)(o,r))return;let s=t.name("valid");t.forIn("key",n,i=>{e.setParams({propertyName:i}),e.subschema({keyword:"propertyNames",data:i,dataTypes:["string"],propertyName:i,compositeRule:!0},s),t.if((0,yy.not)(s),()=>{e.error(!0),o.allErrors||t.break()})}),e.ok(s)}};Qu.default=MT});var tl=w(el=>{"use strict";Object.defineProperty(el,"__esModule",{value:!0});var fi=et(),pt=M(),zT=Ct(),pi=q(),DT={message:"must NOT have additional properties",params:({params:e})=>(0,pt._)`{additionalProperty: ${e.additionalProperty}}`},NT={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:!0,trackErrors:!0,error:DT,code(e){let{gen:t,schema:r,parentSchema:n,data:o,errsCount:s,it:i}=e;if(!s)throw new Error("ajv implementation error");let{allErrors:a,opts:c}=i;if(i.props=!0,c.removeAdditional!=="all"&&(0,pi.alwaysValidSchema)(i,r))return;let u=(0,fi.allSchemaProperties)(n.properties),l=(0,fi.allSchemaProperties)(n.patternProperties);d(),e.ok((0,pt._)`${s} === ${zT.default.errors}`);function d(){t.forIn("key",o,g=>{!u.length&&!l.length?m(g):t.if(f(g),()=>m(g))})}function f(g){let y;if(u.length>8){let E=(0,pi.schemaRefOrVal)(i,n.properties,"properties");y=(0,fi.isOwnProperty)(t,E,g)}else u.length?y=(0,pt.or)(...u.map(E=>(0,pt._)`${g} === ${E}`)):y=pt.nil;return l.length&&(y=(0,pt.or)(y,...l.map(E=>(0,pt._)`${(0,fi.usePattern)(e,E)}.test(${g})`))),(0,pt.not)(y)}function p(g){t.code((0,pt._)`delete ${o}[${g}]`)}function m(g){if(c.removeAdditional==="all"||c.removeAdditional&&r===!1){p(g);return}if(r===!1){e.setParams({additionalProperty:g}),e.error(),a||t.break();return}if(typeof r=="object"&&!(0,pi.alwaysValidSchema)(i,r)){let y=t.name("valid");c.removeAdditional==="failing"?(h(g,y,!1),t.if((0,pt.not)(y),()=>{e.reset(),p(g)})):(h(g,y),a||t.if((0,pt.not)(y),()=>t.break()))}}function h(g,y,E){let v={keyword:"additionalProperties",dataProp:g,dataPropType:pi.Type.Str};E===!1&&Object.assign(v,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(v,y)}}};el.default=NT});var vy=w(nl=>{"use strict";Object.defineProperty(nl,"__esModule",{value:!0});var LT=no(),by=et(),rl=q(),Ey=tl(),jT={keyword:"properties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,parentSchema:n,data:o,it:s}=e;s.opts.removeAdditional==="all"&&n.additionalProperties===void 0&&Ey.default.code(new LT.KeywordCxt(s,Ey.default,"additionalProperties"));let i=(0,by.allSchemaProperties)(r);for(let d of i)s.definedProperties.add(d);s.opts.unevaluated&&i.length&&s.props!==!0&&(s.props=rl.mergeEvaluated.props(t,(0,rl.toHash)(i),s.props));let a=i.filter(d=>!(0,rl.alwaysValidSchema)(s,r[d]));if(a.length===0)return;let c=t.name("valid");for(let d of a)u(d)?l(d):(t.if((0,by.propertyInData)(t,o,d,s.opts.ownProperties)),l(d),s.allErrors||t.else().var(c,!0),t.endIf()),e.it.definedProperties.add(d),e.ok(c);function u(d){return s.opts.useDefaults&&!s.compositeRule&&r[d].default!==void 0}function l(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};nl.default=jT});var Py=w(ol=>{"use strict";Object.defineProperty(ol,"__esModule",{value:!0});var wy=et(),mi=M(),ky=q(),xy=q(),UT={keyword:"patternProperties",type:"object",schemaType:"object",code(e){let{gen:t,schema:r,data:n,parentSchema:o,it:s}=e,{opts:i}=s,a=(0,wy.allSchemaProperties)(r),c=a.filter(h=>(0,ky.alwaysValidSchema)(s,r[h]));if(a.length===0||c.length===a.length&&(!s.opts.unevaluated||s.props===!0))return;let u=i.strictSchema&&!i.allowMatchingProperties&&o.properties,l=t.name("valid");s.props!==!0&&!(s.props instanceof mi.Name)&&(s.props=(0,xy.evaluatedPropsToName)(t,s.props));let{props:d}=s;f();function f(){for(let h of a)u&&p(h),s.allErrors?m(h):(t.var(l,!0),m(h),t.if(l))}function p(h){for(let g in u)new RegExp(h).test(g)&&(0,ky.checkStrictMode)(s,`property ${g} matches pattern ${h} (use allowMatchingProperties)`)}function m(h){t.forIn("key",n,g=>{t.if((0,mi._)`${(0,wy.usePattern)(e,h)}.test(${g})`,()=>{let y=c.includes(h);y||e.subschema({keyword:"patternProperties",schemaProp:h,dataProp:g,dataPropType:xy.Type.Str},l),s.opts.unevaluated&&d!==!0?t.assign((0,mi._)`${d}[${g}]`,!0):!y&&!s.allErrors&&t.if((0,mi.not)(l),()=>t.break())})})}}};ol.default=UT});var $y=w(sl=>{"use strict";Object.defineProperty(sl,"__esModule",{value:!0});var FT=q(),qT={keyword:"not",schemaType:["object","boolean"],trackErrors:!0,code(e){let{gen:t,schema:r,it:n}=e;if((0,FT.alwaysValidSchema)(n,r)){e.fail();return}let o=t.name("valid");e.subschema({keyword:"not",compositeRule:!0,createErrors:!1,allErrors:!1},o),e.failResult(o,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};sl.default=qT});var Ty=w(il=>{"use strict";Object.defineProperty(il,"__esModule",{value:!0});var ZT=et(),HT={keyword:"anyOf",schemaType:"array",trackErrors:!0,code:ZT.validateUnion,error:{message:"must match a schema in anyOf"}};il.default=HT});var Ry=w(al=>{"use strict";Object.defineProperty(al,"__esModule",{value:!0});var hi=M(),WT=q(),VT={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,hi._)`{passingSchemas: ${e.passing}}`},KT={keyword:"oneOf",schemaType:"array",trackErrors:!0,error:VT,code(e){let{gen:t,schema:r,parentSchema:n,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(o.opts.discriminator&&n.discriminator)return;let s=r,i=t.let("valid",!1),a=t.let("passing",null),c=t.name("_valid");e.setParams({passing:a}),t.block(u),e.result(i,()=>e.reset(),()=>e.error(!0));function u(){s.forEach((l,d)=>{let f;(0,WT.alwaysValidSchema)(o,l)?t.var(c,!0):f=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:!0},c),d>0&&t.if((0,hi._)`${c} && ${i}`).assign(i,!1).assign(a,(0,hi._)`[${a}, ${d}]`).else(),t.if(c,()=>{t.assign(i,!0),t.assign(a,d),f&&e.mergeEvaluated(f,hi.Name)})})}}};al.default=KT});var Oy=w(cl=>{"use strict";Object.defineProperty(cl,"__esModule",{value:!0});var BT=q(),GT={keyword:"allOf",schemaType:"array",code(e){let{gen:t,schema:r,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");let o=t.name("valid");r.forEach((s,i)=>{if((0,BT.alwaysValidSchema)(n,s))return;let a=e.subschema({keyword:"allOf",schemaProp:i},o);e.ok(o),e.mergeEvaluated(a)})}};cl.default=GT});var Cy=w(ul=>{"use strict";Object.defineProperty(ul,"__esModule",{value:!0});var gi=M(),Ay=q(),YT={message:({params:e})=>(0,gi.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,gi._)`{failingKeyword: ${e.ifClause}}`},JT={keyword:"if",schemaType:["object","boolean"],trackErrors:!0,error:YT,code(e){let{gen:t,parentSchema:r,it:n}=e;r.then===void 0&&r.else===void 0&&(0,Ay.checkStrictMode)(n,'"if" without "then" and "else" is ignored');let o=Iy(n,"then"),s=Iy(n,"else");if(!o&&!s)return;let i=t.let("valid",!0),a=t.name("_valid");if(c(),e.reset(),o&&s){let l=t.let("ifClause");e.setParams({ifClause:l}),t.if(a,u("then",l),u("else",l))}else o?t.if(a,u("then")):t.if((0,gi.not)(a),u("else"));e.pass(i,()=>e.error(!0));function c(){let l=e.subschema({keyword:"if",compositeRule:!0,createErrors:!1,allErrors:!1},a);e.mergeEvaluated(l)}function u(l,d){return()=>{let f=e.subschema({keyword:l},a);t.assign(i,a),e.mergeValidEvaluated(f,i),d?t.assign(d,(0,gi._)`${l}`):e.setParams({ifClause:l})}}}};function Iy(e,t){let r=e.schema[t];return r!==void 0&&!(0,Ay.alwaysValidSchema)(e,r)}ul.default=JT});var My=w(ll=>{"use strict";Object.defineProperty(ll,"__esModule",{value:!0});var XT=q(),QT={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){t.if===void 0&&(0,XT.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};ll.default=QT});var zy=w(dl=>{"use strict";Object.defineProperty(dl,"__esModule",{value:!0});var eR=Ku(),tR=dy(),rR=Bu(),nR=py(),oR=my(),sR=_y(),iR=Sy(),aR=tl(),cR=vy(),uR=Py(),lR=$y(),dR=Ty(),fR=Ry(),pR=Oy(),mR=Cy(),hR=My();function gR(e=!1){let t=[lR.default,dR.default,fR.default,pR.default,mR.default,hR.default,iR.default,aR.default,sR.default,cR.default,uR.default];return e?t.push(tR.default,nR.default):t.push(eR.default,rR.default),t.push(oR.default),t}dl.default=gR});var Dy=w(fl=>{"use strict";Object.defineProperty(fl,"__esModule",{value:!0});var le=M(),_R={message:({schemaCode:e})=>(0,le.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,le._)`{format: ${e}}`},yR={keyword:"format",type:["number","string"],schemaType:"string",$data:!0,error:_R,code(e,t){let{gen:r,data:n,$data:o,schema:s,schemaCode:i,it:a}=e,{opts:c,errSchemaPath:u,schemaEnv:l,self:d}=a;if(!c.validateFormats)return;o?f():p();function f(){let m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats}),h=r.const("fDef",(0,le._)`${m}[${i}]`),g=r.let("fType"),y=r.let("format");r.if((0,le._)`typeof ${h} == "object" && !(${h} instanceof RegExp)`,()=>r.assign(g,(0,le._)`${h}.type || "string"`).assign(y,(0,le._)`${h}.validate`),()=>r.assign(g,(0,le._)`"string"`).assign(y,h)),e.fail$data((0,le.or)(E(),v()));function E(){return c.strictSchema===!1?le.nil:(0,le._)`${i} && !${y}`}function v(){let I=l.$async?(0,le._)`(${h}.async ? await ${y}(${n}) : ${y}(${n}))`:(0,le._)`${y}(${n})`,x=(0,le._)`(typeof ${y} == "function" ? ${I} : ${y}.test(${n}))`;return(0,le._)`${y} && ${y} !== true && ${g} === ${t} && !${x}`}}function p(){let m=d.formats[s];if(!m){E();return}if(m===!0)return;let[h,g,y]=v(m);h===t&&e.pass(I());function E(){if(c.strictSchema===!1){d.logger.warn(x());return}throw new Error(x());function x(){return`unknown format "${s}" ignored in schema at path "${u}"`}}function v(x){let z=x instanceof RegExp?(0,le.regexpCode)(x):c.code.formats?(0,le._)`${c.code.formats}${(0,le.getProperty)(s)}`:void 0,j=r.scopeValue("formats",{key:s,ref:x,code:z});return typeof x=="object"&&!(x instanceof RegExp)?[x.type||"string",x.validate,(0,le._)`${j}.validate`]:["string",x,j]}function I(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!l.$async)throw new Error("async format in sync schema");return(0,le._)`await ${y}(${n})`}return typeof g=="function"?(0,le._)`${y}(${n})`:(0,le._)`${y}.test(${n})`}}}};fl.default=yR});var Ny=w(pl=>{"use strict";Object.defineProperty(pl,"__esModule",{value:!0});var SR=Dy(),bR=[SR.default];pl.default=bR});var Ly=w(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Xr.contentVocabulary=Xr.metadataVocabulary=void 0;Xr.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];Xr.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Uy=w(ml=>{"use strict";Object.defineProperty(ml,"__esModule",{value:!0});var ER=K_(),vR=ay(),wR=zy(),kR=Ny(),jy=Ly(),xR=[ER.default,vR.default,(0,wR.default)(),kR.default,jy.metadataVocabulary,jy.contentVocabulary];ml.default=xR});var qy=w(_i=>{"use strict";Object.defineProperty(_i,"__esModule",{value:!0});_i.DiscrError=void 0;var Fy;(function(e){e.Tag="tag",e.Mapping="mapping"})(Fy||(_i.DiscrError=Fy={}))});var Hy=w(gl=>{"use strict";Object.defineProperty(gl,"__esModule",{value:!0});var Qr=M(),hl=qy(),Zy=Xs(),PR=oo(),$R=q(),TR={message:({params:{discrError:e,tagName:t}})=>e===hl.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Qr._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`},RR={keyword:"discriminator",type:"object",schemaType:"object",error:TR,code(e){let{gen:t,data:r,schema:n,parentSchema:o,it:s}=e,{oneOf:i}=o;if(!s.opts.discriminator)throw new Error("discriminator: requires discriminator option");let a=n.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(n.mapping)throw new Error("discriminator: mapping is not supported");if(!i)throw new Error("discriminator: requires oneOf keyword");let c=t.let("valid",!1),u=t.const("tag",(0,Qr._)`${r}${(0,Qr.getProperty)(a)}`);t.if((0,Qr._)`typeof ${u} == "string"`,()=>l(),()=>e.error(!1,{discrError:hl.DiscrError.Tag,tag:u,tagName:a})),e.ok(c);function l(){let p=f();t.if(!1);for(let m in p)t.elseIf((0,Qr._)`${u} === ${m}`),t.assign(c,d(p[m]));t.else(),e.error(!1,{discrError:hl.DiscrError.Mapping,tag:u,tagName:a}),t.endIf()}function d(p){let m=t.name("valid"),h=e.subschema({keyword:"oneOf",schemaProp:p},m);return e.mergeEvaluated(h,Qr.Name),m}function f(){var p;let m={},h=y(o),g=!0;for(let I=0;I<i.length;I++){let x=i[I];if(x?.$ref&&!(0,$R.schemaHasRulesButRef)(x,s.self.RULES)){let j=x.$ref;if(x=Zy.resolveRef.call(s.self,s.schemaEnv.root,s.baseId,j),x instanceof Zy.SchemaEnv&&(x=x.schema),x===void 0)throw new PR.default(s.opts.uriResolver,s.baseId,j)}let z=(p=x?.properties)===null||p===void 0?void 0:p[a];if(typeof z!="object")throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`);g=g&&(h||y(x)),E(z,I)}if(!g)throw new Error(`discriminator: "${a}" must be required`);return m;function y({required:I}){return Array.isArray(I)&&I.includes(a)}function E(I,x){if(I.const)v(I.const,x);else if(I.enum)for(let z of I.enum)v(z,x);else throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}function v(I,x){if(typeof I!="string"||I in m)throw new Error(`discriminator: "${a}" values must be unique strings`);m[I]=x}}}};gl.default=RR});var Wy=w((l1,OR)=>{OR.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 yl=w((re,_l)=>{"use strict";Object.defineProperty(re,"__esModule",{value:!0});re.MissingRefError=re.ValidationError=re.CodeGen=re.Name=re.nil=re.stringify=re.str=re._=re.KeywordCxt=re.Ajv=void 0;var IR=F_(),AR=Uy(),CR=Hy(),Vy=Wy(),MR=["/properties"],yi="http://json-schema.org/draft-07/schema",en=class extends IR.default{_addVocabularies(){super._addVocabularies(),AR.default.forEach(t=>this.addVocabulary(t)),this.opts.discriminator&&this.addKeyword(CR.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let t=this.opts.$data?this.$dataMetaSchema(Vy,MR):Vy;this.addMetaSchema(t,yi,!1),this.refs["http://json-schema.org/schema"]=yi}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(yi)?yi:void 0)}};re.Ajv=en;_l.exports=re=en;_l.exports.Ajv=en;Object.defineProperty(re,"__esModule",{value:!0});re.default=en;var zR=no();Object.defineProperty(re,"KeywordCxt",{enumerable:!0,get:function(){return zR.KeywordCxt}});var tn=M();Object.defineProperty(re,"_",{enumerable:!0,get:function(){return tn._}});Object.defineProperty(re,"str",{enumerable:!0,get:function(){return tn.str}});Object.defineProperty(re,"stringify",{enumerable:!0,get:function(){return tn.stringify}});Object.defineProperty(re,"nil",{enumerable:!0,get:function(){return tn.nil}});Object.defineProperty(re,"Name",{enumerable:!0,get:function(){return tn.Name}});Object.defineProperty(re,"CodeGen",{enumerable:!0,get:function(){return tn.CodeGen}});var DR=Ys();Object.defineProperty(re,"ValidationError",{enumerable:!0,get:function(){return DR.default}});var NR=oo();Object.defineProperty(re,"MissingRefError",{enumerable:!0,get:function(){return NR.default}})});var eS=w(wt=>{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.formatNames=wt.fastFormats=wt.fullFormats=void 0;function vt(e,t){return{validate:e,compare:t}}wt.fullFormats={date:vt(Yy,vl),time:vt(bl(!0),wl),"date-time":vt(Ky(!0),Xy),"iso-time":vt(bl(),Jy),"iso-date-time":vt(Ky(),Qy),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:ZR,"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:YR,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:HR,int32:{type:"number",validate:KR},int64:{type:"number",validate:BR},float:{type:"number",validate:Gy},double:{type:"number",validate:Gy},password:!0,binary:!0};wt.fastFormats={...wt.fullFormats,date:vt(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,vl),time:vt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,wl),"date-time":vt(/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Xy),"iso-time":vt(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,Jy),"iso-date-time":vt(/^\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,Qy),uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i};wt.formatNames=Object.keys(wt.fullFormats);function LR(e){return e%4===0&&(e%100!==0||e%400===0)}var jR=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,UR=[0,31,28,31,30,31,30,31,31,30,31,30,31];function Yy(e){let t=jR.exec(e);if(!t)return!1;let r=+t[1],n=+t[2],o=+t[3];return n>=1&&n<=12&&o>=1&&o<=(n===2&&LR(r)?29:UR[n])}function vl(e,t){if(e&&t)return e>t?1:e<t?-1:0}var Sl=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function bl(e){return function(r){let n=Sl.exec(r);if(!n)return!1;let o=+n[1],s=+n[2],i=+n[3],a=n[4],c=n[5]==="-"?-1:1,u=+(n[6]||0),l=+(n[7]||0);if(u>23||l>59||e&&!a)return!1;if(o<=23&&s<=59&&i<60)return!0;let d=s-l*c,f=o-u*c-(d<0?1:0);return(f===23||f===-1)&&(d===59||d===-1)&&i<61}}function wl(e,t){if(!(e&&t))return;let r=new Date("2020-01-01T"+e).valueOf(),n=new Date("2020-01-01T"+t).valueOf();if(r&&n)return r-n}function Jy(e,t){if(!(e&&t))return;let r=Sl.exec(e),n=Sl.exec(t);if(r&&n)return e=r[1]+r[2]+r[3],t=n[1]+n[2]+n[3],e>t?1:e<t?-1:0}var El=/t|\s/i;function Ky(e){let t=bl(e);return function(n){let o=n.split(El);return o.length===2&&Yy(o[0])&&t(o[1])}}function Xy(e,t){if(!(e&&t))return;let r=new Date(e).valueOf(),n=new Date(t).valueOf();if(r&&n)return r-n}function Qy(e,t){if(!(e&&t))return;let[r,n]=e.split(El),[o,s]=t.split(El),i=vl(r,o);if(i!==void 0)return i||wl(n,s)}var FR=/\/|:/,qR=/^(?:[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 ZR(e){return FR.test(e)&&qR.test(e)}var By=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function HR(e){return By.lastIndex=0,By.test(e)}var WR=-(2**31),VR=2**31-1;function KR(e){return Number.isInteger(e)&&e<=VR&&e>=WR}function BR(e){return Number.isInteger(e)}function Gy(){return!0}var GR=/[^\\]\\Z/;function YR(e){if(GR.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}});var tS=w(rn=>{"use strict";Object.defineProperty(rn,"__esModule",{value:!0});rn.formatLimitDefinition=void 0;var JR=yl(),mt=M(),er=mt.operators,Si={formatMaximum:{okStr:"<=",ok:er.LTE,fail:er.GT},formatMinimum:{okStr:">=",ok:er.GTE,fail:er.LT},formatExclusiveMaximum:{okStr:"<",ok:er.LT,fail:er.GTE},formatExclusiveMinimum:{okStr:">",ok:er.GT,fail:er.LTE}},XR={message:({keyword:e,schemaCode:t})=>(0,mt.str)`should be ${Si[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,mt._)`{comparison: ${Si[e].okStr}, limit: ${t}}`};rn.formatLimitDefinition={keyword:Object.keys(Si),type:"string",schemaType:"string",$data:!0,error:XR,code(e){let{gen:t,data:r,schemaCode:n,keyword:o,it:s}=e,{opts:i,self:a}=s;if(!i.validateFormats)return;let c=new JR.KeywordCxt(s,a.RULES.all.format.definition,"format");c.$data?u():l();function u(){let f=t.scopeValue("formats",{ref:a.formats,code:i.code.formats}),p=t.const("fmt",(0,mt._)`${f}[${c.schemaCode}]`);e.fail$data((0,mt.or)((0,mt._)`typeof ${p} != "object"`,(0,mt._)`${p} instanceof RegExp`,(0,mt._)`typeof ${p}.compare != "function"`,d(p)))}function l(){let f=c.schema,p=a.formats[f];if(!p||p===!0)return;if(typeof p!="object"||p instanceof RegExp||typeof p.compare!="function")throw new Error(`"${o}": format "${f}" does not define "compare" function`);let m=t.scopeValue("formats",{key:f,ref:p,code:i.code.formats?(0,mt._)`${i.code.formats}${(0,mt.getProperty)(f)}`:void 0});e.fail$data(d(m))}function d(f){return(0,mt._)`${f}.compare(${r}, ${n}) ${Si[o].fail} 0`}},dependencies:["format"]};var QR=e=>(e.addKeyword(rn.formatLimitDefinition),e);rn.default=QR});var sS=w((bo,oS)=>{"use strict";Object.defineProperty(bo,"__esModule",{value:!0});var nn=eS(),eO=tS(),kl=M(),rS=new kl.Name("fullFormats"),tO=new kl.Name("fastFormats"),xl=(e,t={keywords:!0})=>{if(Array.isArray(t))return nS(e,t,nn.fullFormats,rS),e;let[r,n]=t.mode==="fast"?[nn.fastFormats,tO]:[nn.fullFormats,rS],o=t.formats||nn.formatNames;return nS(e,o,r,n),t.keywords&&(0,eO.default)(e),e};xl.get=(e,t="full")=>{let n=(t==="fast"?nn.fastFormats:nn.fullFormats)[e];if(!n)throw new Error(`Unknown format "${e}"`);return n};function nS(e,t,r,n){var o,s;(o=(s=e.opts.code).formats)!==null&&o!==void 0||(s.formats=(0,kl._)`require("ajv-formats/dist/formats").${n}`);for(let i of t)e.addFormat(i,r[i])}oS.exports=bo=xl;Object.defineProperty(bo,"__esModule",{value:!0});bo.default=xl});ne();var R={};dd(R,{BIGINT_FORMAT_RANGES:()=>Uo,CONSTANT_CATCH:()=>Od,Class:()=>aa,NUMBER_FORMAT_RANGES:()=>mn,aborted:()=>at,allowsEval:()=>fa,assert:()=>Bb,assertEqual:()=>Zb,assertIs:()=>Vb,assertNever:()=>Kb,assertNotEqual:()=>Hb,assignProp:()=>He,attachSchema:()=>qo,base64ToUint8Array:()=>Td,base64urlToUint8Array:()=>pE,cached:()=>Or,captureStackTrace:()=>Lo,cleanEnum:()=>fE,cleanRegex:()=>pn,clone:()=>it,cloneDef:()=>Jb,codePointLength:()=>hn,constantCatch:()=>Id,createTransparentProxy:()=>nE,defineLazy:()=>Ed,defineLazyInternal:()=>H,derived:()=>_E,esc:()=>la,escapeRegex:()=>$t,explicitlyAborted:()=>ha,extend:()=>iE,finalizeIssue:()=>ct,floatSafeRemainder:()=>ua,getElementAtPath:()=>Xb,getEnumValues:()=>Tr,getLengthableOrigin:()=>gn,getParsedType:()=>rE,getSizableOrigin:()=>$d,hexToUint8Array:()=>hE,hide:()=>ya,installLazyProp:()=>bE,isObject:()=>ar,isPlainObject:()=>qt,issue:()=>Ar,joinValues:()=>No,jsonStringifyReplacer:()=>Rr,members:()=>_a,merge:()=>cE,mergeDefs:()=>Pt,normalizeParams:()=>T,nullish:()=>ca,numKeys:()=>tE,objectClone:()=>Gb,omit:()=>sE,optionalKeys:()=>ma,own:()=>Ft,parsedType:()=>ga,partial:()=>uE,pick:()=>oE,prefixIssues:()=>Tt,primitiveTypes:()=>xd,promiseAllObject:()=>Qb,propertyKeyTypes:()=>pa,randomString:()=>eE,rawShape:()=>Ir,required:()=>lE,safeExtend:()=>aE,shallowClone:()=>kd,slugify:()=>da,stringifyPrimitive:()=>jo,toZod:()=>Wb,uint8ArrayToBase64:()=>Rd,uint8ArrayToBase64url:()=>mE,uint8ArrayToHex:()=>gE,unwrapMessage:()=>$r});function Zb(e){return e}function Hb(e){return e}function Wb(){return e=>e}function Vb(e){}function Kb(e){throw new Error("Unexpected value in exhaustive check")}function Bb(e){}function Tr(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,o])=>t.indexOf(+n)===-1).map(([n,o])=>o)}function No(e,t="|"){return e.map(r=>jo(r)).join(t)}function Rr(e,t){return typeof t=="bigint"?t.toString():t}var ia=class{constructor(t){this._getter=t,this._value=void 0}get value(){let t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}};function Or(e){return new ia(e)}function ca(e){return e==null}function pn(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function ua(e,t){let r=e/t,n=Math.round(r),o=4*Number.EPSILON*Math.max(Math.abs(r),1);return Math.abs(r-n)<o?0:r-n}var Sd=Symbol("evaluating");function Ed(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==Sd)return n===void 0&&(n=Sd,n=r()),n},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Gb(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function He(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Ir(e){let t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function xt(e){return Ir(e._zod.def)??e._zod.def.shape}function vd(e,t,r){Object.defineProperty(e,t,{get(){let n=r();return He(this,t,n),n},enumerable:!0,configurable:!0})}function wd(e,t,r){t in e?He(e,t,r):e[t]=r}function ir(e,t,r,n){let o=xt(t);for(let s of r){let i=Object.getOwnPropertyDescriptor(o,s);i.enumerable&&(i.get?vd(e,s,()=>{let a=t._zod.def.shape[s];return n?n(a,s):a}):wd(e,s,n?n(i.value,s):i.value))}}function Yb(e,t){for(let r of Reflect.ownKeys(t)){let n=Object.getOwnPropertyDescriptor(t,r);n.enumerable&&(n.get?vd(e,r,()=>t[r]):wd(e,r,n.value))}}function Pt(...e){let t={};for(let r of e){let n=Object.getOwnPropertyDescriptors(r);Object.assign(t,n)}return Object.defineProperties({},t)}function Jb(e){return Pt(e._zod.def)}function Xb(e,t){return t?t.reduce((r,n)=>r?.[n],e):e}function Qb(e){let t=Object.keys(e),r=t.map(n=>e[n]);return Promise.all(r).then(n=>{let o={};for(let s=0;s<t.length;s++)o[t[s]]=n[s];return o})}function eE(e=10){let t="abcdefghijklmnopqrstuvwxyz",r="";for(let n=0;n<e;n++)r+=t[Math.floor(Math.random()*t.length)];return r}function la(e){return JSON.stringify(e)}function da(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}var Lo="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ar(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var fa=Or(()=>{if(ze.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function qt(e){if(ar(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(ar(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function kd(e){return qt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function tE(e){let t=0;for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}var rE=e=>{let t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},pa=new Set(["string","number","symbol"]),xd=new Set(["string","number","bigint","boolean","symbol","undefined"]);function $t(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function it(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function T(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function nE(e){let t;return new Proxy({},{get(r,n,o){return t??(t=e()),Reflect.get(t,n,o)},set(r,n,o,s){return t??(t=e()),Reflect.set(t,n,o,s)},has(r,n){return t??(t=e()),Reflect.has(t,n)},deleteProperty(r,n){return t??(t=e()),Reflect.deleteProperty(t,n)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,n){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,n)},defineProperty(r,n,o){return t??(t=e()),Reflect.defineProperty(t,n,o)}})}function jo(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function ma(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}var mn={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]},Uo={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function oE(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let s={};return ir(s,e,Fo(e,t)),it(e,Pt(r,{shape:s,checks:[]}))}function Fo(e,t){let r=xt(e),n=[];for(let o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(r,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&n.push(o)}return n}function sE(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let s=new Set(Fo(e,t)),i={};return ir(i,e,Reflect.ownKeys(xt(e)).filter(a=>!s.has(a))),it(e,Pt(r,{shape:i,checks:[]}))}function iE(e,t){if(!qt(t))throw new Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let o=xt(e);for(let s of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return it(e,Pt(e._zod.def,{shape:Pd(e,t)}))}function Pd(e,t){let r={};return ir(r,e,Reflect.ownKeys(xt(e))),Yb(r,t),r}function aE(e,t){if(!qt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return it(e,Pt(e._zod.def,{shape:Pd(e,t)}))}function cE(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r={};ir(r,e,Reflect.ownKeys(xt(e))),ir(r,t,Reflect.ownKeys(xt(t)));let n=Pt(e._zod.def,{shape:r,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return it(e,n)}function uE(e,t,r,n="partial"){let s=t._zod.def.checks;if(s&&s.length>0)throw new Error(`.${n}() cannot be used on object schemas containing refinements`);let a=r?new Set(Fo(t,r)):void 0,c={};return ir(c,t,Reflect.ownKeys(xt(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),it(t,Pt(t._zod.def,{shape:c,checks:[]}))}function lE(e,t,r){let n=r?new Set(Fo(t,r)):void 0,o={};return ir(o,t,Reflect.ownKeys(xt(t)),(s,i)=>n&&!n.has(i)?s:new e({type:"nonoptional",innerType:s})),it(t,Pt(t._zod.def,{shape:o}))}function at(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function ha(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}function Tt(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}function $r(e){return typeof e=="string"?e:e?.message}function qo(e,t,r){var n;for(let o=t;o<e.length;o++)(n=e[o]).schema??(n.schema=r)}function ct(e,t,r){var n;let o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(n=e).schema??(n.schema=e.inst):e.schema=e.inst);let s=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,i=e.message?e.message:$r(e.inst?._zod.def?.error?.(e))??$r(s?.(e))??$r(t?.error?.(e))??$r(r.customError?.(e))??$r(r.localeError?.(e))??"Invalid input",a={};for(let c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=i,t?.reportInput&&(a.input=e.input),a}function $d(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}var dE=/[\uD800-\uDBFF]/;function hn(e){let t=e.length;if(!dE.test(e))return t;let r=t;for(let n=0;n<t-1;n++)(e.charCodeAt(n)&64512)===55296&&(e.charCodeAt(n+1)&64512)===56320&&(r--,n++);return r}function gn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ga(e){let t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";let r=e;if(r&&Object.getPrototypeOf(r)!==Object.prototype&&"constructor"in r&&r.constructor)return r.constructor.name}}return t}function Ar(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}function fE(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Td(e){let t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r}function Rd(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function pE(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Td(t+r)}function mE(e){return Rd(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function hE(e){let t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");let r=new Uint8Array(t.length/2);for(let n=0;n<t.length;n+=2)r[n/2]=Number.parseInt(t.slice(n,n+2),16);return r}function gE(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}var aa=class{constructor(...t){}};function _a(e,t){for(let r in t){let n=Object.getOwnPropertyDescriptor(t,r);n.get?Object.defineProperty(e,r,{...n,enumerable:!1}):bd(e,r,n.value)}for(let r of Object.getOwnPropertySymbols(t))bd(e,r,t[r])}function Ft(e,t,r,n=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:n,value:r}),r}function ya(e,t,r){return Ft(e,t,r,!1)}function _E(e,t){for(let r in e){let n=e[r];Object.defineProperty(t,r,{configurable:!0,enumerable:!0,get(){return Ft(this,r,n(this))},set(o){Ft(this,r,o)}})}return t}function bd(e,t,r){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?r:Ft(this,t,r.bind(this))},set(n){Ft(this,t,n)}})}function yE(e,t){let r=Object.getPrototypeOf(e);return t in r?void 0:r}var sa,Ut=!1,SE={configurable:!0,get(){Ut=!0}};function H(e,t,r){let n=Object.getPrototypeOf(e._zod);if(t in n&&sa!==e._zod){sa=void 0;return}sa=e._zod,Object.defineProperty(n,t,{configurable:!0,get(){Object.defineProperty(this,t,SE);let o=Ut;Ut=!1;try{let s=r(this);return Ut?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:s}),Ut=Ut||o,s}catch(s){throw delete this[t],Ut=Ut||o,s}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function bE(e,t,r,n){let o=yE(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){let s={configurable:!0,writable:!0,enumerable:n,value:void 0};return Object.defineProperty(this,t,s),s.value=r(this),Object.defineProperty(this,t,s),s.value},set(s){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:n,value:s})}})}var Od="~constantCatch";function Id(e){let t=()=>e;return t[Od]=!0,t}var Ad;var Sa={value:void 0,enumerable:!1},Cd="captureStackTrace"in Error?Error:null;function EE(e){let t=Cd;if(t){let r=t.stackTraceLimit;if(typeof r=="number"){try{t.stackTraceLimit=0}catch{return Cd=null,new e}try{return new e}finally{t.stackTraceLimit=r}}}return new e}function b(e,t,r,n){let o={};function s(f){this.def=f,this.constr=d,this.traits=new Set}s.prototype=o;let i=r,a=i&&new WeakSet;function c(f,p){if(!f._zod){Sa.value=new s(p);try{Object.defineProperty(f,"_zod",Sa)}finally{Sa.value=void 0}}if(f._zod.traits.has(e))return;if(f._zod.traits.add(e),t(f,p),a){let h=Object.getPrototypeOf(f),g=f._zod.constr.prototype,y=h;for(;y&&y!==g;)y=Object.getPrototypeOf(y);let E=y??h;a.has(E)||(a.add(E),_a(E,i))}let m=d.prototype;for(let h in m)Object.prototype.hasOwnProperty.call(m,h)&&(h in f||(f[h]=m[h].bind(f)))}let u=n?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){let p=n?.Parent?EE(l):this;c(p,f);let m=p._zod.deferred;if(m){for(let g of m)g();p._zod.deferred=void 0}let h=globalThis.__zod_globalConfig?.postProcessor;return h&&h(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>n?.Parent&&f instanceof n.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var ut=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Cr=class extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}};(Ad=globalThis).__zod_globalConfig??(Ad.__zod_globalConfig={});var ze=globalThis.__zod_globalConfig;function We(e){return e&&Object.assign(ze,e),ze}function vE(){let e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Rr,2)),e.message}function wE(e){this._zod.message=e}var kE={get:vE,set:wE,enumerable:!0,configurable:!0},Ea={value:void 0,enumerable:!1},Md=new WeakSet([Object.prototype,Error.prototype]),zd=(e,t)=>{e.name="$ZodError",Ea.value=t,Object.defineProperty(e,"issues",Ea),Ea.value=void 0,Object.defineProperty(e,"message",kE);let r=Object.getPrototypeOf(e);Md.has(r)||(Md.add(r),Object.defineProperty(r,"toString",{configurable:!0,enumerable:!1,get(){let n=()=>this.message;return Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,"toString",{value:n,configurable:!0,writable:!0})}}))},Dd=b("$ZodError",zd),Nd=b("$ZodError",zd,void 0,{Parent:Error});function xE(e,t,r){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:r(),writable:!0,enumerable:!0,configurable:!0}):e[t]=r()),e[t]}function Ld(e,t=r=>r.message){let r={},n=[];for(let o of e.issues)o.path.length>0?xE(r,o.path[0],()=>[]).push(t(o)):n.push(t(o));return{formErrors:n,fieldErrors:r}}function jd(e,t=r=>r.message){let r={_errors:[]},n=(o,s=[])=>{for(let i of o.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>n({issues:a},[...s,...i.path]));else if(i.code==="invalid_key")n({issues:i.issues},[...s,...i.path]);else if(i.code==="invalid_element")n({issues:i.issues},[...s,...i.path]);else{let a=[...s,...i.path];if(a.length===0)r._errors.push(t(i));else{let c=r,u=0;for(;u<a.length;){let l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(i)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let f=c[l];d&&f._errors.push(t(i)),c=f,u++}}}};return n(e),r}function Zo(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ho=e=>{let t=(r,n,o,s)=>{let i=o?{...o,async:!1}:{async:!1},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ut;if(a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ct(u,i,We())));throw Lo(c,s?.callee??t),c}return a.value};return t};var Wo=e=>{let t=async(r,n,o,s)=>{let i=o?{...o,async:!0}:{async:!0},a=r._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let c=new(s?.Err??e)(a.issues.map(u=>ct(u,i,We())));throw Lo(c,s?.callee??t),c}return a.value};return t};var _n=e=>(t,r,n)=>{let o=n?{...n,async:!1}:{async:!1},s=t._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ut;return s.issues.length?Ud(e,s.issues,o):{success:!0,data:s.value}},va=_n(Nd);function Ud(e,t,r){let n;return{success:!1,get error(){return n||(n=new e(t.map(o=>ct(o,r,We()))),t=void 0,r=void 0),n},set error(o){n=o,t=void 0,r=void 0}}}var Vo=e=>async(t,r,n)=>{let o=n?{...n,async:!0}:{async:!0},s=t._zod.run({value:r,issues:[]},o);return s instanceof Promise&&(s=await s),s.issues.length?Ud(e,s.issues,o):{success:!0,data:s.value}};var $E=Symbol.for("zod.compile.invalid"),TE=Symbol.for("zod.compile.fallback"),Ko=((e,t,r)=>{let n=e._zod.bag.validator;if(n!==void 0){if(n(t)!==$E)return!0;if(n.definite===!0&&r===void 0)return!1}return RE(e,t,r)});function RE(e,t,r){let n=r?{...r,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun,s;if(o?(n[TE]=!0,s=o({value:t,issues:[]},n)):s=e._zod.run({value:t,issues:[]},n),s instanceof Promise)throw new ut;return s.issues.length===0}var Bo=async(e,t,r)=>{let n=r?{...r,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},o=e._zod.run({value:t,issues:[]},n);return o instanceof Promise&&(o=await o),o.issues.length===0},Fd=e=>{let t=Ho(e),r=(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return t(n,o,a,Zo(r,i))};return r};var qd=e=>{let t=Ho(e),r=(n,o,s,i)=>t(n,o,s,Zo(r,i));return r};var Zd=e=>{let t=Wo(e),r=async(n,o,s,i)=>{let a=s?{...s,direction:"backward"}:{direction:"backward"};return await t(n,o,a,Zo(r,i))};return r};var Hd=e=>{let t=Wo(e),r=async(n,o,s,i)=>await t(n,o,s,Zo(r,i));return r};var Wd=e=>(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return _n(e)(t,r,o)};var Vd=e=>(t,r,n)=>_n(e)(t,r,n);var Kd=e=>async(t,r,n)=>{let o=n?{...n,direction:"backward"}:{direction:"backward"};return Vo(e)(t,r,o)};var Bd=e=>async(t,r,n)=>Vo(e)(t,r,n);var Gd=/^[cC][0-9a-z]{6,}$/,Yd=/^[0-9a-z]+$/,Jd=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Xd=/^[0-9a-vA-V]{20}$/,Qd=/^[A-Za-z0-9]{27}$/,ef=/^[a-zA-Z0-9_-]{21}$/;function tf(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var rf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;var nf=/^([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})$/,ka=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;var of=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var OE="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function sf(){return new RegExp(OE,"u")}var af=/^(?:(?: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])$/,cf=/^(([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 uf=/^((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])$/,lf=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,df=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ff=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/;var pf=/^https?$/,mf=/^\+[1-9]\d{6,14}$/;var hf="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))";function IE(e){return new RegExp(`^${e}$`)}var gf=IE(hf);function wa(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function _f(e){return new RegExp(`^${wa(e)}$`)}function yf(e){let t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let r=`${wa({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,n=e.local?`${r}|${wa({precision:e.precision})}`:r;return new RegExp(`^${hf}T(?:${n})$`)}var Sf=/^[\s\S]{0,}$/;var xa=/^-?\d+$/,yn=/^-?\d+(?:\.\d+)?$/,bf=/^(?:true|false)$/i,Ef=/^null$/i;var vf=/^[^A-Z]*$/,wf=/^[^a-z]*$/;var me=b("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])});var Pa=e=>{let t=e.value;return!ca(t)&&t.length!==void 0},Go={number:"number",bigint:"bigint",object:"date"},$a=b("$ZodCheckLessThan",(e,t)=>{me.init(e,t);let r=Go[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value<=t.value:n.value<t.value)||n.issues.push({origin:Go[typeof n.value]??r,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ta=b("$ZodCheckGreaterThan",(e,t)=>{me.init(e,t);let r=Go[typeof t.value];e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:Go[typeof n.value]??r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),kf=b("$ZodCheckMultipleOf",(e,t)=>{me.init(e,t),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?t.value!==BigInt(0)&&r.value%t.value===BigInt(0):ua(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),xf=b("$ZodCheckNumberFormat",(e,t)=>{me.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[o,s]=mn[t.format];e._zod.check=i=>{let a=i.value;if(r){if(!Number.isInteger(a)){i.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?i.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):i.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}a<o&&i.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>s&&i.issues.push({origin:"number",input:a,code:"too_big",maximum:s,inclusive:!0,inst:e,continue:!t.abort})}});var Pf=b("$ZodCheckMaxLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Pa),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>t.maximum?hn(o):s)<=t.maximum)return;let a=gn(o);n.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),$f=b("$ZodCheckMinLength",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Pa),e._zod.check=n=>{let o=n.value,s=o.length;if((typeof o=="string"&&s>=t.minimum&&s<t.minimum*2?hn(o):s)>=t.minimum)return;let a=gn(o);n.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Tf=b("$ZodCheckLengthEquals",(e,t)=>{var r;me.init(e,t),(r=e._zod.def).when??(r.when=Pa),e._zod.check=n=>{let o=n.value,s=o.length,i=typeof o=="string"&&s>=t.length&&s<=t.length*2?hn(o):s;if(i===t.length)return;let a=gn(o),c=i>t.length;n.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),bn=b("$ZodCheckStringFormat",(e,t)=>{var r,n;me.init(e,t),t.pattern?(r=e._zod).check??(r.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Rf=b("$ZodCheckRegex",(e,t)=>{bn.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Of=b("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vf),bn.init(e,t)}),If=b("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=wf),bn.init(e,t)}),Af=b("$ZodCheckIncludes",(e,t)=>{me.init(e,t);let r=$t(t.includes),n=new RegExp(typeof t.position=="number"?`^.{${t.position},}${r}`:r);t.pattern=n,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Cf=b("$ZodCheckStartsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`^${$t(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Mf=b("$ZodCheckEndsWith",(e,t)=>{me.init(e,t);let r=new RegExp(`.*${$t(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}});var zf=b("$ZodCheckOverwrite",(e,t)=>{me.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});var Yo=class{constructor(t=[],r={}){this.content=[],this.indent=0,this.args=t,this.closed=r}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}let n=t.split(`
23
23
  `).filter(i=>i),o=Math.min(...n.map(i=>i.length-i.trimStart().length)),s=n.map(i=>i.slice(o)).map(i=>" ".repeat(this.indent*2)+i);for(let i of s)this.content.push(i)}compile(){let t=Function,r=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
24
24
  ${r.join(`
25
25
  `)}
26
- };`)(...Object.values(this.closed))}};var Df={major:4,minor:6,patch:2};var X=b("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Df;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=at(a),d;for(let f of c){if(f._zod.def.when){if(ha(a)||!f._zod.def.when(a))continue}else if(l)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new ut;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(qo(a.issues,p,e),l||(l=at(a,p)))});else{if(a.issues.length===p)continue;qo(a.issues,p,e),l||(l=at(a,p))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(at(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ut;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ut;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return ya(this,"~standard",Oa(this))},set"~standard"(e){Ft(this,"~standard",e)}}),Vf=(e,t)=>e.issues.length?{issues:e.issues.map(r=>ct(r,t,We()))}:{value:e.value};async function AE(e,t){let r={async:!0};return Vf(await e._zod.run({value:t,issues:[]},r),r)}function Oa(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Vf(n,r)}catch{}return AE(e,t)},vendor:"zod",version:1}}var Qo=b("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=t.pattern??yf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Q=b("$ZodStringFormat",(e,t)=>{bn.init(e,t),Qo.init(e,t)}),Kf=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=rf),Q.init(e,t)}),Bf=b("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ka(n))}else t.pattern??(t.pattern=ka());Q.init(e,t)}),Gf=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=nf),Q.init(e,t)}),Yf=1,Jf=2;function CE(e,t){if(!t.normalize&&t.protocol?.source===ff.source&&!/^https?:\/\//i.test(e))return Yf;try{return new URL(e)}catch{return Jf}}var ME=/[\t\n\r]/g;function zE(e){return e.replace(ME,"")}function DE(e,t){return t.lastIndex=0,t.test(e.hostname)}function NE(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Xf=b("$ZodURL",(e,t)=>{Q.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=CE(n,t);if(o===Yf){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Jf){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}t.hostname&&!DE(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!NE(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:zE(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),Qf=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=of()),Q.init(e,t)}),ep=b("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?Qd:ef(t.length)),Q.init(e,t)}),tp=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Bd),Q.init(e,t)}),rp=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Gd),Q.init(e,t)}),np=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Yd),Q.init(e,t)}),op=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Jd),Q.init(e,t)}),sp=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Xd),Q.init(e,t)}),ip=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=_f(t)),Q.init(e,t)}),ap=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=hf),Q.init(e,t)}),cp=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=gf(t)),Q.init(e,t)}),up=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=tf),Q.init(e,t)}),lp=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=sf),Q.init(e,t)}),LE=/^[0-9a-fA-F:.]+$/;function dp(e){if(!LE.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}var fp=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=af),Q.init(e,t),e._zod.check=r=>{dp(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var pp=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=cf),Q.init(e,t)});function jE(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:dp(r)}var mp=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=uf),Q.init(e,t),e._zod.check=r=>{jE(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function hp(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ia=/^[0-9a-zA-Z+/]*={0,2}$/,gp=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ia),Q.init(e,t),e._zod.check=r=>{hp(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),es=/^[A-Za-z0-9_-]*$/;function UE(e){if(!es.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return hp(r)}var _p=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=es),Q.init(e,t),e._zod.check=r=>{UE(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),yp=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=pf),Q.init(e,t)});function FE(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var Sp=b("$ZodJWT",(e,t)=>{Q.init(e,t),e._zod.check=r=>{FE(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Aa=b("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=yn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),bp=b("$ZodNumberFormat",(e,t)=>{kf.init(e,t),Aa.init(e,t)}),Ep=b("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=Sf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var vp=b("$ZodNull",(e,t)=>{X.init(e,t),e._zod.pattern=bf,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var wp=b("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),kp=b("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Nf(e,t,r){e.issues.length&&t.issues.push(...Tt(r,e.issues)),t.value[r]=e.value}var xp=b("$ZodArray",(e,t)=>{X.init(e,t);let r=ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Nf(d,n,c)));else if(Nf(l,n,c),a&&l.issues.length!==0&&at(l))break}return i.length?Promise.all(i).then(()=>n):n}});function Xo(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...Tt(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var qE=[];function Pp(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:qE,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=ma(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function $p(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout,p=0;for(let m in t){if(i&&r.issues.length!==p){if(at(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){l==="never"&&a.push(m);continue}if(l==="never"){a.push(m);continue}let h=u.run({value:t[m],issues:[]},n);h instanceof Promise?e.push(h.then(g=>Xo(g,r,m,t,d,f))):Xo(h,r,m,t,d,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var ZE=b("$ZodObject",(e,t)=>{X.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=Or(()=>Pp(t));H(e,"propValues",u=>{let l=u.def.shape,d={};for(let f in l){let p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||He(d,f,new Set);for(let m of p.values)d[f].add(m);p.optin!==void 0&&d[f].add(void 0)}}return d});let s=ar,i=t.catchall,a,c=ze.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let f=[],p=a.shape,m=l?.abortEarly,h=u.issues.length;for(let g of a.allKeys){if(m&&u.issues.length!==h){if(at(u,h))break;h=u.issues.length}if(g==="__proto__")continue;let y=p[g],E=y._zod.optin,v=y._zod.optout,I=y._zod.run({value:d[g],issues:[]},l);I instanceof Promise?f.push(I.then(x=>Xo(x,u,g,d,E,v))):Xo(I,u,g,d,E,v)}return i?$p(f,d,u,l,o.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),Tp=b("$ZodObjectJIT",(e,t)=>{ZE.init(e,t);let r=e._zod.parse,n=Or(()=>Pp(t)),o=ze.memoizer,s=p=>{let m=n.value,h=m.symbolKeys,g=new Yo(["payload","ctx"],{shape:p,inst:e,memo:o,syms:h}),y=x=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,E=(x,z)=>`
26
+ };`)(...Object.values(this.closed))}};var Nf={major:4,minor:6,patch:2};var X=b("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Nf;let n=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...n??[]]:n?.length?[...n]:[];for(let s of o)for(let i of s._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let s=(a,c,u)=>{if(a.memo)return a;let l=at(a),d;for(let f of c){if(f._zod.def.when){if(ha(a)||!f._zod.def.when(a))continue}else if(l)continue;let p=a.issues.length,m=f._zod.check(a);if(m instanceof Promise&&u?.async===!1)throw new ut;if(d||m instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(qo(a.issues,p,e),l||(l=at(a,p)))});else{if(a.issues.length===p)continue;qo(a.issues,p,e),l||(l=at(a,p))}}return d?d.then(()=>a):a},i=(a,c,u)=>{if(at(a))return a.aborted=!0,a;let l=s(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new ut;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){let l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>i(d,a,c)):i(l,a,c)}let u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new ut;return u.then(l=>s(l,o,c))}return s(u,o,c)}}},{get"~standard"(){return ya(this,"~standard",Oa(this))},set"~standard"(e){Ft(this,"~standard",e)}}),Kf=(e,t)=>e.issues.length?{issues:e.issues.map(r=>ct(r,t,We()))}:{value:e.value};async function AE(e,t){let r={async:!0};return Kf(await e._zod.run({value:t,issues:[]},r),r)}function Oa(e){return{validate:t=>{let r={async:!1};try{let n=e._zod.run({value:t,issues:[]},r);if(!(n instanceof Promise))return Kf(n,r)}catch{}return AE(e,t)},vendor:"zod",version:1}}var Qo=b("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=t.pattern??Sf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),Q=b("$ZodStringFormat",(e,t)=>{bn.init(e,t),Qo.init(e,t)}),Bf=b("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=nf),Q.init(e,t)}),Gf=b("$ZodUUID",(e,t)=>{if(t.version){let n={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(n===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=ka(n))}else t.pattern??(t.pattern=ka());Q.init(e,t)}),Yf=b("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=of),Q.init(e,t)}),Jf=1,Xf=2;function CE(e,t){if(!t.normalize&&t.protocol?.source===pf.source&&!/^https?:\/\//i.test(e))return Jf;try{return new URL(e)}catch{return Xf}}var ME=/[\t\n\r]/g;function zE(e){return e.replace(ME,"")}function DE(e,t){return t.lastIndex=0,t.test(e.hostname)}function NE(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}var Qf=b("$ZodURL",(e,t)=>{Q.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),o=CE(n,t);if(o===Jf){r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});return}if(o===Xf){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort});return}t.hostname&&!DE(o,t.hostname)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort}),t.protocol&&!NE(o,t.protocol)&&r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort}),r.value=t.normalize?o.href:zE(n);return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ep=b("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=sf()),Q.init(e,t)}),tp=b("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?ef:tf(t.length)),Q.init(e,t)}),rp=b("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Gd),Q.init(e,t)}),np=b("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Yd),Q.init(e,t)}),op=b("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Jd),Q.init(e,t)}),sp=b("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Xd),Q.init(e,t)}),ip=b("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Qd),Q.init(e,t)}),ap=b("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=yf(t)),Q.init(e,t)}),cp=b("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=gf),Q.init(e,t)}),up=b("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=_f(t)),Q.init(e,t)}),lp=b("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=rf),Q.init(e,t)}),dp=b("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=af),Q.init(e,t)}),LE=/^[0-9a-fA-F:.]+$/;function fp(e){if(!LE.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}var pp=b("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=cf),Q.init(e,t),e._zod.check=r=>{fp(r.value)||r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}});var mp=b("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=uf),Q.init(e,t)});function jE(e){let t=e.split("/");if(t.length!==2)return!1;let[r,n]=t;if(!n)return!1;let o=Number(n);return`${o}`!==n||o<0||o>128?!1:fp(r)}var hp=b("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=lf),Q.init(e,t),e._zod.check=r=>{jE(r.value)||r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}});function gp(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}var Ia=/^[0-9a-zA-Z+/]*={0,2}$/,_p=b("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=Ia),Q.init(e,t),e._zod.check=r=>{gp(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),es=/^[A-Za-z0-9_-]*$/;function UE(e){if(!es.test(e))return!1;let t=e.replace(/[-_]/g,n=>n==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return gp(r)}var yp=b("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=es),Q.init(e,t),e._zod.check=r=>{UE(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Sp=b("$ZodE164",(e,t)=>{t.pattern??(t.pattern=mf),Q.init(e,t)});function FE(e,t=null){try{let r=e.split(".");if(r.length!==3)return!1;let[n]=r;if(!n)return!1;let o=JSON.parse(atob(n));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}var bp=b("$ZodJWT",(e,t)=>{Q.init(e,t),e._zod.check=r=>{FE(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}});var Aa=b("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=yn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let o=r.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return r;let s=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return r.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...s?{received:s}:{}}),r}}),Ep=b("$ZodNumberFormat",(e,t)=>{xf.init(e,t),Aa.init(e,t)}),vp=b("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=bf,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let o=r.value;return typeof o=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),r}});var wp=b("$ZodNull",(e,t)=>{X.init(e,t),e._zod.pattern=Ef,e._zod.values=new Set([null]),e._zod.parse=(r,n)=>{let o=r.value;return o===null||r.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),r}});var kp=b("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),xp=b("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)});function Lf(e,t,r){e.issues.length&&t.issues.push(...Tt(r,e.issues)),t.value[r]=e.value}var Pp=b("$ZodArray",(e,t)=>{X.init(e,t);let r=ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!Array.isArray(s))return n.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),n;n.value=r?r.alloc(e,n,Array(s.length),o):Array(s.length);let i=[],a=o?.abortEarly;for(let c=0;c<s.length;c++){let u=s[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)i.push(l.then(d=>Lf(d,n,c)));else if(Lf(l,n,c),a&&l.issues.length!==0&&at(l))break}return i.length?Promise.all(i).then(()=>n):n}});function Xo(e,t,r,n,o,s){let i=r in n,a=s==="optional";if(!(!i&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!i)return;t.issues.push(...Tt(r,e.issues))}if(!i&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}e.value===void 0?(i||o==="defaulted"&&!a)&&(t.value[r]=void 0):t.value[r]=e.value}}var qE=[];function $p(e){let t=Object.keys(e.shape),r=Object.getOwnPropertySymbols(e.shape),n=r.length?r:qE,o=n.length?[...t,...n]:t;for(let i of o)if(!e.shape?.[i]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(i)}": expected a Zod schema`);let s=ma(e.shape);return{...e,allKeys:o,symbolKeys:n,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(s)}}function Tp(e,t,r,n,o,s,i){let a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout,p=0;for(let m in t){if(i&&r.issues.length!==p){if(at(r,p))break;p=r.issues.length}if(c.has(m))continue;if(m==="__proto__"){l==="never"&&a.push(m);continue}if(l==="never"){a.push(m);continue}let h=u.run({value:t[m],issues:[]},n);h instanceof Promise?e.push(h.then(g=>Xo(g,r,m,t,d,f))):Xo(h,r,m,t,d,f)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:s,continue:!0}),e.length?Promise.all(e).then(()=>r):r}var ZE=b("$ZodObject",(e,t)=>{X.init(e,t);let r=Object.getOwnPropertyDescriptor(t,"shape"),n=r?.get?r.get.raw:t.shape??{};if(n){let u=()=>{let l={...n};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=n,Object.defineProperty(t,"shape",{get:u})}let o=Or(()=>$p(t));H(e,"propValues",u=>{let l=u.def.shape,d={};for(let f in l){let p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||He(d,f,new Set);for(let m of p.values)d[f].add(m);p.optin!==void 0&&d[f].add(void 0)}}return d});let s=ar,i=t.catchall,a,c=ze.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);let d=u.value;if(!s(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};let f=[],p=a.shape,m=l?.abortEarly,h=u.issues.length;for(let g of a.allKeys){if(m&&u.issues.length!==h){if(at(u,h))break;h=u.issues.length}if(g==="__proto__")continue;let y=p[g],E=y._zod.optin,v=y._zod.optout,I=y._zod.run({value:d[g],issues:[]},l);I instanceof Promise?f.push(I.then(x=>Xo(x,u,g,d,E,v))):Xo(I,u,g,d,E,v)}return i?Tp(f,d,u,l,o.value,e,m===!0):f.length?Promise.all(f).then(()=>u):u}}),Rp=b("$ZodObjectJIT",(e,t)=>{ZE.init(e,t);let r=e._zod.parse,n=Or(()=>$p(t)),o=ze.memoizer,s=p=>{let m=n.value,h=m.symbolKeys,g=new Yo(["payload","ctx"],{shape:p,inst:e,memo:o,syms:h}),y=x=>`shape[${x}]._zod.run({ value: input[${x}], issues: [] }, ctx)`,E=(x,z)=>`
27
27
  let ${x}_ab = false;
28
28
  for (let i = 0; i < ${x}.issues.length; i++) {
29
29
  const iss = ${x}.issues[i];
@@ -73,15 +73,15 @@ ${r.join(`
73
73
  newResult[${j}] = ${z}.value;
74
74
  }
75
75
 
76
- `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,a=ar,c=!ze.jitless,l=c&&fa.value,d=t.catchall,f;e._zod.parse=(p,m)=>{f??(f=n.value);let h=p.value;return a(h)?c&&l&&m?.async===!1&&m.jitless!==!0?(i||(i=s(t.shape)),p=i(p,m),d?$p([],h,p,m,f,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p)}});function Lf(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!at(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>ct(i,n,We())))}),t)}var Ca=b("$ZodUnion",(e,t)=>{X.init(e,t),H(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),H(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),H(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),H(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>pn(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>Lf(a,n,e,o)):Lf(i,n,e,o)}});function HE(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var Rp=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ca.init(e,t);let r=e._zod.parse;H(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||He(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=Ir(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=Or(()=>HE(t));e._zod.parse=(o,s)=>{let i=o.value;if(!ar(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),Op=b("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>jf(r,c,u)):jf(r,s,i)}});function Ra(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(qt(e)&&qt(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Ra(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=Ra(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 jf(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);s.has(f)||s.set(f,u),d=[f]}else return!1;for(let f of d)n.has(f)||n.set(f,{}),n.get(f)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=Ra(t.value,r.value);if(!c.valid){if(at(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Ip=b("$ZodRecord",(e,t)=>{X.init(e,t);let r=ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!qt(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>ct(m,o,We())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...Tt(l,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...Tt(l,p.issues)),n.value[f]=p.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&yn.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(l=m)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>ct(m,o,We())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[u],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...Tt(u,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...Tt(u,p.issues)),n.value[f]=p.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var Ap=b("$ZodEnum",(e,t)=>{X.init(e,t);let r=Tr(t.entries),n=new Set(r);e._zod.values=n,H(e,"pattern",o=>{let s=Tr(o.def.entries).filter(i=>pa.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>$t(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),Cp=b("$ZodLiteral",(e,t)=>{X.init(e,t);let r=new Set(t.values);e._zod.values=r,H(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?$t(s):s?$t(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var Mp=b("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.optin="optional",ze.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Cr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ut;return r.value=o,r}});function Uf(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ma=b("$ZodOptional",(e,t)=>{X.init(e,t),H(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",H(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),H(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${pn(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Uf(r,s)):Uf(r,o)}return t.innerType._zod.run(r,n)}}),zp=b("$ZodExactOptional",(e,t)=>{Ma.init(e,t),H(e,"values",r=>r.def.innerType._zod.values),H(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Dp=b("$ZodNullable",(e,t)=>{X.init(e,t),H(e,"optin",r=>r.def.innerType._zod.optin),H(e,"optout",r=>r.def.innerType._zod.optout),H(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${pn(n.source)}|null)$`):void 0}),H(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Np=b("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="defaulted",H(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Ff(s,t)):Ff(o,t)}});function Ff(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Lp=b("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="defaulted",H(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),jp=b("$ZodNonOptional",(e,t)=>{X.init(e,t),H(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>qf(s,e)):qf(o,e)}});function qf(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Zf(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>ct(o,n,We()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Up=b("$ZodCatch",(e,t)=>{X.init(e,t),H(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),H(e,"optout",r=>r.def.innerType._zod.optout),H(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Zf(r,s,t,n)):Zf(r,o,t,n)}});var za=b("$ZodPipe",(e,t)=>{X.init(e,t),H(e,"values",r=>r.def.in._zod.values),H(e,"optin",r=>r.def.in._zod.optin),H(e,"optout",r=>r.def.out._zod.optout),H(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Jo(i,t.in,n)):Jo(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Jo(s,t.out,n)):Jo(o,t.out,n)}});function Jo(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var Fp=b("$ZodPreprocess",(e,t)=>{za.init(e,t)}),qp=b("$ZodReadonly",(e,t)=>{X.init(e,t),H(e,"propValues",r=>r.def.innerType._zod.propValues),H(e,"values",r=>r.def.innerType._zod.values),H(e,"optin",r=>r.def.innerType?._zod?.optin),H(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Hf):Hf(o)}});function Hf(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Zp=b("$ZodCustom",(e,t)=>{me.init(e,t),X.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Wf(s,r,n,e));Wf(o,r,n,e)}});function Wf(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Ar(o))}}var Na=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},La="~memo",Hp=[];function Wp(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function Da(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var Vp=new WeakMap,En=0,ns=1,vn=2;function os(e,t,r){let n=Vp.get(e);if(n!==void 0)return n?vn:En;if(t.has(e))return vn;t.add(e);let o=En,s=l=>{if(o!==vn&&l?._zod){let d=os(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let f=En;for(let p of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,p);if(d&&!m.enumerable)continue;let h=m.get?ns:m.value?._zod?os(m.value,t,r):En;h>f&&(f=h)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=Ir(c);a(l?i(l,!0):ns),s(c.catchall);break}case"properties":a(i(c.shape,!1));break;case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?os(l,t,!1):ns);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)s(f);else if(Array.isArray(f))for(let p of f)s(p)}}}return t.delete(e),WE(e,o)}function WE(e,t){return t!==ns&&Vp.set(e,t===vn),t}function VE(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var ts,rs=[],KE={alloc(e,t,r){let n=ts;if(!n)return r;ts=void 0;let o={value:r,issues:null};return n.set(t.value,o),rs.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&BE(s,o.value))throw new Na;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let y=os(e,new Set,!1);if(y===En)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);y===vn||n?r=!0:n=!0}let l=c.value;if(!Wp(l))return i(c,u);let d=u[La];d||(d={buckets:new WeakMap,backEdges:void 0},u[La]=d);let f;o===u?f=s:(f=VE(d,e),o=u,s=f);let p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...Da(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;ts=f;let m=rs.length,h=i(c,u);ts=void 0;let g=rs.length>m?rs.pop():void 0;return h instanceof Promise?h.then(y=>(g&&(g.issues=y.issues.length?Da(y.issues):Hp),y)):(g&&(g.issues=h.issues.length?Da(h.issues):Hp),h)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function Kp(){return KE}function BE(e,t){let r=e[La]?.backEdges;return r!==void 0&&Wp(t)&&r.has(t)}var GE=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=ga(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${jo(s.values[0])}`:`Invalid option: expected one of ${No(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${No(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Bp(){return{localeError:GE()}}var Gp;var ja=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function YE(){return new ja}(Gp=globalThis).__zod_globalRegistry??(Gp.__zod_globalRegistry=YE());var cr=globalThis.__zod_globalRegistry;function Yp(e,t){return new e({type:"string",...T(t)})}function Jp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}function Xp(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...T(t)})}function Qp(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...T(t)})}function em(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(t)})}function tm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(t)})}function rm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(t)})}function nm(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...T(t)})}function om(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...T(t)})}function sm(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(t)})}function im(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...T(t)})}function am(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(t)})}function cm(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...T(t)})}function um(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...T(t)})}function lm(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(t)})}function dm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(t)})}function fm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(t)})}function pm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(t)})}function mm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(t)})}function hm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...T(t)})}function gm(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...T(t)})}function _m(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...T(t)})}function ym(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...T(t)})}function ss(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(t)})}function is(e,t){return new e({type:"string",format:"date",check:"string_format",...T(t)})}function as(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...T(t)})}function cs(e,t){return new e({type:"string",format:"duration",check:"string_format",...T(t)})}function Sm(e,t){return new e({type:"number",checks:[],...T(t)})}function bm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...T(t)})}function Em(e,t){return new e({type:"boolean",...T(t)})}function vm(e,t){return new e({type:"null",...T(t)})}function wm(e){return new e({type:"unknown"})}function km(e,t){return new e({type:"never",...T(t)})}function us(e,t){return new $a({check:"less_than",...T(t),value:e,inclusive:!1})}function wn(e,t){return new $a({check:"less_than",...T(t),value:e,inclusive:!0})}function ls(e,t){return new Ta({check:"greater_than",...T(t),value:e,inclusive:!1})}function kn(e,t){return new Ta({check:"greater_than",...T(t),value:e,inclusive:!0})}function ds(e,t){return new wf({check:"multiple_of",...T(t),value:e})}function fs(e,t){return new xf({check:"max_length",...T(t),maximum:e})}function Mr(e,t){return new Pf({check:"min_length",...T(t),minimum:e})}function ps(e,t){return new $f({check:"length_equals",...T(t),length:e})}function Ua(e,t){return new Tf({check:"string_format",format:"regex",...T(t),pattern:e})}function Fa(e){return new Rf({check:"string_format",format:"lowercase",...T(e)})}function qa(e){return new Of({check:"string_format",format:"uppercase",...T(e)})}function Za(e,t){return new If({check:"string_format",format:"includes",...T(t),includes:e})}function Ha(e,t){return new Af({check:"string_format",format:"starts_with",...T(t),prefix:e})}function Wa(e,t){return new Cf({check:"string_format",format:"ends_with",...T(t),suffix:e})}function Zt(e){return new Mf({check:"overwrite",tx:e})}function Va(e){return Zt(t=>t.normalize(e))}function Ka(){return Zt(e=>e.trim())}function Ba(){return Zt(e=>e.toLowerCase())}function Ga(){return Zt(e=>e.toUpperCase())}function Ya(){return Zt(e=>da(e))}function xm(e,t,r){return new e({type:"array",element:t,...T(r)})}function Pm(e,t,r){let n=T(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function $m(e,t,r){return new e({type:"custom",check:"custom",fn:t,...T(r)})}function Tm(e,t){let r=JE(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Ar(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Ar(s))}},e(n.value,n)),t);return r}function JE(e,t){let r=new me({check:"custom",...T(t)});return r._zod.check=e,r}function xn(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&He(e,n,r[n]);return e}function Xa(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??cr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Rt(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function ue(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),ue(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&xn(i.schema,c),t.io==="input"&&Ee(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Rm(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Qa(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${Rm(p)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Rm(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
76
+ `)}return g.write("payload.value = newResult;"),g.write("return payload;"),g.compile()},i,a=ar,c=!ze.jitless,l=c&&fa.value,d=t.catchall,f;e._zod.parse=(p,m)=>{f??(f=n.value);let h=p.value;return a(h)?c&&l&&m?.async===!1&&m.jitless!==!0?(i||(i=s(t.shape)),p=i(p,m),d?Tp([],h,p,m,f,e,m?.abortEarly===!0):p):r(p,m):(p.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),p)}});function jf(e,t,r,n){for(let s of e)if(s.issues.length===0)return t.value=s.value,t;let o=e.filter(s=>!at(s));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(s=>s.issues.map(i=>ct(i,n,We())))}),t)}var Ca=b("$ZodUnion",(e,t)=>{X.init(e,t),H(e,"optin",n=>n.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":n.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),H(e,"optout",n=>n.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),H(e,"values",n=>{if(n.def.options.every(o=>o._zod.values))return new Set(n.def.options.flatMap(o=>Array.from(o._zod.values)))}),H(e,"pattern",n=>{if(n.def.options.every(o=>o._zod.pattern)){let o=n.def.options.map(s=>s._zod.pattern);return new RegExp(`^(${o.map(s=>pn(s.source)).join("|")})$`)}});let r=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(n,o)=>{if(r)return r(n,o);let s=!1,i=[];for(let a of t.options){let c=a._zod.run({value:n.value,issues:[]},o);if(c instanceof Promise)i.push(c),s=!0;else{if(c.issues.length===0)return c;i.push(c)}}return s?Promise.all(i).then(a=>jf(a,n,e,o)):jf(i,n,e,o)}});function HE(e){let t=new Map;for(let r of e.options){let n=r._zod.propValues?.[e.discriminator];if(!n||n.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(r)}"`);for(let o of n)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,r)}return t}var Op=b("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Ca.init(e,t);let r=e._zod.parse;H(e,"propValues",o=>{let s={},i=0;for(let a of o.def.options){let c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&i++;for(let[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(s,u)||He(s,u,new Set);for(let d of l)s[u].add(d)}}return!o.def.unionFallback&&i>1&&s[o.def.discriminator]?.delete(void 0),s}),t.options.forEach((o,s)=>{let i=Ir(o._zod.def);if(i&&!Object.prototype.hasOwnProperty.call(i,t.discriminator))throw new Error(`Invalid discriminated union option at index "${s}"`)});let n=Or(()=>HE(t));e._zod.parse=(o,s)=>{let i=o.value;if(!ar(i))return o.issues.push({code:"invalid_type",expected:"object",input:i,inst:e}),o;let a=i?.[t.discriminator],c=n.value.get(a);return c&&(a!==void 0||s.direction!=="backward")?c._zod.run(o,s):t.unionFallback||s.direction==="backward"?r(o,s):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(n.value.keys()).filter(u=>n.value.get(u)!==null),input:i,path:[t.discriminator],inst:e}),o)}}),Ip=b("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(r,n)=>{let o=r.value,s=t.left._zod.run({value:o,issues:[]},n),i=t.right._zod.run({value:o,issues:[]},n);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([c,u])=>Uf(r,c,u)):Uf(r,s,i)}});function Ra(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(qt(e)&&qt(t)){let r=Object.keys(t),n=Object.keys(e).filter(s=>r.indexOf(s)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(let s of n){if(s==="__proto__")continue;let i=Ra(e[s],t[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};o[s]=i.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let r=[];for(let n=0;n<e.length;n++){let o=e[n],s=t[n],i=Ra(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 Uf(e,t,r){let n=new Map,o,s=new Map,i=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){let f=String(u.path[0]);s.has(f)||s.set(f,u),d=[f]}else return!1;for(let f of d)n.has(f)||n.set(f,{}),n.get(f)[l]=!0;return!0};for(let u of t.issues)i(u,"l")||e.issues.push(u);for(let u of r.issues)i(u,"r")||e.issues.push(u);let a=[...n].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){let u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(let l of a)!u.includes(l)&&s.has(l)&&e.issues.push(s.get(l))}let c=Ra(t.value,r.value);if(!c.valid){if(at(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Ap=b("$ZodRecord",(e,t)=>{X.init(e,t);let r=ze.memoizer;r?.attach(e),e._zod.parse=(n,o)=>{let s=n.value;if(!qt(s))return n.issues.push({expected:"record",code:"invalid_type",input:s,inst:e}),n;let i=[],a=t.keyType._zod.values;if(a&&!t.partial){n.value=r?r.alloc(e,n,{},o):{};let c=new Set;for(let l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;let d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(m=>ct(m,o,We())),input:l,path:[l],inst:e});continue}let f=d.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[l],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...Tt(l,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...Tt(l,p.issues)),n.value[f]=p.value)}let u;for(let l in s)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;n.value[l]=s[l]}else u=u??[],u.push(l);u&&u.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:u,continue:!0})}else{n.value=r?r.alloc(e,n,{},o):{};let c;for(let u of Reflect.ownKeys(s)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(s,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&yn.test(u)&&l.issues.length){let m=t.keyType._zod.run({value:Number(u),issues:[]},o);if(m instanceof Promise)throw new Error("Async schemas not supported in object keys currently");m.issues.length===0&&(l=m)}if(l.issues.length){t.mode==="loose"?n.value[u]=s[u]:a?(c=c??[],c.push(u)):n.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(m=>ct(m,o,We())),input:u,path:[u],inst:e});continue}let f=l.value;if(f==="__proto__")continue;let p=t.valueType._zod.run({value:s[u],issues:[]},o);p instanceof Promise?i.push(p.then(m=>{m.issues.length&&n.issues.push(...Tt(u,m.issues)),n.value[f]=m.value})):(p.issues.length&&n.issues.push(...Tt(u,p.issues)),n.value[f]=p.value)}c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:s,inst:e,keys:c,continue:!0})}return i.length?Promise.all(i).then(()=>n):n}});var Cp=b("$ZodEnum",(e,t)=>{X.init(e,t);let r=Tr(t.entries),n=new Set(r);e._zod.values=n,H(e,"pattern",o=>{let s=Tr(o.def.entries).filter(i=>pa.has(typeof i));return new RegExp(s.length?`^(${s.map(i=>$t(i.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,s)=>{let i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:r,input:i,inst:e}),o}}),Mp=b("$ZodLiteral",(e,t)=>{X.init(e,t);let r=new Set(t.values);e._zod.values=r,H(e,"pattern",n=>{let o=n.def.values;return new RegExp(o.length?`^(${o.map(s=>typeof s=="string"?$t(s):s?$t(s.toString()):String(s)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(n,o)=>{let s=n.value;return r.has(s)||n.issues.push({code:"invalid_value",values:t.values,input:s,inst:e}),n}});var zp=b("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.optin="optional",ze.memoizer?.guard(e),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Cr(e.constructor.name);let o=t.transform(r.value,r);if(n.async)return(o instanceof Promise?o:Promise.resolve(o)).then(i=>(r.value=i,r));if(o instanceof Promise)throw new ut;return r.value=o,r}});function Ff(e,t){return e.value=t.issues.length?void 0:t.value,e}var Ma=b("$ZodOptional",(e,t)=>{X.init(e,t),H(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",H(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n,void 0]):void 0}),H(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${pn(n.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(r.value===void 0){if(t.innerType._zod.optin!=="defaulted")return r;let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Ff(r,s)):Ff(r,o)}return t.innerType._zod.run(r,n)}}),Dp=b("$ZodExactOptional",(e,t)=>{Ma.init(e,t),H(e,"values",r=>r.def.innerType._zod.values),H(e,"pattern",r=>r.def.innerType._zod.pattern),e._zod.parse=(r,n)=>t.innerType._zod.run(r,n)}),Np=b("$ZodNullable",(e,t)=>{X.init(e,t),H(e,"optin",r=>r.def.innerType._zod.optin),H(e,"optout",r=>r.def.innerType._zod.optout),H(e,"pattern",r=>{let n=r.def.innerType._zod.pattern;return n?new RegExp(`^(${pn(n.source)}|null)$`):void 0}),H(e,"values",r=>r.def.innerType._zod.values?new Set([...r.def.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)}),Lp=b("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="defaulted",H(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);if(r.value===void 0)return r.value=t.defaultValue,r;let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>qf(s,t)):qf(o,t)}});function qf(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var jp=b("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="defaulted",H(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>(n.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,n))}),Up=b("$ZodNonOptional",(e,t)=>{X.init(e,t),H(e,"values",r=>{let n=r.def.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,n)=>{let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(s=>Zf(s,e)):Zf(o,e)}});function Zf(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}function Hf(e,t,r,n){return t.issues.length?(e.value=r.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>ct(o,n,We()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Fp=b("$ZodCatch",(e,t)=>{X.init(e,t),H(e,"optin",r=>r.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),H(e,"optout",r=>r.def.innerType._zod.optout),H(e,"values",r=>r.def.innerType._zod.values),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run({value:r.value,issues:[]},n);return o instanceof Promise?o.then(s=>Hf(r,s,t,n)):Hf(r,o,t,n)}});var za=b("$ZodPipe",(e,t)=>{X.init(e,t),H(e,"values",r=>r.def.in._zod.values),H(e,"optin",r=>r.def.in._zod.optin),H(e,"optout",r=>r.def.out._zod.optout),H(e,"propValues",r=>r.def.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let s=t.out._zod.run(r,n);return s instanceof Promise?s.then(i=>Jo(i,t.in,n)):Jo(s,t.in,n)}let o=t.in._zod.run(r,n);return o instanceof Promise?o.then(s=>Jo(s,t.out,n)):Jo(o,t.out,n)}});function Jo(e,t,r){return e.issues.some(n=>n.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}var qp=b("$ZodPreprocess",(e,t)=>{za.init(e,t)}),Zp=b("$ZodReadonly",(e,t)=>{X.init(e,t),H(e,"propValues",r=>r.def.innerType._zod.propValues),H(e,"values",r=>r.def.innerType._zod.values),H(e,"optin",r=>r.def.innerType?._zod?.optin),H(e,"optout",r=>r.def.innerType?._zod?.optout),e._zod.parse=(r,n)=>{if(n.direction==="backward")return t.innerType._zod.run(r,n);let o=t.innerType._zod.run(r,n);return o instanceof Promise?o.then(Wf):Wf(o)}});function Wf(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Hp=b("$ZodCustom",(e,t)=>{me.init(e,t),X.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,o=t.fn(n);if(o instanceof Promise)return o.then(s=>Vf(s,r,n,e));Vf(o,r,n,e)}});function Vf(e,t,r,n){if(!e){let o={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(o.params=n._zod.def.params),t.issues.push(Ar(o))}}var Na=class extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}},La="~memo",Wp=[];function Vp(e){return e!==null&&(typeof e=="object"||typeof e=="function")}function Da(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}var Kp=new WeakMap,En=0,ns=1,vn=2;function os(e,t,r){let n=Kp.get(e);if(n!==void 0)return n?vn:En;if(t.has(e))return vn;t.add(e);let o=En,s=l=>{if(o!==vn&&l?._zod){let d=os(l,t,r);d>o&&(o=d)}},i=(l,d)=>{let f=En;for(let p of Reflect.ownKeys(l)){let m=Object.getOwnPropertyDescriptor(l,p);if(d&&!m.enumerable)continue;let h=m.get?ns:m.value?._zod?os(m.value,t,r):En;h>f&&(f=h)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def,u=c.type;switch(u){case"object":{let l=Ir(c);a(l?i(l,!0):ns),s(c.catchall);break}case"properties":a(i(c.shape,!1));break;case"array":s(c.element);break;case"tuple":for(let l of c.items)s(l);s(c.rest);break;case"record":case"map":s(c.keyType),s(c.valueType);break;case"set":s(c.valueType);break;case"union":for(let l of c.options)s(l);break;case"intersection":s(c.left),s(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":s(c.innerType);break;case"pipe":s(c.in),s(c.out);break;case"function":s(c.input),s(c.output);break;case"lazy":{let l=c._cachedInner??(r?e._zod.innerType:void 0);a(l?os(l,t,!1):ns);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(let l in c){let d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;let f=d.value;if(!(!f||typeof f!="object")){if(f._zod)s(f);else if(Array.isArray(f))for(let p of f)s(p)}}}return t.delete(e),WE(e,o)}function WE(e,t){return t!==ns&&Kp.set(e,t===vn),t}function VE(e,t){let r=e.buckets.get(t);return r||(r=new WeakMap,e.buckets.set(t,r)),r}var ts,rs=[],KE={alloc(e,t,r){let n=ts;if(!n)return r;ts=void 0;let o={value:r,issues:null};return n.set(t.value,o),rs.push(o),r},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let r=e._zod.parse,n=(o,s)=>{if(s.direction!=="backward"&&BE(s,o.value))throw new Na;return r(o,s)};e._zod.parse=n,e._zod.run===r&&(e._zod.run=n)})},attach(e){var t;let r,n=!1,o,s;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let i=e._zod.parse,a=(c,u)=>{if(r===void 0){let y=os(e,new Set,!1);if(y===En)return e._zod.parse=i,e._zod.run===a&&(e._zod.run=i),i(c,u);y===vn||n?r=!0:n=!0}let l=c.value;if(!Vp(l))return i(c,u);let d=u[La];d||(d={buckets:new WeakMap,backEdges:void 0},u[La]=d);let f;o===u?f=s:(f=VE(d,e),o=u,s=f);let p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...Da(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;ts=f;let m=rs.length,h=i(c,u);ts=void 0;let g=rs.length>m?rs.pop():void 0;return h instanceof Promise?h.then(y=>(g&&(g.issues=y.issues.length?Da(y.issues):Wp),y)):(g&&(g.issues=h.issues.length?Da(h.issues):Wp),h)};e._zod.parse=a,e._zod.run===i&&(e._zod.run=a)})}};function Bp(){return KE}function BE(e,t){let r=e[La]?.backEdges;return r!==void 0&&Vp(t)&&r.has(t)}var GE=()=>{let e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"},map:{unit:"entries",verb:"to have"}};function t(s){return e[s]??null}let r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},n={nan:"NaN"};function o(s,i){return s==="number"&&typeof i=="number"&&!Number.isFinite(i)?String(i):n[s]??s}return s=>{switch(s.code){case"invalid_type":{let i=o(s.expected),a=ga(s.input),c=o(a,s.input);return`Invalid input: expected ${i}, received ${c}`}case"invalid_value":return s.values.length===1?`Invalid input: expected ${jo(s.values[0])}`:`Invalid option: expected one of ${No(s.values,"|")}`;case"too_big":{let i=s.exact?"exactly ":s.inclusive?"<=":"<",a=t(s.origin);return a?`Too big: expected ${s.origin??"value"} to have ${i}${s.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${s.origin??"value"} to be ${i}${s.maximum.toString()}`}case"too_small":{let i=s.exact?"exactly ":s.inclusive?">=":">",a=t(s.origin);return a?`Too small: expected ${s.origin} to have ${i}${s.minimum.toString()} ${a.unit}`:`Too small: expected ${s.origin} to be ${i}${s.minimum.toString()}`}case"invalid_format":{let i=s;return i.format==="starts_with"?`Invalid string: must start with "${i.prefix}"`:i.format==="ends_with"?`Invalid string: must end with "${i.suffix}"`:i.format==="includes"?`Invalid string: must include "${i.includes}"`:i.format==="regex"?`Invalid string: must match pattern ${i.pattern}`:`Invalid ${r[i.format]??s.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${s.divisor}`;case"unrecognized_keys":return`Unrecognized key${s.keys.length>1?"s":""}: ${No(s.keys,", ")}`;case"invalid_key":return`Invalid key in ${s.origin}`;case"invalid_union":return s.options&&Array.isArray(s.options)&&s.options.length>0?`Invalid discriminator value. Expected ${s.options.map(a=>`'${a}'`).join(" | ")}`:s.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${s.origin}`;default:return"Invalid input"}}};function Gp(){return{localeError:GE()}}var Yp;var ja=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let o={...n,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function YE(){return new ja}(Yp=globalThis).__zod_globalRegistry??(Yp.__zod_globalRegistry=YE());var cr=globalThis.__zod_globalRegistry;function Jp(e,t){return new e({type:"string",...T(t)})}function Xp(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...T(t)})}function Qp(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...T(t)})}function em(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...T(t)})}function tm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...T(t)})}function rm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...T(t)})}function nm(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...T(t)})}function om(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...T(t)})}function sm(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...T(t)})}function im(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...T(t)})}function am(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...T(t)})}function cm(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...T(t)})}function um(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...T(t)})}function lm(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...T(t)})}function dm(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...T(t)})}function fm(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...T(t)})}function pm(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...T(t)})}function mm(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...T(t)})}function hm(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...T(t)})}function gm(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...T(t)})}function _m(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...T(t)})}function ym(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...T(t)})}function Sm(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...T(t)})}function ss(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...T(t)})}function is(e,t){return new e({type:"string",format:"date",check:"string_format",...T(t)})}function as(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...T(t)})}function cs(e,t){return new e({type:"string",format:"duration",check:"string_format",...T(t)})}function bm(e,t){return new e({type:"number",checks:[],...T(t)})}function Em(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...T(t)})}function vm(e,t){return new e({type:"boolean",...T(t)})}function wm(e,t){return new e({type:"null",...T(t)})}function km(e){return new e({type:"unknown"})}function xm(e,t){return new e({type:"never",...T(t)})}function us(e,t){return new $a({check:"less_than",...T(t),value:e,inclusive:!1})}function wn(e,t){return new $a({check:"less_than",...T(t),value:e,inclusive:!0})}function ls(e,t){return new Ta({check:"greater_than",...T(t),value:e,inclusive:!1})}function kn(e,t){return new Ta({check:"greater_than",...T(t),value:e,inclusive:!0})}function ds(e,t){return new kf({check:"multiple_of",...T(t),value:e})}function fs(e,t){return new Pf({check:"max_length",...T(t),maximum:e})}function Mr(e,t){return new $f({check:"min_length",...T(t),minimum:e})}function ps(e,t){return new Tf({check:"length_equals",...T(t),length:e})}function Ua(e,t){return new Rf({check:"string_format",format:"regex",...T(t),pattern:e})}function Fa(e){return new Of({check:"string_format",format:"lowercase",...T(e)})}function qa(e){return new If({check:"string_format",format:"uppercase",...T(e)})}function Za(e,t){return new Af({check:"string_format",format:"includes",...T(t),includes:e})}function Ha(e,t){return new Cf({check:"string_format",format:"starts_with",...T(t),prefix:e})}function Wa(e,t){return new Mf({check:"string_format",format:"ends_with",...T(t),suffix:e})}function Zt(e){return new zf({check:"overwrite",tx:e})}function Va(e){return Zt(t=>t.normalize(e))}function Ka(){return Zt(e=>e.trim())}function Ba(){return Zt(e=>e.toLowerCase())}function Ga(){return Zt(e=>e.toUpperCase())}function Ya(){return Zt(e=>da(e))}function Pm(e,t,r){return new e({type:"array",element:t,...T(r)})}function $m(e,t,r){let n=T(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}function Tm(e,t,r){return new e({type:"custom",check:"custom",fn:t,...T(r)})}function Rm(e,t){let r=JE(n=>(n.addIssue=o=>{if(typeof o=="string")n.issues.push(Ar(o,n.value,r._zod.def));else{let s=o;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=r),s.continue??(s.continue=!r._zod.def.abort),n.issues.push(Ar(s))}},e(n.value,n)),t);return r}function JE(e,t){let r=new me({check:"custom",...T(t)});return r._zod.check=e,r}function xn(e,...t){for(let r of t)for(let n of Reflect.ownKeys(r))Object.prototype.propertyIsEnumerable.call(r,n)&&He(e,n,r[n]);return e}function Xa(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??cr,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function Rt(e,t,r,n,o){let s=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:n.path,message:o}):t.unrepresentable;if(s==="any")return!1;if(s===void 0||s==="throw")throw new Error(o);return Object.assign(r,s),!0}function ue(e,t,r={path:[],schemaPath:[]}){var n;let o=e._zod.def,s=t.seen.get(e);if(s)return s.count++,r.schemaPath.includes(e)&&(s.cycle=r.path),s.schema;let i={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,i),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let a=e._zod.toJSONSchema?.();if(a)i.schema=a;else{let l={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,i.schema,l);else{let f=i.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,l)}let d=e._zod.parent;d&&(i.ref||(i.ref=d),ue(d,t,l),t.seen.get(d).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&xn(i.schema,c),t.io==="input"&&Ee(e)&&(delete i.schema.examples,delete i.schema.default),t.io==="input"&&"_prefault"in i.schema&&((n=i.schema).default??(n.default=i.schema._prefault)),delete i.schema._prefault,t.seen.get(e).schema}function Om(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Qa(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;let n=new Map;for(let i of e.seen.entries()){let a=e.metadataRegistry.get(i[0])?.id;if(a){let c=n.get(a);if(c&&c!==i[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(a,i[0])}}let o=i=>{let a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){let d=e.external.registry.get(i[0])?.id,f=e.external.uri??(m=>m);if(d)return{ref:f(d)};let p=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${Om(p)}`}}let c="#",u=`${c}/${a}/`;if(i[1]===r&&!i[1].schema.id)return{ref:c};let l=i[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Om(l)}},s=i=>{if(i[1].schema.$ref)return;let a=i[1],{ref:c,defId:u}=o(i);a.def={...a.schema},u&&(a.defId=u);let l=a.schema;for(let d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(let i of e.seen.entries()){let a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
77
77
 
78
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Am(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Am(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Cm=new Set(["type","properties","required","additionalProperties"]),Om=["oneOf","anyOf"];function Im(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Ja(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Cm.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??Im(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:Ja(a)??{allOf:a};He(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=Im(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function XE(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Cm)if(o in e)return;let r=t.filter(o=>Om.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=Ja(t);else{let o=r[0],s=Om.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>Ja([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,xn(e,n))}function ec(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):xn(u,m),xn(u,l),a._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(m.$ref&&p.def)for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Am(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])XE(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}xn(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,He(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Pn(t,"input",e.processors),output:Pn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ee(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ee(n.element,r);if(n.type==="set")return Ee(n.valueType,r);if(n.type==="lazy")return Ee(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Ee(n.innerType,r);if(n.type==="intersection")return Ee(n.left,r)||Ee(n.right,r);if(n.type==="record"||n.type==="map")return Ee(n.keyType,r)||Ee(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ee(n.in,r)||Ee(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Ee(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Ee(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Ee(o,r))return!0;return!!(n.rest&&Ee(n.rest,r))}return!1}var Mm=(e,t={})=>r=>{let n=Xa({...r,processors:t});return ue(e,n),Qa(n,e),ec(n,e)},Pn=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=Xa({...o??{},target:s,io:t,processors:r});return ue(e,i),Qa(i,e),ec(i,e)};var zr=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Dr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},zm=(e,t)=>{zr(e,"minimum",t),Dr(e,"maximum",t)},jm=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Um=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Fm=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},qm=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Dm=(e,t)=>zr(e,"minimum",t.minimum),Nm=(e,t)=>Dr(e,"maximum",t.maximum),Lm=e=>(t,r)=>{qm(t,r.format);let[n,o]=e[r.format];zr(t,"minimum",n),Dr(t,"maximum",o)},QE={greater_than:(e,t)=>zr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Dr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>jm(e,t.value),number_format:Lm(mn),bigint_format:Lm(Uo),min_length:Dm,max_length:Nm,length_equals:(e,t)=>zm(e,t.length),min_size:Dm,max_size:Nm,size_equals:(e,t)=>zm(e,t.size),string_format:(e,t)=>{qm(e,t.format),t.pattern&&Um(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Fm(e,t.mime)};function Ye(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)QE[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&zr(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&zr(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Dr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Dr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&jm(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Fm(t,o.mime);for(let s of o.patterns??[])Um(t,s);return t}var ev={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},tv=new Map([[Ia,lf],[es,df]]),Zm=e=>tv.get(e)??e,Hm=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=Ye(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=ev[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(Zm);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Wm=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=Ye(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),f?p?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let m=new Set;for(let y of a)Number.isFinite(y)&&y!==0?m.add(Math.abs(y)):Rt(e,t,o,n,`A multipleOf divisor of ${y} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(o.multipleOf=h),g.length&&(o.allOf=[...o.allOf??[],...g.map(y=>({multipleOf:y}))])}},Vm=(e,t,r,n)=>{r.type="boolean"};var Km=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Bm=(e,t,r,n)=>{r.not={}};var Gm=(e,t,r,n)=>{};var Ym=(e,t,r,n)=>{let o=e._zod.def,s=Tr(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},Jm=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Rt(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Rt(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var Xm=(e,t,r,n)=>{Rt(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var Qm=(e,t,r,n)=>{Rt(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var eh=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=Ye(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ue(s.element,t,{...n,path:[...n.path,"items"]})};function ms(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?ms(t.out):t.type==="catch"?ms(t.innerType):e._zod.optin}var th=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Rt(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let l in i)He(o.properties,l,ue(i[l],t,{...n,path:[...n.path,"properties",l]}));let c=new Set(Object.keys(i)),u=new Set([...c].filter(l=>{let d=s.shape[l];return t.io==="input"?ms(d)===void 0:d._zod.optout===void 0}));u.size>0&&(o.required=Array.from(u)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ue(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)};var rh=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ue(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},nh=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=ue(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function tc(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let h=tc(e,m,r);return h===m?t:h}for(let m of["anyOf","oneOf"]){let h=t[m];if(!Array.isArray(h))continue;let g=h.map(y=>tc(e,y,r));g.some((y,E)=>y!==h[E])&&(t={...t,[m]:g})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(m=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(m=>typeof m=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(m=>typeof m=="number"?String(m):m):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",s||(p.pattern=(n.includes("number")?yn:xa).source)),p}var rc=new WeakMap;function rv(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of rc.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=tc(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var oh=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=Ye(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=ue(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)He(o.patternProperties,Zm(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=ue(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=rc.get(t);l||(l=[],rc.set(t,l),t.deferred.push(()=>rv(t))),l.push(e)}o.additionalProperties=ue(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&ms(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},sh=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},ih=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},nc=Symbol();function ah(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(Rt(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),nc):JSON.parse(i)}var ch=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=ah(o.defaultValue,e,t,r,n);i!==nc&&(r.default=i)},uh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=ah(o.defaultValue,e,t,r,n);i!==nc&&(r._prefault=i)},lh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Rt(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},dh=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;ue(i,t,n);let a=t.seen.get(e);a.ref=i},fh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var oc=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};function hs(e){return!!e._zod}function Ht(e,t){return hs(e)?va(e,t):e.safeParse(t)}function gs(e){if(!e)return;let t;if(hs(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function _s(e){if(hs(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var ph=new WeakSet([Object.prototype,Error.prototype]);function ys(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var dv=(e,t)=>{zd.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);ph.has(r)||(ph.add(r),ys(r,"format",n=>o=>Ld(n,o)),ys(r,"flatten",n=>o=>Nd(n,o)),ys(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Rr,2)}),ys(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Rr,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Ve=b("ZodError",dv,void 0,{Parent:Error});var mh=Ho(Ve),hh=Wo(Ve),gh=_n(Ve),_h=Vo(Ve),yh=Ud(Ve),Sh=Fd(Ve),bh=qd(Ve),Eh=Zd(Ve),vh=Hd(Ve),wh=Wd(Ve),kh=Vd(Ve),xh=Kd(Ve);function pv(){ze.localeError||We(Bp())}function bs(){ze.memoizer||We({memoizer:Kp()})}var ie=b("ZodType",(e,t)=>(pv(),X.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(R.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return it(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(rw(e,t))},superRefine(e,t){return this.check(nw(e,t))},overwrite(e){return this.check(Zt(e))},optional(){return se(this)},exactOptional(){return Hv(this)},nullable(){return Th(this)},nullish(){return se(Th(this))},nonoptional(e){return Yv(this,e)},array(){return U(this)},or(e){return ee([this,e])},and(e){return Es(this,e)},transform(e){return Rh(this,zh(e))},default(e){return Kv(this,e)},prefault(e){return Gv(this,e)},catch(e){return Xv(this,e)},pipe(e){return Rh(this,e)},readonly(){return tw(this)},describe(e){let t=this.clone();return cr.add(t,{description:e}),t},meta(...e){if(e.length===0)return cr.get(this);let t=this.clone();return cr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return R.hide(this,"~standard",{...Oa(this),jsonSchema:{input:Pn(this,"input"),output:Pn(this,"output")}})},set"~standard"(e){R.own(this,"~standard",e)},parse:function e(t,r){return mh(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await hh(this,t,r,{callee:e})},safeParse(e,t){return gh(this,e,t)},async safeParseAsync(e,t){return _h(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){R.own(this,"spa",e)},validate(e,t){return Ko(this,e,t)},validateAsync(e,t){return Bo(this,e,t)},encode:function e(t,r){return yh(this,t,r,{callee:e})},decode:function e(t,r){return Sh(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await bh(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await Eh(this,t,r,{callee:e})},safeEncode(e,t){return vh(this,e,t)},safeDecode(e,t){return wh(this,e,t)},async safeEncodeAsync(e,t){return kh(this,e,t)},async safeDecodeAsync(e,t){return xh(this,e,t)},toJSONSchema(e){return Mm(this,{})(e)},get description(){return cr.get(this)?.description},get _def(){return this._zod.def}}),Oh=b("_ZodString",(e,t)=>{Qo.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Hm(e,r,n,o)},R.derived({format:e=>Ye(e).format??null,minLength:e=>Ye(e).minimum??null,maxLength:e=>Ye(e).maximum??null},{regex(...e){return this.check(Ua(...e))},includes(...e){return this.check(Za(...e))},startsWith(...e){return this.check(Ha(...e))},endsWith(...e){return this.check(Wa(...e))},min(...e){return this.check(Mr(...e))},max(...e){return this.check(fs(...e))},length(...e){return this.check(ps(...e))},nonempty(...e){return this.check(Mr(1,...e))},lowercase(e){return this.check(Fa(e))},uppercase(e){return this.check(qa(e))},trim(){return this.check(Ka())},normalize(...e){return this.check(Va(...e))},toLowerCase(){return this.check(Ba())},toUpperCase(){return this.check(Ga())},slugify(){return this.check(Ya())}})),mv=b("ZodString",(e,t)=>{Qo.init(e,t),Oh.init(e,t)},{email(e){return this.check(Jp(hv,e))},url(e){return this.check(nm(_v,e))},jwt(e){return this.check(ym(Av,e))},emoji(e){return this.check(om(yv,e))},guid(e){return this.check(Xp(gv,e))},uuid(e){return this.check(Qp(Ss,e))},uuidv4(e){return this.check(em(Ss,e))},uuidv6(e){return this.check(tm(Ss,e))},uuidv7(e){return this.check(rm(Ss,e))},nanoid(e){return this.check(sm(Sv,e))},cuid(e){return this.check(im(bv,e))},cuid2(e){return this.check(am(Ev,e))},ulid(e){return this.check(cm(vv,e))},base64(e){return this.check(hm(Rv,e))},base64url(e){return this.check(gm(Ov,e))},xid(e){return this.check(um(wv,e))},ksuid(e){return this.check(lm(kv,e))},ipv4(e){return this.check(dm(xv,e))},ipv6(e){return this.check(fm(Pv,e))},cidrv4(e){return this.check(pm($v,e))},cidrv6(e){return this.check(mm(Tv,e))},e164(e){return this.check(_m(Iv,e))},datetime(e){return this.check(ss(Tn,e))},date(e){return this.check(is(Rn,e))},time(e){return this.check(as(On,e))},duration(e){return this.check(cs(In,e))}});function S(e){return Yp(mv,e)}var ae=b("ZodStringFormat",(e,t)=>{Q.init(e,t),Oh.init(e,t)}),Tn=b("ZodISODateTime",(e,t)=>{ip.init(e,t),ae.init(e,t)}),Rn=b("ZodISODate",(e,t)=>{ap.init(e,t),ae.init(e,t)}),On=b("ZodISOTime",(e,t)=>{cp.init(e,t),ae.init(e,t)}),In=b("ZodISODuration",(e,t)=>{up.init(e,t),ae.init(e,t)}),hv=b("ZodEmail",(e,t)=>{Gf.init(e,t),ae.init(e,t)});var gv=b("ZodGUID",(e,t)=>{Kf.init(e,t),ae.init(e,t)});var Ss=b("ZodUUID",(e,t)=>{Bf.init(e,t),ae.init(e,t)});var _v=b("ZodURL",(e,t)=>{Xf.init(e,t),ae.init(e,t)});var yv=b("ZodEmoji",(e,t)=>{Qf.init(e,t),ae.init(e,t)});var Sv=b("ZodNanoID",(e,t)=>{ep.init(e,t),ae.init(e,t)});var bv=b("ZodCUID",(e,t)=>{tp.init(e,t),ae.init(e,t)});var Ev=b("ZodCUID2",(e,t)=>{rp.init(e,t),ae.init(e,t)});var vv=b("ZodULID",(e,t)=>{np.init(e,t),ae.init(e,t)});var wv=b("ZodXID",(e,t)=>{op.init(e,t),ae.init(e,t)});var kv=b("ZodKSUID",(e,t)=>{sp.init(e,t),ae.init(e,t)});var xv=b("ZodIPv4",(e,t)=>{lp.init(e,t),ae.init(e,t)});var Pv=b("ZodIPv6",(e,t)=>{fp.init(e,t),ae.init(e,t)});var $v=b("ZodCIDRv4",(e,t)=>{pp.init(e,t),ae.init(e,t)});var Tv=b("ZodCIDRv6",(e,t)=>{mp.init(e,t),ae.init(e,t)});var Rv=b("ZodBase64",(e,t)=>{gp.init(e,t),ae.init(e,t)});var Ov=b("ZodBase64URL",(e,t)=>{_p.init(e,t),ae.init(e,t)});var Iv=b("ZodE164",(e,t)=>{yp.init(e,t),ae.init(e,t)});var Av=b("ZodJWT",(e,t)=>{Sp.init(e,t),ae.init(e,t)});var Ih=b("ZodNumber",(e,t)=>{Aa.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wm(e,r,n,o),e.isFinite=!0},R.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Ye(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Ye(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Ye(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Ye(e).format??null},{gt(e,t){return this.check(ls(e,t))},gte(e,t){return this.check(kn(e,t))},min(e,t){return this.check(kn(e,t))},lt(e,t){return this.check(us(e,t))},lte(e,t){return this.check(wn(e,t))},max(e,t){return this.check(wn(e,t))},int(e){return this.check(Ph(e))},safe(e){return this.check(Ph(e))},positive(e){return this.check(ls(0,e))},nonnegative(e){return this.check(kn(0,e))},negative(e){return this.check(us(0,e))},nonpositive(e){return this.check(wn(0,e))},multipleOf(e,t){return this.check(ds(e,t))},step(e,t){return this.check(ds(e,t))},finite(){return this}}));function K(e){return Sm(Ih,e)}var Cv=b("ZodNumberFormat",(e,t)=>{bp.init(e,t),Ih.init(e,t)});function Ph(e){return bm(Cv,e)}var Mv=b("ZodBoolean",(e,t)=>{Ep.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vm(e,r,n,o)});function fe(e){return Em(Mv,e)}var zv=b("ZodNull",(e,t)=>{vp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Km(e,r,n,o)});function Ah(e){return vm(zv,e)}var Dv=b("ZodUnknown",(e,t)=>{wp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gm(e,r,n,o)});function oe(){return wm(Dv)}var Nv=b("ZodNever",(e,t)=>{kp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bm(e,r,n,o)});function Lv(e){return km(Nv,e)}var jv=b("ZodArray",(e,t)=>{bs(),xp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>eh(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Mr(e,t))},nonempty(e){return this.check(Mr(1,e))},max(e,t){return this.check(fs(e,t))},length(e,t){return this.check(ps(e,t))},unwrap(){return this.element}});function U(e,t){return xm(jv,e,t)}var Ch=b("ZodObject",(e,t)=>{bs(),Tp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>th(e,r,n,o),R.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return De(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(R.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(R.mergeDefs(this._zod.def,{catchall:oe()}))},loose(){return this.clone(R.mergeDefs(this._zod.def,{catchall:oe()}))},strict(){return this.clone(R.mergeDefs(this._zod.def,{catchall:Lv()}))},strip(){return this.clone(R.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return R.extend(this,e)},safeExtend(e){return R.safeExtend(this,e)},merge(e){return R.merge(this,e)},pick(e){return R.pick(this,e)},omit(e){return R.omit(this,e)},partial(...e){return R.partial(Dh,this,e[0])},exactPartial(...e){return R.partial(Nh,this,e[0],"exactPartial")},required(...e){return R.required(Lh,this,e[0])}});function k(e,t){let r={type:"object",shape:e??{},...R.normalizeParams(t)};return new Ch(r)}function $e(e,t){return new Ch({type:"object",shape:e,catchall:oe(),...R.normalizeParams(t)})}var Mh=b("ZodUnion",(e,t)=>{Ca.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rh(e,r,n,o),e.options=t.options});function ee(e,t){return new Mh({type:"union",options:e,...R.normalizeParams(t)})}var Uv=b("ZodDiscriminatedUnion",(e,t)=>{Mh.init(e,t),Rp.init(e,t)});function ic(e,t,r){return new Uv({type:"union",options:t,discriminator:e,...R.normalizeParams(r)})}var Fv=b("ZodIntersection",(e,t)=>{Op.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nh(e,r,n,o)});function Es(e,t){return new Fv({type:"intersection",left:e,right:t})}var $h=b("ZodRecord",(e,t)=>{bs(),Ip.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oh(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function J(e,t,r){return!t||!t._zod?new $h({type:"record",keyType:S(),valueType:e,...R.normalizeParams(t)}):new $h({type:"record",keyType:e,valueType:t,...R.normalizeParams(r)})}var sc=b("ZodEnum",(e,t)=>{Ap.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Ym(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new sc({...t,checks:[],...R.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new sc({...t,checks:[],...R.normalizeParams(o),entries:s})}});function De(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new sc({type:"enum",entries:r,...R.normalizeParams(t)})}var qv=b("ZodLiteral",(e,t)=>{Cp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Jm(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function P(e,t){return new qv({type:"literal",values:Array.isArray(e)?e:[e],...R.normalizeParams(t)})}var Zv=b("ZodTransform",(e,t)=>{bs(),Mp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qm(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Cr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(R.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(R.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function zh(e){return new Zv({type:"transform",transform:e})}var Dh=b("ZodOptional",(e,t)=>{Ma.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function se(e){return new Dh({type:"optional",innerType:e})}var Nh=b("ZodExactOptional",(e,t)=>{zp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Hv(e){return new Nh({type:"optional",innerType:e})}var Wv=b("ZodNullable",(e,t)=>{Dp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Th(e){return new Wv({type:"nullable",innerType:e})}var Vv=b("ZodDefault",(e,t)=>{Np.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ch(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kv(e,t){return new Vv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var Bv=b("ZodPrefault",(e,t)=>{Lp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Gv(e,t){return new Bv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var Lh=b("ZodNonOptional",(e,t)=>{jp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ih(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Yv(e,t){return new Lh({type:"nonoptional",innerType:e,...R.normalizeParams(t)})}var Jv=b("ZodCatch",(e,t)=>{Up.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Xv(e,t){return new Jv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:R.constantCatch(t)})}var jh=b("ZodPipe",(e,t)=>{za.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dh(e,r,n,o),e.in=t.in,e.out=t.out});function Rh(e,t){return new jh({type:"pipe",in:e,out:t})}var Qv=b("ZodPreprocess",(e,t)=>{jh.init(e,t),Fp.init(e,t)}),ew=b("ZodReadonly",(e,t)=>{qp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function tw(e){return new ew({type:"readonly",innerType:e})}var Uh=b("ZodCustom",(e,t)=>{Zp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xm(e,r,n,o)});function Fh(e,t){return Pm(Uh,e??(()=>!0),t)}function rw(e,t={}){return $m(Uh,e,t)}function nw(e,t){return Tm(e,t)}function ac(e,t){return new Qv({type:"pipe",in:zh(e),out:t})}var vs={};dd(vs,{ZodISODate:()=>Rn,ZodISODateTime:()=>Tn,ZodISODuration:()=>In,ZodISOTime:()=>On,date:()=>sw,datetime:()=>ow,duration:()=>aw,time:()=>iw});function ow(e){return ss(Tn,e)}function sw(e){return is(Rn,e)}function iw(e){return as(On,e)}function aw(e){return cs(In,e)}var uc="2025-11-25";var qh=[uc,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Wt="io.modelcontextprotocol/related-task",ks="2.0",de=Fh(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Zh=ee([S(),K().int()]),Hh=S(),lz=$e({ttl:K().optional(),pollInterval:K().optional()}),cw=k({ttl:K().optional()}),uw=k({taskId:S()}),lc=$e({progressToken:Zh.optional(),[Wt]:uw.optional()}),Ke=k({_meta:lc.optional()}),An=Ke.extend({task:cw.optional()}),Wh=e=>An.safeParse(e).success,he=k({method:S(),params:Ke.loose().optional()}),Je=k({_meta:lc.optional()}),Xe=k({method:S(),params:Je.loose().optional()}),ge=$e({_meta:lc.optional()}),xs=ee([S(),K().int()]),Vh=k({jsonrpc:P(ks),id:xs,...he.shape}).strict(),dc=e=>Vh.safeParse(e).success,Kh=k({jsonrpc:P(ks),...Xe.shape}).strict(),Bh=e=>Kh.safeParse(e).success,fc=k({jsonrpc:P(ks),id:xs,result:ge}).strict(),Cn=e=>fc.safeParse(e).success;var L;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(L||(L={}));var pc=k({jsonrpc:P(ks),id:xs.optional(),error:k({code:K().int(),message:S(),data:oe().optional()})}).strict();var Gh=e=>pc.safeParse(e).success;var Yh=ee([Vh,Kh,fc,pc]),dz=ee([fc,pc]),Ps=ge.strict(),lw=Je.extend({requestId:xs.optional(),reason:S().optional()}),$s=Xe.extend({method:P("notifications/cancelled"),params:lw}),dw=k({src:S(),mimeType:S().optional(),sizes:U(S()).optional(),theme:De(["light","dark"]).optional()}),Mn=k({icons:U(dw).optional()}),Nr=k({name:S(),title:S().optional()}),Jh=Nr.extend({...Nr.shape,...Mn.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),fw=Es(k({applyDefaults:fe().optional()}),J(S(),oe())),pw=ac(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Es(k({form:fw.optional(),url:de.optional()}),J(S(),oe()).optional())),mw=$e({list:de.optional(),cancel:de.optional(),requests:$e({sampling:$e({createMessage:de.optional()}).optional(),elicitation:$e({create:de.optional()}).optional()}).optional()}),hw=$e({list:de.optional(),cancel:de.optional(),requests:$e({tools:$e({call:de.optional()}).optional()}).optional()}),gw=k({experimental:J(S(),de).optional(),sampling:k({context:de.optional(),tools:de.optional()}).optional(),elicitation:pw.optional(),roots:k({listChanged:fe().optional()}).optional(),tasks:mw.optional(),extensions:J(S(),de).optional()}),_w=Ke.extend({protocolVersion:S(),capabilities:gw,clientInfo:Jh}),mc=he.extend({method:P("initialize"),params:_w});var yw=k({experimental:J(S(),de).optional(),logging:de.optional(),completions:de.optional(),prompts:k({listChanged:fe().optional()}).optional(),resources:k({subscribe:fe().optional(),listChanged:fe().optional()}).optional(),tools:k({listChanged:fe().optional()}).optional(),tasks:hw.optional(),extensions:J(S(),de).optional()}),Sw=ge.extend({protocolVersion:S(),capabilities:yw,serverInfo:Jh,instructions:S().optional()}),hc=Xe.extend({method:P("notifications/initialized"),params:Je.optional()});var Ts=he.extend({method:P("ping"),params:Ke.optional()}),bw=k({progress:K(),total:se(K()),message:se(S())}),Ew=k({...Je.shape,...bw.shape,progressToken:Zh}),Rs=Xe.extend({method:P("notifications/progress"),params:Ew}),vw=Ke.extend({cursor:Hh.optional()}),zn=he.extend({params:vw.optional()}),Dn=ge.extend({nextCursor:Hh.optional()}),ww=De(["working","input_required","completed","failed","cancelled"]),Nn=k({taskId:S(),status:ww,ttl:ee([K(),Ah()]),createdAt:S(),lastUpdatedAt:S(),pollInterval:se(K()),statusMessage:se(S())}),Lr=ge.extend({task:Nn}),kw=Je.merge(Nn),Ln=Xe.extend({method:P("notifications/tasks/status"),params:kw}),Os=he.extend({method:P("tasks/get"),params:Ke.extend({taskId:S()})}),Is=ge.merge(Nn),As=he.extend({method:P("tasks/result"),params:Ke.extend({taskId:S()})}),fz=ge.loose(),Cs=zn.extend({method:P("tasks/list")}),Ms=Dn.extend({tasks:U(Nn)}),zs=he.extend({method:P("tasks/cancel"),params:Ke.extend({taskId:S()})}),Xh=ge.merge(Nn),Qh=k({uri:S(),mimeType:se(S()),_meta:J(S(),oe()).optional()}),eg=Qh.extend({text:S()}),gc=S().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),tg=Qh.extend({blob:gc}),jn=De(["user","assistant"]),jr=k({audience:U(jn).optional(),priority:K().min(0).max(1).optional(),lastModified:vs.datetime({offset:!0}).optional()}),rg=k({...Nr.shape,...Mn.shape,uri:S(),description:se(S()),mimeType:se(S()),size:se(K()),annotations:jr.optional(),_meta:se($e({}))}),xw=k({...Nr.shape,...Mn.shape,uriTemplate:S(),description:se(S()),mimeType:se(S()),annotations:jr.optional(),_meta:se($e({}))}),Pw=zn.extend({method:P("resources/list")}),$w=Dn.extend({resources:U(rg)}),Tw=zn.extend({method:P("resources/templates/list")}),Rw=Dn.extend({resourceTemplates:U(xw)}),_c=Ke.extend({uri:S()}),Ow=_c,Iw=he.extend({method:P("resources/read"),params:Ow}),Aw=ge.extend({contents:U(ee([eg,tg]))}),Cw=Xe.extend({method:P("notifications/resources/list_changed"),params:Je.optional()}),Mw=_c,zw=he.extend({method:P("resources/subscribe"),params:Mw}),Dw=_c,Nw=he.extend({method:P("resources/unsubscribe"),params:Dw}),Lw=Je.extend({uri:S()}),jw=Xe.extend({method:P("notifications/resources/updated"),params:Lw}),Uw=k({name:S(),description:se(S()),required:se(fe())}),Fw=k({...Nr.shape,...Mn.shape,description:se(S()),arguments:se(U(Uw)),_meta:se($e({}))}),qw=zn.extend({method:P("prompts/list")}),Zw=Dn.extend({prompts:U(Fw)}),Hw=Ke.extend({name:S(),arguments:J(S(),S()).optional()}),Ww=he.extend({method:P("prompts/get"),params:Hw}),yc=k({type:P("text"),text:S(),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),Sc=k({type:P("image"),data:gc,mimeType:S(),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),bc=k({type:P("audio"),data:gc,mimeType:S(),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),Vw=k({type:P("tool_use"),name:S(),id:S(),input:J(S(),oe()),_meta:J(S(),oe()).optional()}),Kw=k({type:P("resource"),resource:ee([eg,tg]),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),Bw=rg.extend({type:P("resource_link")}),Ec=ee([yc,Sc,bc,Bw,Kw]),Gw=k({role:jn,content:Ec}),Yw=ge.extend({description:S().optional(),messages:U(Gw)}),Jw=Xe.extend({method:P("notifications/prompts/list_changed"),params:Je.optional()}),Xw=k({title:S().optional(),readOnlyHint:fe().optional(),destructiveHint:fe().optional(),idempotentHint:fe().optional(),openWorldHint:fe().optional()}),Qw=k({taskSupport:De(["required","optional","forbidden"]).optional()}),ng=k({...Nr.shape,...Mn.shape,description:S().optional(),inputSchema:k({type:P("object"),properties:J(S(),de).optional(),required:U(S()).optional()}).catchall(oe()),outputSchema:k({type:P("object"),properties:J(S(),de).optional(),required:U(S()).optional()}).catchall(oe()).optional(),annotations:Xw.optional(),execution:Qw.optional(),_meta:J(S(),oe()).optional()}),vc=zn.extend({method:P("tools/list")}),e0=Dn.extend({tools:U(ng)}),Ds=ge.extend({content:U(Ec).default([]),structuredContent:J(S(),oe()).optional(),isError:fe().optional()}),pz=Ds.or(ge.extend({toolResult:oe()})),t0=An.extend({name:S(),arguments:J(S(),oe()).optional()}),Un=he.extend({method:P("tools/call"),params:t0}),r0=Xe.extend({method:P("notifications/tools/list_changed"),params:Je.optional()}),mz=k({autoRefresh:fe().default(!0),debounceMs:K().int().nonnegative().default(300)}),Fn=De(["debug","info","notice","warning","error","critical","alert","emergency"]),n0=Ke.extend({level:Fn}),wc=he.extend({method:P("logging/setLevel"),params:n0}),o0=Je.extend({level:Fn,logger:S().optional(),data:oe()}),s0=Xe.extend({method:P("notifications/message"),params:o0}),i0=k({name:S().optional()}),a0=k({hints:U(i0).optional(),costPriority:K().min(0).max(1).optional(),speedPriority:K().min(0).max(1).optional(),intelligencePriority:K().min(0).max(1).optional()}),c0=k({mode:De(["auto","required","none"]).optional()}),u0=k({type:P("tool_result"),toolUseId:S().describe("The unique identifier for the corresponding tool call."),content:U(Ec).default([]),structuredContent:k({}).loose().optional(),isError:fe().optional(),_meta:J(S(),oe()).optional()}),l0=ic("type",[yc,Sc,bc]),ws=ic("type",[yc,Sc,bc,Vw,u0]),d0=k({role:jn,content:ee([ws,U(ws)]),_meta:J(S(),oe()).optional()}),f0=An.extend({messages:U(d0),modelPreferences:a0.optional(),systemPrompt:S().optional(),includeContext:De(["none","thisServer","allServers"]).optional(),temperature:K().optional(),maxTokens:K().int(),stopSequences:U(S()).optional(),metadata:de.optional(),tools:U(ng).optional(),toolChoice:c0.optional()}),p0=he.extend({method:P("sampling/createMessage"),params:f0}),qn=ge.extend({model:S(),stopReason:se(De(["endTurn","stopSequence","maxTokens"]).or(S())),role:jn,content:l0}),kc=ge.extend({model:S(),stopReason:se(De(["endTurn","stopSequence","maxTokens","toolUse"]).or(S())),role:jn,content:ee([ws,U(ws)])}),m0=k({type:P("boolean"),title:S().optional(),description:S().optional(),default:fe().optional()}),h0=k({type:P("string"),title:S().optional(),description:S().optional(),minLength:K().optional(),maxLength:K().optional(),format:De(["email","uri","date","date-time"]).optional(),default:S().optional()}),g0=k({type:De(["number","integer"]),title:S().optional(),description:S().optional(),minimum:K().optional(),maximum:K().optional(),default:K().optional()}),_0=k({type:P("string"),title:S().optional(),description:S().optional(),enum:U(S()),default:S().optional()}),y0=k({type:P("string"),title:S().optional(),description:S().optional(),oneOf:U(k({const:S(),title:S()})),default:S().optional()}),S0=k({type:P("string"),title:S().optional(),description:S().optional(),enum:U(S()),enumNames:U(S()).optional(),default:S().optional()}),b0=ee([_0,y0]),E0=k({type:P("array"),title:S().optional(),description:S().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({type:P("string"),enum:U(S())}),default:U(S()).optional()}),v0=k({type:P("array"),title:S().optional(),description:S().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({anyOf:U(k({const:S(),title:S()}))}),default:U(S()).optional()}),w0=ee([E0,v0]),k0=ee([S0,b0,w0]),x0=ee([k0,m0,h0,g0]),P0=An.extend({mode:P("form").optional(),message:S(),requestedSchema:k({type:P("object"),properties:J(S(),x0),required:U(S()).optional()})}),$0=An.extend({mode:P("url"),message:S(),elicitationId:S(),url:S().url()}),T0=ee([P0,$0]),R0=he.extend({method:P("elicitation/create"),params:T0}),O0=Je.extend({elicitationId:S()}),I0=Xe.extend({method:P("notifications/elicitation/complete"),params:O0}),Ur=ge.extend({action:De(["accept","decline","cancel"]),content:ac(e=>e===null?void 0:e,J(S(),ee([S(),K(),fe(),U(S())])).optional())}),A0=k({type:P("ref/resource"),uri:S()});var C0=k({type:P("ref/prompt"),name:S()}),M0=Ke.extend({ref:ee([C0,A0]),argument:k({name:S(),value:S()}),context:k({arguments:J(S(),S()).optional()}).optional()}),z0=he.extend({method:P("completion/complete"),params:M0});var D0=ge.extend({completion:$e({values:U(S()).max(100),total:se(K().int()),hasMore:se(fe())})}),N0=k({uri:S().startsWith("file://"),name:S().optional(),_meta:J(S(),oe()).optional()}),L0=he.extend({method:P("roots/list"),params:Ke.optional()}),xc=ge.extend({roots:U(N0)}),j0=Xe.extend({method:P("notifications/roots/list_changed"),params:Je.optional()}),hz=ee([Ts,mc,z0,wc,Ww,qw,Pw,Tw,Iw,zw,Nw,Un,vc,Os,As,Cs,zs]),gz=ee([$s,Rs,hc,j0,Ln]),_z=ee([Ps,qn,kc,Ur,xc,Is,Ms,Lr]),yz=ee([Ts,p0,R0,L0,Os,As,Cs,zs]),Sz=ee([$s,Rs,s0,jw,Cw,r0,Jw,Ln,I0]),bz=ee([Ps,Sw,D0,Yw,Zw,$w,Rw,Aw,Ds,e0,Is,Ms,Lr]),A=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===L.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new cc(o.elicitations,r)}return new e(t,r,n)}},cc=class extends A{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(L.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Vt(e){return e==="completed"||e==="failed"||e==="cancelled"}var Qz=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Pc(e){let r=gs(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=_s(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function $c(e,t){let r=Ht(e,t);if(!r.success)throw r.error;return r.data}var W0=6e4,Ns=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler($s,r=>{this._oncancel(r)}),this.setNotificationHandler(Rs,r=>{this._onprogress(r)}),this.setRequestHandler(Ts,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Os,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(L.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(As,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,f=new A(d.error.code,d.error.message,d.error.data);l(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new A(L.InvalidParams,`Task not found: ${s}`);if(!Vt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Vt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Wt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Cs,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new A(L.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(zs,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(L.InvalidParams,`Task not found: ${r.params.taskId}`);if(Vt(o.status))throw new A(L.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new A(L.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof A?o:new A(L.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),A.fromError(L.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Cn(s)||Gh(s)?this._onresponse(s):dc(s)?this._onrequest(s,i):Bh(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=A.fromError(L.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[Wt]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:L.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(t.id,i);let a=Wh(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(i.signal.aborted)throw new A(L.ConnectionClosed,"Request was cancelled");let p={...f,relatedRequestId:t.id};s&&!p.relatedTask&&(p.relatedTask={taskId:s});let m=p.relatedTask?.taskId??s;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,p)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.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:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:L.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(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Cn(t))n(t);else{let i=new A(t.error.code,t.error.message,t.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(Cn(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),Cn(t))o(t);else{let i=A.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof A?i:new A(L.InternalError,String(i))}}return}let s;try{let i=await this.request(t,Lr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new A(L.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Vt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new A(L.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new A(L.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof A?i:new A(L.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=E=>{l(E)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(E){d(E);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Wt]:c}});let m=E=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(E)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(I=>this._onerror(new Error(`Failed to send cancellation: ${I}`)));let v=E instanceof A?E:new A(L.RequestTimeout,String(E));l(v)};this._responseHandlers.set(f,E=>{if(!n?.signal?.aborted){if(E instanceof Error)return l(E);try{let v=Ht(r,E.result);v.success?u(v.data):l(v.error)}catch(v){l(v)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??W0,g=()=>m(A.fromError(L.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let E=v=>{let I=this._responseHandlers.get(f);I?I(v):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,E),this._enqueueTaskMessage(y,{type:"request",message:p,timestamp:Date.now()}).catch(v=>{this._cleanupTimeout(f),l(v)})}else this._transport.send(p,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(E=>{this._cleanupTimeout(f),l(E)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Is,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Ms,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Xh,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Wt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Wt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Wt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=Pc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=$c(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=Pc(t);this._notificationHandlers.set(n,o=>{let s=$c(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&dc(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new A(L.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new A(L.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new A(L.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new A(L.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=Ln.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Vt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new A(L.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Vt(a.status))throw new A(L.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=Ln.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Vt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function og(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function sg(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];og(i)&&og(s)?r[o]={...i,...s}:r[o]=s}return r}var sS=Lt(yl(),1),iS=Lt(oS(),1);function rO(){let e=new sS.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,iS.default)(e),e}var bi=class{constructor(t){this._ajv=t??rO()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Ei=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(s.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==d.size||![...l].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},qn,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},Ur,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function aS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function cS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var vi=class extends Ns{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Fn.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 bi,this.setRequestHandler(mc,n=>this._oninitialize(n)),this.setNotificationHandler(hc,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(wc,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Fn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Ei(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=sg(this._capabilities,t)}setRequestHandler(t,r){let o=gs(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=_s(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Ht(Un,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new A(L.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=Ht(Lr,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new A(L.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=Ht(Ds,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new A(L.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){cS(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&aS(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:qh.includes(r)?r:uc,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"},Ps)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},kc,r):this.request({method:"sampling/createMessage",params:t},qn,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},Ur,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Ur,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new A(L.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof A?i:new A(L.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},xc,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var Pl=Lt(require("node:process"),1);var nO=10*1024*1024,wi=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??nO}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
79
- `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),oO(r)}clear(){this._buffer=void 0}};function oO(e){return Yh.parse(JSON.parse(e))}function uS(e){return JSON.stringify(e)+`
80
- `}var ki=class{constructor(t=Pl.default.stdin,r=Pl.default.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new wi({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=uS(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Ae=Lt(require("path"),1);var Ce=require("fs");var $l=require("node:child_process");function xi(e,t,r){return(0,$l.spawn)(e,t??[],{windowsHide:!0,...r})}var sO=new Set([".cmd",".bat"]),iO=new Set([".exe",".com"]),T1=new Set([...iO,...sO]);ne();var Oe={HEALTH_CHECK:3e3,API_REQUEST:3e4,HOOK_READINESS_WAIT:1e4,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5};function tr(e){return process.platform==="win32"?Math.round(e*Oe.WINDOWS_MULTIPLIER):e}var Pi=require("fs"),Tl=require("path"),Eo=require("os");Pr();var aO="security_alert",ht=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5-20251001",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:String(37700+(process.getuid?.()??77)%100),CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_API_TIMEOUT_MS:String(tr(Oe.API_REQUEST)),CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"subscription",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-flash-latest",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_BASE_URL:"",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_DATA_DIR:(0,Tl.join)((0,Eo.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CLAUDE_CONFIG_DIR:"",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,Tl.join)((0,Eo.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_OBSERVER_MAX_CONVERSATION_CHARS:"400000",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_FOLDER_MD_SKELETON_DENYLIST:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_TIER_FAST_MODEL:"haiku",CLAUDE_MEM_TIER_SMART_MODEL:"sonnet",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_CHROMA_MODE:"local",CLAUDE_MEM_CHROMA_HOST:"127.0.0.1",CLAUDE_MEM_CHROMA_PORT:"8000",CLAUDE_MEM_CHROMA_SSL:"false",CLAUDE_MEM_CHROMA_API_KEY:"",CLAUDE_MEM_CHROMA_TENANT:"default_tenant",CLAUDE_MEM_CHROMA_DATABASE:"default_database",CLAUDE_MEM_CHROMA_PREWARM_TIMEOUT_MS:"120000",CLAUDE_MEM_CHROMA_MAX_PENDING_MUTATIONS:"5000",CLAUDE_MEM_CLOUD_SYNC_TOKEN:"",CLAUDE_MEM_CLOUD_SYNC_USER_ID:"",CLAUDE_MEM_CLOUD_SYNC_HUB_URL:"",CLAUDE_MEM_CLOUD_SYNC_DEVICE_ID:"",CLAUDE_MEM_CLOUD_SYNC_DEVICE_NAME:(0,Eo.hostname)(),CLAUDE_MEM_CLOUD_SYNC_WS:"true",CLAUDE_MEM_CLOUD_SYNC_CONTENT_BATCH_SIZE:"40",CLAUDE_MEM_CLOUD_SYNC_REQUEST_TIMEOUT_MS:"90000",CLAUDE_MEM_TV_TOKEN:"",CLAUDE_MEM_PRO_TRIAL_EMAIL:"",CLAUDE_MEM_PRO_TRIAL_AT:"",CLAUDE_MEM_PRO_TRIAL_STATE:"",CLAUDE_MEM_PRO_TRIAL_ENDS_AT:"",CLAUDE_MEM_PRO_PLAN:"",CLAUDE_MEM_PRO_FALLBACK_AT:"",CLAUDE_MEM_PRO_MEMORY_KEY:"",CLAUDE_MEM_PRO_MEMORY_BASE_URL:"",CLAUDE_MEM_PRO_MEMORY_MODEL:"",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert,sensitive",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_GROK_BOT_AWARENESS_ENABLED:"true",CLAUDE_MEM_GROK_BOT_AWARENESS_AGENT_IDS:"521e962d-2ec3-4488-bfbc-54d5209ce118,95601360-61f7-4fd9-bb3a-2c976b2b85c0",CLAUDE_MEM_GROK_BOT_AWARENESS_TRIGGER_TYPES:"decision,bugfix,security_alert,sensitive",CLAUDE_MEM_GROK_BOT_AWARENESS_TRIGGER_CONCEPTS:"",CLAUDE_MEM_CCS_ALIGN_ENABLED:"true",CLAUDE_MEM_CCS_ALIGN_VIEWER_IDS:"ccs-align",CLAUDE_MEM_CCS_ALIGN_TRIGGER_TYPES:"decision,bugfix,security_alert,sensitive",CLAUDE_MEM_CCS_ALIGN_PATCH_SHADOWS:"false",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_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_API_KEY:"",CLAUDE_MEM_SERVER_PROJECT_ID:"",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(t){let r=process.env[t]??this.DEFAULTS[t];return t==="CLAUDE_MEM_WORKER_HOST"?this.normalizeWorkerHost(r):r}static normalizeWorkerHost(t){return t==="localhost"?"127.0.0.1":t}static finalizeSettings(t,r){let n=r?this.applyEnvOverrides(t):t;return n.CLAUDE_MEM_WORKER_HOST=this.normalizeWorkerHost(n.CLAUDE_MEM_WORKER_HOST),n}static getInt(t){let r=this.get(t);return parseInt(r,10)}static applyEnvOverrides(t){let r={...t};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(t,r=!0){try{if(!(0,Pi.existsSync)(t)){let u=this.getAllDefaults();try{dn(t,u),console.warn("[SETTINGS] Created settings file with defaults:",t)}catch(l){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",t,l instanceof Error?l.message:String(l))}return this.finalizeSettings(u,r)}let n=(0,Pi.readFileSync)(t,"utf-8"),o=or(n),s=o,i=o.env&&typeof o.env=="object"&&!Array.isArray(o.env),a=i&&Object.keys(o).some(u=>u!=="env");if(i&&(s=o.env,!a))try{dn(t,s),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",t)}catch(u){console.warn("[SETTINGS] Failed to auto-migrate settings file:",t,u instanceof Error?u.message:String(u))}if(s.CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES===aO){s={...s,CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:this.DEFAULTS.CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES};try{dn(t,a?{...o,env:s}:s),console.warn("[SETTINGS] Migrated Telegram trigger types off the legacy default:",t)}catch(u){console.warn("[SETTINGS] Failed to migrate Telegram trigger types:",t,u instanceof Error?u.message:String(u))}}let c={...this.DEFAULTS};for(let u of Object.keys(this.DEFAULTS))s[u]!==void 0&&(c[u]=s[u]);return this.finalizeSettings(c,r)}catch(n){console.warn("[SETTINGS] Failed to load settings, using defaults:",t,n instanceof Error?n.message:String(n));let o=this.getAllDefaults();return this.finalizeSettings(o,r)}}};Ze();Ze();var $i=null;function Ti(){return $i!==null||($i=ht.loadFromFile(Do)),$i}var vr=require("fs");ne();var Dt=require("fs"),Ml=Lt(require("path"),1);ne();var cO=["CLAUDECODE_","CLAUDE_CODE_"],uO=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),lO=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","npm_config_noproxy"]),dO=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","CLAUDE_CODE_USE_FOUNDRY","CLAUDE_CODE_SKIP_BEDROCK_AUTH","CLAUDE_CODE_SKIP_VERTEX_AUTH","CLAUDE_CODE_SKIP_FOUNDRY_AUTH","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",...lO]);function Er(e=process.env){let t={};for(let[r,n]of Object.entries(e))if(n!==void 0){if(dO.has(r)){t[r]=n;continue}uO.has(r)||cO.some(o=>r.startsWith(o))||(t[r]=n)}return t}Ze();var Ol=require("child_process"),dS=require("fs");ne();var fO=5e3,lS=new Map,Rl=0;function pO(e){Rl+=1;let t=(0,Ol.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${e}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...Er(process.env),LC_ALL:"C",LANG:"C"}});if(t.status===0){let r=t.stdout.trim();return r.length>0?r:null}return null}function mO(e,t=!1){if(!t){let n=lS.get(e);if(n&&Date.now()-n.capturedAtMs<fO)return n.token}let r=null;try{r=pO(e)}catch(n){_.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:e,error:n instanceof Error?n.message:String(n)}),r=null}return lS.set(e,{token:r,capturedAtMs:Date.now()}),r}function fS(e,t){if(!Number.isInteger(e)||e<=0)return null;if(process.platform==="linux"){Rl+=1;try{let r=(0,dS.readFileSync)(`/proc/${e}/stat`,"utf-8"),n=r.lastIndexOf(") ");if(n<0)return null;let s=r.slice(n+2).split(" ")[19];return s&&/^\d+$/.test(s)?s:null}catch(r){return _.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:e,error:r instanceof Error?r.message:String(r)}),null}}if(process.platform==="win32")return mO(e,t);Rl+=1;try{let r=(0,Ol.spawnSync)("ps",["-p",String(e),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...Er(process.env),LC_ALL:"C",LANG:"C"}});if(r.status!==0)return null;let n=r.stdout.trim();return n.length>0?n:null}catch(r){return _.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:e,error:r instanceof Error?r.message:String(r)}),null}}function rr(e){return fS(e,!1)}function zt(e,t){if(t===null)return!0;let r=fS(e,!0);return r===null?!0:r===t}var pS=require("child_process"),Ii=require("fs"),mS=require("util");ne();var Il=(0,mS.promisify)(pS.execFile),hO=128,gO=/not found|no running instance|no tasks/i,Ri=class extends Error{pid;constructor(t,r,n){super(r,n),this.name="ProcessTreeKillError",this.pid=t}};async function gt(e,t={}){let r=t.signalMode==="immediate",n=t.expectedStartToken!==void 0?t.expectedStartToken:rr(e),o=()=>zt(e,n);if(!o()){_.warn("PROCESS","Skipping tree-kill: root PID was reused since it was captured",{pid:e});return}if(_.debug("PROCESS",`Killing process tree rooted at PID ${e}`,{immediate:r}),process.platform==="win32"){try{await Il("taskkill",["/PID",String(e),"/T","/F"],{timeout:5e3,windowsHide:!0})}catch(s){let i=s.code,a=String(s.stderr??""),c=s instanceof Error?s.message:String(s);if(i===hO||gO.test(`${a} ${c}`)){_.debug("PROCESS","taskkill reported the process was already gone",{pid:e});return}throw new Ri(e,`taskkill failed for PID ${e} (exit ${String(i)}): ${a.trim()||c}`,{cause:s})}return}try{let s=r?"SIGKILL":"SIGTERM",i=await Oi(e);for(let u of i){if(!zt(u.pid,u.startToken)){_.debug("PROCESS",`Skipping ${s}: descendant PID was reused since enumeration`,{pid:u.pid,rootPid:e});continue}try{process.kill(u.pid,s)}catch{}}if(o())try{process.kill(e,s)}catch(u){let l=u instanceof Error?u:new Error(String(u)),d=l.code;d!=="ESRCH"&&_.debug("PROCESS",`Failed to ${s} PID ${e}`,{code:d},l)}else _.warn("PROCESS","Skipping root signal: PID was reused during descendant enumeration",{pid:e,signal:s});r||await new Promise(u=>setTimeout(u,500));let a=o()?await Oi(e):[],c=new Map;for(let u of i)c.set(u.pid,u.startToken);for(let u of a)c.set(u.pid,u.startToken);for(let[u,l]of c){if(!zt(u,l)){_.debug("PROCESS","Skipping SIGKILL: descendant PID was reused since the scan",{pid:u,rootPid:e});continue}try{process.kill(u,"SIGKILL")}catch{}}if(!r&&o())try{process.kill(e,"SIGKILL")}catch{}}catch(s){throw new Ri(e,`tree-kill failed for PID ${e}: ${s instanceof Error?s.message:String(s)}`,{cause:s})}}async function _O(){return process.platform==="win32"?bO():process.platform==="linux"?yO():SO()}function yO(){let e=[],t;try{t=(0,Ii.readdirSync)("/proc")}catch(r){return _.warn("PROCESS","Cannot read /proc \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),e}for(let r of t){if(!/^\d+$/.test(r))continue;let n;try{n=(0,Ii.readFileSync)(`/proc/${r}/stat`,"utf-8")}catch{continue}let o=n.lastIndexOf(") ");if(o<0)continue;let s=n.slice(o+2).split(" "),i=Number.parseInt(s[1]??"",10),a=s[19];Number.isFinite(i)&&e.push({pid:Number.parseInt(r,10),ppid:i,startToken:a&&/^\d+$/.test(a)?a:null})}return e}async function SO(){let e;try{e=(await Il("ps",["-eo","pid=,ppid=,lstart="],{timeout:1e4,maxBuffer:33554432,env:{...process.env,LC_ALL:"C",LANG:"C"}})).stdout}catch(r){return _.warn("PROCESS","Cannot enumerate the process table \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),[]}let t=[];for(let r of e.split(`
81
- `)){let n=r.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/);if(!n)continue;let o=n[3].trim();t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),startToken:o.length>0?o:null})}return t}async function bO(){let e;try{e=(await Il("powershell.exe",["-NoProfile","-NonInteractive","-Command","Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,@{Name='StartToken';Expression={$_.CreationDate.ToString('yyyyMMddHHmmss.ffffff')}} | ConvertTo-Csv -NoTypeInformation"],{timeout:3e4,windowsHide:!0,maxBuffer:33554432})).stdout}catch(r){return _.warn("PROCESS","Cannot enumerate the Windows process table \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),[]}let t=[];for(let r of e.split(/\r?\n/).slice(1)){let n=r.match(/^"(\d+)","(\d+)","(.*)"$/);if(!n)continue;let o=n[3].trim();t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),startToken:o.length>0?o:null})}return t}async function Oi(e){let t=await _O(),r=new Map;for(let i of t){let a=r.get(i.ppid);a?a.push(i):r.set(i.ppid,[i])}let n=new Set([e]),o=[],s=i=>{for(let a of r.get(i)??[])n.has(a.pid)||(n.add(a.pid),s(a.pid),o.push({pid:a.pid,startToken:a.startToken}))};return s(e),o}var EO=5e3,vO=1e3,wO=qe.supervisorRegistry();function pe(e){if(!Number.isInteger(e)||e<0||e===0)return!1;try{return process.kill(e,0),!0}catch(t){if(t instanceof Error){let r=t.code;return r==="EPERM"?!0:(_.debug("SYSTEM","PID check failed",{pid:e,code:r}),!1)}return _.warn("SYSTEM","PID check threw non-Error",{pid:e,error:String(t)}),!1}}async function Ai(e,t){let r=Date.now()+t;for(;Date.now()<r;){if(e.every(n=>!pe(n.pid)))return;await new Promise(n=>setTimeout(n,100))}}function Dl(e){if(!e||!pe(e.pid))return!1;if(!e.startToken)return!0;let t=rr(e.pid);if(t===null)return!0;let r=t===e.startToken;return r||_.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:e.pid,stored:e.startToken,current:t}),r}var zl=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(t=wO){this.registryPath=t}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,Dt.mkdirSync)(Ml.default.dirname(this.registryPath),{recursive:!0}),!(0,Dt.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,Dt.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?_.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):_.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let t=this.pruneDeadEntries();t>0&&_.info("SYSTEM","Removed dead processes from supervisor registry",{removed:t}),this.persist()}register(t,r,n){this.initialize(),this.entries.set(t,r),n&&this.runtimeProcesses.set(t,n),this.persist()}unregister(t){this.initialize();let r=this.entries.get(t);this.entries.delete(t),this.runtimeProcesses.delete(t),this.persist(),r?.type==="sdk"&&Cl()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([t,r])=>({id:t,...r})).sort((t,r)=>{let n=Date.parse(t.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(t){let r=String(t);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(t){return this.runtimeProcesses.get(t)}pruneDeadEntries(){this.initialize();let t=0,r=0;for(let[n,o]of this.entries)pe(o.pid)||(this.entries.delete(n),this.runtimeProcesses.delete(n),t+=1,o.type==="sdk"&&(r+=1));t>0&&this.persist();for(let n=0;n<r;n+=1)Cl();return t}async reapSession(t){this.initialize();let r=this.getBySession(t);if(r.length===0)return 0;let n=typeof t=="number"?t:Number(t)||void 0;_.info("SYSTEM",`Reaping ${r.length} process(es) for session ${t}`,{sessionId:n,pids:r.map(a=>a.pid)});let o=r.filter(a=>pe(a.pid)),s=new Map(o.map(a=>[a.pid,rr(a.pid)]));for(let a of o)try{process.platform==="win32"?await gt(a.pid,{expectedStartToken:s.get(a.pid)??null}):typeof a.pgid=="number"?process.kill(-a.pgid,"SIGTERM"):process.kill(a.pid,"SIGTERM")}catch(c){c instanceof Error?c.code!=="ESRCH"&&_.debug("SYSTEM",`Failed to SIGTERM session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):_.warn("SYSTEM",`Failed to SIGTERM session process PID ${a.pid} (non-Error)`,{pid:a.pid,pgid:a.pgid,error:String(c)})}await Ai(o,EO);let i=o.filter(a=>pe(a.pid));for(let a of i){_.warn("SYSTEM",`Session process PID ${a.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:a.pid,pgid:a.pgid,sessionId:n});let c=s.get(a.pid)??null;if(!zt(a.pid,c)){_.warn("SYSTEM","Skipping SIGKILL: session process PID was reused during the grace window",{pid:a.pid,sessionId:n});continue}try{process.platform==="win32"?await gt(a.pid,{expectedStartToken:c}):typeof a.pgid=="number"?process.kill(-a.pgid,"SIGKILL"):process.kill(a.pid,"SIGKILL")}catch(u){u instanceof Error?u.code!=="ESRCH"&&_.debug("SYSTEM",`Failed to SIGKILL session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},u):_.warn("SYSTEM",`Failed to SIGKILL session process PID ${a.pid} (non-Error)`,{pid:a.pid,pgid:a.pgid,error:String(u)})}}if(i.length>0){let a=Date.now()+vO;for(;Date.now()<a&&i.filter(u=>pe(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"&&Cl();return _.info("SYSTEM",`Reaped ${r.length} process(es) for session ${t}`,{sessionId:n,reaped:r.length}),r.length}persist(){let t={processes:Object.fromEntries(this.entries.entries())};(0,Dt.mkdirSync)(Ml.default.dirname(this.registryPath),{recursive:!0}),(0,Dt.writeFileSync)(this.registryPath,JSON.stringify(t,null,2))}},Al=null;function Ci(){return Al||(Al=new zl),Al}var Y1=180*1e3,kO=[];function Cl(){let e=kO.shift();e&&e.notify()}var on=require("fs");ne();Ze();var xO=qe.workerPid();async function gS(e){let t=e.currentPid??process.pid,r=e.pidFilePath??xO,n=e.registry.getAll(),o=[...n].filter(c=>c.pid!==t).sort((c,u)=>Date.parse(u.startedAt)-Date.parse(c.startedAt)),s=new Map,i=new Map;for(let c of o){if(!pe(c.pid)){e.registry.unregister(c.id);continue}i.set(c.id,rr(c.pid)),s.set(c.id,await Oi(c.pid));try{await hS(c,"SIGTERM")}catch(u){u instanceof Error?_.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:c.pid,pgid:c.pgid,type:c.type},u):_.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:c.pid,pgid:c.pgid,type:c.type,error:String(u)})}}await Ai(o,5e3);let a=o.filter(c=>pe(c.pid)||(s.get(c.id)??[]).some(u=>pe(u.pid)));for(let c of a){let u=zt(c.pid,i.get(c.id)??null);u||_.warn("SYSTEM","Skipping tree-kill: root PID was reused during the grace window",{pid:c.pid,type:c.type});try{u&&await hS(c,"SIGKILL")}catch(l){l instanceof Error?_.debug("SYSTEM","Failed to force kill child process",{pid:c.pid,pgid:c.pgid,type:c.type},l):_.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:c.pid,pgid:c.pgid,type:c.type,error:String(l)})}finally{PO(s.get(c.id)??[],c.pid)}}await Ai(a,1e3);for(let c of o)e.registry.unregister(c.id);for(let c of n.filter(u=>u.pid===t))e.registry.unregister(c.id);_S(r,t),e.registry.pruneDeadEntries()}function _S(e,t,r=!1){if(!(0,on.existsSync)(e))return;let n=null;try{let i=JSON.parse((0,on.readFileSync)(e,"utf-8"));n=typeof i.pid=="number"?i.pid:null}catch(i){_.debug("SYSTEM","PID file unreadable \u2014 leaving it (cannot prove ownership)",{pidFilePath:e,error:i instanceof Error?i.message:String(i)});return}let o=t!==null&&n===t,s=n===null||!pe(n);if(!o&&!(r&&s)){_.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:e,recordedPid:n,currentPid:t});return}try{(0,on.rmSync)(e,{force:!0})}catch(i){i instanceof Error?_.debug("SYSTEM","Failed to remove PID file",{pidFilePath:e},i):_.warn("SYSTEM","Failed to remove PID file (non-Error)",{pidFilePath:e,error:String(i)})}}function PO(e,t){for(let{pid:r,startToken:n}of e)if(!(r===t||!pe(r))){if(!zt(r,n)){_.debug("SYSTEM","Skipping reap: PID was recycled during the grace window",{pid:r,rootPid:t});continue}try{process.kill(r,"SIGKILL"),_.debug("SYSTEM","Reaped orphaned descendant during shutdown cascade",{pid:r,rootPid:t})}catch(o){let s=o instanceof Error?o.code:void 0;s!=="ESRCH"&&_.warn("SYSTEM","Failed to reap orphaned descendant during shutdown cascade",{pid:r,rootPid:t,errno:s})}}}async function hS(e,t){let{pid:r,pgid:n}=e;if(process.platform!=="win32"){if(typeof n=="number")try{process.kill(-n,t);return}catch(o){if((o instanceof Error?o.code:void 0)!=="ESRCH")throw o}if(t==="SIGKILL"){await gt(r,{signalMode:"immediate"});return}try{process.kill(r,t)}catch(o){if((o instanceof Error?o.code:void 0)!=="ESRCH")throw o}return}await gt(r)}ne();var yS=3e4,sn=null;function $O(){let t=Ci().pruneDeadEntries();t>0&&_.info("SYSTEM",`Health check: pruned ${t} dead process(es) from registry`)}function SS(){sn===null&&(sn=setInterval($O,yS),sn.unref(),_.debug("SYSTEM","Health checker started",{intervalMs:yS}))}function bS(){sn!==null&&(clearInterval(sn),sn=null,_.debug("SYSTEM","Health checker stopped"))}var ES=require("child_process"),vS=require("util");ne();var TO=(0,vS.promisify)(ES.execFile),RO=/(?:^|\/)(?:uvx|uv|python[\d.]*)(?:\s|$).*chroma-mcp/;function OO(e){let t=[];for(let r of e.split(`
82
- `)){let n=r.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/);n&&t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),command:n[3].trim()})}return t}async function IO(){let e=await TO("ps",["-eo","pid=,ppid=,command="],{timeout:1e4,maxBuffer:33554432});return OO(e.stdout)}function AO(e,t){let r=e.filter(i=>RO.test(i.command)&&i.pid!==t.selfPid),n=new Set(r.map(i=>i.pid)),o=r.filter(i=>!n.has(i.ppid)),s=o.filter(i=>i.ppid===t.selfPid?!1:i.ppid===1?!0:!t.isAlive(i.ppid));return{matched:r,roots:o,orphans:s}}async function wS(e={}){let t=e.platform??process.platform,r={matched:0,trees:0,orphans:0,killed:0,failed:0,unregistered:0,skipped:null};if(t==="win32")return r.skipped="windows",r;let n=e.readTable??IO,o=e.isAlive??pe,s=e.killTree??(p=>gt(p,{signalMode:"graceful"})),i=e.selfPid??process.pid,a;try{a=await n()}catch(p){return _.warn("PROCESS","Orphaned chroma-mcp sweep skipped: cannot read the process table",{error:p instanceof Error?p.message:String(p)}),r.skipped="unreadable",r}let{matched:c,roots:u,orphans:l}=AO(a,{isAlive:o,selfPid:i});if(r.matched=c.length,r.trees=u.length,r.orphans=l.length,l.length===0)return _.debug("PROCESS","No orphaned chroma-mcp trees found",{matched:r.matched,trees:r.trees}),r;_.warn("PROCESS","Reaping orphaned chroma-mcp trees left by dead workers",{orphans:l.length,roots:l.map(p=>p.pid)});let d=new Set,f=8;for(let p=0;p<l.length;p+=f){let m=l.slice(p,p+f);(await Promise.allSettled(m.map(g=>s(g.pid)))).forEach((g,y)=>{let E=m[y];g.status==="fulfilled"?(r.killed+=1,d.add(E.pid)):(r.failed+=1,_.warn("PROCESS","Failed to reap an orphaned chroma-mcp tree",{pid:E.pid,ppid:E.ppid,error:g.reason instanceof Error?g.reason.message:String(g.reason)}))})}if(e.registry)for(let p of e.registry.getAll())p.type==="chroma"&&d.has(p.pid)&&(e.registry.unregister(p.id),r.unregistered+=1);return _.info("PROCESS","Orphaned chroma-mcp sweep finished",{orphans:r.orphans,killed:r.killed,failed:r.failed,unregistered:r.unregistered}),r}Ze();var CO=qe.workerPid(),Nl=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(t){this.registry=t}async start(){if(this.started)return;if(this.registry.initialize(),Mi({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,wS({registry:this.registry}).catch(r=>{_.warn("PROCESS","Orphaned chroma-mcp sweep failed",{error:r instanceof Error?r.message:String(r)})}),SS()}configureSignalHandlers(t){if(this.shutdownHandler=t,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){_.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,_.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?_.error("SYSTEM","Error during shutdown",{},o):_.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?_.debug("SYSTEM","Supervisor shutdown fallback failed",{},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",()=>{_.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}bS(),this.stopPromise=gS({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(t){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${t}`)}registerProcess(t,r,n){this.registry.register(t,r,n)}unregisterProcess(t){this.registry.unregister(t)}getRegistry(){return this.registry}},MO=new Nl(Ci());function Ll(){return MO}function Mi(e={}){let t=e.pidFilePath??CO;if(!(0,vr.existsSync)(t))return"missing";let r=null;try{r=JSON.parse((0,vr.readFileSync)(t,"utf-8"))}catch(o){return o instanceof Error?_.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t},o):_.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t,error:String(o)}),(0,vr.rmSync)(t,{force:!0}),"invalid"}return Dl(r)&&r?((e.logAlive??!0)&&_.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(_.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,vr.rmSync)(t,{force:!0}),"stale")}Co();Ze();Pr();ne();ne();var Nt=Lt(require("path"),1),PS=require("os"),Ie=require("fs"),vo=require("child_process");ne();ne();ne();Ze();var rF=qe.dataDir(),kS=qe.workerPid(),xS="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.";function zO(e){try{return(0,Ie.realpathSync)(e)}catch{return null}}function jl(e){return e?/(^|[\\/])bun(\.exe)?$/i.test(e.trim()):!1}function DO(e,t){let r=t==="win32"?`where ${e}`:`which ${e}`,n;try{n=(0,vo.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?_.debug("SYSTEM",`Binary lookup failed for ${e}`,{command:r},s):_.debug("SYSTEM",`Binary lookup failed for ${e}`,{command:r},new Error(String(s))),null}return n.split(/\r?\n/).map(s=>s.trim()).find(s=>s.length>0)||null}var Ul;function Fl(e={}){let t=Object.keys(e).length===0;if(t&&Ul!==void 0)return Ul;let r=NO(e);return t&&r!==null&&(Ul=r),r}function NO(e){let t=e.platform??process.platform,r=e.execPath??process.execPath;if(jl(r))return r;let n=e.env??process.env,o=e.homeDirectory??(0,PS.homedir)(),s=e.pathExists??Ie.existsSync,i=e.lookupInPath??DO,a=e.realpath??zO,c=t==="win32"?[n.BUN,n.BUN_PATH,Nt.default.join(o,".bun","bin","bun.exe"),Nt.default.join(o,".bun","bin","bun"),n.USERPROFILE?Nt.default.join(n.USERPROFILE,".bun","bin","bun.exe"):void 0,n.LOCALAPPDATA?Nt.default.join(n.LOCALAPPDATA,"bun","bun.exe"):void 0,n.LOCALAPPDATA?Nt.default.join(n.LOCALAPPDATA,"bun","bin","bun.exe"):void 0,n.npm_config_prefix?Nt.default.join(n.npm_config_prefix,"bun.exe"):void 0]:[n.BUN,n.BUN_PATH,Nt.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",n.npm_config_prefix?Nt.default.join(n.npm_config_prefix,"bin","bun"):void 0];for(let d of c){let f=d?.trim();if(f&&(jl(f)&&s(f)||f.toLowerCase()==="bun"))return f}let u=i("bun",t)?.trim();if(!u||!jl(u))return null;let l=a(u)??u;return s(l)?l:null}function wr(e){return process.platform==="win32"?Math.round(e*2):e}function $S(){let e=qe.dataDir();return(0,Ie.mkdirSync)(e,{recursive:!0}),e}function LO(e,t,r=$S()){let n=o=>o.replace(/'/g,"''");return`Start-Process -FilePath '${n(e)}' -ArgumentList @('"${n(t)}"','--daemon') -WorkingDirectory '${n(r)}' -WindowStyle Hidden`}var jO=5e3,UO=8;function FO(e,t,r){return e?.code!=="ETIMEDOUT"?!1:t<r/2}function TS(e,t=wr(jO)){let r=Fl();if(!r)return;let n=()=>{let a=Date.now();try{return{result:(0,vo.spawnSync)(r,[e,"status"],{encoding:"utf-8",timeout:t,windowsHide:!0,env:Er({...process.env})}),elapsedMs:Date.now()-a}}catch(c){let u=c instanceof Error?c:new Error(String(c));_.debug("SYSTEM","Worker boot probe could not be launched",{scriptPath:e},u);return}},o=n();if(o===void 0||FO(o.result.error,o.elapsedMs,t)&&(_.debug("SYSTEM","Worker boot probe timed out before it could run \u2014 retrying once",{scriptPath:e,elapsedMs:o.elapsedMs,timeoutMs:t}),o=n(),o===void 0))return;let{result:s}=o;if(s.error||s.status===0)return;let i=`${s.stdout??""}${s.stderr??""}`.trim();if(i)return i.split(/\r?\n/).slice(0,UO).join(`
83
- `)}function RS(e,t,r={}){Ll().assertCanSpawn("worker daemon");let n=Er({...process.env,CLAUDE_MEM_WORKER_PORT:String(t),...r}),o=Fl();if(!o){_.error("SYSTEM",xS);return}if(process.platform==="win32"){let l=LO(o,e),d=Buffer.from(l,"utf16le").toString("base64");try{return(0,vo.execSync)(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:n}),0}catch(f){let p=f instanceof Error?f:new Error(String(f));_.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:o},p);return}}let s="/usr/bin/setsid",i=(0,Ie.existsSync)(s),a=i?s:o,u=xi(a,i?[o,e,"--daemon"]:[e,"--daemon"],{detached:!0,stdio:"ignore",cwd:$S(),env:n});if(u.on("error",l=>{_.error("SYSTEM",xS,{runtimePath:o,execPath:a},l)}),u.pid!==void 0)return u.unref(),u.pid}function OS(){try{if(!(0,Ie.existsSync)(kS))return;let e=new Date;(0,Ie.utimesSync)(kS,e,e)}catch{}}function zi(){return Mi({logAlive:!1})}var IS=Lt(require("net"),1);ne();Ze();function ql(){return ht.loadFromFile(Do).CLAUDE_MEM_WORKER_HOST}function AS(e){return e.startsWith("[")&&e.endsWith("]")?e:e.includes(":")?`[${e}]`:e}var Zl=5e3;async function qO(e,t,r="GET",n=Zl){let o=await fetch(`http://${AS(ql())}:${e}${t}`,{method:r,signal:AbortSignal.timeout(Math.max(1,n))}),s="";try{s=await o.text()}catch{}return{ok:o.ok,statusCode:o.status,body:s}}async function Hl(e,t=Zl){if(process.platform==="win32")try{let r=await fetch(`http://${AS(ql())}:${e}/api/health`,{signal:AbortSignal.timeout(Math.max(1,t))});if(r.ok)return!0;_.debug("SYSTEM","Windows health check returned non-ok; falling through to socket probe",{port:e,status:r.status})}catch(r){r instanceof Error?_.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:e,message:r.message}):_.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:e,error:String(r)})}return new Promise(r=>{let n=IS.default.createServer(),o=ql();n.once("error",s=>{s.code==="EADDRINUSE"?r(!0):r(!1)}),n.once("listening",()=>{n.close(()=>r(!1))}),n.listen(e,o)})}async function CS(e,t,r,n){let o=Date.now()+r;for(;Date.now()<o;){try{let i=o-Date.now();if((await qO(e,t,"GET",Math.min(Zl,i))).ok)return!0}catch(i){i instanceof Error?_.debug("SYSTEM",n,{},i):_.debug("SYSTEM",n,{error:String(i)})}let s=Math.min(500,o-Date.now());s>0&&await new Promise(i=>setTimeout(i,s))}return!1}function wo(e,t=3e4){return CS(e,"/api/health",t,"Service not ready yet, will retry")}function ko(e,t=3e4){return CS(e,"/api/readiness",t,"Worker not ready yet, will retry")}ne();var Di=require("path"),nt=require("fs");Ze();ne();var ZO=9e4;function MS(){return(0,Di.join)(sr(),"spawn.lock")}function Wl(){let e=MS(),t=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return(0,nt.mkdirSync)((0,Di.dirname)(e),{recursive:!0}),(0,nt.writeFileSync)(e,t,{flag:"wx"}),!0}catch(n){let o=n instanceof Error?n:new Error(String(n)),s=o.code;if(s!=="EEXIST")return _.warn("SYSTEM","Spawn lock write failed for a non-contention reason; failing open (spawning unlocked)",{lockPath:e,code:s},o),!0;if(r>0)return!1;let i;try{i=(0,nt.statSync)(e).mtimeMs}catch{continue}if(Date.now()-i<=ZO)return!1;let a;try{a=(0,nt.statSync)(e).mtimeMs}catch{continue}if(a!==i)return!1;try{(0,nt.unlinkSync)(e)}catch{return!1}}return!1}function Vl(){let e=MS();try{if(JSON.parse((0,nt.readFileSync)(e,"utf-8")).pid!==process.pid)return;(0,nt.unlinkSync)(e)}catch{}}Pr();function NS(e,t,r){let n=process.env[e];if(n){let o=parseInt(n,10);if(Number.isFinite(o)&&o>=r.min&&o<=r.max)return o;_.warn("SYSTEM",`Invalid ${e}, using default`,{value:n,min:r.min,max:r.max})}return t}var NF=NS("CLAUDE_MEM_HEALTH_TIMEOUT_MS",tr(Oe.HEALTH_CHECK),{min:500,max:3e5}),LF=NS("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",tr(Oe.HOOK_READINESS_WAIT),{min:0,max:3e5}),HO={min:500,max:3e5};function LS(e=process.env){let t=e.CLAUDE_MEM_FETCH_VERBOSE;if(t===void 0)return!1;let r=t.trim().toLowerCase();return r==="1"||r==="true"||r==="on"||r==="yes"}function WO(e){return LS()?{...e,verbose:!0}:e}function VO(e){let t={},r=e;for(let n=0;r&&n<4;n++){let o=n===0?"error":`cause${n}`;if(r instanceof Error){let s=r;t[o]={name:r.name,message:r.message,...s.code!==void 0?{code:s.code}:{}},r=r.cause;continue}t[o]=String(r);break}return t}function KO(e,t,r){let n=typeof t.method=="string"?t.method:"GET",o=VO(r),s=JSON.stringify(o);_.warn("SYSTEM","Worker IPC fetch failed",{url:e,method:n},s),jt(`[claude-mem] fetch verbose: ${n} ${e} ${s}
84
- `)}async function jS(e,t={}){let r=WO(t);try{return await fetch(e,r)}catch(n){throw LS()&&KO(e,t,n),n}}async function Kl(e,t={},r){try{return await jS(e,{...t,signal:AbortSignal.timeout(r)})}catch(n){throw n instanceof DOMException&&n.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):n}}var Ni=null,Li=null,ji=null,Ui=null;function BO(){return Ae.default.join(ht.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function Bl(){return ji!==null||(ji=ht.loadFromFile(BO())),ji}function zS(e,t){if(!e)return null;let r=parseInt(e,10);return Number.isFinite(r)&&r>=t.min&&r<=t.max?r:null}function GO(e,t,r){let n=process.env[e];if(n!==void 0){let i=zS(n,r);return i!==null?i:(_.warn("SYSTEM",`Invalid ${e}, using default`,{value:n,min:r.min,max:r.max}),t)}let o=Bl()[e],s=zS(o,r);return s!==null?s:(_.warn("SYSTEM",`Invalid ${e} in settings.json, using default`,{value:o,min:r.min,max:r.max}),t)}function Gl(){if(Ni!==null)return Ni;let e=Bl();return Ni=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),Ni}function YO(){return Li!==null||(Li=Bl().CLAUDE_MEM_WORKER_HOST),Li}function JO(){return Ui!==null||(Ui=GO("CLAUDE_MEM_API_TIMEOUT_MS",tr(Oe.API_REQUEST),HO)),Ui}function XO(e){return e.startsWith("[")&&e.endsWith("]")?e:e.includes(":")?`[${e}]`:e}function QO(e){return`http://${XO(YO())}:${Gl()}${e}`}function Fi(e,t={}){let r=t.method??"GET",n=t.timeoutMs??JO(),o=QO(e),s={method:r};return t.headers&&(s.headers=t.headers),t.body&&(s.body=t.body),n>0?Kl(o,s,n):jS(o,s)}function US(e){let t=(0,Ce.existsSync)(Ae.default.join(e,"plugin","scripts"))?Ae.default.join(e,"plugin"):e;return Ae.default.join(t,"scripts","worker-service.cjs")}function eI(e,t){let r=d=>{let f=d.split("-")[0].split(".");return[parseInt(f[0],10)||0,parseInt(f[1],10)||0,parseInt(f[2],10)||0]},[n,o,s]=r(e),[i,a,c]=r(t);if(i!==n)return i-n;if(a!==o)return a-o;if(c!==s)return c-s;let u=e.includes("-")?1:0,l=t.includes("-")?1:0;return u!==l?u-l:e<t?1:e>t?-1:0}function tI(e=Ae.default.join(Ae.default.dirname(Ae.default.dirname(zo)),"cache","thedotmack","claude-mem")){try{return(0,Ce.readdirSync)(e).filter(t=>/^\d/.test(t)).map(t=>Ae.default.join(e,t)).filter(t=>{try{if(!(0,Ce.statSync)(t).isDirectory())return!1}catch{return!1}return!(0,Ce.existsSync)(Ae.default.join(t,".orphaned_at"))}).map(t=>({scriptPath:US(t),version:Ae.default.basename(t)}))}catch{return[]}}function DS(e){try{let t=JSON.parse((0,Ce.readFileSync)(e,"utf-8"));return typeof t.version=="string"?t.version:null}catch(t){let r=t.code;return r!=="ENOENT"&&_.debug("SYSTEM","Could not read package version for worker resolution",{packageJsonPath:e,code:r}),null}}function rI(){let e=process.env.CLAUDE_MEM_WORKER_SCRIPT_PATH?.trim();if(e){if((0,Ce.existsSync)(e))return{scriptPath:e,version:null};_.debug("SYSTEM","Ignoring missing CLAUDE_MEM_WORKER_SCRIPT_PATH override",{override:e})}let t=[...tI(),{scriptPath:US(Ae.default.join(zo,"plugin")),version:DS(Ae.default.join(zo,"package.json"))},{scriptPath:Ae.default.join(process.cwd(),"plugin","scripts","worker-service.cjs"),version:DS(Ae.default.join(process.cwd(),"package.json"))}];return nI(t)}function nI(e){let t=e.filter(r=>(0,Ce.existsSync)(r.scriptPath));return t.length===0?null:(t.sort((r,n)=>r.version===null&&n.version===null?0:r.version===null?1:n.version===null?-1:eI(r.version,n.version)),t[0])}function FS(){return rI()?.scriptPath??null}var oI=1e3;var sI=5e3,jF=sI+oI;var Yl=Lt(require("path"),1),ot=require("fs");ne();var ZS=require("node:child_process"),HS=require("node:util");ne();Ze();var WS=(0,HS.promisify)(ZS.execFile),iI=/^(uv|uvx|python|chroma-mcp)(\.exe)?$/i;function qS(e){return iI.test(e.trim())}function aI(e,t){if(!e)return!1;let r=e.toLowerCase().replace(/\\/g,"/"),n=r.indexOf("--data-dir");if(n<0)return!1;let o=r.slice(n+10).trim();if(o.startsWith('"')){let i=o.indexOf('"',1);o=i<0?o.slice(1):o.slice(1,i)}let s=t.toLowerCase().replace(/\\/g,"/");return o===s||o.startsWith(s)&&o[s.length]==="/"}async function cI(){try{let e=await WS("powershell.exe",["-NoProfile","-NonInteractive","-Command","Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,Name,CommandLine,@{Name='StartToken';Expression={$_.CreationDate.ToString('yyyyMMddHHmmss.ffffff')}} | ConvertTo-Json -Compress"],{timeout:3e4,windowsHide:!0,maxBuffer:33554432}),t=JSON.parse(e.stdout),r=Array.isArray(t)?t:t===null?[]:[t],n=[];for(let o of r){let s=typeof o.Name=="string"?o.Name.trim():"";if(!s)continue;let i=typeof o.ProcessId=="number"?o.ProcessId:Number.parseInt(String(o.ProcessId),10),a=typeof o.ParentProcessId=="number"?o.ParentProcessId:Number.parseInt(String(o.ParentProcessId),10);!Number.isInteger(i)||!Number.isInteger(a)||n.push({pid:i,ppid:a,name:s,cmdline:typeof o.CommandLine=="string"?o.CommandLine:null,startToken:typeof o.StartToken=="string"&&o.StartToken.length>0?o.StartToken:null})}return n}catch(e){return _.warn("PROCESS","Cannot enumerate the Windows process table with names \u2014 ghost-port reclaim disabled",{error:e instanceof Error?e.message:String(e)}),null}}async function uI(e){try{let t=await WS("netstat",["-ano"],{timeout:15e3,windowsHide:!0,maxBuffer:16777216});return lI(t.stdout,e)}catch(t){return _.warn("PROCESS","netstat failed \u2014 ghost-port reclaim disabled for this attempt",{port:e,error:t instanceof Error?t.message:String(t)}),null}}function lI(e,t){let r=new Set,n=`:${t}`;for(let o of e.split(/\r?\n/)){let s=o.trim();if(!/^TCP\b/i.test(s))continue;let i=s.split(/\s+/);if(!i[1]?.endsWith(n)||i[3]!=="LISTENING")continue;let c=Number.parseInt(i[4]??"",10);Number.isInteger(c)&&c>0&&r.add(c)}return[...r]}async function VS(e,t={}){let r=t.isWin32??(()=>process.platform==="win32"),n=t.listOwners??uI,o=t.readTable??cI,s=t.killTree??((y,E)=>gt(y,E)),i=t.dataDir??(()=>ce);if(!r())return{reclaimed:!1,reason:"not-supported",killedPids:[]};let a=await n(e);if(a===null)return{reclaimed:!1,reason:"netstat-unreadable",killedPids:[]};if(a.length===0)return{reclaimed:!1,reason:"no-listener",killedPids:[]};let c=await o();if(c===null)return{reclaimed:!1,reason:"table-unreadable",killedPids:[]};if(a.filter(y=>pe(y)).length>0)return{reclaimed:!1,reason:"owner-alive",killedPids:[]};let l=new Map;for(let y of c){let E=l.get(y.ppid);E?E.push(y):l.set(y.ppid,[y])}let d=new Map,f=new Set,p=y=>{for(let E of l.get(y)??[])f.has(E.pid)||(f.add(E.pid),p(E.pid),qS(E.name)&&d.set(E.pid,E))};for(let y of a)p(y);let m=i();if(m)for(let y of c)d.has(y.pid)||qS(y.name)&&aI(y.cmdline,m)&&d.set(y.pid,y);if(d.size===0)return _.info("PROCESS","Ghost listener owner is dead but no chroma-sidecar descendants found",{port:e,deadOwners:a,processTableRows:c.length,dataDir:m??"(unresolved)"}),{reclaimed:!1,reason:"no-chroma-descendants",killedPids:[]};_.warn("PROCESS","Reclaiming ghost listener: killing dead worker's surviving chroma sidecar chain",{port:e,deadOwners:a,targets:[...d.values()].map(y=>({pid:y.pid,name:y.name}))});let h=[];for(let y of d.values())try{await s(y.pid,{expectedStartToken:y.startToken,signalMode:"immediate"}),h.push(y.pid)}catch(E){return _.error("PROCESS","Ghost-port reclaim tree-kill failed",{port:e,pid:y.pid},E instanceof Error?E:new Error(String(E))),{reclaimed:!1,reason:"kill-failed",killedPids:h}}let g=await n(e);return g!==null&&g.length===0?(_.info("PROCESS","Ghost listener reclaimed \u2014 port is free again",{port:e,killedPids:h}),{reclaimed:!0,killedPids:h}):(_.warn("PROCESS","Ghost-port reclaim killed the sidecar chain but the port is still bound",{port:e,killedPids:h,stillOwnedBy:g}),{reclaimed:!1,reason:"still-bound",killedPids:h})}var dI=120*1e3;function Jl(){return Yl.default.join(ht.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function fI(){if(process.platform!=="win32")return!1;let e=Jl();if(!(0,ot.existsSync)(e))return!1;try{let t=(0,ot.statSync)(e).mtimeMs;return Date.now()-t<dI}catch(t){return t instanceof Error?_.debug("SYSTEM","Could not stat worker spawn lock file",{},t):_.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(t)}),!1}}function pI(){if(process.platform==="win32")try{let e=Jl();(0,ot.mkdirSync)(Yl.default.dirname(e),{recursive:!0}),(0,ot.writeFileSync)(e,"","utf-8")}catch{}}function xo(){if(process.platform==="win32")try{let e=Jl();(0,ot.existsSync)(e)&&(0,ot.unlinkSync)(e)}catch{}}var qi;async function KS(e,t){if(qi=void 0,!t)return _.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,ot.existsSync)(t))return _.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:t}),"dead";if(zi()==="alive"){if(_.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await ko(e,wr(Oe.READINESS_WAIT)))return xo(),_.info("SYSTEM","Worker became ready while waiting on live PID"),"ready";let a=await wo(e,1e3),c=zi()==="alive";return!a&&!c?(_.error("SYSTEM","Live PID disappeared before readiness endpoint became available"),"dead"):(_.warn("SYSTEM","Live PID detected but worker did not become ready before timeout"),"warming")}if(await wo(e,1e3)){xo();let i=await ko(e,wr(Oe.READINESS_WAIT));return i||_.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),_.info("SYSTEM","Worker already running and healthy"),i?"ready":"warming"}if(await Hl(e)){if(_.info("SYSTEM","Port in use, waiting for worker to become healthy"),await wo(e,wr(Oe.PORT_IN_USE_WAIT))){xo();let c=await ko(e,wr(Oe.READINESS_WAIT));return _.info("SYSTEM","Worker is now healthy"),c?"ready":"warming"}let a=await VS(e);if(a.reclaimed)_.info("SYSTEM","Reclaimed ghost listener left by a dead worker \u2014 proceeding to spawn",{port:e,killedPids:a.killedPids}),xo();else return _.error("SYSTEM","Port in use but worker not responding to health checks",{port:e,reclaimReason:a.reason}),"dead"}if(fI())return _.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";let o=Wl(),s;try{if(o){if(_.info("SYSTEM","Starting worker daemon",{workerScriptPath:t}),pI(),s=RS(t,e),s===void 0)return _.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else _.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");if(!await ko(e,wr(Oe.READINESS_WAIT))){let a=await wo(e,1e3),c=zi()==="alive",u=s!==void 0&&s>0&&pe(s);return!a&&!c&&!u?o?(qi=TS(t),_.error("SYSTEM","Worker exited before readiness endpoint became available",qi?{bootFailure:qi}:{}),"dead"):(_.error("SYSTEM","Spawn-lock holder never produced a live worker before readiness timed out"),"dead"):(_.warn("SYSTEM",o?"Worker spawned but readiness endpoint not responding within window":"Spawn-lock holder's worker not ready within window"),"warming")}return xo(),OS(),_.info("SYSTEM",o?"Worker started successfully":"Worker is up (started by another launcher)"),"ready"}finally{o&&Vl()}}var cn=require("node:fs/promises"),Po=require("node:path");var nd=require("node:child_process"),be=require("node:fs"),Me=require("node:path"),od=require("node:os"),ed=require("node:module");ne();Ze();var II={},td=typeof __CM_FILENAME__<"u"?(0,ed.createRequire)(__CM_FILENAME__):(0,ed.createRequire)(II.url),mI={".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",".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 QS(e){let t=e.slice(e.lastIndexOf("."));return mI[t]??"unknown"}var hI={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",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"},gI={markdown:"tree-sitter-markdown"};function eb(e){let t=hI[e];if(!t)return null;let r=gI[e];if(r){try{let n=td.resolve(t+"/package.json"),o=(0,Me.join)((0,Me.dirname)(n),r);if((0,be.existsSync)((0,Me.join)(o,"src")))return o}catch{}return null}try{let n=td.resolve(t+"/package.json");return(0,Me.dirname)(n)}catch{return null}}var _I={jsts:`
78
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let i of e.seen.entries()){let a=i[1];if(t===i[0]){s(i);continue}if(e.external){let u=e.external.registry.get(i[0])?.id;if(t!==i[0]&&u){s(i);continue}}if(e.metadataRegistry.get(i[0])?.id){s(i);continue}if(a.cycle){s(i);continue}a.count>1&&e.reused==="ref"&&s(i)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Cm(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let r=[];for(let n of t){if(!n||typeof n!="object")return;Cm(n);let o=Object.keys(n);if(o.length!==1||o[0]!=="type")return;let s=n.type;for(let i of Array.isArray(s)?s:[s]){if(typeof i!="string")return;r.includes(i)||r.push(i)}}delete e.anyOf,e.type=r.length===1?r[0]:r}var Mm=new Set(["type","properties","required","additionalProperties"]),Im=["oneOf","anyOf"];function Am(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Ja(e){let t=[];for(let s of e){if(typeof s!="object"||s.type!=="object")return null;for(let i in s)if(!Mm.has(i))return null;t.push(s)}let r={},n=new Set;for(let s of t){for(let i in s.properties){if(Object.prototype.hasOwnProperty.call(r,i))continue;let a=[];for(let u of t){let l=u.properties?.[i]??Am(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}let c=a.length===1?a[0]:Ja(a)??{allOf:a};He(r,i,c)}for(let i of s.required??[])n.add(i)}let o={type:"object",properties:r};if(n.size&&(o.required=[...n]),t.every(s=>s.additionalProperties===!1))o.additionalProperties=!1;else{let s=[];for(let i of t){let a=Am(i);a&&!s.some(c=>JSON.stringify(c)===JSON.stringify(a))&&s.push(a)}s.length===1?o.additionalProperties=s[0]:s.length>1&&(o.additionalProperties={allOf:s})}return o}function XE(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let o of Mm)if(o in e)return;let r=t.filter(o=>Im.some(s=>Array.isArray(o[s]))),n=null;if(!r.length)n=Ja(t);else{let o=r[0],s=Im.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;let i=t.filter(c=>c!==o),a=o[s].map(c=>Ja([...i,c]));if(a.some(c=>!c))return;n={[s]:a}}n&&(delete e.allOf,xn(e,n))}function ec(e,t){let r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");let n=a=>{let c=e.seen.get(a);if(c.ref===null)return;let u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){n(d);let p=e.seen.get(d),m=p.schema;if(m.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(m)):xn(u,m),xn(u,l),a._zod.parent===d)for(let g in u)g==="$ref"||g==="allOf"||g in l||delete u[g];if(m.$ref&&p.def)for(let g in u)g==="$ref"||g==="allOf"||g in p.def&&JSON.stringify(u[g])===JSON.stringify(p.def[g])&&delete u[g]}let f=a._zod.parent;if(f&&f!==d){n(f);let p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(let m in u)m==="$ref"||m==="allOf"||m in p.def&&JSON.stringify(u[m])===JSON.stringify(p.def[m])&&delete u[m]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let a of[...e.seen.entries()].reverse())n(a[0]);if(e.target!=="openapi-3.0")for(let a of e.seen.entries())Cm(a[1].def??a[1].schema);for(let a of e.deferred)a();if(e.intersections.length){let a=new Map;for(let c of e.seen.values())for(let u of[c.schema,c.def]){let l=u?.allOf;if(!Array.isArray(l))continue;let d=a.get(l);d?d.push(u):a.set(l,[u])}for(let c of e.intersections)for(let u of a.get(c)??[])XE(u)}}let o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");o.$id=e.external.uri(a)}xn(o,r.defId?r.schema:r.def??r.schema);let s=e.metadataRegistry.get(t)?.id;s!==void 0&&o.id===s&&delete o.id;let i=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let a of e.seen.entries()){let c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,He(i,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?o.$defs=i:o.definitions=i);try{let a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Pn(t,"input",e.processors),output:Pn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ee(e,t){let r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);let n=e._zod.def;if(n.type==="transform")return!0;if(n.type==="array")return Ee(n.element,r);if(n.type==="set")return Ee(n.valueType,r);if(n.type==="lazy")return Ee(n.getter(),r);if(n.type==="promise"||n.type==="optional"||n.type==="nonoptional"||n.type==="nullable"||n.type==="readonly"||n.type==="default"||n.type==="prefault"||n.type==="catch")return Ee(n.innerType,r);if(n.type==="intersection")return Ee(n.left,r)||Ee(n.right,r);if(n.type==="record"||n.type==="map")return Ee(n.keyType,r)||Ee(n.valueType,r);if(n.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Ee(n.in,r)||Ee(n.out,r);if(n.type==="object"){for(let o in n.shape)if(Ee(n.shape[o],r))return!0;return!1}if(n.type==="union"){for(let o of n.options)if(Ee(o,r))return!0;return!1}if(n.type==="tuple"){for(let o of n.items)if(Ee(o,r))return!0;return!!(n.rest&&Ee(n.rest,r))}return!1}var zm=(e,t={})=>r=>{let n=Xa({...r,processors:t});return ue(e,n),Qa(n,e),ec(n,e)},Pn=(e,t,r={})=>n=>{let{libraryOptions:o,target:s}=n??{},i=Xa({...o??{},target:s,io:t,processors:r});return ue(e,i),Qa(i,e),ec(i,e)};var zr=(e,t,r)=>{(e[t]===void 0||r>e[t])&&(e[t]=r)},Dr=(e,t,r)=>{(e[t]===void 0||r<e[t])&&(e[t]=r)},Dm=(e,t)=>{zr(e,"minimum",t),Dr(e,"maximum",t)},Um=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Fm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},qm=(e,t)=>{e.mime=e.mime?e.mime.filter(r=>t.includes(r)):[...t]},Zm=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Nm=(e,t)=>zr(e,"minimum",t.minimum),Lm=(e,t)=>Dr(e,"maximum",t.maximum),jm=e=>(t,r)=>{Zm(t,r.format);let[n,o]=e[r.format];zr(t,"minimum",n),Dr(t,"maximum",o)},QE={greater_than:(e,t)=>zr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>Dr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Um(e,t.value),number_format:jm(mn),bigint_format:jm(Uo),min_length:Nm,max_length:Lm,length_equals:(e,t)=>Dm(e,t.length),min_size:Nm,max_size:Lm,size_equals:(e,t)=>Dm(e,t.size),string_format:(e,t)=>{Zm(e,t.format),t.pattern&&Fm(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>qm(e,t.mime)};function Ye(e){let t={},r=e._zod.def,n=e._zod.traits.has("$ZodCheck")?[e,...r.checks??[]]:r.checks??[];for(let s of n)QE[s._zod.def.check]?.(t,s._zod.def);let o=e._zod.bag;o.minimum!==void 0&&zr(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&zr(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&Dr(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&Dr(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Um(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&qm(t,o.mime);for(let s of o.patterns??[])Fm(t,s);return t}var ev={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},tv=new Map([[Ia,df],[es,ff]]),Hm=e=>tv.get(e)??e,Wm=(e,t,r,n)=>{let o=r;o.type="string";let{minimum:s,maximum:i,format:a,patterns:c,contentEncoding:u,laxFormat:l}=Ye(e);if(typeof s=="number"&&(o.minLength=s),typeof i=="number"&&(o.maxLength=i),a&&(o.format=ev[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){let d=[...c].map(Hm);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Vm=(e,t,r,n)=>{let o=r,{minimum:s,maximum:i,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=Ye(e);o.type=l?"integer":"number";let d=typeof u=="number"&&u>=(s??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(i??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof s=="number"&&(o.minimum=s),f?p?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof i=="number"&&(o.maximum=i),a){let m=new Set;for(let y of a)Number.isFinite(y)&&y!==0?m.add(Math.abs(y)):Rt(e,t,o,n,`A multipleOf divisor of ${y} cannot be represented in JSON Schema`);let[h,...g]=m;h!==void 0&&(o.multipleOf=h),g.length&&(o.allOf=[...o.allOf??[],...g.map(y=>({multipleOf:y}))])}},Km=(e,t,r,n)=>{r.type="boolean"};var Bm=(e,t,r,n)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"};var Gm=(e,t,r,n)=>{r.not={}};var Ym=(e,t,r,n)=>{};var Jm=(e,t,r,n)=>{let o=e._zod.def,s=Tr(o.entries);if(s.length===0){r.not={};return}s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),r.enum=s},Xm=(e,t,r,n)=>{let o=e._zod.def;if(o.values.length===0){r.not={};return}let s=[];for(let i of o.values)if(i===void 0){if(Rt(e,t,r,n,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof i=="bigint"){if(Rt(e,t,r,n,"BigInt literals cannot be represented in JSON Schema"))return;s.push(Number(i))}else s.push(i);if(s.length!==0)if(s.length===1){let i=s[0];r.type=i===null?"null":typeof i,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[i]:r.const=i}else s.every(i=>typeof i=="number")&&(r.type="number"),s.every(i=>typeof i=="string")&&(r.type="string"),s.every(i=>typeof i=="boolean")&&(r.type="boolean"),s.every(i=>i===null)&&(r.type="null"),r.enum=s};var Qm=(e,t,r,n)=>{Rt(e,t,r,n,"Custom types cannot be represented in JSON Schema")};var eh=(e,t,r,n)=>{Rt(e,t,r,n,"Transforms cannot be represented in JSON Schema")};var th=(e,t,r,n)=>{let o=r,s=e._zod.def,{minimum:i,maximum:a}=Ye(e);typeof i=="number"&&(o.minItems=i),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ue(s.element,t,{...n,path:[...n.path,"items"]})};function ms(e){let t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?ms(t.out):t.type==="catch"?ms(t.innerType):e._zod.optin}var rh=(e,t,r,n)=>{let o=r,s=e._zod.def,i=s.shape;if(Object.getOwnPropertySymbols(i).length&&Rt(e,t,o,n,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(let l in i)He(o.properties,l,ue(i[l],t,{...n,path:[...n.path,"properties",l]}));let c=new Set(Object.keys(i)),u=new Set([...c].filter(l=>{let d=s.shape[l];return t.io==="input"?ms(d)===void 0:d._zod.optout===void 0}));u.size>0&&(o.required=Array.from(u)),s.catchall?._zod.def.type==="never"?o.additionalProperties=!1:s.catchall?s.catchall&&(o.additionalProperties=ue(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)};var nh=(e,t,r,n)=>{let o=e._zod.def,s=o.inclusive===!1,i=o.options.map((a,c)=>ue(a,t,{...n,path:[...n.path,s?"oneOf":"anyOf",c]}));s?r.oneOf=i:r.anyOf=i},oh=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.left,t,{...n,path:[...n.path,"allOf",0]}),i=ue(o.right,t,{...n,path:[...n.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(s)?s.allOf:[s],...a(i)?i.allOf:[i]];r.allOf=c,t.intersections.push(c)};function tc(e,t,r){if(t.$ref){if(r.has(t))return t;r.add(t);let m=e.get(t)?.def;if(!m)return t;let h=tc(e,m,r);return h===m?t:h}for(let m of["anyOf","oneOf"]){let h=t[m];if(!Array.isArray(h))continue;let g=h.map(y=>tc(e,y,r));g.some((y,E)=>y!==h[E])&&(t={...t,[m]:g})}let n=Array.isArray(t.type)?t.type:[t.type],o=!n.includes("string")&&n.some(m=>m==="number"||m==="integer"),s=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!s?.some(m=>typeof m=="number"))return t;let{minimum:i,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(m=>typeof m=="number"?String(m):m):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",s||(p.pattern=(n.includes("number")?yn:xa).source)),p}var rc=new WeakMap;function rv(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let r=new Map;for(let n of rc.get(e)??[]){let o=e.seen.get(n),s=(o?.def??o?.schema)?.propertyNames;if(!s||s===!0||r.has(s))continue;let i=tc(t,s,new Set);i!==s&&r.set(s,i)}if(r.size)for(let n of e.seen.values())for(let o of[n.schema,n.def]){let s=o&&r.get(o.propertyNames);s&&(o.propertyNames=s)}}var sh=(e,t,r,n)=>{let o=r,s=e._zod.def;o.type="object";let i=s.keyType,a=Ye(i).patterns;if(s.mode==="loose"&&a&&a.size>0){let l=ue(s.valueType,t,{...n,path:[...n.path,"patternProperties","*"]});o.patternProperties={};for(let d of a)He(o.patternProperties,Hm(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=ue(s.keyType,t,{...n,path:[...n.path,"propertyNames"]});let l=rc.get(t);l||(l=[],rc.set(t,l),t.deferred.push(()=>rv(t))),l.push(e)}o.additionalProperties=ue(s.valueType,t,{...n,path:[...n.path,"additionalProperties"]})}let c=i._zod.values,u=t.io==="input"&&ms(s.valueType)!==void 0;if(c&&!s.partial&&!u){let l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},ih=(e,t,r,n)=>{let o=e._zod.def,s=ue(o.innerType,t,n),i=t.seen.get(e);t.target==="openapi-3.0"?(i.ref=o.innerType,r.nullable=!0):r.anyOf=[s,{type:"null"}]},ah=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType},nc=Symbol();function ch(e,t,r,n,o){let s=!1,i=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(s=!0,null));return s?(Rt(t,r,n,o,"BigInt defaults cannot be represented in JSON Schema"),nc):JSON.parse(i)}var uh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i=ch(o.defaultValue,e,t,r,n);i!==nc&&(r.default=i)},lh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);if(s.ref=o.innerType,t.io!=="input")return;let i=ch(o.defaultValue,e,t,r,n);i!==nc&&(r._prefault=i)},dh=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType;let i;try{i=o.catchValue(void 0)}catch{Rt(e,t,r,n,"Dynamic catch values are not supported in JSON Schema");return}r.default=i},fh=(e,t,r,n)=>{let o=e._zod.def,s=o.in._zod.traits.has("$ZodTransform"),i=t.io==="input"?s?o.out:o.in:o.out;ue(i,t,n);let a=t.seen.get(e);a.ref=i},ph=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType,r.readOnly=!0};var oc=(e,t,r,n)=>{let o=e._zod.def;ue(o.innerType,t,n);let s=t.seen.get(e);s.ref=o.innerType};function hs(e){return!!e._zod}function Ht(e,t){return hs(e)?va(e,t):e.safeParse(t)}function gs(e){if(!e)return;let t;if(hs(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function _s(e){if(hs(e)){let s=e._zod?.def;if(s){if(s.value!==void 0)return s.value;if(Array.isArray(s.values)&&s.values.length>0)return s.values[0]}}let r=e._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0)return r.values[0]}let n=e.value;if(n!==void 0)return n}var mh=new WeakSet([Object.prototype,Error.prototype]);function ys(e,t,r){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let n=r(this);return Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0}),n},set(n){Object.defineProperty(this,t,{value:n,configurable:!0,writable:!0})}})}var dv=(e,t)=>{Dd.init(e,t),e.name="ZodError";let r=Object.getPrototypeOf(e);mh.has(r)||(mh.add(r),ys(r,"format",n=>o=>jd(n,o)),ys(r,"flatten",n=>o=>Ld(n,o)),ys(r,"addIssue",n=>o=>{n.issues.push(o),n.message=JSON.stringify(n.issues,Rr,2)}),ys(r,"addIssues",n=>o=>{n.issues.push(...o),n.message=JSON.stringify(n.issues,Rr,2)}),Object.defineProperty(r,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))};var Ve=b("ZodError",dv,void 0,{Parent:Error});var hh=Ho(Ve),gh=Wo(Ve),_h=_n(Ve),yh=Vo(Ve),Sh=Fd(Ve),bh=qd(Ve),Eh=Zd(Ve),vh=Hd(Ve),wh=Wd(Ve),kh=Vd(Ve),xh=Kd(Ve),Ph=Bd(Ve);function pv(){ze.localeError||We(Gp())}function bs(){ze.memoizer||We({memoizer:Bp()})}var ie=b("ZodType",(e,t)=>(pv(),X.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(R.mergeDefs(t,{checks:[...t.checks??[],...e.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return it(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(rw(e,t))},superRefine(e,t){return this.check(nw(e,t))},overwrite(e){return this.check(Zt(e))},optional(){return se(this)},exactOptional(){return Hv(this)},nullable(){return Rh(this)},nullish(){return se(Rh(this))},nonoptional(e){return Yv(this,e)},array(){return U(this)},or(e){return ee([this,e])},and(e){return Es(this,e)},transform(e){return Oh(this,Dh(e))},default(e){return Kv(this,e)},prefault(e){return Gv(this,e)},catch(e){return Xv(this,e)},pipe(e){return Oh(this,e)},readonly(){return tw(this)},describe(e){let t=this.clone();return cr.add(t,{description:e}),t},meta(...e){if(e.length===0)return cr.get(this);let t=this.clone();return cr.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return R.hide(this,"~standard",{...Oa(this),jsonSchema:{input:Pn(this,"input"),output:Pn(this,"output")}})},set"~standard"(e){R.own(this,"~standard",e)},parse:function e(t,r){return hh(this,t,r,{callee:e})},parseAsync:async function e(t,r){return await gh(this,t,r,{callee:e})},safeParse(e,t){return _h(this,e,t)},async safeParseAsync(e,t){return yh(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){R.own(this,"spa",e)},validate(e,t){return Ko(this,e,t)},validateAsync(e,t){return Bo(this,e,t)},encode:function e(t,r){return Sh(this,t,r,{callee:e})},decode:function e(t,r){return bh(this,t,r,{callee:e})},encodeAsync:async function e(t,r){return await Eh(this,t,r,{callee:e})},decodeAsync:async function e(t,r){return await vh(this,t,r,{callee:e})},safeEncode(e,t){return wh(this,e,t)},safeDecode(e,t){return kh(this,e,t)},async safeEncodeAsync(e,t){return xh(this,e,t)},async safeDecodeAsync(e,t){return Ph(this,e,t)},toJSONSchema(e){return zm(this,{})(e)},get description(){return cr.get(this)?.description},get _def(){return this._zod.def}}),Ih=b("_ZodString",(e,t)=>{Qo.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Wm(e,r,n,o)},R.derived({format:e=>Ye(e).format??null,minLength:e=>Ye(e).minimum??null,maxLength:e=>Ye(e).maximum??null},{regex(...e){return this.check(Ua(...e))},includes(...e){return this.check(Za(...e))},startsWith(...e){return this.check(Ha(...e))},endsWith(...e){return this.check(Wa(...e))},min(...e){return this.check(Mr(...e))},max(...e){return this.check(fs(...e))},length(...e){return this.check(ps(...e))},nonempty(...e){return this.check(Mr(1,...e))},lowercase(e){return this.check(Fa(e))},uppercase(e){return this.check(qa(e))},trim(){return this.check(Ka())},normalize(...e){return this.check(Va(...e))},toLowerCase(){return this.check(Ba())},toUpperCase(){return this.check(Ga())},slugify(){return this.check(Ya())}})),mv=b("ZodString",(e,t)=>{Qo.init(e,t),Ih.init(e,t)},{email(e){return this.check(Xp(hv,e))},url(e){return this.check(om(_v,e))},jwt(e){return this.check(Sm(Av,e))},emoji(e){return this.check(sm(yv,e))},guid(e){return this.check(Qp(gv,e))},uuid(e){return this.check(em(Ss,e))},uuidv4(e){return this.check(tm(Ss,e))},uuidv6(e){return this.check(rm(Ss,e))},uuidv7(e){return this.check(nm(Ss,e))},nanoid(e){return this.check(im(Sv,e))},cuid(e){return this.check(am(bv,e))},cuid2(e){return this.check(cm(Ev,e))},ulid(e){return this.check(um(vv,e))},base64(e){return this.check(gm(Rv,e))},base64url(e){return this.check(_m(Ov,e))},xid(e){return this.check(lm(wv,e))},ksuid(e){return this.check(dm(kv,e))},ipv4(e){return this.check(fm(xv,e))},ipv6(e){return this.check(pm(Pv,e))},cidrv4(e){return this.check(mm($v,e))},cidrv6(e){return this.check(hm(Tv,e))},e164(e){return this.check(ym(Iv,e))},datetime(e){return this.check(ss(Tn,e))},date(e){return this.check(is(Rn,e))},time(e){return this.check(as(On,e))},duration(e){return this.check(cs(In,e))}});function S(e){return Jp(mv,e)}var ae=b("ZodStringFormat",(e,t)=>{Q.init(e,t),Ih.init(e,t)}),Tn=b("ZodISODateTime",(e,t)=>{ap.init(e,t),ae.init(e,t)}),Rn=b("ZodISODate",(e,t)=>{cp.init(e,t),ae.init(e,t)}),On=b("ZodISOTime",(e,t)=>{up.init(e,t),ae.init(e,t)}),In=b("ZodISODuration",(e,t)=>{lp.init(e,t),ae.init(e,t)}),hv=b("ZodEmail",(e,t)=>{Yf.init(e,t),ae.init(e,t)});var gv=b("ZodGUID",(e,t)=>{Bf.init(e,t),ae.init(e,t)});var Ss=b("ZodUUID",(e,t)=>{Gf.init(e,t),ae.init(e,t)});var _v=b("ZodURL",(e,t)=>{Qf.init(e,t),ae.init(e,t)});var yv=b("ZodEmoji",(e,t)=>{ep.init(e,t),ae.init(e,t)});var Sv=b("ZodNanoID",(e,t)=>{tp.init(e,t),ae.init(e,t)});var bv=b("ZodCUID",(e,t)=>{rp.init(e,t),ae.init(e,t)});var Ev=b("ZodCUID2",(e,t)=>{np.init(e,t),ae.init(e,t)});var vv=b("ZodULID",(e,t)=>{op.init(e,t),ae.init(e,t)});var wv=b("ZodXID",(e,t)=>{sp.init(e,t),ae.init(e,t)});var kv=b("ZodKSUID",(e,t)=>{ip.init(e,t),ae.init(e,t)});var xv=b("ZodIPv4",(e,t)=>{dp.init(e,t),ae.init(e,t)});var Pv=b("ZodIPv6",(e,t)=>{pp.init(e,t),ae.init(e,t)});var $v=b("ZodCIDRv4",(e,t)=>{mp.init(e,t),ae.init(e,t)});var Tv=b("ZodCIDRv6",(e,t)=>{hp.init(e,t),ae.init(e,t)});var Rv=b("ZodBase64",(e,t)=>{_p.init(e,t),ae.init(e,t)});var Ov=b("ZodBase64URL",(e,t)=>{yp.init(e,t),ae.init(e,t)});var Iv=b("ZodE164",(e,t)=>{Sp.init(e,t),ae.init(e,t)});var Av=b("ZodJWT",(e,t)=>{bp.init(e,t),ae.init(e,t)});var Ah=b("ZodNumber",(e,t)=>{Aa.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Vm(e,r,n,o),e.isFinite=!0},R.derived({minValue:e=>{let{minimum:t,exclusiveMinimum:r}=Ye(e);return Math.max(t??Number.NEGATIVE_INFINITY,r??Number.NEGATIVE_INFINITY)},maxValue:e=>{let{maximum:t,exclusiveMaximum:r}=Ye(e);return Math.min(t??Number.POSITIVE_INFINITY,r??Number.POSITIVE_INFINITY)},isInt:e=>{let{isInt:t,multipleOf:r}=Ye(e);return!!t||!!r?.some(Number.isSafeInteger)},format:e=>Ye(e).format??null},{gt(e,t){return this.check(ls(e,t))},gte(e,t){return this.check(kn(e,t))},min(e,t){return this.check(kn(e,t))},lt(e,t){return this.check(us(e,t))},lte(e,t){return this.check(wn(e,t))},max(e,t){return this.check(wn(e,t))},int(e){return this.check($h(e))},safe(e){return this.check($h(e))},positive(e){return this.check(ls(0,e))},nonnegative(e){return this.check(kn(0,e))},negative(e){return this.check(us(0,e))},nonpositive(e){return this.check(wn(0,e))},multipleOf(e,t){return this.check(ds(e,t))},step(e,t){return this.check(ds(e,t))},finite(){return this}}));function K(e){return bm(Ah,e)}var Cv=b("ZodNumberFormat",(e,t)=>{Ep.init(e,t),Ah.init(e,t)});function $h(e){return Em(Cv,e)}var Mv=b("ZodBoolean",(e,t)=>{vp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Km(e,r,n,o)});function fe(e){return vm(Mv,e)}var zv=b("ZodNull",(e,t)=>{wp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Bm(e,r,n,o)});function Ch(e){return wm(zv,e)}var Dv=b("ZodUnknown",(e,t)=>{kp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Ym(e,r,n,o)});function oe(){return km(Dv)}var Nv=b("ZodNever",(e,t)=>{xp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Gm(e,r,n,o)});function Lv(e){return xm(Nv,e)}var jv=b("ZodArray",(e,t)=>{bs(),Pp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>th(e,r,n,o),e.element=t.element},{min(e,t){return this.check(Mr(e,t))},nonempty(e){return this.check(Mr(1,e))},max(e,t){return this.check(fs(e,t))},length(e,t){return this.check(ps(e,t))},unwrap(){return this.element}});function U(e,t){return Pm(jv,e,t)}var Mh=b("ZodObject",(e,t)=>{bs(),Rp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>rh(e,r,n,o),R.installLazyProp(e,"shape",r=>r._zod.def.shape,!1)},{keyof(){return De(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(R.mergeDefs(this._zod.def,{catchall:e}))},passthrough(){return this.clone(R.mergeDefs(this._zod.def,{catchall:oe()}))},loose(){return this.clone(R.mergeDefs(this._zod.def,{catchall:oe()}))},strict(){return this.clone(R.mergeDefs(this._zod.def,{catchall:Lv()}))},strip(){return this.clone(R.mergeDefs(this._zod.def,{catchall:void 0}))},extend(e){return R.extend(this,e)},safeExtend(e){return R.safeExtend(this,e)},merge(e){return R.merge(this,e)},pick(e){return R.pick(this,e)},omit(e){return R.omit(this,e)},partial(...e){return R.partial(Nh,this,e[0])},exactPartial(...e){return R.partial(Lh,this,e[0],"exactPartial")},required(...e){return R.required(jh,this,e[0])}});function k(e,t){let r={type:"object",shape:e??{},...R.normalizeParams(t)};return new Mh(r)}function $e(e,t){return new Mh({type:"object",shape:e,catchall:oe(),...R.normalizeParams(t)})}var zh=b("ZodUnion",(e,t)=>{Ca.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>nh(e,r,n,o),e.options=t.options});function ee(e,t){return new zh({type:"union",options:e,...R.normalizeParams(t)})}var Uv=b("ZodDiscriminatedUnion",(e,t)=>{zh.init(e,t),Op.init(e,t)});function ic(e,t,r){return new Uv({type:"union",options:t,discriminator:e,...R.normalizeParams(r)})}var Fv=b("ZodIntersection",(e,t)=>{Ip.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oh(e,r,n,o)});function Es(e,t){return new Fv({type:"intersection",left:e,right:t})}var Th=b("ZodRecord",(e,t)=>{bs(),Ap.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>sh(e,r,n,o),e.keyType=t.keyType,e.valueType=t.valueType});function J(e,t,r){return!t||!t._zod?new Th({type:"record",keyType:S(),valueType:e,...R.normalizeParams(t)}):new Th({type:"record",keyType:e,valueType:t,...R.normalizeParams(r)})}var sc=b("ZodEnum",(e,t)=>{Cp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(n,o,s)=>Jm(e,n,o,s),e.enum=t.entries,e.options=[...e._zod.values];let r=new Set(Object.keys(t.entries));e.extract=(n,o)=>{let s={};for(let i of n)if(r.has(i))s[i]=t.entries[i];else throw new Error(`Key ${i} not found in enum`);return new sc({...t,checks:[],...R.normalizeParams(o),entries:s})},e.exclude=(n,o)=>{let s={...t.entries};for(let i of n)if(r.has(i))delete s[i];else throw new Error(`Key ${i} not found in enum`);return new sc({...t,checks:[],...R.normalizeParams(o),entries:s})}});function De(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new sc({type:"enum",entries:r,...R.normalizeParams(t)})}var qv=b("ZodLiteral",(e,t)=>{Mp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Xm(e,r,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function P(e,t){return new qv({type:"literal",values:Array.isArray(e)?e:[e],...R.normalizeParams(t)})}var Zv=b("ZodTransform",(e,t)=>{bs(),zp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>eh(e,r,n,o),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Cr(e.constructor.name);r.addIssue=s=>{if(typeof s=="string")r.issues.push(R.issue(s,r.value,t));else{let i=s;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=e),r.issues.push(R.issue(i))}};let o=t.transform(r.value,r);return o instanceof Promise?o.then(s=>(r.value=s,r)):(r.value=o,r)}});function Dh(e){return new Zv({type:"transform",transform:e})}var Nh=b("ZodOptional",(e,t)=>{Ma.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function se(e){return new Nh({type:"optional",innerType:e})}var Lh=b("ZodExactOptional",(e,t)=>{Dp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>oc(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Hv(e){return new Lh({type:"optional",innerType:e})}var Wv=b("ZodNullable",(e,t)=>{Np.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ih(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Rh(e){return new Wv({type:"nullable",innerType:e})}var Vv=b("ZodDefault",(e,t)=>{Lp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>uh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Kv(e,t){return new Vv({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var Bv=b("ZodPrefault",(e,t)=>{jp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>lh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Gv(e,t){return new Bv({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():R.shallowClone(t)}})}var jh=b("ZodNonOptional",(e,t)=>{Up.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ah(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function Yv(e,t){return new jh({type:"nonoptional",innerType:e,...R.normalizeParams(t)})}var Jv=b("ZodCatch",(e,t)=>{Fp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>dh(e,r,n,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Xv(e,t){return new Jv({type:"catch",innerType:e,catchValue:typeof t=="function"?t:R.constantCatch(t)})}var Uh=b("ZodPipe",(e,t)=>{za.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>fh(e,r,n,o),e.in=t.in,e.out=t.out});function Oh(e,t){return new Uh({type:"pipe",in:e,out:t})}var Qv=b("ZodPreprocess",(e,t)=>{Uh.init(e,t),qp.init(e,t)}),ew=b("ZodReadonly",(e,t)=>{Zp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>ph(e,r,n,o),e.unwrap=()=>e._zod.def.innerType});function tw(e){return new ew({type:"readonly",innerType:e})}var Fh=b("ZodCustom",(e,t)=>{Hp.init(e,t),ie.init(e,t),e._zod.processJSONSchema=(r,n,o)=>Qm(e,r,n,o)});function qh(e,t){return $m(Fh,e??(()=>!0),t)}function rw(e,t={}){return Tm(Fh,e,t)}function nw(e,t){return Rm(e,t)}function ac(e,t){return new Qv({type:"pipe",in:Dh(e),out:t})}var vs={};dd(vs,{ZodISODate:()=>Rn,ZodISODateTime:()=>Tn,ZodISODuration:()=>In,ZodISOTime:()=>On,date:()=>sw,datetime:()=>ow,duration:()=>aw,time:()=>iw});function ow(e){return ss(Tn,e)}function sw(e){return is(Rn,e)}function iw(e){return as(On,e)}function aw(e){return cs(In,e)}var uc="2025-11-25";var Zh=[uc,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Wt="io.modelcontextprotocol/related-task",ks="2.0",de=qh(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Hh=ee([S(),K().int()]),Wh=S(),lz=$e({ttl:K().optional(),pollInterval:K().optional()}),cw=k({ttl:K().optional()}),uw=k({taskId:S()}),lc=$e({progressToken:Hh.optional(),[Wt]:uw.optional()}),Ke=k({_meta:lc.optional()}),An=Ke.extend({task:cw.optional()}),Vh=e=>An.safeParse(e).success,he=k({method:S(),params:Ke.loose().optional()}),Je=k({_meta:lc.optional()}),Xe=k({method:S(),params:Je.loose().optional()}),ge=$e({_meta:lc.optional()}),xs=ee([S(),K().int()]),Kh=k({jsonrpc:P(ks),id:xs,...he.shape}).strict(),dc=e=>Kh.safeParse(e).success,Bh=k({jsonrpc:P(ks),...Xe.shape}).strict(),Gh=e=>Bh.safeParse(e).success,fc=k({jsonrpc:P(ks),id:xs,result:ge}).strict(),Cn=e=>fc.safeParse(e).success;var L;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(L||(L={}));var pc=k({jsonrpc:P(ks),id:xs.optional(),error:k({code:K().int(),message:S(),data:oe().optional()})}).strict();var Yh=e=>pc.safeParse(e).success;var Jh=ee([Kh,Bh,fc,pc]),dz=ee([fc,pc]),Ps=ge.strict(),lw=Je.extend({requestId:xs.optional(),reason:S().optional()}),$s=Xe.extend({method:P("notifications/cancelled"),params:lw}),dw=k({src:S(),mimeType:S().optional(),sizes:U(S()).optional(),theme:De(["light","dark"]).optional()}),Mn=k({icons:U(dw).optional()}),Nr=k({name:S(),title:S().optional()}),Xh=Nr.extend({...Nr.shape,...Mn.shape,version:S(),websiteUrl:S().optional(),description:S().optional()}),fw=Es(k({applyDefaults:fe().optional()}),J(S(),oe())),pw=ac(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Es(k({form:fw.optional(),url:de.optional()}),J(S(),oe()).optional())),mw=$e({list:de.optional(),cancel:de.optional(),requests:$e({sampling:$e({createMessage:de.optional()}).optional(),elicitation:$e({create:de.optional()}).optional()}).optional()}),hw=$e({list:de.optional(),cancel:de.optional(),requests:$e({tools:$e({call:de.optional()}).optional()}).optional()}),gw=k({experimental:J(S(),de).optional(),sampling:k({context:de.optional(),tools:de.optional()}).optional(),elicitation:pw.optional(),roots:k({listChanged:fe().optional()}).optional(),tasks:mw.optional(),extensions:J(S(),de).optional()}),_w=Ke.extend({protocolVersion:S(),capabilities:gw,clientInfo:Xh}),mc=he.extend({method:P("initialize"),params:_w});var yw=k({experimental:J(S(),de).optional(),logging:de.optional(),completions:de.optional(),prompts:k({listChanged:fe().optional()}).optional(),resources:k({subscribe:fe().optional(),listChanged:fe().optional()}).optional(),tools:k({listChanged:fe().optional()}).optional(),tasks:hw.optional(),extensions:J(S(),de).optional()}),Sw=ge.extend({protocolVersion:S(),capabilities:yw,serverInfo:Xh,instructions:S().optional()}),hc=Xe.extend({method:P("notifications/initialized"),params:Je.optional()});var Ts=he.extend({method:P("ping"),params:Ke.optional()}),bw=k({progress:K(),total:se(K()),message:se(S())}),Ew=k({...Je.shape,...bw.shape,progressToken:Hh}),Rs=Xe.extend({method:P("notifications/progress"),params:Ew}),vw=Ke.extend({cursor:Wh.optional()}),zn=he.extend({params:vw.optional()}),Dn=ge.extend({nextCursor:Wh.optional()}),ww=De(["working","input_required","completed","failed","cancelled"]),Nn=k({taskId:S(),status:ww,ttl:ee([K(),Ch()]),createdAt:S(),lastUpdatedAt:S(),pollInterval:se(K()),statusMessage:se(S())}),Lr=ge.extend({task:Nn}),kw=Je.merge(Nn),Ln=Xe.extend({method:P("notifications/tasks/status"),params:kw}),Os=he.extend({method:P("tasks/get"),params:Ke.extend({taskId:S()})}),Is=ge.merge(Nn),As=he.extend({method:P("tasks/result"),params:Ke.extend({taskId:S()})}),fz=ge.loose(),Cs=zn.extend({method:P("tasks/list")}),Ms=Dn.extend({tasks:U(Nn)}),zs=he.extend({method:P("tasks/cancel"),params:Ke.extend({taskId:S()})}),Qh=ge.merge(Nn),eg=k({uri:S(),mimeType:se(S()),_meta:J(S(),oe()).optional()}),tg=eg.extend({text:S()}),gc=S().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),rg=eg.extend({blob:gc}),jn=De(["user","assistant"]),jr=k({audience:U(jn).optional(),priority:K().min(0).max(1).optional(),lastModified:vs.datetime({offset:!0}).optional()}),ng=k({...Nr.shape,...Mn.shape,uri:S(),description:se(S()),mimeType:se(S()),size:se(K()),annotations:jr.optional(),_meta:se($e({}))}),xw=k({...Nr.shape,...Mn.shape,uriTemplate:S(),description:se(S()),mimeType:se(S()),annotations:jr.optional(),_meta:se($e({}))}),Pw=zn.extend({method:P("resources/list")}),$w=Dn.extend({resources:U(ng)}),Tw=zn.extend({method:P("resources/templates/list")}),Rw=Dn.extend({resourceTemplates:U(xw)}),_c=Ke.extend({uri:S()}),Ow=_c,Iw=he.extend({method:P("resources/read"),params:Ow}),Aw=ge.extend({contents:U(ee([tg,rg]))}),Cw=Xe.extend({method:P("notifications/resources/list_changed"),params:Je.optional()}),Mw=_c,zw=he.extend({method:P("resources/subscribe"),params:Mw}),Dw=_c,Nw=he.extend({method:P("resources/unsubscribe"),params:Dw}),Lw=Je.extend({uri:S()}),jw=Xe.extend({method:P("notifications/resources/updated"),params:Lw}),Uw=k({name:S(),description:se(S()),required:se(fe())}),Fw=k({...Nr.shape,...Mn.shape,description:se(S()),arguments:se(U(Uw)),_meta:se($e({}))}),qw=zn.extend({method:P("prompts/list")}),Zw=Dn.extend({prompts:U(Fw)}),Hw=Ke.extend({name:S(),arguments:J(S(),S()).optional()}),Ww=he.extend({method:P("prompts/get"),params:Hw}),yc=k({type:P("text"),text:S(),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),Sc=k({type:P("image"),data:gc,mimeType:S(),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),bc=k({type:P("audio"),data:gc,mimeType:S(),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),Vw=k({type:P("tool_use"),name:S(),id:S(),input:J(S(),oe()),_meta:J(S(),oe()).optional()}),Kw=k({type:P("resource"),resource:ee([tg,rg]),annotations:jr.optional(),_meta:J(S(),oe()).optional()}),Bw=ng.extend({type:P("resource_link")}),Ec=ee([yc,Sc,bc,Bw,Kw]),Gw=k({role:jn,content:Ec}),Yw=ge.extend({description:S().optional(),messages:U(Gw)}),Jw=Xe.extend({method:P("notifications/prompts/list_changed"),params:Je.optional()}),Xw=k({title:S().optional(),readOnlyHint:fe().optional(),destructiveHint:fe().optional(),idempotentHint:fe().optional(),openWorldHint:fe().optional()}),Qw=k({taskSupport:De(["required","optional","forbidden"]).optional()}),og=k({...Nr.shape,...Mn.shape,description:S().optional(),inputSchema:k({type:P("object"),properties:J(S(),de).optional(),required:U(S()).optional()}).catchall(oe()),outputSchema:k({type:P("object"),properties:J(S(),de).optional(),required:U(S()).optional()}).catchall(oe()).optional(),annotations:Xw.optional(),execution:Qw.optional(),_meta:J(S(),oe()).optional()}),vc=zn.extend({method:P("tools/list")}),e0=Dn.extend({tools:U(og)}),Ds=ge.extend({content:U(Ec).default([]),structuredContent:J(S(),oe()).optional(),isError:fe().optional()}),pz=Ds.or(ge.extend({toolResult:oe()})),t0=An.extend({name:S(),arguments:J(S(),oe()).optional()}),Un=he.extend({method:P("tools/call"),params:t0}),r0=Xe.extend({method:P("notifications/tools/list_changed"),params:Je.optional()}),mz=k({autoRefresh:fe().default(!0),debounceMs:K().int().nonnegative().default(300)}),Fn=De(["debug","info","notice","warning","error","critical","alert","emergency"]),n0=Ke.extend({level:Fn}),wc=he.extend({method:P("logging/setLevel"),params:n0}),o0=Je.extend({level:Fn,logger:S().optional(),data:oe()}),s0=Xe.extend({method:P("notifications/message"),params:o0}),i0=k({name:S().optional()}),a0=k({hints:U(i0).optional(),costPriority:K().min(0).max(1).optional(),speedPriority:K().min(0).max(1).optional(),intelligencePriority:K().min(0).max(1).optional()}),c0=k({mode:De(["auto","required","none"]).optional()}),u0=k({type:P("tool_result"),toolUseId:S().describe("The unique identifier for the corresponding tool call."),content:U(Ec).default([]),structuredContent:k({}).loose().optional(),isError:fe().optional(),_meta:J(S(),oe()).optional()}),l0=ic("type",[yc,Sc,bc]),ws=ic("type",[yc,Sc,bc,Vw,u0]),d0=k({role:jn,content:ee([ws,U(ws)]),_meta:J(S(),oe()).optional()}),f0=An.extend({messages:U(d0),modelPreferences:a0.optional(),systemPrompt:S().optional(),includeContext:De(["none","thisServer","allServers"]).optional(),temperature:K().optional(),maxTokens:K().int(),stopSequences:U(S()).optional(),metadata:de.optional(),tools:U(og).optional(),toolChoice:c0.optional()}),p0=he.extend({method:P("sampling/createMessage"),params:f0}),qn=ge.extend({model:S(),stopReason:se(De(["endTurn","stopSequence","maxTokens"]).or(S())),role:jn,content:l0}),kc=ge.extend({model:S(),stopReason:se(De(["endTurn","stopSequence","maxTokens","toolUse"]).or(S())),role:jn,content:ee([ws,U(ws)])}),m0=k({type:P("boolean"),title:S().optional(),description:S().optional(),default:fe().optional()}),h0=k({type:P("string"),title:S().optional(),description:S().optional(),minLength:K().optional(),maxLength:K().optional(),format:De(["email","uri","date","date-time"]).optional(),default:S().optional()}),g0=k({type:De(["number","integer"]),title:S().optional(),description:S().optional(),minimum:K().optional(),maximum:K().optional(),default:K().optional()}),_0=k({type:P("string"),title:S().optional(),description:S().optional(),enum:U(S()),default:S().optional()}),y0=k({type:P("string"),title:S().optional(),description:S().optional(),oneOf:U(k({const:S(),title:S()})),default:S().optional()}),S0=k({type:P("string"),title:S().optional(),description:S().optional(),enum:U(S()),enumNames:U(S()).optional(),default:S().optional()}),b0=ee([_0,y0]),E0=k({type:P("array"),title:S().optional(),description:S().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({type:P("string"),enum:U(S())}),default:U(S()).optional()}),v0=k({type:P("array"),title:S().optional(),description:S().optional(),minItems:K().optional(),maxItems:K().optional(),items:k({anyOf:U(k({const:S(),title:S()}))}),default:U(S()).optional()}),w0=ee([E0,v0]),k0=ee([S0,b0,w0]),x0=ee([k0,m0,h0,g0]),P0=An.extend({mode:P("form").optional(),message:S(),requestedSchema:k({type:P("object"),properties:J(S(),x0),required:U(S()).optional()})}),$0=An.extend({mode:P("url"),message:S(),elicitationId:S(),url:S().url()}),T0=ee([P0,$0]),R0=he.extend({method:P("elicitation/create"),params:T0}),O0=Je.extend({elicitationId:S()}),I0=Xe.extend({method:P("notifications/elicitation/complete"),params:O0}),Ur=ge.extend({action:De(["accept","decline","cancel"]),content:ac(e=>e===null?void 0:e,J(S(),ee([S(),K(),fe(),U(S())])).optional())}),A0=k({type:P("ref/resource"),uri:S()});var C0=k({type:P("ref/prompt"),name:S()}),M0=Ke.extend({ref:ee([C0,A0]),argument:k({name:S(),value:S()}),context:k({arguments:J(S(),S()).optional()}).optional()}),z0=he.extend({method:P("completion/complete"),params:M0});var D0=ge.extend({completion:$e({values:U(S()).max(100),total:se(K().int()),hasMore:se(fe())})}),N0=k({uri:S().startsWith("file://"),name:S().optional(),_meta:J(S(),oe()).optional()}),L0=he.extend({method:P("roots/list"),params:Ke.optional()}),xc=ge.extend({roots:U(N0)}),j0=Xe.extend({method:P("notifications/roots/list_changed"),params:Je.optional()}),hz=ee([Ts,mc,z0,wc,Ww,qw,Pw,Tw,Iw,zw,Nw,Un,vc,Os,As,Cs,zs]),gz=ee([$s,Rs,hc,j0,Ln]),_z=ee([Ps,qn,kc,Ur,xc,Is,Ms,Lr]),yz=ee([Ts,p0,R0,L0,Os,As,Cs,zs]),Sz=ee([$s,Rs,s0,jw,Cw,r0,Jw,Ln,I0]),bz=ee([Ps,Sw,D0,Yw,Zw,$w,Rw,Aw,Ds,e0,Is,Ms,Lr]),A=class e extends Error{constructor(t,r,n){super(`MCP error ${t}: ${r}`),this.code=t,this.data=n,this.name="McpError"}static fromError(t,r,n){if(t===L.UrlElicitationRequired&&n){let o=n;if(o.elicitations)return new cc(o.elicitations,r)}return new e(t,r,n)}},cc=class extends A{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(L.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Vt(e){return e==="completed"||e==="failed"||e==="cancelled"}var Qz=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Pc(e){let r=gs(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let n=_s(r);if(typeof n!="string")throw new Error("Schema method literal must be a string");return n}function $c(e,t){let r=Ht(e,t);if(!r.success)throw r.error;return r.data}var W0=6e4,Ns=class{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler($s,r=>{this._oncancel(r)}),this.setNotificationHandler(Rs,r=>{this._onprogress(r)}),this.setRequestHandler(Ts,r=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Os,async(r,n)=>{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(L.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(As,async(r,n)=>{let o=async()=>{let s=r.params.taskId;if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(s,n.sessionId);){if(a.type==="response"||a.type==="error"){let c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{let d=c,f=new A(d.error.code,d.error.message,d.error.data);l(f)}else{let d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:n.requestId})}}let i=await this._taskStore.getTask(s,n.sessionId);if(!i)throw new A(L.InvalidParams,`Task not found: ${s}`);if(!Vt(i.status))return await this._waitForTaskUpdate(s,n.signal),await o();if(Vt(i.status)){let a=await this._taskStore.getTaskResult(s,n.sessionId);return this._clearTaskQueue(s),{...a,_meta:{...a._meta,[Wt]:{taskId:s}}}}return await o()};return await o()}),this.setRequestHandler(Cs,async(r,n)=>{try{let{tasks:o,nextCursor:s}=await this._taskStore.listTasks(r.params?.cursor,n.sessionId);return{tasks:o,nextCursor:s,_meta:{}}}catch(o){throw new A(L.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(zs,async(r,n)=>{try{let o=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!o)throw new A(L.InvalidParams,`Task not found: ${r.params.taskId}`);if(Vt(o.status))throw new A(L.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",n.sessionId),this._clearTaskQueue(r.params.taskId);let s=await this._taskStore.getTask(r.params.taskId,n.sessionId);if(!s)throw new A(L.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`);return{_meta:{},...s}}catch(o){throw o instanceof A?o:new A(L.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,r,n,o,s=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,r),startTime:Date.now(),timeout:r,maxTotalTimeout:n,resetTimeoutOnProgress:s,onTimeout:o})}_resetTimeout(t){let r=this._timeoutInfo.get(t);if(!r)return!1;let n=Date.now()-r.startTime;if(r.maxTotalTimeout&&n>=r.maxTotalTimeout)throw this._timeoutInfo.delete(t),A.fromError(L.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:n});return clearTimeout(r.timeoutId),r.timeoutId=setTimeout(r.onTimeout,r.timeout),!0}_cleanupTimeout(t){let r=this._timeoutInfo.get(t);r&&(clearTimeout(r.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;let r=this.transport?.onclose;this._transport.onclose=()=>{r?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=s=>{n?.(s),this._onerror(s)};let o=this._transport?.onmessage;this._transport.onmessage=(s,i)=>{o?.(s,i),Cn(s)||Yh(s)?this._onresponse(s):dc(s)?this._onrequest(s,i):Gh(s)?this._onnotification(s):this._onerror(new Error(`Unknown message type: ${JSON.stringify(s)}`))},await this._transport.start()}_onclose(){let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let n of this._timeoutInfo.values())clearTimeout(n.timeoutId);this._timeoutInfo.clear();for(let n of this._requestHandlerAbortControllers.values())n.abort();this._requestHandlerAbortControllers.clear();let r=A.fromError(L.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let n of t.values())n(r)}_onerror(t){this.onerror?.(t)}_onnotification(t){let r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;r!==void 0&&Promise.resolve().then(()=>r(t)).catch(n=>this._onerror(new Error(`Uncaught error in notification handler: ${n}`)))}_onrequest(t,r){let n=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,s=t.params?._meta?.[Wt]?.taskId;if(n===void 0){let l={jsonrpc:"2.0",id:t.id,error:{code:L.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(t.id,i);let a=Vh(t.params)?t.params.task:void 0,c=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,u={signal:i.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async l=>{if(i.signal.aborted)return;let d={relatedRequestId:t.id};s&&(d.relatedTask={taskId:s}),await this.notification(l,d)},sendRequest:async(l,d,f)=>{if(i.signal.aborted)throw new A(L.ConnectionClosed,"Request was cancelled");let p={...f,relatedRequestId:t.id};s&&!p.relatedTask&&(p.relatedTask={taskId:s});let m=p.relatedTask?.taskId??s;return m&&c&&await c.updateTaskStatus(m,"input_required"),await this.request(l,d,p)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:s,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{a&&this.assertTaskHandlerCapability(t.method)}).then(()=>n(t,u)).then(async l=>{if(i.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:t.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:t.id,error:{code:Number.isSafeInteger(l.code)?l.code:L.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(t.id)===i&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){let{progressToken:r,...n}=t.params,o=Number(r),s=this._progressHandlers.get(o);if(!s){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}let i=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&i&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),i(c);return}s(n)}_onresponse(t){let r=Number(t.id),n=this._requestResolvers.get(r);if(n){if(this._requestResolvers.delete(r),Cn(t))n(t);else{let i=new A(t.error.code,t.error.message,t.error.data);n(i)}return}let o=this._responseHandlers.get(r);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(r),this._cleanupTimeout(r);let s=!1;if(Cn(t)&&t.result&&typeof t.result=="object"){let i=t.result;if(i.task&&typeof i.task=="object"){let a=i.task;typeof a.taskId=="string"&&(s=!0,this._taskProgressTokens.set(a.taskId,r))}}if(s||this._progressHandlers.delete(r),Cn(t))o(t);else{let i=A.fromError(t.error.code,t.error.message,t.error.data);o(i)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,n){let{task:o}=n??{};if(!o){try{yield{type:"result",result:await this.request(t,r,n)}}catch(i){yield{type:"error",error:i instanceof A?i:new A(L.InternalError,String(i))}}return}let s;try{let i=await this.request(t,Lr,n);if(i.task)s=i.task.taskId,yield{type:"taskCreated",task:i.task};else throw new A(L.InternalError,"Task creation did not return a task");for(;;){let a=await this.getTask({taskId:s},n);if(yield{type:"taskStatus",task:a},Vt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)}:a.status==="failed"?yield{type:"error",error:new A(L.InternalError,`Task ${s} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new A(L.InternalError,`Task ${s} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:s},r,n)};return}let c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),n?.signal?.throwIfAborted()}}catch(i){yield{type:"error",error:i instanceof A?i:new A(L.InternalError,String(i))}}}request(t,r,n){let{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i,task:a,relatedTask:c}=n??{};return new Promise((u,l)=>{let d=E=>{l(E)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(E){d(E);return}n?.signal?.throwIfAborted();let f=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:f};n?.onprogress&&(this._progressHandlers.set(f,n.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Wt]:c}});let m=E=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(E)}},{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(I=>this._onerror(new Error(`Failed to send cancellation: ${I}`)));let v=E instanceof A?E:new A(L.RequestTimeout,String(E));l(v)};this._responseHandlers.set(f,E=>{if(!n?.signal?.aborted){if(E instanceof Error)return l(E);try{let v=Ht(r,E.result);v.success?u(v.data):l(v.error)}catch(v){l(v)}}}),n?.signal?.addEventListener("abort",()=>{m(n?.signal?.reason)});let h=n?.timeout??W0,g=()=>m(A.fromError(L.RequestTimeout,"Request timed out",{timeout:h}));this._setupTimeout(f,h,n?.maxTotalTimeout,g,n?.resetTimeoutOnProgress??!1);let y=c?.taskId;if(y){let E=v=>{let I=this._responseHandlers.get(f);I?I(v):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,E),this._enqueueTaskMessage(y,{type:"request",message:p,timestamp:Date.now()}).catch(v=>{this._cleanupTimeout(f),l(v)})}else this._transport.send(p,{relatedRequestId:o,resumptionToken:s,onresumptiontoken:i}).catch(E=>{this._cleanupTimeout(f),l(E)})})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Is,r)}async getTaskResult(t,r,n){return this.request({method:"tasks/result",params:t},r,n)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Ms,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},Qh,r)}async notification(t,r){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);let n=r?.relatedTask?.taskId;if(n){let a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Wt]:r.relatedTask}}};await this._enqueueTaskMessage(n,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};r?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Wt]:r.relatedTask}}}),this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let i={...t,jsonrpc:"2.0"};r?.relatedTask&&(i={...i,params:{...i.params,_meta:{...i.params?._meta||{},[Wt]:r.relatedTask}}}),await this._transport.send(i,r)}setRequestHandler(t,r){let n=Pc(t);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(o,s)=>{let i=$c(t,o);return Promise.resolve(r(i,s))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,r){let n=Pc(t);this._notificationHandlers.set(n,o=>{let s=$c(t,o);return Promise.resolve(r(s))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){let r=this._taskProgressTokens.get(t);r!==void 0&&(this._progressHandlers.delete(r),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,r,n){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,n,o)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(t,r);for(let o of n)if(o.type==="request"&&dc(o.message)){let s=o.message.id,i=this._requestResolvers.get(s);i?(i(new A(L.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(s)):this._onerror(new Error(`Resolver missing for request ${s} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,r){let n=this._options?.defaultTaskPollInterval??1e3;try{let o=await this._taskStore?.getTask(t);o?.pollInterval&&(n=o.pollInterval)}catch{}return new Promise((o,s)=>{if(r.aborted){s(new A(L.InvalidRequest,"Request cancelled"));return}let i=setTimeout(o,n);r.addEventListener("abort",()=>{clearTimeout(i),s(new A(L.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,r){let n=this._taskStore;if(!n)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await n.createTask(o,t.id,{method:t.method,params:t.params},r)},getTask:async o=>{let s=await n.getTask(o,r);if(!s)throw new A(L.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=Ln.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Vt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>n.getTaskResult(o,r),updateTaskStatus:async(o,s,i)=>{let a=await n.getTask(o,r);if(!a)throw new A(L.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Vt(a.status))throw new A(L.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=Ln.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Vt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>n.listTasks(o,r)}}};function sg(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ig(e,t){let r={...e};for(let n in t){let o=n,s=t[o];if(s===void 0)continue;let i=r[o];sg(i)&&sg(s)?r[o]={...i,...s}:r[o]=s}return r}var iS=Lt(yl(),1),aS=Lt(sS(),1);function rO(){let e=new iS.default({strict:!1,validateFormats:!0,validateSchema:!1,allErrors:!0});return(0,aS.default)(e),e}var bi=class{constructor(t){this._ajv=t??rO()}getValidator(t){let r="$id"in t&&typeof t.$id=="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return n=>r(n)?{valid:!0,data:n,errorMessage:void 0}:{valid:!1,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}};var Ei=class{constructor(t){this._server=t}requestStream(t,r,n){return this._server.requestStream(t,r,n)}createMessageStream(t,r){let n=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!n?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let o=t.messages[t.messages.length-1],s=Array.isArray(o.content)?o.content:[o.content],i=s.some(l=>l.type==="tool_result"),a=t.messages.length>1?t.messages[t.messages.length-2]:void 0,c=a?Array.isArray(a.content)?a.content:[a.content]:[],u=c.some(l=>l.type==="tool_use");if(i){if(s.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(f=>f.type==="tool_use").map(f=>f.id)),d=new Set(s.filter(f=>f.type==="tool_result").map(f=>f.toolUseId));if(l.size!==d.size||![...l].every(f=>d.has(f)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:t},qn,r)}elicitInputStream(t,r){let n=this._server.getClientCapabilities(),o=t.mode??"form";switch(o){case"url":{if(!n?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case"form":{if(!n?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let s=o==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:s},Ur,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,n){return this._server.getTaskResult({taskId:t},r,n)}async listTasks(t,r){return this._server.listTasks(t?{cursor:t}:void 0,r)}async cancelTask(t,r){return this._server.cancelTask({taskId:t},r)}};function cS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"tools/call":if(!e.tools?.call)throw new Error(`${r} does not support task creation for tools/call (required for ${t})`);break;default:break}}function uS(e,t,r){if(!e)throw new Error(`${r} does not support task creation (required for ${t})`);switch(t){case"sampling/createMessage":if(!e.sampling?.createMessage)throw new Error(`${r} does not support task creation for sampling/createMessage (required for ${t})`);break;case"elicitation/create":if(!e.elicitation?.create)throw new Error(`${r} does not support task creation for elicitation/create (required for ${t})`);break;default:break}}var vi=class extends Ns{constructor(t,r){super(r),this._serverInfo=t,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Fn.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 bi,this.setRequestHandler(mc,n=>this._oninitialize(n)),this.setNotificationHandler(hc,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(wc,async(n,o)=>{let s=o.sessionId||o.requestInfo?.headers["mcp-session-id"]||void 0,{level:i}=n.params,a=Fn.safeParse(i);return a.success&&this._loggingLevels.set(s,a.data),{}})}get experimental(){return this._experimental||(this._experimental={tasks:new Ei(this)}),this._experimental}registerCapabilities(t){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=ig(this._capabilities,t)}setRequestHandler(t,r){let o=gs(t)?.method;if(!o)throw new Error("Schema is missing a method literal");let s=_s(o);if(typeof s!="string")throw new Error("Schema method literal must be a string");if(s==="tools/call"){let a=async(c,u)=>{let l=Ht(Un,c);if(!l.success){let m=l.error instanceof Error?l.error.message:String(l.error);throw new A(L.InvalidParams,`Invalid tools/call request: ${m}`)}let{params:d}=l.data,f=await Promise.resolve(r(c,u));if(d.task){let m=Ht(Lr,f);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new A(L.InvalidParams,`Invalid task creation result: ${h}`)}return m.data}let p=Ht(Ds,f);if(!p.success){let m=p.error instanceof Error?p.error.message:String(p.error);throw new A(L.InvalidParams,`Invalid tools/call result: ${m}`)}return p.data};return super.setRequestHandler(t,a)}return super.setRequestHandler(t,r)}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${t})`);break;case"elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${t})`);break;case"roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${t})`);break;case"ping":break}}assertNotificationCapability(t){switch(t){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${t})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${t})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${t})`);break;case"notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${t})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability(t){if(this._capabilities)switch(t){case"completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${t})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${t})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${t})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${t})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${t})`);break;case"tasks/get":case"tasks/list":case"tasks/result":case"tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${t})`);break;case"ping":case"initialize":break}}assertTaskCapability(t){uS(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){this._capabilities&&cS(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){let r=t.params.protocolVersion;return this._clientCapabilities=t.params.capabilities,this._clientVersion=t.params.clientInfo,{protocolVersion:Zh.includes(r)?r:uc,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"},Ps)}async createMessage(t,r){if((t.tools||t.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(t.messages.length>0){let n=t.messages[t.messages.length-1],o=Array.isArray(n.content)?n.content:[n.content],s=o.some(u=>u.type==="tool_result"),i=t.messages.length>1?t.messages[t.messages.length-2]:void 0,a=i?Array.isArray(i.content)?i.content:[i.content]:[],c=a.some(u=>u.type==="tool_use");if(s){if(o.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(o.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return t.tools?this.request({method:"sampling/createMessage",params:t},kc,r):this.request({method:"sampling/createMessage",params:t},qn,r)}async elicitInput(t,r){switch(t.mode??"form"){case"url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let o=t;return this.request({method:"elicitation/create",params:o},Ur,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let o=t.mode==="form"?t:{...t,mode:"form"},s=await this.request({method:"elicitation/create",params:o},Ur,r);if(s.action==="accept"&&s.content&&o.requestedSchema)try{let a=this._jsonSchemaValidator.getValidator(o.requestedSchema)(s.content);if(!a.valid)throw new A(L.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}catch(i){throw i instanceof A?i:new A(L.InternalError,`Error validating elicitation response: ${i instanceof Error?i.message:String(i)}`)}return s}}}createElicitationCompletionNotifier(t,r){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:t}},r)}async listRoots(t,r){return this.request({method:"roots/list",params:t},xc,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging&&!this.isMessageIgnored(t.level,r))return this.notification({method:"notifications/message",params:t})}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var Pl=Lt(require("node:process"),1);var nO=10*1024*1024,wi=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??nO}append(t){if((this._buffer?.length??0)+t.length>this._maxBufferSize)throw this.clear(),new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,t]):t}readMessage(){if(!this._buffer)return null;let t=this._buffer.indexOf(`
79
+ `);if(t===-1)return null;let r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");return this._buffer=this._buffer.subarray(t+1),oO(r)}clear(){this._buffer=void 0}};function oO(e){return Jh.parse(JSON.parse(e))}function lS(e){return JSON.stringify(e)+`
80
+ `}var ki=class{constructor(t=Pl.default.stdin,r=Pl.default.stdout,n){this._stdin=t,this._stdout=r,this._started=!1,this._ondata=o=>{try{this._readBuffer.append(o),this.processReadBuffer()}catch(s){this.onerror?.(s),this.close().catch(()=>{})}},this._onerror=o=>{this.onerror?.(o)},this._readBuffer=new wi({maxBufferSize:n?.maxBufferSize})}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){for(;;)try{let t=this._readBuffer.readMessage();if(t===null)break;this.onmessage?.(t)}catch(t){this.onerror?.(t)}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.()}send(t){return new Promise(r=>{let n=lS(t);this._stdout.write(n)?r():this._stdout.once("drain",r)})}};var Ae=Lt(require("path"),1);var Ce=require("fs");var $l=require("node:child_process");function xi(e,t,r){return(0,$l.spawn)(e,t??[],{windowsHide:!0,...r})}var sO=new Set([".cmd",".bat"]),iO=new Set([".exe",".com"]),T1=new Set([...iO,...sO]);ne();var Oe={HEALTH_CHECK:3e3,API_REQUEST:3e4,HOOK_READINESS_WAIT:1e4,POST_SPAWN_WAIT:15e3,READINESS_WAIT:3e4,PORT_IN_USE_WAIT:3e3,POWERSHELL_COMMAND:1e4,WINDOWS_MULTIPLIER:1.5};function tr(e){return process.platform==="win32"?Math.round(e*Oe.WINDOWS_MULTIPLIER):e}var Pi=require("fs"),Tl=require("path"),Eo=require("os");Pr();var aO="security_alert",ht=class{static DEFAULTS={CLAUDE_MEM_MODEL:"claude-haiku-4-5-20251001",CLAUDE_MEM_CONTEXT_OBSERVATIONS:"50",CLAUDE_MEM_WORKER_PORT:String(37700+(process.getuid?.()??77)%100),CLAUDE_MEM_WORKER_HOST:"127.0.0.1",CLAUDE_MEM_API_TIMEOUT_MS:String(tr(Oe.API_REQUEST)),CLAUDE_MEM_SKIP_TOOLS:"ListMcpResourcesTool,SlashCommand,Skill,TodoWrite,AskUserQuestion",CLAUDE_MEM_PROVIDER:"claude",CLAUDE_MEM_CLAUDE_AUTH_METHOD:"subscription",CLAUDE_MEM_GEMINI_API_KEY:"",CLAUDE_MEM_GEMINI_MODEL:"gemini-flash-latest",CLAUDE_MEM_GEMINI_RATE_LIMITING_ENABLED:"true",CLAUDE_MEM_OPENROUTER_API_KEY:"",CLAUDE_MEM_OPENROUTER_MODEL:"xiaomi/mimo-v2-flash:free",CLAUDE_MEM_OPENROUTER_BASE_URL:"",CLAUDE_MEM_OPENROUTER_SITE_URL:"",CLAUDE_MEM_OPENROUTER_APP_NAME:"claude-mem",CLAUDE_MEM_DATA_DIR:(0,Tl.join)((0,Eo.homedir)(),".claude-mem"),CLAUDE_MEM_LOG_LEVEL:"INFO",CLAUDE_MEM_PYTHON_VERSION:"3.13",CLAUDE_CODE_PATH:"",CLAUDE_MEM_CLAUDE_CONFIG_DIR:"",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,Tl.join)((0,Eo.homedir)(),".claude-mem","transcript-watch.json"),CLAUDE_MEM_CODEX_TRANSCRIPT_INGESTION:"false",CLAUDE_MEM_MAX_CONCURRENT_AGENTS:"2",CLAUDE_MEM_OBSERVER_MAX_CONVERSATION_CHARS:"400000",CLAUDE_MEM_HOOK_FAIL_LOUD_THRESHOLD:"3",CLAUDE_MEM_EXCLUDED_PROJECTS:"",CLAUDE_MEM_FOLDER_MD_EXCLUDE:"[]",CLAUDE_MEM_FOLDER_MD_SKELETON_DENYLIST:"[]",CLAUDE_MEM_SEMANTIC_INJECT:"false",CLAUDE_MEM_SEMANTIC_INJECT_LIMIT:"5",CLAUDE_MEM_TIER_ROUTING_ENABLED:"true",CLAUDE_MEM_TIER_SIMPLE_MODEL:"haiku",CLAUDE_MEM_TIER_SUMMARY_MODEL:"",CLAUDE_MEM_TIER_FAST_MODEL:"haiku",CLAUDE_MEM_TIER_SMART_MODEL:"sonnet",CLAUDE_MEM_CHROMA_ENABLED:"true",CLAUDE_MEM_CHROMA_MODE:"local",CLAUDE_MEM_CHROMA_HOST:"127.0.0.1",CLAUDE_MEM_CHROMA_PORT:"8000",CLAUDE_MEM_CHROMA_SSL:"false",CLAUDE_MEM_CHROMA_API_KEY:"",CLAUDE_MEM_CHROMA_TENANT:"default_tenant",CLAUDE_MEM_CHROMA_DATABASE:"default_database",CLAUDE_MEM_CHROMA_PREWARM_TIMEOUT_MS:"120000",CLAUDE_MEM_CHROMA_MAX_PENDING_MUTATIONS:"5000",CLAUDE_MEM_CLOUD_SYNC_TOKEN:"",CLAUDE_MEM_CLOUD_SYNC_USER_ID:"",CLAUDE_MEM_CLOUD_SYNC_HUB_URL:"",CLAUDE_MEM_CLOUD_SYNC_DEVICE_ID:"",CLAUDE_MEM_CLOUD_SYNC_DEVICE_NAME:(0,Eo.hostname)(),CLAUDE_MEM_CLOUD_SYNC_WS:"true",CLAUDE_MEM_CLOUD_SYNC_CONTENT_BATCH_SIZE:"40",CLAUDE_MEM_CLOUD_SYNC_REQUEST_TIMEOUT_MS:"90000",CLAUDE_MEM_TV_TOKEN:"",CLAUDE_MEM_PRO_TRIAL_EMAIL:"",CLAUDE_MEM_PRO_TRIAL_AT:"",CLAUDE_MEM_PRO_TRIAL_STATE:"",CLAUDE_MEM_PRO_TRIAL_ENDS_AT:"",CLAUDE_MEM_PRO_PLAN:"",CLAUDE_MEM_PRO_FALLBACK_AT:"",CLAUDE_MEM_PRO_MEMORY_KEY:"",CLAUDE_MEM_PRO_MEMORY_BASE_URL:"",CLAUDE_MEM_PRO_MEMORY_MODEL:"",CLAUDE_MEM_TELEGRAM_ENABLED:"true",CLAUDE_MEM_TELEGRAM_BOT_TOKEN:"",CLAUDE_MEM_TELEGRAM_CHAT_ID:"",CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:"security_alert,sensitive",CLAUDE_MEM_TELEGRAM_TRIGGER_CONCEPTS:"",CLAUDE_MEM_GROK_BOT_AWARENESS_ENABLED:"true",CLAUDE_MEM_GROK_BOT_AWARENESS_AGENT_IDS:"521e962d-2ec3-4488-bfbc-54d5209ce118,95601360-61f7-4fd9-bb3a-2c976b2b85c0",CLAUDE_MEM_GROK_BOT_AWARENESS_TRIGGER_TYPES:"decision,bugfix,security_alert,sensitive",CLAUDE_MEM_GROK_BOT_AWARENESS_TRIGGER_CONCEPTS:"",CLAUDE_MEM_CCS_ALIGN_ENABLED:"true",CLAUDE_MEM_CCS_ALIGN_VIEWER_IDS:"ccs-align",CLAUDE_MEM_CCS_ALIGN_TRIGGER_TYPES:"decision,bugfix,security_alert,sensitive",CLAUDE_MEM_CCS_ALIGN_PATCH_SHADOWS:"false",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_URL:`http://127.0.0.1:${process.env.CLAUDE_MEM_SERVER_PORT??String(37877+(process.getuid?.()??77)%100)}`,CLAUDE_MEM_SERVER_API_KEY:"",CLAUDE_MEM_SERVER_PROJECT_ID:"",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(t){let r=process.env[t]??this.DEFAULTS[t];return t==="CLAUDE_MEM_WORKER_HOST"?this.normalizeWorkerHost(r):r}static normalizeWorkerHost(t){return t==="localhost"?"127.0.0.1":t}static finalizeSettings(t,r){let n=r?this.applyEnvOverrides(t):t;return n.CLAUDE_MEM_WORKER_HOST=this.normalizeWorkerHost(n.CLAUDE_MEM_WORKER_HOST),n}static getInt(t){let r=this.get(t);return parseInt(r,10)}static applyEnvOverrides(t){let r={...t};for(let n of Object.keys(this.DEFAULTS))process.env[n]!==void 0&&(r[n]=process.env[n]);return r}static loadFromFile(t,r=!0){try{if(!(0,Pi.existsSync)(t)){let u=this.getAllDefaults();try{dn(t,u),console.warn("[SETTINGS] Created settings file with defaults:",t)}catch(l){console.warn("[SETTINGS] Failed to create settings file, using in-memory defaults:",t,l instanceof Error?l.message:String(l))}return this.finalizeSettings(u,r)}let n=(0,Pi.readFileSync)(t,"utf-8"),o=or(n),s=o,i=o.env&&typeof o.env=="object"&&!Array.isArray(o.env),a=i&&Object.keys(o).some(u=>u!=="env");if(i&&(s=o.env,!a))try{dn(t,s),console.warn("[SETTINGS] Migrated settings file from nested to flat schema:",t)}catch(u){console.warn("[SETTINGS] Failed to auto-migrate settings file:",t,u instanceof Error?u.message:String(u))}if(s.CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES===aO){s={...s,CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES:this.DEFAULTS.CLAUDE_MEM_TELEGRAM_TRIGGER_TYPES};try{dn(t,a?{...o,env:s}:s),console.warn("[SETTINGS] Migrated Telegram trigger types off the legacy default:",t)}catch(u){console.warn("[SETTINGS] Failed to migrate Telegram trigger types:",t,u instanceof Error?u.message:String(u))}}let c={...this.DEFAULTS};for(let u of Object.keys(this.DEFAULTS))s[u]!==void 0&&(c[u]=s[u]);return this.finalizeSettings(c,r)}catch(n){console.warn("[SETTINGS] Failed to load settings, using defaults:",t,n instanceof Error?n.message:String(n));let o=this.getAllDefaults();return this.finalizeSettings(o,r)}}};Ze();Ze();var $i=null;function Ti(){return $i!==null||($i=ht.loadFromFile(Do)),$i}var vr=require("fs");ne();var Dt=require("fs"),Ml=Lt(require("path"),1);ne();var cO=["CLAUDECODE_","CLAUDE_CODE_"],uO=new Set(["CLAUDECODE","CLAUDE_CODE_SESSION","CLAUDE_CODE_ENTRYPOINT","MCP_SESSION_ID"]),lO=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","npm_config_noproxy"]),dO=new Set(["CLAUDE_CODE_OAUTH_TOKEN","CLAUDE_CODE_GIT_BASH_PATH","CLAUDE_CODE_USE_BEDROCK","CLAUDE_CODE_USE_VERTEX","CLAUDE_CODE_USE_FOUNDRY","CLAUDE_CODE_SKIP_BEDROCK_AUTH","CLAUDE_CODE_SKIP_VERTEX_AUTH","CLAUDE_CODE_SKIP_FOUNDRY_AUTH","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",...lO]);function Er(e=process.env){let t={};for(let[r,n]of Object.entries(e))if(n!==void 0){if(dO.has(r)){t[r]=n;continue}uO.has(r)||cO.some(o=>r.startsWith(o))||(t[r]=n)}return t}Ze();var Ol=require("child_process"),fS=require("fs");ne();var fO=5e3,dS=new Map,Rl=0;function pO(e){Rl+=1;let t=(0,Ol.spawnSync)("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-CimInstance Win32_Process -Filter "ProcessId=${e}").CreationDate.ToString('yyyyMMddHHmmss.ffffff')`],{encoding:"utf-8",timeout:5e3,windowsHide:!0,env:{...Er(process.env),LC_ALL:"C",LANG:"C"}});if(t.status===0){let r=t.stdout.trim();return r.length>0?r:null}return null}function mO(e,t=!1){if(!t){let n=dS.get(e);if(n&&Date.now()-n.capturedAtMs<fO)return n.token}let r=null;try{r=pO(e)}catch(n){_.debug("SYSTEM","captureProcessStartToken: powershell CIM lookup failed",{pid:e,error:n instanceof Error?n.message:String(n)}),r=null}return dS.set(e,{token:r,capturedAtMs:Date.now()}),r}function pS(e,t){if(!Number.isInteger(e)||e<=0)return null;if(process.platform==="linux"){Rl+=1;try{let r=(0,fS.readFileSync)(`/proc/${e}/stat`,"utf-8"),n=r.lastIndexOf(") ");if(n<0)return null;let s=r.slice(n+2).split(" ")[19];return s&&/^\d+$/.test(s)?s:null}catch(r){return _.debug("SYSTEM","captureProcessStartToken: /proc read failed",{pid:e,error:r instanceof Error?r.message:String(r)}),null}}if(process.platform==="win32")return mO(e,t);Rl+=1;try{let r=(0,Ol.spawnSync)("ps",["-p",String(e),"-o","lstart="],{encoding:"utf-8",timeout:2e3,env:{...Er(process.env),LC_ALL:"C",LANG:"C"}});if(r.status!==0)return null;let n=r.stdout.trim();return n.length>0?n:null}catch(r){return _.debug("SYSTEM","captureProcessStartToken: ps exec failed",{pid:e,error:r instanceof Error?r.message:String(r)}),null}}function rr(e){return pS(e,!1)}function zt(e,t){if(t===null)return!0;let r=pS(e,!0);return r===null?!0:r===t}var mS=require("child_process"),Ii=require("fs"),hS=require("util");ne();var Il=(0,hS.promisify)(mS.execFile),hO=128,gO=/not found|no running instance|no tasks/i,Ri=class extends Error{pid;constructor(t,r,n){super(r,n),this.name="ProcessTreeKillError",this.pid=t}};async function gt(e,t={}){let r=t.signalMode==="immediate",n=t.expectedStartToken!==void 0?t.expectedStartToken:rr(e),o=()=>zt(e,n);if(!o()){_.warn("PROCESS","Skipping tree-kill: root PID was reused since it was captured",{pid:e});return}if(_.debug("PROCESS",`Killing process tree rooted at PID ${e}`,{immediate:r}),process.platform==="win32"){try{await Il("taskkill",["/PID",String(e),"/T","/F"],{timeout:5e3,windowsHide:!0})}catch(s){let i=s.code,a=String(s.stderr??""),c=s instanceof Error?s.message:String(s);if(i===hO||gO.test(`${a} ${c}`)){_.debug("PROCESS","taskkill reported the process was already gone",{pid:e});return}throw new Ri(e,`taskkill failed for PID ${e} (exit ${String(i)}): ${a.trim()||c}`,{cause:s})}return}try{let s=r?"SIGKILL":"SIGTERM",i=await Oi(e);for(let u of i){if(!zt(u.pid,u.startToken)){_.debug("PROCESS",`Skipping ${s}: descendant PID was reused since enumeration`,{pid:u.pid,rootPid:e});continue}try{process.kill(u.pid,s)}catch{}}if(o())try{process.kill(e,s)}catch(u){let l=u instanceof Error?u:new Error(String(u)),d=l.code;d!=="ESRCH"&&_.debug("PROCESS",`Failed to ${s} PID ${e}`,{code:d},l)}else _.warn("PROCESS","Skipping root signal: PID was reused during descendant enumeration",{pid:e,signal:s});r||await new Promise(u=>setTimeout(u,500));let a=o()?await Oi(e):[],c=new Map;for(let u of i)c.set(u.pid,u.startToken);for(let u of a)c.set(u.pid,u.startToken);for(let[u,l]of c){if(!zt(u,l)){_.debug("PROCESS","Skipping SIGKILL: descendant PID was reused since the scan",{pid:u,rootPid:e});continue}try{process.kill(u,"SIGKILL")}catch{}}if(!r&&o())try{process.kill(e,"SIGKILL")}catch{}}catch(s){throw new Ri(e,`tree-kill failed for PID ${e}: ${s instanceof Error?s.message:String(s)}`,{cause:s})}}async function _O(){return process.platform==="win32"?bO():process.platform==="linux"?yO():SO()}function yO(){let e=[],t;try{t=(0,Ii.readdirSync)("/proc")}catch(r){return _.warn("PROCESS","Cannot read /proc \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),e}for(let r of t){if(!/^\d+$/.test(r))continue;let n;try{n=(0,Ii.readFileSync)(`/proc/${r}/stat`,"utf-8")}catch{continue}let o=n.lastIndexOf(") ");if(o<0)continue;let s=n.slice(o+2).split(" "),i=Number.parseInt(s[1]??"",10),a=s[19];Number.isFinite(i)&&e.push({pid:Number.parseInt(r,10),ppid:i,startToken:a&&/^\d+$/.test(a)?a:null})}return e}async function SO(){let e;try{e=(await Il("ps",["-eo","pid=,ppid=,lstart="],{timeout:1e4,maxBuffer:33554432,env:{...process.env,LC_ALL:"C",LANG:"C"}})).stdout}catch(r){return _.warn("PROCESS","Cannot enumerate the process table \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),[]}let t=[];for(let r of e.split(`
81
+ `)){let n=r.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/);if(!n)continue;let o=n[3].trim();t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),startToken:o.length>0?o:null})}return t}async function bO(){let e;try{e=(await Il("powershell.exe",["-NoProfile","-NonInteractive","-Command","Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,@{Name='StartToken';Expression={$_.CreationDate.ToString('yyyyMMddHHmmss.ffffff')}} | ConvertTo-Csv -NoTypeInformation"],{timeout:3e4,windowsHide:!0,maxBuffer:33554432})).stdout}catch(r){return _.warn("PROCESS","Cannot enumerate the Windows process table \u2014 tree-kill degrades to a single-PID kill",{error:r instanceof Error?r.message:String(r)}),[]}let t=[];for(let r of e.split(/\r?\n/).slice(1)){let n=r.match(/^"(\d+)","(\d+)","(.*)"$/);if(!n)continue;let o=n[3].trim();t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),startToken:o.length>0?o:null})}return t}async function Oi(e){let t=await _O(),r=new Map;for(let i of t){let a=r.get(i.ppid);a?a.push(i):r.set(i.ppid,[i])}let n=new Set([e]),o=[],s=i=>{for(let a of r.get(i)??[])n.has(a.pid)||(n.add(a.pid),s(a.pid),o.push({pid:a.pid,startToken:a.startToken}))};return s(e),o}var EO=5e3,vO=1e3,wO=qe.supervisorRegistry();function pe(e){if(!Number.isInteger(e)||e<0||e===0)return!1;try{return process.kill(e,0),!0}catch(t){if(t instanceof Error){let r=t.code;return r==="EPERM"?!0:(_.debug("SYSTEM","PID check failed",{pid:e,code:r}),!1)}return _.warn("SYSTEM","PID check threw non-Error",{pid:e,error:String(t)}),!1}}async function Ai(e,t){let r=Date.now()+t;for(;Date.now()<r;){if(e.every(n=>!pe(n.pid)))return;await new Promise(n=>setTimeout(n,100))}}function Dl(e){if(!e||!pe(e.pid))return!1;if(!e.startToken)return!0;let t=rr(e.pid);if(t===null)return!0;let r=t===e.startToken;return r||_.debug("SYSTEM","verifyPidFileOwnership: start-token mismatch (PID reused)",{pid:e.pid,stored:e.startToken,current:t}),r}var zl=class{registryPath;entries=new Map;runtimeProcesses=new Map;initialized=!1;constructor(t=wO){this.registryPath=t}initialize(){if(this.initialized)return;if(this.initialized=!0,(0,Dt.mkdirSync)(Ml.default.dirname(this.registryPath),{recursive:!0}),!(0,Dt.existsSync)(this.registryPath)){this.persist();return}try{let n=JSON.parse((0,Dt.readFileSync)(this.registryPath,"utf-8")).processes??{};for(let[o,s]of Object.entries(n))this.entries.set(o,s)}catch(r){r instanceof Error?_.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath},r):_.warn("SYSTEM","Failed to parse supervisor registry, rebuilding",{path:this.registryPath,error:String(r)}),this.entries.clear()}let t=this.pruneDeadEntries();t>0&&_.info("SYSTEM","Removed dead processes from supervisor registry",{removed:t}),this.persist()}register(t,r,n){this.initialize(),this.entries.set(t,r),n&&this.runtimeProcesses.set(t,n),this.persist()}unregister(t){this.initialize();let r=this.entries.get(t);this.entries.delete(t),this.runtimeProcesses.delete(t),this.persist(),r?.type==="sdk"&&Cl()}clear(){this.entries.clear(),this.runtimeProcesses.clear(),this.persist()}getAll(){return this.initialize(),Array.from(this.entries.entries()).map(([t,r])=>({id:t,...r})).sort((t,r)=>{let n=Date.parse(t.startedAt),o=Date.parse(r.startedAt);return(Number.isNaN(n)?0:n)-(Number.isNaN(o)?0:o)})}getBySession(t){let r=String(t);return this.getAll().filter(n=>n.sessionId!==void 0&&String(n.sessionId)===r)}getRuntimeProcess(t){return this.runtimeProcesses.get(t)}pruneDeadEntries(){this.initialize();let t=0,r=0;for(let[n,o]of this.entries)pe(o.pid)||(this.entries.delete(n),this.runtimeProcesses.delete(n),t+=1,o.type==="sdk"&&(r+=1));t>0&&this.persist();for(let n=0;n<r;n+=1)Cl();return t}async reapSession(t){this.initialize();let r=this.getBySession(t);if(r.length===0)return 0;let n=typeof t=="number"?t:Number(t)||void 0;_.info("SYSTEM",`Reaping ${r.length} process(es) for session ${t}`,{sessionId:n,pids:r.map(a=>a.pid)});let o=r.filter(a=>pe(a.pid)),s=new Map(o.map(a=>[a.pid,rr(a.pid)]));for(let a of o)try{process.platform==="win32"?await gt(a.pid,{expectedStartToken:s.get(a.pid)??null}):typeof a.pgid=="number"?process.kill(-a.pgid,"SIGTERM"):process.kill(a.pid,"SIGTERM")}catch(c){c instanceof Error?c.code!=="ESRCH"&&_.debug("SYSTEM",`Failed to SIGTERM session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},c):_.warn("SYSTEM",`Failed to SIGTERM session process PID ${a.pid} (non-Error)`,{pid:a.pid,pgid:a.pgid,error:String(c)})}await Ai(o,EO);let i=o.filter(a=>pe(a.pid));for(let a of i){_.warn("SYSTEM",`Session process PID ${a.pid} did not exit after SIGTERM, sending SIGKILL`,{pid:a.pid,pgid:a.pgid,sessionId:n});let c=s.get(a.pid)??null;if(!zt(a.pid,c)){_.warn("SYSTEM","Skipping SIGKILL: session process PID was reused during the grace window",{pid:a.pid,sessionId:n});continue}try{process.platform==="win32"?await gt(a.pid,{expectedStartToken:c}):typeof a.pgid=="number"?process.kill(-a.pgid,"SIGKILL"):process.kill(a.pid,"SIGKILL")}catch(u){u instanceof Error?u.code!=="ESRCH"&&_.debug("SYSTEM",`Failed to SIGKILL session process PID ${a.pid}`,{pid:a.pid,pgid:a.pgid},u):_.warn("SYSTEM",`Failed to SIGKILL session process PID ${a.pid} (non-Error)`,{pid:a.pid,pgid:a.pgid,error:String(u)})}}if(i.length>0){let a=Date.now()+vO;for(;Date.now()<a&&i.filter(u=>pe(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"&&Cl();return _.info("SYSTEM",`Reaped ${r.length} process(es) for session ${t}`,{sessionId:n,reaped:r.length}),r.length}persist(){let t={processes:Object.fromEntries(this.entries.entries())};(0,Dt.mkdirSync)(Ml.default.dirname(this.registryPath),{recursive:!0}),(0,Dt.writeFileSync)(this.registryPath,JSON.stringify(t,null,2))}},Al=null;function Ci(){return Al||(Al=new zl),Al}var J1=180*1e3,kO=[];function Cl(){let e=kO.shift();e&&e.notify()}var on=require("fs");ne();Ze();var xO=qe.workerPid();async function _S(e){let t=e.currentPid??process.pid,r=e.pidFilePath??xO,n=e.registry.getAll(),o=[...n].filter(c=>c.pid!==t).sort((c,u)=>Date.parse(u.startedAt)-Date.parse(c.startedAt)),s=new Map,i=new Map;for(let c of o){if(!pe(c.pid)){e.registry.unregister(c.id);continue}i.set(c.id,rr(c.pid)),s.set(c.id,await Oi(c.pid));try{await gS(c,"SIGTERM")}catch(u){u instanceof Error?_.debug("SYSTEM","Failed to send SIGTERM to child process",{pid:c.pid,pgid:c.pgid,type:c.type},u):_.warn("SYSTEM","Failed to send SIGTERM to child process (non-Error)",{pid:c.pid,pgid:c.pgid,type:c.type,error:String(u)})}}await Ai(o,5e3);let a=o.filter(c=>pe(c.pid)||(s.get(c.id)??[]).some(u=>pe(u.pid)));for(let c of a){let u=zt(c.pid,i.get(c.id)??null);u||_.warn("SYSTEM","Skipping tree-kill: root PID was reused during the grace window",{pid:c.pid,type:c.type});try{u&&await gS(c,"SIGKILL")}catch(l){l instanceof Error?_.debug("SYSTEM","Failed to force kill child process",{pid:c.pid,pgid:c.pgid,type:c.type},l):_.warn("SYSTEM","Failed to force kill child process (non-Error)",{pid:c.pid,pgid:c.pgid,type:c.type,error:String(l)})}finally{PO(s.get(c.id)??[],c.pid)}}await Ai(a,1e3);for(let c of o)e.registry.unregister(c.id);for(let c of n.filter(u=>u.pid===t))e.registry.unregister(c.id);yS(r,t),e.registry.pruneDeadEntries()}function yS(e,t,r=!1){if(!(0,on.existsSync)(e))return;let n=null;try{let i=JSON.parse((0,on.readFileSync)(e,"utf-8"));n=typeof i.pid=="number"?i.pid:null}catch(i){_.debug("SYSTEM","PID file unreadable \u2014 leaving it (cannot prove ownership)",{pidFilePath:e,error:i instanceof Error?i.message:String(i)});return}let o=t!==null&&n===t,s=n===null||!pe(n);if(!o&&!(r&&s)){_.debug("SYSTEM","PID file not owned by this process \u2014 leaving it for its owner (restart successor?)",{pidFilePath:e,recordedPid:n,currentPid:t});return}try{(0,on.rmSync)(e,{force:!0})}catch(i){i instanceof Error?_.debug("SYSTEM","Failed to remove PID file",{pidFilePath:e},i):_.warn("SYSTEM","Failed to remove PID file (non-Error)",{pidFilePath:e,error:String(i)})}}function PO(e,t){for(let{pid:r,startToken:n}of e)if(!(r===t||!pe(r))){if(!zt(r,n)){_.debug("SYSTEM","Skipping reap: PID was recycled during the grace window",{pid:r,rootPid:t});continue}try{process.kill(r,"SIGKILL"),_.debug("SYSTEM","Reaped orphaned descendant during shutdown cascade",{pid:r,rootPid:t})}catch(o){let s=o instanceof Error?o.code:void 0;s!=="ESRCH"&&_.warn("SYSTEM","Failed to reap orphaned descendant during shutdown cascade",{pid:r,rootPid:t,errno:s})}}}async function gS(e,t){let{pid:r,pgid:n}=e;if(process.platform!=="win32"){if(typeof n=="number")try{process.kill(-n,t);return}catch(o){if((o instanceof Error?o.code:void 0)!=="ESRCH")throw o}if(t==="SIGKILL"){await gt(r,{signalMode:"immediate"});return}try{process.kill(r,t)}catch(o){if((o instanceof Error?o.code:void 0)!=="ESRCH")throw o}return}await gt(r)}ne();var SS=3e4,sn=null;function $O(){let t=Ci().pruneDeadEntries();t>0&&_.info("SYSTEM",`Health check: pruned ${t} dead process(es) from registry`)}function bS(){sn===null&&(sn=setInterval($O,SS),sn.unref(),_.debug("SYSTEM","Health checker started",{intervalMs:SS}))}function ES(){sn!==null&&(clearInterval(sn),sn=null,_.debug("SYSTEM","Health checker stopped"))}var vS=require("child_process"),wS=require("util");ne();var TO=(0,wS.promisify)(vS.execFile),RO=/(?:^|\/)(?:uvx|uv|python[\d.]*)(?:\s|$).*chroma-mcp/;function OO(e){let t=[];for(let r of e.split(`
82
+ `)){let n=r.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/);n&&t.push({pid:Number.parseInt(n[1],10),ppid:Number.parseInt(n[2],10),command:n[3].trim()})}return t}async function IO(){let e=await TO("ps",["-eo","pid=,ppid=,command="],{timeout:1e4,maxBuffer:33554432});return OO(e.stdout)}function AO(e,t){let r=e.filter(i=>RO.test(i.command)&&i.pid!==t.selfPid),n=new Set(r.map(i=>i.pid)),o=r.filter(i=>!n.has(i.ppid)),s=o.filter(i=>i.ppid===t.selfPid?!1:i.ppid===1?!0:!t.isAlive(i.ppid));return{matched:r,roots:o,orphans:s}}async function kS(e={}){let t=e.platform??process.platform,r={matched:0,trees:0,orphans:0,killed:0,failed:0,unregistered:0,skipped:null};if(t==="win32")return r.skipped="windows",r;let n=e.readTable??IO,o=e.isAlive??pe,s=e.killTree??(p=>gt(p,{signalMode:"graceful"})),i=e.selfPid??process.pid,a;try{a=await n()}catch(p){return _.warn("PROCESS","Orphaned chroma-mcp sweep skipped: cannot read the process table",{error:p instanceof Error?p.message:String(p)}),r.skipped="unreadable",r}let{matched:c,roots:u,orphans:l}=AO(a,{isAlive:o,selfPid:i});if(r.matched=c.length,r.trees=u.length,r.orphans=l.length,l.length===0)return _.debug("PROCESS","No orphaned chroma-mcp trees found",{matched:r.matched,trees:r.trees}),r;_.warn("PROCESS","Reaping orphaned chroma-mcp trees left by dead workers",{orphans:l.length,roots:l.map(p=>p.pid)});let d=new Set,f=8;for(let p=0;p<l.length;p+=f){let m=l.slice(p,p+f);(await Promise.allSettled(m.map(g=>s(g.pid)))).forEach((g,y)=>{let E=m[y];g.status==="fulfilled"?(r.killed+=1,d.add(E.pid)):(r.failed+=1,_.warn("PROCESS","Failed to reap an orphaned chroma-mcp tree",{pid:E.pid,ppid:E.ppid,error:g.reason instanceof Error?g.reason.message:String(g.reason)}))})}if(e.registry)for(let p of e.registry.getAll())p.type==="chroma"&&d.has(p.pid)&&(e.registry.unregister(p.id),r.unregistered+=1);return _.info("PROCESS","Orphaned chroma-mcp sweep finished",{orphans:r.orphans,killed:r.killed,failed:r.failed,unregistered:r.unregistered}),r}Ze();var CO=qe.workerPid(),Nl=class{registry;started=!1;stopPromise=null;signalHandlersRegistered=!1;shutdownInitiated=!1;shutdownHandler=null;constructor(t){this.registry=t}async start(){if(this.started)return;if(this.registry.initialize(),Mi({logAlive:!1})==="alive")throw new Error("Worker already running");this.started=!0,kS({registry:this.registry}).catch(r=>{_.warn("PROCESS","Orphaned chroma-mcp sweep failed",{error:r instanceof Error?r.message:String(r)})}),bS()}configureSignalHandlers(t){if(this.shutdownHandler=t,this.signalHandlersRegistered)return;this.signalHandlersRegistered=!0;let r=async n=>{if(this.shutdownInitiated){_.warn("SYSTEM",`Received ${n} but shutdown already in progress`);return}this.shutdownInitiated=!0,_.info("SYSTEM",`Received ${n}, shutting down...`);try{this.shutdownHandler?await this.shutdownHandler():await this.stop()}catch(o){o instanceof Error?_.error("SYSTEM","Error during shutdown",{},o):_.error("SYSTEM","Error during shutdown (non-Error)",{error:String(o)});try{await this.stop()}catch(s){s instanceof Error?_.debug("SYSTEM","Supervisor shutdown fallback failed",{},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",()=>{_.debug("SYSTEM","Ignoring SIGHUP in daemon mode")}):process.on("SIGHUP",()=>{r("SIGHUP")}))}async stop(){if(this.stopPromise){await this.stopPromise;return}ES(),this.stopPromise=_S({registry:this.registry,currentPid:process.pid}).finally(()=>{this.started=!1,this.stopPromise=null}),await this.stopPromise}assertCanSpawn(t){if(this.stopPromise!==null)throw new Error(`Supervisor is shutting down, refusing to spawn ${t}`)}registerProcess(t,r,n){this.registry.register(t,r,n)}unregisterProcess(t){this.registry.unregister(t)}getRegistry(){return this.registry}},MO=new Nl(Ci());function Ll(){return MO}function Mi(e={}){let t=e.pidFilePath??CO;if(!(0,vr.existsSync)(t))return"missing";let r=null;try{r=JSON.parse((0,vr.readFileSync)(t,"utf-8"))}catch(o){return o instanceof Error?_.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t},o):_.warn("SYSTEM","Failed to parse worker PID file, removing it",{path:t,error:String(o)}),(0,vr.rmSync)(t,{force:!0}),"invalid"}return Dl(r)&&r?((e.logAlive??!0)&&_.info("SYSTEM","Worker already running (PID alive)",{existingPid:r.pid,existingPort:r.port,startedAt:r.startedAt}),"alive"):(_.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,vr.rmSync)(t,{force:!0}),"stale")}Co();Ze();Pr();ne();ne();var Nt=Lt(require("path"),1),$S=require("os"),Ie=require("fs"),vo=require("child_process");ne();ne();ne();Ze();var nF=qe.dataDir(),xS=qe.workerPid(),PS="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.";function zO(e){try{return(0,Ie.realpathSync)(e)}catch{return null}}function jl(e){return e?/(^|[\\/])bun(\.exe)?$/i.test(e.trim()):!1}function DO(e,t){let r=t==="win32"?`where ${e}`:`which ${e}`,n;try{n=(0,vo.execSync)(r,{stdio:["ignore","pipe","ignore"],encoding:"utf-8",windowsHide:!0})}catch(s){return s instanceof Error?_.debug("SYSTEM",`Binary lookup failed for ${e}`,{command:r},s):_.debug("SYSTEM",`Binary lookup failed for ${e}`,{command:r},new Error(String(s))),null}return n.split(/\r?\n/).map(s=>s.trim()).find(s=>s.length>0)||null}var Ul;function Fl(e={}){let t=Object.keys(e).length===0;if(t&&Ul!==void 0)return Ul;let r=NO(e);return t&&r!==null&&(Ul=r),r}function NO(e){let t=e.platform??process.platform,r=e.execPath??process.execPath;if(jl(r))return r;let n=e.env??process.env,o=e.homeDirectory??(0,$S.homedir)(),s=e.pathExists??Ie.existsSync,i=e.lookupInPath??DO,a=e.realpath??zO,c=t==="win32"?[n.BUN,n.BUN_PATH,Nt.default.join(o,".bun","bin","bun.exe"),Nt.default.join(o,".bun","bin","bun"),n.USERPROFILE?Nt.default.join(n.USERPROFILE,".bun","bin","bun.exe"):void 0,n.LOCALAPPDATA?Nt.default.join(n.LOCALAPPDATA,"bun","bun.exe"):void 0,n.LOCALAPPDATA?Nt.default.join(n.LOCALAPPDATA,"bun","bin","bun.exe"):void 0,n.npm_config_prefix?Nt.default.join(n.npm_config_prefix,"bun.exe"):void 0]:[n.BUN,n.BUN_PATH,Nt.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",n.npm_config_prefix?Nt.default.join(n.npm_config_prefix,"bin","bun"):void 0];for(let d of c){let f=d?.trim();if(f&&(jl(f)&&s(f)||f.toLowerCase()==="bun"))return f}let u=i("bun",t)?.trim();if(!u||!jl(u))return null;let l=a(u)??u;return s(l)?l:null}function wr(e){return process.platform==="win32"?Math.round(e*2):e}function TS(){let e=qe.dataDir();return(0,Ie.mkdirSync)(e,{recursive:!0}),e}function LO(e,t,r=TS()){let n=o=>o.replace(/'/g,"''");return`Start-Process -FilePath '${n(e)}' -ArgumentList @('"${n(t)}"','--daemon') -WorkingDirectory '${n(r)}' -WindowStyle Hidden`}var jO=5e3,UO=8;function FO(e,t,r){return e?.code!=="ETIMEDOUT"?!1:t<r/2}function RS(e,t=wr(jO)){let r=Fl();if(!r)return;let n=()=>{let a=Date.now();try{return{result:(0,vo.spawnSync)(r,[e,"status"],{encoding:"utf-8",timeout:t,windowsHide:!0,env:Er({...process.env})}),elapsedMs:Date.now()-a}}catch(c){let u=c instanceof Error?c:new Error(String(c));_.debug("SYSTEM","Worker boot probe could not be launched",{scriptPath:e},u);return}},o=n();if(o===void 0||FO(o.result.error,o.elapsedMs,t)&&(_.debug("SYSTEM","Worker boot probe timed out before it could run \u2014 retrying once",{scriptPath:e,elapsedMs:o.elapsedMs,timeoutMs:t}),o=n(),o===void 0))return;let{result:s}=o;if(s.error||s.status===0)return;let i=`${s.stdout??""}${s.stderr??""}`.trim();if(i)return i.split(/\r?\n/).slice(0,UO).join(`
83
+ `)}function OS(e,t,r={}){Ll().assertCanSpawn("worker daemon");let n=Er({...process.env,CLAUDE_MEM_WORKER_PORT:String(t),...r}),o=Fl();if(!o){_.error("SYSTEM",PS);return}if(process.platform==="win32"){let l=LO(o,e),d=Buffer.from(l,"utf16le").toString("base64");try{return(0,vo.execSync)(`powershell -NoProfile -EncodedCommand ${d}`,{stdio:"ignore",windowsHide:!0,env:n}),0}catch(f){let p=f instanceof Error?f:new Error(String(f));_.error("SYSTEM","Failed to spawn worker daemon on Windows",{runtimePath:o},p);return}}let s="/usr/bin/setsid",i=(0,Ie.existsSync)(s),a=i?s:o,u=xi(a,i?[o,e,"--daemon"]:[e,"--daemon"],{detached:!0,stdio:"ignore",cwd:TS(),env:n});if(u.on("error",l=>{_.error("SYSTEM",PS,{runtimePath:o,execPath:a},l)}),u.pid!==void 0)return u.unref(),u.pid}function IS(){try{if(!(0,Ie.existsSync)(xS))return;let e=new Date;(0,Ie.utimesSync)(xS,e,e)}catch{}}function zi(){return Mi({logAlive:!1})}var AS=Lt(require("net"),1);ne();Ze();function ql(){return ht.loadFromFile(Do).CLAUDE_MEM_WORKER_HOST}function CS(e){return e.startsWith("[")&&e.endsWith("]")?e:e.includes(":")?`[${e}]`:e}var Zl=5e3;async function qO(e,t,r="GET",n=Zl){let o=await fetch(`http://${CS(ql())}:${e}${t}`,{method:r,signal:AbortSignal.timeout(Math.max(1,n))}),s="";try{s=await o.text()}catch{}return{ok:o.ok,statusCode:o.status,body:s}}async function Hl(e,t=Zl){if(process.platform==="win32")try{let r=await fetch(`http://${CS(ql())}:${e}/api/health`,{signal:AbortSignal.timeout(Math.max(1,t))});if(r.ok)return!0;_.debug("SYSTEM","Windows health check returned non-ok; falling through to socket probe",{port:e,status:r.status})}catch(r){r instanceof Error?_.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:e,message:r.message}):_.debug("SYSTEM","Windows health check threw; falling through to socket probe",{port:e,error:String(r)})}return new Promise(r=>{let n=AS.default.createServer(),o=ql();n.once("error",s=>{s.code==="EADDRINUSE"?r(!0):r(!1)}),n.once("listening",()=>{n.close(()=>r(!1))}),n.listen(e,o)})}async function MS(e,t,r,n){let o=Date.now()+r;for(;Date.now()<o;){try{let i=o-Date.now();if((await qO(e,t,"GET",Math.min(Zl,i))).ok)return!0}catch(i){i instanceof Error?_.debug("SYSTEM",n,{},i):_.debug("SYSTEM",n,{error:String(i)})}let s=Math.min(500,o-Date.now());s>0&&await new Promise(i=>setTimeout(i,s))}return!1}function wo(e,t=3e4){return MS(e,"/api/health",t,"Service not ready yet, will retry")}function ko(e,t=3e4){return MS(e,"/api/readiness",t,"Worker not ready yet, will retry")}ne();var Di=require("path"),nt=require("fs");Ze();ne();var ZO=9e4;function zS(){return(0,Di.join)(sr(),"spawn.lock")}function Wl(){let e=zS(),t=JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()});for(let r=0;r<2;r++)try{return(0,nt.mkdirSync)((0,Di.dirname)(e),{recursive:!0}),(0,nt.writeFileSync)(e,t,{flag:"wx"}),!0}catch(n){let o=n instanceof Error?n:new Error(String(n)),s=o.code;if(s!=="EEXIST")return _.warn("SYSTEM","Spawn lock write failed for a non-contention reason; failing open (spawning unlocked)",{lockPath:e,code:s},o),!0;if(r>0)return!1;let i;try{i=(0,nt.statSync)(e).mtimeMs}catch{continue}if(Date.now()-i<=ZO)return!1;let a;try{a=(0,nt.statSync)(e).mtimeMs}catch{continue}if(a!==i)return!1;try{(0,nt.unlinkSync)(e)}catch{return!1}}return!1}function Vl(){let e=zS();try{if(JSON.parse((0,nt.readFileSync)(e,"utf-8")).pid!==process.pid)return;(0,nt.unlinkSync)(e)}catch{}}Pr();function LS(e,t,r){let n=process.env[e];if(n){let o=parseInt(n,10);if(Number.isFinite(o)&&o>=r.min&&o<=r.max)return o;_.warn("SYSTEM",`Invalid ${e}, using default`,{value:n,min:r.min,max:r.max})}return t}var LF=LS("CLAUDE_MEM_HEALTH_TIMEOUT_MS",tr(Oe.HEALTH_CHECK),{min:500,max:3e5}),jF=LS("CLAUDE_MEM_HOOK_READINESS_TIMEOUT_MS",tr(Oe.HOOK_READINESS_WAIT),{min:0,max:3e5}),HO={min:500,max:3e5};function jS(e=process.env){let t=e.CLAUDE_MEM_FETCH_VERBOSE;if(t===void 0)return!1;let r=t.trim().toLowerCase();return r==="1"||r==="true"||r==="on"||r==="yes"}function WO(e){return jS()?{...e,verbose:!0}:e}function VO(e){let t={},r=e;for(let n=0;r&&n<4;n++){let o=n===0?"error":`cause${n}`;if(r instanceof Error){let s=r;t[o]={name:r.name,message:r.message,...s.code!==void 0?{code:s.code}:{}},r=r.cause;continue}t[o]=String(r);break}return t}function KO(e,t,r){let n=typeof t.method=="string"?t.method:"GET",o=VO(r),s=JSON.stringify(o);_.warn("SYSTEM","Worker IPC fetch failed",{url:e,method:n},s),jt(`[claude-mem] fetch verbose: ${n} ${e} ${s}
84
+ `)}async function US(e,t={}){let r=WO(t);try{return await fetch(e,r)}catch(n){throw jS()&&KO(e,t,n),n}}async function Kl(e,t={},r){try{return await US(e,{...t,signal:AbortSignal.timeout(r)})}catch(n){throw n instanceof DOMException&&n.name==="TimeoutError"?new Error(`Request timed out after ${r}ms`):n}}var Ni=null,Li=null,ji=null,Ui=null;function BO(){return Ae.default.join(ht.get("CLAUDE_MEM_DATA_DIR"),"settings.json")}function Bl(){return ji!==null||(ji=ht.loadFromFile(BO())),ji}function DS(e,t){if(!e)return null;let r=parseInt(e,10);return Number.isFinite(r)&&r>=t.min&&r<=t.max?r:null}function GO(e,t,r){let n=process.env[e];if(n!==void 0){let i=DS(n,r);return i!==null?i:(_.warn("SYSTEM",`Invalid ${e}, using default`,{value:n,min:r.min,max:r.max}),t)}let o=Bl()[e],s=DS(o,r);return s!==null?s:(_.warn("SYSTEM",`Invalid ${e} in settings.json, using default`,{value:o,min:r.min,max:r.max}),t)}function Gl(){if(Ni!==null)return Ni;let e=Bl();return Ni=parseInt(e.CLAUDE_MEM_WORKER_PORT,10),Ni}function YO(){return Li!==null||(Li=Bl().CLAUDE_MEM_WORKER_HOST),Li}function JO(){return Ui!==null||(Ui=GO("CLAUDE_MEM_API_TIMEOUT_MS",tr(Oe.API_REQUEST),HO)),Ui}function XO(e){return e.startsWith("[")&&e.endsWith("]")?e:e.includes(":")?`[${e}]`:e}function QO(e){return`http://${XO(YO())}:${Gl()}${e}`}function Fi(e,t={}){let r=t.method??"GET",n=t.timeoutMs??JO(),o=QO(e),s={method:r};return t.headers&&(s.headers=t.headers),t.body&&(s.body=t.body),n>0?Kl(o,s,n):US(o,s)}function FS(e){let t=(0,Ce.existsSync)(Ae.default.join(e,"plugin","scripts"))?Ae.default.join(e,"plugin"):e;return Ae.default.join(t,"scripts","worker-service.cjs")}function eI(e,t){let r=d=>{let f=d.split("-")[0].split(".");return[parseInt(f[0],10)||0,parseInt(f[1],10)||0,parseInt(f[2],10)||0]},[n,o,s]=r(e),[i,a,c]=r(t);if(i!==n)return i-n;if(a!==o)return a-o;if(c!==s)return c-s;let u=e.includes("-")?1:0,l=t.includes("-")?1:0;return u!==l?u-l:e<t?1:e>t?-1:0}function tI(e=Ae.default.join(Ae.default.dirname(Ae.default.dirname(zo)),"cache","thedotmack","claude-mem")){try{return(0,Ce.readdirSync)(e).filter(t=>/^\d/.test(t)).map(t=>Ae.default.join(e,t)).filter(t=>{try{if(!(0,Ce.statSync)(t).isDirectory())return!1}catch{return!1}return!(0,Ce.existsSync)(Ae.default.join(t,".orphaned_at"))}).map(t=>({scriptPath:FS(t),version:Ae.default.basename(t)}))}catch{return[]}}function NS(e){try{let t=JSON.parse((0,Ce.readFileSync)(e,"utf-8"));return typeof t.version=="string"?t.version:null}catch(t){let r=t.code;return r!=="ENOENT"&&_.debug("SYSTEM","Could not read package version for worker resolution",{packageJsonPath:e,code:r}),null}}function rI(){let e=process.env.CLAUDE_MEM_WORKER_SCRIPT_PATH?.trim();if(e){if((0,Ce.existsSync)(e))return{scriptPath:e,version:null};_.debug("SYSTEM","Ignoring missing CLAUDE_MEM_WORKER_SCRIPT_PATH override",{override:e})}let t=[...tI(),{scriptPath:FS(Ae.default.join(zo,"plugin")),version:NS(Ae.default.join(zo,"package.json"))},{scriptPath:Ae.default.join(process.cwd(),"plugin","scripts","worker-service.cjs"),version:NS(Ae.default.join(process.cwd(),"package.json"))}];return nI(t)}function nI(e){let t=e.filter(r=>(0,Ce.existsSync)(r.scriptPath));return t.length===0?null:(t.sort((r,n)=>r.version===null&&n.version===null?0:r.version===null?1:n.version===null?-1:eI(r.version,n.version)),t[0])}function qS(){return rI()?.scriptPath??null}var oI=1e3;var sI=5e3,UF=sI+oI;var Yl=Lt(require("path"),1),ot=require("fs");ne();var HS=require("node:child_process"),WS=require("node:util");ne();Ze();var VS=(0,WS.promisify)(HS.execFile),iI=/^(uv|uvx|python|chroma-mcp)(\.exe)?$/i;function ZS(e){return iI.test(e.trim())}function aI(e,t){if(!e)return!1;let r=e.toLowerCase().replace(/\\/g,"/"),n=r.indexOf("--data-dir");if(n<0)return!1;let o=r.slice(n+10).trim();if(o.startsWith('"')){let i=o.indexOf('"',1);o=i<0?o.slice(1):o.slice(1,i)}let s=t.toLowerCase().replace(/\\/g,"/");return o===s||o.startsWith(s)&&o[s.length]==="/"}async function cI(){try{let e=await VS("powershell.exe",["-NoProfile","-NonInteractive","-Command","Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,Name,CommandLine,@{Name='StartToken';Expression={$_.CreationDate.ToString('yyyyMMddHHmmss.ffffff')}} | ConvertTo-Json -Compress"],{timeout:3e4,windowsHide:!0,maxBuffer:33554432}),t=JSON.parse(e.stdout),r=Array.isArray(t)?t:t===null?[]:[t],n=[];for(let o of r){let s=typeof o.Name=="string"?o.Name.trim():"";if(!s)continue;let i=typeof o.ProcessId=="number"?o.ProcessId:Number.parseInt(String(o.ProcessId),10),a=typeof o.ParentProcessId=="number"?o.ParentProcessId:Number.parseInt(String(o.ParentProcessId),10);!Number.isInteger(i)||!Number.isInteger(a)||n.push({pid:i,ppid:a,name:s,cmdline:typeof o.CommandLine=="string"?o.CommandLine:null,startToken:typeof o.StartToken=="string"&&o.StartToken.length>0?o.StartToken:null})}return n}catch(e){return _.warn("PROCESS","Cannot enumerate the Windows process table with names \u2014 ghost-port reclaim disabled",{error:e instanceof Error?e.message:String(e)}),null}}async function uI(e){try{let t=await VS("netstat",["-ano"],{timeout:15e3,windowsHide:!0,maxBuffer:16777216});return lI(t.stdout,e)}catch(t){return _.warn("PROCESS","netstat failed \u2014 ghost-port reclaim disabled for this attempt",{port:e,error:t instanceof Error?t.message:String(t)}),null}}function lI(e,t){let r=new Set,n=`:${t}`;for(let o of e.split(/\r?\n/)){let s=o.trim();if(!/^TCP\b/i.test(s))continue;let i=s.split(/\s+/);if(!i[1]?.endsWith(n)||i[3]!=="LISTENING")continue;let c=Number.parseInt(i[4]??"",10);Number.isInteger(c)&&c>0&&r.add(c)}return[...r]}async function KS(e,t={}){let r=t.isWin32??(()=>process.platform==="win32"),n=t.listOwners??uI,o=t.readTable??cI,s=t.killTree??((y,E)=>gt(y,E)),i=t.dataDir??(()=>ce);if(!r())return{reclaimed:!1,reason:"not-supported",killedPids:[]};let a=await n(e);if(a===null)return{reclaimed:!1,reason:"netstat-unreadable",killedPids:[]};if(a.length===0)return{reclaimed:!1,reason:"no-listener",killedPids:[]};let c=await o();if(c===null)return{reclaimed:!1,reason:"table-unreadable",killedPids:[]};if(a.filter(y=>pe(y)).length>0)return{reclaimed:!1,reason:"owner-alive",killedPids:[]};let l=new Map;for(let y of c){let E=l.get(y.ppid);E?E.push(y):l.set(y.ppid,[y])}let d=new Map,f=new Set,p=y=>{for(let E of l.get(y)??[])f.has(E.pid)||(f.add(E.pid),p(E.pid),ZS(E.name)&&d.set(E.pid,E))};for(let y of a)p(y);let m=i();if(m)for(let y of c)d.has(y.pid)||ZS(y.name)&&aI(y.cmdline,m)&&d.set(y.pid,y);if(d.size===0)return _.info("PROCESS","Ghost listener owner is dead but no chroma-sidecar descendants found",{port:e,deadOwners:a,processTableRows:c.length,dataDir:m??"(unresolved)"}),{reclaimed:!1,reason:"no-chroma-descendants",killedPids:[]};_.warn("PROCESS","Reclaiming ghost listener: killing dead worker's surviving chroma sidecar chain",{port:e,deadOwners:a,targets:[...d.values()].map(y=>({pid:y.pid,name:y.name}))});let h=[];for(let y of d.values())try{await s(y.pid,{expectedStartToken:y.startToken,signalMode:"immediate"}),h.push(y.pid)}catch(E){return _.error("PROCESS","Ghost-port reclaim tree-kill failed",{port:e,pid:y.pid},E instanceof Error?E:new Error(String(E))),{reclaimed:!1,reason:"kill-failed",killedPids:h}}let g=await n(e);return g!==null&&g.length===0?(_.info("PROCESS","Ghost listener reclaimed \u2014 port is free again",{port:e,killedPids:h}),{reclaimed:!0,killedPids:h}):(_.warn("PROCESS","Ghost-port reclaim killed the sidecar chain but the port is still bound",{port:e,killedPids:h,stillOwnedBy:g}),{reclaimed:!1,reason:"still-bound",killedPids:h})}var dI=120*1e3;function Jl(){return Yl.default.join(ht.get("CLAUDE_MEM_DATA_DIR"),".worker-start-attempted")}function fI(){if(process.platform!=="win32")return!1;let e=Jl();if(!(0,ot.existsSync)(e))return!1;try{let t=(0,ot.statSync)(e).mtimeMs;return Date.now()-t<dI}catch(t){return t instanceof Error?_.debug("SYSTEM","Could not stat worker spawn lock file",{},t):_.debug("SYSTEM","Could not stat worker spawn lock file",{error:String(t)}),!1}}function pI(){if(process.platform==="win32")try{let e=Jl();(0,ot.mkdirSync)(Yl.default.dirname(e),{recursive:!0}),(0,ot.writeFileSync)(e,"","utf-8")}catch{}}function xo(){if(process.platform==="win32")try{let e=Jl();(0,ot.existsSync)(e)&&(0,ot.unlinkSync)(e)}catch{}}var qi;async function BS(e,t){if(qi=void 0,!t)return _.error("SYSTEM","ensureWorkerStarted called with empty workerScriptPath \u2014 caller bug"),"dead";if(!(0,ot.existsSync)(t))return _.error("SYSTEM","ensureWorkerStarted: worker script not found at expected path \u2014 likely a partial install or build artifact missing",{workerScriptPath:t}),"dead";if(zi()==="alive"){if(_.info("SYSTEM","Worker PID file points to a live process, skipping duplicate spawn"),await ko(e,wr(Oe.READINESS_WAIT)))return xo(),_.info("SYSTEM","Worker became ready while waiting on live PID"),"ready";let a=await wo(e,1e3),c=zi()==="alive";return!a&&!c?(_.error("SYSTEM","Live PID disappeared before readiness endpoint became available"),"dead"):(_.warn("SYSTEM","Live PID detected but worker did not become ready before timeout"),"warming")}if(await wo(e,1e3)){xo();let i=await ko(e,wr(Oe.READINESS_WAIT));return i||_.warn("SYSTEM","Worker is alive but readiness timed out \u2014 proceeding anyway"),_.info("SYSTEM","Worker already running and healthy"),i?"ready":"warming"}if(await Hl(e)){if(_.info("SYSTEM","Port in use, waiting for worker to become healthy"),await wo(e,wr(Oe.PORT_IN_USE_WAIT))){xo();let c=await ko(e,wr(Oe.READINESS_WAIT));return _.info("SYSTEM","Worker is now healthy"),c?"ready":"warming"}let a=await KS(e);if(a.reclaimed)_.info("SYSTEM","Reclaimed ghost listener left by a dead worker \u2014 proceeding to spawn",{port:e,killedPids:a.killedPids}),xo();else return _.error("SYSTEM","Port in use but worker not responding to health checks",{port:e,reclaimReason:a.reason}),"dead"}if(fI())return _.warn("SYSTEM","Worker unavailable on Windows \u2014 skipping spawn (recent attempt failed within cooldown)"),"dead";let o=Wl(),s;try{if(o){if(_.info("SYSTEM","Starting worker daemon",{workerScriptPath:t}),pI(),s=OS(t,e),s===void 0)return _.error("SYSTEM","Failed to spawn worker daemon"),"dead"}else _.info("SYSTEM","Another launcher holds the spawn lock \u2014 skipping duplicate spawn and waiting for its worker");if(!await ko(e,wr(Oe.READINESS_WAIT))){let a=await wo(e,1e3),c=zi()==="alive",u=s!==void 0&&s>0&&pe(s);return!a&&!c&&!u?o?(qi=RS(t),_.error("SYSTEM","Worker exited before readiness endpoint became available",qi?{bootFailure:qi}:{}),"dead"):(_.error("SYSTEM","Spawn-lock holder never produced a live worker before readiness timed out"),"dead"):(_.warn("SYSTEM",o?"Worker spawned but readiness endpoint not responding within window":"Spawn-lock holder's worker not ready within window"),"warming")}return xo(),IS(),_.info("SYSTEM",o?"Worker started successfully":"Worker is up (started by another launcher)"),"ready"}finally{o&&Vl()}}var cn=require("node:fs/promises"),Po=require("node:path");var nd=require("node:child_process"),be=require("node:fs"),Me=require("node:path"),od=require("node:os"),ed=require("node:module");ne();Ze();var II={},td=typeof __CM_FILENAME__<"u"?(0,ed.createRequire)(__CM_FILENAME__):(0,ed.createRequire)(II.url),mI={".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",".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 eb(e){let t=e.slice(e.lastIndexOf("."));return mI[t]??"unknown"}var hI={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",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"},gI={markdown:"tree-sitter-markdown"};function tb(e){let t=hI[e];if(!t)return null;let r=gI[e];if(r){try{let n=td.resolve(t+"/package.json"),o=(0,Me.join)((0,Me.dirname)(n),r);if((0,be.existsSync)((0,Me.join)(o,"src")))return o}catch{}return null}try{let n=td.resolve(t+"/package.json");return(0,Me.dirname)(n)}catch{return null}}var _I={jsts:`
85
85
  (function_declaration name: (identifier) @name) @func
86
86
  (lexical_declaration (variable_declarator name: (identifier) @name value: [(arrow_function) (function_expression)])) @const_func
87
87
  (class_declaration name: (type_identifier) @name) @cls
@@ -203,25 +203,25 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
203
203
  (class_definition name: (identifier) @name) @cls
204
204
  (import_statement) @imp
205
205
  (import_declaration) @imp
206
- `};function tb(e){switch(e){case"javascript":return"js";case"typescript":case"tsx":return"jsts";case"python":return"python";case"go":return"go";case"rust":return"rust";case"ruby":return"ruby";case"java":return"java";case"kotlin":return"kotlin";case"swift":return"swift";case"php":return"php";case"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 Xl=null,Ql=new Map;function rb(e){if(Ql.has(e))return Ql.get(e);Xl||(Xl=(0,be.mkdtempSync)((0,Me.join)((0,od.tmpdir)(),"smart-read-queries-")));let t=(0,Me.join)(Xl,`${e}.scm`);return(0,be.writeFileSync)(t,_I[e]),Ql.set(e,t),t}function yI(e=process.platform){let t=e==="win32"?"tree-sitter.exe":"tree-sitter";try{let r=td.resolve("tree-sitter-cli/package.json"),n=(0,Me.join)((0,Me.dirname)(r),t);if((0,be.existsSync)(n))return n}catch{}return t}var Zi=null;function nb(){return Zi||(Zi=yI(),Zi)}var BS=(0,Me.join)(sr(),"tree-sitter-libs"),SI=process.platform==="win32"?".dll":process.platform==="darwin"?".dylib":".so",bI=["parser.c","scanner.c","scanner.cc"],rd=new Set;function EI(e){let t=0;for(let r of bI)try{let n=(0,be.statSync)((0,Me.join)(e,"src",r));n.mtimeMs>t&&(t=n.mtimeMs)}catch{}return t}function vI(e,t){if(rd.has(e))return null;let r=(0,Me.join)(BS,`${e}${SI}`);try{return(!(0,be.existsSync)(r)||(0,be.statSync)(r).mtimeMs<EI(t))&&((0,be.mkdirSync)(BS,{recursive:!0}),(0,nd.execFileSync)(nb(),["build","-o",r,t],{encoding:"utf-8",timeout:12e4,stdio:["pipe","pipe","pipe"]})),r}catch(n){return _.debug("WORKER",`tree-sitter build failed for ${e}; falling back to --grammar-path`,void 0,n instanceof Error?n:void 0),rd.add(e),null}}function wI(e,t,r,n){return ob(e,[t],r,n).get(t)||[]}function GS(e,t){try{return(0,nd.execFileSync)(nb(),e,{encoding:"utf-8",timeout:3e4,stdio:["pipe","pipe","pipe"]})}catch(r){return _.debug("WORKER",`tree-sitter query failed for ${t} file(s)`,void 0,r instanceof Error?r:void 0),null}}function ob(e,t,r,n){if(t.length===0)return new Map;let o=vI(n,r);if(o){let i=GS(["query","-l",o,"--lang-name",n,e,...t],t.length);if(i!==null)return YS(i);rd.add(n)}let s=GS(["query","-p",r,e,...t],t.length);return s===null?new Map:YS(s)}function YS(e){let t=new Map,r=null,n=null;for(let o of e.split(`
207
- `)){if(o.length>0&&!o.startsWith(" ")&&!o.startsWith(" ")){r=o.trim(),t.has(r)||t.set(r,[]),n=null;continue}if(!r)continue;let s=o.match(/^\s+pattern:\s+(\d+)/);if(s){n={pattern:parseInt(s[1]),captures:[]},t.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 t}var JS={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"},kI=new Set(["class","struct","impl","trait"]);function xI(e,t,r,n=200){let s=e[t]||"";if(!s.trimEnd().endsWith("{")&&!s.trimEnd().endsWith(":")){let i=e.slice(t,Math.min(t+10,r+1)).join(`
206
+ `};function rb(e){switch(e){case"javascript":return"js";case"typescript":case"tsx":return"jsts";case"python":return"python";case"go":return"go";case"rust":return"rust";case"ruby":return"ruby";case"java":return"java";case"kotlin":return"kotlin";case"swift":return"swift";case"php":return"php";case"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 Xl=null,Ql=new Map;function nb(e){if(Ql.has(e))return Ql.get(e);Xl||(Xl=(0,be.mkdtempSync)((0,Me.join)((0,od.tmpdir)(),"smart-read-queries-")));let t=(0,Me.join)(Xl,`${e}.scm`);return(0,be.writeFileSync)(t,_I[e]),Ql.set(e,t),t}function yI(e=process.platform){let t=e==="win32"?"tree-sitter.exe":"tree-sitter";try{let r=td.resolve("tree-sitter-cli/package.json"),n=(0,Me.join)((0,Me.dirname)(r),t);if((0,be.existsSync)(n))return n}catch{}return t}var Zi=null;function ob(){return Zi||(Zi=yI(),Zi)}var GS=(0,Me.join)(sr(),"tree-sitter-libs"),SI=process.platform==="win32"?".dll":process.platform==="darwin"?".dylib":".so",bI=["parser.c","scanner.c","scanner.cc"],rd=new Set;function EI(e){let t=0;for(let r of bI)try{let n=(0,be.statSync)((0,Me.join)(e,"src",r));n.mtimeMs>t&&(t=n.mtimeMs)}catch{}return t}function vI(e,t){if(rd.has(e))return null;let r=(0,Me.join)(GS,`${e}${SI}`);try{return(!(0,be.existsSync)(r)||(0,be.statSync)(r).mtimeMs<EI(t))&&((0,be.mkdirSync)(GS,{recursive:!0}),(0,nd.execFileSync)(ob(),["build","-o",r,t],{encoding:"utf-8",timeout:12e4,stdio:["pipe","pipe","pipe"]})),r}catch(n){return _.debug("WORKER",`tree-sitter build failed for ${e}; falling back to --grammar-path`,void 0,n instanceof Error?n:void 0),rd.add(e),null}}function wI(e,t,r,n){return sb(e,[t],r,n).get(t)||[]}function YS(e,t){try{return(0,nd.execFileSync)(ob(),e,{encoding:"utf-8",timeout:3e4,stdio:["pipe","pipe","pipe"]})}catch(r){return _.debug("WORKER",`tree-sitter query failed for ${t} file(s)`,void 0,r instanceof Error?r:void 0),null}}function sb(e,t,r,n){if(t.length===0)return new Map;let o=vI(n,r);if(o){let i=YS(["query","-l",o,"--lang-name",n,e,...t],t.length);if(i!==null)return JS(i);rd.add(n)}let s=YS(["query","-p",r,e,...t],t.length);return s===null?new Map:JS(s)}function JS(e){let t=new Map,r=null,n=null;for(let o of e.split(`
207
+ `)){if(o.length>0&&!o.startsWith(" ")&&!o.startsWith(" ")){r=o.trim(),t.has(r)||t.set(r,[]),n=null;continue}if(!r)continue;let s=o.match(/^\s+pattern:\s+(\d+)/);if(s){n={pattern:parseInt(s[1]),captures:[]},t.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 t}var XS={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"},kI=new Set(["class","struct","impl","trait"]);function xI(e,t,r,n=200){let s=e[t]||"";if(!s.trimEnd().endsWith("{")&&!s.trimEnd().endsWith(":")){let i=e.slice(t,Math.min(t+10,r+1)).join(`
208
208
  `),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 PI(e,t){let r=[],n=!1;for(let o=t-1;o>=0;o--){let s=e[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(e[o]),n=!0;else break}return r.length>0?r.join(`
209
- `).trim():void 0}function $I(e,t,r){for(let n=t+1;n<=Math.min(t+3,r);n++){let o=e[n]?.trim();if(o){if(o.startsWith('"""')||o.startsWith("'''"))return o;break}}}function TI(e,t,r,n,o,s){switch(s){case"javascript":case"typescript":case"tsx":return n.some(i=>t>=i.startRow&&r<=i.endRow);case"python":return!e.startsWith("_");case"go":return e.length>0&&e[0]===e[0].toUpperCase()&&e[0]!==e[0].toLowerCase();case"rust":return o[t]?.trimStart().startsWith("pub")??!1;default:return!0}}function sb(e,t,r){let n=[],o=[],s=[],i=[];for(let c of e)for(let u of c.captures)u.tag==="exp"&&s.push({startRow:u.startRow,endRow:u.endRow}),u.tag==="imp"&&o.push(u.text||t[u.startRow]?.trim()||"");for(let c of e){let u=c.captures.find(v=>JS[v.tag]),l=c.captures.find(v=>v.tag==="name");if(!u)continue;let d=u.startRow,f=u.endRow,p=JS[u.tag],m=l?.text||"anonymous",h;if(r==="markdown"&&p==="section"){let I=(t[d]||"").match(/^(#{1,6})\s/),x=I?I[1].length:1;h=`${"#".repeat(x)} ${m}`}else if(r==="markdown"&&p==="code"){let v=m!=="anonymous"?m:"";h=v?"```"+v:"```"}else r==="markdown"&&p==="metadata"?h="---frontmatter---":r==="markdown"&&p==="reference"?h=t[d]?.trim()||m:h=xI(t,d,f);let g=r==="markdown"?void 0:PI(t,d),y=r==="python"?$I(t,d,f):void 0,E={name:m,kind:p,signature:h,jsdoc:g||y,lineStart:d,lineEnd:f,exported:TI(m,d,f,s,t,r)};kI.has(p)&&(E.children=[],i.push({sym:E,startRow:d,endRow:f})),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}`,f=c.get(d);f?l.name!=="anonymous"?(u.add(f),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 Hi(e,t){let r=QS(t),n=e.split(`
210
- `),o=eb(r);if(!o)return{filePath:t,language:r,symbols:[],imports:[],totalLines:n.length,foldedTokenEstimate:50};let s=rb(tb(r)),i=t.slice(t.lastIndexOf("."))||".txt",a=(0,be.mkdtempSync)((0,Me.join)((0,od.tmpdir)(),"smart-src-")),c=(0,Me.join)(a,`source${i}`);(0,be.writeFileSync)(c,e);try{let u=wI(s,c,o,r),l=sb(u,n,r),d=an({filePath:t,language:r,symbols:l.symbols,imports:l.imports,totalLines:n.length,foldedTokenEstimate:0});return{filePath:t,language:r,symbols:l.symbols,imports:l.imports,totalLines:n.length,foldedTokenEstimate:Math.ceil(d.length/4)}}finally{(0,be.rmSync)(a,{recursive:!0,force:!0})}}function ib(e){let t=new Map,r=new Map;for(let n of e){let o=QS(n.relativePath);r.has(o)||r.set(o,[]),r.get(o).push(n)}for(let[n,o]of r){let s=eb(n);if(!s){for(let u of o){let l=u.content.split(`
211
- `);t.set(u.relativePath,{filePath:u.relativePath,language:n,symbols:[],imports:[],totalLines:l.length,foldedTokenEstimate:50})}continue}let i=rb(tb(n)),a=o.map(u=>u.absolutePath),c=ob(i,a,s,n);for(let u of o){let l=u.content.split(`
212
- `),d=c.get(u.absolutePath)||[],f=sb(d,l,n),p=an({filePath:u.relativePath,language:n,symbols:f.symbols,imports:f.imports,totalLines:l.length,foldedTokenEstimate:0});t.set(u.relativePath,{filePath:u.relativePath,language:n,symbols:f.symbols,imports:f.imports,totalLines:l.length,foldedTokenEstimate:Math.ceil(p.length/4)})}}return t}function an(e){if(e.language==="markdown")return RI(e);let t=[];if(t.push(`\u{1F4C1} ${e.filePath} (${e.language}, ${e.totalLines} lines)`),t.push(""),e.imports.length>0){t.push(` \u{1F4E6} Imports: ${e.imports.length} statements`);for(let r of e.imports.slice(0,10))t.push(` ${r}`);e.imports.length>10&&t.push(` ... +${e.imports.length-10} more`),t.push("")}for(let r of e.symbols)t.push(ab(r," "));return t.join(`
213
- `)}function RI(e){let t=[];t.push(`\u{1F4C4} ${e.filePath} (${e.language}, ${e.totalLines} lines)`);for(let n of e.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}`;t.push(`${c.padEnd(56)}${a}`)}else if(n.kind==="code"){let o=XS(e.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}`;t.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}`;t.push(`${s.padEnd(56)}${o}`)}else if(n.kind==="reference"){let o=XS(e.symbols,n.lineStart),s=" ".repeat(o+1),i=`L${n.lineStart+1}`,a=`${s}\u2197 ${n.name}`;t.push(`${a.padEnd(56)}${i}`)}return t.join(`
214
- `)}function XS(e,t){let r=0;for(let n of e)if(n.kind==="section"&&n.lineStart<t){let o=n.signature.match(/^(#{1,6})\s/);r=o?o[1].length:1}return r}function ab(e,t){let r=[],n=OI(e.kind),o=e.exported?" [exported]":"",s=e.lineStart===e.lineEnd?`L${e.lineStart+1}`:`L${e.lineStart+1}-${e.lineEnd+1}`;if(r.push(`${t}${n} ${e.name}${o} (${s})`),r.push(`${t} ${e.signature}`),e.jsdoc){let a=e.jsdoc.split(`
215
- `).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(`${t} \u{1F4AC} ${c}`)}}if(e.children&&e.children.length>0)for(let i of e.children)r.push(ab(i,t+" "));return r.join(`
216
- `)}function OI(e){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"}[e]||"\xB7"}function cb(e,t,r){let n=Hi(e,t),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=e.split(`
209
+ `).trim():void 0}function $I(e,t,r){for(let n=t+1;n<=Math.min(t+3,r);n++){let o=e[n]?.trim();if(o){if(o.startsWith('"""')||o.startsWith("'''"))return o;break}}}function TI(e,t,r,n,o,s){switch(s){case"javascript":case"typescript":case"tsx":return n.some(i=>t>=i.startRow&&r<=i.endRow);case"python":return!e.startsWith("_");case"go":return e.length>0&&e[0]===e[0].toUpperCase()&&e[0]!==e[0].toLowerCase();case"rust":return o[t]?.trimStart().startsWith("pub")??!1;default:return!0}}function ib(e,t,r){let n=[],o=[],s=[],i=[];for(let c of e)for(let u of c.captures)u.tag==="exp"&&s.push({startRow:u.startRow,endRow:u.endRow}),u.tag==="imp"&&o.push(u.text||t[u.startRow]?.trim()||"");for(let c of e){let u=c.captures.find(v=>XS[v.tag]),l=c.captures.find(v=>v.tag==="name");if(!u)continue;let d=u.startRow,f=u.endRow,p=XS[u.tag],m=l?.text||"anonymous",h;if(r==="markdown"&&p==="section"){let I=(t[d]||"").match(/^(#{1,6})\s/),x=I?I[1].length:1;h=`${"#".repeat(x)} ${m}`}else if(r==="markdown"&&p==="code"){let v=m!=="anonymous"?m:"";h=v?"```"+v:"```"}else r==="markdown"&&p==="metadata"?h="---frontmatter---":r==="markdown"&&p==="reference"?h=t[d]?.trim()||m:h=xI(t,d,f);let g=r==="markdown"?void 0:PI(t,d),y=r==="python"?$I(t,d,f):void 0,E={name:m,kind:p,signature:h,jsdoc:g||y,lineStart:d,lineEnd:f,exported:TI(m,d,f,s,t,r)};kI.has(p)&&(E.children=[],i.push({sym:E,startRow:d,endRow:f})),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}`,f=c.get(d);f?l.name!=="anonymous"?(u.add(f),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 Hi(e,t){let r=eb(t),n=e.split(`
210
+ `),o=tb(r);if(!o)return{filePath:t,language:r,symbols:[],imports:[],totalLines:n.length,foldedTokenEstimate:50};let s=nb(rb(r)),i=t.slice(t.lastIndexOf("."))||".txt",a=(0,be.mkdtempSync)((0,Me.join)((0,od.tmpdir)(),"smart-src-")),c=(0,Me.join)(a,`source${i}`);(0,be.writeFileSync)(c,e);try{let u=wI(s,c,o,r),l=ib(u,n,r),d=an({filePath:t,language:r,symbols:l.symbols,imports:l.imports,totalLines:n.length,foldedTokenEstimate:0});return{filePath:t,language:r,symbols:l.symbols,imports:l.imports,totalLines:n.length,foldedTokenEstimate:Math.ceil(d.length/4)}}finally{(0,be.rmSync)(a,{recursive:!0,force:!0})}}function ab(e){let t=new Map,r=new Map;for(let n of e){let o=eb(n.relativePath);r.has(o)||r.set(o,[]),r.get(o).push(n)}for(let[n,o]of r){let s=tb(n);if(!s){for(let u of o){let l=u.content.split(`
211
+ `);t.set(u.relativePath,{filePath:u.relativePath,language:n,symbols:[],imports:[],totalLines:l.length,foldedTokenEstimate:50})}continue}let i=nb(rb(n)),a=o.map(u=>u.absolutePath),c=sb(i,a,s,n);for(let u of o){let l=u.content.split(`
212
+ `),d=c.get(u.absolutePath)||[],f=ib(d,l,n),p=an({filePath:u.relativePath,language:n,symbols:f.symbols,imports:f.imports,totalLines:l.length,foldedTokenEstimate:0});t.set(u.relativePath,{filePath:u.relativePath,language:n,symbols:f.symbols,imports:f.imports,totalLines:l.length,foldedTokenEstimate:Math.ceil(p.length/4)})}}return t}function an(e){if(e.language==="markdown")return RI(e);let t=[];if(t.push(`\u{1F4C1} ${e.filePath} (${e.language}, ${e.totalLines} lines)`),t.push(""),e.imports.length>0){t.push(` \u{1F4E6} Imports: ${e.imports.length} statements`);for(let r of e.imports.slice(0,10))t.push(` ${r}`);e.imports.length>10&&t.push(` ... +${e.imports.length-10} more`),t.push("")}for(let r of e.symbols)t.push(cb(r," "));return t.join(`
213
+ `)}function RI(e){let t=[];t.push(`\u{1F4C4} ${e.filePath} (${e.language}, ${e.totalLines} lines)`);for(let n of e.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}`;t.push(`${c.padEnd(56)}${a}`)}else if(n.kind==="code"){let o=QS(e.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}`;t.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}`;t.push(`${s.padEnd(56)}${o}`)}else if(n.kind==="reference"){let o=QS(e.symbols,n.lineStart),s=" ".repeat(o+1),i=`L${n.lineStart+1}`,a=`${s}\u2197 ${n.name}`;t.push(`${a.padEnd(56)}${i}`)}return t.join(`
214
+ `)}function QS(e,t){let r=0;for(let n of e)if(n.kind==="section"&&n.lineStart<t){let o=n.signature.match(/^(#{1,6})\s/);r=o?o[1].length:1}return r}function cb(e,t){let r=[],n=OI(e.kind),o=e.exported?" [exported]":"",s=e.lineStart===e.lineEnd?`L${e.lineStart+1}`:`L${e.lineStart+1}-${e.lineEnd+1}`;if(r.push(`${t}${n} ${e.name}${o} (${s})`),r.push(`${t} ${e.signature}`),e.jsdoc){let a=e.jsdoc.split(`
215
+ `).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(`${t} \u{1F4AC} ${c}`)}}if(e.children&&e.children.length>0)for(let i of e.children)r.push(cb(i,t+" "));return r.join(`
216
+ `)}function OI(e){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"}[e]||"\xB7"}function ub(e,t,r){let n=Hi(e,t),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=e.split(`
217
217
  `);if(n.language==="markdown"&&s.kind==="section"){let u=s.signature.match(/^(#{1,6})\s/),l=u?u[1].length:1,d=s.lineStart,f=i.length-1;for(let m of n.symbols)if(m.kind==="section"&&m.lineStart>d){let h=m.signature.match(/^(#{1,6})\s/);if((h?h[1].length:1)<=l){for(f=m.lineStart-1;f>d&&i[f].trim()==="";)f--;break}}let p=i.slice(d,f+1).join(`
218
218
  `);return`<!-- \u{1F4CD} ${t} L${d+1}-${f+1} -->
219
219
  ${p}`}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(`
220
220
  `);return`// \u{1F4CD} ${t} L${a+1}-${s.lineEnd+1}
221
- ${c}`}ne();var AI=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",".lua",".scala",".sc",".sh",".bash",".zsh",".hs",".zig",".css",".scss",".toml",".yml",".yaml",".sql",".md",".mdx"]),CI=new Set(["node_modules",".git","dist","build",".next","__pycache__",".venv","venv","env",".env","target","vendor",".cache",".turbo","coverage",".nyc_output",".claude",".smart-file-read"]),MI=512*1024;async function*ub(e,t,r=20){if(r<=0)return;let n;try{n=await(0,cn.readdir)(e,{withFileTypes:!0})}catch(o){_.debug("WORKER",`walkDir: failed to read directory ${e}`,void 0,o instanceof Error?o:void 0);return}for(let o of n){if(o.name.startsWith(".")&&o.name!=="."||CI.has(o.name))continue;let s=(0,Po.join)(e,o.name);if(o.isDirectory())yield*ub(s,t,r-1);else if(o.isFile()){let i=o.name.slice(o.name.lastIndexOf("."));AI.has(i)&&(yield s)}}}async function zI(e){try{let t=await(0,cn.stat)(e);if(t.size>MI||t.size===0)return null;let r=await(0,cn.readFile)(e,"utf-8");return r.slice(0,1e3).includes("\0")?null:r}catch(t){return _.debug("WORKER",`safeReadFile: failed to read ${e}`,void 0,t instanceof Error?t:void 0),null}}async function lb(e,t,r={}){let n=r.maxResults||20,o=t.toLowerCase(),s=o.split(/[\s_\-./]+/).filter(h=>h.length>0),i=[];for await(let h of ub(e,e,20)){if(r.filePattern&&!(0,Po.relative)(e,h).toLowerCase().includes(r.filePattern.toLowerCase()))continue;let g=await zI(h);g&&i.push({absolutePath:h,relativePath:(0,Po.relative)(e,h),content:g})}let a=ib(i),c=[],u=[],l=0;for(let[h,g]of a){l+=DI(g);let E=Wi(h.toLowerCase(),s)>0,v=[],I=(x,z)=>{for(let j of x){let Be=0,Pe="",Ge=Wi(j.name.toLowerCase(),s);Ge>0&&(Be+=Ge*3,Pe="name match"),j.signature.toLowerCase().includes(o)&&(Be+=2,Pe=Pe?`${Pe} + signature`:"signature match"),j.jsdoc&&j.jsdoc.toLowerCase().includes(o)&&(Be+=1,Pe=Pe?`${Pe} + jsdoc`:"jsdoc match"),Be>0&&(E=!0,v.push({filePath:h,symbolName:z?`${z}.${j.name}`:j.name,kind:j.kind,signature:j.signature,jsdoc:j.jsdoc,lineStart:j.lineStart,lineEnd:j.lineEnd,matchReason:Pe})),j.children&&I(j.children,j.name)}};I(g.symbols),E&&(c.push(g),u.push(...v))}u.sort((h,g)=>{let y=Wi(h.symbolName.toLowerCase(),s);return Wi(g.symbolName.toLowerCase(),s)-y});let d=u.slice(0,n),f=new Set(d.map(h=>h.filePath)),p=c.filter(h=>f.has(h.filePath)).slice(0,n),m=p.reduce((h,g)=>h+g.foldedTokenEstimate,0);return{foldedFiles:p,matchingSymbols:d,totalFilesScanned:i.length,totalSymbolsFound:l,tokenEstimate:m}}function Wi(e,t){let r=0;for(let n of t)if(e===n)r+=10;else if(e.includes(n))r+=5;else{let o=0,s=0;for(let i of n){let a=e.indexOf(i,o);a!==-1&&(s++,o=a+1)}s===n.length&&(r+=1)}return r}function DI(e){let t=e.symbols.length;for(let r of e.symbols)r.children&&(t+=r.children.length);return t}function db(e,t){let r=[];if(r.push(`\u{1F50D} Smart Search: "${t}"`),r.push(` Scanned ${e.totalFilesScanned} files, found ${e.totalSymbolsFound} symbols`),r.push(` ${e.matchingSymbols.length} matches across ${e.foldedFiles.length} files (~${e.tokenEstimate} tokens for folded view)`),r.push(""),e.matchingSymbols.length===0)return r.push(" No matching symbols found."),r.join(`
221
+ ${c}`}ne();var AI=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",".lua",".scala",".sc",".sh",".bash",".zsh",".hs",".zig",".css",".scss",".toml",".yml",".yaml",".sql",".md",".mdx"]),CI=new Set(["node_modules",".git","dist","build",".next","__pycache__",".venv","venv","env",".env","target","vendor",".cache",".turbo","coverage",".nyc_output",".claude",".smart-file-read"]),MI=512*1024;async function*lb(e,t,r=20){if(r<=0)return;let n;try{n=await(0,cn.readdir)(e,{withFileTypes:!0})}catch(o){_.debug("WORKER",`walkDir: failed to read directory ${e}`,void 0,o instanceof Error?o:void 0);return}for(let o of n){if(o.name.startsWith(".")&&o.name!=="."||CI.has(o.name))continue;let s=(0,Po.join)(e,o.name);if(o.isDirectory())yield*lb(s,t,r-1);else if(o.isFile()){let i=o.name.slice(o.name.lastIndexOf("."));AI.has(i)&&(yield s)}}}async function zI(e){try{let t=await(0,cn.stat)(e);if(t.size>MI||t.size===0)return null;let r=await(0,cn.readFile)(e,"utf-8");return r.slice(0,1e3).includes("\0")?null:r}catch(t){return _.debug("WORKER",`safeReadFile: failed to read ${e}`,void 0,t instanceof Error?t:void 0),null}}async function db(e,t,r={}){let n=r.maxResults||20,o=t.toLowerCase(),s=o.split(/[\s_\-./]+/).filter(h=>h.length>0),i=[];for await(let h of lb(e,e,20)){if(r.filePattern&&!(0,Po.relative)(e,h).toLowerCase().includes(r.filePattern.toLowerCase()))continue;let g=await zI(h);g&&i.push({absolutePath:h,relativePath:(0,Po.relative)(e,h),content:g})}let a=ab(i),c=[],u=[],l=0;for(let[h,g]of a){l+=DI(g);let E=Wi(h.toLowerCase(),s)>0,v=[],I=(x,z)=>{for(let j of x){let Be=0,Pe="",Ge=Wi(j.name.toLowerCase(),s);Ge>0&&(Be+=Ge*3,Pe="name match"),j.signature.toLowerCase().includes(o)&&(Be+=2,Pe=Pe?`${Pe} + signature`:"signature match"),j.jsdoc&&j.jsdoc.toLowerCase().includes(o)&&(Be+=1,Pe=Pe?`${Pe} + jsdoc`:"jsdoc match"),Be>0&&(E=!0,v.push({filePath:h,symbolName:z?`${z}.${j.name}`:j.name,kind:j.kind,signature:j.signature,jsdoc:j.jsdoc,lineStart:j.lineStart,lineEnd:j.lineEnd,matchReason:Pe})),j.children&&I(j.children,j.name)}};I(g.symbols),E&&(c.push(g),u.push(...v))}u.sort((h,g)=>{let y=Wi(h.symbolName.toLowerCase(),s);return Wi(g.symbolName.toLowerCase(),s)-y});let d=u.slice(0,n),f=new Set(d.map(h=>h.filePath)),p=c.filter(h=>f.has(h.filePath)).slice(0,n),m=p.reduce((h,g)=>h+g.foldedTokenEstimate,0);return{foldedFiles:p,matchingSymbols:d,totalFilesScanned:i.length,totalSymbolsFound:l,tokenEstimate:m}}function Wi(e,t){let r=0;for(let n of t)if(e===n)r+=10;else if(e.includes(n))r+=5;else{let o=0,s=0;for(let i of n){let a=e.indexOf(i,o);a!==-1&&(s++,o=a+1)}s===n.length&&(r+=1)}return r}function DI(e){let t=e.symbols.length;for(let r of e.symbols)r.children&&(t+=r.children.length);return t}function fb(e,t){let r=[];if(r.push(`\u{1F50D} Smart Search: "${t}"`),r.push(` Scanned ${e.totalFilesScanned} files, found ${e.totalSymbolsFound} symbols`),r.push(` ${e.matchingSymbols.length} matches across ${e.foldedFiles.length} files (~${e.tokenEstimate} tokens for folded view)`),r.push(""),e.matchingSymbols.length===0)return r.push(" No matching symbols found."),r.join(`
222
222
  `);r.push("\u2500\u2500 Matching Symbols \u2500\u2500"),r.push("");for(let n of e.matchingSymbols){if(r.push(` ${n.kind} ${n.symbolName} (${n.filePath}:${n.lineStart+1})`),r.push(` ${n.signature}`),n.jsdoc){let o=n.jsdoc.split(`
223
223
  `).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 e.foldedFiles)r.push(an(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(`
224
- `)}var sd=require("node:fs/promises"),id=require("node:os"),kr=require("node:path");function NI(e){return e==="~"?(0,id.homedir)():e.startsWith("~/")||e.startsWith("~\\")?(0,kr.join)((0,id.homedir)(),e.slice(2)):e}async function Vi(e,t=process.cwd()){if(typeof e!="string"||e.trim().length===0)throw new Error("file_path is required");let r=await(0,sd.realpath)((0,kr.resolve)(t)),n=(0,kr.resolve)(r,NI(e.trim())),o;try{o=await(0,sd.realpath)(n)}catch{o=n}if(o!==r&&!o.startsWith(r+kr.sep))throw new Error(`Access denied: "${e}" resolves outside the workspace (${r}). MCP file tools can only read files within the current project.`);return o}var cd=require("node:fs/promises"),Yi=require("node:fs"),nr=require("node:path"),yb=require("node:os"),Sb=require("node:url");var fb="claude";function LI(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function Ki(e){if(!e)return fb;let t=LI(e);return t?t==="transcript"||t.includes("codex")?"codex":t.includes("cursor")?"cursor":t.includes("claude")?"claude":t:fb}var jI=tr(Oe.API_REQUEST),st=class extends Error{kind;status;cause;constructor(t,r,n={}){super(r),this.name="ServerClientError",this.kind=t,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)}},Bi=class{baseUrl;apiKey;timeoutMs;constructor(t){this.baseUrl=UI(t.serverBaseUrl),this.apiKey=t.apiKey,this.timeoutMs=t.timeoutMs??jI}async startSession(t){let r=this.buildStartSessionPayload(t);return this.request("POST","/v1/sessions/start",r)}async recordEvent(t){let r=this.buildEventPayload(t),n=t.generate===!1?"/v1/events?generate=false":"/v1/events";return this.request("POST",n,r)}async endSession(t){if(!t.sessionId)throw new st("invalid_response","sessionId is required for endSession");return this.request("POST",`/v1/sessions/${encodeURIComponent(t.sessionId)}/end`,{})}async addObservation(t){return this.request("POST","/v1/memories",this.buildAddObservationPayload(t))}async searchObservations(t){return this.request("POST","/v1/search",this.buildSearchPayload(t))}async contextObservations(t){return this.request("POST","/v1/context",this.buildSearchPayload(t))}async getJobStatus(t){if(!t)throw new st("invalid_response","jobId is required for getJobStatus");return this.request("GET",`/v1/jobs/${encodeURIComponent(t)}`)}buildAddObservationPayload(t){let r=t.content,n=t.kind??"manual",o=typeof t.metadata?.title=="string"?t.metadata.title:void 0;return{projectId:t.projectId,kind:n,type:n,narrative:r,...o?{title:o}:{},...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.platformSource!==void 0?{platformSource:t.platformSource}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}}}buildSearchPayload(t){return{projectId:t.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{},...t.platformSource!==void 0?{platformSource:ad(t.platformSource)}:{}}}buildStartSessionPayload(t){return{projectId:t.projectId,...t.externalSessionId!==void 0?{externalSessionId:t.externalSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.agentId!==void 0?{agentId:t.agentId}:{},...t.agentType!==void 0?{agentType:t.agentType}:{},...t.platformSource!==void 0?{platformSource:ad(t.platformSource)}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}}}buildEventPayload(t){return{projectId:t.projectId,sourceType:t.sourceType,eventType:t.eventType,occurredAtEpoch:t.occurredAtEpoch,...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.memorySessionId!==void 0?{memorySessionId:t.memorySessionId}:{},...t.platformSource!==void 0?{platformSource:ad(t.platformSource)}:{},...t.payload!==void 0?{payload:t.payload}:{}}}async request(t,r,n){if(!this.apiKey||!this.apiKey.trim())throw new st("missing_api_key","Server API key is not configured (CLAUDE_MEM_SERVER_API_KEY).");let o=`${this.baseUrl}${r}`,s={method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}};n!==void 0&&(s.body=JSON.stringify(n));let i;try{i=await Kl(o,s,this.timeoutMs)}catch(c){let u=c instanceof Error?c.message:String(c),l=/timed out|timeout/i.test(u);throw new st(l?"timeout":"transport",`Server ${t} ${r} failed: ${u}`,{cause:c})}if(!i.ok){let c=await i.text().catch(()=>"");throw new st("http_error",`Server ${t} ${r} returned ${i.status}: ${FI(c,200)}`,{status:i.status})}let a=await i.text();if(!a||a.length===0)return{};try{return JSON.parse(a)}catch(c){let u=c instanceof Error?c:new Error(String(c));throw new st("invalid_response",`Server ${t} ${r} returned non-JSON response`,{cause:u})}}};function pb(e){return e instanceof st}function UI(e){return e.replace(/\/+$/,"")}function ad(e){return typeof e=="string"?Ki(e):null}function FI(e,t){return e.length<=t?e:`${e.slice(0,t)}\u2026`}ne();function Gi(){let t=(Ti().CLAUDE_MEM_RUNTIME??"worker").trim().toLowerCase();return t==="server"||t==="server-beta"?"server":"worker"}function mb(){let e=Ti(),t=(...i)=>{for(let a of i){let c=(a??"").trim();if(c.length>0)return c}return""},r=t(e.CLAUDE_MEM_SERVER_URL,e.CLAUDE_MEM_SERVER_BETA_URL),n=t(e.CLAUDE_MEM_SERVER_API_KEY,e.CLAUDE_MEM_SERVER_BETA_API_KEY),o=t(e.CLAUDE_MEM_SERVER_PROJECT_ID,e.CLAUDE_MEM_SERVER_BETA_PROJECT_ID);if(!r)return _.warn("HOOK","[server-fallback] reason=missing_base_url"),null;if(!n)return _.warn("HOOK","[server-fallback] reason=missing_api_key"),null;if(!o)return _.warn("HOOK","[server-fallback] reason=missing_project_id"),null;let s={serverBaseUrl:r,apiKey:n};return{runtime:"server",client:new Bi(s),projectId:o,serverBaseUrl:r}}ne();var hb=["observation_add","observation_record_event","observation_search","observation_context","observation_generation_status","memory_add","memory_search","memory_context"],qI=new Set(hb);function gb(e,t){return t==="server"?[...e]:(_.debug("SYSTEM","Filtering server-beta-only MCP tools from worker runtime advertisement",{runtime:t,hiddenToolCount:hb.length}),e.filter(r=>!qI.has(r.name)))}var cA={},ZI="13.24.21";console.log=(...e)=>{_.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:e})};var bb=!1,Eb=(()=>{if(typeof __CM_DIRNAME__<"u")return __CM_DIRNAME__;try{return(0,nr.dirname)((0,Sb.fileURLToPath)(cA.url))}catch(e){return bb=!0,_.warn("SYSTEM","mcp-server: failed to resolve module directory from import.meta.url, falling back to process.cwd()",void 0,e instanceof Error?e:new Error(String(e))),process.cwd()}})(),ud=FS()??(0,nr.resolve)(Eb,"worker-service.cjs");function HI(){bb&&((0,Yi.existsSync)(ud)||_.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:ud,mcpServerDir:Eb}))}async function _t(e,t={}){_.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:e});try{let r;if(t.body)r=await Fi(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)});else{let n=new URLSearchParams;for(let[o,s]of Object.entries(t.query??{}))s!=null&&n.append(o,String(s));r=await Fi(`${e}?${n}`)}if(!r.ok){let n=await r.text();throw new Error(`Worker API error (${r.status}): ${n}`)}return _.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:e}),t.text?{content:[{type:"text",text:await r.text()}]}:t.body?{content:[{type:"text",text:JSON.stringify(await r.json(),null,2)}]}:await r.json()}catch(r){return _.error("SYSTEM","\u2190 Worker API error",{endpoint:e},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 WI(){try{return(await Fi("/api/health")).ok}catch(e){return _.debug("SYSTEM","Worker health check failed",{},e instanceof Error?e:new Error(String(e))),!1}}function vb(){if(Gi()!=="server")return null;let t=mb();return t?{...t,available:!0}:{runtime:"server",available:!1,reason:"server runtime is selected but configuration is incomplete (missing url, api key, or project id)"}}function VI(e){return pb(e)?{content:[{type:"text",text:`Server error (${e.kind}${e.status?` ${e.status}`:""}): ${e.message}`}],isError:!0}:{content:[{type:"text",text:`Tool error: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}function un(e){return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}function To(e){let t=vb();if(!t)throw new st("transport",`${e} requires CLAUDE_MEM_RUNTIME=server. Current runtime is "worker"; use the existing search/timeline/get_observations tools for worker-mode memory access.`);if(!t.available)throw new st("missing_api_key",`${e}: ${t.reason}`);return t}function Ro(e,t){return async r=>{try{return await t(r)}catch(n){let o=n instanceof Error?n:new Error(String(n));return _.warn("SYSTEM",`${e} failed`,void 0,o),VI(n)}}}var KI=Ro("observation_add",async e=>{let t=To("observation_add");if(typeof e?.content!="string"||e.content.trim().length===0)throw new Error('observation_add: "content" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,content:e.content,...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.platformSource!==void 0?{platformSource:e.platformSource}:{},...e.kind!==void 0?{kind:e.kind}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}},o=await t.client.addObservation(n);return un(o)});function Xi(e){return typeof e=="string"?Ki(e):null}var BI=Ro("observation_record_event",async e=>{let t=To("observation_record_event");if(typeof e?.eventType!="string"||e.eventType.trim().length===0)throw new Error('observation_record_event: "eventType" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,sourceType:e.sourceType??"api",eventType:e.eventType,occurredAtEpoch:typeof e.occurredAtEpoch=="number"?e.occurredAtEpoch:Date.now(),...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.memorySessionId!==void 0?{memorySessionId:e.memorySessionId}:{},...e.platformSource!==void 0?{platformSource:Xi(e.platformSource)}:{},...e.payload!==void 0?{payload:e.payload}:{},...e.generate!==void 0?{generate:e.generate}:{}},o=await t.client.recordEvent(n);return un(o)}),GI=Ro("observation_search",async e=>{let t=To("observation_search");if(typeof e?.query!="string"||e.query.trim().length===0)throw new Error('observation_search: "query" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{},...e.platformSource!==void 0?{platformSource:Xi(e.platformSource)}:{}},o=await t.client.searchObservations(n);return un(o)}),YI=Ro("observation_context",async e=>{let t=To("observation_context");if(typeof e?.query!="string"||e.query.trim().length===0)throw new Error('observation_context: "query" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{},...e.platformSource!==void 0?{platformSource:Xi(e.platformSource)}:{}},o=await t.client.contextObservations(n);return un(o)});function JI(e){return Array.isArray(e.projects)?e.projects.map(t=>typeof t=="string"?t.trim():"").filter(Boolean):typeof e.projects=="string"?e.projects.split(",").map(t=>t.trim()).filter(Boolean):typeof e.project=="string"&&e.project.trim().length>0?[e.project.trim()]:[]}async function XI(e){let t=JI(e);return t.length===0?{content:[{type:"text",text:'session_start_context: "project" or "projects" is required'}],isError:!0}:_t("/api/context/inject",{query:{projects:t.join(","),...e.platformSource!==void 0?{platformSource:Xi(e.platformSource)}:{},...e.full!==void 0?{full:e.full}:{},...e.colors!==void 0?{colors:e.colors}:{}},text:!0})}var QI=Ro("observation_generation_status",async e=>{let t=To("observation_generation_status"),r=(e?.jobId??e?.job_id??"").trim();if(!r)throw new Error('observation_generation_status: "jobId" is required');let n=await t.client.getJobStatus(r);return un(n)});async function eA(){if(await WI())return!0;_.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),HI();try{let e=Gl(),t=await KS(e,ud);return t==="dead"&&_.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.)."),t!=="dead"}catch(e){return _.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,e instanceof Error?e:new Error(String(e))),!1}}var wb=[{name:"important_workflow",description:`LAYERED WORKFLOW (ALWAYS FOLLOW):
224
+ `)}var sd=require("node:fs/promises"),id=require("node:os"),kr=require("node:path");function NI(e){return e==="~"?(0,id.homedir)():e.startsWith("~/")||e.startsWith("~\\")?(0,kr.join)((0,id.homedir)(),e.slice(2)):e}async function Vi(e,t=process.cwd()){if(typeof e!="string"||e.trim().length===0)throw new Error("file_path is required");let r=await(0,sd.realpath)((0,kr.resolve)(t)),n=(0,kr.resolve)(r,NI(e.trim())),o;try{o=await(0,sd.realpath)(n)}catch{o=n}if(o!==r&&!o.startsWith(r+kr.sep))throw new Error(`Access denied: "${e}" resolves outside the workspace (${r}). MCP file tools can only read files within the current project.`);return o}var cd=require("node:fs/promises"),Yi=require("node:fs"),nr=require("node:path"),Sb=require("node:os"),bb=require("node:url");var pb="claude";function LI(e){return e.trim().toLowerCase().replace(/\s+/g,"-")}function Ki(e){if(!e)return pb;let t=LI(e);return t?t==="transcript"||t.includes("codex")?"codex":t.includes("cursor")?"cursor":t.includes("claude")?"claude":t:pb}var jI=tr(Oe.API_REQUEST),st=class extends Error{kind;status;cause;constructor(t,r,n={}){super(r),this.name="ServerClientError",this.kind=t,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)}},Bi=class{baseUrl;apiKey;timeoutMs;constructor(t){this.baseUrl=UI(t.serverBaseUrl),this.apiKey=t.apiKey,this.timeoutMs=t.timeoutMs??jI}async startSession(t){let r=this.buildStartSessionPayload(t);return this.request("POST","/v1/sessions/start",r)}async recordEvent(t){let r=this.buildEventPayload(t),n=t.generate===!1?"/v1/events?generate=false":"/v1/events";return this.request("POST",n,r)}async endSession(t){if(!t.sessionId)throw new st("invalid_response","sessionId is required for endSession");return this.request("POST",`/v1/sessions/${encodeURIComponent(t.sessionId)}/end`,{})}async addObservation(t){return this.request("POST","/v1/memories",this.buildAddObservationPayload(t))}async searchObservations(t){return this.request("POST","/v1/search",this.buildSearchPayload(t))}async contextObservations(t){return this.request("POST","/v1/context",this.buildSearchPayload(t))}async getJobStatus(t){if(!t)throw new st("invalid_response","jobId is required for getJobStatus");return this.request("GET",`/v1/jobs/${encodeURIComponent(t)}`)}buildAddObservationPayload(t){let r=t.content,n=t.kind??"manual",o=typeof t.metadata?.title=="string"?t.metadata.title:void 0;return{projectId:t.projectId,kind:n,type:n,narrative:r,...o?{title:o}:{},...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.platformSource!==void 0?{platformSource:t.platformSource}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}}}buildSearchPayload(t){return{projectId:t.projectId,query:t.query,...t.limit!==void 0?{limit:t.limit}:{},...t.platformSource!==void 0?{platformSource:ad(t.platformSource)}:{}}}buildStartSessionPayload(t){return{projectId:t.projectId,...t.externalSessionId!==void 0?{externalSessionId:t.externalSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.agentId!==void 0?{agentId:t.agentId}:{},...t.agentType!==void 0?{agentType:t.agentType}:{},...t.platformSource!==void 0?{platformSource:ad(t.platformSource)}:{},...t.metadata!==void 0?{metadata:t.metadata}:{}}}buildEventPayload(t){return{projectId:t.projectId,sourceType:t.sourceType,eventType:t.eventType,occurredAtEpoch:t.occurredAtEpoch,...t.serverSessionId!==void 0?{serverSessionId:t.serverSessionId}:{},...t.contentSessionId!==void 0?{contentSessionId:t.contentSessionId}:{},...t.memorySessionId!==void 0?{memorySessionId:t.memorySessionId}:{},...t.platformSource!==void 0?{platformSource:ad(t.platformSource)}:{},...t.payload!==void 0?{payload:t.payload}:{}}}async request(t,r,n){if(!this.apiKey||!this.apiKey.trim())throw new st("missing_api_key","Server API key is not configured (CLAUDE_MEM_SERVER_API_KEY).");let o=`${this.baseUrl}${r}`,s={method:t,headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.apiKey}`}};n!==void 0&&(s.body=JSON.stringify(n));let i;try{i=await Kl(o,s,this.timeoutMs)}catch(c){let u=c instanceof Error?c.message:String(c),l=/timed out|timeout/i.test(u);throw new st(l?"timeout":"transport",`Server ${t} ${r} failed: ${u}`,{cause:c})}if(!i.ok){let c=await i.text().catch(()=>"");throw new st("http_error",`Server ${t} ${r} returned ${i.status}: ${FI(c,200)}`,{status:i.status})}let a=await i.text();if(!a||a.length===0)return{};try{return JSON.parse(a)}catch(c){let u=c instanceof Error?c:new Error(String(c));throw new st("invalid_response",`Server ${t} ${r} returned non-JSON response`,{cause:u})}}};function mb(e){return e instanceof st}function UI(e){return e.replace(/\/+$/,"")}function ad(e){return typeof e=="string"?Ki(e):null}function FI(e,t){return e.length<=t?e:`${e.slice(0,t)}\u2026`}ne();function Gi(){let t=(Ti().CLAUDE_MEM_RUNTIME??"worker").trim().toLowerCase();return t==="server"||t==="server-beta"?"server":"worker"}function hb(){let e=Ti(),t=(...i)=>{for(let a of i){let c=(a??"").trim();if(c.length>0)return c}return""},r=t(e.CLAUDE_MEM_SERVER_URL,e.CLAUDE_MEM_SERVER_BETA_URL),n=t(e.CLAUDE_MEM_SERVER_API_KEY,e.CLAUDE_MEM_SERVER_BETA_API_KEY),o=t(e.CLAUDE_MEM_SERVER_PROJECT_ID,e.CLAUDE_MEM_SERVER_BETA_PROJECT_ID);if(!r)return _.warn("HOOK","[server-fallback] reason=missing_base_url"),null;if(!n)return _.warn("HOOK","[server-fallback] reason=missing_api_key"),null;if(!o)return _.warn("HOOK","[server-fallback] reason=missing_project_id"),null;let s={serverBaseUrl:r,apiKey:n};return{runtime:"server",client:new Bi(s),projectId:o,serverBaseUrl:r}}ne();var gb=["observation_add","observation_record_event","observation_search","observation_context","observation_generation_status","memory_add","memory_search","memory_context"],qI=new Set(gb);function _b(e,t){return t==="server"?[...e]:(_.debug("SYSTEM","Filtering server-beta-only MCP tools from worker runtime advertisement",{runtime:t,hiddenToolCount:gb.length}),e.filter(r=>!qI.has(r.name)))}var cA={},ZI="13.24.23";console.log=(...e)=>{_.error("CONSOLE","Intercepted console output (MCP protocol protection)",void 0,{args:e})};var Eb=!1,vb=(()=>{if(typeof __CM_DIRNAME__<"u")return __CM_DIRNAME__;try{return(0,nr.dirname)((0,bb.fileURLToPath)(cA.url))}catch(e){return Eb=!0,_.warn("SYSTEM","mcp-server: failed to resolve module directory from import.meta.url, falling back to process.cwd()",void 0,e instanceof Error?e:new Error(String(e))),process.cwd()}})(),ud=qS()??(0,nr.resolve)(vb,"worker-service.cjs");function HI(){Eb&&((0,Yi.existsSync)(ud)||_.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:ud,mcpServerDir:vb}))}async function _t(e,t={}){_.debug("SYSTEM","\u2192 Worker API",void 0,{endpoint:e});try{let r;if(t.body)r=await Fi(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.body)});else{let n=new URLSearchParams;for(let[o,s]of Object.entries(t.query??{}))s!=null&&n.append(o,String(s));r=await Fi(`${e}?${n}`)}if(!r.ok){let n=await r.text();throw new Error(`Worker API error (${r.status}): ${n}`)}return _.debug("SYSTEM","\u2190 Worker API success",void 0,{endpoint:e}),t.text?{content:[{type:"text",text:await r.text()}]}:t.body?{content:[{type:"text",text:JSON.stringify(await r.json(),null,2)}]}:await r.json()}catch(r){return _.error("SYSTEM","\u2190 Worker API error",{endpoint:e},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 WI(){try{return(await Fi("/api/health")).ok}catch(e){return _.debug("SYSTEM","Worker health check failed",{},e instanceof Error?e:new Error(String(e))),!1}}function wb(){if(Gi()!=="server")return null;let t=hb();return t?{...t,available:!0}:{runtime:"server",available:!1,reason:"server runtime is selected but configuration is incomplete (missing url, api key, or project id)"}}function VI(e){return mb(e)?{content:[{type:"text",text:`Server error (${e.kind}${e.status?` ${e.status}`:""}): ${e.message}`}],isError:!0}:{content:[{type:"text",text:`Tool error: ${e instanceof Error?e.message:String(e)}`}],isError:!0}}function un(e){return{content:[{type:"text",text:JSON.stringify(e,null,2)}]}}function To(e){let t=wb();if(!t)throw new st("transport",`${e} requires CLAUDE_MEM_RUNTIME=server. Current runtime is "worker"; use the existing search/timeline/get_observations tools for worker-mode memory access.`);if(!t.available)throw new st("missing_api_key",`${e}: ${t.reason}`);return t}function Ro(e,t){return async r=>{try{return await t(r)}catch(n){let o=n instanceof Error?n:new Error(String(n));return _.warn("SYSTEM",`${e} failed`,void 0,o),VI(n)}}}var KI=Ro("observation_add",async e=>{let t=To("observation_add");if(typeof e?.content!="string"||e.content.trim().length===0)throw new Error('observation_add: "content" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,content:e.content,...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.platformSource!==void 0?{platformSource:e.platformSource}:{},...e.kind!==void 0?{kind:e.kind}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}},o=await t.client.addObservation(n);return un(o)});function Xi(e){return typeof e=="string"?Ki(e):null}var BI=Ro("observation_record_event",async e=>{let t=To("observation_record_event");if(typeof e?.eventType!="string"||e.eventType.trim().length===0)throw new Error('observation_record_event: "eventType" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,sourceType:e.sourceType??"api",eventType:e.eventType,occurredAtEpoch:typeof e.occurredAtEpoch=="number"?e.occurredAtEpoch:Date.now(),...e.serverSessionId!==void 0?{serverSessionId:e.serverSessionId}:{},...e.contentSessionId!==void 0?{contentSessionId:e.contentSessionId}:{},...e.memorySessionId!==void 0?{memorySessionId:e.memorySessionId}:{},...e.platformSource!==void 0?{platformSource:Xi(e.platformSource)}:{},...e.payload!==void 0?{payload:e.payload}:{},...e.generate!==void 0?{generate:e.generate}:{}},o=await t.client.recordEvent(n);return un(o)}),GI=Ro("observation_search",async e=>{let t=To("observation_search");if(typeof e?.query!="string"||e.query.trim().length===0)throw new Error('observation_search: "query" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{},...e.platformSource!==void 0?{platformSource:Xi(e.platformSource)}:{}},o=await t.client.searchObservations(n);return un(o)}),YI=Ro("observation_context",async e=>{let t=To("observation_context");if(typeof e?.query!="string"||e.query.trim().length===0)throw new Error('observation_context: "query" is required');let n={projectId:e.projectId&&e.projectId.trim().length>0?e.projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{},...e.platformSource!==void 0?{platformSource:Xi(e.platformSource)}:{}},o=await t.client.contextObservations(n);return un(o)});function JI(e){return Array.isArray(e.projects)?e.projects.map(t=>typeof t=="string"?t.trim():"").filter(Boolean):typeof e.projects=="string"?e.projects.split(",").map(t=>t.trim()).filter(Boolean):typeof e.project=="string"&&e.project.trim().length>0?[e.project.trim()]:[]}async function XI(e){let t=JI(e);return t.length===0?{content:[{type:"text",text:'session_start_context: "project" or "projects" is required'}],isError:!0}:_t("/api/context/inject",{query:{projects:t.join(","),...e.platformSource!==void 0?{platformSource:Xi(e.platformSource)}:{},...e.full!==void 0?{full:e.full}:{},...e.colors!==void 0?{colors:e.colors}:{}},text:!0})}var QI=Ro("observation_generation_status",async e=>{let t=To("observation_generation_status"),r=(e?.jobId??e?.job_id??"").trim();if(!r)throw new Error('observation_generation_status: "jobId" is required');let n=await t.client.getJobStatus(r);return un(n)});async function eA(){if(await WI())return!0;_.warn("SYSTEM","Worker not available, attempting auto-start for MCP client"),HI();try{let e=Gl(),t=await BS(e,ud);return t==="dead"&&_.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.)."),t!=="dead"}catch(e){return _.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,e instanceof Error?e:new Error(String(e))),!1}}var kb=[{name:"important_workflow",description:`LAYERED WORKFLOW (ALWAYS FOLLOW):
225
225
  1. search(query) \u2192 Get index with IDs (~50-100 tokens/result)
226
226
  2. timeline(anchor=ID) \u2192 Get context around interesting results
227
227
  3. get_observations([IDs]) \u2192 Fetch full details ONLY for filtered IDs
@@ -246,9 +246,9 @@ NEVER fetch full details without filtering first. 10x token savings.`,inputSchem
246
246
  \`get_tool_uses(ids=[...])\`
247
247
  Returns: The original tool_input / tool_response bodies (UNSUMMARIZED \u2014 can be thousands of tokens each)
248
248
 
249
- **Why:** 10x token savings. Never fetch full details without filtering first, and never reach for layer 4 before layer 3 answered.`}]})},{name:"search",description:"Step 1: Search memory. Returns index with IDs. Params: query, limit, project, platformSource, type, obs_type, dateStart, dateEnd, offset, orderBy",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},limit:{type:"number",description:"Max results (default 20)"},project:{type:"string",description:"Filter by project name"},platformSource:{type:"string",description:"Filter by platform source (e.g. claude, codex, cursor) \u2014 restricts results to that agent's own memory"},type:{type:"string",description:"Document category to search: 'observations', 'sessions', or 'prompts' (default: all). Any other value is treated as an observation-type filter (alias for obs_type)."},obs_type:{type:"string",description:"Filter observations by their type (e.g. bugfix, feature). Comma-separated for multiple."},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 e=>{let t=vb(),r=typeof e?.query=="string"&&e.query.trim().length>0,n=e?.type===void 0||e?.type==="observations",o=e?.platformSource!==void 0||e?.project!==void 0||e?.obs_type!==void 0||e?.dateStart!==void 0||e?.dateEnd!==void 0||e?.offset!==void 0||e?.orderBy!==void 0;if(t&&t.available&&r&&n&&!o){let s={projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{}};return un(await t.client.searchObservations(s))}return await _t("/api/search",{query:e})}},{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 e=>await _t("/api/timeline",{query:e})},{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 e=>await _t("/api/observations/batch",{body:e})},{name:"get_tool_uses",description:"Step 4 (raw tool I/O, rarely needed): fetch the ORIGINAL tool_input/tool_response for tool calls you already identified. Requires ids \u2014 run search/timeline/get_observations first and pass only the ids you actually need; these payloads are large and unsummarized. ids accept numeric tool_uses ids or tool_use_id strings. Params: ids (required), limit, project, contentSessionId.",inputSchema:{type:"object",properties:{ids:{type:"array",items:{type:["number","string"]},description:"Tool-use ids to fetch (required). Numeric tool_uses.id or opaque tool_use_id strings."},limit:{type:"number",description:"Max rows to return"},project:{type:"string",description:"Filter by project name"},contentSessionId:{type:"string",description:"Filter to one content session"}},required:["ids"],additionalProperties:!0},handler:async e=>await _t("/api/tool-uses/batch",{body:e})},{name:"session_start_context",description:"Render the exact worker-mode SessionStart context for a project. Calls /api/context/inject and returns the same text hooks inject at startup. Params: project OR projects, platformSource, full, colors.",inputSchema:{type:"object",properties:{project:{type:"string",description:"Project name, e.g. claude-mem/night-parsnip"},projects:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}],description:"Project chain for context injection. Array or comma-separated string; last project is treated as primary."},platformSource:{type:"string",description:"Optional platform source filter, e.g. claude, codex, cursor"},full:{type:"boolean",description:"When true, request full context instead of configured limits"},colors:{type:"boolean",description:"When true, request human terminal-color formatting"}},additionalProperties:!1},handler:async e=>XI(e??{})},{name:"observation_add",description:"Insert a manual observation directly into server storage. Calls /v1/memories \u2014 does NOT enqueue generation. Server 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_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 e=>KI(e??{})},{name:"observation_record_event",description:"Record an agent event into the server. Calls /v1/events \u2014 server inserts the event row, the outbox row, and enqueues a generation job atomically. Server 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"},platformSource:{type:"string",description:"Optional platform source for session linkage and event scoping"},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 e=>BI(e??{})},{name:"observation_search",description:"Full-text search across generated observations using the server's GIN tsvector index (Phase 1). Calls /v1/search. Server runtime only. Params: query (required), projectId (optional), platformSource, limit (default 20, max 100).",inputSchema:{type:"object",properties:{projectId:{type:"string"},query:{type:"string",description:"Search query (required)"},platformSource:{type:"string",description:"Optional platform source filter, e.g. claude, codex, cursor"},limit:{type:"number",description:"Max results (default 20, max 100)"}},required:["query"],additionalProperties:!1},handler:async e=>GI(e??{})},{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 runtime only.",inputSchema:{type:"object",properties:{projectId:{type:"string"},query:{type:"string",description:"Search query (required)"},platformSource:{type:"string",description:"Optional platform source filter, e.g. claude, codex, cursor"},limit:{type:"number",description:"Max observations (default 10, max 50)"}},required:["query"],additionalProperties:!1},handler:async e=>YI(e??{})},{name:"observation_generation_status",description:"Look up the status of an observation generation job by id. Calls /v1/jobs/:id. Server 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 e=>QI(e??{})},{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 e=>{let t=await Vi(e.path||process.cwd()),r=await lb(t,e.query,{maxResults:e.max_results||20,filePattern:e.file_pattern});return{content:[{type:"text",text:db(r,e.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 e=>{let t=await Vi(e.file_path),r=await(0,cd.readFile)(t,"utf-8"),n=cb(r,t,e.symbol_name);if(n)return{content:[{type:"text",text:n}]};let o=Hi(r,t);if(o.symbols.length>0){let s=o.symbols.map(i=>` - ${i.name} (${i.kind})`).join(`
249
+ **Why:** 10x token savings. Never fetch full details without filtering first, and never reach for layer 4 before layer 3 answered.`}]})},{name:"search",description:"Step 1: Search memory. Returns index with IDs. Params: query, limit, project, platformSource, type, obs_type, dateStart, dateEnd, offset, orderBy",inputSchema:{type:"object",properties:{query:{type:"string",description:"Search query"},limit:{type:"number",description:"Max results (default 20)"},project:{type:"string",description:"Filter by project name"},platformSource:{type:"string",description:"Filter by platform source (e.g. claude, codex, cursor) \u2014 restricts results to that agent's own memory"},type:{type:"string",description:"Document category to search: 'observations', 'sessions', or 'prompts' (default: all). Any other value is treated as an observation-type filter (alias for obs_type)."},obs_type:{type:"string",description:"Filter observations by their type (e.g. bugfix, feature). Comma-separated for multiple."},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 e=>{let t=wb(),r=typeof e?.query=="string"&&e.query.trim().length>0,n=e?.type===void 0||e?.type==="observations",o=e?.platformSource!==void 0||e?.project!==void 0||e?.obs_type!==void 0||e?.dateStart!==void 0||e?.dateEnd!==void 0||e?.offset!==void 0||e?.orderBy!==void 0;if(t&&t.available&&r&&n&&!o){let s={projectId:t.projectId,query:e.query,...e.limit!==void 0?{limit:e.limit}:{}};return un(await t.client.searchObservations(s))}return await _t("/api/search",{query:e})}},{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 e=>await _t("/api/timeline",{query:e})},{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 e=>await _t("/api/observations/batch",{body:e})},{name:"get_tool_uses",description:"Step 4 (raw tool I/O, rarely needed): fetch the ORIGINAL tool_input/tool_response for tool calls you already identified. Requires ids \u2014 run search/timeline/get_observations first and pass only the ids you actually need; these payloads are large and unsummarized. ids accept numeric tool_uses ids or tool_use_id strings. Params: ids (required), limit, project, contentSessionId.",inputSchema:{type:"object",properties:{ids:{type:"array",items:{type:["number","string"]},description:"Tool-use ids to fetch (required). Numeric tool_uses.id or opaque tool_use_id strings."},limit:{type:"number",description:"Max rows to return"},project:{type:"string",description:"Filter by project name"},contentSessionId:{type:"string",description:"Filter to one content session"}},required:["ids"],additionalProperties:!0},handler:async e=>await _t("/api/tool-uses/batch",{body:e})},{name:"session_start_context",description:"Render the exact worker-mode SessionStart context for a project. Calls /api/context/inject and returns the same text hooks inject at startup. Params: project OR projects, platformSource, full, colors.",inputSchema:{type:"object",properties:{project:{type:"string",description:"Project name, e.g. claude-mem/night-parsnip"},projects:{oneOf:[{type:"array",items:{type:"string"}},{type:"string"}],description:"Project chain for context injection. Array or comma-separated string; last project is treated as primary."},platformSource:{type:"string",description:"Optional platform source filter, e.g. claude, codex, cursor"},full:{type:"boolean",description:"When true, request full context instead of configured limits"},colors:{type:"boolean",description:"When true, request human terminal-color formatting"}},additionalProperties:!1},handler:async e=>XI(e??{})},{name:"observation_add",description:"Insert a manual observation directly into server storage. Calls /v1/memories \u2014 does NOT enqueue generation. Server 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_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 e=>KI(e??{})},{name:"observation_record_event",description:"Record an agent event into the server. Calls /v1/events \u2014 server inserts the event row, the outbox row, and enqueues a generation job atomically. Server 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"},platformSource:{type:"string",description:"Optional platform source for session linkage and event scoping"},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 e=>BI(e??{})},{name:"observation_search",description:"Full-text search across generated observations using the server's GIN tsvector index (Phase 1). Calls /v1/search. Server runtime only. Params: query (required), projectId (optional), platformSource, limit (default 20, max 100).",inputSchema:{type:"object",properties:{projectId:{type:"string"},query:{type:"string",description:"Search query (required)"},platformSource:{type:"string",description:"Optional platform source filter, e.g. claude, codex, cursor"},limit:{type:"number",description:"Max results (default 20, max 100)"}},required:["query"],additionalProperties:!1},handler:async e=>GI(e??{})},{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 runtime only.",inputSchema:{type:"object",properties:{projectId:{type:"string"},query:{type:"string",description:"Search query (required)"},platformSource:{type:"string",description:"Optional platform source filter, e.g. claude, codex, cursor"},limit:{type:"number",description:"Max observations (default 10, max 50)"}},required:["query"],additionalProperties:!1},handler:async e=>YI(e??{})},{name:"observation_generation_status",description:"Look up the status of an observation generation job by id. Calls /v1/jobs/:id. Server 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 e=>QI(e??{})},{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 e=>{let t=await Vi(e.path||process.cwd()),r=await db(t,e.query,{maxResults:e.max_results||20,filePattern:e.file_pattern});return{content:[{type:"text",text:fb(r,e.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 e=>{let t=await Vi(e.file_path),r=await(0,cd.readFile)(t,"utf-8"),n=ub(r,t,e.symbol_name);if(n)return{content:[{type:"text",text:n}]};let o=Hi(r,t);if(o.symbols.length>0){let s=o.symbols.map(i=>` - ${i.name} (${i.kind})`).join(`
250
250
  `);return{content:[{type:"text",text:`Symbol "${e.symbol_name}" not found in ${e.file_path}.
251
251
 
252
252
  Available symbols:
253
- ${s}`}]}}return{content:[{type:"text",text:`Could not parse ${e.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 e=>{let t=await Vi(e.file_path),r=await(0,cd.readFile)(t,"utf-8"),n=Hi(r,t);return n.symbols.length>0?{content:[{type:"text",text:an(n)}]}:{content:[{type:"text",text:`Could not parse ${e.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 e=>await _t("/api/corpus",{body:e})},{name:"list_corpora",description:"List all knowledge corpora with their stats and priming status",inputSchema:{type:"object",properties:{},additionalProperties:!0},handler:async e=>await _t("/api/corpus",{query:e})},{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 e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/prime`,{body: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 e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/query`,{body: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 e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/rebuild`,{body: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 e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/reprime`,{body:r})}}],ld=new vi({name:"claude-mem",version:ZI},{capabilities:{tools:{}}});ld.setRequestHandler(vc,async()=>({tools:gb(wb,Gi()).map(t=>({name:t.name,description:t.description,inputSchema:t.inputSchema}))}));ld.setRequestHandler(Un,async e=>{let t=wb.find(r=>r.name===e.params.name);if(!t)throw new Error(`Unknown tool: ${e.params.name}`);try{return await t.handler(e.params.arguments||{})}catch(r){return _.error("SYSTEM","Tool execution failed",{tool:e.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 tA=3e4,$o=null,_b=!1;function Ji(){Oo("stdio-closed")}function kb(e){_.warn("SYSTEM","MCP stdio stream errored, shutting down",{message:e.message}),Oo("stdio-error")}function rA(){process.stdin.on("end",Ji),process.stdin.on("close",Ji),process.stdin.on("error",kb)}function nA(){process.stdin.off("end",Ji),process.stdin.off("close",Ji),process.stdin.off("error",kb)}function oA(){if(process.platform==="win32")return;let e=process.ppid;$o=setInterval(()=>{(process.ppid===1||process.ppid!==e)&&(_.info("SYSTEM","Parent process died, self-exiting to prevent orphan",{initialPpid:e,currentPpid:process.ppid}),Oo())},tA),$o.unref&&$o.unref()}function Oo(e="shutdown"){_b||(_b=!0,$o&&clearInterval($o),nA(),_.info("SYSTEM","MCP server shutting down",{reason:e}),process.exit(0))}process.on("SIGTERM",Oo);process.on("SIGINT",Oo);function sA(){let e=(0,yb.homedir)(),t=[(0,nr.resolve)(e,".claude","plugins","marketplaces","thedotmack"),(0,nr.resolve)(e,".config","claude","plugins","marketplaces","thedotmack")],r=t.some(i=>i&&(0,Yi.existsSync)(i)),n=[(0,nr.resolve)(e,".claude","plugins","cache","thedotmack","claude-mem"),(0,nr.resolve)(e,".config","claude","plugins","cache","thedotmack","claude-mem")],o=n.some(i=>i&&(0,Yi.existsSync)(i)),s=n[0];!r&&o&&_.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:t,cacheRoot:s})}function iA(){try{sA()}catch(e){_.warn("SYSTEM","checkMarketplaceMarker failed (non-fatal startup check)",void 0,e instanceof Error?e:new Error(String(e)))}}async function aA(){let e=new ki;rA(),await ld.connect(e),_.info("SYSTEM","Claude-mem search server started"),iA(),oA(),setTimeout(async()=>{if(Gi()==="server"){_.info("SYSTEM","MCP runtime=server \u2014 skipping worker auto-start",void 0,{});return}await eA()?_.info("SYSTEM","Worker available",void 0,{}):(_.error("SYSTEM","Worker not available",void 0,{}),_.error("SYSTEM","Tools will fail until Worker is started"),_.error("SYSTEM","Start Worker with: npm run worker:restart"))},0)}aA().catch(e=>{_.error("SYSTEM","Fatal error",void 0,e),process.exit(0)});
253
+ ${s}`}]}}return{content:[{type:"text",text:`Could not parse ${e.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 e=>{let t=await Vi(e.file_path),r=await(0,cd.readFile)(t,"utf-8"),n=Hi(r,t);return n.symbols.length>0?{content:[{type:"text",text:an(n)}]}:{content:[{type:"text",text:`Could not parse ${e.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 e=>await _t("/api/corpus",{body:e})},{name:"list_corpora",description:"List all knowledge corpora with their stats and priming status",inputSchema:{type:"object",properties:{},additionalProperties:!0},handler:async e=>await _t("/api/corpus",{query:e})},{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 e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/prime`,{body: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 e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/query`,{body: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 e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/rebuild`,{body: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 e=>{let{name:t,...r}=e;if(typeof t!="string"||t.trim()==="")throw new Error("Missing required argument: name");return await _t(`/api/corpus/${encodeURIComponent(t)}/reprime`,{body:r})}}],ld=new vi({name:"claude-mem",version:ZI},{capabilities:{tools:{}}});ld.setRequestHandler(vc,async()=>({tools:_b(kb,Gi()).map(t=>({name:t.name,description:t.description,inputSchema:t.inputSchema}))}));ld.setRequestHandler(Un,async e=>{let t=kb.find(r=>r.name===e.params.name);if(!t)throw new Error(`Unknown tool: ${e.params.name}`);try{return await t.handler(e.params.arguments||{})}catch(r){return _.error("SYSTEM","Tool execution failed",{tool:e.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 tA=3e4,$o=null,yb=!1;function Ji(){Oo("stdio-closed")}function xb(e){_.warn("SYSTEM","MCP stdio stream errored, shutting down",{message:e.message}),Oo("stdio-error")}function rA(){process.stdin.on("end",Ji),process.stdin.on("close",Ji),process.stdin.on("error",xb)}function nA(){process.stdin.off("end",Ji),process.stdin.off("close",Ji),process.stdin.off("error",xb)}function oA(){if(process.platform==="win32")return;let e=process.ppid;$o=setInterval(()=>{(process.ppid===1||process.ppid!==e)&&(_.info("SYSTEM","Parent process died, self-exiting to prevent orphan",{initialPpid:e,currentPpid:process.ppid}),Oo())},tA),$o.unref&&$o.unref()}function Oo(e="shutdown"){yb||(yb=!0,$o&&clearInterval($o),nA(),_.info("SYSTEM","MCP server shutting down",{reason:e}),process.exit(0))}process.on("SIGTERM",Oo);process.on("SIGINT",Oo);function sA(){let e=(0,Sb.homedir)(),t=[(0,nr.resolve)(e,".claude","plugins","marketplaces","thedotmack"),(0,nr.resolve)(e,".config","claude","plugins","marketplaces","thedotmack")],r=t.some(i=>i&&(0,Yi.existsSync)(i)),n=[(0,nr.resolve)(e,".claude","plugins","cache","thedotmack","claude-mem"),(0,nr.resolve)(e,".config","claude","plugins","cache","thedotmack","claude-mem")],o=n.some(i=>i&&(0,Yi.existsSync)(i)),s=n[0];!r&&o&&_.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:t,cacheRoot:s})}function iA(){try{sA()}catch(e){_.warn("SYSTEM","checkMarketplaceMarker failed (non-fatal startup check)",void 0,e instanceof Error?e:new Error(String(e)))}}async function aA(){let e=new ki;rA(),await ld.connect(e),_.info("SYSTEM","Claude-mem search server started"),iA(),oA(),setTimeout(async()=>{if(Gi()==="server"){_.info("SYSTEM","MCP runtime=server \u2014 skipping worker auto-start",void 0,{});return}await eA()?_.info("SYSTEM","Worker available",void 0,{}):(_.error("SYSTEM","Worker not available",void 0,{}),_.error("SYSTEM","Tools will fail until Worker is started"),_.error("SYSTEM","Start Worker with: npm run worker:restart"))},0)}aA().catch(e=>{_.error("SYSTEM","Fatal error",void 0,e),process.exit(0)});
254
254
  //# sourceMappingURL=mcp-server.cjs.map