alran 0.9.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ALRAN_TOOLS_NOTICES.md +11 -0
- package/README.md +11 -16
- package/assets/agents/alran/skills/alran-code-product/SKILL.md +3 -3
- package/assets/agents/alran/skills/alran-code-product/references/account-models.md +19 -16
- package/chunks/{account-commands-JZ6NXTTK.js → account-commands-GW7N3MYC.js} +1 -1
- package/chunks/{anthropic-MN33DP4E.js → anthropic-63VE6MAE.js} +1 -1
- package/chunks/{application-ITGAJ4HC.js → application-WPPTE6LU.js} +1 -1
- package/chunks/{auth-command-V3RVPLZO.js → auth-command-36RMNQZW.js} +1 -1
- package/chunks/azure-openai-responses-OIP3KVKJ.js +2 -0
- package/chunks/chunk-2K5H5GA7.js +2 -0
- package/chunks/chunk-3GGKARES.js +2 -0
- package/chunks/chunk-5RIMHTEU.js +207 -0
- package/chunks/{chunk-EYK25HWR.js → chunk-5Y76VFHY.js} +1 -1
- package/chunks/{chunk-QIN5ZBE2.js → chunk-6DOVXX7W.js} +1 -1
- package/chunks/{chunk-E3GLGDGC.js → chunk-6PFI65C6.js} +1 -1
- package/chunks/{chunk-4PDIO3M6.js → chunk-6UXSIWCB.js} +1 -1
- package/chunks/{chunk-OQNU3VPS.js → chunk-C6LAAFG2.js} +2 -2
- package/chunks/{chunk-33CNY6GP.js → chunk-CUG7F2FN.js} +1 -1
- package/chunks/chunk-DFMYLGVU.js +249 -0
- package/chunks/{chunk-IIE366LR.js → chunk-G5MOGPZ3.js} +490 -485
- package/chunks/{chunk-FC4M2B7E.js → chunk-IC6A323Q.js} +1 -1
- package/chunks/{chunk-4X22UJQH.js → chunk-IN2Z5SSJ.js} +1 -1
- package/chunks/chunk-JSTSFMGK.js +70 -0
- package/chunks/{chunk-WWNUAU4P.js → chunk-LCC45PCZ.js} +1 -1
- package/chunks/{chunk-7QLAXRD2.js → chunk-MPQ6G7LH.js} +254 -254
- package/chunks/{chunk-FUERW2DW.js → chunk-MUXNNOSQ.js} +1 -1
- package/chunks/{chunk-44VPC5LA.js → chunk-NBONSNQZ.js} +1 -1
- package/chunks/chunk-NMKRNU5O.js +2 -0
- package/chunks/chunk-NVPGGFT3.js +2 -0
- package/chunks/chunk-NZXJAHTO.js +9 -0
- package/chunks/{chunk-6255CZPL.js → chunk-PCL2CVVE.js} +1 -1
- package/chunks/chunk-PXH4SBCS.js +3 -0
- package/chunks/chunk-RLJVY75P.js +28 -0
- package/chunks/{chunk-WYANV3IX.js → chunk-RLND4AYL.js} +1 -1
- package/chunks/chunk-TJC4LPRQ.js +2 -0
- package/chunks/chunk-U4PFHJ7Z.js +27 -0
- package/chunks/chunk-V2SB4U4D.js +2 -0
- package/chunks/chunk-VGKKKM2W.js +6 -0
- package/chunks/{chunk-XFCC2CI2.js → chunk-VUISZDXX.js} +1 -1
- package/chunks/chunk-XVGPB7TW.js +21 -0
- package/chunks/{chunk-CJM7ZJ6W.js → chunk-ZDI22NOK.js} +1 -1
- package/chunks/{data-dir-LDVKDCJ2.js → data-dir-OEPRRIOO.js} +1 -1
- package/chunks/{dist-2BRD4JFU.js → dist-VKYZJYR6.js} +1 -1
- package/chunks/{dist-EXKHRFQO.js → dist-WGTMUM3E.js} +1 -1
- package/chunks/{ffi-OUPK6AY6.js → ffi-EFLUAAVX.js} +1 -1
- package/chunks/{ffi-M5UP5J6C.js → ffi-QKKA5HYI.js} +1 -1
- package/chunks/{google-UJAPMFAB.js → google-RCR46TTQ.js} +1 -1
- package/chunks/{google-vertex-VLSF55PW.js → google-vertex-Y26T7YYR.js} +1 -1
- package/chunks/{install-source-JTIUC4G4.js → install-source-63OVVBMK.js} +1 -1
- package/chunks/launcher-2UG3JPYF.js +63 -0
- package/chunks/lifecycle-5IPJRP2V.js +2 -0
- package/chunks/{main-TQGGRHTS.js → main-7SGOQBHZ.js} +2 -2
- package/chunks/{mistral-ZJZUEF2X.js → mistral-NEBDKUEI.js} +1 -1
- package/chunks/{module-6F3E5H7Y-BN7QWGYB.js → module-6F3E5H7Y-FIMLNSCK.js} +1 -1
- package/chunks/{module-asyncify-R6PWJ6ZV-P4FWSBAY.js → module-asyncify-R6PWJ6ZV-Q2HJ3NOC.js} +1 -1
- package/chunks/{multipart-parser-L6M455MS.js → multipart-parser-JVSLI2CL.js} +1 -1
- package/chunks/{network-proxy-U72JCK2I.js → network-proxy-AJO7ZW3O.js} +1 -1
- package/chunks/openai-codex-responses-L2CIGCKO.js +2 -0
- package/chunks/openai-completions-C4PHW6MD.js +2 -0
- package/chunks/openai-responses-5NVFOW4Y.js +2 -0
- package/chunks/{openrouter-G2EHY5BD.js → openrouter-BKUGQT7Z.js} +1 -1
- package/chunks/{otel-OHXIZ666.js → otel-DRJM2PIX.js} +1 -1
- package/chunks/plugin-command-CIDTOPNB.js +2 -0
- package/chunks/provider-command-UZ7KQFAC.js +2 -0
- package/chunks/run-acp-command-AKDLHKMR.js +59 -0
- package/chunks/{run-exec-command-5ADSQR2Z.js → run-exec-command-UXTPS7LC.js} +1 -1
- package/chunks/{skills-command-XXXEZAG6.js → skills-command-57TF53NO.js} +1 -1
- package/chunks/src-5PSNGHHD.js +2 -0
- package/chunks/{src-IBHIRTD7.js → src-YZ26EVSY.js} +1 -1
- package/chunks/telemetry-3NXMCOVD.js +2 -0
- package/chunks/{telemetry-command-COQG2AKK.js → telemetry-command-CMDERYNN.js} +1 -1
- package/chunks/{tools-WDBB2JKV.js → tools-CRJR35HS.js} +1 -1
- package/chunks/{undici-TUGHZJSA.js → undici-O4OQVZ6I.js} +1 -1
- package/chunks/{update-NB6OD572.js → update-ACFAGV6F.js} +1 -1
- package/cli.js +2 -3
- package/embedded/alran-tools/cli.mjs +1 -5
- package/embedded/alran-tools/manifest.json +1 -1
- package/image-preview-worker.js +1 -1
- package/matrix-mcp-stdio.js +1 -1
- package/package.json +1 -1
- package/quickjs-worker.js +1 -1
- package/chunks/azure-openai-responses-OWHMUNKC.js +0 -2
- package/chunks/chunk-C3CMJAAV.js +0 -3
- package/chunks/chunk-ENHOPPS7.js +0 -16
- package/chunks/chunk-FSNYOJPJ.js +0 -2
- package/chunks/chunk-FXOH6TEQ.js +0 -21
- package/chunks/chunk-GRXX6I72.js +0 -2
- package/chunks/chunk-GSYHBK5Q.js +0 -6
- package/chunks/chunk-IWK7PZP7.js +0 -207
- package/chunks/chunk-KCLRJQ53.js +0 -59
- package/chunks/chunk-M7GW4VMR.js +0 -27
- package/chunks/chunk-QFUV5PX6.js +0 -2
- package/chunks/chunk-TW23QKAD.js +0 -3
- package/chunks/chunk-U7U3DJHF.js +0 -2
- package/chunks/chunk-WTAJMYF2.js +0 -249
- package/chunks/chunk-YLQXZBEL.js +0 -2
- package/chunks/chunk-Z6BHCXKT.js +0 -25
- package/chunks/chunk-Z6HBNJCA.js +0 -8
- package/chunks/launcher-FCZ3EDBF.js +0 -61
- package/chunks/lifecycle-GY435YMF.js +0 -2
- package/chunks/openai-codex-responses-FPCDNRL5.js +0 -2
- package/chunks/openai-completions-D32YW6KL.js +0 -2
- package/chunks/openai-responses-ZCGSENM4.js +0 -2
- package/chunks/plugin-command-OSAFHS7C.js +0 -2
- package/chunks/provider-command-SKTCHD4E.js +0 -2
- package/chunks/run-acp-command-SG2BDMFJ.js +0 -2
- package/chunks/src-DNIDEMVV.js +0 -2
- package/chunks/telemetry-J7ZLGF5X.js +0 -2
- /package/chunks/{chunk-EOR6EDNR.js → chunk-2AYWJZ72.js} +0 -0
- /package/chunks/{chunk-YPV2X2RG.js → chunk-4XP5XUIZ.js} +0 -0
- /package/chunks/{chunk-NWB7LFOK.js → chunk-5DQTVSQV.js} +0 -0
- /package/chunks/{chunk-OIQ336YE.js → chunk-EJN3SE5B.js} +0 -0
- /package/chunks/{chunk-A7GMJNA2.js → chunk-K5DTFR6D.js} +0 -0
- /package/chunks/{chunk-ZQOALVGL.js → chunk-R44C5DM6.js} +0 -0
- /package/chunks/{chunk-PNXZWSWT.js → chunk-UJCAE7SG.js} +0 -0
- /package/chunks/{chunk-J3KCPYZT.js → chunk-W5ZOLW7T.js} +0 -0
- /package/chunks/{chunk-XAGZ6ZEU.js → chunk-XLVABFJC.js} +0 -0
- /package/chunks/{chunk-N5SVBCUB.js → chunk-XSEU4WQD.js} +0 -0
- /package/chunks/{chunk-CSOUJVKM.js → chunk-Z5HOCNTZ.js} +0 -0
- /package/chunks/{emscripten-module-ZS3PMSDF.js → emscripten-module-3WGSFZYF.js} +0 -0
- /package/chunks/{emscripten-module-XPTEOIWW.js → emscripten-module-74WUXTHL.js} +0 -0
- /package/chunks/{emscripten-module-WYNDFH3N.js → emscripten-module-MCN4Y3N4.js} +0 -0
- /package/chunks/{emscripten-module-RD6P2XH5.js → emscripten-module-NEAT5LGD.js} +0 -0
- /package/chunks/{ffi-ORLOPBB3.js → ffi-JIGPPPF7.js} +0 -0
- /package/chunks/{ffi-IO7WZQNG.js → ffi-RLX77WFG.js} +0 -0
- /package/chunks/{pdfjs-SHZAF7PF.js → pdfjs-2UOWBGC2.js} +0 -0
- /package/chunks/{photon_rs-C52RL4CI.js → photon_rs-MVWYTYTO.js} +0 -0
package/chunks/chunk-ENHOPPS7.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createRequire as __alran_cR } from "module"; import { basename as __alran_basename, dirname as __alran_dirname, join as __alran_join } from "path"; import { fileURLToPath as __alran_fileURLToPath, pathToFileURL as __alran_pathToFileURL } from "url"; const __alran_tuiCurrentModuleDir = __alran_dirname(__alran_fileURLToPath(import.meta.url)); const __alran_tuiPackageRoot = __alran_basename(__alran_tuiCurrentModuleDir) === "chunks" ? __alran_dirname(__alran_tuiCurrentModuleDir) : __alran_tuiCurrentModuleDir; const __alran_tuiPackageEntryUrl = __alran_pathToFileURL(__alran_join(__alran_tuiPackageRoot, "cli.js")).href; const require = __alran_cR(__alran_tuiPackageEntryUrl); const __dirname = __alran_tuiPackageRoot;
|
|
2
|
-
import{A as Vf,B as $u,d as Au,e as Gf,f as T,g as _e,i as rt,j as Bf,l as Ge,o as ae,p as A,q as Rt,r as Ne,s as ku,t as Eu,u as Oe,v as Bt,w as $,x as qe}from"./chunk-M7GW4VMR.js";import{f as Ou,h as Pu}from"./chunk-VLXX22YO.js";import{a as rw}from"./chunk-NWB7LFOK.js";import{b as qf,c as Kf}from"./chunk-EOR6EDNR.js";import{a as tw,c as P,d as xn,e as Ru,f as Q,g as Z,h as ee}from"./chunk-XQK7JM66.js";var hs=P(fe=>{"use strict";Object.defineProperty(fe,"__esModule",{value:true});fe.regexpCode=fe.getEsmExportName=fe.getProperty=fe.safeStringify=fe.stringify=fe.strConcat=fe.addCodeArg=fe.str=fe._=fe.nil=fe._Code=fe.Name=fe.IDENTIFIER=fe._CodeOrName=void 0;var fs=class{};fe._CodeOrName=fs;fe.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var _n=class extends fs{constructor(t){super();if(!fe.IDENTIFIER.test(t))throw new Error("CodeGen: name must be a valid identifier");this.str=t}toString(){return this.str}emptyStr(){return false}get names(){return{[this.str]:1}}};fe.Name=_n;var cr=class extends fs{constructor(t){super();this._items=typeof t==="string"?[t]:t}toString(){return this.str}emptyStr(){if(this._items.length>1)return false;const 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,o)=>`${r}${o}`,"")}get names(){var t;return(t=this._names)!==null&&t!==void 0?t:this._names=this._items.reduce((r,o)=>{if(o instanceof _n)r[o.str]=(r[o.str]||0)+1;return r},{})}};fe._Code=cr;fe.nil=new cr("");function dm(e,...t){const r=[e[0]];let o=0;while(o<t.length){el(r,t[o]);r.push(e[++o])}return new cr(r)}fe._=dm;var Zu=new cr("+");function pm(e,...t){const r=[ms(e[0])];let o=0;while(o<t.length){r.push(Zu);el(r,t[o]);r.push(Zu,ms(e[++o]))}jT(r);return new cr(r)}fe.str=pm;function el(e,t){if(t instanceof cr)e.push(...t._items);else if(t instanceof _n)e.push(t);else e.push(UT(t))}fe.addCodeArg=el;function jT(e){let t=1;while(t<e.length-1){if(e[t]===Zu){const r=zT(e[t-1],e[t+1]);if(r!==void 0){e.splice(t-1,3,r);continue}e[t++]="+"}t++}}function zT(e,t){if(t==='""')return e;if(e==='""')return t;if(typeof e=="string"){if(t instanceof _n||e[e.length-1]!=='"')return;if(typeof t!="string")return`${e.slice(0,-1)}${t}"`;if(t[0]==='"')return e.slice(0,-1)+t.slice(1);return}if(typeof t=="string"&&t[0]==='"'&&!(e instanceof _n))return`"${e}${t.slice(1)}`;return}function DT(e,t){return t.emptyStr()?e:e.emptyStr()?t:pm`${e}${t}`}fe.strConcat=DT;function UT(e){return typeof e=="number"||typeof e=="boolean"||e===null?e:ms(Array.isArray(e)?e.join(","):e)}function LT(e){return new cr(ms(e))}fe.stringify=LT;function ms(e){return JSON.stringify(e).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}fe.safeStringify=ms;function qT(e){return typeof e=="string"&&fe.IDENTIFIER.test(e)?new cr(`.${e}`):dm`[${e}]`}fe.getProperty=qT;function KT(e){if(typeof e=="string"&&fe.IDENTIFIER.test(e)){return new cr(`${e}`)}throw new Error(`CodeGen: invalid export name: ${e}, use explicit $id name mapping`)}fe.getEsmExportName=KT;function GT(e){return new cr(e.toString())}fe.regexpCode=GT});var ol=P(Ct=>{"use strict";Object.defineProperty(Ct,"__esModule",{value:true});Ct.ValueScope=Ct.ValueScopeName=Ct.Scope=Ct.varKinds=Ct.UsedValueState=void 0;var vt=hs();var tl=class extends Error{constructor(t){super(`CodeGen: "code" for ${t} not defined`);this.value=t.value}};var $a;(function(e){e[e["Started"]=0]="Started";e[e["Completed"]=1]="Completed"})($a||(Ct.UsedValueState=$a={}));Ct.varKinds={const:new vt.Name("const"),let:new vt.Name("let"),var:new vt.Name("var")};var va=class{constructor({prefixes:t,parent:r}={}){this._names={};this._prefixes=t;this._parent=r}toName(t){return t instanceof vt.Name?t:this.name(t)}name(t){return new vt.Name(this._newName(t))}_newName(t){const r=this._names[t]||this._nameGroup(t);return`${t}${r.index++}`}_nameGroup(t){var r,o;if(((o=(r=this._parent)===null||r===void 0?void 0:r._prefixes)===null||o===void 0?void 0:o.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}}};Ct.Scope=va;var Ca=class extends vt.Name{constructor(t,r){super(r);this.prefix=t}setValue(t,{property:r,itemIndex:o}){this.value=t;this.scopePath=(0,vt._)`.${new vt.Name(r)}[${o}]`}};Ct.ValueScopeName=Ca;var BT=(0,vt._)`\n`;var rl=class extends va{constructor(t){super(t);this._values={};this._scope=t.scope;this.opts={...t,_n:t.lines?BT:vt.nil}}get(){return this._scope}name(t){return new Ca(t,this._newName(t))}value(t,r){var o;if(r.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const n=this.toName(t);const{prefix:i}=n;const s=(o=r.key)!==null&&o!==void 0?o:r.ref;let a=this._values[i];if(a){const u=a.get(s);if(u)return u}else{a=this._values[i]=new Map}a.set(s,n);const c=this._scope[i]||(this._scope[i]=[]);const l=c.length;c[l]=r.ref;n.setValue(r,{property:i,itemIndex:l});return n}getValue(t,r){const o=this._values[t];if(!o)return;return o.get(r)}scopeRefs(t,r=this._values){return this._reduceValues(r,o=>{if(o.scopePath===void 0)throw new Error(`CodeGen: name "${o}" has no value`);return(0,vt._)`${t}${o.scopePath}`})}scopeCode(t=this._values,r,o){return this._reduceValues(t,n=>{if(n.value===void 0)throw new Error(`CodeGen: name "${n}" has no value`);return n.value.code},r,o)}_reduceValues(t,r,o={},n){let i=vt.nil;for(const s in t){const a=t[s];if(!a)continue;const c=o[s]=o[s]||new Map;a.forEach(l=>{if(c.has(l))return;c.set(l,$a.Started);let u=r(l);if(u){const d=this.opts.es5?Ct.varKinds.var:Ct.varKinds.const;i=(0,vt._)`${i}${d} ${l} = ${u};${this.opts._n}`}else if(u=n===null||n===void 0?void 0:n(l)){i=(0,vt._)`${i}${u}${this.opts._n}`}else{throw new tl(l)}c.set(l,$a.Completed)})}return i}};Ct.ValueScope=rl});var K=P(G=>{"use strict";Object.defineProperty(G,"__esModule",{value:true});G.or=G.and=G.not=G.CodeGen=G.operators=G.varKinds=G.ValueScopeName=G.ValueScope=G.Scope=G.Name=G.regexpCode=G.stringify=G.getProperty=G.nil=G.strConcat=G.str=G._=void 0;var ie=hs();var br=ol();var Ao=hs();Object.defineProperty(G,"_",{enumerable:true,get:function(){return Ao._}});Object.defineProperty(G,"str",{enumerable:true,get:function(){return Ao.str}});Object.defineProperty(G,"strConcat",{enumerable:true,get:function(){return Ao.strConcat}});Object.defineProperty(G,"nil",{enumerable:true,get:function(){return Ao.nil}});Object.defineProperty(G,"getProperty",{enumerable:true,get:function(){return Ao.getProperty}});Object.defineProperty(G,"stringify",{enumerable:true,get:function(){return Ao.stringify}});Object.defineProperty(G,"regexpCode",{enumerable:true,get:function(){return Ao.regexpCode}});Object.defineProperty(G,"Name",{enumerable:true,get:function(){return Ao.Name}});var za=ol();Object.defineProperty(G,"Scope",{enumerable:true,get:function(){return za.Scope}});Object.defineProperty(G,"ValueScope",{enumerable:true,get:function(){return za.ValueScope}});Object.defineProperty(G,"ValueScopeName",{enumerable:true,get:function(){return za.ValueScopeName}});Object.defineProperty(G,"varKinds",{enumerable:true,get:function(){return za.varKinds}});G.operators={GT:new ie._Code(">"),GTE:new ie._Code(">="),LT:new ie._Code("<"),LTE:new ie._Code("<="),EQ:new ie._Code("==="),NEQ:new ie._Code("!=="),NOT:new ie._Code("!"),OR:new ie._Code("||"),AND:new ie._Code("&&"),ADD:new ie._Code("+")};var ao=class{optimizeNodes(){return this}optimizeNames(t,r){return this}};var nl=class extends ao{constructor(t,r,o){super();this.varKind=t;this.name=r;this.rhs=o}render({es5:t,_n:r}){const o=t?br.varKinds.var:this.varKind;const n=this.rhs===void 0?"":` = ${this.rhs}`;return`${o} ${this.name}${n};`+r}optimizeNames(t,r){if(!t[this.name.str])return;if(this.rhs)this.rhs=pi(this.rhs,t,r);return this}get names(){return this.rhs instanceof ie._CodeOrName?this.rhs.names:{}}};var Fa=class extends ao{constructor(t,r,o){super();this.lhs=t;this.rhs=r;this.sideEffects=o}render({_n:t}){return`${this.lhs} = ${this.rhs};`+t}optimizeNames(t,r){if(this.lhs instanceof ie.Name&&!t[this.lhs.str]&&!this.sideEffects)return;this.rhs=pi(this.rhs,t,r);return this}get names(){const t=this.lhs instanceof ie.Name?{}:{...this.lhs.names};return ja(t,this.rhs)}};var il=class extends Fa{constructor(t,r,o,n){super(t,o,n);this.op=r}render({_n:t}){return`${this.lhs} ${this.op}= ${this.rhs};`+t}};var sl=class extends ao{constructor(t){super();this.label=t;this.names={}}render({_n:t}){return`${this.label}:`+t}};var al=class extends ao{constructor(t){super();this.label=t;this.names={}}render({_n:t}){const r=this.label?` ${this.label}`:"";return`break${r};`+t}};var cl=class extends ao{constructor(t){super();this.error=t}render({_n:t}){return`throw ${this.error};`+t}get names(){return this.error.names}};var ul=class extends ao{constructor(t){super();this.code=t}render({_n:t}){return`${this.code};`+t}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(t,r){this.code=pi(this.code,t,r);return this}get names(){return this.code instanceof ie._CodeOrName?this.code.names:{}}};var gs=class extends ao{constructor(t=[]){super();this.nodes=t}render(t){return this.nodes.reduce((r,o)=>r+o.render(t),"")}optimizeNodes(){const{nodes:t}=this;let r=t.length;while(r--){const o=t[r].optimizeNodes();if(Array.isArray(o))t.splice(r,1,...o);else if(o)t[r]=o;else t.splice(r,1)}return t.length>0?this:void 0}optimizeNames(t,r){const{nodes:o}=this;let n=o.length;while(n--){const i=o[n];if(i.optimizeNames(t,r))continue;VT(t,i.names);o.splice(n,1)}return o.length>0?this:void 0}get names(){return this.nodes.reduce((t,r)=>wn(t,r.names),{})}};var co=class extends gs{render(t){return"{"+t._n+super.render(t)+"}"+t._n}};var ll=class extends gs{};var di=class extends co{};di.kind="else";var In=class e extends co{constructor(t,r){super(r);this.condition=t}render(t){let r=`if(${this.condition})`+super.render(t);if(this.else)r+="else "+this.else.render(t);return r}optimizeNodes(){super.optimizeNodes();const t=this.condition;if(t===true)return this.nodes;let r=this.else;if(r){const o=r.optimizeNodes();r=this.else=Array.isArray(o)?new di(o):o}if(r){if(t===false)return r instanceof e?r:r.nodes;if(this.nodes.length)return this;return new e(fm(t),r instanceof e?[r]:r.nodes)}if(t===false||!this.nodes.length)return void 0;return this}optimizeNames(t,r){var o;this.else=(o=this.else)===null||o===void 0?void 0:o.optimizeNames(t,r);if(!(super.optimizeNames(t,r)||this.else))return;this.condition=pi(this.condition,t,r);return this}get names(){const t=super.names;ja(t,this.condition);if(this.else)wn(t,this.else.names);return t}};In.kind="if";var bn=class extends co{};bn.kind="for";var dl=class extends bn{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=pi(this.iteration,t,r);return this}get names(){return wn(super.names,this.iteration.names)}};var pl=class extends bn{constructor(t,r,o,n){super();this.varKind=t;this.name=r;this.from=o;this.to=n}render(t){const r=t.es5?br.varKinds.var:this.varKind;const{name:o,from:n,to:i}=this;return`for(${r} ${o}=${n}; ${o}<${i}; ${o}++)`+super.render(t)}get names(){const t=ja(super.names,this.from);return ja(t,this.to)}};var Na=class extends bn{constructor(t,r,o,n){super();this.loop=t;this.varKind=r;this.name=o;this.iterable=n}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=pi(this.iterable,t,r);return this}get names(){return wn(super.names,this.iterable.names)}};var ys=class extends co{constructor(t,r,o){super();this.name=t;this.args=r;this.async=o}render(t){const r=this.async?"async ":"";return`${r}function ${this.name}(${this.args})`+super.render(t)}};ys.kind="func";var xs=class extends gs{render(t){return"return "+super.render(t)}};xs.kind="return";var fl=class extends co{render(t){let r="try"+super.render(t);if(this.catch)r+=this.catch.render(t);if(this.finally)r+=this.finally.render(t);return r}optimizeNodes(){var t,r;super.optimizeNodes();(t=this.catch)===null||t===void 0?void 0:t.optimizeNodes();(r=this.finally)===null||r===void 0?void 0:r.optimizeNodes();return this}optimizeNames(t,r){var o,n;super.optimizeNames(t,r);(o=this.catch)===null||o===void 0?void 0:o.optimizeNames(t,r);(n=this.finally)===null||n===void 0?void 0:n.optimizeNames(t,r);return this}get names(){const t=super.names;if(this.catch)wn(t,this.catch.names);if(this.finally)wn(t,this.finally.names);return t}};var _s=class extends co{constructor(t){super();this.error=t}render(t){return`catch(${this.error})`+super.render(t)}};_s.kind="catch";var Is=class extends co{render(t){return"finally"+super.render(t)}};Is.kind="finally";var ml=class{constructor(t,r={}){this._values={};this._blockStarts=[];this._constants={};this.opts={...r,_n:r.lines?"\n":""};this._extScope=t;this._scope=new br.Scope({parent:t});this._nodes=[new ll]}toString(){return this._root.render(this.opts)}name(t){return this._scope.name(t)}scopeName(t){return this._extScope.name(t)}scopeValue(t,r){const o=this._extScope.value(t,r);const n=this._values[o.prefix]||(this._values[o.prefix]=new Set);n.add(o);return o}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,o,n){const i=this._scope.toName(r);if(o!==void 0&&n)this._constants[i.str]=o;this._leafNode(new nl(t,i,o));return i}const(t,r,o){return this._def(br.varKinds.const,t,r,o)}let(t,r,o){return this._def(br.varKinds.let,t,r,o)}var(t,r,o){return this._def(br.varKinds.var,t,r,o)}assign(t,r,o){return this._leafNode(new Fa(t,r,o))}add(t,r){return this._leafNode(new il(t,G.operators.ADD,r))}code(t){if(typeof t=="function")t();else if(t!==ie.nil)this._leafNode(new ul(t));return this}object(...t){const r=["{"];for(const[o,n]of t){if(r.length>1)r.push(",");r.push(o);if(o!==n||this.opts.es5){r.push(":");(0,ie.addCodeArg)(r,n)}}r.push("}");return new ie._Code(r)}if(t,r,o){this._blockNode(new In(t));if(r&&o){this.code(r).else().code(o).endIf()}else if(r){this.code(r).endIf()}else if(o){throw new Error('CodeGen: "else" body without "then" body')}return this}elseIf(t){return this._elseNode(new In(t))}else(){return this._elseNode(new di)}endIf(){return this._endBlockNode(In,di)}_for(t,r){this._blockNode(t);if(r)this.code(r).endFor();return this}for(t,r){return this._for(new dl(t),r)}forRange(t,r,o,n,i=this.opts.es5?br.varKinds.var:br.varKinds.let){const s=this._scope.toName(t);return this._for(new pl(i,s,r,o),()=>n(s))}forOf(t,r,o,n=br.varKinds.const){const i=this._scope.toName(t);if(this.opts.es5){const s=r instanceof ie.Name?r:this.var("_arr",r);return this.forRange("_i",0,(0,ie._)`${s}.length`,a=>{this.var(i,(0,ie._)`${s}[${a}]`);o(i)})}return this._for(new Na("of",n,i,r),()=>o(i))}forIn(t,r,o,n=this.opts.es5?br.varKinds.var:br.varKinds.const){if(this.opts.ownProperties){return this.forOf(t,(0,ie._)`Object.keys(${r})`,o)}const i=this._scope.toName(t);return this._for(new Na("in",n,i,r),()=>o(i))}endFor(){return this._endBlockNode(bn)}label(t){return this._leafNode(new sl(t))}break(t){return this._leafNode(new al(t))}return(t){const r=new xs;this._blockNode(r);this.code(t);if(r.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(xs)}try(t,r,o){if(!r&&!o)throw new Error('CodeGen: "try" without "catch" and "finally"');const n=new fl;this._blockNode(n);this.code(t);if(r){const i=this.name("e");this._currNode=n.catch=new _s(i);r(i)}if(o){this._currNode=n.finally=new Is;this.code(o)}return this._endBlockNode(_s,Is)}throw(t){return this._leafNode(new cl(t))}block(t,r){this._blockStarts.push(this._nodes.length);if(t)this.code(t).endBlock(r);return this}endBlock(t){const r=this._blockStarts.pop();if(r===void 0)throw new Error("CodeGen: not in self-balancing block");const o=this._nodes.length-r;if(o<0||t!==void 0&&o!==t){throw new Error(`CodeGen: wrong number of nodes: ${o} vs ${t} expected`)}this._nodes.length=r;return this}func(t,r=ie.nil,o,n){this._blockNode(new ys(t,r,o));if(n)this.code(n).endFunc();return this}endFunc(){return this._endBlockNode(ys)}optimize(t=1){while(t-- >0){this._root.optimizeNodes();this._root.optimizeNames(this._root.names,this._constants)}}_leafNode(t){this._currNode.nodes.push(t);return this}_blockNode(t){this._currNode.nodes.push(t);this._nodes.push(t)}_endBlockNode(t,r){const o=this._currNode;if(o instanceof t||r&&o instanceof r){this._nodes.pop();return this}throw new Error(`CodeGen: not in block "${r?`${t.kind}/${r.kind}`:t.kind}"`)}_elseNode(t){const r=this._currNode;if(!(r instanceof In)){throw new Error('CodeGen: "else" without "if"')}this._currNode=r.else=t;return this}get _root(){return this._nodes[0]}get _currNode(){const t=this._nodes;return t[t.length-1]}set _currNode(t){const r=this._nodes;r[r.length-1]=t}};G.CodeGen=ml;function wn(e,t){for(const r in t)e[r]=(e[r]||0)+(t[r]||0);return e}function ja(e,t){return t instanceof ie._CodeOrName?wn(e,t.names):e}function pi(e,t,r){if(e instanceof ie.Name)return o(e);if(!n(e))return e;return new ie._Code(e._items.reduce((i,s)=>{if(s instanceof ie.Name)s=o(s);if(s instanceof ie._Code)i.push(...s._items);else i.push(s);return i},[]));function o(i){const s=r[i.str];if(s===void 0||t[i.str]!==1)return i;delete t[i.str];return s}function n(i){return i instanceof ie._Code&&i._items.some(s=>s instanceof ie.Name&&t[s.str]===1&&r[s.str]!==void 0)}}function VT(e,t){for(const r in t)e[r]=(e[r]||0)-(t[r]||0)}function fm(e){return typeof e=="boolean"||typeof e=="number"||e===null?!e:(0,ie._)`!${hl(e)}`}G.not=fm;var HT=mm(G.operators.AND);function WT(...e){return e.reduce(HT)}G.and=WT;var JT=mm(G.operators.OR);function XT(...e){return e.reduce(JT)}G.or=XT;function mm(e){return(t,r)=>t===ie.nil?r:r===ie.nil?t:(0,ie._)`${hl(t)} ${e} ${hl(r)}`}function hl(e){return e instanceof ie.Name?e:(0,ie._)`(${e})`}});var ce=P(V=>{"use strict";Object.defineProperty(V,"__esModule",{value:true});V.checkStrictMode=V.getErrorPath=V.Type=V.useFunc=V.setEvaluated=V.evaluatedPropsToName=V.mergeEvaluated=V.eachItem=V.unescapeJsonPointer=V.escapeJsonPointer=V.escapeFragment=V.unescapeFragment=V.schemaRefOrVal=V.schemaHasRulesButRef=V.schemaHasRules=V.checkUnknownRules=V.alwaysValidSchema=V.toHash=void 0;var Se=K();var YT=hs();function QT(e){const t={};for(const r of e)t[r]=true;return t}V.toHash=QT;function ZT(e,t){if(typeof t=="boolean")return t;if(Object.keys(t).length===0)return true;ym(e,t);return!xm(t,e.self.RULES.all)}V.alwaysValidSchema=ZT;function ym(e,t=e.schema){const{opts:r,self:o}=e;if(!r.strictSchema)return;if(typeof t==="boolean")return;const n=o.RULES.keywords;for(const i in t){if(!n[i])bm(e,`unknown keyword: "${i}"`)}}V.checkUnknownRules=ym;function xm(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(t[r])return true;return false}V.schemaHasRules=xm;function eS(e,t){if(typeof e=="boolean")return!e;for(const r in e)if(r!=="$ref"&&t.all[r])return true;return false}V.schemaHasRulesButRef=eS;function tS({topSchemaRef:e,schemaPath:t},r,o,n){if(!n){if(typeof r=="number"||typeof r=="boolean")return r;if(typeof r=="string")return(0,Se._)`${r}`}return(0,Se._)`${e}${t}${(0,Se.getProperty)(o)}`}V.schemaRefOrVal=tS;function rS(e){return _m(decodeURIComponent(e))}V.unescapeFragment=rS;function oS(e){return encodeURIComponent(yl(e))}V.escapeFragment=oS;function yl(e){if(typeof e=="number")return`${e}`;return e.replace(/~/g,"~0").replace(/\//g,"~1")}V.escapeJsonPointer=yl;function _m(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}V.unescapeJsonPointer=_m;function nS(e,t){if(Array.isArray(e)){for(const r of e)t(r)}else{t(e)}}V.eachItem=nS;function hm({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:o}){return(n,i,s,a)=>{const c=s===void 0?i:s instanceof Se.Name?(i instanceof Se.Name?e(n,i,s):t(n,i,s),s):i instanceof Se.Name?(t(n,s,i),i):r(i,s);return a===Se.Name&&!(c instanceof Se.Name)?o(n,c):c}}V.mergeEvaluated={props:hm({mergeNames:(e,t,r)=>e.if((0,Se._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,Se._)`${t} === true`,()=>e.assign(r,true),()=>e.assign(r,(0,Se._)`${r} || {}`).code((0,Se._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,Se._)`${r} !== true`,()=>{if(t===true){e.assign(r,true)}else{e.assign(r,(0,Se._)`${r} || {}`);xl(e,r,t)}}),mergeValues:(e,t)=>e===true?true:{...e,...t},resultToName:Im}),items:hm({mergeNames:(e,t,r)=>e.if((0,Se._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,Se._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,Se._)`${r} !== true`,()=>e.assign(r,t===true?true:(0,Se._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===true?true:Math.max(e,t),resultToName:(e,t)=>e.var("items",t)})};function Im(e,t){if(t===true)return e.var("props",true);const r=e.var("props",(0,Se._)`{}`);if(t!==void 0)xl(e,r,t);return r}V.evaluatedPropsToName=Im;function xl(e,t,r){Object.keys(r).forEach(o=>e.assign((0,Se._)`${t}${(0,Se.getProperty)(o)}`,true))}V.setEvaluated=xl;var gm={};function iS(e,t){return e.scopeValue("func",{ref:t,code:gm[t.code]||(gm[t.code]=new YT._Code(t.code))})}V.useFunc=iS;var gl;(function(e){e[e["Num"]=0]="Num";e[e["Str"]=1]="Str"})(gl||(V.Type=gl={}));function sS(e,t,r){if(e instanceof Se.Name){const o=t===gl.Num;return r?o?(0,Se._)`"[" + ${e} + "]"`:(0,Se._)`"['" + ${e} + "']"`:o?(0,Se._)`"/" + ${e}`:(0,Se._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,Se.getProperty)(e).toString():"/"+yl(e)}V.getErrorPath=sS;function bm(e,t,r=e.opts.strictSchema){if(!r)return;t=`strict mode: ${t}`;if(r===true)throw new Error(t);e.self.logger.warn(t)}V.checkStrictMode=bm});var uo=P(_l=>{"use strict";Object.defineProperty(_l,"__esModule",{value:true});var yt=K();var aS={data:new yt.Name("data"),valCxt:new yt.Name("valCxt"),instancePath:new yt.Name("instancePath"),parentData:new yt.Name("parentData"),parentDataProperty:new yt.Name("parentDataProperty"),rootData:new yt.Name("rootData"),dynamicAnchors:new yt.Name("dynamicAnchors"),vErrors:new yt.Name("vErrors"),errors:new yt.Name("errors"),this:new yt.Name("this"),self:new yt.Name("self"),scope:new yt.Name("scope"),json:new yt.Name("json"),jsonPos:new yt.Name("jsonPos"),jsonLen:new yt.Name("jsonLen"),jsonPart:new yt.Name("jsonPart")};_l.default=aS});var bs=P(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:true});xt.extendErrors=xt.resetErrorsCount=xt.reportExtraError=xt.reportError=xt.keyword$DataError=xt.keywordError=void 0;var ue=K();var Da=ce();var Ot=uo();xt.keywordError={message:({keyword:e})=>(0,ue.str)`must pass "${e}" keyword validation`};xt.keyword$DataError={message:({keyword:e,schemaType:t})=>t?(0,ue.str)`"${e}" keyword must be ${t} ($data)`:(0,ue.str)`"${e}" keyword is invalid ($data)`};function cS(e,t=xt.keywordError,r,o){const{it:n}=e;const{gen:i,compositeRule:s,allErrors:a}=n;const c=Sm(e,t,r);if(o!==null&&o!==void 0?o:s||a){wm(i,c)}else{Tm(n,(0,ue._)`[${c}]`)}}xt.reportError=cS;function uS(e,t=xt.keywordError,r){const{it:o}=e;const{gen:n,compositeRule:i,allErrors:s}=o;const a=Sm(e,t,r);wm(n,a);if(!(i||s)){Tm(o,Ot.default.vErrors)}}xt.reportExtraError=uS;function lS(e,t){e.assign(Ot.default.errors,t);e.if((0,ue._)`${Ot.default.vErrors} !== null`,()=>e.if(t,()=>e.assign((0,ue._)`${Ot.default.vErrors}.length`,t),()=>e.assign(Ot.default.vErrors,null)))}xt.resetErrorsCount=lS;function dS({gen:e,keyword:t,schemaValue:r,data:o,errsCount:n,it:i}){if(n===void 0)throw new Error("ajv implementation error");const s=e.name("err");e.forRange("i",n,Ot.default.errors,a=>{e.const(s,(0,ue._)`${Ot.default.vErrors}[${a}]`);e.if((0,ue._)`${s}.instancePath === undefined`,()=>e.assign((0,ue._)`${s}.instancePath`,(0,ue.strConcat)(Ot.default.instancePath,i.errorPath)));e.assign((0,ue._)`${s}.schemaPath`,(0,ue.str)`${i.errSchemaPath}/${t}`);if(i.opts.verbose){e.assign((0,ue._)`${s}.schema`,r);e.assign((0,ue._)`${s}.data`,o)}})}xt.extendErrors=dS;function wm(e,t){const r=e.const("err",t);e.if((0,ue._)`${Ot.default.vErrors} === null`,()=>e.assign(Ot.default.vErrors,(0,ue._)`[${r}]`),(0,ue._)`${Ot.default.vErrors}.push(${r})`);e.code((0,ue._)`${Ot.default.errors}++`)}function Tm(e,t){const{gen:r,validateName:o,schemaEnv:n}=e;if(n.$async){r.throw((0,ue._)`new ${e.ValidationError}(${t})`)}else{r.assign((0,ue._)`${o}.errors`,t);r.return(false)}}var Tn={keyword:new ue.Name("keyword"),schemaPath:new ue.Name("schemaPath"),params:new ue.Name("params"),propertyName:new ue.Name("propertyName"),message:new ue.Name("message"),schema:new ue.Name("schema"),parentSchema:new ue.Name("parentSchema")};function Sm(e,t,r){const{createErrors:o}=e.it;if(o===false)return(0,ue._)`{}`;return pS(e,t,r)}function pS(e,t,r={}){const{gen:o,it:n}=e;const i=[fS(n,r),mS(e,r)];hS(e,t,i);return o.object(...i)}function fS({errorPath:e},{instancePath:t}){const r=t?(0,ue.str)`${e}${(0,Da.getErrorPath)(t,Da.Type.Str)}`:e;return[Ot.default.instancePath,(0,ue.strConcat)(Ot.default.instancePath,r)]}function mS({keyword:e,it:{errSchemaPath:t}},{schemaPath:r,parentSchema:o}){let n=o?t:(0,ue.str)`${t}/${e}`;if(r){n=(0,ue.str)`${n}${(0,Da.getErrorPath)(r,Da.Type.Str)}`}return[Tn.schemaPath,n]}function hS(e,{params:t,message:r},o){const{keyword:n,data:i,schemaValue:s,it:a}=e;const{opts:c,propertyName:l,topSchemaRef:u,schemaPath:d}=a;o.push([Tn.keyword,n],[Tn.params,typeof t=="function"?t(e):t||(0,ue._)`{}`]);if(c.messages){o.push([Tn.message,typeof r=="function"?r(e):r])}if(c.verbose){o.push([Tn.schema,s],[Tn.parentSchema,(0,ue._)`${u}${d}`],[Ot.default.data,i])}if(l)o.push([Tn.propertyName,l])}});var Rm=P(fi=>{"use strict";Object.defineProperty(fi,"__esModule",{value:true});fi.boolOrEmptySchema=fi.topBoolOrEmptySchema=void 0;var gS=bs();var yS=K();var xS=uo();var _S={message:"boolean schema is false"};function IS(e){const{gen:t,schema:r,validateName:o}=e;if(r===false){Mm(e,false)}else if(typeof r=="object"&&r.$async===true){t.return(xS.default.data)}else{t.assign((0,yS._)`${o}.errors`,null);t.return(true)}}fi.topBoolOrEmptySchema=IS;function bS(e,t){const{gen:r,schema:o}=e;if(o===false){r.var(t,false);Mm(e)}else{r.var(t,true)}}fi.boolOrEmptySchema=bS;function Mm(e,t){const{gen:r,data:o}=e;const n={gen:r,keyword:"false schema",data:o,schema:false,schemaCode:false,schemaValue:false,params:{},it:e};(0,gS.reportError)(n,_S,void 0,t)}});var Il=P(mi=>{"use strict";Object.defineProperty(mi,"__esModule",{value:true});mi.getRules=mi.isJSONType=void 0;var wS=["string","number","integer","boolean","null","object","array"];var TS=new Set(wS);function SS(e){return typeof e=="string"&&TS.has(e)}mi.isJSONType=SS;function MS(){const e={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...e,integer:true,boolean:true,null:true},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}mi.getRules=MS});var bl=P(ko=>{"use strict";Object.defineProperty(ko,"__esModule",{value:true});ko.shouldUseRule=ko.shouldUseGroup=ko.schemaHasRulesForType=void 0;function RS({schema:e,self:t},r){const o=t.RULES.types[r];return o&&o!==true&&Om(e,o)}ko.schemaHasRulesForType=RS;function Om(e,t){return t.rules.some(r=>Pm(e,r))}ko.shouldUseGroup=Om;function Pm(e,t){var r;return e[t.keyword]!==void 0||((r=t.definition.implements)===null||r===void 0?void 0:r.some(o=>e[o]!==void 0))}ko.shouldUseRule=Pm});var ws=P(_t=>{"use strict";Object.defineProperty(_t,"__esModule",{value:true});_t.reportTypeError=_t.checkDataTypes=_t.checkDataType=_t.coerceAndCheckDataType=_t.getJSONTypes=_t.getSchemaTypes=_t.DataType=void 0;var OS=Il();var PS=bl();var AS=bs();var L=K();var Am=ce();var hi;(function(e){e[e["Correct"]=0]="Correct";e[e["Wrong"]=1]="Wrong"})(hi||(_t.DataType=hi={}));function kS(e){const t=km(e.type);const r=t.includes("null");if(r){if(e.nullable===false)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"')}if(e.nullable===true)t.push("null")}return t}_t.getSchemaTypes=kS;function km(e){const t=Array.isArray(e)?e:e?[e]:[];if(t.every(OS.isJSONType))return t;throw new Error("type must be JSONType or JSONType[]: "+t.join(","))}_t.getJSONTypes=km;function ES(e,t){const{gen:r,data:o,opts:n}=e;const i=$S(t,n.coerceTypes);const s=t.length>0&&!(i.length===0&&t.length===1&&(0,PS.schemaHasRulesForType)(e,t[0]));if(s){const a=Tl(t,o,n.strictNumbers,hi.Wrong);r.if(a,()=>{if(i.length)vS(e,t,i);else Sl(e)})}return s}_t.coerceAndCheckDataType=ES;var Em=new Set(["string","number","integer","boolean","null"]);function $S(e,t){return t?e.filter(r=>Em.has(r)||t==="array"&&r==="array"):[]}function vS(e,t,r){const{gen:o,data:n,opts:i}=e;const s=o.let("dataType",(0,L._)`typeof ${n}`);const a=o.let("coerced",(0,L._)`undefined`);if(i.coerceTypes==="array"){o.if((0,L._)`${s} == 'object' && Array.isArray(${n}) && ${n}.length == 1`,()=>o.assign(n,(0,L._)`${n}[0]`).assign(s,(0,L._)`typeof ${n}`).if(Tl(t,n,i.strictNumbers),()=>o.assign(a,n)))}o.if((0,L._)`${a} !== undefined`);for(const l of r){if(Em.has(l)||l==="array"&&i.coerceTypes==="array"){c(l)}}o.else();Sl(e);o.endIf();o.if((0,L._)`${a} !== undefined`,()=>{o.assign(n,a);CS(e,a)});function c(l){switch(l){case"string":o.elseIf((0,L._)`${s} == "number" || ${s} == "boolean"`).assign(a,(0,L._)`"" + ${n}`).elseIf((0,L._)`${n} === null`).assign(a,(0,L._)`""`);return;case"number":o.elseIf((0,L._)`${s} == "boolean" || ${n} === null
|
|
3
|
-
|| (${s} == "string" && ${n} && ${n} == +${n})`).assign(a,(0,L._)`+${n}`);return;case"integer":o.elseIf((0,L._)`${s} === "boolean" || ${n} === null
|
|
4
|
-
|| (${s} === "string" && ${n} && ${n} == +${n} && !(${n} % 1))`).assign(a,(0,L._)`+${n}`);return;case"boolean":o.elseIf((0,L._)`${n} === "false" || ${n} === 0 || ${n} === null`).assign(a,false).elseIf((0,L._)`${n} === "true" || ${n} === 1`).assign(a,true);return;case"null":o.elseIf((0,L._)`${n} === "" || ${n} === 0 || ${n} === false`);o.assign(a,null);return;case"array":o.elseIf((0,L._)`${s} === "string" || ${s} === "number"
|
|
5
|
-
|| ${s} === "boolean" || ${n} === null`).assign(a,(0,L._)`[${n}]`)}}}function CS({gen:e,parentData:t,parentDataProperty:r},o){e.if((0,L._)`${t} !== undefined`,()=>e.assign((0,L._)`${t}[${r}]`,o))}function wl(e,t,r,o=hi.Correct){const n=o===hi.Correct?L.operators.EQ:L.operators.NEQ;let i;switch(e){case"null":return(0,L._)`${t} ${n} null`;case"array":i=(0,L._)`Array.isArray(${t})`;break;case"object":i=(0,L._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case"integer":i=s((0,L._)`!(${t} % 1) && !isNaN(${t})`);break;case"number":i=s();break;default:return(0,L._)`typeof ${t} ${n} ${e}`}return o===hi.Correct?i:(0,L.not)(i);function s(a=L.nil){return(0,L.and)((0,L._)`typeof ${t} == "number"`,a,r?(0,L._)`isFinite(${t})`:L.nil)}}_t.checkDataType=wl;function Tl(e,t,r,o){if(e.length===1){return wl(e[0],t,r,o)}let n;const i=(0,Am.toHash)(e);if(i.array&&i.object){const s=(0,L._)`typeof ${t} != "object"`;n=i.null?s:(0,L._)`!${t} || ${s}`;delete i.null;delete i.array;delete i.object}else{n=L.nil}if(i.number)delete i.integer;for(const s in i)n=(0,L.and)(n,wl(s,t,r,o));return n}_t.checkDataTypes=Tl;var FS={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e=="string"?(0,L._)`{type: ${e}}`:(0,L._)`{type: ${t}}`};function Sl(e){const t=NS(e);(0,AS.reportError)(t,FS)}_t.reportTypeError=Sl;function NS(e){const{gen:t,data:r,schema:o}=e;const n=(0,Am.schemaRefOrVal)(e,o,"type");return{gen:t,keyword:"type",data:r,schema:o.type,schemaCode:n,schemaValue:n,parentSchema:o,params:{},it:e}}});var vm=P(Ua=>{"use strict";Object.defineProperty(Ua,"__esModule",{value:true});Ua.assignDefaults=void 0;var gi=K();var jS=ce();function zS(e,t){const{properties:r,items:o}=e.schema;if(t==="object"&&r){for(const n in r){$m(e,n,r[n].default)}}else if(t==="array"&&Array.isArray(o)){o.forEach((n,i)=>$m(e,i,n.default))}}Ua.assignDefaults=zS;function $m(e,t,r){const{gen:o,compositeRule:n,data:i,opts:s}=e;if(r===void 0)return;const a=(0,gi._)`${i}${(0,gi.getProperty)(t)}`;if(n){(0,jS.checkStrictMode)(e,`default is ignored for: ${a}`);return}let c=(0,gi._)`${a} === undefined`;if(s.useDefaults==="empty"){c=(0,gi._)`${c} || ${a} === null || ${a} === ""`}o.if(c,(0,gi._)`${a} = ${(0,gi.stringify)(r)}`)}});var ur=P(Te=>{"use strict";Object.defineProperty(Te,"__esModule",{value:true});Te.validateUnion=Te.validateArray=Te.usePattern=Te.callValidateCode=Te.schemaProperties=Te.allSchemaProperties=Te.noPropertyInData=Te.propertyInData=Te.isOwnProperty=Te.hasPropFunc=Te.reportMissingProp=Te.checkMissingProp=Te.checkReportMissingProp=void 0;var Ae=K();var Ml=ce();var Eo=uo();var DS=ce();function US(e,t){const{gen:r,data:o,it:n}=e;r.if(Ol(r,o,t,n.opts.ownProperties),()=>{e.setParams({missingProperty:(0,Ae._)`${t}`},true);e.error()})}Te.checkReportMissingProp=US;function LS({gen:e,data:t,it:{opts:r}},o,n){return(0,Ae.or)(...o.map(i=>(0,Ae.and)(Ol(e,t,i,r.ownProperties),(0,Ae._)`${n} = ${i}`)))}Te.checkMissingProp=LS;function qS(e,t){e.setParams({missingProperty:t},true);e.error()}Te.reportMissingProp=qS;function Cm(e){return e.scopeValue("func",{ref:Object.prototype.hasOwnProperty,code:(0,Ae._)`Object.prototype.hasOwnProperty`})}Te.hasPropFunc=Cm;function Rl(e,t,r){return(0,Ae._)`${Cm(e)}.call(${t}, ${r})`}Te.isOwnProperty=Rl;function KS(e,t,r,o){const n=(0,Ae._)`${t}${(0,Ae.getProperty)(r)} !== undefined`;return o?(0,Ae._)`${n} && ${Rl(e,t,r)}`:n}Te.propertyInData=KS;function Ol(e,t,r,o){const n=(0,Ae._)`${t}${(0,Ae.getProperty)(r)} === undefined`;return o?(0,Ae.or)(n,(0,Ae.not)(Rl(e,t,r))):n}Te.noPropertyInData=Ol;function Fm(e){return e?Object.keys(e).filter(t=>t!=="__proto__"):[]}Te.allSchemaProperties=Fm;function GS(e,t){return Fm(t).filter(r=>!(0,Ml.alwaysValidSchema)(e,t[r]))}Te.schemaProperties=GS;function BS({schemaCode:e,data:t,it:{gen:r,topSchemaRef:o,schemaPath:n,errorPath:i},it:s},a,c,l){const u=l?(0,Ae._)`${e}, ${t}, ${o}${n}`:t;const d=[[Eo.default.instancePath,(0,Ae.strConcat)(Eo.default.instancePath,i)],[Eo.default.parentData,s.parentData],[Eo.default.parentDataProperty,s.parentDataProperty],[Eo.default.rootData,Eo.default.rootData]];if(s.opts.dynamicRef)d.push([Eo.default.dynamicAnchors,Eo.default.dynamicAnchors]);const x=(0,Ae._)`${u}, ${r.object(...d)}`;return c!==Ae.nil?(0,Ae._)`${a}.call(${c}, ${x})`:(0,Ae._)`${a}(${x})`}Te.callValidateCode=BS;var VS=(0,Ae._)`new RegExp`;function HS({gen:e,it:{opts:t}},r){const o=t.unicodeRegExp?"u":"";const{regExp:n}=t.code;const i=n(r,o);return e.scopeValue("pattern",{key:i.toString(),ref:i,code:(0,Ae._)`${n.code==="new RegExp"?VS:(0,DS.useFunc)(e,n)}(${r}, ${o})`})}Te.usePattern=HS;function WS(e){const{gen:t,data:r,keyword:o,it:n}=e;const i=t.name("valid");if(n.allErrors){const a=t.let("valid",true);s(()=>t.assign(a,false));return a}t.var(i,true);s(()=>t.break());return i;function s(a){const c=t.const("len",(0,Ae._)`${r}.length`);t.forRange("i",0,c,l=>{e.subschema({keyword:o,dataProp:l,dataPropType:Ml.Type.Num},i);t.if((0,Ae.not)(i),a)})}}Te.validateArray=WS;function JS(e){const{gen:t,schema:r,keyword:o,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");const i=r.some(c=>(0,Ml.alwaysValidSchema)(n,c));if(i&&!n.opts.unevaluated)return;const s=t.let("valid",false);const a=t.name("_valid");t.block(()=>r.forEach((c,l)=>{const u=e.subschema({keyword:o,schemaProp:l,compositeRule:true},a);t.assign(s,(0,Ae._)`${s} || ${a}`);const d=e.mergeValidEvaluated(u,a);if(!d)t.if((0,Ae.not)(s))}));e.result(s,()=>e.reset(),()=>e.error(true))}Te.validateUnion=JS});var zm=P(Jr=>{"use strict";Object.defineProperty(Jr,"__esModule",{value:true});Jr.validateKeywordUsage=Jr.validSchemaType=Jr.funcKeywordCode=Jr.macroKeywordCode=void 0;var Pt=K();var Sn=uo();var XS=ur();var YS=bs();function QS(e,t){const{gen:r,keyword:o,schema:n,parentSchema:i,it:s}=e;const a=t.macro.call(s.self,n,i,s);const c=jm(r,o,a);if(s.opts.validateSchema!==false)s.self.validateSchema(a,true);const l=r.name("valid");e.subschema({schema:a,schemaPath:Pt.nil,errSchemaPath:`${s.errSchemaPath}/${o}`,topSchemaRef:c,compositeRule:true},l);e.pass(l,()=>e.error(true))}Jr.macroKeywordCode=QS;function ZS(e,t){var r;const{gen:o,keyword:n,schema:i,parentSchema:s,$data:a,it:c}=e;t0(c,t);const l=!a&&t.compile?t.compile.call(c.self,i,s,c):t.validate;const u=jm(o,n,l);const d=o.let("valid");e.block$data(d,x);e.ok((r=t.valid)!==null&&r!==void 0?r:d);function x(){if(t.errors===false){f();if(t.modifying)Nm(e);h(()=>e.error())}else{const _=t.async?y():m();if(t.modifying)Nm(e);h(()=>e0(e,_))}}function y(){const _=o.let("ruleErrs",null);o.try(()=>f((0,Pt._)`await `),I=>o.assign(d,false).if((0,Pt._)`${I} instanceof ${c.ValidationError}`,()=>o.assign(_,(0,Pt._)`${I}.errors`),()=>o.throw(I)));return _}function m(){const _=(0,Pt._)`${u}.errors`;o.assign(_,null);f(Pt.nil);return _}function f(_=t.async?(0,Pt._)`await `:Pt.nil){const I=c.opts.passContext?Sn.default.this:Sn.default.self;const R=!("compile"in t&&!a||t.schema===false);o.assign(d,(0,Pt._)`${_}${(0,XS.callValidateCode)(e,u,I,R)}`,t.modifying)}function h(_){var I;o.if((0,Pt.not)((I=t.valid)!==null&&I!==void 0?I:d),_)}}Jr.funcKeywordCode=ZS;function Nm(e){const{gen:t,data:r,it:o}=e;t.if(o.parentData,()=>t.assign(r,(0,Pt._)`${o.parentData}[${o.parentDataProperty}]`))}function e0(e,t){const{gen:r}=e;r.if((0,Pt._)`Array.isArray(${t})`,()=>{r.assign(Sn.default.vErrors,(0,Pt._)`${Sn.default.vErrors} === null ? ${t} : ${Sn.default.vErrors}.concat(${t})`).assign(Sn.default.errors,(0,Pt._)`${Sn.default.vErrors}.length`);(0,YS.extendErrors)(e)},()=>e.error())}function t0({schemaEnv:e},t){if(t.async&&!e.$async)throw new Error("async keyword in sync schema")}function jm(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,Pt.stringify)(r)})}function r0(e,t,r=false){return!t.length||t.some(o=>o==="array"?Array.isArray(e):o==="object"?e&&typeof e=="object"&&!Array.isArray(e):typeof e==o||r&&typeof e=="undefined")}Jr.validSchemaType=r0;function o0({schema:e,opts:t,self:r,errSchemaPath:o},n,i){if(Array.isArray(n.keyword)?!n.keyword.includes(i):n.keyword!==i){throw new Error("ajv implementation error")}const s=n.dependencies;if(s===null||s===void 0?void 0:s.some(a=>!Object.prototype.hasOwnProperty.call(e,a))){throw new Error(`parent schema must have dependencies of ${i}: ${s.join(",")}`)}if(n.validateSchema){const a=n.validateSchema(e[i]);if(!a){const c=`keyword "${i}" value is invalid at path "${o}": `+r.errorsText(n.validateSchema.errors);if(t.validateSchema==="log")r.logger.error(c);else throw new Error(c)}}}Jr.validateKeywordUsage=o0});var Um=P($o=>{"use strict";Object.defineProperty($o,"__esModule",{value:true});$o.extendSubschemaMode=$o.extendSubschemaData=$o.getSubschema=void 0;var Xr=K();var Dm=ce();function n0(e,{keyword:t,schemaProp:r,schema:o,schemaPath:n,errSchemaPath:i,topSchemaRef:s}){if(t!==void 0&&o!==void 0){throw new Error('both "keyword" and "schema" passed, only one allowed')}if(t!==void 0){const a=e.schema[t];return r===void 0?{schema:a,schemaPath:(0,Xr._)`${e.schemaPath}${(0,Xr.getProperty)(t)}`,errSchemaPath:`${e.errSchemaPath}/${t}`}:{schema:a[r],schemaPath:(0,Xr._)`${e.schemaPath}${(0,Xr.getProperty)(t)}${(0,Xr.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${t}/${(0,Dm.escapeFragment)(r)}`}}if(o!==void 0){if(n===void 0||i===void 0||s===void 0){throw new Error('"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"')}return{schema:o,schemaPath:n,topSchemaRef:s,errSchemaPath:i}}throw new Error('either "keyword" or "schema" must be passed')}$o.getSubschema=n0;function i0(e,t,{dataProp:r,dataPropType:o,data:n,dataTypes:i,propertyName:s}){if(n!==void 0&&r!==void 0){throw new Error('both "data" and "dataProp" passed, only one allowed')}const{gen:a}=t;if(r!==void 0){const{errorPath:l,dataPathArr:u,opts:d}=t;const x=a.let("data",(0,Xr._)`${t.data}${(0,Xr.getProperty)(r)}`,true);c(x);e.errorPath=(0,Xr.str)`${l}${(0,Dm.getErrorPath)(r,o,d.jsPropertySyntax)}`;e.parentDataProperty=(0,Xr._)`${r}`;e.dataPathArr=[...u,e.parentDataProperty]}if(n!==void 0){const l=n instanceof Xr.Name?n:a.let("data",n,true);c(l);if(s!==void 0)e.propertyName=s}if(i)e.dataTypes=i;function c(l){e.data=l;e.dataLevel=t.dataLevel+1;e.dataTypes=[];t.definedProperties=new Set;e.parentData=t.data;e.dataNames=[...t.dataNames,l]}}$o.extendSubschemaData=i0;function s0(e,{jtdDiscriminator:t,jtdMetadata:r,compositeRule:o,createErrors:n,allErrors:i}){if(o!==void 0)e.compositeRule=o;if(n!==void 0)e.createErrors=n;if(i!==void 0)e.allErrors=i;e.jtdDiscriminator=t;e.jtdMetadata=r}$o.extendSubschemaMode=s0});var Pl=P((EL,Lm)=>{"use strict";Lm.exports=function e(t,r){if(t===r)return true;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return false;var o,n,i;if(Array.isArray(t)){o=t.length;if(o!=r.length)return false;for(n=o;n--!==0;)if(!e(t[n],r[n]))return false;return true}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();i=Object.keys(t);o=i.length;if(o!==Object.keys(r).length)return false;for(n=o;n--!==0;)if(!Object.prototype.hasOwnProperty.call(r,i[n]))return false;for(n=o;n--!==0;){var s=i[n];if(!e(t[s],r[s]))return false}return true}return t!==t&&r!==r}});var Km=P(($L,qm)=>{"use strict";var vo=qm.exports=function(e,t,r){if(typeof t=="function"){r=t;t={}}r=t.cb||r;var o=typeof r=="function"?r:r.pre||function(){};var n=r.post||function(){};La(t,o,n,e,"",e)};vo.keywords={additionalItems:true,items:true,contains:true,additionalProperties:true,propertyNames:true,not:true,if:true,then:true,else:true};vo.arrayKeywords={items:true,allOf:true,anyOf:true,oneOf:true};vo.propsKeywords={$defs:true,definitions:true,properties:true,patternProperties:true,dependencies:true};vo.skipKeywords={default:true,enum:true,const:true,required:true,maximum:true,minimum:true,exclusiveMaximum:true,exclusiveMinimum:true,multipleOf:true,maxLength:true,minLength:true,pattern:true,format:true,maxItems:true,minItems:true,uniqueItems:true,maxProperties:true,minProperties:true};function La(e,t,r,o,n,i,s,a,c,l){if(o&&typeof o=="object"&&!Array.isArray(o)){t(o,n,i,s,a,c,l);for(var u in o){var d=o[u];if(Array.isArray(d)){if(u in vo.arrayKeywords){for(var x=0;x<d.length;x++)La(e,t,r,d[x],n+"/"+u+"/"+x,i,n,u,o,x)}}else if(u in vo.propsKeywords){if(d&&typeof d=="object"){for(var y in d)La(e,t,r,d[y],n+"/"+u+"/"+a0(y),i,n,u,o,y)}}else if(u in vo.keywords||e.allKeys&&!(u in vo.skipKeywords)){La(e,t,r,d,n+"/"+u,i,n,u,o)}}r(o,n,i,s,a,c,l)}}function a0(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}});var Ts=P(Ft=>{"use strict";Object.defineProperty(Ft,"__esModule",{value:true});Ft.getSchemaRefs=Ft.resolveUrl=Ft.normalizeId=Ft._getFullPath=Ft.getFullPath=Ft.inlineRef=void 0;var c0=ce();var u0=Pl();var l0=Km();var d0=new Set(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum","const"]);function p0(e,t=true){if(typeof e=="boolean")return true;if(t===true)return!Al(e);if(!t)return false;return Gm(e)<=t}Ft.inlineRef=p0;var f0=new Set(["$ref","$recursiveRef","$recursiveAnchor","$dynamicRef","$dynamicAnchor"]);function Al(e){for(const t in e){if(f0.has(t))return true;const r=e[t];if(Array.isArray(r)&&r.some(Al))return true;if(typeof r=="object"&&Al(r))return true}return false}function Gm(e){let t=0;for(const r in e){if(r==="$ref")return Infinity;t++;if(d0.has(r))continue;if(typeof e[r]=="object"){(0,c0.eachItem)(e[r],o=>t+=Gm(o))}if(t===Infinity)return Infinity}return t}function Bm(e,t="",r){if(r!==false)t=yi(t);const o=e.parse(t);return Vm(e,o)}Ft.getFullPath=Bm;function Vm(e,t){const r=e.serialize(t);return r.split("#")[0]+"#"}Ft._getFullPath=Vm;var m0=/#\/?$/;function yi(e){return e?e.replace(m0,""):""}Ft.normalizeId=yi;function h0(e,t,r){r=yi(r);return e.resolve(t,r)}Ft.resolveUrl=h0;var g0=/^[a-z_][-a-z0-9._]*$/i;function y0(e,t){if(typeof e=="boolean")return{};const{schemaId:r,uriResolver:o}=this.opts;const n=yi(e[r]||t);const i={"":n};const s=Bm(o,n,false);const a={};const c=new Set;l0(e,{allKeys:true},(d,x,y,m)=>{if(m===void 0)return;const f=s+x;let h=i[m];if(typeof d[r]=="string")h=_.call(this,d[r]);I.call(this,d.$anchor);I.call(this,d.$dynamicAnchor);i[x]=h;function _(R){const C=this.opts.uriResolver.resolve;R=yi(h?C(h,R):R);if(c.has(R))throw u(R);c.add(R);let k=this.refs[R];if(typeof k=="string")k=this.refs[k];if(typeof k=="object"){l(d,k.schema,R)}else if(R!==yi(f)){if(R[0]==="#"){l(d,a[R],R);a[R]=d}else{this.refs[R]=f}}return R}function I(R){if(typeof R=="string"){if(!g0.test(R))throw new Error(`invalid anchor "${R}"`);_.call(this,`#${R}`)}}});return a;function l(d,x,y){if(x!==void 0&&!u0(d,x))throw u(y)}function u(d){return new Error(`reference "${d}" resolves to more than one schema`)}}Ft.getSchemaRefs=y0});var Rs=P(Co=>{"use strict";Object.defineProperty(Co,"__esModule",{value:true});Co.getData=Co.KeywordCxt=Co.validateFunctionCode=void 0;var Ym=Rm();var Hm=ws();var El=bl();var qa=ws();var x0=vm();var Ms=zm();var kl=Um();var v=K();var z=uo();var _0=Ts();var lo=ce();var Ss=bs();function I0(e){if(eh(e)){th(e);if(Zm(e)){T0(e);return}}Qm(e,()=>(0,Ym.topBoolOrEmptySchema)(e))}Co.validateFunctionCode=I0;function Qm({gen:e,validateName:t,schema:r,schemaEnv:o,opts:n},i){if(n.code.es5){e.func(t,(0,v._)`${z.default.data}, ${z.default.valCxt}`,o.$async,()=>{e.code((0,v._)`"use strict"; ${Wm(r,n)}`);w0(e,n);e.code(i)})}else{e.func(t,(0,v._)`${z.default.data}, ${b0(n)}`,o.$async,()=>e.code(Wm(r,n)).code(i))}}function b0(e){return(0,v._)`{${z.default.instancePath}="", ${z.default.parentData}, ${z.default.parentDataProperty}, ${z.default.rootData}=${z.default.data}${e.dynamicRef?(0,v._)`, ${z.default.dynamicAnchors}={}`:v.nil}}={}`}function w0(e,t){e.if(z.default.valCxt,()=>{e.var(z.default.instancePath,(0,v._)`${z.default.valCxt}.${z.default.instancePath}`);e.var(z.default.parentData,(0,v._)`${z.default.valCxt}.${z.default.parentData}`);e.var(z.default.parentDataProperty,(0,v._)`${z.default.valCxt}.${z.default.parentDataProperty}`);e.var(z.default.rootData,(0,v._)`${z.default.valCxt}.${z.default.rootData}`);if(t.dynamicRef)e.var(z.default.dynamicAnchors,(0,v._)`${z.default.valCxt}.${z.default.dynamicAnchors}`)},()=>{e.var(z.default.instancePath,(0,v._)`""`);e.var(z.default.parentData,(0,v._)`undefined`);e.var(z.default.parentDataProperty,(0,v._)`undefined`);e.var(z.default.rootData,z.default.data);if(t.dynamicRef)e.var(z.default.dynamicAnchors,(0,v._)`{}`)})}function T0(e){const{schema:t,opts:r,gen:o}=e;Qm(e,()=>{if(r.$comment&&t.$comment)oh(e);P0(e);o.let(z.default.vErrors,null);o.let(z.default.errors,0);if(r.unevaluated)S0(e);rh(e);E0(e)});return}function S0(e){const{gen:t,validateName:r}=e;e.evaluated=t.const("evaluated",(0,v._)`${r}.evaluated`);t.if((0,v._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,v._)`${e.evaluated}.props`,(0,v._)`undefined`));t.if((0,v._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,v._)`${e.evaluated}.items`,(0,v._)`undefined`))}function Wm(e,t){const r=typeof e=="object"&&e[t.schemaId];return r&&(t.code.source||t.code.process)?(0,v._)`/*# sourceURL=${r} */`:v.nil}function M0(e,t){if(eh(e)){th(e);if(Zm(e)){R0(e,t);return}}(0,Ym.boolOrEmptySchema)(e,t)}function Zm({schema:e,self:t}){if(typeof e=="boolean")return!e;for(const r in e)if(t.RULES.all[r])return true;return false}function eh(e){return typeof e.schema!="boolean"}function R0(e,t){const{schema:r,gen:o,opts:n}=e;if(n.$comment&&r.$comment)oh(e);A0(e);k0(e);const i=o.const("_errs",z.default.errors);rh(e,i);o.var(t,(0,v._)`${i} === ${z.default.errors}`)}function th(e){(0,lo.checkUnknownRules)(e);O0(e)}function rh(e,t){if(e.opts.jtd)return Jm(e,[],false,t);const r=(0,Hm.getSchemaTypes)(e.schema);const o=(0,Hm.coerceAndCheckDataType)(e,r);Jm(e,r,!o,t)}function O0(e){const{schema:t,errSchemaPath:r,opts:o,self:n}=e;if(t.$ref&&o.ignoreKeywordsWithRef&&(0,lo.schemaHasRulesButRef)(t,n.RULES)){n.logger.warn(`$ref: keywords ignored in schema at path "${r}"`)}}function P0(e){const{schema:t,opts:r}=e;if(t.default!==void 0&&r.useDefaults&&r.strictSchema){(0,lo.checkStrictMode)(e,"default is ignored in the schema root")}}function A0(e){const t=e.schema[e.opts.schemaId];if(t)e.baseId=(0,_0.resolveUrl)(e.opts.uriResolver,e.baseId,t)}function k0(e){if(e.schema.$async&&!e.schemaEnv.$async)throw new Error("async schema in sync schema")}function oh({gen:e,schemaEnv:t,schema:r,errSchemaPath:o,opts:n}){const i=r.$comment;if(n.$comment===true){e.code((0,v._)`${z.default.self}.logger.log(${i})`)}else if(typeof n.$comment=="function"){const s=(0,v.str)`${o}/$comment`;const a=e.scopeValue("root",{ref:t.root});e.code((0,v._)`${z.default.self}.opts.$comment(${i}, ${s}, ${a}.schema)`)}}function E0(e){const{gen:t,schemaEnv:r,validateName:o,ValidationError:n,opts:i}=e;if(r.$async){t.if((0,v._)`${z.default.errors} === 0`,()=>t.return(z.default.data),()=>t.throw((0,v._)`new ${n}(${z.default.vErrors})`))}else{t.assign((0,v._)`${o}.errors`,z.default.vErrors);if(i.unevaluated)$0(e);t.return((0,v._)`${z.default.errors} === 0`)}}function $0({gen:e,evaluated:t,props:r,items:o}){if(r instanceof v.Name)e.assign((0,v._)`${t}.props`,r);if(o instanceof v.Name)e.assign((0,v._)`${t}.items`,o)}function Jm(e,t,r,o){const{gen:n,schema:i,data:s,allErrors:a,opts:c,self:l}=e;const{RULES:u}=l;if(i.$ref&&(c.ignoreKeywordsWithRef||!(0,lo.schemaHasRulesButRef)(i,u))){n.block(()=>ih(e,"$ref",u.all.$ref.definition));return}if(!c.jtd)v0(e,t);n.block(()=>{for(const x of u.rules)d(x);d(u.post)});function d(x){if(!(0,El.shouldUseGroup)(i,x))return;if(x.type){n.if((0,qa.checkDataType)(x.type,s,c.strictNumbers));Xm(e,x);if(t.length===1&&t[0]===x.type&&r){n.else();(0,qa.reportTypeError)(e)}n.endIf()}else{Xm(e,x)}if(!a)n.if((0,v._)`${z.default.errors} === ${o||0}`)}}function Xm(e,t){const{gen:r,schema:o,opts:{useDefaults:n}}=e;if(n)(0,x0.assignDefaults)(e,t.type);r.block(()=>{for(const i of t.rules){if((0,El.shouldUseRule)(o,i)){ih(e,i.keyword,i.definition,t.type)}}})}function v0(e,t){if(e.schemaEnv.meta||!e.opts.strictTypes)return;C0(e,t);if(!e.opts.allowUnionTypes)F0(e,t);N0(e,e.dataTypes)}function C0(e,t){if(!t.length)return;if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(r=>{if(!nh(e.dataTypes,r)){$l(e,`type "${r}" not allowed by context "${e.dataTypes.join(",")}"`)}});z0(e,t)}function F0(e,t){if(t.length>1&&!(t.length===2&&t.includes("null"))){$l(e,"use allowUnionTypes to allow union type keyword")}}function N0(e,t){const r=e.self.RULES.all;for(const o in r){const n=r[o];if(typeof n=="object"&&(0,El.shouldUseRule)(e.schema,n)){const{type:i}=n.definition;if(i.length&&!i.some(s=>j0(t,s))){$l(e,`missing type "${i.join(",")}" for keyword "${o}"`)}}}}function j0(e,t){return e.includes(t)||t==="number"&&e.includes("integer")}function nh(e,t){return e.includes(t)||t==="integer"&&e.includes("number")}function z0(e,t){const r=[];for(const o of e.dataTypes){if(nh(t,o))r.push(o);else if(t.includes("integer")&&o==="number")r.push("integer")}e.dataTypes=r}function $l(e,t){const r=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${r}" (strictTypes)`;(0,lo.checkStrictMode)(e,t,e.opts.strictTypes)}var Ka=class{constructor(t,r,o){(0,Ms.validateKeywordUsage)(t,r,o);this.gen=t.gen;this.allErrors=t.allErrors;this.keyword=o;this.data=t.data;this.schema=t.schema[o];this.$data=r.$data&&t.opts.$data&&this.schema&&this.schema.$data;this.schemaValue=(0,lo.schemaRefOrVal)(t,this.schema,o,this.$data);this.schemaType=r.schemaType;this.parentSchema=t.schema;this.params={};this.it=t;this.def=r;if(this.$data){this.schemaCode=t.gen.const("vSchema",sh(this.$data,t))}else{this.schemaCode=this.schemaValue;if(!(0,Ms.validSchemaType)(this.schema,r.schemaType,r.allowUndefined)){throw new Error(`${o} value must be ${JSON.stringify(r.schemaType)}`)}}if("code"in r?r.trackErrors:r.errors!==false){this.errsCount=t.gen.const("_errs",z.default.errors)}}result(t,r,o){this.failResult((0,v.not)(t),r,o)}failResult(t,r,o){this.gen.if(t);if(o)o();else this.error();if(r){this.gen.else();r();if(this.allErrors)this.gen.endIf()}else{if(this.allErrors)this.gen.endIf();else this.gen.else()}}pass(t,r){this.failResult((0,v.not)(t),void 0,r)}fail(t){if(t===void 0){this.error();if(!this.allErrors)this.gen.if(false);return}this.gen.if(t);this.error();if(this.allErrors)this.gen.endIf();else this.gen.else()}fail$data(t){if(!this.$data)return this.fail(t);const{schemaCode:r}=this;this.fail((0,v._)`${r} !== undefined && (${(0,v.or)(this.invalid$data(),t)})`)}error(t,r,o){if(r){this.setParams(r);this._error(t,o);this.setParams({});return}this._error(t,o)}_error(t,r){;(t?Ss.reportExtraError:Ss.reportError)(this,this.def.error,r)}$dataError(){(0,Ss.reportError)(this,this.def.$dataError||Ss.keyword$DataError)}reset(){if(this.errsCount===void 0)throw new Error('add "trackErrors" to keyword definition');(0,Ss.resetErrorsCount)(this.gen,this.errsCount)}ok(t){if(!this.allErrors)this.gen.if(t)}setParams(t,r){if(r)Object.assign(this.params,t);else this.params=t}block$data(t,r,o=v.nil){this.gen.block(()=>{this.check$data(t,o);r()})}check$data(t=v.nil,r=v.nil){if(!this.$data)return;const{gen:o,schemaCode:n,schemaType:i,def:s}=this;o.if((0,v.or)((0,v._)`${n} === undefined`,r));if(t!==v.nil)o.assign(t,true);if(i.length||s.validateSchema){o.elseIf(this.invalid$data());this.$dataError();if(t!==v.nil)o.assign(t,false)}o.else()}invalid$data(){const{gen:t,schemaCode:r,schemaType:o,def:n,it:i}=this;return(0,v.or)(s(),a());function s(){if(o.length){if(!(r instanceof v.Name))throw new Error("ajv implementation error");const c=Array.isArray(o)?o:[o];return(0,v._)`${(0,qa.checkDataTypes)(c,r,i.opts.strictNumbers,qa.DataType.Wrong)}`}return v.nil}function a(){if(n.validateSchema){const c=t.scopeValue("validate$data",{ref:n.validateSchema});return(0,v._)`!${c}(${r})`}return v.nil}}subschema(t,r){const o=(0,kl.getSubschema)(this.it,t);(0,kl.extendSubschemaData)(o,this.it,t);(0,kl.extendSubschemaMode)(o,t);const n={...this.it,...o,items:void 0,props:void 0};M0(n,r);return n}mergeEvaluated(t,r){const{it:o,gen:n}=this;if(!o.opts.unevaluated)return;if(o.props!==true&&t.props!==void 0){o.props=lo.mergeEvaluated.props(n,t.props,o.props,r)}if(o.items!==true&&t.items!==void 0){o.items=lo.mergeEvaluated.items(n,t.items,o.items,r)}}mergeValidEvaluated(t,r){const{it:o,gen:n}=this;if(o.opts.unevaluated&&(o.props!==true||o.items!==true)){n.if(r,()=>this.mergeEvaluated(t,v.Name));return true}}};Co.KeywordCxt=Ka;function ih(e,t,r,o){const n=new Ka(e,r,t);if("code"in r){r.code(n,o)}else if(n.$data&&r.validate){(0,Ms.funcKeywordCode)(n,r)}else if("macro"in r){(0,Ms.macroKeywordCode)(n,r)}else if(r.compile||r.validate){(0,Ms.funcKeywordCode)(n,r)}}var D0=/^\/(?:[^~]|~0|~1)*$/;var U0=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function sh(e,{dataLevel:t,dataNames:r,dataPathArr:o}){let n;let i;if(e==="")return z.default.rootData;if(e[0]==="/"){if(!D0.test(e))throw new Error(`Invalid JSON-pointer: ${e}`);n=e;i=z.default.rootData}else{const l=U0.exec(e);if(!l)throw new Error(`Invalid JSON-pointer: ${e}`);const u=+l[1];n=l[2];if(n==="#"){if(u>=t)throw new Error(c("property/index",u));return o[t-u]}if(u>t)throw new Error(c("data",u));i=r[t-u];if(!n)return i}let s=i;const a=n.split("/");for(const l of a){if(l){i=(0,v._)`${i}${(0,v.getProperty)((0,lo.unescapeJsonPointer)(l))}`;s=(0,v._)`${s} && ${i}`}}return s;function c(l,u){return`Cannot access ${l} ${u} levels up, current level is ${t}`}}Co.getData=sh});var Ga=P(Cl=>{"use strict";Object.defineProperty(Cl,"__esModule",{value:true});var vl=class extends Error{constructor(t){super("validation failed");this.errors=t;this.ajv=this.validation=true}};Cl.default=vl});var Os=P(jl=>{"use strict";Object.defineProperty(jl,"__esModule",{value:true});var Fl=Ts();var Nl=class extends Error{constructor(t,r,o,n){super(n||`can't resolve reference ${o} from id ${r}`);this.missingRef=(0,Fl.resolveUrl)(t,r,o);this.missingSchema=(0,Fl.normalizeId)((0,Fl.getFullPath)(t,this.missingRef))}};jl.default=Nl});var Va=P(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:true});lr.resolveSchema=lr.getCompilingSchema=lr.resolveRef=lr.compileSchema=lr.SchemaEnv=void 0;var wr=K();var L0=Ga();var Mn=uo();var Tr=Ts();var ah=ce();var q0=Rs();var xi=class{constructor(t){var r;this.refs={};this.dynamicAnchors={};let o;if(typeof t.schema=="object")o=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,Tr.normalizeId)(o===null||o===void 0?void 0:o[t.schemaId||"$id"]);this.schemaPath=t.schemaPath;this.localRefs=t.localRefs;this.meta=t.meta;this.$async=o===null||o===void 0?void 0:o.$async;this.refs={}}};lr.SchemaEnv=xi;function Dl(e){const t=ch.call(this,e);if(t)return t;const r=(0,Tr.getFullPath)(this.opts.uriResolver,e.root.baseId);const{es5:o,lines:n}=this.opts.code;const{ownProperties:i}=this.opts;const s=new wr.CodeGen(this.scope,{es5:o,lines:n,ownProperties:i});let a;if(e.$async){a=s.scopeValue("Error",{ref:L0.default,code:(0,wr._)`require("ajv/dist/runtime/validation_error").default`})}const c=s.scopeName("validate");e.validateName=c;const l={gen:s,allErrors:this.opts.allErrors,data:Mn.default.data,parentData:Mn.default.parentData,parentDataProperty:Mn.default.parentDataProperty,dataNames:[Mn.default.data],dataPathArr:[wr.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:s.scopeValue("schema",this.opts.code.source===true?{ref:e.schema,code:(0,wr.stringify)(e.schema)}:{ref:e.schema}),validateName:c,ValidationError:a,schema:e.schema,schemaEnv:e,rootId:r,baseId:e.baseId||r,schemaPath:wr.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?"":"#"),errorPath:(0,wr._)`""`,opts:this.opts,self:this};let u;try{this._compilations.add(e);(0,q0.validateFunctionCode)(l);s.optimize(this.opts.code.optimize);const d=s.toString();u=`${s.scopeRefs(Mn.default.scope)}return ${d}`;if(this.opts.code.process)u=this.opts.code.process(u,e);const x=new Function(`${Mn.default.self}`,`${Mn.default.scope}`,u);const y=x(this,this.scope.get());this.scope.value(c,{ref:y});y.errors=null;y.schema=e.schema;y.schemaEnv=e;if(e.$async)y.$async=true;if(this.opts.code.source===true){y.source={validateName:c,validateCode:d,scopeValues:s._values}}if(this.opts.unevaluated){const{props:m,items:f}=l;y.evaluated={props:m instanceof wr.Name?void 0:m,items:f instanceof wr.Name?void 0:f,dynamicProps:m instanceof wr.Name,dynamicItems:f instanceof wr.Name};if(y.source)y.source.evaluated=(0,wr.stringify)(y.evaluated)}e.validate=y;return e}catch(d){delete e.validate;delete e.validateName;if(u)this.logger.error("Error compiling schema, function code:",u);throw d}finally{this._compilations.delete(e)}}lr.compileSchema=Dl;function K0(e,t,r){var o;r=(0,Tr.resolveUrl)(this.opts.uriResolver,t,r);const n=e.refs[r];if(n)return n;let i=V0.call(this,e,r);if(i===void 0){const s=(o=e.localRefs)===null||o===void 0?void 0:o[r];const{schemaId:a}=this.opts;if(s)i=new xi({schema:s,schemaId:a,root:e,baseId:t})}if(i===void 0)return;return e.refs[r]=G0.call(this,i)}lr.resolveRef=K0;function G0(e){if((0,Tr.inlineRef)(e.schema,this.opts.inlineRefs))return e.schema;return e.validate?e:Dl.call(this,e)}function ch(e){for(const t of this._compilations){if(B0(t,e))return t}}lr.getCompilingSchema=ch;function B0(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function V0(e,t){let r;while(typeof(r=this.refs[t])=="string")t=r;return r||this.schemas[t]||Ba.call(this,e,t)}function Ba(e,t){const r=this.opts.uriResolver.parse(t);const o=(0,Tr._getFullPath)(this.opts.uriResolver,r);let n=(0,Tr.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&o===n){return zl.call(this,r,e)}const i=(0,Tr.normalizeId)(o);const s=this.refs[i]||this.schemas[i];if(typeof s=="string"){const a=Ba.call(this,e,s);if(typeof(a===null||a===void 0?void 0:a.schema)!=="object")return;return zl.call(this,r,a)}if(typeof(s===null||s===void 0?void 0:s.schema)!=="object")return;if(!s.validate)Dl.call(this,s);if(i===(0,Tr.normalizeId)(t)){const{schema:a}=s;const{schemaId:c}=this.opts;const l=a[c];if(l)n=(0,Tr.resolveUrl)(this.opts.uriResolver,n,l);return new xi({schema:a,schemaId:c,root:e,baseId:n})}return zl.call(this,r,s)}lr.resolveSchema=Ba;var H0=new Set(["properties","patternProperties","enum","dependencies","definitions"]);function zl(e,{baseId:t,schema:r,root:o}){var n;if(((n=e.fragment)===null||n===void 0?void 0:n[0])!=="/")return;for(const a of e.fragment.slice(1).split("/")){if(typeof r==="boolean")return;const c=r[(0,ah.unescapeFragment)(a)];if(c===void 0)return;r=c;const l=typeof r==="object"&&r[this.opts.schemaId];if(!H0.has(a)&&l){t=(0,Tr.resolveUrl)(this.opts.uriResolver,t,l)}}let i;if(typeof r!="boolean"&&r.$ref&&!(0,ah.schemaHasRulesButRef)(r,this.RULES)){const a=(0,Tr.resolveUrl)(this.opts.uriResolver,t,r.$ref);i=Ba.call(this,o,a)}const{schemaId:s}=this.opts;i=i||new xi({schema:r,schemaId:s,root:o,baseId:t});if(i.schema!==i.root.schema)return i;return void 0}});var uh=P((zL,W0)=>{W0.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:false}});var Bl=P((DL,gh)=>{"use strict";var J0=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);var Ll=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);var Rn=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);var ql=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);var dh=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);var Kl=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);var X0=RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);var Nt=new Array(256);{const e="0123456789ABCDEF";for(let t=0;t<256;t++){Nt[t]="%"+e[t>>4]+e[t&15]}}function It(e){if(e<2048){return Nt[192|e>>6]+Nt[128|e&63]}if(e<65536){return Nt[224|e>>12]+Nt[128|e>>6&63]+Nt[128|e&63]}return Nt[240|e>>18]+Nt[128|e>>12&63]+Nt[128|e>>6&63]+Nt[128|e&63]}function Y0(e){let t="";let r=0;let o=0;for(o=0;o<e.length;o++){r=e[o].charCodeAt(0);if(r===48){continue}if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102)){return""}t+=e[o];break}for(o+=1;o<e.length;o++){r=e[o].charCodeAt(0);if(!(r>=48&&r<=57||r>=65&&r<=70||r>=97&&r<=102)){return""}t+=e[o]}return t}var Q0=RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);var Z0=RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);var eM=RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);var tM=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function rM(e){if(e.length===0)return false;for(let t=0;t<e.length;t++){if(eM(e[t]))continue;if(e[t]==="%"&&t+2<e.length&&Rn(e.slice(t+1,t+3))){t+=2;continue}return false}return true}function lh(e){let t=-1;let r=0;let o=-1;let n=0;for(let a=0;a<e.length;a++){if(e[a]==="0"){if(o===-1)o=a;n++;if(n>r){r=n;t=o}}else{o=-1;n=0}}if(r<2)return e.join(":");const i=e.slice(0,t).join(":");const s=e.slice(t+r).join(":");return i+"::"+s}function oM(e){const t=e.indexOf("::");if(t!==-1&&e.indexOf("::",t+1)!==-1)return void 0;const r=t===-1?e.split(":"):e.slice(0,t).split(":");const o=t===-1?[]:e.slice(t+2).split(":");if(t!==-1){if(r.length===1&&r[0]==="")r.length=0;if(o.length===1&&o[0]==="")o.length=0}const n=r.concat(o);let i=0;for(let a=0;a<n.length;a++){const c=n[a];if(c==="")return void 0;if(c.indexOf(".")!==-1){if(a!==n.length-1||t!==-1&&o.length===0||!Ll(c))return void 0;i+=2;continue}if(!Q0(c))return void 0;n[a]=parseInt(c,16).toString(16);i++}if(t===-1){if(i!==8)return void 0;return lh(n)}if(i>=8)return void 0;const s=n.slice(0,r.length);for(let a=i;a<8;a++)s.push("0");for(let a=r.length;a<n.length;a++)s.push(n[a]);return lh(s)}function Ul(e){const t=e[0]==="["&&e[e.length-1]==="]";const r=e[0]==="["||e[e.length-1]==="]";if(r&&!t)return{host:e,isIPV6:false,error:true};let o=t?e.slice(1,-1):e;if(t&&Z0(o)){o=o.toLowerCase();return{host:`[${o}]`,escapedHost:o,isIPV6:false,isIPVFuture:true}}if(nM(o,":")<2){return{host:e,isIPV6:false,error:t}}let n="";const i=o.indexOf("%");if(i!==-1){const a=o.slice(i,i+3).toLowerCase()==="%25"?3:1;n=o.slice(i+a);if(!rM(n))return{host:e,isIPV6:false,error:true};o=o.slice(0,i)}const s=oM(o);if(s===void 0)return{host:e,isIPV6:false,error:true};return{host:s+(n?"%"+n:""),escapedHost:s+(n?"%25"+n:""),isIPV6:true}}function nM(e,t){let r=0;for(let o=0;o<e.length;o++){if(e[o]===t)r++}return r}function iM(e){let t=e;const r=[];let o=-1;let n=0;while(n=t.length){if(n===1){if(t==="."){break}else if(t==="/"){r.push("/");break}else{r.push(t);break}}else if(n===2){if(t[0]==="."){if(t[1]==="."){break}else if(t[1]==="/"){t=t.slice(2);continue}}else if(t[0]==="/"){if(t[1]==="."||t[1]==="/"){r.push("/");break}}}else if(n===3){if(t==="/.."){if(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]==="/"){if(t[1]==="."){if(t[2]==="/"){t=t.slice(2);continue}else if(t[2]==="."){if(t[3]==="/"){t=t.slice(3);if(r.length!==0){r.pop()}continue}}}}if((o=t.indexOf("/",1))===-1){r.push(t);break}else{r.push(t.slice(0,o));t=t.slice(o)}}return r.join("")}var sM={"@":"%40","/":"%2F","?":"%3F","#":"%23",":":"%3A"};var aM=/[@/?#:]/g;var cM=/[@/?#]/g;function ph(e,t){const r=t?cM:aM;r.lastIndex=0;return e.replace(r,o=>sM[o])}function fh(e,t=false){if(e.indexOf("%")===-1){return e}let r="";for(let o=0;o<e.length;o++){if(e[o]==="%"&&o+2<e.length){const n=e.slice(o+1,o+3);if(Rn(n)){const i=n.toUpperCase();const s=String.fromCharCode(parseInt(i,16));if(t&&ql(s)){r+=s}else{r+="%"+i}o+=2;continue}}r+=e[o]}return r}function uM(e){let t="";for(let r=0;r<e.length;r++){const o=e[r];if(o==="%"&&r+2<e.length){const n=e.slice(r+1,r+3);if(Rn(n)){const i=n.toUpperCase();const s=String.fromCharCode(parseInt(i,16));if(s!=="."&&ql(s)){t+=s}else{t+="%"+i}r+=2;continue}}if(dh(o)){t+=o}else{const n=e.charCodeAt(r);if(n<128){t+=hh(n)?o:Nt[n]}else if(n<55296||n>57343){t+=It(n)}else if(n<=56319&&r+1<e.length){const i=e.charCodeAt(r+1);if(i>=56320&&i<=57343){t+=It(65536+(n-55296<<10)+(i-56320));r++}else{t+=It(65533)}}else{t+=It(65533)}}}return t}function lM(e,t=false){let r="";let o=t&&e[0]!=="/";for(let n=0;n<e.length;n++){const i=e[n];if(i==="%"&&n+2<e.length){const s=e.slice(n+1,n+3);if(Rn(s)){r+="%"+s.toUpperCase();n+=2;continue}}if(i==="/"){o=false}if(dh(i)&&(i!==":"||!o)){r+=i}else{const s=e.charCodeAt(n);if(s<128){r+=Nt[s]}else if(s<55296||s>57343){r+=It(s)}else if(s<=56319&&n+1<e.length){const a=e.charCodeAt(n+1);if(a>=56320&&a<=57343){r+=It(65536+(s-55296<<10)+(a-56320));n++}else{r+=It(65533)}}else{r+=It(65533)}}}return r}function Gl(e,t){let r="";for(let o=0;o<e.length;o++){const n=e[o];if(n==="%"&&o+2<e.length){const i=e.slice(o+1,o+3);if(Rn(i)){r+="%"+i.toUpperCase();o+=2;continue}}if(t(n)){r+=n}else{const i=e.charCodeAt(o);if(i<128){r+=Nt[i]}else if(i<55296||i>57343){r+=It(i)}else if(i<=56319&&o+1<e.length){const s=e.charCodeAt(o+1);if(s>=56320&&s<=57343){r+=It(65536+(i-55296<<10)+(s-56320));o++}else{r+=It(65533)}}else{r+=It(65533)}}}return r}function mh(e){return Gl(e,X0)}function dM(e){return Gl(e,Kl)}function pM(e){return Gl(e,Kl)}function hh(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 fM(e){let t="";for(let r=0;r<e.length;r++){const o=e[r];if(o==="%"&&r+2<e.length){const n=e.slice(r+1,r+3);if(Rn(n)){const i=n.toUpperCase();const s=String.fromCharCode(parseInt(i,16));if(ql(s)){t+=s}else{t+="%"+i}r+=2;continue}}if(Kl(o)){t+=o}else{const n=e.charCodeAt(r);if(n<128){t+=hh(n)?o:Nt[n]}else if(n<55296||n>57343){t+=It(n)}else if(n<=56319&&r+1<e.length){const i=e.charCodeAt(r+1);if(i>=56320&&i<=57343){t+=It(65536+(n-55296<<10)+(i-56320));r++}else{t+=It(65533)}}else{t+=It(65533)}}}return t}function mM(e){let t="";for(let r=0;r<e.length;r++){if(e[r]==="%"&&r+2<e.length){const o=e.slice(r+1,r+3);if(Rn(o)){t+="%"+o.toUpperCase();r+=2;continue}}t+=escape(e[r])}return t}function hM(e){const t=[];if(e.userinfo!==void 0){t.push(mh(e.userinfo));t.push("@")}if(e.host!==void 0){let r=e.host;if(!Ll(r)){let o=Ul(r);if(o.isIPV6!==true&&o.isIPVFuture!==true){r=fh(r,true);o=Ul(r)}if(o.isIPV6===true||o.isIPVFuture===true){r=`[${o.escapedHost}]`}else{r=ph(r,false)}}t.push(r)}if(typeof e.port==="number"||typeof e.port==="string"){t.push(":");t.push(String(e.port))}return t.length?t.join(""):void 0}gh.exports={nonSimpleDomain:tM,recomposeAuthority:hM,reescapeHostDelimiters:ph,normalizePercentEncoding:fh,normalizePathEncoding:uM,serializePathEncoding:lM,normalizeQueryFragmentEncoding:fM,encodeUserinfo:mh,encodeQuery:dM,encodeFragment:pM,escapePreservingEscapes:mM,removeDotSegments:iM,isIPv4:Ll,isUUID:J0,normalizeIPv6:Ul,stringArrayToHexStripped:Y0}});var bh=P((UL,Ih)=>{"use strict";var{isUUID:gM}=Bl();var yM=/^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;var xM=["http","https","ws","wss","urn","urn:uuid"];function _M(e){return xM.indexOf(e)!==-1}function Vl(e){if(e.secure===true){return true}else if(e.secure===false){return false}else if(e.scheme){return 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")}else{return false}}function yh(e){if(!e.host){e.error=e.error||"HTTP URIs must have a host."}return e}function xh(e){const t=String(e.scheme).toLowerCase()==="https";if(e.port===(t?443:80)||e.port===""){e.port=void 0}if(!e.path){e.path="/"}return e}function IM(e){e.secure=Vl(e);e.resourceName=(e.path||"/")+(e.query?"?"+e.query:"");e.path=void 0;e.query=void 0;return e}function bM(e){if(e.port===(Vl(e)?443:80)||e.port===""){e.port=void 0}if(typeof e.secure==="boolean"){e.scheme=e.secure?"wss":"ws";e.secure=void 0}if(e.resourceName){const t=e.resourceName.indexOf("?");const 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}e.fragment=void 0;return e}function wM(e,t){if(!e.path){e.error="URN can not be parsed";return e}const r=e.path.match(yM);if(r&&r[0]===e.path){const o=t.scheme||e.scheme||"urn";e.nid=r[1].toLowerCase();e.nss=r[2];const n=`${o}:${t.nid||e.nid}`;const i=Hl(n);e.path=void 0;if(i){e=i.parse(e,t)}}else{e.error=e.error||"URN can not be parsed."}return e}function TM(e,t){if(e.nid===void 0){throw new Error("URN without nid cannot be serialized")}const r=t.scheme||e.scheme||"urn";const o=e.nid.toLowerCase();const n=`${r}:${t.nid||o}`;const i=Hl(n);if(i){e=i.serialize(e,t)}const s=e;const a=e.nss;s.path=`${o||t.nid}:${a}`;t.skipEscape=true;return s}function SM(e,t){const r=e;r.uuid=r.nss;r.nss=void 0;if(!t.tolerant&&(!r.uuid||!gM(r.uuid))){r.error=r.error||"UUID is not valid."}return r}function MM(e){const t=e;t.nss=(e.uuid||"").toLowerCase();return t}var _h={scheme:"http",domainHost:true,parse:yh,serialize:xh};var RM={scheme:"https",domainHost:_h.domainHost,parse:yh,serialize:xh};var Ha={scheme:"ws",domainHost:true,parse:IM,serialize:bM};var OM={scheme:"wss",domainHost:Ha.domainHost,parse:Ha.parse,serialize:Ha.serialize};var PM={scheme:"urn",parse:wM,serialize:TM,skipNormalize:true};var AM={scheme:"urn:uuid",parse:SM,serialize:MM,skipNormalize:true};var Wa={http:_h,https:RM,ws:Ha,wss:OM,urn:PM,"urn:uuid":AM};Object.setPrototypeOf(Wa,null);function Hl(e){return e&&(Wa[e]||Wa[e.toLowerCase()])||void 0}Ih.exports={wsIsSecure:Vl,SCHEMES:Wa,isValidSchemeName:_M,getSchemeHandler:Hl}});var Fh=P((LL,Ya)=>{"use strict";var{normalizeIPv6:Rh,removeDotSegments:As,recomposeAuthority:kM,normalizePercentEncoding:Oh,normalizePathEncoding:EM,serializePathEncoding:wh,normalizeQueryFragmentEncoding:Th,encodeQuery:$M,encodeFragment:vM,reescapeHostDelimiters:CM,isIPv4:Ph,nonSimpleDomain:FM}=Bl();var{SCHEMES:Ah,getSchemeHandler:Wl}=bh();var kh=/^[A-Za-z][A-Za-z0-9+.-]*$/u;var Eh="URI scheme is malformed.";function Sh(e){const t=unescape(String(e));if(!kh.test(t)){throw new TypeError(Eh)}return t}function NM(e,t){if(typeof e==="string"){e=GM(e,t)}else if(typeof e==="object"){e=Xa(On(e,t),t)}return e}function jM(e,t,r){const o=r?Object.assign({scheme:"null"},r):{scheme:"null"};const{parsed:n,malformedAuthorityOrPort:i,malformedPercentEncoding:s,malformedSchemeSpecific:a,malformedHost:c,malformedScheme:l}=Ja(e,o);const{parsed:u,malformedAuthorityOrPort:d,malformedPercentEncoding:x,malformedSchemeSpecific:y,malformedHost:m,malformedScheme:f}=Ja(t,o);if(i||d||s||x||a||y||c||m||l||f){throw new Error(n.error||u.error||"URI is malformed.")}const h=$h(n,u,o,true);const _=Wl(r&&r.scheme||h.scheme);const I=h.host;const R=I!==void 0&&I!==""&&(Ph(I)||Rh(I).isIPV6);vh(h,r||{},_,R);const C=I&&I.indexOf("%")!==-1&&!new RegExp("\\P{ASCII}","u").test(I);if(h.error&&!C){throw new Error(h.error)}o.skipEscape=true;return On(h,o)}function $h(e,t,r,o){const n={};if(!o){e=Xa(On(e,r),r);t=Xa(On(t,r),r)}r=r||{};if(!r.tolerant&&t.scheme){n.scheme=t.scheme;n.userinfo=t.userinfo;n.host=t.host;n.port=t.port;n.path=As(t.path||"");n.query=t.query}else{if(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0){n.userinfo=t.userinfo;n.host=t.host;n.port=t.port;n.path=As(t.path||"");n.query=t.query}else{if(!t.path){n.path=e.path;if(t.query!==void 0){n.query=t.query}else{n.query=e.query}}else{if(t.path[0]==="/"){n.path=As(t.path)}else{if((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path){n.path="/"+t.path}else if(!e.path){n.path=t.path}else{n.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path}n.path=As(n.path)}n.query=t.query}n.userinfo=e.userinfo;n.host=e.host;n.port=e.port}n.scheme=e.scheme}n.fragment=t.fragment;return n}function zM(e,t,r){const o=Mh(e,r);const n=Mh(t,r);return o!==void 0&&n!==void 0&&o===n}function On(e,t){const 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:""};const o=Object.assign({},t);const n=[];if(r.scheme){r.scheme=Sh(r.scheme)}const i=Wl(o.scheme||r.scheme);if(i&&i.serialize)i.serialize(r,o);const s=r.userinfo!==void 0||r.host!==void 0||r.port!==void 0;const a=!o.skipEscape&&r.scheme===void 0&&!s;if(r.path!==void 0){if(!o.skipEscape){r.path=wh(r.path,a)}else{r.path=Oh(r.path)}}if(o.reference!=="suffix"&&r.scheme){r.scheme=Sh(r.scheme);n.push(r.scheme,":")}const c=kM(r);if(c!==void 0){if(o.reference!=="suffix"){n.push("//")}n.push(c);if(r.path&&r.path[0]!=="/"){n.push("/")}}if(r.path!==void 0){let l=r.path;if(!o.absolutePath&&(!i||!i.absolutePath)){l=As(l)}if(a){l=wh(l,true)}if(c===void 0&&l[0]==="/"&&l[1]==="/"){l="/%2F"+l.slice(2)}n.push(l)}if(r.query!==void 0){n.push("?",$M(r.query))}if(r.fragment!==void 0){n.push("#",vM(r.fragment))}return n.join("")}var DM=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;var UM=/^(?:[^#/:?]+:)?\/\/([^/?#]*)/;var LM=/^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;function qM(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."}return void 0}function Ps(e){if(e===void 0)return false;let t=e.indexOf("%");while(t!==-1){if(t+2>=e.length||!/^[\da-f]{2}$/iu.test(e.slice(t+1,t+3))){return true}t=e.indexOf("%",t+3)}return false}function KM(e){const t=e[4];return Ps(e[3])||t!==void 0&&!(t[0]==="["&&t[t.length-1]==="]")&&Ps(t)||Ps(e[6])||Ps(e[7])||Ps(e[8])}function vh(e,t,r,o){if(!t.unicodeSupport&&(!r||!r.unicodeSupport)&&e.host&&e.host[0]!=="["&&(t.domainHost||r&&r.domainHost)&&o===false&&FM(e.host)){try{e.host=new URL("http://"+e.host).hostname}catch(n){e.error=e.error||"Host's domain name can not be converted to ASCII: "+n;return true}}return false}function Ja(e,t){const r=Object.assign({},t);const o={scheme:void 0,userinfo:void 0,host:"",port:void 0,path:"",query:void 0,fragment:void 0};let n=false;let i=false;let s=false;let a=false;let c=false;let l=false;let u=false;if(r.reference==="suffix"){if(r.scheme){e=r.scheme+":"+e}else{e="//"+e}}const d=e.match(UM);if(d!==null&&d[1].indexOf("\\")!==-1){o.error="URI authority must not contain a literal backslash.";n=true}const x=e.match(LM);if(x!==null){const m=x[1];const f=m.replace(/[\t\n\r]/g,"");if(f.length>=2){if(f.slice(0,2)!=="//"){o.error=o.error||"URI authority must not contain a literal backslash.";n=true}else if(m.length!==f.length){o.error=o.error||"URI authority introducer must not contain whitespace.";n=true}}}const y=e.match(DM);if(y){o.scheme=y[1];o.userinfo=y[3];o.host=y[4];o.port=parseInt(y[5],10);o.path=y[6]||"";o.query=y[7];o.fragment=y[8];if(o.scheme!==void 0){const h=unescape(o.scheme);if(kh.test(h)){o.scheme=h.toLowerCase()}else{o.error=o.error||Eh;l=true}}i=KM(y);if(i){o.error=o.error||"URI contains malformed percent-encoding."}if(isNaN(o.port)){o.port=y[5]}const m=qM(o,y);if(m!==void 0){o.error=o.error||m;n=true}if(o.host){const h=Ph(o.host);if(h===false){const _=o.host[0]==="["&&o.host[o.host.length-1]==="]";const I=Rh(o.host);u=I.isIPV6||I.isIPVFuture===true;c=_&&I.error===true;o.host=u?I.host:I.host.toLowerCase();if(c){o.error=o.error||"URI host is malformed.";n=true}}else{u=true}}if(o.scheme===void 0&&o.userinfo===void 0&&o.host===void 0&&o.port===void 0&&o.query===void 0&&!o.path){o.reference="same-document"}else if(o.scheme===void 0){o.reference="relative"}else if(o.fragment===void 0){o.reference="absolute"}else{o.reference="uri"}if(r.reference&&r.reference!=="suffix"&&r.reference!==o.reference){o.error=o.error||"URI is not a "+r.reference+" reference."}const f=Wl(r.scheme||o.scheme);a=vh(o,r,f,u);if(!f||f&&!f.skipNormalize){if(e.indexOf("%")!==-1){if(o.host!==void 0&&!c){const h=u?o.host:Oh(o.host,true);o.host=CM(h,u)}}if(o.path){o.path=EM(o.path)}if(o.query){o.query=Th(o.query)}if(o.fragment){o.fragment=Th(o.fragment)}}if(f&&f.parse){f.parse(o,r);if(f===Ah.urn&&o.nid===void 0){s=true}}}else{o.error=o.error||"URI can not be parsed."}return{parsed:o,malformedAuthorityOrPort:n,malformedPercentEncoding:i,malformedSchemeSpecific:s,malformedHost:a,malformedScheme:l}}function Xa(e,t){return Ja(e,t).parsed}function GM(e,t){return Ch(e,t).normalized}function Ch(e,t){const{parsed:r,malformedAuthorityOrPort:o,malformedPercentEncoding:n,malformedSchemeSpecific:i,malformedHost:s,malformedScheme:a}=Ja(e,t);return{normalized:o||n||i||s||a?e:On(r,t),malformedAuthorityOrPort:o,malformedPercentEncoding:n,malformedSchemeSpecific:i,malformedHost:s,malformedScheme:a}}function Mh(e,t){if(typeof e!=="string"&&typeof e!=="object"){return void 0}let r;try{r=typeof e==="string"?e:On(e,t)}catch{return void 0}const{normalized:o,malformedAuthorityOrPort:n,malformedPercentEncoding:i,malformedSchemeSpecific:s,malformedHost:a,malformedScheme:c}=Ch(r,t);return n||i||s||a||c?void 0:o}var Jl={SCHEMES:Ah,normalize:NM,resolve:jM,resolveComponent:$h,equal:zM,serialize:On,parse:Xa};Ya.exports=Jl;Ya.exports.default=Jl;Ya.exports.fastUri=Jl});var jh=P(Xl=>{"use strict";Object.defineProperty(Xl,"__esModule",{value:true});var Nh=Fh();Nh.code='require("ajv/dist/runtime/uri").default';Xl.default=Nh});var Bh=P(dt=>{"use strict";Object.defineProperty(dt,"__esModule",{value:true});dt.CodeGen=dt.Name=dt.nil=dt.stringify=dt.str=dt._=dt.KeywordCxt=void 0;var BM=Rs();Object.defineProperty(dt,"KeywordCxt",{enumerable:true,get:function(){return BM.KeywordCxt}});var _i=K();Object.defineProperty(dt,"_",{enumerable:true,get:function(){return _i._}});Object.defineProperty(dt,"str",{enumerable:true,get:function(){return _i.str}});Object.defineProperty(dt,"stringify",{enumerable:true,get:function(){return _i.stringify}});Object.defineProperty(dt,"nil",{enumerable:true,get:function(){return _i.nil}});Object.defineProperty(dt,"Name",{enumerable:true,get:function(){return _i.Name}});Object.defineProperty(dt,"CodeGen",{enumerable:true,get:function(){return _i.CodeGen}});var VM=Ga();var qh=Os();var HM=Il();var ks=Va();var WM=K();var Es=Ts();var Qa=ws();var Ql=ce();var zh=uh();var JM=jh();var Kh=(e,t)=>new RegExp(e,t);Kh.code="new RegExp";var XM=["removeAdditional","useDefaults","coerceTypes"];var YM=new Set(["validate","serialize","parse","wrapper","root","schema","keyword","pattern","formats","validate$data","func","obj","Error"]);var QM={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."};var ZM={ignoreKeywordsWithRef:"",jsPropertySyntax:"",unicode:'"minLength"/"maxLength" account for unicode characters by default.'};var Dh=200;function eR(e){var t,r,o,n,i,s,a,c,l,u,d,x,y,m,f,h,_,I,R,C,k,Wr,so,Tu,Su;const ts=e.strict;const Mu=(t=e.code)===null||t===void 0?void 0:t.optimize;const Uf=Mu===true||Mu===void 0?1:Mu||0;const Lf=(o=(r=e.code)===null||r===void 0?void 0:r.regExp)!==null&&o!==void 0?o:Kh;const ew=(n=e.uriResolver)!==null&&n!==void 0?n:JM.default;return{strictSchema:(s=(i=e.strictSchema)!==null&&i!==void 0?i:ts)!==null&&s!==void 0?s:true,strictNumbers:(c=(a=e.strictNumbers)!==null&&a!==void 0?a:ts)!==null&&c!==void 0?c:true,strictTypes:(u=(l=e.strictTypes)!==null&&l!==void 0?l:ts)!==null&&u!==void 0?u:"log",strictTuples:(x=(d=e.strictTuples)!==null&&d!==void 0?d:ts)!==null&&x!==void 0?x:"log",strictRequired:(m=(y=e.strictRequired)!==null&&y!==void 0?y:ts)!==null&&m!==void 0?m:false,code:e.code?{...e.code,optimize:Uf,regExp:Lf}:{optimize:Uf,regExp:Lf},loopRequired:(f=e.loopRequired)!==null&&f!==void 0?f:Dh,loopEnum:(h=e.loopEnum)!==null&&h!==void 0?h:Dh,meta:(_=e.meta)!==null&&_!==void 0?_:true,messages:(I=e.messages)!==null&&I!==void 0?I:true,inlineRefs:(R=e.inlineRefs)!==null&&R!==void 0?R:true,schemaId:(C=e.schemaId)!==null&&C!==void 0?C:"$id",addUsedSchema:(k=e.addUsedSchema)!==null&&k!==void 0?k:true,validateSchema:(Wr=e.validateSchema)!==null&&Wr!==void 0?Wr:true,validateFormats:(so=e.validateFormats)!==null&&so!==void 0?so:true,unicodeRegExp:(Tu=e.unicodeRegExp)!==null&&Tu!==void 0?Tu:true,int32range:(Su=e.int32range)!==null&&Su!==void 0?Su:true,uriResolver:ew}}var $s=class{constructor(t={}){this.schemas={};this.refs={};this.formats={};this._compilations=new Set;this._loading={};this._cache=new Map;t=this.opts={...t,...eR(t)};const{es5:r,lines:o}=this.opts.code;this.scope=new WM.ValueScope({scope:{},prefixes:YM,es5:r,lines:o});this.logger=sR(t.logger);const n=t.validateFormats;t.validateFormats=false;this.RULES=(0,HM.getRules)();Uh.call(this,QM,t,"NOT SUPPORTED");Uh.call(this,ZM,t,"DEPRECATED","warn");this._metaOpts=nR.call(this);if(t.formats)rR.call(this);this._addVocabularies();this._addDefaultMetaSchema();if(t.keywords)oR.call(this,t.keywords);if(typeof t.meta=="object")this.addMetaSchema(t.meta);tR.call(this);t.validateFormats=n}_addVocabularies(){this.addKeyword("$async")}_addDefaultMetaSchema(){const{$data:t,meta:r,schemaId:o}=this.opts;let n=zh;if(o==="id"){n={...zh};n.id=n.$id;delete n.$id}if(r&&t)this.addMetaSchema(n,n[o],false)}defaultMeta(){const{meta:t,schemaId:r}=this.opts;return this.opts.defaultMeta=typeof t=="object"?t[r]||t:void 0}validate(t,r){let o;if(typeof t=="string"){o=this.getSchema(t);if(!o)throw new Error(`no schema with key or ref "${t}"`)}else{o=this.compile(t)}const n=o(r);if(!("$async"in o))this.errors=o.errors;return n}compile(t,r){const o=this._addSchema(t,r);return o.validate||this._compileSchemaEnv(o)}compileAsync(t,r){if(typeof this.opts.loadSchema!="function"){throw new Error("options.loadSchema should be a function")}const{loadSchema:o}=this.opts;return n.call(this,t,r);async function n(u,d){await i.call(this,u.$schema);const x=this._addSchema(u,d);return x.validate||s.call(this,x)}async function i(u){if(u&&!this.getSchema(u)){await n.call(this,{$ref:u},true)}}async function s(u){try{return this._compileSchemaEnv(u)}catch(d){if(!(d instanceof qh.default))throw d;a.call(this,d);await c.call(this,d.missingSchema);return s.call(this,u)}}function a({missingSchema:u,missingRef:d}){if(this.refs[u]){throw new Error(`AnySchema ${u} is loaded but ${d} cannot be resolved`)}}async function c(u){const d=await l.call(this,u);if(!this.refs[u])await i.call(this,d.$schema);if(!this.refs[u])this.addSchema(d,u,r)}async function l(u){const d=this._loading[u];if(d)return d;try{return await(this._loading[u]=o(u))}finally{delete this._loading[u]}}}addSchema(t,r,o,n=this.opts.validateSchema){if(Array.isArray(t)){for(const s of t)this.addSchema(s,void 0,o,n);return this}let i;if(typeof t==="object"){const{schemaId:s}=this.opts;i=t[s];if(i!==void 0&&typeof i!="string"){throw new Error(`schema ${s} must be string`)}}r=(0,Es.normalizeId)(r||i);this._checkUnique(r);this.schemas[r]=this._addSchema(t,o,r,n,true);return this}addMetaSchema(t,r,o=this.opts.validateSchema){this.addSchema(t,r,true,o);return this}validateSchema(t,r){if(typeof t=="boolean")return true;let o;o=t.$schema;if(o!==void 0&&typeof o!="string"){throw new Error("$schema must be a string")}o=o||this.opts.defaultMeta||this.defaultMeta();if(!o){this.logger.warn("meta-schema not available");this.errors=null;return true}const n=this.validate(o,t);if(!n&&r){const i="schema is invalid: "+this.errorsText();if(this.opts.validateSchema==="log")this.logger.error(i);else throw new Error(i)}return n}getSchema(t){let r;while(typeof(r=Lh.call(this,t))=="string")t=r;if(r===void 0){const{schemaId:o}=this.opts;const n=new ks.SchemaEnv({schema:{},schemaId:o});r=ks.resolveSchema.call(this,n,t);if(!r)return;this.refs[t]=r}return r.validate||this._compileSchemaEnv(r)}removeSchema(t){if(t instanceof RegExp){this._removeAllSchemas(this.schemas,t);this._removeAllSchemas(this.refs,t);return this}switch(typeof t){case"undefined":this._removeAllSchemas(this.schemas);this._removeAllSchemas(this.refs);this._cache.clear();return this;case"string":{const r=Lh.call(this,t);if(typeof r=="object")this._cache.delete(r.schema);delete this.schemas[t];delete this.refs[t];return this}case"object":{const r=t;this._cache.delete(r);let o=t[this.opts.schemaId];if(o){o=(0,Es.normalizeId)(o);delete this.schemas[o];delete this.refs[o]}return this}default:throw new Error("ajv.removeSchema: invalid parameter")}}addVocabulary(t){for(const r of t)this.addKeyword(r);return this}addKeyword(t,r){let o;if(typeof t=="string"){o=t;if(typeof r=="object"){this.logger.warn("these parameters are deprecated, see docs for addKeyword");r.keyword=o}}else if(typeof t=="object"&&r===void 0){r=t;o=r.keyword;if(Array.isArray(o)&&!o.length){throw new Error("addKeywords: keyword must be string or non-empty array")}}else{throw new Error("invalid addKeywords parameters")}cR.call(this,o,r);if(!r){(0,Ql.eachItem)(o,i=>Yl.call(this,i));return this}lR.call(this,r);const n={...r,type:(0,Qa.getJSONTypes)(r.type),schemaType:(0,Qa.getJSONTypes)(r.schemaType)};(0,Ql.eachItem)(o,n.type.length===0?i=>Yl.call(this,i,n):i=>n.type.forEach(s=>Yl.call(this,i,n,s)));return this}getKeyword(t){const r=this.RULES.all[t];return typeof r=="object"?r.definition:!!r}removeKeyword(t){const{RULES:r}=this;delete r.keywords[t];delete r.all[t];for(const o of r.rules){const n=o.rules.findIndex(i=>i.keyword===t);if(n>=0)o.rules.splice(n,1)}return this}addFormat(t,r){if(typeof r=="string")r=new RegExp(r);this.formats[t]=r;return this}errorsText(t=this.errors,{separator:r=", ",dataVar:o="data"}={}){if(!t||t.length===0)return"No errors";return t.map(n=>`${o}${n.instancePath} ${n.message}`).reduce((n,i)=>n+r+i)}$dataMetaSchema(t,r){const o=this.RULES.all;t=JSON.parse(JSON.stringify(t));for(const n of r){const i=n.split("/").slice(1);let s=t;for(const a of i)s=s[a];for(const a in o){const c=o[a];if(typeof c!="object")continue;const{$data:l}=c.definition;const u=s[a];if(l&&u)s[a]=Gh(u)}}return t}_removeAllSchemas(t,r){for(const o in t){const n=t[o];if(!r||r.test(o)){if(typeof n=="string"){delete t[o]}else if(n&&!n.meta){this._cache.delete(n.schema);delete t[o]}}}}_addSchema(t,r,o,n=this.opts.validateSchema,i=this.opts.addUsedSchema){let s;const{schemaId:a}=this.opts;if(typeof t=="object"){s=t[a]}else{if(this.opts.jtd)throw new Error("schema must be object");else 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;o=(0,Es.normalizeId)(s||o);const l=Es.getSchemaRefs.call(this,t,o);c=new ks.SchemaEnv({schema:t,schemaId:a,meta:r,baseId:o,localRefs:l});this._cache.set(c.schema,c);if(i&&!o.startsWith("#")){if(o)this._checkUnique(o);this.refs[o]=c}if(n)this.validateSchema(t,true);return 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);else ks.compileSchema.call(this,t);if(!t.validate)throw new Error("ajv implementation error");return t.validate}_compileMetaSchema(t){const r=this.opts;this.opts=this._metaOpts;try{ks.compileSchema.call(this,t)}finally{this.opts=r}}};$s.ValidationError=VM.default;$s.MissingRefError=qh.default;dt.default=$s;function Uh(e,t,r,o="error"){for(const n in e){const i=n;if(i in t)this.logger[o](`${r}: option ${n}. ${e[i]}`)}}function Lh(e){e=(0,Es.normalizeId)(e);return this.schemas[e]||this.refs[e]}function tR(){const e=this.opts.schemas;if(!e)return;if(Array.isArray(e))this.addSchema(e);else for(const t in e)this.addSchema(e[t],t)}function rR(){for(const e in this.opts.formats){const t=this.opts.formats[e];if(t)this.addFormat(e,t)}}function oR(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn("keywords option as map is deprecated, pass array");for(const t in e){const r=e[t];if(!r.keyword)r.keyword=t;this.addKeyword(r)}}function nR(){const e={...this.opts};for(const t of XM)delete e[t];return e}var iR={log(){},warn(){},error(){}};function sR(e){if(e===false)return iR;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 aR=/^[a-z_$][a-z0-9_$:-]*$/i;function cR(e,t){const{RULES:r}=this;(0,Ql.eachItem)(e,o=>{if(r.keywords[o])throw new Error(`Keyword ${o} is already defined`);if(!aR.test(o))throw new Error(`Keyword ${o} has invalid name`)});if(!t)return;if(t.$data&&!("code"in t||"validate"in t)){throw new Error('$data keyword must have "code" or "validate" function')}}function Yl(e,t,r){var o;const n=t===null||t===void 0?void 0:t.post;if(r&&n)throw new Error('keyword with "post" flag cannot have "type"');const{RULES:i}=this;let s=n?i.post:i.rules.find(({type:c})=>c===r);if(!s){s={type:r,rules:[]};i.rules.push(s)}i.keywords[e]=true;if(!t)return;const a={keyword:e,definition:{...t,type:(0,Qa.getJSONTypes)(t.type),schemaType:(0,Qa.getJSONTypes)(t.schemaType)}};if(t.before)uR.call(this,s,a,t.before);else s.rules.push(a);i.all[e]=a;(o=t.implements)===null||o===void 0?void 0:o.forEach(c=>this.addKeyword(c))}function uR(e,t,r){const o=e.rules.findIndex(n=>n.keyword===r);if(o>=0){e.rules.splice(o,0,t)}else{e.rules.push(t);this.logger.warn(`rule ${r} is not defined`)}}function lR(e){let{metaSchema:t}=e;if(t===void 0)return;if(e.$data&&this.opts.$data)t=Gh(t);e.validateSchema=this.compile(t,true)}var dR={$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"};function Gh(e){return{anyOf:[e,dR]}}});var Vh=P(Zl=>{"use strict";Object.defineProperty(Zl,"__esModule",{value:true});var pR={keyword:"id",code(){throw new Error('NOT SUPPORTED: keyword "id", use "$id" for schema ID')}};Zl.default=pR});var Xh=P(Pn=>{"use strict";Object.defineProperty(Pn,"__esModule",{value:true});Pn.callRef=Pn.getValidate=void 0;var fR=Os();var Hh=ur();var jt=K();var Ii=uo();var Wh=Va();var Za=ce();var mR={keyword:"$ref",schemaType:"string",code(e){const{gen:t,schema:r,it:o}=e;const{baseId:n,schemaEnv:i,validateName:s,opts:a,self:c}=o;const{root:l}=i;if((r==="#"||r==="#/")&&n===l.baseId)return d();const u=Wh.resolveRef.call(c,l,n,r);if(u===void 0)throw new fR.default(o.opts.uriResolver,n,r);if(u instanceof Wh.SchemaEnv)return x(u);return y(u);function d(){if(i===l)return ec(e,s,i,i.$async);const m=t.scopeValue("root",{ref:l});return ec(e,(0,jt._)`${m}.validate`,l,l.$async)}function x(m){const f=Jh(e,m);ec(e,f,m,m.$async)}function y(m){const f=t.scopeValue("schema",a.code.source===true?{ref:m,code:(0,jt.stringify)(m)}:{ref:m});const h=t.name("valid");const _=e.subschema({schema:m,dataTypes:[],schemaPath:jt.nil,topSchemaRef:f,errSchemaPath:r},h);e.mergeEvaluated(_);e.ok(h)}}};function Jh(e,t){const{gen:r}=e;return t.validate?r.scopeValue("validate",{ref:t.validate}):(0,jt._)`${r.scopeValue("wrapper",{ref:t})}.validate`}Pn.getValidate=Jh;function ec(e,t,r,o){const{gen:n,it:i}=e;const{allErrors:s,schemaEnv:a,opts:c}=i;const l=c.passContext?Ii.default.this:jt.nil;if(o)u();else d();function u(){if(!a.$async)throw new Error("async schema referenced by sync schema");const m=n.let("valid");n.try(()=>{n.code((0,jt._)`await ${(0,Hh.callValidateCode)(e,t,l)}`);y(t);if(!s)n.assign(m,true)},f=>{n.if((0,jt._)`!(${f} instanceof ${i.ValidationError})`,()=>n.throw(f));x(f);if(!s)n.assign(m,false)});e.ok(m)}function d(){e.result((0,Hh.callValidateCode)(e,t,l),()=>y(t),()=>x(t))}function x(m){const f=(0,jt._)`${m}.errors`;n.assign(Ii.default.vErrors,(0,jt._)`${Ii.default.vErrors} === null ? ${f} : ${Ii.default.vErrors}.concat(${f})`);n.assign(Ii.default.errors,(0,jt._)`${Ii.default.vErrors}.length`)}function y(m){var f;if(!i.opts.unevaluated)return;const h=(f=r===null||r===void 0?void 0:r.validate)===null||f===void 0?void 0:f.evaluated;if(i.props!==true){if(h&&!h.dynamicProps){if(h.props!==void 0){i.props=Za.mergeEvaluated.props(n,h.props,i.props)}}else{const _=n.var("props",(0,jt._)`${m}.evaluated.props`);i.props=Za.mergeEvaluated.props(n,_,i.props,jt.Name)}}if(i.items!==true){if(h&&!h.dynamicItems){if(h.items!==void 0){i.items=Za.mergeEvaluated.items(n,h.items,i.items)}}else{const _=n.var("items",(0,jt._)`${m}.evaluated.items`);i.items=Za.mergeEvaluated.items(n,_,i.items,jt.Name)}}}}Pn.callRef=ec;Pn.default=mR});var Yh=P(ed=>{"use strict";Object.defineProperty(ed,"__esModule",{value:true});var hR=Vh();var gR=Xh();var yR=["$schema","$id","$defs","$vocabulary",{keyword:"$comment"},"definitions",hR.default,gR.default];ed.default=yR});var Qh=P(td=>{"use strict";Object.defineProperty(td,"__esModule",{value:true});var tc=K();var Fo=tc.operators;var rc={maximum:{okStr:"<=",ok:Fo.LTE,fail:Fo.GT},minimum:{okStr:">=",ok:Fo.GTE,fail:Fo.LT},exclusiveMaximum:{okStr:"<",ok:Fo.LT,fail:Fo.GTE},exclusiveMinimum:{okStr:">",ok:Fo.GT,fail:Fo.LTE}};var xR={message:({keyword:e,schemaCode:t})=>(0,tc.str)`must be ${rc[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,tc._)`{comparison: ${rc[e].okStr}, limit: ${t}}`};var _R={keyword:Object.keys(rc),type:"number",schemaType:"number",$data:true,error:xR,code(e){const{keyword:t,data:r,schemaCode:o}=e;e.fail$data((0,tc._)`${r} ${rc[t].fail} ${o} || isNaN(${r})`)}};td.default=_R});var Zh=P(rd=>{"use strict";Object.defineProperty(rd,"__esModule",{value:true});var vs=K();var IR={message:({schemaCode:e})=>(0,vs.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,vs._)`{multipleOf: ${e}}`};var bR={keyword:"multipleOf",type:"number",schemaType:"number",$data:true,error:IR,code(e){const{gen:t,data:r,schemaCode:o,it:n}=e;const i=n.opts.multipleOfPrecision;const s=t.let("res");const a=i?(0,vs._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${i}`:(0,vs._)`${s} !== parseInt(${s})`;e.fail$data((0,vs._)`(${o} === 0 || (${s} = ${r}/${o}, ${a}))`)}};rd.default=bR});var tg=P(od=>{"use strict";Object.defineProperty(od,"__esModule",{value:true});function eg(e){const t=e.length;let r=0;let o=0;let n;while(o<t){r++;n=e.charCodeAt(o++);if(n>=55296&&n<=56319&&o<t){n=e.charCodeAt(o);if((n&64512)===56320)o++}}return r}od.default=eg;eg.code='require("ajv/dist/runtime/ucs2length").default'});var rg=P(nd=>{"use strict";Object.defineProperty(nd,"__esModule",{value:true});var An=K();var wR=ce();var TR=tg();var SR={message({keyword:e,schemaCode:t}){const r=e==="maxLength"?"more":"fewer";return(0,An.str)`must NOT have ${r} than ${t} characters`},params:({schemaCode:e})=>(0,An._)`{limit: ${e}}`};var MR={keyword:["maxLength","minLength"],type:"string",schemaType:"number",$data:true,error:SR,code(e){const{keyword:t,data:r,schemaCode:o,it:n}=e;const i=t==="maxLength"?An.operators.GT:An.operators.LT;const s=n.opts.unicode===false?(0,An._)`${r}.length`:(0,An._)`${(0,wR.useFunc)(e.gen,TR.default)}(${r})`;e.fail$data((0,An._)`${s} ${i} ${o}`)}};nd.default=MR});var og=P(id=>{"use strict";Object.defineProperty(id,"__esModule",{value:true});var RR=ur();var OR=ce();var bi=K();var PR={message:({schemaCode:e})=>(0,bi.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,bi._)`{pattern: ${e}}`};var AR={keyword:"pattern",type:"string",schemaType:"string",$data:true,error:PR,code(e){const{gen:t,data:r,$data:o,schema:n,schemaCode:i,it:s}=e;const a=s.opts.unicodeRegExp?"u":"";if(o){const{regExp:c}=s.opts.code;const l=c.code==="new RegExp"?(0,bi._)`new RegExp`:(0,OR.useFunc)(t,c);const u=t.let("valid");t.try(()=>t.assign(u,(0,bi._)`${l}(${i}, ${a}).test(${r})`),()=>t.assign(u,false));e.fail$data((0,bi._)`!${u}`)}else{const c=(0,RR.usePattern)(e,n);e.fail$data((0,bi._)`!${c}.test(${r})`)}}};id.default=AR});var ng=P(sd=>{"use strict";Object.defineProperty(sd,"__esModule",{value:true});var Cs=K();var kR={message({keyword:e,schemaCode:t}){const r=e==="maxProperties"?"more":"fewer";return(0,Cs.str)`must NOT have ${r} than ${t} properties`},params:({schemaCode:e})=>(0,Cs._)`{limit: ${e}}`};var ER={keyword:["maxProperties","minProperties"],type:"object",schemaType:"number",$data:true,error:kR,code(e){const{keyword:t,data:r,schemaCode:o}=e;const n=t==="maxProperties"?Cs.operators.GT:Cs.operators.LT;e.fail$data((0,Cs._)`Object.keys(${r}).length ${n} ${o}`)}};sd.default=ER});var ig=P(ad=>{"use strict";Object.defineProperty(ad,"__esModule",{value:true});var Fs=ur();var Ns=K();var $R=ce();var vR={message:({params:{missingProperty:e}})=>(0,Ns.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,Ns._)`{missingProperty: ${e}}`};var CR={keyword:"required",type:"object",schemaType:"array",$data:true,error:vR,code(e){const{gen:t,schema:r,schemaCode:o,data:n,$data:i,it:s}=e;const{opts:a}=s;if(!i&&r.length===0)return;const c=r.length>=a.loopRequired;if(s.allErrors)l();else u();if(a.strictRequired){const y=e.parentSchema.properties;const{definedProperties:m}=e.it;for(const f of r){if((y===null||y===void 0?void 0:y[f])===void 0&&!m.has(f)){const h=s.schemaEnv.baseId+s.errSchemaPath;const _=`required property "${f}" is not defined at "${h}" (strictRequired)`;(0,$R.checkStrictMode)(s,_,s.opts.strictRequired)}}}function l(){if(c||i){e.block$data(Ns.nil,d)}else{for(const y of r){(0,Fs.checkReportMissingProp)(e,y)}}}function u(){const y=t.let("missing");if(c||i){const m=t.let("valid",true);e.block$data(m,()=>x(y,m));e.ok(m)}else{t.if((0,Fs.checkMissingProp)(e,r,y));(0,Fs.reportMissingProp)(e,y);t.else()}}function d(){t.forOf("prop",o,y=>{e.setParams({missingProperty:y});t.if((0,Fs.noPropertyInData)(t,n,y,a.ownProperties),()=>e.error())})}function x(y,m){e.setParams({missingProperty:y});t.forOf(y,o,()=>{t.assign(m,(0,Fs.propertyInData)(t,n,y,a.ownProperties));t.if((0,Ns.not)(m),()=>{e.error();t.break()})},Ns.nil)}}};ad.default=CR});var sg=P(cd=>{"use strict";Object.defineProperty(cd,"__esModule",{value:true});var js=K();var FR={message({keyword:e,schemaCode:t}){const r=e==="maxItems"?"more":"fewer";return(0,js.str)`must NOT have ${r} than ${t} items`},params:({schemaCode:e})=>(0,js._)`{limit: ${e}}`};var NR={keyword:["maxItems","minItems"],type:"array",schemaType:"number",$data:true,error:FR,code(e){const{keyword:t,data:r,schemaCode:o}=e;const n=t==="maxItems"?js.operators.GT:js.operators.LT;e.fail$data((0,js._)`${r}.length ${n} ${o}`)}};cd.default=NR});var oc=P(ud=>{"use strict";Object.defineProperty(ud,"__esModule",{value:true});var ag=Pl();ag.code='require("ajv/dist/runtime/equal").default';ud.default=ag});var cg=P(dd=>{"use strict";Object.defineProperty(dd,"__esModule",{value:true});var ld=ws();var pt=K();var jR=ce();var zR=oc();var DR={message:({params:{i:e,j:t}})=>(0,pt.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,pt._)`{i: ${e}, j: ${t}}`};var UR={keyword:"uniqueItems",type:"array",schemaType:"boolean",$data:true,error:DR,code(e){const{gen:t,data:r,$data:o,schema:n,parentSchema:i,schemaCode:s,it:a}=e;if(!o&&!n)return;const c=t.let("valid");const l=i.items?(0,ld.getSchemaTypes)(i.items):[];e.block$data(c,u,(0,pt._)`${s} === false`);e.ok(c);function u(){const m=t.let("i",(0,pt._)`${r}.length`);const f=t.let("j");e.setParams({i:m,j:f});t.assign(c,true);t.if((0,pt._)`${m} > 1`,()=>(d()?x:y)(m,f))}function d(){return l.length>0&&!l.some(m=>m==="object"||m==="array")}function x(m,f){const h=t.name("item");const _=(0,ld.checkDataTypes)(l,h,a.opts.strictNumbers,ld.DataType.Wrong);const I=t.const("indices",(0,pt._)`{}`);t.for((0,pt._)`;${m}--;`,()=>{t.let(h,(0,pt._)`${r}[${m}]`);t.if(_,(0,pt._)`continue`);if(l.length>1)t.if((0,pt._)`typeof ${h} == "string"`,(0,pt._)`${h} += "_"`);t.if((0,pt._)`typeof ${I}[${h}] == "number"`,()=>{t.assign(f,(0,pt._)`${I}[${h}]`);e.error();t.assign(c,false).break()}).code((0,pt._)`${I}[${h}] = ${m}`)})}function y(m,f){const h=(0,jR.useFunc)(t,zR.default);const _=t.name("outer");t.label(_).for((0,pt._)`;${m}--;`,()=>t.for((0,pt._)`${f} = ${m}; ${f}--;`,()=>t.if((0,pt._)`${h}(${r}[${m}], ${r}[${f}])`,()=>{e.error();t.assign(c,false).break(_)})))}}};dd.default=UR});var ug=P(fd=>{"use strict";Object.defineProperty(fd,"__esModule",{value:true});var pd=K();var LR=ce();var qR=oc();var KR={message:"must be equal to constant",params:({schemaCode:e})=>(0,pd._)`{allowedValue: ${e}}`};var GR={keyword:"const",$data:true,error:KR,code(e){const{gen:t,data:r,$data:o,schemaCode:n,schema:i}=e;if(o||i&&typeof i=="object"){e.fail$data((0,pd._)`!${(0,LR.useFunc)(t,qR.default)}(${r}, ${n})`)}else{e.fail((0,pd._)`${i} !== ${r}`)}}};fd.default=GR});var lg=P(md=>{"use strict";Object.defineProperty(md,"__esModule",{value:true});var zs=K();var BR=ce();var VR=oc();var HR={message:"must be equal to one of the allowed values",params:({schemaCode:e})=>(0,zs._)`{allowedValues: ${e}}`};var WR={keyword:"enum",schemaType:"array",$data:true,error:HR,code(e){const{gen:t,data:r,$data:o,schema:n,schemaCode:i,it:s}=e;if(!o&&n.length===0)throw new Error("enum must have non-empty array");const a=n.length>=s.opts.loopEnum;let c;const l=()=>c!==null&&c!==void 0?c:c=(0,BR.useFunc)(t,VR.default);let u;if(a||o){u=t.let("valid");e.block$data(u,d)}else{if(!Array.isArray(n))throw new Error("ajv implementation error");const y=t.const("vSchema",i);u=(0,zs.or)(...n.map((m,f)=>x(y,f)))}e.pass(u);function d(){t.assign(u,false);t.forOf("v",i,y=>t.if((0,zs._)`${l()}(${r}, ${y})`,()=>t.assign(u,true).break()))}function x(y,m){const f=n[m];return typeof f==="object"&&f!==null?(0,zs._)`${l()}(${r}, ${y}[${m}])`:(0,zs._)`${r} === ${f}`}}};md.default=WR});var dg=P(hd=>{"use strict";Object.defineProperty(hd,"__esModule",{value:true});var JR=Qh();var XR=Zh();var YR=rg();var QR=og();var ZR=ng();var eO=ig();var tO=sg();var rO=cg();var oO=ug();var nO=lg();var iO=[JR.default,XR.default,YR.default,QR.default,ZR.default,eO.default,tO.default,rO.default,{keyword:"type",schemaType:["string","array"]},{keyword:"nullable",schemaType:"boolean"},oO.default,nO.default];hd.default=iO});var yd=P(Ds=>{"use strict";Object.defineProperty(Ds,"__esModule",{value:true});Ds.validateAdditionalItems=void 0;var kn=K();var gd=ce();var sO={message:({params:{len:e}})=>(0,kn.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,kn._)`{limit: ${e}}`};var aO={keyword:"additionalItems",type:"array",schemaType:["boolean","object"],before:"uniqueItems",error:sO,code(e){const{parentSchema:t,it:r}=e;const{items:o}=t;if(!Array.isArray(o)){(0,gd.checkStrictMode)(r,'"additionalItems" is ignored when "items" is not an array of schemas');return}pg(e,o)}};function pg(e,t){const{gen:r,schema:o,data:n,keyword:i,it:s}=e;s.items=true;const a=r.const("len",(0,kn._)`${n}.length`);if(o===false){e.setParams({len:t.length});e.pass((0,kn._)`${a} <= ${t.length}`)}else if(typeof o=="object"&&!(0,gd.alwaysValidSchema)(s,o)){const l=r.var("valid",(0,kn._)`${a} <= ${t.length}`);r.if((0,kn.not)(l),()=>c(l));e.ok(l)}function c(l){r.forRange("i",t.length,a,u=>{e.subschema({keyword:i,dataProp:u,dataPropType:gd.Type.Num},l);if(!s.allErrors)r.if((0,kn.not)(l),()=>r.break())})}}Ds.validateAdditionalItems=pg;Ds.default=aO});var xd=P(Us=>{"use strict";Object.defineProperty(Us,"__esModule",{value:true});Us.validateTuple=void 0;var fg=K();var nc=ce();var cO=ur();var uO={keyword:"items",type:"array",schemaType:["object","array","boolean"],before:"uniqueItems",code(e){const{schema:t,it:r}=e;if(Array.isArray(t))return mg(e,"additionalItems",t);r.items=true;if((0,nc.alwaysValidSchema)(r,t))return;e.ok((0,cO.validateArray)(e))}};function mg(e,t,r=e.schema){const{gen:o,parentSchema:n,data:i,keyword:s,it:a}=e;u(n);if(a.opts.unevaluated&&r.length&&a.items!==true){a.items=nc.mergeEvaluated.items(o,r.length,a.items)}const c=o.name("valid");const l=o.const("len",(0,fg._)`${i}.length`);r.forEach((d,x)=>{if((0,nc.alwaysValidSchema)(a,d))return;o.if((0,fg._)`${l} > ${x}`,()=>e.subschema({keyword:s,schemaProp:x,dataProp:x},c));e.ok(c)});function u(d){const{opts:x,errSchemaPath:y}=a;const m=r.length;const f=m===d.minItems&&(m===d.maxItems||d[t]===false);if(x.strictTuples&&!f){const h=`"${s}" is ${m}-tuple, but minItems or maxItems/${t} are not specified or different at path "${y}"`;(0,nc.checkStrictMode)(a,h,x.strictTuples)}}}Us.validateTuple=mg;Us.default=uO});var hg=P(_d=>{"use strict";Object.defineProperty(_d,"__esModule",{value:true});var lO=xd();var dO={keyword:"prefixItems",type:"array",schemaType:["array"],before:"uniqueItems",code:e=>(0,lO.validateTuple)(e,"items")};_d.default=dO});var yg=P(Id=>{"use strict";Object.defineProperty(Id,"__esModule",{value:true});var gg=K();var pO=ce();var fO=ur();var mO=yd();var hO={message:({params:{len:e}})=>(0,gg.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,gg._)`{limit: ${e}}`};var gO={keyword:"items",type:"array",schemaType:["object","boolean"],before:"uniqueItems",error:hO,code(e){const{schema:t,parentSchema:r,it:o}=e;const{prefixItems:n}=r;o.items=true;if((0,pO.alwaysValidSchema)(o,t))return;if(n)(0,mO.validateAdditionalItems)(e,n);else e.ok((0,fO.validateArray)(e))}};Id.default=gO});var xg=P(bd=>{"use strict";Object.defineProperty(bd,"__esModule",{value:true});var dr=K();var ic=ce();var yO={message:({params:{min:e,max:t}})=>t===void 0?(0,dr.str)`must contain at least ${e} valid item(s)`:(0,dr.str)`must contain at least ${e} and no more than ${t} valid item(s)`,params:({params:{min:e,max:t}})=>t===void 0?(0,dr._)`{minContains: ${e}}`:(0,dr._)`{minContains: ${e}, maxContains: ${t}}`};var xO={keyword:"contains",type:"array",schemaType:["object","boolean"],before:"uniqueItems",trackErrors:true,error:yO,code(e){const{gen:t,schema:r,parentSchema:o,data:n,it:i}=e;let s;let a;const{minContains:c,maxContains:l}=o;if(i.opts.next){s=c===void 0?1:c;a=l}else{s=1}const u=t.const("len",(0,dr._)`${n}.length`);e.setParams({min:s,max:a});if(a===void 0&&s===0){(0,ic.checkStrictMode)(i,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(a!==void 0&&s>a){(0,ic.checkStrictMode)(i,`"minContains" > "maxContains" is always invalid`);e.fail();return}if((0,ic.alwaysValidSchema)(i,r)){let f=(0,dr._)`${u} >= ${s}`;if(a!==void 0)f=(0,dr._)`${f} && ${u} <= ${a}`;e.pass(f);return}i.items=true;const d=t.name("valid");if(a===void 0&&s===1){y(d,()=>t.if(d,()=>t.break()))}else if(s===0){t.let(d,true);if(a!==void 0)t.if((0,dr._)`${n}.length > 0`,x)}else{t.let(d,false);x()}e.result(d,()=>e.reset());function x(){const f=t.name("_valid");const h=t.let("count",0);y(f,()=>t.if(f,()=>m(h)))}function y(f,h){t.forRange("i",0,u,_=>{e.subschema({keyword:"contains",dataProp:_,dataPropType:ic.Type.Num,compositeRule:true},f);h()})}function m(f){t.code((0,dr._)`${f}++`);if(a===void 0){t.if((0,dr._)`${f} >= ${s}`,()=>t.assign(d,true).break())}else{t.if((0,dr._)`${f} > ${a}`,()=>t.assign(d,false).break());if(s===1)t.assign(d,true);else t.if((0,dr._)`${f} >= ${s}`,()=>t.assign(d,true))}}}};bd.default=xO});var bg=P(Yr=>{"use strict";Object.defineProperty(Yr,"__esModule",{value:true});Yr.validateSchemaDeps=Yr.validatePropertyDeps=Yr.error=void 0;var wd=K();var _O=ce();var Ls=ur();Yr.error={message:({params:{property:e,depsCount:t,deps:r}})=>{const o=t===1?"property":"properties";return(0,wd.str)`must have ${o} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:t,deps:r,missingProperty:o}})=>(0,wd._)`{property: ${e},
|
|
6
|
-
missingProperty: ${o},
|
|
7
|
-
depsCount: ${t},
|
|
8
|
-
deps: ${r}}`};var IO={keyword:"dependencies",type:"object",schemaType:"object",error:Yr.error,code(e){const[t,r]=bO(e);_g(e,t);Ig(e,r)}};function bO({schema:e}){const t={};const r={};for(const o in e){if(o==="__proto__")continue;const n=Array.isArray(e[o])?t:r;n[o]=e[o]}return[t,r]}function _g(e,t=e.schema){const{gen:r,data:o,it:n}=e;if(Object.keys(t).length===0)return;const i=r.let("missing");for(const s in t){const a=t[s];if(a.length===0)continue;const c=(0,Ls.propertyInData)(r,o,s,n.opts.ownProperties);e.setParams({property:s,depsCount:a.length,deps:a.join(", ")});if(n.allErrors){r.if(c,()=>{for(const l of a){(0,Ls.checkReportMissingProp)(e,l)}})}else{r.if((0,wd._)`${c} && (${(0,Ls.checkMissingProp)(e,a,i)})`);(0,Ls.reportMissingProp)(e,i);r.else()}}}Yr.validatePropertyDeps=_g;function Ig(e,t=e.schema){const{gen:r,data:o,keyword:n,it:i}=e;const s=r.name("valid");for(const a in t){if((0,_O.alwaysValidSchema)(i,t[a]))continue;r.if((0,Ls.propertyInData)(r,o,a,i.opts.ownProperties),()=>{const c=e.subschema({keyword:n,schemaProp:a},s);e.mergeValidEvaluated(c,s)},()=>r.var(s,true));e.ok(s)}}Yr.validateSchemaDeps=Ig;Yr.default=IO});var Tg=P(Td=>{"use strict";Object.defineProperty(Td,"__esModule",{value:true});var wg=K();var wO=ce();var TO={message:"property name must be valid",params:({params:e})=>(0,wg._)`{propertyName: ${e.propertyName}}`};var SO={keyword:"propertyNames",type:"object",schemaType:["object","boolean"],error:TO,code(e){const{gen:t,schema:r,data:o,it:n}=e;if((0,wO.alwaysValidSchema)(n,r))return;const i=t.name("valid");t.forIn("key",o,s=>{e.setParams({propertyName:s});e.subschema({keyword:"propertyNames",data:s,dataTypes:["string"],propertyName:s,compositeRule:true},i);t.if((0,wg.not)(i),()=>{e.error(true);if(!n.allErrors)t.break()})});e.ok(i)}};Td.default=SO});var Md=P(Sd=>{"use strict";Object.defineProperty(Sd,"__esModule",{value:true});var sc=ur();var Sr=K();var MO=uo();var ac=ce();var RO={message:"must NOT have additional properties",params:({params:e})=>(0,Sr._)`{additionalProperty: ${e.additionalProperty}}`};var OO={keyword:"additionalProperties",type:["object"],schemaType:["boolean","object"],allowUndefined:true,trackErrors:true,error:RO,code(e){const{gen:t,schema:r,parentSchema:o,data:n,errsCount:i,it:s}=e;if(!i)throw new Error("ajv implementation error");const{allErrors:a,opts:c}=s;s.props=true;if(c.removeAdditional!=="all"&&(0,ac.alwaysValidSchema)(s,r))return;const l=(0,sc.allSchemaProperties)(o.properties);const u=(0,sc.allSchemaProperties)(o.patternProperties);d();e.ok((0,Sr._)`${i} === ${MO.default.errors}`);function d(){t.forIn("key",n,h=>{if(!l.length&&!u.length)m(h);else t.if(x(h),()=>m(h))})}function x(h){let _;if(l.length>8){const I=(0,ac.schemaRefOrVal)(s,o.properties,"properties");_=(0,sc.isOwnProperty)(t,I,h)}else if(l.length){_=(0,Sr.or)(...l.map(I=>(0,Sr._)`${h} === ${I}`))}else{_=Sr.nil}if(u.length){_=(0,Sr.or)(_,...u.map(I=>(0,Sr._)`${(0,sc.usePattern)(e,I)}.test(${h})`))}return(0,Sr.not)(_)}function y(h){t.code((0,Sr._)`delete ${n}[${h}]`)}function m(h){if(c.removeAdditional==="all"||c.removeAdditional&&r===false){y(h);return}if(r===false){e.setParams({additionalProperty:h});e.error();if(!a)t.break();return}if(typeof r=="object"&&!(0,ac.alwaysValidSchema)(s,r)){const _=t.name("valid");if(c.removeAdditional==="failing"){f(h,_,false);t.if((0,Sr.not)(_),()=>{e.reset();y(h)})}else{f(h,_);if(!a)t.if((0,Sr.not)(_),()=>t.break())}}}function f(h,_,I){const R={keyword:"additionalProperties",dataProp:h,dataPropType:ac.Type.Str};if(I===false){Object.assign(R,{compositeRule:true,createErrors:false,allErrors:false})}e.subschema(R,_)}}};Sd.default=OO});var Rg=P(Od=>{"use strict";Object.defineProperty(Od,"__esModule",{value:true});var PO=Rs();var Sg=ur();var Rd=ce();var Mg=Md();var AO={keyword:"properties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,parentSchema:o,data:n,it:i}=e;if(i.opts.removeAdditional==="all"&&o.additionalProperties===void 0){Mg.default.code(new PO.KeywordCxt(i,Mg.default,"additionalProperties"))}const s=(0,Sg.allSchemaProperties)(r);for(const d of s){i.definedProperties.add(d)}if(i.opts.unevaluated&&s.length&&i.props!==true){i.props=Rd.mergeEvaluated.props(t,(0,Rd.toHash)(s),i.props)}const a=s.filter(d=>!(0,Rd.alwaysValidSchema)(i,r[d]));if(a.length===0)return;const c=t.name("valid");for(const d of a){if(l(d)){u(d)}else{t.if((0,Sg.propertyInData)(t,n,d,i.opts.ownProperties));u(d);if(!i.allErrors)t.else().var(c,true);t.endIf()}e.it.definedProperties.add(d);e.ok(c)}function l(d){return i.opts.useDefaults&&!i.compositeRule&&r[d].default!==void 0}function u(d){e.subschema({keyword:"properties",schemaProp:d,dataProp:d},c)}}};Od.default=AO});var kg=P(Pd=>{"use strict";Object.defineProperty(Pd,"__esModule",{value:true});var Og=ur();var cc=K();var Pg=ce();var Ag=ce();var kO={keyword:"patternProperties",type:"object",schemaType:"object",code(e){const{gen:t,schema:r,data:o,parentSchema:n,it:i}=e;const{opts:s}=i;const a=(0,Og.allSchemaProperties)(r);const c=a.filter(f=>(0,Pg.alwaysValidSchema)(i,r[f]));if(a.length===0||c.length===a.length&&(!i.opts.unevaluated||i.props===true)){return}const l=s.strictSchema&&!s.allowMatchingProperties&&n.properties;const u=t.name("valid");if(i.props!==true&&!(i.props instanceof cc.Name)){i.props=(0,Ag.evaluatedPropsToName)(t,i.props)}const{props:d}=i;x();function x(){for(const f of a){if(l)y(f);if(i.allErrors){m(f)}else{t.var(u,true);m(f);t.if(u)}}}function y(f){for(const h in l){if(new RegExp(f).test(h)){(0,Pg.checkStrictMode)(i,`property ${h} matches pattern ${f} (use allowMatchingProperties)`)}}}function m(f){t.forIn("key",o,h=>{t.if((0,cc._)`${(0,Og.usePattern)(e,f)}.test(${h})`,()=>{const _=c.includes(f);if(!_){e.subschema({keyword:"patternProperties",schemaProp:f,dataProp:h,dataPropType:Ag.Type.Str},u)}if(i.opts.unevaluated&&d!==true){t.assign((0,cc._)`${d}[${h}]`,true)}else if(!_&&!i.allErrors){t.if((0,cc.not)(u),()=>t.break())}})})}}};Pd.default=kO});var Eg=P(Ad=>{"use strict";Object.defineProperty(Ad,"__esModule",{value:true});var EO=ce();var $O={keyword:"not",schemaType:["object","boolean"],trackErrors:true,code(e){const{gen:t,schema:r,it:o}=e;if((0,EO.alwaysValidSchema)(o,r)){e.fail();return}const n=t.name("valid");e.subschema({keyword:"not",compositeRule:true,createErrors:false,allErrors:false},n);e.failResult(n,()=>e.reset(),()=>e.error())},error:{message:"must NOT be valid"}};Ad.default=$O});var $g=P(kd=>{"use strict";Object.defineProperty(kd,"__esModule",{value:true});var vO=ur();var CO={keyword:"anyOf",schemaType:"array",trackErrors:true,code:vO.validateUnion,error:{message:"must match a schema in anyOf"}};kd.default=CO});var vg=P(Ed=>{"use strict";Object.defineProperty(Ed,"__esModule",{value:true});var uc=K();var FO=ce();var NO={message:"must match exactly one schema in oneOf",params:({params:e})=>(0,uc._)`{passingSchemas: ${e.passing}}`};var jO={keyword:"oneOf",schemaType:"array",trackErrors:true,error:NO,code(e){const{gen:t,schema:r,parentSchema:o,it:n}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");if(n.opts.discriminator&&o.discriminator)return;const i=r;const s=t.let("valid",false);const a=t.let("passing",null);const c=t.name("_valid");e.setParams({passing:a});t.block(l);e.result(s,()=>e.reset(),()=>e.error(true));function l(){i.forEach((u,d)=>{let x;if((0,FO.alwaysValidSchema)(n,u)){t.var(c,true)}else{x=e.subschema({keyword:"oneOf",schemaProp:d,compositeRule:true},c)}if(d>0){t.if((0,uc._)`${c} && ${s}`).assign(s,false).assign(a,(0,uc._)`[${a}, ${d}]`).else()}t.if(c,()=>{t.assign(s,true);t.assign(a,d);if(x)e.mergeEvaluated(x,uc.Name)})})}}};Ed.default=jO});var Cg=P($d=>{"use strict";Object.defineProperty($d,"__esModule",{value:true});var zO=ce();var DO={keyword:"allOf",schemaType:"array",code(e){const{gen:t,schema:r,it:o}=e;if(!Array.isArray(r))throw new Error("ajv implementation error");const n=t.name("valid");r.forEach((i,s)=>{if((0,zO.alwaysValidSchema)(o,i))return;const a=e.subschema({keyword:"allOf",schemaProp:s},n);e.ok(n);e.mergeEvaluated(a)})}};$d.default=DO});var jg=P(vd=>{"use strict";Object.defineProperty(vd,"__esModule",{value:true});var lc=K();var Ng=ce();var UO={message:({params:e})=>(0,lc.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,lc._)`{failingKeyword: ${e.ifClause}}`};var LO={keyword:"if",schemaType:["object","boolean"],trackErrors:true,error:UO,code(e){const{gen:t,parentSchema:r,it:o}=e;if(r.then===void 0&&r.else===void 0){(0,Ng.checkStrictMode)(o,'"if" without "then" and "else" is ignored')}const n=Fg(o,"then");const i=Fg(o,"else");if(!n&&!i)return;const s=t.let("valid",true);const a=t.name("_valid");c();e.reset();if(n&&i){const u=t.let("ifClause");e.setParams({ifClause:u});t.if(a,l("then",u),l("else",u))}else if(n){t.if(a,l("then"))}else{t.if((0,lc.not)(a),l("else"))}e.pass(s,()=>e.error(true));function c(){const u=e.subschema({keyword:"if",compositeRule:true,createErrors:false,allErrors:false},a);e.mergeEvaluated(u)}function l(u,d){return()=>{const x=e.subschema({keyword:u},a);t.assign(s,a);e.mergeValidEvaluated(x,s);if(d)t.assign(d,(0,lc._)`${u}`);else e.setParams({ifClause:u})}}}};function Fg(e,t){const r=e.schema[t];return r!==void 0&&!(0,Ng.alwaysValidSchema)(e,r)}vd.default=LO});var zg=P(Cd=>{"use strict";Object.defineProperty(Cd,"__esModule",{value:true});var qO=ce();var KO={keyword:["then","else"],schemaType:["object","boolean"],code({keyword:e,parentSchema:t,it:r}){if(t.if===void 0)(0,qO.checkStrictMode)(r,`"${e}" without "if" is ignored`)}};Cd.default=KO});var Dg=P(Fd=>{"use strict";Object.defineProperty(Fd,"__esModule",{value:true});var GO=yd();var BO=hg();var VO=xd();var HO=yg();var WO=xg();var JO=bg();var XO=Tg();var YO=Md();var QO=Rg();var ZO=kg();var eP=Eg();var tP=$g();var rP=vg();var oP=Cg();var nP=jg();var iP=zg();function sP(e=false){const t=[eP.default,tP.default,rP.default,oP.default,nP.default,iP.default,XO.default,YO.default,JO.default,QO.default,ZO.default];if(e)t.push(BO.default,HO.default);else t.push(GO.default,VO.default);t.push(WO.default);return t}Fd.default=sP});var Ug=P(Nd=>{"use strict";Object.defineProperty(Nd,"__esModule",{value:true});var Be=K();var aP={message:({schemaCode:e})=>(0,Be.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,Be._)`{format: ${e}}`};var cP={keyword:"format",type:["number","string"],schemaType:"string",$data:true,error:aP,code(e,t){const{gen:r,data:o,$data:n,schema:i,schemaCode:s,it:a}=e;const{opts:c,errSchemaPath:l,schemaEnv:u,self:d}=a;if(!c.validateFormats)return;if(n)x();else y();function x(){const m=r.scopeValue("formats",{ref:d.formats,code:c.code.formats});const f=r.const("fDef",(0,Be._)`${m}[${s}]`);const h=r.let("fType");const _=r.let("format");r.if((0,Be._)`typeof ${f} == "object" && !(${f} instanceof RegExp)`,()=>r.assign(h,(0,Be._)`${f}.type || "string"`).assign(_,(0,Be._)`${f}.validate`),()=>r.assign(h,(0,Be._)`"string"`).assign(_,f));e.fail$data((0,Be.or)(I(),R()));function I(){if(c.strictSchema===false)return Be.nil;return(0,Be._)`${s} && !${_}`}function R(){const C=u.$async?(0,Be._)`(${f}.async ? await ${_}(${o}) : ${_}(${o}))`:(0,Be._)`${_}(${o})`;const k=(0,Be._)`(typeof ${_} == "function" ? ${C} : ${_}.test(${o}))`;return(0,Be._)`${_} && ${_} !== true && ${h} === ${t} && !${k}`}}function y(){const m=d.formats[i];if(!m){I();return}if(m===true)return;const[f,h,_]=R(m);if(f===t)e.pass(C());function I(){if(c.strictSchema===false){d.logger.warn(k());return}throw new Error(k());function k(){return`unknown format "${i}" ignored in schema at path "${l}"`}}function R(k){const Wr=k instanceof RegExp?(0,Be.regexpCode)(k):c.code.formats?(0,Be._)`${c.code.formats}${(0,Be.getProperty)(i)}`:void 0;const so=r.scopeValue("formats",{key:i,ref:k,code:Wr});if(typeof k=="object"&&!(k instanceof RegExp)){return[k.type||"string",k.validate,(0,Be._)`${so}.validate`]}return["string",k,so]}function C(){if(typeof m=="object"&&!(m instanceof RegExp)&&m.async){if(!u.$async)throw new Error("async format in sync schema");return(0,Be._)`await ${_}(${o})`}return typeof h=="function"?(0,Be._)`${_}(${o})`:(0,Be._)`${_}.test(${o})`}}}};Nd.default=cP});var Lg=P(jd=>{"use strict";Object.defineProperty(jd,"__esModule",{value:true});var uP=Ug();var lP=[uP.default];jd.default=lP});var qg=P(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:true});wi.contentVocabulary=wi.metadataVocabulary=void 0;wi.metadataVocabulary=["title","description","default","deprecated","readOnly","writeOnly","examples"];wi.contentVocabulary=["contentMediaType","contentEncoding","contentSchema"]});var Gg=P(zd=>{"use strict";Object.defineProperty(zd,"__esModule",{value:true});var dP=Yh();var pP=dg();var fP=Dg();var mP=Lg();var Kg=qg();var hP=[dP.default,pP.default,(0,fP.default)(),mP.default,Kg.metadataVocabulary,Kg.contentVocabulary];zd.default=hP});var Vg=P(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:true});dc.DiscrError=void 0;var Bg;(function(e){e["Tag"]="tag";e["Mapping"]="mapping"})(Bg||(dc.DiscrError=Bg={}))});var Wg=P(Ud=>{"use strict";Object.defineProperty(Ud,"__esModule",{value:true});var Ti=K();var Dd=Vg();var Hg=Va();var gP=Os();var yP=ce();var xP={message:({params:{discrError:e,tagName:t}})=>e===Dd.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:t,tagName:r}})=>(0,Ti._)`{error: ${e}, tag: ${r}, tagValue: ${t}}`};var _P={keyword:"discriminator",type:"object",schemaType:"object",error:xP,code(e){const{gen:t,data:r,schema:o,parentSchema:n,it:i}=e;const{oneOf:s}=n;if(!i.opts.discriminator){throw new Error("discriminator: requires discriminator option")}const a=o.propertyName;if(typeof a!="string")throw new Error("discriminator: requires propertyName");if(o.mapping)throw new Error("discriminator: mapping is not supported");if(!s)throw new Error("discriminator: requires oneOf keyword");const c=t.let("valid",false);const l=t.const("tag",(0,Ti._)`${r}${(0,Ti.getProperty)(a)}`);t.if((0,Ti._)`typeof ${l} == "string"`,()=>u(),()=>e.error(false,{discrError:Dd.DiscrError.Tag,tag:l,tagName:a}));e.ok(c);function u(){const y=x();t.if(false);for(const m in y){t.elseIf((0,Ti._)`${l} === ${m}`);t.assign(c,d(y[m]))}t.else();e.error(false,{discrError:Dd.DiscrError.Mapping,tag:l,tagName:a});t.endIf()}function d(y){const m=t.name("valid");const f=e.subschema({keyword:"oneOf",schemaProp:y},m);e.mergeEvaluated(f,Ti.Name);return m}function x(){var y;const m={};const f=_(n);let h=true;for(let C=0;C<s.length;C++){let k=s[C];if((k===null||k===void 0?void 0:k.$ref)&&!(0,yP.schemaHasRulesButRef)(k,i.self.RULES)){const so=k.$ref;k=Hg.resolveRef.call(i.self,i.schemaEnv.root,i.baseId,so);if(k instanceof Hg.SchemaEnv)k=k.schema;if(k===void 0)throw new gP.default(i.opts.uriResolver,i.baseId,so)}const Wr=(y=k===null||k===void 0?void 0:k.properties)===null||y===void 0?void 0:y[a];if(typeof Wr!="object"){throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${a}"`)}h=h&&(f||_(k));I(Wr,C)}if(!h)throw new Error(`discriminator: "${a}" must be required`);return m;function _({required:C}){return Array.isArray(C)&&C.includes(a)}function I(C,k){if(C.const){R(C.const,k)}else if(C.enum){for(const Wr of C.enum){R(Wr,k)}}else{throw new Error(`discriminator: "properties/${a}" must have "const" or "enum"`)}}function R(C,k){if(typeof C!="string"||C in m){throw new Error(`discriminator: "${a}" values must be unique strings`)}m[C]=k}}}};Ud.default=_P});var Jg=P((Aq,IP)=>{IP.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:true,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:true,readOnly:{type:"boolean",default:false},examples:{type:"array",items:true},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:true},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:false},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:true,enum:{type:"array",items:true,minItems:1,uniqueItems:true},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:true}]},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:true}});var qd=P((ke,Ld)=>{"use strict";Object.defineProperty(ke,"__esModule",{value:true});ke.MissingRefError=ke.ValidationError=ke.CodeGen=ke.Name=ke.nil=ke.stringify=ke.str=ke._=ke.KeywordCxt=ke.Ajv=void 0;var bP=Bh();var wP=Gg();var TP=Wg();var Xg=Jg();var SP=["/properties"];var pc="http://json-schema.org/draft-07/schema";var Si=class extends bP.default{_addVocabularies(){super._addVocabularies();wP.default.forEach(t=>this.addVocabulary(t));if(this.opts.discriminator)this.addKeyword(TP.default)}_addDefaultMetaSchema(){super._addDefaultMetaSchema();if(!this.opts.meta)return;const t=this.opts.$data?this.$dataMetaSchema(Xg,SP):Xg;this.addMetaSchema(t,pc,false);this.refs["http://json-schema.org/schema"]=pc}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(pc)?pc:void 0)}};ke.Ajv=Si;Ld.exports=ke=Si;Ld.exports.Ajv=Si;Object.defineProperty(ke,"__esModule",{value:true});ke.default=Si;var MP=Rs();Object.defineProperty(ke,"KeywordCxt",{enumerable:true,get:function(){return MP.KeywordCxt}});var Mi=K();Object.defineProperty(ke,"_",{enumerable:true,get:function(){return Mi._}});Object.defineProperty(ke,"str",{enumerable:true,get:function(){return Mi.str}});Object.defineProperty(ke,"stringify",{enumerable:true,get:function(){return Mi.stringify}});Object.defineProperty(ke,"nil",{enumerable:true,get:function(){return Mi.nil}});Object.defineProperty(ke,"Name",{enumerable:true,get:function(){return Mi.Name}});Object.defineProperty(ke,"CodeGen",{enumerable:true,get:function(){return Mi.CodeGen}});var RP=Ga();Object.defineProperty(ke,"ValidationError",{enumerable:true,get:function(){return RP.default}});var OP=Os();Object.defineProperty(ke,"MissingRefError",{enumerable:true,get:function(){return OP.default}})});var ny=P(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:true});Zr.formatNames=Zr.fastFormats=Zr.fullFormats=void 0;function Qr(e,t){return{validate:e,compare:t}}Zr.fullFormats={date:Qr(ey,Vd),time:Qr(Gd(true),Hd),"date-time":Qr(Yg(true),ry),"iso-time":Qr(Gd(),ty),"iso-date-time":Qr(Yg(),oy),duration:/^P(?!$)((\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+S)?)?|(\d+W)?)$/,uri:vP,"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:UP,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:CP,int32:{type:"number",validate:jP},int64:{type:"number",validate:zP},float:{type:"number",validate:Zg},double:{type:"number",validate:Zg},password:true,binary:true};Zr.fastFormats={...Zr.fullFormats,date:Qr(/^\d\d\d\d-[0-1]\d-[0-3]\d$/,Vd),time:Qr(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,Hd),"date-time":Qr(/^\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,ry),"iso-time":Qr(/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,ty),"iso-date-time":Qr(/^\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,oy),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};Zr.formatNames=Object.keys(Zr.fullFormats);function PP(e){return e%4===0&&(e%100!==0||e%400===0)}var AP=/^(\d\d\d\d)-(\d\d)-(\d\d)$/;var kP=[0,31,28,31,30,31,30,31,31,30,31,30,31];function ey(e){const t=AP.exec(e);if(!t)return false;const r=+t[1];const o=+t[2];const n=+t[3];return o>=1&&o<=12&&n>=1&&n<=(o===2&&PP(r)?29:kP[o])}function Vd(e,t){if(!(e&&t))return void 0;if(e>t)return 1;if(e<t)return-1;return 0}var Kd=/^(\d\d):(\d\d):(\d\d(?:\.\d+)?)(z|([+-])(\d\d)(?::?(\d\d))?)?$/i;function Gd(e){return function t(r){const o=Kd.exec(r);if(!o)return false;const n=+o[1];const i=+o[2];const s=+o[3];const a=o[4];const c=o[5]==="-"?-1:1;const l=+(o[6]||0);const u=+(o[7]||0);if(l>23||u>59||e&&!a)return false;if(n<=23&&i<=59&&s<60)return true;const d=i-u*c;const x=n-l*c-(d<0?1:0);return(x===23||x===-1)&&(d===59||d===-1)&&s<61}}function Hd(e,t){if(!(e&&t))return void 0;const r=new Date("2020-01-01T"+e).valueOf();const o=new Date("2020-01-01T"+t).valueOf();if(!(r&&o))return void 0;return r-o}function ty(e,t){if(!(e&&t))return void 0;const r=Kd.exec(e);const o=Kd.exec(t);if(!(r&&o))return void 0;e=r[1]+r[2]+r[3];t=o[1]+o[2]+o[3];if(e>t)return 1;if(e<t)return-1;return 0}var Bd=/t|\s/i;function Yg(e){const t=Gd(e);return function r(o){const n=o.split(Bd);return n.length===2&&ey(n[0])&&t(n[1])}}function ry(e,t){if(!(e&&t))return void 0;const r=new Date(e).valueOf();const o=new Date(t).valueOf();if(!(r&&o))return void 0;return r-o}function oy(e,t){if(!(e&&t))return void 0;const[r,o]=e.split(Bd);const[n,i]=t.split(Bd);const s=Vd(r,n);if(s===void 0)return void 0;return s||Hd(o,i)}var EP=/\/|:/;var $P=/^(?:[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 vP(e){return EP.test(e)&&$P.test(e)}var Qg=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/gm;function CP(e){Qg.lastIndex=0;return Qg.test(e)}var FP=-(2**31);var NP=2**31-1;function jP(e){return Number.isInteger(e)&&e<=NP&&e>=FP}function zP(e){return Number.isInteger(e)}function Zg(){return true}var DP=/[^\\]\\Z/;function UP(e){if(DP.test(e))return false;try{new RegExp(e);return true}catch(t){return false}}});var iy=P(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:true});Ri.formatLimitDefinition=void 0;var LP=qd();var Mr=K();var No=Mr.operators;var fc={formatMaximum:{okStr:"<=",ok:No.LTE,fail:No.GT},formatMinimum:{okStr:">=",ok:No.GTE,fail:No.LT},formatExclusiveMaximum:{okStr:"<",ok:No.LT,fail:No.GTE},formatExclusiveMinimum:{okStr:">",ok:No.GT,fail:No.LTE}};var qP={message:({keyword:e,schemaCode:t})=>(0,Mr.str)`should be ${fc[e].okStr} ${t}`,params:({keyword:e,schemaCode:t})=>(0,Mr._)`{comparison: ${fc[e].okStr}, limit: ${t}}`};Ri.formatLimitDefinition={keyword:Object.keys(fc),type:"string",schemaType:"string",$data:true,error:qP,code(e){const{gen:t,data:r,schemaCode:o,keyword:n,it:i}=e;const{opts:s,self:a}=i;if(!s.validateFormats)return;const c=new LP.KeywordCxt(i,a.RULES.all.format.definition,"format");if(c.$data)l();else u();function l(){const x=t.scopeValue("formats",{ref:a.formats,code:s.code.formats});const y=t.const("fmt",(0,Mr._)`${x}[${c.schemaCode}]`);e.fail$data((0,Mr.or)((0,Mr._)`typeof ${y} != "object"`,(0,Mr._)`${y} instanceof RegExp`,(0,Mr._)`typeof ${y}.compare != "function"`,d(y)))}function u(){const x=c.schema;const y=a.formats[x];if(!y||y===true)return;if(typeof y!="object"||y instanceof RegExp||typeof y.compare!="function"){throw new Error(`"${n}": format "${x}" does not define "compare" function`)}const m=t.scopeValue("formats",{key:x,ref:y,code:s.code.formats?(0,Mr._)`${s.code.formats}${(0,Mr.getProperty)(x)}`:void 0});e.fail$data(d(m))}function d(x){return(0,Mr._)`${x}.compare(${r}, ${o}) ${fc[n].fail} 0`}},dependencies:["format"]};var KP=e=>{e.addKeyword(Ri.formatLimitDefinition);return e};Ri.default=KP});var uy=P((qs,cy)=>{"use strict";Object.defineProperty(qs,"__esModule",{value:true});var Oi=ny();var GP=iy();var Wd=K();var sy=new Wd.Name("fullFormats");var BP=new Wd.Name("fastFormats");var Jd=(e,t={keywords:true})=>{if(Array.isArray(t)){ay(e,t,Oi.fullFormats,sy);return e}const[r,o]=t.mode==="fast"?[Oi.fastFormats,BP]:[Oi.fullFormats,sy];const n=t.formats||Oi.formatNames;ay(e,n,r,o);if(t.keywords)(0,GP.default)(e);return e};Jd.get=(e,t="full")=>{const r=t==="fast"?Oi.fastFormats:Oi.fullFormats;const o=r[e];if(!o)throw new Error(`Unknown format "${e}"`);return o};function ay(e,t,r,o){var n;var i;(n=(i=e.opts.code).formats)!==null&&n!==void 0?n:i.formats=(0,Wd._)`require("ajv-formats/dist/formats").${o}`;for(const s of t)e.addFormat(s,r[s])}cy.exports=qs=Jd;Object.defineProperty(qs,"__esModule",{value:true});qs.default=Jd});import{delimiter as $U}from"node:path";function ma(e){const t=e;return!!t._zod}function Ro(e,t){if(ma(e)){const n=Au(e,t);return n}const r=e;const o=r.safeParse(t);return o}function ha(e){if(!e)return void 0;let t;if(ma(e)){const r=e;t=r._zod?.def?.shape}else{const r=e;t=r.shape}if(!t)return void 0;if(typeof t==="function"){try{return t()}catch{return void 0}}return t}function ga(e){if(ma(e)){const n=e;const i=n._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0){return i.values[0]}}}const t=e;const r=t._def;if(r){if(r.value!==void 0)return r.value;if(Array.isArray(r.values)&&r.values.length>0){return r.values[0]}}const o=e.value;if(o!==void 0)return o;return void 0}var Cu="2025-11-25";var Hf=[Cu,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"];var Oo="io.modelcontextprotocol/related-task";var xa="2.0";var et=Vf(e=>e!==null&&(typeof e==="object"||typeof e==="function"));var Wf=Ne([T(),_e().int()]);var Jf=T();var JU=Rt({ttl:_e().optional(),pollInterval:_e().optional()});var nw=A({ttl:_e().optional()});var iw=A({taskId:T()});var Fu=Rt({progressToken:Wf.optional(),[Oo]:iw.optional()});var Vt=A({_meta:Fu.optional()});var rs=Vt.extend({task:nw.optional()});var Xf=e=>rs.safeParse(e).success;var ut=A({method:T(),params:Vt.loose().optional()});var sr=A({_meta:Fu.optional()});var ar=A({method:T(),params:sr.loose().optional()});var lt=Rt({_meta:Fu.optional()});var _a=Ne([T(),_e().int()]);var Yf=A({jsonrpc:$(xa),id:_a,...ut.shape}).strict();var Nu=e=>Yf.safeParse(e).success;var Qf=A({jsonrpc:$(xa),...ar.shape}).strict();var Zf=e=>Qf.safeParse(e).success;var ju=A({jsonrpc:$(xa),id:_a,result:lt}).strict();var os=e=>ju.safeParse(e).success;var te;(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"})(te||(te={}));var zu=A({jsonrpc:$(xa),id:_a.optional(),error:A({code:_e().int(),message:T(),data:Ge().optional()})}).strict();var em=e=>zu.safeParse(e).success;var tm=Ne([Yf,Qf,ju,zu]);var XU=Ne([ju,zu]);var Ia=lt.strict();var sw=sr.extend({requestId:_a.optional(),reason:T().optional()});var ba=ar.extend({method:$("notifications/cancelled"),params:sw});var aw=A({src:T(),mimeType:T().optional(),sizes:ae(T()).optional(),theme:Bt(["light","dark"]).optional()});var ns=A({icons:ae(aw).optional()});var ai=A({name:T(),title:T().optional()});var rm=ai.extend({...ai.shape,...ns.shape,version:T(),websiteUrl:T().optional(),description:T().optional()});var cw=Eu(A({applyDefaults:rt().optional()}),Oe(T(),Ge()));var uw=$u(e=>{if(e&&typeof e==="object"&&!Array.isArray(e)){if(Object.keys(e).length===0){return{form:{}}}}return e},Eu(A({form:cw.optional(),url:et.optional()}),Oe(T(),Ge()).optional()));var lw=Rt({list:et.optional(),cancel:et.optional(),requests:Rt({sampling:Rt({createMessage:et.optional()}).optional(),elicitation:Rt({create:et.optional()}).optional()}).optional()});var dw=Rt({list:et.optional(),cancel:et.optional(),requests:Rt({tools:Rt({call:et.optional()}).optional()}).optional()});var pw=A({experimental:Oe(T(),et).optional(),sampling:A({context:et.optional(),tools:et.optional()}).optional(),elicitation:uw.optional(),roots:A({listChanged:rt().optional()}).optional(),tasks:lw.optional(),extensions:Oe(T(),et).optional()});var fw=Vt.extend({protocolVersion:T(),capabilities:pw,clientInfo:rm});var Du=ut.extend({method:$("initialize"),params:fw});var mw=A({experimental:Oe(T(),et).optional(),logging:et.optional(),completions:et.optional(),prompts:A({listChanged:rt().optional()}).optional(),resources:A({subscribe:rt().optional(),listChanged:rt().optional()}).optional(),tools:A({listChanged:rt().optional()}).optional(),tasks:dw.optional(),extensions:Oe(T(),et).optional()});var hw=lt.extend({protocolVersion:T(),capabilities:mw,serverInfo:rm,instructions:T().optional()});var Uu=ar.extend({method:$("notifications/initialized"),params:sr.optional()});var wa=ut.extend({method:$("ping"),params:Vt.optional()});var gw=A({progress:_e(),total:qe(_e()),message:qe(T())});var yw=A({...sr.shape,...gw.shape,progressToken:Wf});var Ta=ar.extend({method:$("notifications/progress"),params:yw});var xw=Vt.extend({cursor:Jf.optional()});var is=ut.extend({params:xw.optional()});var ss=lt.extend({nextCursor:Jf.optional()});var _w=Bt(["working","input_required","completed","failed","cancelled"]);var as=A({taskId:T(),status:_w,ttl:Ne([_e(),Bf()]),createdAt:T(),lastUpdatedAt:T(),pollInterval:qe(_e()),statusMessage:qe(T())});var ci=lt.extend({task:as});var Iw=sr.merge(as);var cs=ar.extend({method:$("notifications/tasks/status"),params:Iw});var Sa=ut.extend({method:$("tasks/get"),params:Vt.extend({taskId:T()})});var Ma=lt.merge(as);var Ra=ut.extend({method:$("tasks/result"),params:Vt.extend({taskId:T()})});var YU=lt.loose();var Oa=is.extend({method:$("tasks/list")});var Pa=ss.extend({tasks:ae(as)});var Aa=ut.extend({method:$("tasks/cancel"),params:Vt.extend({taskId:T()})});var om=lt.merge(as);var nm=A({uri:T(),mimeType:qe(T()),_meta:Oe(T(),Ge()).optional()});var im=nm.extend({text:T()});var Lu=T().refine(e=>{try{atob(e);return true}catch{return false}},{message:"Invalid Base64 string"});var sm=nm.extend({blob:Lu});var us=Bt(["user","assistant"]);var ui=A({audience:ae(us).optional(),priority:_e().min(0).max(1).optional(),lastModified:Gf.datetime({offset:true}).optional()});var am=A({...ai.shape,...ns.shape,uri:T(),description:qe(T()),mimeType:qe(T()),size:qe(_e()),annotations:ui.optional(),_meta:qe(Rt({}))});var bw=A({...ai.shape,...ns.shape,uriTemplate:T(),description:qe(T()),mimeType:qe(T()),annotations:ui.optional(),_meta:qe(Rt({}))});var ww=is.extend({method:$("resources/list")});var Tw=ss.extend({resources:ae(am)});var Sw=is.extend({method:$("resources/templates/list")});var Mw=ss.extend({resourceTemplates:ae(bw)});var qu=Vt.extend({uri:T()});var Rw=qu;var Ow=ut.extend({method:$("resources/read"),params:Rw});var Pw=lt.extend({contents:ae(Ne([im,sm]))});var Aw=ar.extend({method:$("notifications/resources/list_changed"),params:sr.optional()});var kw=qu;var Ew=ut.extend({method:$("resources/subscribe"),params:kw});var $w=qu;var vw=ut.extend({method:$("resources/unsubscribe"),params:$w});var Cw=sr.extend({uri:T()});var Fw=ar.extend({method:$("notifications/resources/updated"),params:Cw});var Nw=A({name:T(),description:qe(T()),required:qe(rt())});var jw=A({...ai.shape,...ns.shape,description:qe(T()),arguments:qe(ae(Nw)),_meta:qe(Rt({}))});var zw=is.extend({method:$("prompts/list")});var Dw=ss.extend({prompts:ae(jw)});var Uw=Vt.extend({name:T(),arguments:Oe(T(),T()).optional()});var Lw=ut.extend({method:$("prompts/get"),params:Uw});var Ku=A({type:$("text"),text:T(),annotations:ui.optional(),_meta:Oe(T(),Ge()).optional()});var Gu=A({type:$("image"),data:Lu,mimeType:T(),annotations:ui.optional(),_meta:Oe(T(),Ge()).optional()});var Bu=A({type:$("audio"),data:Lu,mimeType:T(),annotations:ui.optional(),_meta:Oe(T(),Ge()).optional()});var qw=A({type:$("tool_use"),name:T(),id:T(),input:Oe(T(),Ge()),_meta:Oe(T(),Ge()).optional()});var Kw=A({type:$("resource"),resource:Ne([im,sm]),annotations:ui.optional(),_meta:Oe(T(),Ge()).optional()});var Gw=am.extend({type:$("resource_link")});var Vu=Ne([Ku,Gu,Bu,Gw,Kw]);var Bw=A({role:us,content:Vu});var Vw=lt.extend({description:T().optional(),messages:ae(Bw)});var Hw=ar.extend({method:$("notifications/prompts/list_changed"),params:sr.optional()});var Ww=A({title:T().optional(),readOnlyHint:rt().optional(),destructiveHint:rt().optional(),idempotentHint:rt().optional(),openWorldHint:rt().optional()});var Jw=A({taskSupport:Bt(["required","optional","forbidden"]).optional()});var cm=A({...ai.shape,...ns.shape,description:T().optional(),inputSchema:A({type:$("object"),properties:Oe(T(),et).optional(),required:ae(T()).optional()}).catchall(Ge()),outputSchema:A({type:$("object"),properties:Oe(T(),et).optional(),required:ae(T()).optional()}).catchall(Ge()).optional(),annotations:Ww.optional(),execution:Jw.optional(),_meta:Oe(T(),Ge()).optional()});var Hu=is.extend({method:$("tools/list")});var Xw=ss.extend({tools:ae(cm)});var ka=lt.extend({content:ae(Vu).default([]),structuredContent:Oe(T(),Ge()).optional(),isError:rt().optional()});var QU=ka.or(lt.extend({toolResult:Ge()}));var Yw=rs.extend({name:T(),arguments:Oe(T(),Ge()).optional()});var ls=ut.extend({method:$("tools/call"),params:Yw});var Qw=ar.extend({method:$("notifications/tools/list_changed"),params:sr.optional()});var ZU=A({autoRefresh:rt().default(true),debounceMs:_e().int().nonnegative().default(300)});var ds=Bt(["debug","info","notice","warning","error","critical","alert","emergency"]);var Zw=Vt.extend({level:ds});var Wu=ut.extend({method:$("logging/setLevel"),params:Zw});var eT=sr.extend({level:ds,logger:T().optional(),data:Ge()});var tT=ar.extend({method:$("notifications/message"),params:eT});var rT=A({name:T().optional()});var oT=A({hints:ae(rT).optional(),costPriority:_e().min(0).max(1).optional(),speedPriority:_e().min(0).max(1).optional(),intelligencePriority:_e().min(0).max(1).optional()});var nT=A({mode:Bt(["auto","required","none"]).optional()});var iT=A({type:$("tool_result"),toolUseId:T().describe("The unique identifier for the corresponding tool call."),content:ae(Vu).default([]),structuredContent:A({}).loose().optional(),isError:rt().optional(),_meta:Oe(T(),Ge()).optional()});var sT=ku("type",[Ku,Gu,Bu]);var ya=ku("type",[Ku,Gu,Bu,qw,iT]);var aT=A({role:us,content:Ne([ya,ae(ya)]),_meta:Oe(T(),Ge()).optional()});var cT=rs.extend({messages:ae(aT),modelPreferences:oT.optional(),systemPrompt:T().optional(),includeContext:Bt(["none","thisServer","allServers"]).optional(),temperature:_e().optional(),maxTokens:_e().int(),stopSequences:ae(T()).optional(),metadata:et.optional(),tools:ae(cm).optional(),toolChoice:nT.optional()});var uT=ut.extend({method:$("sampling/createMessage"),params:cT});var ps=lt.extend({model:T(),stopReason:qe(Bt(["endTurn","stopSequence","maxTokens"]).or(T())),role:us,content:sT});var Ju=lt.extend({model:T(),stopReason:qe(Bt(["endTurn","stopSequence","maxTokens","toolUse"]).or(T())),role:us,content:Ne([ya,ae(ya)])});var lT=A({type:$("boolean"),title:T().optional(),description:T().optional(),default:rt().optional()});var dT=A({type:$("string"),title:T().optional(),description:T().optional(),minLength:_e().optional(),maxLength:_e().optional(),format:Bt(["email","uri","date","date-time"]).optional(),default:T().optional()});var pT=A({type:Bt(["number","integer"]),title:T().optional(),description:T().optional(),minimum:_e().optional(),maximum:_e().optional(),default:_e().optional()});var fT=A({type:$("string"),title:T().optional(),description:T().optional(),enum:ae(T()),default:T().optional()});var mT=A({type:$("string"),title:T().optional(),description:T().optional(),oneOf:ae(A({const:T(),title:T()})),default:T().optional()});var hT=A({type:$("string"),title:T().optional(),description:T().optional(),enum:ae(T()),enumNames:ae(T()).optional(),default:T().optional()});var gT=Ne([fT,mT]);var yT=A({type:$("array"),title:T().optional(),description:T().optional(),minItems:_e().optional(),maxItems:_e().optional(),items:A({type:$("string"),enum:ae(T())}),default:ae(T()).optional()});var xT=A({type:$("array"),title:T().optional(),description:T().optional(),minItems:_e().optional(),maxItems:_e().optional(),items:A({anyOf:ae(A({const:T(),title:T()}))}),default:ae(T()).optional()});var _T=Ne([yT,xT]);var IT=Ne([hT,gT,_T]);var bT=Ne([IT,lT,dT,pT]);var wT=rs.extend({mode:$("form").optional(),message:T(),requestedSchema:A({type:$("object"),properties:Oe(T(),bT),required:ae(T()).optional()})});var TT=rs.extend({mode:$("url"),message:T(),elicitationId:T(),url:T().url()});var ST=Ne([wT,TT]);var MT=ut.extend({method:$("elicitation/create"),params:ST});var RT=sr.extend({elicitationId:T()});var OT=ar.extend({method:$("notifications/elicitation/complete"),params:RT});var li=lt.extend({action:Bt(["accept","decline","cancel"]),content:$u(e=>e===null?void 0:e,Oe(T(),Ne([T(),_e(),rt(),ae(T())])).optional())});var PT=A({type:$("ref/resource"),uri:T()});var AT=A({type:$("ref/prompt"),name:T()});var kT=Vt.extend({ref:Ne([AT,PT]),argument:A({name:T(),value:T()}),context:A({arguments:Oe(T(),T()).optional()}).optional()});var ET=ut.extend({method:$("completion/complete"),params:kT});var $T=lt.extend({completion:Rt({values:ae(T()).max(100),total:qe(_e().int()),hasMore:qe(rt())})});var vT=A({uri:T().startsWith("file://"),name:T().optional(),_meta:Oe(T(),Ge()).optional()});var CT=ut.extend({method:$("roots/list"),params:Vt.optional()});var Xu=lt.extend({roots:ae(vT)});var FT=ar.extend({method:$("notifications/roots/list_changed"),params:sr.optional()});var eL=Ne([wa,Du,ET,Wu,Lw,zw,ww,Sw,Ow,Ew,vw,ls,Hu,Sa,Ra,Oa,Aa]);var tL=Ne([ba,Ta,Uu,FT,cs]);var rL=Ne([Ia,ps,Ju,li,Xu,Ma,Pa,ci]);var oL=Ne([wa,uT,MT,CT,Sa,Ra,Oa,Aa]);var nL=Ne([ba,Ta,tT,Fw,Aw,Qw,Hw,cs,OT]);var iL=Ne([Ia,hw,$T,Vw,Dw,Tw,Mw,Pw,ka,Xw,Ma,Pa,ci]);var U=class e extends Error{constructor(t,r,o){super(`MCP error ${t}: ${r}`);this.code=t;this.data=o;this.name="McpError"}static fromError(t,r,o){if(t===te.UrlElicitationRequired&&o){const n=o;if(n.elicitations){return new vu(n.elicitations,r)}}return new e(t,r,o)}};var vu=class extends U{constructor(t,r=`URL elicitation${t.length>1?"s":""} required`){super(te.UrlElicitationRequired,r,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}};function Po(e){return e==="completed"||e==="failed"||e==="cancelled"}function Yu(e){const t=ha(e);const r=t?.method;if(!r){throw new Error("Schema is missing a method literal")}const o=ga(r);if(typeof o!=="string"){throw new Error("Schema method literal must be a string")}return o}function Qu(e,t){const r=Ro(e,t);if(!r.success){throw r.error}return r.data}var NT=6e4;var Ea=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(ba,r=>{this._oncancel(r)});this.setNotificationHandler(Ta,r=>{this._onprogress(r)});this.setRequestHandler(wa,r=>({}));this._taskStore=t?.taskStore;this._taskMessageQueue=t?.taskMessageQueue;if(this._taskStore){this.setRequestHandler(Sa,async(r,o)=>{const n=await this._taskStore.getTask(r.params.taskId,o.sessionId);if(!n){throw new U(te.InvalidParams,"Failed to retrieve task: Task not found")}return{...n}});this.setRequestHandler(Ra,async(r,o)=>{const n=async()=>{const i=r.params.taskId;if(this._taskMessageQueue){let a;while(a=await this._taskMessageQueue.dequeue(i,o.sessionId)){if(a.type==="response"||a.type==="error"){const c=a.message;const l=c.id;const u=this._requestResolvers.get(l);if(u){this._requestResolvers.delete(l);if(a.type==="response"){u(c)}else{const d=c;const x=new U(d.error.code,d.error.message,d.error.data);u(x)}}else{const d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${l}`))}continue}await this._transport?.send(a.message,{relatedRequestId:o.requestId})}}const s=await this._taskStore.getTask(i,o.sessionId);if(!s){throw new U(te.InvalidParams,`Task not found: ${i}`)}if(!Po(s.status)){await this._waitForTaskUpdate(i,o.signal);return await n()}if(Po(s.status)){const a=await this._taskStore.getTaskResult(i,o.sessionId);this._clearTaskQueue(i);return{...a,_meta:{...a._meta,[Oo]:{taskId:i}}}}return await n()};return await n()});this.setRequestHandler(Oa,async(r,o)=>{try{const{tasks:n,nextCursor:i}=await this._taskStore.listTasks(r.params?.cursor,o.sessionId);return{tasks:n,nextCursor:i,_meta:{}}}catch(n){throw new U(te.InvalidParams,`Failed to list tasks: ${n instanceof Error?n.message:String(n)}`)}});this.setRequestHandler(Aa,async(r,o)=>{try{const n=await this._taskStore.getTask(r.params.taskId,o.sessionId);if(!n){throw new U(te.InvalidParams,`Task not found: ${r.params.taskId}`)}if(Po(n.status)){throw new U(te.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`)}await this._taskStore.updateTaskStatus(r.params.taskId,"cancelled","Client cancelled task execution.",o.sessionId);this._clearTaskQueue(r.params.taskId);const i=await this._taskStore.getTask(r.params.taskId,o.sessionId);if(!i){throw new U(te.InvalidParams,`Task not found after cancellation: ${r.params.taskId}`)}return{_meta:{},...i}}catch(n){if(n instanceof U){throw n}throw new U(te.InvalidRequest,`Failed to cancel task: ${n instanceof Error?n.message:String(n)}`)}})}}async _oncancel(t){if(!t.params.requestId){return}const r=this._requestHandlerAbortControllers.get(t.params.requestId);r?.abort(t.params.reason)}_setupTimeout(t,r,o,n,i=false){this._timeoutInfo.set(t,{timeoutId:setTimeout(n,r),startTime:Date.now(),timeout:r,maxTotalTimeout:o,resetTimeoutOnProgress:i,onTimeout:n})}_resetTimeout(t){const r=this._timeoutInfo.get(t);if(!r)return false;const o=Date.now()-r.startTime;if(r.maxTotalTimeout&&o>=r.maxTotalTimeout){this._timeoutInfo.delete(t);throw U.fromError(te.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:r.maxTotalTimeout,totalElapsed:o})}clearTimeout(r.timeoutId);r.timeoutId=setTimeout(r.onTimeout,r.timeout);return true}_cleanupTimeout(t){const r=this._timeoutInfo.get(t);if(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;const r=this.transport?.onclose;this._transport.onclose=()=>{r?.();this._onclose()};const o=this.transport?.onerror;this._transport.onerror=i=>{o?.(i);this._onerror(i)};const n=this._transport?.onmessage;this._transport.onmessage=(i,s)=>{n?.(i,s);if(os(i)||em(i)){this._onresponse(i)}else if(Nu(i)){this._onrequest(i,s)}else if(Zf(i)){this._onnotification(i)}else{this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`))}};await this._transport.start()}_onclose(){const t=this._responseHandlers;this._responseHandlers=new Map;this._progressHandlers.clear();this._taskProgressTokens.clear();this._pendingDebouncedNotifications.clear();for(const o of this._timeoutInfo.values()){clearTimeout(o.timeoutId)}this._timeoutInfo.clear();for(const o of this._requestHandlerAbortControllers.values()){o.abort()}this._requestHandlerAbortControllers.clear();const r=U.fromError(te.ConnectionClosed,"Connection closed");this._transport=void 0;this.onclose?.();for(const o of t.values()){o(r)}}_onerror(t){this.onerror?.(t)}_onnotification(t){const r=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;if(r===void 0){return}Promise.resolve().then(()=>r(t)).catch(o=>this._onerror(new Error(`Uncaught error in notification handler: ${o}`)))}_onrequest(t,r){const o=this._requestHandlers.get(t.method)??this.fallbackRequestHandler;const n=this._transport;const i=t.params?._meta?.[Oo]?.taskId;if(o===void 0){const u={jsonrpc:"2.0",id:t.id,error:{code:te.MethodNotFound,message:"Method not found"}};if(i&&this._taskMessageQueue){this._enqueueTaskMessage(i,{type:"error",message:u,timestamp:Date.now()},n?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`)))}else{n?.send(u).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)))}return}const s=new AbortController;this._requestHandlerAbortControllers.set(t.id,s);const a=Xf(t.params)?t.params.task:void 0;const c=this._taskStore?this.requestTaskStore(t,n?.sessionId):void 0;const l={signal:s.signal,sessionId:n?.sessionId,_meta:t.params?._meta,sendNotification:async u=>{if(s.signal.aborted)return;const d={relatedRequestId:t.id};if(i){d.relatedTask={taskId:i}}await this.notification(u,d)},sendRequest:async(u,d,x)=>{if(s.signal.aborted){throw new U(te.ConnectionClosed,"Request was cancelled")}const y={...x,relatedRequestId:t.id};if(i&&!y.relatedTask){y.relatedTask={taskId:i}}const m=y.relatedTask?.taskId??i;if(m&&c){await c.updateTaskStatus(m,"input_required")}return await this.request(u,d,y)},authInfo:r?.authInfo,requestId:t.id,requestInfo:r?.requestInfo,taskId:i,taskStore:c,taskRequestedTtl:a?.ttl,closeSSEStream:r?.closeSSEStream,closeStandaloneSSEStream:r?.closeStandaloneSSEStream};Promise.resolve().then(()=>{if(a){this.assertTaskHandlerCapability(t.method)}}).then(()=>o(t,l)).then(async u=>{if(s.signal.aborted){return}const d={result:u,jsonrpc:"2.0",id:t.id};if(i&&this._taskMessageQueue){await this._enqueueTaskMessage(i,{type:"response",message:d,timestamp:Date.now()},n?.sessionId)}else{await n?.send(d)}},async u=>{if(s.signal.aborted){return}const d={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(u["code"])?u["code"]:te.InternalError,message:u.message??"Internal error",...u["data"]!==void 0&&{data:u["data"]}}};if(i&&this._taskMessageQueue){await this._enqueueTaskMessage(i,{type:"error",message:d,timestamp:Date.now()},n?.sessionId)}else{await n?.send(d)}}).catch(u=>this._onerror(new Error(`Failed to send response: ${u}`))).finally(()=>{if(this._requestHandlerAbortControllers.get(t.id)===s){this._requestHandlerAbortControllers.delete(t.id)}})}_onprogress(t){const{progressToken:r,...o}=t.params;const n=Number(r);const i=this._progressHandlers.get(n);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const s=this._responseHandlers.get(n);const a=this._timeoutInfo.get(n);if(a&&s&&a.resetTimeoutOnProgress){try{this._resetTimeout(n)}catch(c){this._responseHandlers.delete(n);this._progressHandlers.delete(n);this._cleanupTimeout(n);s(c);return}}i(o)}_onresponse(t){const r=Number(t.id);const o=this._requestResolvers.get(r);if(o){this._requestResolvers.delete(r);if(os(t)){o(t)}else{const s=new U(t.error.code,t.error.message,t.error.data);o(s)}return}const n=this._responseHandlers.get(r);if(n===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 i=false;if(os(t)&&t.result&&typeof t.result==="object"){const s=t.result;if(s.task&&typeof s.task==="object"){const a=s.task;if(typeof a.taskId==="string"){i=true;this._taskProgressTokens.set(a.taskId,r)}}}if(!i){this._progressHandlers.delete(r)}if(os(t)){n(t)}else{const s=U.fromError(t.error.code,t.error.message,t.error.data);n(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,r,o){const{task:n}=o??{};if(!n){try{const s=await this.request(t,r,o);yield{type:"result",result:s}}catch(s){yield{type:"error",error:s instanceof U?s:new U(te.InternalError,String(s))}}return}let i;try{const s=await this.request(t,ci,o);if(s.task){i=s.task.taskId;yield{type:"taskCreated",task:s.task}}else{throw new U(te.InternalError,"Task creation did not return a task")}while(true){const a=await this.getTask({taskId:i},o);yield{type:"taskStatus",task:a};if(Po(a.status)){if(a.status==="completed"){const l=await this.getTaskResult({taskId:i},r,o);yield{type:"result",result:l}}else if(a.status==="failed"){yield{type:"error",error:new U(te.InternalError,`Task ${i} failed`)}}else if(a.status==="cancelled"){yield{type:"error",error:new U(te.InternalError,`Task ${i} was cancelled`)}}return}if(a.status==="input_required"){const l=await this.getTaskResult({taskId:i},r,o);yield{type:"result",result:l};return}const c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(l=>setTimeout(l,c));o?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof U?s:new U(te.InternalError,String(s))}}}request(t,r,o){const{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s,task:a,relatedTask:c}=o??{};return new Promise((l,u)=>{const d=I=>{u(I)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===true){try{this.assertCapabilityForMethod(t.method);if(a){this.assertTaskCapability(t.method)}}catch(I){d(I);return}}o?.signal?.throwIfAborted();const x=this._requestMessageId++;const y={...t,jsonrpc:"2.0",id:x};if(o?.onprogress){this._progressHandlers.set(x,o.onprogress);y.params={...t.params,_meta:{...t.params?._meta||{},progressToken:x}}}if(a){y.params={...y.params,task:a}}if(c){y.params={...y.params,_meta:{...y.params?._meta||{},[Oo]:c}}}const m=I=>{this._responseHandlers.delete(x);this._progressHandlers.delete(x);this._cleanupTimeout(x);this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:x,reason:String(I)}},{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s}).catch(C=>this._onerror(new Error(`Failed to send cancellation: ${C}`)));const R=I instanceof U?I:new U(te.RequestTimeout,String(I));u(R)};this._responseHandlers.set(x,I=>{if(o?.signal?.aborted){return}if(I instanceof Error){return u(I)}try{const R=Ro(r,I.result);if(!R.success){u(R.error)}else{l(R.data)}}catch(R){u(R)}});o?.signal?.addEventListener("abort",()=>{m(o?.signal?.reason)});const f=o?.timeout??NT;const h=()=>m(U.fromError(te.RequestTimeout,"Request timed out",{timeout:f}));this._setupTimeout(x,f,o?.maxTotalTimeout,h,o?.resetTimeoutOnProgress??false);const _=c?.taskId;if(_){const I=R=>{const C=this._responseHandlers.get(x);if(C){C(R)}else{this._onerror(new Error(`Response handler missing for side-channeled request ${x}`))}};this._requestResolvers.set(x,I);this._enqueueTaskMessage(_,{type:"request",message:y,timestamp:Date.now()}).catch(R=>{this._cleanupTimeout(x);u(R)})}else{this._transport.send(y,{relatedRequestId:n,resumptionToken:i,onresumptiontoken:s}).catch(I=>{this._cleanupTimeout(x);u(I)})}})}async getTask(t,r){return this.request({method:"tasks/get",params:t},Ma,r)}async getTaskResult(t,r,o){return this.request({method:"tasks/result",params:t},r,o)}async listTasks(t,r){return this.request({method:"tasks/list",params:t},Pa,r)}async cancelTask(t,r){return this.request({method:"tasks/cancel",params:t},om,r)}async notification(t,r){if(!this._transport){throw new Error("Not connected")}this.assertNotificationCapability(t.method);const o=r?.relatedTask?.taskId;if(o){const a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Oo]:r.relatedTask}}};await this._enqueueTaskMessage(o,{type:"notification",message:a,timestamp:Date.now()});return}const n=this._options?.debouncedNotificationMethods??[];const i=n.includes(t.method)&&!t.params&&!r?.relatedRequestId&&!r?.relatedTask;if(i){if(this._pendingDebouncedNotifications.has(t.method)){return}this._pendingDebouncedNotifications.add(t.method);Promise.resolve().then(()=>{this._pendingDebouncedNotifications.delete(t.method);if(!this._transport){return}let a={...t,jsonrpc:"2.0"};if(r?.relatedTask){a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Oo]:r.relatedTask}}}}this._transport?.send(a,r).catch(c=>this._onerror(c))});return}let s={...t,jsonrpc:"2.0"};if(r?.relatedTask){s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Oo]:r.relatedTask}}}}await this._transport.send(s,r)}setRequestHandler(t,r){const o=Yu(t);this.assertRequestHandlerCapability(o);this._requestHandlers.set(o,(n,i)=>{const s=Qu(t,n);return Promise.resolve(r(s,i))})}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){const o=Yu(t);this._notificationHandlers.set(o,n=>{const i=Qu(t,n);return Promise.resolve(r(i))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const r=this._taskProgressTokens.get(t);if(r!==void 0){this._progressHandlers.delete(r);this._taskProgressTokens.delete(t)}}async _enqueueTaskMessage(t,r,o){if(!this._taskStore||!this._taskMessageQueue){throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured")}const n=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,r,o,n)}async _clearTaskQueue(t,r){if(this._taskMessageQueue){const o=await this._taskMessageQueue.dequeueAll(t,r);for(const n of o){if(n.type==="request"&&Nu(n.message)){const i=n.message.id;const s=this._requestResolvers.get(i);if(s){s(new U(te.InternalError,"Task cancelled or completed"));this._requestResolvers.delete(i)}else{this._onerror(new Error(`Resolver missing for request ${i} during task ${t} cleanup`))}}}}}async _waitForTaskUpdate(t,r){let o=this._options?.defaultTaskPollInterval??1e3;try{const n=await this._taskStore?.getTask(t);if(n?.pollInterval){o=n.pollInterval}}catch{}return new Promise((n,i)=>{if(r.aborted){i(new U(te.InvalidRequest,"Request cancelled"));return}const s=setTimeout(n,o);r.addEventListener("abort",()=>{clearTimeout(s);i(new U(te.InvalidRequest,"Request cancelled"))},{once:true})})}requestTaskStore(t,r){const o=this._taskStore;if(!o){throw new Error("No task store configured")}return{createTask:async n=>{if(!t){throw new Error("No request provided")}return await o.createTask(n,t.id,{method:t.method,params:t.params},r)},getTask:async n=>{const i=await o.getTask(n,r);if(!i){throw new U(te.InvalidParams,"Failed to retrieve task: Task not found")}return i},storeTaskResult:async(n,i,s)=>{await o.storeTaskResult(n,i,s,r);const a=await o.getTask(n,r);if(a){const c=cs.parse({method:"notifications/tasks/status",params:a});await this.notification(c);if(Po(a.status)){this._cleanupTaskProgressHandler(n)}}},getTaskResult:n=>{return o.getTaskResult(n,r)},updateTaskStatus:async(n,i,s)=>{const a=await o.getTask(n,r);if(!a){throw new U(te.InvalidParams,`Task "${n}" not found - it may have been cleaned up`)}if(Po(a.status)){throw new U(te.InvalidParams,`Cannot update task "${n}" from terminal status "${a.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`)}await o.updateTaskStatus(n,i,s,r);const c=await o.getTask(n,r);if(c){const l=cs.parse({method:"notifications/tasks/status",params:c});await this.notification(l);if(Po(c.status)){this._cleanupTaskProgressHandler(n)}}},listTasks:n=>{return o.listTasks(n,r)}}}};function um(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function lm(e,t){const r={...e};for(const o in t){const n=o;const i=t[n];if(i===void 0)continue;const s=r[n];if(um(s)&&um(i)){r[n]={...s,...i}}else{r[n]=i}}return r}var ly=Ru(qd(),1);var dy=Ru(uy(),1);function VP(){const e=new ly.default({strict:false,validateFormats:true,validateSchema:false,allErrors:true});const t=dy.default;t(e);return e}var mc=class{constructor(t){this._ajv=t??VP()}getValidator(t){const r="$id"in t&&typeof t.$id==="string"?this._ajv.getSchema(t.$id)??this._ajv.compile(t):this._ajv.compile(t);return o=>{const n=r(o);if(n){return{valid:true,data:o,errorMessage:void 0}}else{return{valid:false,data:void 0,errorMessage:this._ajv.errorsText(r.errors)}}}}};var hc=class{constructor(t){this._server=t}requestStream(t,r,o){return this._server.requestStream(t,r,o)}createMessageStream(t,r){const o=this._server.getClientCapabilities();if((t.tools||t.toolChoice)&&!o?.sampling?.tools){throw new Error("Client does not support sampling tools capability.")}if(t.messages.length>0){const n=t.messages[t.messages.length-1];const i=Array.isArray(n.content)?n.content:[n.content];const s=i.some(u=>u.type==="tool_result");const a=t.messages.length>1?t.messages[t.messages.length-2]:void 0;const c=a?Array.isArray(a.content)?a.content:[a.content]:[];const l=c.some(u=>u.type==="tool_use");if(s){if(i.some(u=>u.type!=="tool_result")){throw new Error("The last message must contain only tool_result content if any is present")}if(!l){throw new Error("tool_result blocks are not matching any tool_use from the previous message")}}if(l){const u=new Set(c.filter(x=>x.type==="tool_use").map(x=>x.id));const d=new Set(i.filter(x=>x.type==="tool_result").map(x=>x.toolUseId));if(u.size!==d.size||![...u].every(x=>d.has(x))){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},ps,r)}elicitInputStream(t,r){const o=this._server.getClientCapabilities();const n=t.mode??"form";switch(n){case"url":{if(!o?.elicitation?.url){throw new Error("Client does not support url elicitation.")}break}case"form":{if(!o?.elicitation?.form){throw new Error("Client does not support form elicitation.")}break}}const i=n==="form"&&t.mode===void 0?{...t,mode:"form"}:t;return this.requestStream({method:"elicitation/create",params:i},li,r)}async getTask(t,r){return this._server.getTask({taskId:t},r)}async getTaskResult(t,r,o){return this._server.getTaskResult({taskId:t},r,o)}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 py(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 fy(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 gc=class extends Ea{constructor(t,r){super(r);this._serverInfo=t;this._loggingLevels=new Map;this.LOG_LEVEL_SEVERITY=new Map(ds.options.map((o,n)=>[o,n]));this.isMessageIgnored=(o,n)=>{const i=this._loggingLevels.get(n);return i?this.LOG_LEVEL_SEVERITY.get(o)<this.LOG_LEVEL_SEVERITY.get(i):false};this._capabilities=r?.capabilities??{};this._instructions=r?.instructions;this._jsonSchemaValidator=r?.jsonSchemaValidator??new mc;this.setRequestHandler(Du,o=>this._oninitialize(o));this.setNotificationHandler(Uu,()=>this.oninitialized?.());if(this._capabilities.logging){this.setRequestHandler(Wu,async(o,n)=>{const i=n.sessionId||n.requestInfo?.headers["mcp-session-id"]||void 0;const{level:s}=o.params;const a=ds.safeParse(s);if(a.success){this._loggingLevels.set(i,a.data)}return{}})}}get experimental(){if(!this._experimental){this._experimental={tasks:new hc(this)}}return this._experimental}registerCapabilities(t){if(this.transport){throw new Error("Cannot register capabilities after connecting to transport")}this._capabilities=lm(this._capabilities,t)}setRequestHandler(t,r){const o=ha(t);const n=o?.method;if(!n){throw new Error("Schema is missing a method literal")}const i=ga(n);if(typeof i!=="string"){throw new Error("Schema method literal must be a string")}const s=i;if(s==="tools/call"){const a=async(c,l)=>{const u=Ro(ls,c);if(!u.success){const m=u.error instanceof Error?u.error.message:String(u.error);throw new U(te.InvalidParams,`Invalid tools/call request: ${m}`)}const{params:d}=u.data;const x=await Promise.resolve(r(c,l));if(d.task){const m=Ro(ci,x);if(!m.success){const f=m.error instanceof Error?m.error.message:String(m.error);throw new U(te.InvalidParams,`Invalid task creation result: ${f}`)}return m.data}const y=Ro(ka,x);if(!y.success){const m=y.error instanceof Error?y.error.message:String(y.error);throw new U(te.InvalidParams,`Invalid tools/call result: ${m}`)}return y.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){return}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){fy(this._clientCapabilities?.tasks?.requests,t,"Client")}assertTaskHandlerCapability(t){if(!this._capabilities){return}py(this._capabilities.tasks?.requests,t,"Server")}async _oninitialize(t){const r=t.params.protocolVersion;this._clientCapabilities=t.params.capabilities;this._clientVersion=t.params.clientInfo;const o=Hf.includes(r)?r:Cu;return{protocolVersion:o,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"},Ia)}async createMessage(t,r){if(t.tools||t.toolChoice){if(!this._clientCapabilities?.sampling?.tools){throw new Error("Client does not support sampling tools capability.")}}if(t.messages.length>0){const o=t.messages[t.messages.length-1];const n=Array.isArray(o.content)?o.content:[o.content];const i=n.some(l=>l.type==="tool_result");const s=t.messages.length>1?t.messages[t.messages.length-2]:void 0;const a=s?Array.isArray(s.content)?s.content:[s.content]:[];const c=a.some(l=>l.type==="tool_use");if(i){if(n.some(l=>l.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){const l=new Set(a.filter(d=>d.type==="tool_use").map(d=>d.id));const u=new Set(n.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(l.size!==u.size||![...l].every(d=>u.has(d))){throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}}if(t.tools){return this.request({method:"sampling/createMessage",params:t},Ju,r)}return this.request({method:"sampling/createMessage",params:t},ps,r)}async elicitInput(t,r){const o=t.mode??"form";switch(o){case"url":{if(!this._clientCapabilities?.elicitation?.url){throw new Error("Client does not support url elicitation.")}const n=t;return this.request({method:"elicitation/create",params:n},li,r)}case"form":{if(!this._clientCapabilities?.elicitation?.form){throw new Error("Client does not support form elicitation.")}const n=t.mode==="form"?t:{...t,mode:"form"};const i=await this.request({method:"elicitation/create",params:n},li,r);if(i.action==="accept"&&i.content&&n.requestedSchema){try{const s=this._jsonSchemaValidator.getValidator(n.requestedSchema);const a=s(i.content);if(!a.valid){throw new U(te.InvalidParams,`Elicitation response content does not match requested schema: ${a.errorMessage}`)}}catch(s){if(s instanceof U){throw s}throw new U(te.InternalError,`Error validating elicitation response: ${s instanceof Error?s.message:String(s)}`)}}return i}}}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},Xu,r)}async sendLoggingMessage(t,r){if(this._capabilities.logging){if(!this.isMessageIgnored(t.level,r)){return this.notification({method:"notifications/message",params:t})}}}async sendResourceUpdated(t){return this.notification({method:"notifications/resources/updated",params:t})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};import hy from"node:process";var HP=10*1024*1024;var yc=class{constructor(t){this._maxBufferSize=t?.maxBufferSize??HP}append(t){const r=(this._buffer?.length??0)+t.length;if(r>this._maxBufferSize){this.clear();throw 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}const t=this._buffer.indexOf("\n");if(t===-1){return null}const r=this._buffer.toString("utf8",0,t).replace(/\r$/,"");this._buffer=this._buffer.subarray(t+1);return WP(r)}clear(){this._buffer=void 0}};function WP(e){return tm.parse(JSON.parse(e))}function my(e){return JSON.stringify(e)+"\n"}var xc=class{constructor(t=hy.stdin,r=hy.stdout,o){this._stdin=t;this._stdout=r;this._started=false;this._ondata=n=>{try{this._readBuffer.append(n);this.processReadBuffer()}catch(i){this.onerror?.(i);this.close().catch(()=>{})}};this._onerror=n=>{this.onerror?.(n)};this._readBuffer=new yc({maxBufferSize:o?.maxBufferSize})}async start(){if(this._started){throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.")}this._started=true;this._stdin.on("data",this._ondata);this._stdin.on("error",this._onerror)}processReadBuffer(){while(true){try{const 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);const t=this._stdin.listenerCount("data");if(t===0){this._stdin.pause()}this._readBuffer.clear();this.onclose?.()}send(t){return new Promise(r=>{const o=my(t);if(this._stdout.write(o)){r()}else{this._stdout.once("drain",r)}})}};var Ic=Ru(rw(),1);var gy={cn:{dev:"https://matrix-test.example.invalid",test:"https://matrix-test.example.invalid",staging:"https://matrix-pre.example.invalid",prod:"https://api.ottili.one"},en:{dev:"https://matrix-overseas-test.example.invalid",test:"https://matrix-overseas-test.example.invalid",staging:"https://matrix-overseas-pre.example.invalid",prod:"https://api.ottili.one"}};var JP=new Set(["https://api.ottili.one"]);function Ks(e){return e.trim().replace(/\/+$/u,"")}function _c(e=process.env){const t=e.MATRIX_BASE_URL?.trim();const r=t?Ks(t):XP(e);const o=Xd(r);const n=o?void 0:e.MATRIX_TOKEN?.trim();return{baseUrl:r,managed:o,...n?{explicitToken:n}:{}}}function XP(e=process.env){return gy[YP(e.ALRAN_REGION)][QP(e.ALRAN_BUILD_ENV)]}function Xd(e){const t=Ks(e);if(JP.has(t))return true;return Object.values(gy).some(r=>Object.values(r).some(o=>Ks(o)===t))}function YP(e){return e==="cn"?"cn":"en"}function QP(e){if(e==="dev"||e==="test"||e==="staging"||e==="prod"){return e}return"dev"}var ZP="AlranAgent";var eA=12e4;var tA=3e5;var rA=tA-2e4;var oA=15e3;var yy="/matrix/api/v1/mcp/";var xy="/alran/api/v1/mcp/";var Qd=class extends Error{constructor(r,o,n,i=""){super(`Matrix backend ${r} HTTP ${o}: ${i}`);this.pathname=r;this.statusCode=o;this.errorCode=n;this.name="DesktopGatewayHttpError"}pathname;statusCode;errorCode};var eo=class{baseUrl;explicitAccessToken;managedEndpoint;useManagedAuth;authContext;authContextGetter;timeoutMs;fetchImpl;dispatcherFactory;routingHeadersGetter;constructor(t={}){const r=sA(t);const o=t.accessToken?.trim()||r.explicitToken;this.baseUrl=r.baseUrl;this.explicitAccessToken=o;this.managedEndpoint=r.managed;this.useManagedAuth=r.managed&&!o;this.authContext=t.authContext;this.authContextGetter=t.authContextGetter;this.timeoutMs=t.timeoutMs??eA;this.fetchImpl=t.fetchImpl??Ic.fetch;this.dispatcherFactory=t.dispatcherFactory??(n=>new Ic.Agent({headersTimeout:n.headersTimeout,bodyTimeout:n.bodyTimeout}));this.routingHeadersGetter=t.routingHeadersGetter}async postJson(t,r,o,n){const i=await this.postGatewayJson(iA(t),r,o,n?.timeoutMs);return aA(i)}async postGatewayJson(t,r,o,n){const i=n??this.timeoutMs;const s=Yd(o,i);try{const a={method:"POST",headers:{...this.buildHeaders({"Content-Type":"application/json"}),...this.managedEndpoint?this.routingHeadersGetter?.()??{}:{}},body:JSON.stringify(r),signal:s.signal};const c=cA(i,this.dispatcherFactory);if(c!==void 0){uA(a,c)}const l=await this.fetchImpl(`${this.baseUrl}${t}`,a);const u=await l.text();if(!l.ok){throw new Qd(t,l.status,nA(u),u.slice(0,500))}return u?JSON.parse(u):{}}finally{s.dispose()}}async putBytes(t,r,o,n,i){const s=Yd(n,i??this.timeoutMs);try{const a=await this.fetchImpl(t,{method:"PUT",body:r,headers:o,signal:s.signal,duplex:"half"});if(!a.ok){const c=await a.text().catch(()=>"");throw new Error(`Matrix upload PUT HTTP ${a.status}: ${c.slice(0,500)}`)}}finally{s.dispose()}}async getStream(t,r,o){const n=Yd(r,o??this.timeoutMs);try{const i=await this.fetchImpl(t,{method:"GET",signal:n.signal});if(!i.ok||!i.body){const c=await i.text().catch(()=>"");throw new Error(`Matrix download HTTP ${i.status}: ${c.slice(0,500)}`)}const s=i.headers.get("content-length");const a=s?Number.parseInt(s,10):void 0;return{body:i.body,dispose:n.dispose,...Number.isFinite(a)&&a!==void 0?{contentLength:a}:{}}}catch(i){n.dispose();throw i}}buildHeaders(t={}){const r=this.explicitAccessToken??this.getManagedAccessToken();if(!r){throw new Error(this.useManagedAuth?"Matrix tools require a managed-login access token.":"Matrix tools require MATRIX_TOKEN for non-managed MATRIX_BASE_URL.")}return{"User-Agent":ZP,Authorization:`Bearer ${r}`,...t}}getManagedAccessToken(){if(!this.useManagedAuth)return void 0;const t=this.authContextGetter?this.authContextGetter():this.authContext;return t?.accessToken?.trim()||void 0}};function nA(e){if(!e)return void 0;try{const t=JSON.parse(e);return typeof t.error_code==="string"?t.error_code:void 0}catch{return void 0}}function iA(e){if(e.startsWith(yy)){return`${xy}${e.slice(yy.length)}`}if(e.startsWith(xy))return e;throw new Error(`Unsupported Matrix tool path: ${e}`)}function sA(e){if(e.baseUrl){return{baseUrl:Ks(e.baseUrl),managed:Xd(e.baseUrl)}}return e.endpoint??_c()}function aA(e){if(e.base_resp!==void 0)return e;const t=e.code;if(typeof t!=="number")return e;const{code:r,message:o,...n}=e;return{base_resp:{status_code:t,...typeof o==="string"?{status_msg:o}:{}},...n}}function Yd(e,t){const r=new AbortController;const o=()=>r.abort();if(e?.aborted)o();e?.addEventListener("abort",o,{once:true});const n=setTimeout(o,t);return{signal:r.signal,dispose(){clearTimeout(n);e?.removeEventListener("abort",o)}}}function cA(e,t){if(!Number.isFinite(e)||e<rA)return void 0;const r=e+oA;return t({headersTimeout:r,bodyTimeout:r})}function uA(e,t){Object.assign(e,{dispatcher:t})}import{createReadStream as xU,createWriteStream as _U}from"node:fs";import{mkdir as IU,readFile as bU,stat as Bb}from"node:fs/promises";import{basename as Vb,dirname as wU,extname as TU}from"node:path";import{Readable as Hb}from"node:stream";import{pipeline as SU}from"node:stream/promises";import{createHash as lA}from"node:crypto";var _y=Symbol.for("alran.programmaticTool.errorRaw");var Iy=Symbol.for("alran.programmaticTool.errorData");function dA(e,t){if(t===void 0||e===null||typeof e!=="object")return false;if(!Object.isExtensible(e))return false;Object.defineProperty(e,_y,{value:t,enumerable:false,configurable:true});return true}function pA(e){if(e===null||typeof e!=="object")return void 0;return Reflect.get(e,_y)}function fA(e,t){if(e===null||typeof e!=="object"||!Object.isExtensible(e))return false;Object.defineProperty(e,Iy,{value:t,enumerable:false,configurable:true});return true}function mA(e){if(e===null||typeof e!=="object")return void 0;const t=Reflect.get(e,Iy);return t!==null&&typeof t==="object"&&!Array.isArray(t)?t:void 0}function hA(e,t){return{...e,programmatic:{...e.programmatic,...t}}}var by=new WeakMap;function gA(e,t,r){const o=Zd(e);const n=Zd(t);if(o===void 0||n===void 0||r.length===0)return;by.set(t,{source:o,output:n,images:r})}function yA(e,t){if(t===void 0||e===null||typeof e!=="object"){return void 0}const r=by.get(e);if(!r||r.source!==wy(t))return void 0;return r.output===Zd(e)?r.images:void 0}function Zd(e){try{const t=JSON.stringify(e);return t===void 0?void 0:wy(t)}catch{return void 0}}function wy(e){return lA("sha256").update(e).digest("hex")}var ep=12e4;var tp=36e5;function xA(e){if(e===void 0)return{ms:ep,source:"default"};if(typeof e!=="number"||!Number.isFinite(e)||e<=0){return{ms:ep,source:"invalid"}}if(e>tp)return{ms:tp,source:"capped"};return{ms:e,source:"requested"}}function _A(){const e=new Map;return{record(t,r){if(!t||r.length===0)return;const o=e.get(t)??[];e.set(t,[...o,...r])},read(t){return[...e.get(t)??[]]}}}function IA(e){if(!pr(e)||e.role!=="toolResult"||e.toolName!=="run_code"){return void 0}const t=pr(e.details)?e.details:void 0;const r=t&&pr(t.ptc)?t.ptc:void 0;if(!r||r.version!==1||!Array.isArray(r.child_calls)||!Array.isArray(r.retained_facts)||r.host_forced_content!==void 0&&typeof r.host_forced_content!=="string"){return void 0}const o=r.child_calls.filter(Sy);const n=r.retained_facts.filter(My);if(o.length!==r.child_calls.length||n.length!==r.retained_facts.length){return void 0}return{version:1,child_calls:o,retained_facts:n,...typeof r.host_forced_content==="string"?{host_forced_content:r.host_forced_content}:{}}}function bA(e){if(!pr(e)||!ot(e.tool_call_id)||!ot(e.parent_tool_call_id)||!pr(e.result)){return void 0}const t=pr(e.result.details)?e.result.details:void 0;const r=t&&pr(t.ptc_child)?t.ptc_child:void 0;if(!r||r.version!==1||!Sy(r.record)||!Array.isArray(r.retained_facts)){return void 0}const o=r.retained_facts.filter(My);if(o.length!==r.retained_facts.length||r.record.child_tool_call_id!==e.tool_call_id||r.record.parent_tool_call_id!==e.parent_tool_call_id){return void 0}return{version:1,record:r.record,retained_facts:o}}function Sy(e){if(!pr(e))return false;return ot(e.child_tool_call_id)&&ot(e.parent_tool_call_id)&&ot(e.tool_name)&&(e.input===void 0||pr(e.input))&&(e.status==="completed"||e.status==="failed"||e.status==="unknown")&&(e.is_error===void 0||typeof e.is_error==="boolean")&&(e.outcome_unknown===void 0||typeof e.outcome_unknown==="boolean")&&(e.result_ref===void 0||ot(e.result_ref))}function My(e){if(!pr(e)||typeof e.kind!=="string")return false;switch(e.kind){case"terminate_agent":return true;case"outcome_unknown":return ot(e.child_tool_call_id);case"child_error":return ot(e.child_tool_call_id)&&ot(e.code)&&(e.cancelled===void 0||typeof e.cancelled==="boolean")&&(e.tool_error_code===void 0||TA(e.tool_error_code));case"truncation":return ot(e.child_tool_call_id)&&(e.truncated==="true"||e.truncated==="unknown")&&(e.continuation===void 0||pr(e.continuation));case"background_task":return ot(e.child_tool_call_id)&&ot(e.task_id);case"bash_exit":return ot(e.child_tool_call_id)&&(e.exit_code===null||Ty(e.exit_code));case"media_delivery":return ot(e.child_tool_call_id)&&(e.status==="delivered"||e.status==="unavailable"||e.status==="budget_exceeded")&&(e.refs===void 0||Array.isArray(e.refs)&&e.refs.every(SA));case"approval":return ot(e.child_tool_call_id)&&(e.status==="denied"||e.status==="expired");case"plugin_feedback":return ot(e.child_tool_call_id)&&(e.phase==="additional_context"||e.phase==="post_tool_feedback"||e.phase==="updated_result")&&(e.text===void 0||typeof e.text==="string");case"delivery_incomplete":return e.reason==="outer_limit"&&(e.reference===void 0||ot(e.reference));case"budget_exceeded":return(e.budget==="tool_calls"||e.budget==="bridge"||e.budget==="code")&&(e.refused_calls===void 0||Ty(e.refused_calls)&&e.refused_calls>0);default:return false}}var wA=128;function TA(e){return typeof e==="string"&&e.length>0&&e.length<=wA}function pr(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function ot(e){return typeof e==="string"&&e.length>0}function Ty(e){return typeof e==="number"&&Number.isSafeInteger(e)}function SA(e){return pr(e)&&ot(e.uri)&&(e.mimeType===void 0||typeof e.mimeType==="string")}var Ry="terminates_turn";function MA(e){if(typeof e!=="object"||e===null||Array.isArray(e))return false;return e[Ry]===true}function RA(e){const{name:t,label:r,description:o,schema:n,promptGuidelines:i,prepareArguments:s,executionMode:a,operationClassifier:c,source:l,execute:u}=e;const d={name:t,...r!==void 0?{label:r}:{},description:o,schema:n,...i!==void 0?{promptGuidelines:i}:{},...s!==void 0?{prepareArguments:s}:{},...a!==void 0?{executionMode:a}:{},...c!==void 0?{operationClassifier:c}:{}};return{def:d,impl:{execute:u},...l!==void 0?{source:l}:{}}}var Oy=new WeakMap;function W(e){return function(t,r){Oy.set(t,e);return t}}function Xe(e){const t=Oy.get(e.constructor);if(!t){throw new Error(`toRuntimeTool: ${e.constructor.name} is missing the @bindTool(...) decorator`)}return{def:t,impl:e}}var bt={};xn(bt,{HasPropertyKey:()=>bc,IsArray:()=>Ve,IsAsyncIterator:()=>rp,IsBigInt:()=>Gs,IsBoolean:()=>po,IsDate:()=>En,IsFunction:()=>op,IsIterator:()=>np,IsNull:()=>ip,IsNumber:()=>Ht,IsObject:()=>Ie,IsRegExp:()=>Bs,IsString:()=>Me,IsSymbol:()=>sp,IsUint8Array:()=>fo,IsUndefined:()=>He});function bc(e,t){return t in e}function rp(e){return Ie(e)&&!Ve(e)&&!fo(e)&&Symbol.asyncIterator in e}function Ve(e){return Array.isArray(e)}function Gs(e){return typeof e==="bigint"}function po(e){return typeof e==="boolean"}function En(e){return e instanceof globalThis.Date}function op(e){return typeof e==="function"}function np(e){return Ie(e)&&!Ve(e)&&!fo(e)&&Symbol.iterator in e}function ip(e){return e===null}function Ht(e){return typeof e==="number"}function Ie(e){return typeof e==="object"&&e!==null}function Bs(e){return e instanceof globalThis.RegExp}function Me(e){return typeof e==="string"}function sp(e){return typeof e==="symbol"}function fo(e){return e instanceof globalThis.Uint8Array}function He(e){return e===void 0}function OA(e){return e.map(t=>wc(t))}function PA(e){return new Date(e.getTime())}function AA(e){return new Uint8Array(e)}function kA(e){return new RegExp(e.source,e.flags)}function EA(e){const t={};for(const r of Object.getOwnPropertyNames(e)){t[r]=wc(e[r])}for(const r of Object.getOwnPropertySymbols(e)){t[r]=wc(e[r])}return t}function wc(e){return Ve(e)?OA(e):En(e)?PA(e):fo(e)?AA(e):Bs(e)?kA(e):Ie(e)?EA(e):e}function Ee(e){return wc(e)}function Pi(e,t){return t===void 0?Ee(e):Ee({...t,...e})}function Tc(e){return D(e)&&globalThis.Symbol.asyncIterator in e}function Sc(e){return D(e)&&globalThis.Symbol.iterator in e}function ap(e){return D(e)&&(globalThis.Object.getPrototypeOf(e)===Object.prototype||globalThis.Object.getPrototypeOf(e)===null)}function Mc(e){return e instanceof globalThis.Promise}function At(e){return e instanceof Date&&globalThis.Number.isFinite(e.getTime())}function Py(e){return e instanceof globalThis.Map}function Ay(e){return e instanceof globalThis.Set}function fr(e){return globalThis.ArrayBuffer.isView(e)}function Ai(e){return e instanceof globalThis.Uint8Array}function F(e,t){return t in e}function D(e){return e!==null&&typeof e==="object"}function N(e){return globalThis.Array.isArray(e)&&!globalThis.ArrayBuffer.isView(e)}function $e(e){return e===void 0}function mo(e){return e===null}function to(e){return typeof e==="boolean"}function ve(e){return typeof e==="number"}function Rc(e){return globalThis.Number.isInteger(e)}function Rr(e){return typeof e==="bigint"}function xe(e){return typeof e==="string"}function jo(e){return typeof e==="function"}function ho(e){return typeof e==="symbol"}function Wt(e){return Rr(e)||to(e)||mo(e)||ve(e)||xe(e)||ho(e)||$e(e)}var Ye;(function(e){e.InstanceMode="default";e.ExactOptionalPropertyTypes=false;e.AllowArrayObject=false;e.AllowNaN=false;e.AllowNullVoid=false;function t(s,a){return e.ExactOptionalPropertyTypes?a in s:s[a]!==void 0}e.IsExactOptionalProperty=t;function r(s){const a=D(s);return e.AllowArrayObject?a:a&&!N(s)}e.IsObjectLike=r;function o(s){return r(s)&&!(s instanceof Date)&&!(s instanceof Uint8Array)}e.IsRecordLike=o;function n(s){return e.AllowNaN?ve(s):Number.isFinite(s)}e.IsNumberLike=n;function i(s){const a=$e(s);return e.AllowNullVoid?a||s===null:a}e.IsVoidLike=i})(Ye||(Ye={}));function $A(e){return globalThis.Object.freeze(e).map(t=>Vs(t))}function vA(e){return e}function CA(e){return e}function FA(e){return e}function NA(e){const t={};for(const r of Object.getOwnPropertyNames(e)){t[r]=Vs(e[r])}for(const r of Object.getOwnPropertySymbols(e)){t[r]=Vs(e[r])}return globalThis.Object.freeze(t)}function Vs(e){return Ve(e)?$A(e):En(e)?vA(e):fo(e)?CA(e):Bs(e)?FA(e):Ie(e)?NA(e):e}function S(e,t){const r=t!==void 0?{...t,...e}:e;switch(Ye.InstanceMode){case"freeze":return Vs(r);case"clone":return Ee(r);default:return r}}var j=class extends Error{constructor(t){super(t)}};var je=Symbol.for("TypeBox.Transform");var Or=Symbol.for("TypeBox.Readonly");var ft=Symbol.for("TypeBox.Optional");var mr=Symbol.for("TypeBox.Hint");var w=Symbol.for("TypeBox.Kind");function ki(e){return Ie(e)&&e[Or]==="Readonly"}function zt(e){return Ie(e)&&e[ft]==="Optional"}function cp(e){return re(e,"Any")}function up(e){return re(e,"Argument")}function Pr(e){return re(e,"Array")}function $n(e){return re(e,"AsyncIterator")}function vn(e){return re(e,"BigInt")}function go(e){return re(e,"Boolean")}function Ar(e){return re(e,"Computed")}function kr(e){return re(e,"Constructor")}function jA(e){return re(e,"Date")}function Er(e){return re(e,"Function")}function $r(e){return re(e,"Integer")}function Ue(e){return re(e,"Intersect")}function Cn(e){return re(e,"Iterator")}function re(e,t){return Ie(e)&&w in e&&e[w]===t}function Oc(e){return po(e)||Ht(e)||Me(e)}function Jt(e){return re(e,"Literal")}function Xt(e){return re(e,"MappedKey")}function Ce(e){return re(e,"MappedResult")}function zo(e){return re(e,"Never")}function zA(e){return re(e,"Not")}function Hs(e){return re(e,"Null")}function vr(e){return re(e,"Number")}function We(e){return re(e,"Object")}function Fn(e){return re(e,"Promise")}function Nn(e){return re(e,"Record")}function Ke(e){return re(e,"Ref")}function lp(e){return re(e,"RegExp")}function yo(e){return re(e,"String")}function Ws(e){return re(e,"Symbol")}function Yt(e){return re(e,"TemplateLiteral")}function DA(e){return re(e,"This")}function me(e){return Ie(e)&&je in e}function Qt(e){return re(e,"Tuple")}function xo(e){return re(e,"Undefined")}function se(e){return re(e,"Union")}function UA(e){return re(e,"Uint8Array")}function LA(e){return re(e,"Unknown")}function qA(e){return re(e,"Unsafe")}function KA(e){return re(e,"Void")}function Do(e){return Ie(e)&&w in e&&Me(e[w])}function ze(e){return cp(e)||up(e)||Pr(e)||go(e)||vn(e)||$n(e)||Ar(e)||kr(e)||jA(e)||Er(e)||$r(e)||Ue(e)||Cn(e)||Jt(e)||Xt(e)||Ce(e)||zo(e)||zA(e)||Hs(e)||vr(e)||We(e)||Fn(e)||Nn(e)||Ke(e)||lp(e)||yo(e)||Ws(e)||Yt(e)||DA(e)||Qt(e)||xo(e)||se(e)||UA(e)||LA(e)||qA(e)||KA(e)||Do(e)}var g={};xn(g,{IsAny:()=>vy,IsArgument:()=>Cy,IsArray:()=>Fy,IsAsyncIterator:()=>Ny,IsBigInt:()=>jy,IsBoolean:()=>zy,IsComputed:()=>Dy,IsConstructor:()=>Uy,IsDate:()=>Ly,IsFunction:()=>qy,IsImport:()=>JA,IsInteger:()=>Ky,IsIntersect:()=>Gy,IsIterator:()=>By,IsKind:()=>yx,IsKindOf:()=>H,IsLiteral:()=>Xs,IsLiteralBoolean:()=>XA,IsLiteralNumber:()=>Hy,IsLiteralString:()=>Vy,IsLiteralValue:()=>Wy,IsMappedKey:()=>Jy,IsMappedResult:()=>Xy,IsNever:()=>Yy,IsNot:()=>Qy,IsNull:()=>Zy,IsNumber:()=>ex,IsObject:()=>tx,IsOptional:()=>WA,IsPromise:()=>rx,IsProperties:()=>Pc,IsReadonly:()=>HA,IsRecord:()=>ox,IsRecursive:()=>YA,IsRef:()=>nx,IsRegExp:()=>ix,IsSchema:()=>nt,IsString:()=>sx,IsSymbol:()=>ax,IsTemplateLiteral:()=>cx,IsThis:()=>ux,IsTransform:()=>lx,IsTuple:()=>dx,IsUint8Array:()=>fx,IsUndefined:()=>px,IsUnion:()=>mp,IsUnionLiteral:()=>QA,IsUnknown:()=>mx,IsUnsafe:()=>hx,IsVoid:()=>gx,TypeGuardUnknownTypeError:()=>dp});var dp=class extends j{};var GA=["Argument","Any","Array","AsyncIterator","BigInt","Boolean","Computed","Constructor","Date","Enum","Function","Integer","Intersect","Iterator","Literal","MappedKey","MappedResult","Not","Null","Number","Object","Promise","Record","Ref","RegExp","String","Symbol","TemplateLiteral","This","Tuple","Undefined","Union","Uint8Array","Unknown","Void"];function ky(e){try{new RegExp(e);return true}catch{return false}}function pp(e){if(!Me(e))return false;for(let t=0;t<e.length;t++){const r=e.charCodeAt(t);if(r>=7&&r<=13||r===27||r===127){return false}}return true}function Ey(e){return fp(e)||nt(e)}function Js(e){return He(e)||Gs(e)}function Re(e){return He(e)||Ht(e)}function fp(e){return He(e)||po(e)}function be(e){return He(e)||Me(e)}function BA(e){return He(e)||Me(e)&&pp(e)&&ky(e)}function VA(e){return He(e)||Me(e)&&pp(e)}function $y(e){return He(e)||nt(e)}function HA(e){return Ie(e)&&e[Or]==="Readonly"}function WA(e){return Ie(e)&&e[ft]==="Optional"}function vy(e){return H(e,"Any")&&be(e.$id)}function Cy(e){return H(e,"Argument")&&Ht(e.index)}function Fy(e){return H(e,"Array")&&e.type==="array"&&be(e.$id)&&nt(e.items)&&Re(e.minItems)&&Re(e.maxItems)&&fp(e.uniqueItems)&&$y(e.contains)&&Re(e.minContains)&&Re(e.maxContains)}function Ny(e){return H(e,"AsyncIterator")&&e.type==="AsyncIterator"&&be(e.$id)&&nt(e.items)}function jy(e){return H(e,"BigInt")&&e.type==="bigint"&&be(e.$id)&&Js(e.exclusiveMaximum)&&Js(e.exclusiveMinimum)&&Js(e.maximum)&&Js(e.minimum)&&Js(e.multipleOf)}function zy(e){return H(e,"Boolean")&&e.type==="boolean"&&be(e.$id)}function Dy(e){return H(e,"Computed")&&Me(e.target)&&Ve(e.parameters)&&e.parameters.every(t=>nt(t))}function Uy(e){return H(e,"Constructor")&&e.type==="Constructor"&&be(e.$id)&&Ve(e.parameters)&&e.parameters.every(t=>nt(t))&&nt(e.returns)}function Ly(e){return H(e,"Date")&&e.type==="Date"&&be(e.$id)&&Re(e.exclusiveMaximumTimestamp)&&Re(e.exclusiveMinimumTimestamp)&&Re(e.maximumTimestamp)&&Re(e.minimumTimestamp)&&Re(e.multipleOfTimestamp)}function qy(e){return H(e,"Function")&&e.type==="Function"&&be(e.$id)&&Ve(e.parameters)&&e.parameters.every(t=>nt(t))&&nt(e.returns)}function JA(e){return H(e,"Import")&&bc(e,"$defs")&&Ie(e.$defs)&&Pc(e.$defs)&&bc(e,"$ref")&&Me(e.$ref)&&e.$ref in e.$defs}function Ky(e){return H(e,"Integer")&&e.type==="integer"&&be(e.$id)&&Re(e.exclusiveMaximum)&&Re(e.exclusiveMinimum)&&Re(e.maximum)&&Re(e.minimum)&&Re(e.multipleOf)}function Pc(e){return Ie(e)&&Object.entries(e).every(([t,r])=>pp(t)&&nt(r))}function Gy(e){return H(e,"Intersect")&&(Me(e.type)&&e.type!=="object"?false:true)&&Ve(e.allOf)&&e.allOf.every(t=>nt(t)&&!lx(t))&&be(e.type)&&(fp(e.unevaluatedProperties)||$y(e.unevaluatedProperties))&&be(e.$id)}function By(e){return H(e,"Iterator")&&e.type==="Iterator"&&be(e.$id)&&nt(e.items)}function H(e,t){return Ie(e)&&w in e&&e[w]===t}function Vy(e){return Xs(e)&&Me(e.const)}function Hy(e){return Xs(e)&&Ht(e.const)}function XA(e){return Xs(e)&&po(e.const)}function Xs(e){return H(e,"Literal")&&be(e.$id)&&Wy(e.const)}function Wy(e){return po(e)||Ht(e)||Me(e)}function Jy(e){return H(e,"MappedKey")&&Ve(e.keys)&&e.keys.every(t=>Ht(t)||Me(t))}function Xy(e){return H(e,"MappedResult")&&Pc(e.properties)}function Yy(e){return H(e,"Never")&&Ie(e.not)&&Object.getOwnPropertyNames(e.not).length===0}function Qy(e){return H(e,"Not")&&nt(e.not)}function Zy(e){return H(e,"Null")&&e.type==="null"&&be(e.$id)}function ex(e){return H(e,"Number")&&e.type==="number"&&be(e.$id)&&Re(e.exclusiveMaximum)&&Re(e.exclusiveMinimum)&&Re(e.maximum)&&Re(e.minimum)&&Re(e.multipleOf)}function tx(e){return H(e,"Object")&&e.type==="object"&&be(e.$id)&&Pc(e.properties)&&Ey(e.additionalProperties)&&Re(e.minProperties)&&Re(e.maxProperties)}function rx(e){return H(e,"Promise")&&e.type==="Promise"&&be(e.$id)&&nt(e.item)}function ox(e){return H(e,"Record")&&e.type==="object"&&be(e.$id)&&Ey(e.additionalProperties)&&Ie(e.patternProperties)&&(t=>{const r=Object.getOwnPropertyNames(t.patternProperties);return r.length===1&&ky(r[0])&&Ie(t.patternProperties)&&nt(t.patternProperties[r[0]])})(e)}function YA(e){return Ie(e)&&mr in e&&e[mr]==="Recursive"}function nx(e){return H(e,"Ref")&&be(e.$id)&&Me(e.$ref)}function ix(e){return H(e,"RegExp")&&be(e.$id)&&Me(e.source)&&Me(e.flags)&&Re(e.maxLength)&&Re(e.minLength)}function sx(e){return H(e,"String")&&e.type==="string"&&be(e.$id)&&Re(e.minLength)&&Re(e.maxLength)&&BA(e.pattern)&&VA(e.format)}function ax(e){return H(e,"Symbol")&&e.type==="symbol"&&be(e.$id)}function cx(e){return H(e,"TemplateLiteral")&&e.type==="string"&&Me(e.pattern)&&e.pattern[0]==="^"&&e.pattern[e.pattern.length-1]==="$"}function ux(e){return H(e,"This")&&be(e.$id)&&Me(e.$ref)}function lx(e){return Ie(e)&&je in e}function dx(e){return H(e,"Tuple")&&e.type==="array"&&be(e.$id)&&Ht(e.minItems)&&Ht(e.maxItems)&&e.minItems===e.maxItems&&(He(e.items)&&He(e.additionalItems)&&e.minItems===0||Ve(e.items)&&e.items.every(t=>nt(t)))}function px(e){return H(e,"Undefined")&&e.type==="undefined"&&be(e.$id)}function QA(e){return mp(e)&&e.anyOf.every(t=>Vy(t)||Hy(t))}function mp(e){return H(e,"Union")&&be(e.$id)&&Ie(e)&&Ve(e.anyOf)&&e.anyOf.every(t=>nt(t))}function fx(e){return H(e,"Uint8Array")&&e.type==="Uint8Array"&&be(e.$id)&&Re(e.minByteLength)&&Re(e.maxByteLength)}function mx(e){return H(e,"Unknown")&&be(e.$id)}function hx(e){return H(e,"Unsafe")}function gx(e){return H(e,"Void")&&e.type==="void"&&be(e.$id)}function yx(e){return Ie(e)&&w in e&&Me(e[w])&&!GA.includes(e[w])}function nt(e){return Ie(e)&&(vy(e)||Cy(e)||Fy(e)||zy(e)||jy(e)||Ny(e)||Dy(e)||Uy(e)||Ly(e)||qy(e)||Ky(e)||Gy(e)||By(e)||Xs(e)||Jy(e)||Xy(e)||Yy(e)||Qy(e)||Zy(e)||ex(e)||tx(e)||rx(e)||ox(e)||nx(e)||ix(e)||sx(e)||ax(e)||cx(e)||ux(e)||dx(e)||px(e)||mp(e)||fx(e)||mx(e)||hx(e)||gx(e)||yx(e))}var hp="(true|false)";var Ys="(0|[1-9][0-9]*)";var gp="(.*)";var ZA="(?!.*)";var bK=`^${hp}$`;var Uo=`^${Ys}$`;var Lo=`^${gp}$`;var xx=`^${ZA}$`;var qo={};xn(qo,{Clear:()=>tk,Delete:()=>rk,Entries:()=>ek,Get:()=>ik,Has:()=>ok,Set:()=>nk});var Ei=new Map;function ek(){return new Map(Ei)}function tk(){return Ei.clear()}function rk(e){return Ei.delete(e)}function ok(e){return Ei.has(e)}function nk(e,t){Ei.set(e,t)}function ik(e){return Ei.get(e)}var Cr={};xn(Cr,{Clear:()=>ak,Delete:()=>ck,Entries:()=>sk,Get:()=>dk,Has:()=>uk,Set:()=>lk});var $i=new Map;function sk(){return new Map($i)}function ak(){return $i.clear()}function ck(e){return $i.delete(e)}function uk(e){return $i.has(e)}function lk(e,t){$i.set(e,t)}function dk(e){return $i.get(e)}function _x(e,t){return e.includes(t)}function Ix(e){return[...new Set(e)]}function pk(e,t){return e.filter(r=>t.includes(r))}function fk(e,t){return e.reduce((r,o)=>{return pk(r,o)},t)}function bx(e){return e.length===1?e[0]:e.length>1?fk(e.slice(1),e[0]):[]}function wx(e){const t=[];for(const r of e)t.push(...r);return t}function Ko(e){return S({[w]:"Any"},e)}function vi(e,t){return S({[w]:"Array",type:"array",items:e},t)}function Tx(e){return S({[w]:"Argument",index:e})}function Ci(e,t){return S({[w]:"AsyncIterator",type:"AsyncIterator",items:e},t)}function Pe(e,t,r){return S({[w]:"Computed",target:e,parameters:t},r)}function mk(e,t){const{[t]:r,...o}=e;return o}function Le(e,t){return t.reduce((r,o)=>mk(r,o),e)}function B(e){return S({[w]:"Never",not:{}},e)}function le(e){return S({[w]:"MappedResult",properties:e})}function Fi(e,t,r){return S({[w]:"Constructor",type:"Constructor",parameters:e,returns:t},r)}function ro(e,t,r){return S({[w]:"Function",type:"Function",parameters:e,returns:t},r)}function Qs(e,t){return S({[w]:"Union",anyOf:e},t)}function hk(e){return e.some(t=>zt(t))}function Sx(e){return e.map(t=>zt(t)?gk(t):t)}function gk(e){return Le(e,[ft])}function yk(e,t){const r=hk(e);return r?wt(Qs(Sx(e),t)):Qs(Sx(e),t)}function oo(e,t){return e.length===1?S(e[0],t):e.length===0?B(t):yk(e,t)}function he(e,t){return e.length===0?B(t):e.length===1?S(e[0],t):Qs(e,t)}var Ac=class extends j{};function xk(e){return e.replace(/\\\$/g,"$").replace(/\\\*/g,"*").replace(/\\\^/g,"^").replace(/\\\|/g,"|").replace(/\\\(/g,"(").replace(/\\\)/g,")")}function yp(e,t,r){return e[t]===r&&e.charCodeAt(t-1)!==92}function Io(e,t){return yp(e,t,"(")}function Zs(e,t){return yp(e,t,")")}function Mx(e,t){return yp(e,t,"|")}function _k(e){if(!(Io(e,0)&&Zs(e,e.length-1)))return false;let t=0;for(let r=0;r<e.length;r++){if(Io(e,r))t+=1;if(Zs(e,r))t-=1;if(t===0&&r!==e.length-1)return false}return true}function Ik(e){return e.slice(1,e.length-1)}function bk(e){let t=0;for(let r=0;r<e.length;r++){if(Io(e,r))t+=1;if(Zs(e,r))t-=1;if(Mx(e,r)&&t===0)return true}return false}function wk(e){for(let t=0;t<e.length;t++){if(Io(e,t))return true}return false}function Tk(e){let[t,r]=[0,0];const o=[];for(let i=0;i<e.length;i++){if(Io(e,i))t+=1;if(Zs(e,i))t-=1;if(Mx(e,i)&&t===0){const s=e.slice(r,i);if(s.length>0)o.push(Ni(s));r=i+1}}const n=e.slice(r);if(n.length>0)o.push(Ni(n));if(o.length===0)return{type:"const",const:""};if(o.length===1)return o[0];return{type:"or",expr:o}}function Sk(e){function t(n,i){if(!Io(n,i))throw new Ac(`TemplateLiteralParser: Index must point to open parens`);let s=0;for(let a=i;a<n.length;a++){if(Io(n,a))s+=1;if(Zs(n,a))s-=1;if(s===0)return[i,a]}throw new Ac(`TemplateLiteralParser: Unclosed group parens in expression`)}function r(n,i){for(let s=i;s<n.length;s++){if(Io(n,s))return[i,s]}return[i,n.length]}const o=[];for(let n=0;n<e.length;n++){if(Io(e,n)){const[i,s]=t(e,n);const a=e.slice(i,s+1);o.push(Ni(a));n=s}else{const[i,s]=r(e,n);const a=e.slice(i,s);if(a.length>0)o.push(Ni(a));n=s-1}}return o.length===0?{type:"const",const:""}:o.length===1?o[0]:{type:"and",expr:o}}function Ni(e){return _k(e)?Ni(Ik(e)):bk(e)?Tk(e):wk(e)?Sk(e):{type:"const",const:xk(e)}}function ji(e){return Ni(e.slice(1,e.length-1))}var xp=class extends j{};function Mk(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="0"&&e.expr[1].type==="const"&&e.expr[1].const==="[1-9][0-9]*"}function Rk(e){return e.type==="or"&&e.expr.length===2&&e.expr[0].type==="const"&&e.expr[0].const==="true"&&e.expr[1].type==="const"&&e.expr[1].const==="false"}function Ok(e){return e.type==="const"&&e.const===".*"}function jn(e){return Mk(e)||Ok(e)?false:Rk(e)?true:e.type==="and"?e.expr.every(t=>jn(t)):e.type==="or"?e.expr.every(t=>jn(t)):e.type==="const"?true:(()=>{throw new xp(`Unknown expression type`)})()}function kc(e){const t=ji(e.pattern);return jn(t)}var _p=class extends j{};function*Rx(e){if(e.length===1)return yield*e[0];for(const t of e[0]){for(const r of Rx(e.slice(1))){yield`${t}${r}`}}}function*Pk(e){return yield*Rx(e.expr.map(t=>[...ea(t)]))}function*Ak(e){for(const t of e.expr)yield*ea(t)}function*kk(e){return yield e.const}function*ea(e){return e.type==="and"?yield*Pk(e):e.type==="or"?yield*Ak(e):e.type==="const"?yield*kk(e):(()=>{throw new _p("Unknown expression")})()}function zi(e){const t=ji(e.pattern);return jn(t)?[...ea(t)]:[]}function oe(e,t){return S({[w]:"Literal",const:e,type:typeof e},t)}function Ec(e){return S({[w]:"Boolean",type:"boolean"},e)}function Di(e){return S({[w]:"BigInt",type:"bigint"},e)}function hr(e){return S({[w]:"Number",type:"number"},e)}function kt(e){return S({[w]:"String",type:"string"},e)}function*Ek(e){const t=e.trim().replace(/"|'/g,"");return t==="boolean"?yield Ec():t==="number"?yield hr():t==="bigint"?yield Di():t==="string"?yield kt():yield(()=>{const r=t.split("|").map(o=>oe(o.trim()));return r.length===0?B():r.length===1?r[0]:oo(r)})()}function*$k(e){if(e[1]!=="{"){const t=oe("$");const r=Ip(e.slice(1));return yield*[t,...r]}for(let t=2;t<e.length;t++){if(e[t]==="}"){const r=Ek(e.slice(2,t));const o=Ip(e.slice(t+1));return yield*[...r,...o]}}yield oe(e)}function*Ip(e){for(let t=0;t<e.length;t++){if(e[t]==="$"){const r=oe(e.slice(0,t));const o=$k(e.slice(t));return yield*[r,...o]}}yield oe(e)}function Ox(e){return[...Ip(e)]}var bp=class extends j{};function vk(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Px(e,t){return Yt(e)?e.pattern.slice(1,e.pattern.length-1):se(e)?`(${e.anyOf.map(r=>Px(r,t)).join("|")})`:vr(e)?`${t}${Ys}`:$r(e)?`${t}${Ys}`:vn(e)?`${t}${Ys}`:yo(e)?`${t}${gp}`:Jt(e)?`${t}${vk(e.const.toString())}`:go(e)?`${t}${hp}`:(()=>{throw new bp(`Unexpected Kind '${e[w]}'`)})()}function wp(e){return`^${e.map(t=>Px(t,"")).join("")}$`}function zn(e){const t=zi(e);const r=t.map(o=>oe(o));return oo(r)}function $c(e,t){const r=Me(e)?wp(Ox(e)):wp(e);return S({[w]:"TemplateLiteral",type:"string",pattern:r},t)}function Ck(e){const t=zi(e);return t.map(r=>r.toString())}function Fk(e){const t=[];for(const r of e)t.push(...Dt(r));return t}function Nk(e){return[e.toString()]}function Dt(e){return[...new Set(Yt(e)?Ck(e):se(e)?Fk(e.anyOf):Jt(e)?Nk(e.const):vr(e)?["[number]"]:$r(e)?["[number]"]:[])]}function jk(e,t,r){const o={};for(const n of Object.getOwnPropertyNames(t)){o[n]=Go(e,Dt(t[n]),r)}return o}function zk(e,t,r){return jk(e,t.properties,r)}function Ax(e,t,r){const o=zk(e,t,r);return le(o)}function Ex(e,t){return e.map(r=>$x(r,t))}function Dk(e){return e.filter(t=>!zo(t))}function Uk(e,t){return vc(Dk(Ex(e,t)))}function Lk(e){return e.some(t=>zo(t))?[]:e}function qk(e,t){return oo(Lk(Ex(e,t)))}function Kk(e,t){return t in e?e[t]:t==="[number]"?oo(e):B()}function Gk(e,t){return t==="[number]"?e:B()}function Bk(e,t){return t in e?e[t]:B()}function $x(e,t){return Ue(e)?Uk(e.allOf,t):se(e)?qk(e.anyOf,t):Qt(e)?Kk(e.items??[],t):Pr(e)?Gk(e.items,t):We(e)?Bk(e.properties,t):B()}function ta(e,t){return t.map(r=>$x(e,r))}function kx(e,t){return oo(ta(e,t))}function Go(e,t,r){if(Ke(e)||Ke(t)){const o=`Index types using Ref parameters require both Type and Key to be of TSchema`;if(!ze(e)||!ze(t))throw new j(o);return Pe("Index",[e,t])}if(Ce(t))return Ax(e,t,r);if(Xt(t))return vx(e,t,r);return S(ze(t)?kx(e,Dt(t)):kx(e,t),r)}function Vk(e,t,r){return{[t]:Go(e,[t],Ee(r))}}function Hk(e,t,r){return t.reduce((o,n)=>{return{...o,...Vk(e,n,r)}},{})}function Wk(e,t,r){return Hk(e,t.keys,r)}function vx(e,t,r){const o=Wk(e,t,r);return le(o)}function Ui(e,t){return S({[w]:"Iterator",type:"Iterator",items:e},t)}function Jk(e){return globalThis.Object.keys(e).filter(t=>!zt(e[t]))}function Xk(e,t){const r=Jk(e);const o=r.length>0?{[w]:"Object",type:"object",required:r,properties:e}:{[w]:"Object",type:"object",properties:e};return S(o,t)}var ge=Xk;function Cc(e,t){return S({[w]:"Promise",type:"Promise",item:e},t)}function Yk(e){return S(Le(e,[Or]))}function Qk(e){return S({...e,[Or]:"Readonly"})}function Zk(e,t){return t===false?Yk(e):Qk(e)}function Ut(e,t){const r=t??true;return Ce(e)?Cx(e,r):Zk(e,r)}function eE(e,t){const r={};for(const o of globalThis.Object.getOwnPropertyNames(e))r[o]=Ut(e[o],t);return r}function tE(e,t){return eE(e.properties,t)}function Cx(e,t){const r=tE(e,t);return le(r)}function gr(e,t){return S(e.length>0?{[w]:"Tuple",type:"array",items:e,additionalItems:false,minItems:e.length,maxItems:e.length}:{[w]:"Tuple",type:"array",minItems:e.length,maxItems:e.length},t)}function Fx(e,t){return e in t?yr(e,t[e]):le(t)}function rE(e){return{[e]:oe(e)}}function oE(e){const t={};for(const r of e)t[r]=oe(r);return t}function nE(e,t){return _x(t,e)?rE(e):oE(t)}function iE(e,t){const r=nE(e,t);return Fx(e,r)}function ra(e,t){return t.map(r=>yr(e,r))}function sE(e,t){const r={};for(const o of globalThis.Object.getOwnPropertyNames(t))r[o]=yr(e,t[o]);return r}function yr(e,t){const r={...t};return zt(t)?wt(yr(e,Le(t,[ft]))):ki(t)?Ut(yr(e,Le(t,[Or]))):Ce(t)?Fx(e,t.properties):Xt(t)?iE(e,t.keys):kr(t)?Fi(ra(e,t.parameters),yr(e,t.returns),r):Er(t)?ro(ra(e,t.parameters),yr(e,t.returns),r):$n(t)?Ci(yr(e,t.items),r):Cn(t)?Ui(yr(e,t.items),r):Ue(t)?Tt(ra(e,t.allOf),r):se(t)?he(ra(e,t.anyOf),r):Qt(t)?gr(ra(e,t.items??[]),r):We(t)?ge(sE(e,t.properties),r):Pr(t)?vi(yr(e,t.items),r):Fn(t)?Cc(yr(e,t.item),r):t}function aE(e,t){const r={};for(const o of e)r[o]=yr(o,t);return r}function Nx(e,t,r){const o=ze(e)?Dt(e):e;const n=t({[w]:"MappedKey",keys:o});const i=aE(o,n);return ge(i,r)}function cE(e){return S(Le(e,[ft]))}function uE(e){return S({...e,[ft]:"Optional"})}function lE(e,t){return t===false?cE(e):uE(e)}function wt(e,t){const r=t??true;return Ce(e)?jx(e,r):lE(e,r)}function dE(e,t){const r={};for(const o of globalThis.Object.getOwnPropertyNames(e))r[o]=wt(e[o],t);return r}function pE(e,t){return dE(e.properties,t)}function jx(e,t){const r=pE(e,t);return le(r)}function oa(e,t={}){const r=e.every(n=>We(n));const o=ze(t.unevaluatedProperties)?{unevaluatedProperties:t.unevaluatedProperties}:{};return S(t.unevaluatedProperties===false||ze(t.unevaluatedProperties)||r?{...o,[w]:"Intersect",type:"object",allOf:e}:{...o,[w]:"Intersect",allOf:e},t)}function fE(e){return e.every(t=>zt(t))}function mE(e){return Le(e,[ft])}function zx(e){return e.map(t=>zt(t)?mE(t):t)}function hE(e,t){return fE(e)?wt(oa(zx(e),t)):oa(zx(e),t)}function vc(e,t={}){if(e.length===1)return S(e[0],t);if(e.length===0)return B(t);if(e.some(r=>me(r)))throw new Error("Cannot intersect transform types");return hE(e,t)}function Tt(e,t){if(e.length===1)return S(e[0],t);if(e.length===0)return B(t);if(e.some(r=>me(r)))throw new Error("Cannot intersect transform types");return oa(e,t)}function no(...e){const[t,r]=typeof e[0]==="string"?[e[0],e[1]]:[e[0].$id,e[1]];if(typeof t!=="string")throw new j("Ref: $ref must be a string");return S({[w]:"Ref",$ref:t},r)}function gE(e,t){return Pe("Awaited",[Pe(e,t)])}function yE(e){return Pe("Awaited",[no(e)])}function xE(e){return Tt(Dx(e))}function _E(e){return he(Dx(e))}function IE(e){return Li(e)}function Dx(e){return e.map(t=>Li(t))}function Li(e,t){return S(Ar(e)?gE(e.target,e.parameters):Ue(e)?xE(e.allOf):se(e)?_E(e.anyOf):Fn(e)?IE(e.item):Ke(e)?yE(e.$ref):e,t)}function Ux(e){const t=[];for(const r of e)t.push(Lt(r));return t}function bE(e){const t=Ux(e);const r=wx(t);return r}function wE(e){const t=Ux(e);const r=bx(t);return r}function TE(e){return e.map((t,r)=>r.toString())}function SE(e){return["[number]"]}function ME(e){return globalThis.Object.getOwnPropertyNames(e)}function RE(e){if(!Tp)return[];const t=globalThis.Object.getOwnPropertyNames(e);return t.map(r=>{return r[0]==="^"&&r[r.length-1]==="$"?r.slice(1,r.length-1):r})}function Lt(e){return Ue(e)?bE(e.allOf):se(e)?wE(e.anyOf):Qt(e)?TE(e.items??[]):Pr(e)?SE(e.items):We(e)?ME(e.properties):Nn(e)?RE(e.patternProperties):[]}var Tp=false;function qi(e){Tp=true;const t=Lt(e);Tp=false;const r=t.map(o=>`(${o})`);return`^(${r.join("|")})$`}function OE(e,t){return Pe("KeyOf",[Pe(e,t)])}function PE(e){return Pe("KeyOf",[no(e)])}function AE(e,t){const r=Lt(e);const o=kE(r);const n=oo(o);return S(n,t)}function kE(e){return e.map(t=>t==="[number]"?hr():oe(t))}function Ki(e,t){return Ar(e)?OE(e.target,e.parameters):Ke(e)?PE(e.$ref):Ce(e)?Lx(e,t):AE(e,t)}function EE(e,t){const r={};for(const o of globalThis.Object.getOwnPropertyNames(e))r[o]=Ki(e[o],Ee(t));return r}function $E(e,t){return EE(e.properties,t)}function Lx(e,t){const r=$E(e,t);return le(r)}function Fc(e){const t=Lt(e);const r=ta(e,t);return t.map((o,n)=>[t[n],r[n]])}function vE(e){const t=[];for(const r of e)t.push(...Lt(r));return Ix(t)}function CE(e){return e.filter(t=>!zo(t))}function FE(e,t){const r=[];for(const o of e)r.push(...ta(o,[t]));return CE(r)}function NE(e,t){const r={};for(const o of t){r[o]=vc(FE(e,o))}return r}function qx(e,t){const r=vE(e);const o=NE(e,r);const n=ge(o,t);return n}function Nc(e){return S({[w]:"Date",type:"Date"},e)}function jc(e){return S({[w]:"Null",type:"null"},e)}function zc(e){return S({[w]:"Symbol",type:"symbol"},e)}function Dc(e){return S({[w]:"Undefined",type:"undefined"},e)}function Uc(e){return S({[w]:"Uint8Array",type:"Uint8Array"},e)}function Fr(e){return S({[w]:"Unknown"},e)}function jE(e){return e.map(t=>Sp(t,false))}function zE(e){const t={};for(const r of globalThis.Object.getOwnPropertyNames(e))t[r]=Ut(Sp(e[r],false));return t}function Lc(e,t){return t===true?e:Ut(e)}function Sp(e,t){return rp(e)?Lc(Ko(),t):np(e)?Lc(Ko(),t):Ve(e)?Ut(gr(jE(e))):fo(e)?Uc():En(e)?Nc():Ie(e)?Lc(ge(zE(e)),t):op(e)?Lc(ro([],Fr()),t):He(e)?Dc():ip(e)?jc():sp(e)?zc():Gs(e)?Di():Ht(e)?oe(e):po(e)?oe(e):Me(e)?oe(e):ge({})}function Kx(e,t){return S(Sp(e,true),t)}function Gx(e,t){return kr(e)?gr(e.parameters,t):B(t)}function Bx(e,t){if(He(e))throw new Error("Enum undefined or empty");const r=globalThis.Object.getOwnPropertyNames(e).filter(i=>isNaN(i)).map(i=>e[i]);const o=[...new Set(r)];const n=o.map(i=>oe(i));return he(n,{...t,[mr]:"Enum"})}var Rp=class extends j{};var M;(function(e){e[e["Union"]=0]="Union";e[e["True"]=1]="True";e[e["False"]=2]="False"})(M||(M={}));function xr(e){return e===M.False?e:M.True}function Gi(e){throw new Rp(e)}function Qe(e){return g.IsNever(e)||g.IsIntersect(e)||g.IsUnion(e)||g.IsUnknown(e)||g.IsAny(e)}function Ze(e,t){return g.IsNever(t)?Qx(e,t):g.IsIntersect(t)?qc(e,t):g.IsUnion(t)?kp(e,t):g.IsUnknown(t)?r_(e,t):g.IsAny(t)?Ap(e,t):Gi("StructuralRight")}function Ap(e,t){return M.True}function DE(e,t){return g.IsIntersect(t)?qc(e,t):g.IsUnion(t)&&t.anyOf.some(r=>g.IsAny(r)||g.IsUnknown(r))?M.True:g.IsUnion(t)?M.Union:g.IsUnknown(t)?M.True:g.IsAny(t)?M.True:M.Union}function UE(e,t){return g.IsUnknown(e)?M.False:g.IsAny(e)?M.Union:g.IsNever(e)?M.True:M.False}function LE(e,t){return g.IsObject(t)&&Kc(t)?M.True:Qe(t)?Ze(e,t):!g.IsArray(t)?M.False:xr(we(e.items,t.items))}function qE(e,t){return Qe(t)?Ze(e,t):!g.IsAsyncIterator(t)?M.False:xr(we(e.items,t.items))}function KE(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):g.IsBigInt(t)?M.True:M.False}function Xx(e,t){return g.IsLiteralBoolean(e)?M.True:g.IsBoolean(e)?M.True:M.False}function GE(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):g.IsBoolean(t)?M.True:M.False}function BE(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):!g.IsConstructor(t)?M.False:e.parameters.length>t.parameters.length?M.False:!e.parameters.every((r,o)=>xr(we(t.parameters[o],r))===M.True)?M.False:xr(we(e.returns,t.returns))}function VE(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):g.IsDate(t)?M.True:M.False}function HE(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):!g.IsFunction(t)?M.False:e.parameters.length>t.parameters.length?M.False:!e.parameters.every((r,o)=>xr(we(t.parameters[o],r))===M.True)?M.False:xr(we(e.returns,t.returns))}function Yx(e,t){return g.IsLiteral(e)&&bt.IsNumber(e.const)?M.True:g.IsNumber(e)||g.IsInteger(e)?M.True:M.False}function WE(e,t){return g.IsInteger(t)||g.IsNumber(t)?M.True:Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):M.False}function qc(e,t){return t.allOf.every(r=>we(e,r)===M.True)?M.True:M.False}function JE(e,t){return e.allOf.some(r=>we(r,t)===M.True)?M.True:M.False}function XE(e,t){return Qe(t)?Ze(e,t):!g.IsIterator(t)?M.False:xr(we(e.items,t.items))}function YE(e,t){return g.IsLiteral(t)&&t.const===e.const?M.True:Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):g.IsString(t)?t_(e,t):g.IsNumber(t)?Zx(e,t):g.IsInteger(t)?Yx(e,t):g.IsBoolean(t)?Xx(e,t):M.False}function Qx(e,t){return M.False}function QE(e,t){return M.True}function Vx(e){let[t,r]=[e,0];while(true){if(!g.IsNot(t))break;t=t.not;r+=1}return r%2===0?t:Fr()}function ZE(e,t){return g.IsNot(e)?we(Vx(e),t):g.IsNot(t)?we(e,Vx(t)):Gi("Invalid fallthrough for Not")}function e$(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):g.IsNull(t)?M.True:M.False}function Zx(e,t){return g.IsLiteralNumber(e)?M.True:g.IsNumber(e)||g.IsInteger(e)?M.True:M.False}function t$(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):g.IsInteger(t)||g.IsNumber(t)?M.True:M.False}function qt(e,t){return Object.getOwnPropertyNames(e.properties).length===t}function Hx(e){return Kc(e)}function Wx(e){return qt(e,0)||qt(e,1)&&"description"in e.properties&&g.IsUnion(e.properties.description)&&e.properties.description.anyOf.length===2&&(g.IsString(e.properties.description.anyOf[0])&&g.IsUndefined(e.properties.description.anyOf[1])||g.IsString(e.properties.description.anyOf[1])&&g.IsUndefined(e.properties.description.anyOf[0]))}function Mp(e){return qt(e,0)}function Jx(e){return qt(e,0)}function r$(e){return qt(e,0)}function o$(e){return qt(e,0)}function n$(e){return Kc(e)}function i$(e){const t=hr();return qt(e,0)||qt(e,1)&&"length"in e.properties&&xr(we(e.properties["length"],t))===M.True}function s$(e){return qt(e,0)}function Kc(e){const t=hr();return qt(e,0)||qt(e,1)&&"length"in e.properties&&xr(we(e.properties["length"],t))===M.True}function a$(e){const t=ro([Ko()],Ko());return qt(e,0)||qt(e,1)&&"then"in e.properties&&xr(we(e.properties["then"],t))===M.True}function e_(e,t){return we(e,t)===M.False?M.False:g.IsOptional(e)&&!g.IsOptional(t)?M.False:M.True}function St(e,t){return g.IsUnknown(e)?M.False:g.IsAny(e)?M.Union:g.IsNever(e)||g.IsLiteralString(e)&&Hx(t)||g.IsLiteralNumber(e)&&Mp(t)||g.IsLiteralBoolean(e)&&Jx(t)||g.IsSymbol(e)&&Wx(t)||g.IsBigInt(e)&&r$(t)||g.IsString(e)&&Hx(t)||g.IsSymbol(e)&&Wx(t)||g.IsNumber(e)&&Mp(t)||g.IsInteger(e)&&Mp(t)||g.IsBoolean(e)&&Jx(t)||g.IsUint8Array(e)&&n$(t)||g.IsDate(e)&&o$(t)||g.IsConstructor(e)&&s$(t)||g.IsFunction(e)&&i$(t)?M.True:g.IsRecord(e)&&g.IsString(Op(e))?(()=>{return t[mr]==="Record"?M.True:M.False})():g.IsRecord(e)&&g.IsNumber(Op(e))?(()=>{return qt(t,0)?M.True:M.False})():M.False}function c$(e,t){return Qe(t)?Ze(e,t):g.IsRecord(t)?_r(e,t):!g.IsObject(t)?M.False:(()=>{for(const r of Object.getOwnPropertyNames(t.properties)){if(!(r in e.properties)&&!g.IsOptional(t.properties[r])){return M.False}if(g.IsOptional(t.properties[r])){return M.True}if(e_(e.properties[r],t.properties[r])===M.False){return M.False}}return M.True})()}function u$(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)&&a$(t)?M.True:!g.IsPromise(t)?M.False:xr(we(e.item,t.item))}function Op(e){return Uo in e.patternProperties?hr():Lo in e.patternProperties?kt():Gi("Unknown record key pattern")}function Pp(e){return Uo in e.patternProperties?e.patternProperties[Uo]:Lo in e.patternProperties?e.patternProperties[Lo]:Gi("Unable to get record value schema")}function _r(e,t){const[r,o]=[Op(t),Pp(t)];return g.IsLiteralString(e)&&g.IsNumber(r)&&xr(we(e,o))===M.True?M.True:g.IsUint8Array(e)&&g.IsNumber(r)?we(e,o):g.IsString(e)&&g.IsNumber(r)?we(e,o):g.IsArray(e)&&g.IsNumber(r)?we(e,o):g.IsObject(e)?(()=>{for(const n of Object.getOwnPropertyNames(e.properties)){if(e_(o,e.properties[n])===M.False){return M.False}}return M.True})():M.False}function l$(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):!g.IsRecord(t)?M.False:we(Pp(e),Pp(t))}function d$(e,t){const r=g.IsRegExp(e)?kt():e;const o=g.IsRegExp(t)?kt():t;return we(r,o)}function t_(e,t){return g.IsLiteral(e)&&bt.IsString(e.const)?M.True:g.IsString(e)?M.True:M.False}function p$(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):g.IsString(t)?M.True:M.False}function f$(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):g.IsSymbol(t)?M.True:M.False}function m$(e,t){return g.IsTemplateLiteral(e)?we(zn(e),t):g.IsTemplateLiteral(t)?we(e,zn(t)):Gi("Invalid fallthrough for TemplateLiteral")}function h$(e,t){return g.IsArray(t)&&e.items!==void 0&&e.items.every(r=>we(r,t.items)===M.True)}function g$(e,t){return g.IsNever(e)?M.True:g.IsUnknown(e)?M.False:g.IsAny(e)?M.Union:M.False}function y$(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)&&Kc(t)?M.True:g.IsArray(t)&&h$(e,t)?M.True:!g.IsTuple(t)?M.False:bt.IsUndefined(e.items)&&!bt.IsUndefined(t.items)||!bt.IsUndefined(e.items)&&bt.IsUndefined(t.items)?M.False:bt.IsUndefined(e.items)&&!bt.IsUndefined(t.items)?M.True:e.items.every((r,o)=>we(r,t.items[o])===M.True)?M.True:M.False}function x$(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):g.IsUint8Array(t)?M.True:M.False}function _$(e,t){return Qe(t)?Ze(e,t):g.IsObject(t)?St(e,t):g.IsRecord(t)?_r(e,t):g.IsVoid(t)?w$(e,t):g.IsUndefined(t)?M.True:M.False}function kp(e,t){return t.anyOf.some(r=>we(e,r)===M.True)?M.True:M.False}function I$(e,t){return e.anyOf.every(r=>we(r,t)===M.True)?M.True:M.False}function r_(e,t){return M.True}function b$(e,t){return g.IsNever(t)?Qx(e,t):g.IsIntersect(t)?qc(e,t):g.IsUnion(t)?kp(e,t):g.IsAny(t)?Ap(e,t):g.IsString(t)?t_(e,t):g.IsNumber(t)?Zx(e,t):g.IsInteger(t)?Yx(e,t):g.IsBoolean(t)?Xx(e,t):g.IsArray(t)?UE(e,t):g.IsTuple(t)?g$(e,t):g.IsObject(t)?St(e,t):g.IsUnknown(t)?M.True:M.False}function w$(e,t){return g.IsUndefined(e)?M.True:g.IsUndefined(e)?M.True:M.False}function T$(e,t){return g.IsIntersect(t)?qc(e,t):g.IsUnion(t)?kp(e,t):g.IsUnknown(t)?r_(e,t):g.IsAny(t)?Ap(e,t):g.IsObject(t)?St(e,t):g.IsVoid(t)?M.True:M.False}function we(e,t){return g.IsTemplateLiteral(e)||g.IsTemplateLiteral(t)?m$(e,t):g.IsRegExp(e)||g.IsRegExp(t)?d$(e,t):g.IsNot(e)||g.IsNot(t)?ZE(e,t):g.IsAny(e)?DE(e,t):g.IsArray(e)?LE(e,t):g.IsBigInt(e)?KE(e,t):g.IsBoolean(e)?GE(e,t):g.IsAsyncIterator(e)?qE(e,t):g.IsConstructor(e)?BE(e,t):g.IsDate(e)?VE(e,t):g.IsFunction(e)?HE(e,t):g.IsInteger(e)?WE(e,t):g.IsIntersect(e)?JE(e,t):g.IsIterator(e)?XE(e,t):g.IsLiteral(e)?YE(e,t):g.IsNever(e)?QE(e,t):g.IsNull(e)?e$(e,t):g.IsNumber(e)?t$(e,t):g.IsObject(e)?c$(e,t):g.IsRecord(e)?l$(e,t):g.IsString(e)?p$(e,t):g.IsSymbol(e)?f$(e,t):g.IsTuple(e)?y$(e,t):g.IsPromise(e)?u$(e,t):g.IsUint8Array(e)?x$(e,t):g.IsUndefined(e)?_$(e,t):g.IsUnion(e)?I$(e,t):g.IsUnknown(e)?b$(e,t):g.IsVoid(e)?T$(e,t):Gi(`Unknown left type operand '${e[w]}'`)}function Bo(e,t){return we(e,t)}function S$(e,t,r,o,n){const i={};for(const s of globalThis.Object.getOwnPropertyNames(e))i[s]=Bi(e[s],t,r,o,Ee(n));return i}function M$(e,t,r,o,n){return S$(e.properties,t,r,o,n)}function o_(e,t,r,o,n){const i=M$(e,t,r,o,n);return le(i)}function R$(e,t,r,o){const n=Bo(e,t);return n===M.Union?he([r,o]):n===M.True?r:o}function Bi(e,t,r,o,n){return Ce(e)?o_(e,t,r,o,n):Xt(e)?S(n_(e,t,r,o,n)):S(R$(e,t,r,o),n)}function O$(e,t,r,o,n){return{[e]:Bi(oe(e),t,r,o,Ee(n))}}function P$(e,t,r,o,n){return e.reduce((i,s)=>{return{...i,...O$(s,t,r,o,n)}},{})}function A$(e,t,r,o,n){return P$(e.keys,t,r,o,n)}function n_(e,t,r,o,n){const i=A$(e,t,r,o,n);return le(i)}function k$(e){return e.allOf.every(t=>Dn(t))}function E$(e){return e.anyOf.some(t=>Dn(t))}function $$(e){return!Dn(e.not)}function Dn(e){return e[w]==="Intersect"?k$(e):e[w]==="Union"?E$(e):e[w]==="Not"?$$(e):e[w]==="Undefined"?true:false}function i_(e,t){return Vi(zn(e),t)}function v$(e,t){const r=e.filter(o=>Bo(o,t)===M.False);return r.length===1?r[0]:he(r)}function Vi(e,t,r={}){if(Yt(e))return S(i_(e,t),r);if(Ce(e))return S(s_(e,t),r);return S(se(e)?v$(e.anyOf,t):Bo(e,t)!==M.False?B():e,r)}function C$(e,t){const r={};for(const o of globalThis.Object.getOwnPropertyNames(e))r[o]=Vi(e[o],t);return r}function F$(e,t){return C$(e.properties,t)}function s_(e,t){const r=F$(e,t);return le(r)}function a_(e,t){return Hi(zn(e),t)}function N$(e,t){const r=e.filter(o=>Bo(o,t)!==M.False);return r.length===1?r[0]:he(r)}function Hi(e,t,r){if(Yt(e))return S(a_(e,t),r);if(Ce(e))return S(c_(e,t),r);return S(se(e)?N$(e.anyOf,t):Bo(e,t)!==M.False?e:B(),r)}function j$(e,t){const r={};for(const o of globalThis.Object.getOwnPropertyNames(e))r[o]=Hi(e[o],t);return r}function z$(e,t){return j$(e.properties,t)}function c_(e,t){const r=z$(e,t);return le(r)}function u_(e,t){return kr(e)?S(e.returns,t):B(t)}function Gc(e){return Ut(wt(e))}function Un(e,t,r){return S({[w]:"Record",type:"object",patternProperties:{[e]:t}},r)}function Ep(e,t,r){const o={};for(const n of e)o[n]=t;return ge(o,{...r,[mr]:"Record"})}function D$(e,t,r){return kc(e)?Ep(Dt(e),t,r):Un(e.pattern,t,r)}function U$(e,t,r){return Ep(Dt(he(e)),t,r)}function L$(e,t,r){return Ep([e.toString()],t,r)}function q$(e,t,r){return Un(e.source,t,r)}function K$(e,t,r){const o=He(e.pattern)?Lo:e.pattern;return Un(o,t,r)}function G$(e,t,r){return Un(Lo,t,r)}function B$(e,t,r){return Un(xx,t,r)}function V$(e,t,r){return ge({true:t,false:t},r)}function H$(e,t,r){return Un(Uo,t,r)}function W$(e,t,r){return Un(Uo,t,r)}function Bc(e,t,r={}){return se(e)?U$(e.anyOf,t,r):Yt(e)?D$(e,t,r):Jt(e)?L$(e.const,t,r):go(e)?V$(e,t,r):$r(e)?H$(e,t,r):vr(e)?W$(e,t,r):lp(e)?q$(e,t,r):yo(e)?K$(e,t,r):cp(e)?G$(e,t,r):zo(e)?B$(e,t,r):B(r)}function Vc(e){return globalThis.Object.getOwnPropertyNames(e.patternProperties)[0]}function l_(e){const t=Vc(e);return t===Lo?kt():t===Uo?hr():kt({pattern:t})}function Hc(e){return e.patternProperties[Vc(e)]}function J$(e,t){t.parameters=na(e,t.parameters);t.returns=Nr(e,t.returns);return t}function X$(e,t){t.parameters=na(e,t.parameters);t.returns=Nr(e,t.returns);return t}function Y$(e,t){t.allOf=na(e,t.allOf);return t}function Q$(e,t){t.anyOf=na(e,t.anyOf);return t}function Z$(e,t){if(He(t.items))return t;t.items=na(e,t.items);return t}function ev(e,t){t.items=Nr(e,t.items);return t}function tv(e,t){t.items=Nr(e,t.items);return t}function rv(e,t){t.items=Nr(e,t.items);return t}function ov(e,t){t.item=Nr(e,t.item);return t}function nv(e,t){const r=cv(e,t.properties);return{...t,...ge(r)}}function iv(e,t){const r=Nr(e,l_(t));const o=Nr(e,Hc(t));const n=Bc(r,o);return{...t,...n}}function sv(e,t){return t.index in e?e[t.index]:Fr()}function av(e,t){const r=ki(t);const o=zt(t);const n=Nr(e,t);return r&&o?Gc(n):r&&!o?Ut(n):!r&&o?wt(n):n}function cv(e,t){return globalThis.Object.getOwnPropertyNames(t).reduce((r,o)=>{return{...r,[o]:av(e,t[o])}},{})}function na(e,t){return t.map(r=>Nr(e,r))}function Nr(e,t){return kr(t)?J$(e,t):Er(t)?X$(e,t):Ue(t)?Y$(e,t):se(t)?Q$(e,t):Qt(t)?Z$(e,t):Pr(t)?ev(e,t):$n(t)?tv(e,t):Cn(t)?rv(e,t):Fn(t)?ov(e,t):We(t)?nv(e,t):Nn(t)?iv(e,t):up(t)?sv(e,t):t}function d_(e,t){return Nr(t,Pi(e))}function p_(e){return S({[w]:"Integer",type:"integer"},e)}function uv(e,t,r){return{[e]:jr(oe(e),t,Ee(r))}}function lv(e,t,r){const o=e.reduce((n,i)=>{return{...n,...uv(i,t,r)}},{});return o}function dv(e,t,r){return lv(e["keys"],t,r)}function f_(e,t,r){const o=dv(e,t,r);return le(o)}function pv(e){const[t,r]=[e.slice(0,1),e.slice(1)];return[t.toLowerCase(),r].join("")}function fv(e){const[t,r]=[e.slice(0,1),e.slice(1)];return[t.toUpperCase(),r].join("")}function mv(e){return e.toUpperCase()}function hv(e){return e.toLowerCase()}function gv(e,t,r){const o=ji(e.pattern);const n=jn(o);if(!n)return{...e,pattern:m_(e.pattern,t)};const i=[...ea(o)];const s=i.map(l=>oe(l));const a=h_(s,t);const c=he(a);return $c([c],r)}function m_(e,t){return typeof e==="string"?t==="Uncapitalize"?pv(e):t==="Capitalize"?fv(e):t==="Uppercase"?mv(e):t==="Lowercase"?hv(e):e:e.toString()}function h_(e,t){return e.map(r=>jr(r,t))}function jr(e,t,r={}){return Xt(e)?f_(e,t,r):Yt(e)?gv(e,t,r):se(e)?he(h_(e.anyOf,t),r):Jt(e)?oe(m_(e.const,t),r):S(e,r)}function g_(e,t={}){return jr(e,"Capitalize",t)}function y_(e,t={}){return jr(e,"Lowercase",t)}function x_(e,t={}){return jr(e,"Uncapitalize",t)}function __(e,t={}){return jr(e,"Uppercase",t)}function yv(e,t,r){const o={};for(const n of globalThis.Object.getOwnPropertyNames(e))o[n]=Vo(e[n],t,Ee(r));return o}function xv(e,t,r){return yv(e.properties,t,r)}function I_(e,t,r){const o=xv(e,t,r);return le(o)}function _v(e,t){return e.map(r=>$p(r,t))}function Iv(e,t){return e.map(r=>$p(r,t))}function bv(e,t){const{[t]:r,...o}=e;return o}function wv(e,t){return t.reduce((r,o)=>bv(r,o),e)}function Tv(e,t,r){const o=Le(e,[je,"$id","required","properties"]);const n=wv(r,t);return ge(n,o)}function Sv(e){const t=e.reduce((r,o)=>Oc(o)?[...r,oe(o)]:r,[]);return he(t)}function $p(e,t){return Ue(e)?Tt(_v(e.allOf,t)):se(e)?he(Iv(e.anyOf,t)):We(e)?Tv(e,t,e.properties):ge({})}function Vo(e,t,r){const o=Ve(t)?Sv(t):t;const n=ze(t)?Dt(t):t;const i=Ke(e);const s=Ke(t);return Ce(e)?I_(e,n,r):Xt(t)?b_(e,t,r):i&&s?Pe("Omit",[e,o],r):!i&&s?Pe("Omit",[e,o],r):i&&!s?Pe("Omit",[e,o],r):S({...$p(e,n),...r})}function Mv(e,t,r){return{[t]:Vo(e,[t],Ee(r))}}function Rv(e,t,r){return t.reduce((o,n)=>{return{...o,...Mv(e,n,r)}},{})}function Ov(e,t,r){return Rv(e,t.keys,r)}function b_(e,t,r){const o=Ov(e,t,r);return le(o)}function Pv(e,t,r){const o={};for(const n of globalThis.Object.getOwnPropertyNames(e))o[n]=Ho(e[n],t,Ee(r));return o}function Av(e,t,r){return Pv(e.properties,t,r)}function w_(e,t,r){const o=Av(e,t,r);return le(o)}function kv(e,t){return e.map(r=>vp(r,t))}function Ev(e,t){return e.map(r=>vp(r,t))}function $v(e,t){const r={};for(const o of t)if(o in e)r[o]=e[o];return r}function vv(e,t,r){const o=Le(e,[je,"$id","required","properties"]);const n=$v(r,t);return ge(n,o)}function Cv(e){const t=e.reduce((r,o)=>Oc(o)?[...r,oe(o)]:r,[]);return he(t)}function vp(e,t){return Ue(e)?Tt(kv(e.allOf,t)):se(e)?he(Ev(e.anyOf,t)):We(e)?vv(e,t,e.properties):ge({})}function Ho(e,t,r){const o=Ve(t)?Cv(t):t;const n=ze(t)?Dt(t):t;const i=Ke(e);const s=Ke(t);return Ce(e)?w_(e,n,r):Xt(t)?T_(e,t,r):i&&s?Pe("Pick",[e,o],r):!i&&s?Pe("Pick",[e,o],r):i&&!s?Pe("Pick",[e,o],r):S({...vp(e,n),...r})}function Fv(e,t,r){return{[t]:Ho(e,[t],Ee(r))}}function Nv(e,t,r){return t.reduce((o,n)=>{return{...o,...Fv(e,n,r)}},{})}function jv(e,t,r){return Nv(e,t.keys,r)}function T_(e,t,r){const o=jv(e,t,r);return le(o)}function zv(e,t){return Pe("Partial",[Pe(e,t)])}function Dv(e){return Pe("Partial",[no(e)])}function Uv(e){const t={};for(const r of globalThis.Object.getOwnPropertyNames(e))t[r]=wt(e[r]);return t}function Lv(e,t){const r=Le(e,[je,"$id","required","properties"]);const o=Uv(t);return ge(o,r)}function S_(e){return e.map(t=>M_(t))}function M_(e){return Ar(e)?zv(e.target,e.parameters):Ke(e)?Dv(e.$ref):Ue(e)?Tt(S_(e.allOf)):se(e)?he(S_(e.anyOf)):We(e)?Lv(e,e.properties):vn(e)?e:go(e)?e:$r(e)?e:Jt(e)?e:Hs(e)?e:vr(e)?e:yo(e)?e:Ws(e)?e:xo(e)?e:ge({})}function Wi(e,t){if(Ce(e)){return R_(e,t)}else{return S({...M_(e),...t})}}function qv(e,t){const r={};for(const o of globalThis.Object.getOwnPropertyNames(e))r[o]=Wi(e[o],Ee(t));return r}function Kv(e,t){return qv(e.properties,t)}function R_(e,t){const r=Kv(e,t);return le(r)}function Gv(e,t){return Pe("Required",[Pe(e,t)])}function Bv(e){return Pe("Required",[no(e)])}function Vv(e){const t={};for(const r of globalThis.Object.getOwnPropertyNames(e))t[r]=Le(e[r],[ft]);return t}function Hv(e,t){const r=Le(e,[je,"$id","required","properties"]);const o=Vv(t);return ge(o,r)}function O_(e){return e.map(t=>P_(t))}function P_(e){return Ar(e)?Gv(e.target,e.parameters):Ke(e)?Bv(e.$ref):Ue(e)?Tt(O_(e.allOf)):se(e)?he(O_(e.anyOf)):We(e)?Hv(e,e.properties):vn(e)?e:go(e)?e:$r(e)?e:Jt(e)?e:Hs(e)?e:vr(e)?e:yo(e)?e:Ws(e)?e:xo(e)?e:ge({})}function Ji(e,t){if(Ce(e)){return A_(e,t)}else{return S({...P_(e),...t})}}function Wv(e,t){const r={};for(const o of globalThis.Object.getOwnPropertyNames(e))r[o]=Ji(e[o],t);return r}function Jv(e,t){return Wv(e.properties,t)}function A_(e,t){const r=Jv(e,t);return le(r)}function Xv(e,t){return t.map(r=>{return Ke(r)?Cp(e,r.$ref):Zt(e,r)})}function Cp(e,t){return t in e?Ke(e[t])?Cp(e,e[t].$ref):Zt(e,e[t]):B()}function Yv(e){return Li(e[0])}function Qv(e){return Go(e[0],e[1])}function Zv(e){return Ki(e[0])}function eC(e){return Wi(e[0])}function tC(e){return Vo(e[0],e[1])}function rC(e){return Ho(e[0],e[1])}function oC(e){return Ji(e[0])}function nC(e,t,r){const o=Xv(e,r);return t==="Awaited"?Yv(o):t==="Index"?Qv(o):t==="KeyOf"?Zv(o):t==="Partial"?eC(o):t==="Omit"?tC(o):t==="Pick"?rC(o):t==="Required"?oC(o):B()}function iC(e,t){return vi(Zt(e,t))}function sC(e,t){return Ci(Zt(e,t))}function aC(e,t,r){return Fi(ia(e,t),Zt(e,r))}function cC(e,t,r){return ro(ia(e,t),Zt(e,r))}function uC(e,t){return Tt(ia(e,t))}function lC(e,t){return Ui(Zt(e,t))}function dC(e,t){return ge(globalThis.Object.keys(t).reduce((r,o)=>{return{...r,[o]:Zt(e,t[o])}},{}))}function pC(e,t){const[r,o]=[Zt(e,Hc(t)),Vc(t)];const n=Pi(t);n.patternProperties[o]=r;return n}function fC(e,t){return Ke(t)?{...Cp(e,t.$ref),[je]:t[je]}:t}function mC(e,t){return gr(ia(e,t))}function hC(e,t){return he(ia(e,t))}function ia(e,t){return t.map(r=>Zt(e,r))}function Zt(e,t){return zt(t)?S(Zt(e,Le(t,[ft])),t):ki(t)?S(Zt(e,Le(t,[Or])),t):me(t)?S(fC(e,t),t):Pr(t)?S(iC(e,t.items),t):$n(t)?S(sC(e,t.items),t):Ar(t)?S(nC(e,t.target,t.parameters)):kr(t)?S(aC(e,t.parameters,t.returns),t):Er(t)?S(cC(e,t.parameters,t.returns),t):Ue(t)?S(uC(e,t.allOf),t):Cn(t)?S(lC(e,t.items),t):We(t)?S(dC(e,t.properties),t):Nn(t)?S(pC(e,t)):Qt(t)?S(mC(e,t.items||[]),t):se(t)?S(hC(e,t.anyOf),t):t}function gC(e,t){return t in e?Zt(e,e[t]):B()}function k_(e){return globalThis.Object.getOwnPropertyNames(e).reduce((t,r)=>{return{...t,[r]:gC(e,r)}},{})}var Fp=class{constructor(t){const r=k_(t);const o=this.WithIdentifiers(r);this.$defs=o}Import(t,r){const o={...this.$defs,[t]:S(this.$defs[t],r)};return S({[w]:"Import",$defs:o,$ref:t})}WithIdentifiers(t){return globalThis.Object.getOwnPropertyNames(t).reduce((r,o)=>{return{...r,[o]:{...t[o],$id:o}}},{})}};function E_(e){return new Fp(e)}function $_(e,t){return S({[w]:"Not",not:e},t)}function v_(e,t){return Er(e)?gr(e.parameters,t):B()}var yC=0;function C_(e,t={}){if(He(t.$id))t.$id=`T${yC++}`;const r=Pi(e({[w]:"This",$ref:`${t.$id}`}));r.$id=t.$id;return S({[mr]:"Recursive",...r},t)}function F_(e,t){const r=Me(e)?new globalThis.RegExp(e):e;return S({[w]:"RegExp",type:"RegExp",source:r.source,flags:r.flags},t)}function xC(e){return Ue(e)?e.allOf:se(e)?e.anyOf:Qt(e)?e.items??[]:[]}function N_(e){return xC(e)}function j_(e,t){return Er(e)?S(e.returns,t):B(t)}var Np=class{constructor(t){this.schema=t}Decode(t){return new jp(this.schema,t)}};var jp=class{constructor(t,r){this.schema=t;this.decode=r}EncodeTransform(t,r){const o=s=>r[je].Encode(t(s));const n=s=>this.decode(r[je].Decode(s));const i={Encode:o,Decode:n};return{...r,[je]:i}}EncodeSchema(t,r){const o={Decode:this.decode,Encode:t};return{...r,[je]:o}}Encode(t){return me(this.schema)?this.EncodeTransform(t,this.schema):this.EncodeSchema(t,this.schema)}};function z_(e){return new Np(e)}function D_(e={}){return S({[w]:e[w]??"Unsafe"},e)}function U_(e){return S({[w]:"Void",type:"void"},e)}var zp={};xn(zp,{Any:()=>Ko,Argument:()=>Tx,Array:()=>vi,AsyncIterator:()=>Ci,Awaited:()=>Li,BigInt:()=>Di,Boolean:()=>Ec,Capitalize:()=>g_,Composite:()=>qx,Const:()=>Kx,Constructor:()=>Fi,ConstructorParameters:()=>Gx,Date:()=>Nc,Enum:()=>Bx,Exclude:()=>Vi,Extends:()=>Bi,Extract:()=>Hi,Function:()=>ro,Index:()=>Go,InstanceType:()=>u_,Instantiate:()=>d_,Integer:()=>p_,Intersect:()=>Tt,Iterator:()=>Ui,KeyOf:()=>Ki,Literal:()=>oe,Lowercase:()=>y_,Mapped:()=>Nx,Module:()=>E_,Never:()=>B,Not:()=>$_,Null:()=>jc,Number:()=>hr,Object:()=>ge,Omit:()=>Vo,Optional:()=>wt,Parameters:()=>v_,Partial:()=>Wi,Pick:()=>Ho,Promise:()=>Cc,Readonly:()=>Ut,ReadonlyOptional:()=>Gc,Record:()=>Bc,Recursive:()=>C_,Ref:()=>no,RegExp:()=>F_,Required:()=>Ji,Rest:()=>N_,ReturnType:()=>j_,String:()=>kt,Symbol:()=>zc,TemplateLiteral:()=>$c,Transform:()=>z_,Tuple:()=>gr,Uint8Array:()=>Uc,Uncapitalize:()=>x_,Undefined:()=>Dc,Union:()=>he,Unknown:()=>Fr,Unsafe:()=>D_,Uppercase:()=>__,Void:()=>U_});var p=zp;function _C(e){switch(e.errorType){case b.ArrayContains:return"Expected array to contain at least one matching value";case b.ArrayMaxContains:return`Expected array to contain no more than ${e.schema.maxContains} matching values`;case b.ArrayMinContains:return`Expected array to contain at least ${e.schema.minContains} matching values`;case b.ArrayMaxItems:return`Expected array length to be less or equal to ${e.schema.maxItems}`;case b.ArrayMinItems:return`Expected array length to be greater or equal to ${e.schema.minItems}`;case b.ArrayUniqueItems:return"Expected array elements to be unique";case b.Array:return"Expected array";case b.AsyncIterator:return"Expected AsyncIterator";case b.BigIntExclusiveMaximum:return`Expected bigint to be less than ${e.schema.exclusiveMaximum}`;case b.BigIntExclusiveMinimum:return`Expected bigint to be greater than ${e.schema.exclusiveMinimum}`;case b.BigIntMaximum:return`Expected bigint to be less or equal to ${e.schema.maximum}`;case b.BigIntMinimum:return`Expected bigint to be greater or equal to ${e.schema.minimum}`;case b.BigIntMultipleOf:return`Expected bigint to be a multiple of ${e.schema.multipleOf}`;case b.BigInt:return"Expected bigint";case b.Boolean:return"Expected boolean";case b.DateExclusiveMinimumTimestamp:return`Expected Date timestamp to be greater than ${e.schema.exclusiveMinimumTimestamp}`;case b.DateExclusiveMaximumTimestamp:return`Expected Date timestamp to be less than ${e.schema.exclusiveMaximumTimestamp}`;case b.DateMinimumTimestamp:return`Expected Date timestamp to be greater or equal to ${e.schema.minimumTimestamp}`;case b.DateMaximumTimestamp:return`Expected Date timestamp to be less or equal to ${e.schema.maximumTimestamp}`;case b.DateMultipleOfTimestamp:return`Expected Date timestamp to be a multiple of ${e.schema.multipleOfTimestamp}`;case b.Date:return"Expected Date";case b.Function:return"Expected function";case b.IntegerExclusiveMaximum:return`Expected integer to be less than ${e.schema.exclusiveMaximum}`;case b.IntegerExclusiveMinimum:return`Expected integer to be greater than ${e.schema.exclusiveMinimum}`;case b.IntegerMaximum:return`Expected integer to be less or equal to ${e.schema.maximum}`;case b.IntegerMinimum:return`Expected integer to be greater or equal to ${e.schema.minimum}`;case b.IntegerMultipleOf:return`Expected integer to be a multiple of ${e.schema.multipleOf}`;case b.Integer:return"Expected integer";case b.IntersectUnevaluatedProperties:return"Unexpected property";case b.Intersect:return"Expected all values to match";case b.Iterator:return"Expected Iterator";case b.Literal:return`Expected ${typeof e.schema.const==="string"?`'${e.schema.const}'`:e.schema.const}`;case b.Never:return"Never";case b.Not:return"Value should not match";case b.Null:return"Expected null";case b.NumberExclusiveMaximum:return`Expected number to be less than ${e.schema.exclusiveMaximum}`;case b.NumberExclusiveMinimum:return`Expected number to be greater than ${e.schema.exclusiveMinimum}`;case b.NumberMaximum:return`Expected number to be less or equal to ${e.schema.maximum}`;case b.NumberMinimum:return`Expected number to be greater or equal to ${e.schema.minimum}`;case b.NumberMultipleOf:return`Expected number to be a multiple of ${e.schema.multipleOf}`;case b.Number:return"Expected number";case b.Object:return"Expected object";case b.ObjectAdditionalProperties:return"Unexpected property";case b.ObjectMaxProperties:return`Expected object to have no more than ${e.schema.maxProperties} properties`;case b.ObjectMinProperties:return`Expected object to have at least ${e.schema.minProperties} properties`;case b.ObjectRequiredProperty:return"Expected required property";case b.Promise:return"Expected Promise";case b.RegExp:return"Expected string to match regular expression";case b.StringFormatUnknown:return`Unknown format '${e.schema.format}'`;case b.StringFormat:return`Expected string to match '${e.schema.format}' format`;case b.StringMaxLength:return`Expected string length less or equal to ${e.schema.maxLength}`;case b.StringMinLength:return`Expected string length greater or equal to ${e.schema.minLength}`;case b.StringPattern:return`Expected string to match '${e.schema.pattern}'`;case b.String:return"Expected string";case b.Symbol:return"Expected symbol";case b.TupleLength:return`Expected tuple to have ${e.schema.maxItems||0} elements`;case b.Tuple:return"Expected tuple";case b.Uint8ArrayMaxByteLength:return`Expected byte length less or equal to ${e.schema.maxByteLength}`;case b.Uint8ArrayMinByteLength:return`Expected byte length greater or equal to ${e.schema.minByteLength}`;case b.Uint8Array:return"Expected Uint8Array";case b.Undefined:return"Expected undefined";case b.Union:return"Expected union value";case b.Void:return"Expected void";case b.Kind:return`Expected kind '${e.schema[w]}'`;default:return"Unknown error type"}}var IC=_C;function L_(){return IC}var Dp=class extends j{constructor(t){super(`Unable to dereference schema with $id '${t.$ref}'`);this.schema=t}};function bC(e,t){const r=t.find(o=>o.$id===e.$ref);if(r===void 0)throw new Dp(e);return ye(r,t)}function it(e,t){if(!xe(e.$id)||t.some(r=>r.$id===e.$id))return t;t.push(e);return t}function ye(e,t){return e[w]==="This"||e[w]==="Ref"?bC(e,t):e}var Up=class extends j{constructor(t){super(`Unable to hash value`);this.value=t}};var er;(function(e){e[e["Undefined"]=0]="Undefined";e[e["Null"]=1]="Null";e[e["Boolean"]=2]="Boolean";e[e["Number"]=3]="Number";e[e["String"]=4]="String";e[e["Object"]=5]="Object";e[e["Array"]=6]="Array";e[e["Date"]=7]="Date";e[e["Uint8Array"]=8]="Uint8Array";e[e["Symbol"]=9]="Symbol";e[e["BigInt"]=10]="BigInt"})(er||(er={}));var Xi=BigInt("14695981039346656037");var[wC,TC]=[BigInt("1099511628211"),BigInt("18446744073709551616")];var SC=Array.from({length:256}).map((e,t)=>BigInt(t));var q_=new Float64Array(1);var K_=new DataView(q_.buffer);var G_=new Uint8Array(q_.buffer);function*MC(e){const t=e===0?1:Math.ceil(Math.floor(Math.log2(e)+1)/8);for(let r=0;r<t;r++){yield e>>8*(t-1-r)&255}}function RC(e){Mt(er.Array);for(const t of e){Yi(t)}}function OC(e){Mt(er.Boolean);Mt(e?1:0)}function PC(e){Mt(er.BigInt);K_.setBigInt64(0,e);for(const t of G_){Mt(t)}}function AC(e){Mt(er.Date);Yi(e.getTime())}function kC(e){Mt(er.Null)}function EC(e){Mt(er.Number);K_.setFloat64(0,e);for(const t of G_){Mt(t)}}function $C(e){Mt(er.Object);for(const t of globalThis.Object.getOwnPropertyNames(e).sort()){Yi(t);Yi(e[t])}}function vC(e){Mt(er.String);for(let t=0;t<e.length;t++){for(const r of MC(e.charCodeAt(t))){Mt(r)}}}function CC(e){Mt(er.Symbol);Yi(e.description)}function FC(e){Mt(er.Uint8Array);for(let t=0;t<e.length;t++){Mt(e[t])}}function NC(e){return Mt(er.Undefined)}function Yi(e){if(N(e))return RC(e);if(to(e))return OC(e);if(Rr(e))return PC(e);if(At(e))return AC(e);if(mo(e))return kC(e);if(ve(e))return EC(e);if(D(e))return $C(e);if(xe(e))return vC(e);if(ho(e))return CC(e);if(Ai(e))return FC(e);if($e(e))return NC(e);throw new Up(e)}function Mt(e){Xi=Xi^SC[e];Xi=Xi*wC%TC}function Qi(e){Xi=BigInt("14695981039346656037");Yi(e);return Xi}var Lp=class extends j{constructor(t){super(`Unknown type`);this.schema=t}};function jC(e){return e[w]==="Any"||e[w]==="Unknown"}function J(e){return e!==void 0}function zC(e,t,r){return true}function DC(e,t,r){return true}function UC(e,t,r){if(!N(r))return false;if(J(e.minItems)&&!(r.length>=e.minItems)){return false}if(J(e.maxItems)&&!(r.length<=e.maxItems)){return false}for(const i of r){if(!st(e.items,t,i))return false}if(e.uniqueItems===true&&!(function(){const i=new Set;for(const s of r){const a=Qi(s);if(i.has(a)){return false}else{i.add(a)}}return true})()){return false}if(!(J(e.contains)||ve(e.minContains)||ve(e.maxContains))){return true}const o=J(e.contains)?e.contains:B();const n=r.reduce((i,s)=>st(o,t,s)?i+1:i,0);if(n===0){return false}if(ve(e.minContains)&&n<e.minContains){return false}if(ve(e.maxContains)&&n>e.maxContains){return false}return true}function LC(e,t,r){return Tc(r)}function qC(e,t,r){if(!Rr(r))return false;if(J(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum)){return false}if(J(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum)){return false}if(J(e.maximum)&&!(r<=e.maximum)){return false}if(J(e.minimum)&&!(r>=e.minimum)){return false}if(J(e.multipleOf)&&!(r%e.multipleOf===BigInt(0))){return false}return true}function KC(e,t,r){return to(r)}function GC(e,t,r){return st(e.returns,t,r.prototype)}function BC(e,t,r){if(!At(r))return false;if(J(e.exclusiveMaximumTimestamp)&&!(r.getTime()<e.exclusiveMaximumTimestamp)){return false}if(J(e.exclusiveMinimumTimestamp)&&!(r.getTime()>e.exclusiveMinimumTimestamp)){return false}if(J(e.maximumTimestamp)&&!(r.getTime()<=e.maximumTimestamp)){return false}if(J(e.minimumTimestamp)&&!(r.getTime()>=e.minimumTimestamp)){return false}if(J(e.multipleOfTimestamp)&&!(r.getTime()%e.multipleOfTimestamp===0)){return false}return true}function VC(e,t,r){return jo(r)}function HC(e,t,r){const o=globalThis.Object.values(e.$defs);const n=e.$defs[e.$ref];return st(n,[...t,...o],r)}function WC(e,t,r){if(!Rc(r)){return false}if(J(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum)){return false}if(J(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum)){return false}if(J(e.maximum)&&!(r<=e.maximum)){return false}if(J(e.minimum)&&!(r>=e.minimum)){return false}if(J(e.multipleOf)&&!(r%e.multipleOf===0)){return false}return true}function JC(e,t,r){const o=e.allOf.every(n=>st(n,t,r));if(e.unevaluatedProperties===false){const n=new RegExp(qi(e));const i=Object.getOwnPropertyNames(r).every(s=>n.test(s));return o&&i}else if(ze(e.unevaluatedProperties)){const n=new RegExp(qi(e));const i=Object.getOwnPropertyNames(r).every(s=>n.test(s)||st(e.unevaluatedProperties,t,r[s]));return o&&i}else{return o}}function XC(e,t,r){return Sc(r)}function YC(e,t,r){return r===e.const}function QC(e,t,r){return false}function ZC(e,t,r){return!st(e.not,t,r)}function eF(e,t,r){return mo(r)}function tF(e,t,r){if(!Ye.IsNumberLike(r))return false;if(J(e.exclusiveMaximum)&&!(r<e.exclusiveMaximum)){return false}if(J(e.exclusiveMinimum)&&!(r>e.exclusiveMinimum)){return false}if(J(e.minimum)&&!(r>=e.minimum)){return false}if(J(e.maximum)&&!(r<=e.maximum)){return false}if(J(e.multipleOf)&&!(r%e.multipleOf===0)){return false}return true}function rF(e,t,r){if(!Ye.IsObjectLike(r))return false;if(J(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties)){return false}if(J(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties)){return false}const o=Object.getOwnPropertyNames(e.properties);for(const n of o){const i=e.properties[n];if(e.required&&e.required.includes(n)){if(!st(i,t,r[n])){return false}if((Dn(i)||jC(i))&&!(n in r)){return false}}else{if(Ye.IsExactOptionalProperty(r,n)&&!st(i,t,r[n])){return false}}}if(e.additionalProperties===false){const n=Object.getOwnPropertyNames(r);if(e.required&&e.required.length===o.length&&n.length===o.length){return true}else{return n.every(i=>o.includes(i))}}else if(typeof e.additionalProperties==="object"){const n=Object.getOwnPropertyNames(r);return n.every(i=>o.includes(i)||st(e.additionalProperties,t,r[i]))}else{return true}}function oF(e,t,r){return Mc(r)}function nF(e,t,r){if(!Ye.IsRecordLike(r)){return false}if(J(e.minProperties)&&!(Object.getOwnPropertyNames(r).length>=e.minProperties)){return false}if(J(e.maxProperties)&&!(Object.getOwnPropertyNames(r).length<=e.maxProperties)){return false}const[o,n]=Object.entries(e.patternProperties)[0];const i=new RegExp(o);const s=Object.entries(r).every(([l,u])=>{return i.test(l)?st(n,t,u):true});const a=typeof e.additionalProperties==="object"?Object.entries(r).every(([l,u])=>{return!i.test(l)?st(e.additionalProperties,t,u):true}):true;const c=e.additionalProperties===false?Object.getOwnPropertyNames(r).every(l=>{return i.test(l)}):true;return s&&a&&c}function iF(e,t,r){return st(ye(e,t),t,r)}function sF(e,t,r){const o=new RegExp(e.source,e.flags);if(J(e.minLength)){if(!(r.length>=e.minLength))return false}if(J(e.maxLength)){if(!(r.length<=e.maxLength))return false}return o.test(r)}function aF(e,t,r){if(!xe(r)){return false}if(J(e.minLength)){if(!(r.length>=e.minLength))return false}if(J(e.maxLength)){if(!(r.length<=e.maxLength))return false}if(J(e.pattern)){const o=new RegExp(e.pattern);if(!o.test(r))return false}if(J(e.format)){if(!qo.Has(e.format))return false;const o=qo.Get(e.format);return o(r)}return true}function cF(e,t,r){return ho(r)}function uF(e,t,r){return xe(r)&&new RegExp(e.pattern).test(r)}function lF(e,t,r){return st(ye(e,t),t,r)}function dF(e,t,r){if(!N(r)){return false}if(e.items===void 0&&!(r.length===0)){return false}if(!(r.length===e.maxItems)){return false}if(!e.items){return true}for(let o=0;o<e.items.length;o++){if(!st(e.items[o],t,r[o]))return false}return true}function pF(e,t,r){return $e(r)}function fF(e,t,r){return e.anyOf.some(o=>st(o,t,r))}function mF(e,t,r){if(!Ai(r)){return false}if(J(e.maxByteLength)&&!(r.length<=e.maxByteLength)){return false}if(J(e.minByteLength)&&!(r.length>=e.minByteLength)){return false}return true}function hF(e,t,r){return true}function gF(e,t,r){return Ye.IsVoidLike(r)}function yF(e,t,r){if(!Cr.Has(e[w]))return false;const o=Cr.Get(e[w]);return o(e,r)}function st(e,t,r){const o=J(e.$id)?it(e,t):t;const n=e;switch(n[w]){case"Any":return zC(n,o,r);case"Argument":return DC(n,o,r);case"Array":return UC(n,o,r);case"AsyncIterator":return LC(n,o,r);case"BigInt":return qC(n,o,r);case"Boolean":return KC(n,o,r);case"Constructor":return GC(n,o,r);case"Date":return BC(n,o,r);case"Function":return VC(n,o,r);case"Import":return HC(n,o,r);case"Integer":return WC(n,o,r);case"Intersect":return JC(n,o,r);case"Iterator":return XC(n,o,r);case"Literal":return YC(n,o,r);case"Never":return QC(n,o,r);case"Not":return ZC(n,o,r);case"Null":return eF(n,o,r);case"Number":return tF(n,o,r);case"Object":return rF(n,o,r);case"Promise":return oF(n,o,r);case"Record":return nF(n,o,r);case"Ref":return iF(n,o,r);case"RegExp":return sF(n,o,r);case"String":return aF(n,o,r);case"Symbol":return cF(n,o,r);case"TemplateLiteral":return uF(n,o,r);case"This":return lF(n,o,r);case"Tuple":return dF(n,o,r);case"Undefined":return pF(n,o,r);case"Union":return fF(n,o,r);case"Uint8Array":return mF(n,o,r);case"Unknown":return hF(n,o,r);case"Void":return gF(n,o,r);default:if(!Cr.Has(n[w]))throw new Lp(n);return yF(n,o,r)}}function q(...e){return e.length===3?st(e[0],e[1],e[2]):st(e[0],[],e[1])}var b;(function(e){e[e["ArrayContains"]=0]="ArrayContains";e[e["ArrayMaxContains"]=1]="ArrayMaxContains";e[e["ArrayMaxItems"]=2]="ArrayMaxItems";e[e["ArrayMinContains"]=3]="ArrayMinContains";e[e["ArrayMinItems"]=4]="ArrayMinItems";e[e["ArrayUniqueItems"]=5]="ArrayUniqueItems";e[e["Array"]=6]="Array";e[e["AsyncIterator"]=7]="AsyncIterator";e[e["BigIntExclusiveMaximum"]=8]="BigIntExclusiveMaximum";e[e["BigIntExclusiveMinimum"]=9]="BigIntExclusiveMinimum";e[e["BigIntMaximum"]=10]="BigIntMaximum";e[e["BigIntMinimum"]=11]="BigIntMinimum";e[e["BigIntMultipleOf"]=12]="BigIntMultipleOf";e[e["BigInt"]=13]="BigInt";e[e["Boolean"]=14]="Boolean";e[e["DateExclusiveMaximumTimestamp"]=15]="DateExclusiveMaximumTimestamp";e[e["DateExclusiveMinimumTimestamp"]=16]="DateExclusiveMinimumTimestamp";e[e["DateMaximumTimestamp"]=17]="DateMaximumTimestamp";e[e["DateMinimumTimestamp"]=18]="DateMinimumTimestamp";e[e["DateMultipleOfTimestamp"]=19]="DateMultipleOfTimestamp";e[e["Date"]=20]="Date";e[e["Function"]=21]="Function";e[e["IntegerExclusiveMaximum"]=22]="IntegerExclusiveMaximum";e[e["IntegerExclusiveMinimum"]=23]="IntegerExclusiveMinimum";e[e["IntegerMaximum"]=24]="IntegerMaximum";e[e["IntegerMinimum"]=25]="IntegerMinimum";e[e["IntegerMultipleOf"]=26]="IntegerMultipleOf";e[e["Integer"]=27]="Integer";e[e["IntersectUnevaluatedProperties"]=28]="IntersectUnevaluatedProperties";e[e["Intersect"]=29]="Intersect";e[e["Iterator"]=30]="Iterator";e[e["Kind"]=31]="Kind";e[e["Literal"]=32]="Literal";e[e["Never"]=33]="Never";e[e["Not"]=34]="Not";e[e["Null"]=35]="Null";e[e["NumberExclusiveMaximum"]=36]="NumberExclusiveMaximum";e[e["NumberExclusiveMinimum"]=37]="NumberExclusiveMinimum";e[e["NumberMaximum"]=38]="NumberMaximum";e[e["NumberMinimum"]=39]="NumberMinimum";e[e["NumberMultipleOf"]=40]="NumberMultipleOf";e[e["Number"]=41]="Number";e[e["ObjectAdditionalProperties"]=42]="ObjectAdditionalProperties";e[e["ObjectMaxProperties"]=43]="ObjectMaxProperties";e[e["ObjectMinProperties"]=44]="ObjectMinProperties";e[e["ObjectRequiredProperty"]=45]="ObjectRequiredProperty";e[e["Object"]=46]="Object";e[e["Promise"]=47]="Promise";e[e["RegExp"]=48]="RegExp";e[e["StringFormatUnknown"]=49]="StringFormatUnknown";e[e["StringFormat"]=50]="StringFormat";e[e["StringMaxLength"]=51]="StringMaxLength";e[e["StringMinLength"]=52]="StringMinLength";e[e["StringPattern"]=53]="StringPattern";e[e["String"]=54]="String";e[e["Symbol"]=55]="Symbol";e[e["TupleLength"]=56]="TupleLength";e[e["Tuple"]=57]="Tuple";e[e["Uint8ArrayMaxByteLength"]=58]="Uint8ArrayMaxByteLength";e[e["Uint8ArrayMinByteLength"]=59]="Uint8ArrayMinByteLength";e[e["Uint8Array"]=60]="Uint8Array";e[e["Undefined"]=61]="Undefined";e[e["Union"]=62]="Union";e[e["Void"]=63]="Void"})(b||(b={}));var qp=class extends j{constructor(t){super("Unknown type");this.schema=t}};function bo(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function X(e){return e!==void 0}var Wo=class{constructor(t){this.iterator=t}[Symbol.iterator](){return this.iterator}First(){const t=this.iterator.next();return t.done?void 0:t.value}};function O(e,t,r,o,n=[]){return{type:e,schema:t,path:r,value:o,message:L_()({errorType:e,path:r,schema:t,value:o,errors:n}),errors:n}}function*xF(e,t,r,o){}function*_F(e,t,r,o){}function*IF(e,t,r,o){if(!N(o)){return yield O(b.Array,e,r,o)}if(X(e.minItems)&&!(o.length>=e.minItems)){yield O(b.ArrayMinItems,e,r,o)}if(X(e.maxItems)&&!(o.length<=e.maxItems)){yield O(b.ArrayMaxItems,e,r,o)}for(let s=0;s<o.length;s++){yield*at(e.items,t,`${r}/${s}`,o[s])}if(e.uniqueItems===true&&!(function(){const s=new Set;for(const a of o){const c=Qi(a);if(s.has(c)){return false}else{s.add(c)}}return true})()){yield O(b.ArrayUniqueItems,e,r,o)}if(!(X(e.contains)||X(e.minContains)||X(e.maxContains))){return}const n=X(e.contains)?e.contains:B();const i=o.reduce((s,a,c)=>at(n,t,`${r}${c}`,a).next().done===true?s+1:s,0);if(i===0){yield O(b.ArrayContains,e,r,o)}if(ve(e.minContains)&&i<e.minContains){yield O(b.ArrayMinContains,e,r,o)}if(ve(e.maxContains)&&i>e.maxContains){yield O(b.ArrayMaxContains,e,r,o)}}function*bF(e,t,r,o){if(!Tc(o))yield O(b.AsyncIterator,e,r,o)}function*wF(e,t,r,o){if(!Rr(o))return yield O(b.BigInt,e,r,o);if(X(e.exclusiveMaximum)&&!(o<e.exclusiveMaximum)){yield O(b.BigIntExclusiveMaximum,e,r,o)}if(X(e.exclusiveMinimum)&&!(o>e.exclusiveMinimum)){yield O(b.BigIntExclusiveMinimum,e,r,o)}if(X(e.maximum)&&!(o<=e.maximum)){yield O(b.BigIntMaximum,e,r,o)}if(X(e.minimum)&&!(o>=e.minimum)){yield O(b.BigIntMinimum,e,r,o)}if(X(e.multipleOf)&&!(o%e.multipleOf===BigInt(0))){yield O(b.BigIntMultipleOf,e,r,o)}}function*TF(e,t,r,o){if(!to(o))yield O(b.Boolean,e,r,o)}function*SF(e,t,r,o){yield*at(e.returns,t,r,o.prototype)}function*MF(e,t,r,o){if(!At(o))return yield O(b.Date,e,r,o);if(X(e.exclusiveMaximumTimestamp)&&!(o.getTime()<e.exclusiveMaximumTimestamp)){yield O(b.DateExclusiveMaximumTimestamp,e,r,o)}if(X(e.exclusiveMinimumTimestamp)&&!(o.getTime()>e.exclusiveMinimumTimestamp)){yield O(b.DateExclusiveMinimumTimestamp,e,r,o)}if(X(e.maximumTimestamp)&&!(o.getTime()<=e.maximumTimestamp)){yield O(b.DateMaximumTimestamp,e,r,o)}if(X(e.minimumTimestamp)&&!(o.getTime()>=e.minimumTimestamp)){yield O(b.DateMinimumTimestamp,e,r,o)}if(X(e.multipleOfTimestamp)&&!(o.getTime()%e.multipleOfTimestamp===0)){yield O(b.DateMultipleOfTimestamp,e,r,o)}}function*RF(e,t,r,o){if(!jo(o))yield O(b.Function,e,r,o)}function*OF(e,t,r,o){const n=globalThis.Object.values(e.$defs);const i=e.$defs[e.$ref];yield*at(i,[...t,...n],r,o)}function*PF(e,t,r,o){if(!Rc(o))return yield O(b.Integer,e,r,o);if(X(e.exclusiveMaximum)&&!(o<e.exclusiveMaximum)){yield O(b.IntegerExclusiveMaximum,e,r,o)}if(X(e.exclusiveMinimum)&&!(o>e.exclusiveMinimum)){yield O(b.IntegerExclusiveMinimum,e,r,o)}if(X(e.maximum)&&!(o<=e.maximum)){yield O(b.IntegerMaximum,e,r,o)}if(X(e.minimum)&&!(o>=e.minimum)){yield O(b.IntegerMinimum,e,r,o)}if(X(e.multipleOf)&&!(o%e.multipleOf===0)){yield O(b.IntegerMultipleOf,e,r,o)}}function*AF(e,t,r,o){let n=false;for(const i of e.allOf){for(const s of at(i,t,r,o)){n=true;yield s}}if(n){return yield O(b.Intersect,e,r,o)}if(e.unevaluatedProperties===false){const i=new RegExp(qi(e));for(const s of Object.getOwnPropertyNames(o)){if(!i.test(s)){yield O(b.IntersectUnevaluatedProperties,e,`${r}/${s}`,o)}}}if(typeof e.unevaluatedProperties==="object"){const i=new RegExp(qi(e));for(const s of Object.getOwnPropertyNames(o)){if(!i.test(s)){const a=at(e.unevaluatedProperties,t,`${r}/${s}`,o[s]).next();if(!a.done)yield a.value}}}}function*kF(e,t,r,o){if(!Sc(o))yield O(b.Iterator,e,r,o)}function*EF(e,t,r,o){if(!(o===e.const))yield O(b.Literal,e,r,o)}function*$F(e,t,r,o){yield O(b.Never,e,r,o)}function*vF(e,t,r,o){if(at(e.not,t,r,o).next().done===true)yield O(b.Not,e,r,o)}function*CF(e,t,r,o){if(!mo(o))yield O(b.Null,e,r,o)}function*FF(e,t,r,o){if(!Ye.IsNumberLike(o))return yield O(b.Number,e,r,o);if(X(e.exclusiveMaximum)&&!(o<e.exclusiveMaximum)){yield O(b.NumberExclusiveMaximum,e,r,o)}if(X(e.exclusiveMinimum)&&!(o>e.exclusiveMinimum)){yield O(b.NumberExclusiveMinimum,e,r,o)}if(X(e.maximum)&&!(o<=e.maximum)){yield O(b.NumberMaximum,e,r,o)}if(X(e.minimum)&&!(o>=e.minimum)){yield O(b.NumberMinimum,e,r,o)}if(X(e.multipleOf)&&!(o%e.multipleOf===0)){yield O(b.NumberMultipleOf,e,r,o)}}function*NF(e,t,r,o){if(!Ye.IsObjectLike(o))return yield O(b.Object,e,r,o);if(X(e.minProperties)&&!(Object.getOwnPropertyNames(o).length>=e.minProperties)){yield O(b.ObjectMinProperties,e,r,o)}if(X(e.maxProperties)&&!(Object.getOwnPropertyNames(o).length<=e.maxProperties)){yield O(b.ObjectMaxProperties,e,r,o)}const n=Array.isArray(e.required)?e.required:[];const i=Object.getOwnPropertyNames(e.properties);const s=Object.getOwnPropertyNames(o);for(const a of n){if(s.includes(a))continue;yield O(b.ObjectRequiredProperty,e.properties[a],`${r}/${bo(a)}`,void 0)}if(e.additionalProperties===false){for(const a of s){if(!i.includes(a)){yield O(b.ObjectAdditionalProperties,e,`${r}/${bo(a)}`,o[a])}}}if(typeof e.additionalProperties==="object"){for(const a of s){if(i.includes(a))continue;yield*at(e.additionalProperties,t,`${r}/${bo(a)}`,o[a])}}for(const a of i){const c=e.properties[a];if(e.required&&e.required.includes(a)){yield*at(c,t,`${r}/${bo(a)}`,o[a]);if(Dn(e)&&!(a in o)){yield O(b.ObjectRequiredProperty,c,`${r}/${bo(a)}`,void 0)}}else{if(Ye.IsExactOptionalProperty(o,a)){yield*at(c,t,`${r}/${bo(a)}`,o[a])}}}}function*jF(e,t,r,o){if(!Mc(o))yield O(b.Promise,e,r,o)}function*zF(e,t,r,o){if(!Ye.IsRecordLike(o))return yield O(b.Object,e,r,o);if(X(e.minProperties)&&!(Object.getOwnPropertyNames(o).length>=e.minProperties)){yield O(b.ObjectMinProperties,e,r,o)}if(X(e.maxProperties)&&!(Object.getOwnPropertyNames(o).length<=e.maxProperties)){yield O(b.ObjectMaxProperties,e,r,o)}const[n,i]=Object.entries(e.patternProperties)[0];const s=new RegExp(n);for(const[a,c]of Object.entries(o)){if(s.test(a))yield*at(i,t,`${r}/${bo(a)}`,c)}if(typeof e.additionalProperties==="object"){for(const[a,c]of Object.entries(o)){if(!s.test(a))yield*at(e.additionalProperties,t,`${r}/${bo(a)}`,c)}}if(e.additionalProperties===false){for(const[a,c]of Object.entries(o)){if(s.test(a))continue;return yield O(b.ObjectAdditionalProperties,e,`${r}/${bo(a)}`,c)}}}function*DF(e,t,r,o){yield*at(ye(e,t),t,r,o)}function*UF(e,t,r,o){if(!xe(o))return yield O(b.String,e,r,o);if(X(e.minLength)&&!(o.length>=e.minLength)){yield O(b.StringMinLength,e,r,o)}if(X(e.maxLength)&&!(o.length<=e.maxLength)){yield O(b.StringMaxLength,e,r,o)}const n=new RegExp(e.source,e.flags);if(!n.test(o)){return yield O(b.RegExp,e,r,o)}}function*LF(e,t,r,o){if(!xe(o))return yield O(b.String,e,r,o);if(X(e.minLength)&&!(o.length>=e.minLength)){yield O(b.StringMinLength,e,r,o)}if(X(e.maxLength)&&!(o.length<=e.maxLength)){yield O(b.StringMaxLength,e,r,o)}if(xe(e.pattern)){const n=new RegExp(e.pattern);if(!n.test(o)){yield O(b.StringPattern,e,r,o)}}if(xe(e.format)){if(!qo.Has(e.format)){yield O(b.StringFormatUnknown,e,r,o)}else{const n=qo.Get(e.format);if(!n(o)){yield O(b.StringFormat,e,r,o)}}}}function*qF(e,t,r,o){if(!ho(o))yield O(b.Symbol,e,r,o)}function*KF(e,t,r,o){if(!xe(o))return yield O(b.String,e,r,o);const n=new RegExp(e.pattern);if(!n.test(o)){yield O(b.StringPattern,e,r,o)}}function*GF(e,t,r,o){yield*at(ye(e,t),t,r,o)}function*BF(e,t,r,o){if(!N(o))return yield O(b.Tuple,e,r,o);if(e.items===void 0&&!(o.length===0)){return yield O(b.TupleLength,e,r,o)}if(!(o.length===e.maxItems)){return yield O(b.TupleLength,e,r,o)}if(!e.items){return}for(let n=0;n<e.items.length;n++){yield*at(e.items[n],t,`${r}/${n}`,o[n])}}function*VF(e,t,r,o){if(!$e(o))yield O(b.Undefined,e,r,o)}function*HF(e,t,r,o){if(q(e,t,o))return;const n=e.anyOf.map(i=>new Wo(at(i,t,r,o)));yield O(b.Union,e,r,o,n)}function*WF(e,t,r,o){if(!Ai(o))return yield O(b.Uint8Array,e,r,o);if(X(e.maxByteLength)&&!(o.length<=e.maxByteLength)){yield O(b.Uint8ArrayMaxByteLength,e,r,o)}if(X(e.minByteLength)&&!(o.length>=e.minByteLength)){yield O(b.Uint8ArrayMinByteLength,e,r,o)}}function*JF(e,t,r,o){}function*XF(e,t,r,o){if(!Ye.IsVoidLike(o))yield O(b.Void,e,r,o)}function*YF(e,t,r,o){const n=Cr.Get(e[w]);if(!n(e,o))yield O(b.Kind,e,r,o)}function*at(e,t,r,o){const n=X(e.$id)?[...t,e]:t;const i=e;switch(i[w]){case"Any":return yield*xF(i,n,r,o);case"Argument":return yield*_F(i,n,r,o);case"Array":return yield*IF(i,n,r,o);case"AsyncIterator":return yield*bF(i,n,r,o);case"BigInt":return yield*wF(i,n,r,o);case"Boolean":return yield*TF(i,n,r,o);case"Constructor":return yield*SF(i,n,r,o);case"Date":return yield*MF(i,n,r,o);case"Function":return yield*RF(i,n,r,o);case"Import":return yield*OF(i,n,r,o);case"Integer":return yield*PF(i,n,r,o);case"Intersect":return yield*AF(i,n,r,o);case"Iterator":return yield*kF(i,n,r,o);case"Literal":return yield*EF(i,n,r,o);case"Never":return yield*$F(i,n,r,o);case"Not":return yield*vF(i,n,r,o);case"Null":return yield*CF(i,n,r,o);case"Number":return yield*FF(i,n,r,o);case"Object":return yield*NF(i,n,r,o);case"Promise":return yield*jF(i,n,r,o);case"Record":return yield*zF(i,n,r,o);case"Ref":return yield*DF(i,n,r,o);case"RegExp":return yield*UF(i,n,r,o);case"String":return yield*LF(i,n,r,o);case"Symbol":return yield*qF(i,n,r,o);case"TemplateLiteral":return yield*KF(i,n,r,o);case"This":return yield*GF(i,n,r,o);case"Tuple":return yield*BF(i,n,r,o);case"Undefined":return yield*VF(i,n,r,o);case"Union":return yield*HF(i,n,r,o);case"Uint8Array":return yield*WF(i,n,r,o);case"Unknown":return yield*JF(i,n,r,o);case"Void":return yield*XF(i,n,r,o);default:if(!Cr.Has(i[w]))throw new qp(e);return yield*YF(i,n,r,o)}}function Jo(...e){const t=e.length===3?at(e[0],e[1],"",e[2]):at(e[0],[],"",e[1]);return new Wo(t)}var QF=function(e,t,r,o,n){if(o==="m")throw new TypeError("Private method is not writable");if(o==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r};var V_=function(e,t,r,o){if(r==="a"&&!o)throw new TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?o:r==="a"?o.call(e):o?o.value:t.get(e)};var Kp;var Wc;var H_;var Gp=class extends j{constructor(t){const r=t.First();super(r===void 0?"Invalid Value":r.message);Kp.add(this);Wc.set(this,void 0);QF(this,Wc,t,"f");this.error=r}Errors(){return new Wo(V_(this,Kp,"m",H_).call(this))}};Wc=new WeakMap,Kp=new WeakSet,H_=function*e(){if(this.error)yield this.error;yield*V_(this,Wc,"f")};function B_(e,t,r){if(q(e,t,r))return;throw new Gp(Jo(e,t,r))}function Jc(...e){return e.length===3?B_(e[0],e[1],e[2]):B_(e[0],[],e[1])}function ZF(e){const t={};for(const r of Object.getOwnPropertyNames(e)){t[r]=de(e[r])}for(const r of Object.getOwnPropertySymbols(e)){t[r]=de(e[r])}return t}function eN(e){return e.map(t=>de(t))}function tN(e){return e.slice()}function rN(e){return new Map(de([...e.entries()]))}function oN(e){return new Set(de([...e.entries()]))}function nN(e){return new Date(e.toISOString())}function iN(e){return e}function de(e){if(N(e))return eN(e);if(At(e))return nN(e);if(fr(e))return tN(e);if(Py(e))return rN(e);if(Ay(e))return oN(e);if(D(e))return ZF(e);if(Wt(e))return iN(e);throw new Error("ValueClone: Unable to clone value")}var tr=class extends j{constructor(t,r){super(r);this.schema=t}};function pe(e){return jo(e)?e():de(e)}function sN(e,t){if(F(e,"default")){return pe(e.default)}else{return{}}}function aN(e,t){return{}}function cN(e,t){if(e.uniqueItems===true&&!F(e,"default")){throw new tr(e,"Array with the uniqueItems constraint requires a default value")}else if("contains"in e&&!F(e,"default")){throw new tr(e,"Array with the contains constraint requires a default value")}else if("default"in e){return pe(e.default)}else if(e.minItems!==void 0){return Array.from({length:e.minItems}).map(r=>{return rr(e.items,t)})}else{return[]}}function uN(e,t){if(F(e,"default")){return pe(e.default)}else{return(async function*(){})()}}function lN(e,t){if(F(e,"default")){return pe(e.default)}else{return BigInt(0)}}function dN(e,t){if(F(e,"default")){return pe(e.default)}else{return false}}function pN(e,t){if(F(e,"default")){return pe(e.default)}else{const r=rr(e.returns,t);if(typeof r==="object"&&!Array.isArray(r)){return class{constructor(){for(const[o,n]of Object.entries(r)){const i=this;i[o]=n}}}}else{return class{}}}}function fN(e,t){if(F(e,"default")){return pe(e.default)}else if(e.minimumTimestamp!==void 0){return new Date(e.minimumTimestamp)}else{return new Date}}function mN(e,t){if(F(e,"default")){return pe(e.default)}else{return()=>rr(e.returns,t)}}function hN(e,t){const r=globalThis.Object.values(e.$defs);const o=e.$defs[e.$ref];return rr(o,[...t,...r])}function gN(e,t){if(F(e,"default")){return pe(e.default)}else if(e.minimum!==void 0){return e.minimum}else{return 0}}function yN(e,t){if(F(e,"default")){return pe(e.default)}else{const r=e.allOf.reduce((o,n)=>{const i=rr(n,t);return typeof i==="object"?{...o,...i}:i},{});if(!q(e,t,r))throw new tr(e,"Intersect produced invalid value. Consider using a default value.");return r}}function xN(e,t){if(F(e,"default")){return pe(e.default)}else{return(function*(){})()}}function _N(e,t){if(F(e,"default")){return pe(e.default)}else{return e.const}}function IN(e,t){if(F(e,"default")){return pe(e.default)}else{throw new tr(e,"Never types cannot be created. Consider using a default value.")}}function bN(e,t){if(F(e,"default")){return pe(e.default)}else{throw new tr(e,"Not types must have a default value")}}function wN(e,t){if(F(e,"default")){return pe(e.default)}else{return null}}function TN(e,t){if(F(e,"default")){return pe(e.default)}else if(e.minimum!==void 0){return e.minimum}else{return 0}}function SN(e,t){if(F(e,"default")){return pe(e.default)}else{const r=new Set(e.required);const o={};for(const[n,i]of Object.entries(e.properties)){if(!r.has(n))continue;o[n]=rr(i,t)}return o}}function MN(e,t){if(F(e,"default")){return pe(e.default)}else{return Promise.resolve(rr(e.item,t))}}function RN(e,t){if(F(e,"default")){return pe(e.default)}else{return{}}}function ON(e,t){if(F(e,"default")){return pe(e.default)}else{return rr(ye(e,t),t)}}function PN(e,t){if(F(e,"default")){return pe(e.default)}else{throw new tr(e,"RegExp types cannot be created. Consider using a default value.")}}function AN(e,t){if(e.pattern!==void 0){if(!F(e,"default")){throw new tr(e,"String types with patterns must specify a default value")}else{return pe(e.default)}}else if(e.format!==void 0){if(!F(e,"default")){throw new tr(e,"String types with formats must specify a default value")}else{return pe(e.default)}}else{if(F(e,"default")){return pe(e.default)}else if(e.minLength!==void 0){return Array.from({length:e.minLength}).map(()=>" ").join("")}else{return""}}}function kN(e,t){if(F(e,"default")){return pe(e.default)}else if("value"in e){return Symbol.for(e.value)}else{return Symbol()}}function EN(e,t){if(F(e,"default")){return pe(e.default)}if(!kc(e))throw new tr(e,"Can only create template literals that produce a finite variants. Consider using a default value.");const r=zi(e);return r[0]}function $N(e,t){if(W_++>UN)throw new tr(e,"Cannot create recursive type as it appears possibly infinite. Consider using a default.");if(F(e,"default")){return pe(e.default)}else{return rr(ye(e,t),t)}}function vN(e,t){if(F(e,"default")){return pe(e.default)}if(e.items===void 0){return[]}else{return Array.from({length:e.minItems}).map((r,o)=>rr(e.items[o],t))}}function CN(e,t){if(F(e,"default")){return pe(e.default)}else{return void 0}}function FN(e,t){if(F(e,"default")){return pe(e.default)}else if(e.anyOf.length===0){throw new Error("ValueCreate.Union: Cannot create Union with zero variants")}else{return rr(e.anyOf[0],t)}}function NN(e,t){if(F(e,"default")){return pe(e.default)}else if(e.minByteLength!==void 0){return new Uint8Array(e.minByteLength)}else{return new Uint8Array(0)}}function jN(e,t){if(F(e,"default")){return pe(e.default)}else{return{}}}function zN(e,t){if(F(e,"default")){return pe(e.default)}else{return void 0}}function DN(e,t){if(F(e,"default")){return pe(e.default)}else{throw new Error("User defined types must specify a default value")}}function rr(e,t){const r=it(e,t);const o=e;switch(o[w]){case"Any":return sN(o,r);case"Argument":return aN(o,r);case"Array":return cN(o,r);case"AsyncIterator":return uN(o,r);case"BigInt":return lN(o,r);case"Boolean":return dN(o,r);case"Constructor":return pN(o,r);case"Date":return fN(o,r);case"Function":return mN(o,r);case"Import":return hN(o,r);case"Integer":return gN(o,r);case"Intersect":return yN(o,r);case"Iterator":return xN(o,r);case"Literal":return _N(o,r);case"Never":return IN(o,r);case"Not":return bN(o,r);case"Null":return wN(o,r);case"Number":return TN(o,r);case"Object":return SN(o,r);case"Promise":return MN(o,r);case"Record":return RN(o,r);case"Ref":return ON(o,r);case"RegExp":return PN(o,r);case"String":return AN(o,r);case"Symbol":return kN(o,r);case"TemplateLiteral":return EN(o,r);case"This":return $N(o,r);case"Tuple":return vN(o,r);case"Undefined":return CN(o,r);case"Union":return FN(o,r);case"Uint8Array":return NN(o,r);case"Unknown":return jN(o,r);case"Void":return zN(o,r);default:if(!Cr.Has(o[w]))throw new tr(o,"Unknown type");return DN(o,r)}}var UN=512;var W_=0;function zr(...e){W_=0;return e.length===2?rr(e[0],e[1]):rr(e[0],[])}var Xc=class extends j{constructor(t,r){super(r);this.schema=t}};function J_(e,t,r){if(e[w]==="Object"&&typeof r==="object"&&!mo(r)){const o=e;const n=Object.getOwnPropertyNames(r);const i=Object.entries(o.properties);return i.reduce((s,[a,c])=>{const l=c[w]==="Literal"&&c.const===r[a]?100:0;const u=q(c,t,r[a])?10:0;const d=n.includes(a)?1:0;return s+(l+u+d)},0)}else if(e[w]==="Union"){const o=e.anyOf.map(i=>ye(i,t));const n=o.map(i=>J_(i,t,r));return Math.max(...n)}else{return q(e,t,r)?1:0}}function LN(e,t,r){const o=e.anyOf.map(s=>ye(s,t));let[n,i]=[o[0],0];for(const s of o){const a=J_(s,t,r);if(a>i){n=s;i=a}}return n}function qN(e,t,r){if("default"in e){return typeof r==="function"?e.default:de(e.default)}else{const o=LN(e,t,r);return sa(o,t,r)}}function KN(e,t,r){return q(e,t,r)?de(r):zr(e,t)}function GN(e,t,r){return q(e,t,r)?r:zr(e,t)}function BN(e,t,r){if(q(e,t,r))return de(r);const o=N(r)?de(r):zr(e,t);const n=ve(e.minItems)&&o.length<e.minItems?[...o,...Array.from({length:e.minItems-o.length},()=>null)]:o;const i=ve(e.maxItems)&&n.length>e.maxItems?n.slice(0,e.maxItems):n;const s=i.map(c=>Dr(e.items,t,c));if(e.uniqueItems!==true)return s;const a=[...new Set(s)];if(!q(e,t,a))throw new Xc(e,"Array cast produced invalid data due to uniqueItems constraint");return a}function VN(e,t,r){if(q(e,t,r))return zr(e,t);const o=new Set(e.returns.required||[]);const n=function(){};for(const[i,s]of Object.entries(e.returns.properties)){if(!o.has(i)&&r.prototype[i]===void 0)continue;n.prototype[i]=Dr(s,t,r.prototype[i])}return n}function HN(e,t,r){const o=globalThis.Object.values(e.$defs);const n=e.$defs[e.$ref];return Dr(n,[...t,...o],r)}function X_(e,t){if(D(e)&&!D(t)||!D(e)&&D(t))return e;if(!D(e)||!D(t))return t;return globalThis.Object.getOwnPropertyNames(e).reduce((r,o)=>{const n=o in t?X_(e[o],t[o]):e[o];return{...r,[o]:n}},{})}function WN(e,t,r){if(q(e,t,r))return r;const o=zr(e,t);const n=X_(o,r);return q(e,t,n)?n:o}function JN(e,t,r){throw new Xc(e,"Never types cannot be cast")}function XN(e,t,r){if(q(e,t,r))return r;if(r===null||typeof r!=="object")return zr(e,t);const o=new Set(e.required||[]);const n={};for(const[i,s]of Object.entries(e.properties)){if(!o.has(i)&&r[i]===void 0)continue;n[i]=Dr(s,t,r[i])}if(typeof e.additionalProperties==="object"){const i=Object.getOwnPropertyNames(e.properties);for(const s of Object.getOwnPropertyNames(r)){if(i.includes(s))continue;n[s]=Dr(e.additionalProperties,t,r[s])}}return n}function YN(e,t,r){if(q(e,t,r))return de(r);if(r===null||typeof r!=="object"||Array.isArray(r)||r instanceof Date)return zr(e,t);const o=Object.getOwnPropertyNames(e.patternProperties)[0];const n=e.patternProperties[o];const i={};for(const[s,a]of Object.entries(r)){i[s]=Dr(n,t,a)}return i}function QN(e,t,r){return Dr(ye(e,t),t,r)}function ZN(e,t,r){return Dr(ye(e,t),t,r)}function e1(e,t,r){if(q(e,t,r))return de(r);if(!N(r))return zr(e,t);if(e.items===void 0)return[];return e.items.map((o,n)=>Dr(o,t,r[n]))}function t1(e,t,r){return q(e,t,r)?de(r):qN(e,t,r)}function Dr(e,t,r){const o=xe(e.$id)?it(e,t):t;const n=e;switch(e[w]){case"Array":return BN(n,o,r);case"Constructor":return VN(n,o,r);case"Import":return HN(n,o,r);case"Intersect":return WN(n,o,r);case"Never":return JN(n,o,r);case"Object":return XN(n,o,r);case"Record":return YN(n,o,r);case"Ref":return QN(n,o,r);case"This":return ZN(n,o,r);case"Tuple":return e1(n,o,r);case"Union":return t1(n,o,r);case"Date":case"Symbol":case"Uint8Array":return KN(e,t,r);default:return GN(n,o,r)}}function sa(...e){return e.length===3?Dr(e[0],e[1],e[2]):Dr(e[0],[],e[1])}function r1(e){return Do(e)&&e[w]!=="Unsafe"}function o1(e,t,r){if(!N(r))return r;return r.map(o=>Kt(e.items,t,o))}function n1(e,t,r){const o=globalThis.Object.values(e.$defs);const n=e.$defs[e.$ref];return Kt(n,[...t,...o],r)}function i1(e,t,r){const o=e.unevaluatedProperties;const n=e.allOf.map(a=>Kt(a,t,de(r)));const i=n.reduce((a,c)=>D(c)?{...a,...c}:c,{});if(!D(r)||!D(i)||!Do(o))return i;const s=Lt(e);for(const a of Object.getOwnPropertyNames(r)){if(s.includes(a))continue;if(q(o,t,r[a])){i[a]=Kt(o,t,r[a])}}return i}function s1(e,t,r){if(!D(r)||N(r))return r;const o=e.additionalProperties;for(const n of Object.getOwnPropertyNames(r)){if(F(e.properties,n)){r[n]=Kt(e.properties[n],t,r[n]);continue}if(Do(o)&&q(o,t,r[n])){r[n]=Kt(o,t,r[n]);continue}delete r[n]}return r}function a1(e,t,r){if(!D(r))return r;const o=e.additionalProperties;const n=Object.getOwnPropertyNames(r);const[i,s]=Object.entries(e.patternProperties)[0];const a=new RegExp(i);for(const c of n){if(a.test(c)){r[c]=Kt(s,t,r[c]);continue}if(Do(o)&&q(o,t,r[c])){r[c]=Kt(o,t,r[c]);continue}delete r[c]}return r}function c1(e,t,r){return Kt(ye(e,t),t,r)}function u1(e,t,r){return Kt(ye(e,t),t,r)}function l1(e,t,r){if(!N(r))return r;if($e(e.items))return[];const o=Math.min(r.length,e.items.length);for(let n=0;n<o;n++){r[n]=Kt(e.items[n],t,r[n])}return r.length>o?r.slice(0,o):r}function d1(e,t,r){for(const o of e.anyOf){if(r1(o)&&q(o,t,r)){return Kt(o,t,r)}}return r}function Kt(e,t,r){const o=xe(e.$id)?it(e,t):t;const n=e;switch(n[w]){case"Array":return o1(n,o,r);case"Import":return n1(n,o,r);case"Intersect":return i1(n,o,r);case"Object":return s1(n,o,r);case"Record":return a1(n,o,r);case"Ref":return c1(n,o,r);case"This":return u1(n,o,r);case"Tuple":return l1(n,o,r);case"Union":return d1(n,o,r);default:return r}}function Yc(...e){return e.length===3?Kt(e[0],e[1],e[2]):Kt(e[0],[],e[1])}function Qc(e){return xe(e)&&!isNaN(e)&&!isNaN(parseFloat(e))}function p1(e){return Rr(e)||to(e)||ve(e)}function aa(e){return e===true||ve(e)&&e===1||Rr(e)&&e===BigInt("1")||xe(e)&&(e.toLowerCase()==="true"||e==="1")}function ca(e){return e===false||ve(e)&&(e===0||Object.is(e,-0))||Rr(e)&&e===BigInt("0")||xe(e)&&(e.toLowerCase()==="false"||e==="0"||e==="-0")}function f1(e){return xe(e)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i.test(e)}function m1(e){return xe(e)&&/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(e)}function h1(e){return xe(e)&&/^\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.test(e)}function g1(e){return xe(e)&&/^\d\d\d\d-[0-1]\d-[0-3]\dt(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)?$/i.test(e)}function y1(e){return xe(e)&&/^\d\d\d\d-[0-1]\d-[0-3]\d$/i.test(e)}function x1(e,t){const r=Q_(e);return r===t?r:e}function _1(e,t){const r=Z_(e);return r===t?r:e}function I1(e,t){const r=Y_(e);return r===t?r:e}function b1(e,t){return xe(e.const)?x1(t,e.const):ve(e.const)?_1(t,e.const):to(e.const)?I1(t,e.const):t}function Y_(e){return aa(e)?true:ca(e)?false:e}function w1(e){const t=r=>r.split(".")[0];return Qc(e)?BigInt(t(e)):ve(e)?BigInt(Math.trunc(e)):ca(e)?BigInt(0):aa(e)?BigInt(1):e}function Q_(e){return ho(e)&&e.description!==void 0?e.description.toString():p1(e)?e.toString():e}function Z_(e){return Qc(e)?parseFloat(e):aa(e)?1:ca(e)?0:e}function T1(e){return Qc(e)?parseInt(e):ve(e)?Math.trunc(e):aa(e)?1:ca(e)?0:e}function S1(e){return xe(e)&&e.toLowerCase()==="null"?null:e}function M1(e){return xe(e)&&e==="undefined"?void 0:e}function R1(e){return At(e)?e:ve(e)?new Date(e):aa(e)?new Date(1):ca(e)?new Date(0):Qc(e)?new Date(parseInt(e)):m1(e)?new Date(`1970-01-01T${e}.000Z`):f1(e)?new Date(`1970-01-01T${e}`):g1(e)?new Date(`${e}.000Z`):h1(e)?new Date(e):y1(e)?new Date(`${e}T00:00:00.000Z`):e}function O1(e){return e}function P1(e,t,r){const o=N(r)?r:[r];return o.map(n=>Ur(e.items,t,n))}function A1(e,t,r){return w1(r)}function k1(e,t,r){return Y_(r)}function E1(e,t,r){return R1(r)}function $1(e,t,r){const o=globalThis.Object.values(e.$defs);const n=e.$defs[e.$ref];return Ur(n,[...t,...o],r)}function v1(e,t,r){return T1(r)}function C1(e,t,r){return e.allOf.reduce((o,n)=>Ur(n,t,o),r)}function F1(e,t,r){return b1(e,r)}function N1(e,t,r){return S1(r)}function j1(e,t,r){return Z_(r)}function z1(e,t,r){if(!D(r)||N(r))return r;for(const o of Object.getOwnPropertyNames(e.properties)){if(!F(r,o))continue;r[o]=Ur(e.properties[o],t,r[o])}return r}function D1(e,t,r){const o=D(r)&&!N(r);if(!o)return r;const n=Object.getOwnPropertyNames(e.patternProperties)[0];const i=e.patternProperties[n];for(const[s,a]of Object.entries(r)){r[s]=Ur(i,t,a)}return r}function U1(e,t,r){return Ur(ye(e,t),t,r)}function L1(e,t,r){return Q_(r)}function q1(e,t,r){return xe(r)||ve(r)?Symbol(r):r}function K1(e,t,r){return Ur(ye(e,t),t,r)}function G1(e,t,r){const o=N(r)&&!$e(e.items);if(!o)return r;return r.map((n,i)=>{return i<e.items.length?Ur(e.items[i],t,n):n})}function B1(e,t,r){return M1(r)}function V1(e,t,r){for(const o of e.anyOf){if(q(o,t,r)){return r}}for(const o of e.anyOf){const n=Ur(o,t,de(r));if(!q(o,t,n))continue;return n}return r}function Ur(e,t,r){const o=it(e,t);const n=e;switch(e[w]){case"Array":return P1(n,o,r);case"BigInt":return A1(n,o,r);case"Boolean":return k1(n,o,r);case"Date":return E1(n,o,r);case"Import":return $1(n,o,r);case"Integer":return v1(n,o,r);case"Intersect":return C1(n,o,r);case"Literal":return F1(n,o,r);case"Null":return N1(n,o,r);case"Number":return j1(n,o,r);case"Object":return z1(n,o,r);case"Record":return D1(n,o,r);case"Ref":return U1(n,o,r);case"String":return L1(n,o,r);case"Symbol":return q1(n,o,r);case"This":return K1(n,o,r);case"Tuple":return G1(n,o,r);case"Undefined":return B1(n,o,r);case"Union":return V1(n,o,r);default:return O1(r)}}function Zc(...e){return e.length===3?Ur(e[0],e[1],e[2]):Ur(e[0],[],e[1])}var eu=class extends j{constructor(t,r,o){super(`Unable to decode value as it does not match the expected schema`);this.schema=t;this.value=r;this.error=o}};var Bp=class extends j{constructor(t,r,o,n){super(n instanceof Error?n.message:"Unknown error");this.schema=t;this.path=r;this.value=o;this.error=n}};function De(e,t,r){try{return me(e)?e[je].Decode(r):r}catch(o){throw new Bp(e,t,r,o)}}function H1(e,t,r,o){return N(o)?De(e,r,o.map((n,i)=>Lr(e.items,t,`${r}/${i}`,n))):De(e,r,o)}function W1(e,t,r,o){if(!D(o)||Wt(o))return De(e,r,o);const n=Fc(e);const i=n.map(u=>u[0]);const s={...o};for(const[u,d]of n)if(u in s){s[u]=Lr(d,t,`${r}/${u}`,s[u])}if(!me(e.unevaluatedProperties)){return De(e,r,s)}const a=Object.getOwnPropertyNames(s);const c=e.unevaluatedProperties;const l={...s};for(const u of a)if(!i.includes(u)){l[u]=De(c,`${r}/${u}`,l[u])}return De(e,r,l)}function J1(e,t,r,o){const n=globalThis.Object.values(e.$defs);const i=e.$defs[e.$ref];const s=Lr(i,[...t,...n],r,o);return De(e,r,s)}function X1(e,t,r,o){return De(e,r,Lr(e.not,t,r,o))}function Y1(e,t,r,o){if(!D(o))return De(e,r,o);const n=Lt(e);const i={...o};for(const l of n){if(!F(i,l))continue;if($e(i[l])&&(!xo(e.properties[l])||Ye.IsExactOptionalProperty(i,l)))continue;i[l]=Lr(e.properties[l],t,`${r}/${l}`,i[l])}if(!ze(e.additionalProperties)){return De(e,r,i)}const s=Object.getOwnPropertyNames(i);const a=e.additionalProperties;const c={...i};for(const l of s)if(!n.includes(l)){c[l]=De(a,`${r}/${l}`,c[l])}return De(e,r,c)}function Q1(e,t,r,o){if(!D(o))return De(e,r,o);const n=Object.getOwnPropertyNames(e.patternProperties)[0];const i=new RegExp(n);const s={...o};for(const u of Object.getOwnPropertyNames(o))if(i.test(u)){s[u]=Lr(e.patternProperties[n],t,`${r}/${u}`,s[u])}if(!ze(e.additionalProperties)){return De(e,r,s)}const a=Object.getOwnPropertyNames(s);const c=e.additionalProperties;const l={...s};for(const u of a)if(!i.test(u)){l[u]=De(c,`${r}/${u}`,l[u])}return De(e,r,l)}function Z1(e,t,r,o){const n=ye(e,t);return De(e,r,Lr(n,t,r,o))}function ej(e,t,r,o){const n=ye(e,t);return De(e,r,Lr(n,t,r,o))}function tj(e,t,r,o){return N(o)&&N(e.items)?De(e,r,e.items.map((n,i)=>Lr(n,t,`${r}/${i}`,o[i]))):De(e,r,o)}function rj(e,t,r,o){for(const n of e.anyOf){if(!q(n,t,o))continue;const i=Lr(n,t,r,o);return De(e,r,i)}return De(e,r,o)}function Lr(e,t,r,o){const n=it(e,t);const i=e;switch(e[w]){case"Array":return H1(i,n,r,o);case"Import":return J1(i,n,r,o);case"Intersect":return W1(i,n,r,o);case"Not":return X1(i,n,r,o);case"Object":return Y1(i,n,r,o);case"Record":return Q1(i,n,r,o);case"Ref":return Z1(i,n,r,o);case"Symbol":return De(i,r,o);case"This":return ej(i,n,r,o);case"Tuple":return tj(i,n,r,o);case"Union":return rj(i,n,r,o);default:return De(i,r,o)}}function tu(e,t,r){return Lr(e,t,"",r)}var ru=class extends j{constructor(t,r,o){super(`The encoded value does not match the expected schema`);this.schema=t;this.value=r;this.error=o}};var Vp=class extends j{constructor(t,r,o,n){super(`${n instanceof Error?n.message:"Unknown error"}`);this.schema=t;this.path=r;this.value=o;this.error=n}};function mt(e,t,r){try{return me(e)?e[je].Encode(r):r}catch(o){throw new Vp(e,t,r,o)}}function oj(e,t,r,o){const n=mt(e,r,o);return N(n)?n.map((i,s)=>qr(e.items,t,`${r}/${s}`,i)):n}function nj(e,t,r,o){const n=globalThis.Object.values(e.$defs);const i=e.$defs[e.$ref];const s=mt(e,r,o);return qr(i,[...t,...n],r,s)}function ij(e,t,r,o){const n=mt(e,r,o);if(!D(o)||Wt(o))return n;const i=Fc(e);const s=i.map(d=>d[0]);const a={...n};for(const[d,x]of i)if(d in a){a[d]=qr(x,t,`${r}/${d}`,a[d])}if(!me(e.unevaluatedProperties)){return a}const c=Object.getOwnPropertyNames(a);const l=e.unevaluatedProperties;const u={...a};for(const d of c)if(!s.includes(d)){u[d]=mt(l,`${r}/${d}`,u[d])}return u}function sj(e,t,r,o){return mt(e.not,r,mt(e,r,o))}function aj(e,t,r,o){const n=mt(e,r,o);if(!D(n))return n;const i=Lt(e);const s={...n};for(const u of i){if(!F(s,u))continue;if($e(s[u])&&(!xo(e.properties[u])||Ye.IsExactOptionalProperty(s,u)))continue;s[u]=qr(e.properties[u],t,`${r}/${u}`,s[u])}if(!ze(e.additionalProperties)){return s}const a=Object.getOwnPropertyNames(s);const c=e.additionalProperties;const l={...s};for(const u of a)if(!i.includes(u)){l[u]=mt(c,`${r}/${u}`,l[u])}return l}function cj(e,t,r,o){const n=mt(e,r,o);if(!D(o))return n;const i=Object.getOwnPropertyNames(e.patternProperties)[0];const s=new RegExp(i);const a={...n};for(const d of Object.getOwnPropertyNames(o))if(s.test(d)){a[d]=qr(e.patternProperties[i],t,`${r}/${d}`,a[d])}if(!ze(e.additionalProperties)){return a}const c=Object.getOwnPropertyNames(a);const l=e.additionalProperties;const u={...a};for(const d of c)if(!s.test(d)){u[d]=mt(l,`${r}/${d}`,u[d])}return u}function uj(e,t,r,o){const n=ye(e,t);const i=qr(n,t,r,o);return mt(e,r,i)}function lj(e,t,r,o){const n=ye(e,t);const i=qr(n,t,r,o);return mt(e,r,i)}function dj(e,t,r,o){const n=mt(e,r,o);return N(e.items)?e.items.map((i,s)=>qr(i,t,`${r}/${s}`,n[s])):[]}function pj(e,t,r,o){for(const n of e.anyOf){if(!q(n,t,o))continue;const i=qr(n,t,r,o);return mt(e,r,i)}for(const n of e.anyOf){const i=qr(n,t,r,o);if(!q(e,t,i))continue;return mt(e,r,i)}return mt(e,r,o)}function qr(e,t,r,o){const n=it(e,t);const i=e;switch(e[w]){case"Array":return oj(i,n,r,o);case"Import":return nj(i,n,r,o);case"Intersect":return ij(i,n,r,o);case"Not":return sj(i,n,r,o);case"Object":return aj(i,n,r,o);case"Record":return cj(i,n,r,o);case"Ref":return uj(i,n,r,o);case"This":return lj(i,n,r,o);case"Tuple":return dj(i,n,r,o);case"Union":return pj(i,n,r,o);default:return mt(i,r,o)}}function ou(e,t,r){return qr(e,t,"",r)}function fj(e,t){return me(e)||tt(e.items,t)}function mj(e,t){return me(e)||tt(e.items,t)}function hj(e,t){return me(e)||tt(e.returns,t)||e.parameters.some(r=>tt(r,t))}function gj(e,t){return me(e)||tt(e.returns,t)||e.parameters.some(r=>tt(r,t))}function yj(e,t){return me(e)||me(e.unevaluatedProperties)||e.allOf.some(r=>tt(r,t))}function xj(e,t){const r=globalThis.Object.getOwnPropertyNames(e.$defs).reduce((n,i)=>[...n,e.$defs[i]],[]);const o=e.$defs[e.$ref];return me(e)||tt(o,[...r,...t])}function _j(e,t){return me(e)||tt(e.items,t)}function Ij(e,t){return me(e)||tt(e.not,t)}function bj(e,t){return me(e)||Object.values(e.properties).some(r=>tt(r,t))||ze(e.additionalProperties)&&tt(e.additionalProperties,t)}function wj(e,t){return me(e)||tt(e.item,t)}function Tj(e,t){const r=Object.getOwnPropertyNames(e.patternProperties)[0];const o=e.patternProperties[r];return me(e)||tt(o,t)||ze(e.additionalProperties)&&me(e.additionalProperties)}function Sj(e,t){if(me(e))return true;return tt(ye(e,t),t)}function Mj(e,t){if(me(e))return true;return tt(ye(e,t),t)}function Rj(e,t){return me(e)||!$e(e.items)&&e.items.some(r=>tt(r,t))}function Oj(e,t){return me(e)||e.anyOf.some(r=>tt(r,t))}function tt(e,t){const r=it(e,t);const o=e;if(e.$id&&Hp.has(e.$id))return false;if(e.$id)Hp.add(e.$id);switch(e[w]){case"Array":return fj(o,r);case"AsyncIterator":return mj(o,r);case"Constructor":return hj(o,r);case"Function":return gj(o,r);case"Import":return xj(o,r);case"Intersect":return yj(o,r);case"Iterator":return _j(o,r);case"Not":return Ij(o,r);case"Object":return bj(o,r);case"Promise":return wj(o,r);case"Record":return Tj(o,r);case"Ref":return Sj(o,r);case"This":return Mj(o,r);case"Tuple":return Rj(o,r);case"Union":return Oj(o,r);default:return me(e)}}var Hp=new Set;function Ln(e,t){Hp.clear();return tt(e,t)}function eI(...e){const[t,r,o]=e.length===3?[e[0],e[1],e[2]]:[e[0],[],e[1]];if(!q(t,r,o))throw new eu(t,o,Jo(t,r,o).First());return Ln(t,r)?tu(t,r,o):o}function wo(e,t){const r=F(e,"default")?e.default:void 0;const o=jo(r)?r():de(r);return $e(t)?o:D(t)&&D(o)?Object.assign(o,t):t}function Wp(e){return Do(e)&&"default"in e}function Pj(e,t,r){if(N(r)){for(let n=0;n<r.length;n++){r[n]=Et(e.items,t,r[n])}return r}const o=wo(e,r);if(!N(o))return o;for(let n=0;n<o.length;n++){o[n]=Et(e.items,t,o[n])}return o}function Aj(e,t,r){return At(r)?r:wo(e,r)}function kj(e,t,r){const o=globalThis.Object.values(e.$defs);const n=e.$defs[e.$ref];return Et(n,[...t,...o],r)}function Ej(e,t,r){const o=wo(e,r);return e.allOf.reduce((n,i)=>{const s=Et(i,t,o);return D(s)?{...n,...s}:s},{})}function $j(e,t,r){const o=wo(e,r);if(!D(o))return o;const n=Object.getOwnPropertyNames(e.properties);for(const i of n){const s=Et(e.properties[i],t,o[i]);if($e(s))continue;o[i]=Et(e.properties[i],t,o[i])}if(!Wp(e.additionalProperties))return o;for(const i of Object.getOwnPropertyNames(o)){if(n.includes(i))continue;o[i]=Et(e.additionalProperties,t,o[i])}return o}function vj(e,t,r){const o=wo(e,r);if(!D(o))return o;const n=e.additionalProperties;const[i,s]=Object.entries(e.patternProperties)[0];const a=new RegExp(i);for(const c of Object.getOwnPropertyNames(o)){if(!(a.test(c)&&Wp(s)))continue;o[c]=Et(s,t,o[c])}if(!Wp(n))return o;for(const c of Object.getOwnPropertyNames(o)){if(a.test(c))continue;o[c]=Et(n,t,o[c])}return o}function Cj(e,t,r){return Et(ye(e,t),t,wo(e,r))}function Fj(e,t,r){return Et(ye(e,t),t,r)}function Nj(e,t,r){const o=wo(e,r);if(!N(o)||$e(e.items))return o;const[n,i]=[e.items,Math.max(e.items.length,o.length)];for(let s=0;s<i;s++){if(s<n.length)o[s]=Et(n[s],t,o[s])}return o}function jj(e,t,r){const o=wo(e,r);for(const n of e.anyOf){const i=Et(n,t,de(o));if(q(n,t,i)){return i}}return o}function Et(e,t,r){const o=it(e,t);const n=e;switch(n[w]){case"Array":return Pj(n,o,r);case"Date":return Aj(n,o,r);case"Import":return kj(n,o,r);case"Intersect":return Ej(n,o,r);case"Object":return $j(n,o,r);case"Record":return vj(n,o,r);case"Ref":return Cj(n,o,r);case"This":return Fj(n,o,r);case"Tuple":return Nj(n,o,r);case"Union":return jj(n,o,r);default:return wo(n,r)}}function nu(...e){return e.length===3?Et(e[0],e[1],e[2]):Et(e[0],[],e[1])}var Kr={};xn(Kr,{Delete:()=>Dj,Format:()=>ua,Get:()=>Lj,Has:()=>Uj,Set:()=>zj,ValuePointerRootDeleteError:()=>su,ValuePointerRootSetError:()=>iu});var iu=class extends j{constructor(t,r,o){super("Cannot set root value");this.value=t;this.path=r;this.update=o}};var su=class extends j{constructor(t,r){super("Cannot delete root value");this.value=t;this.path=r}};function tI(e){return e.indexOf("~")===-1?e:e.replace(/~1/g,"/").replace(/~0/g,"~")}function*ua(e){if(e==="")return;let[t,r]=[0,0];for(let o=0;o<e.length;o++){const n=e.charAt(o);if(n==="/"){if(o===0){t=o+1}else{r=o;yield tI(e.slice(t,r));t=o+1}}else{r=o}}yield tI(e.slice(t))}function zj(e,t,r){if(t==="")throw new iu(e,t,r);let[o,n,i]=[null,e,""];for(const s of ua(t)){if(n[s]===void 0)n[s]={};o=n;n=n[s];i=s}o[i]=r}function Dj(e,t){if(t==="")throw new su(e,t);let[r,o,n]=[null,e,""];for(const i of ua(t)){if(o[i]===void 0||o[i]===null)return;r=o;o=o[i];n=i}if(Array.isArray(r)){const i=parseInt(n);r.splice(i,1)}else{delete r[n]}}function Uj(e,t){if(t==="")return true;let[r,o,n]=[null,e,""];for(const i of ua(t)){if(o[i]===void 0)return false;r=o;o=o[i];n=i}return Object.getOwnPropertyNames(r).includes(n)}function Lj(e,t){if(t==="")return e;let r=e;for(const o of ua(t)){if(r[o]===void 0)return void 0;r=r[o]}return r}function qj(e,t){if(!D(t))return false;const r=[...Object.keys(e),...Object.getOwnPropertySymbols(e)];const o=[...Object.keys(t),...Object.getOwnPropertySymbols(t)];if(r.length!==o.length)return false;return r.every(n=>qn(e[n],t[n]))}function Kj(e,t){return At(t)&&e.getTime()===t.getTime()}function Gj(e,t){if(!N(t)||e.length!==t.length)return false;return e.every((r,o)=>qn(r,t[o]))}function Bj(e,t){if(!fr(t)||e.length!==t.length||Object.getPrototypeOf(e).constructor.name!==Object.getPrototypeOf(t).constructor.name)return false;return e.every((r,o)=>qn(r,t[o]))}function Vj(e,t){return e===t}function qn(e,t){if(At(e))return Kj(e,t);if(fr(e))return Bj(e,t);if(N(e))return Gj(e,t);if(D(e))return qj(e,t);if(Wt(e))return Vj(e,t);throw new Error("ValueEquals: Unable to compare value")}var Hj=ge({type:oe("insert"),path:kt(),value:Fr()});var Wj=ge({type:oe("update"),path:kt(),value:Fr()});var Jj=ge({type:oe("delete"),path:kt()});var oI=he([Hj,Wj,Jj]);var au=class extends j{constructor(t,r){super(r);this.value=t}};function cu(e,t){return{type:"update",path:e,value:t}}function nI(e,t){return{type:"insert",path:e,value:t}}function iI(e){return{type:"delete",path:e}}function rI(e){if(globalThis.Object.getOwnPropertySymbols(e).length>0)throw new au(e,"Cannot diff objects with symbols")}function*Xj(e,t,r){rI(t);rI(r);if(!ap(r))return yield cu(e,r);const o=globalThis.Object.getOwnPropertyNames(t);const n=globalThis.Object.getOwnPropertyNames(r);for(const i of n){if(F(t,i))continue;yield nI(`${e}/${i}`,r[i])}for(const i of o){if(!F(r,i))continue;if(qn(t,r))continue;yield*uu(`${e}/${i}`,t[i],r[i])}for(const i of o){if(F(r,i))continue;yield iI(`${e}/${i}`)}}function*Yj(e,t,r){if(!N(r))return yield cu(e,r);for(let o=0;o<Math.min(t.length,r.length);o++){yield*uu(`${e}/${o}`,t[o],r[o])}for(let o=0;o<r.length;o++){if(o<t.length)continue;yield nI(`${e}/${o}`,r[o])}for(let o=t.length-1;o>=0;o--){if(o<r.length)continue;yield iI(`${e}/${o}`)}}function*Qj(e,t,r){if(!fr(r)||t.length!==r.length||globalThis.Object.getPrototypeOf(t).constructor.name!==globalThis.Object.getPrototypeOf(r).constructor.name)return yield cu(e,r);for(let o=0;o<Math.min(t.length,r.length);o++){yield*uu(`${e}/${o}`,t[o],r[o])}}function*Zj(e,t,r){if(t===r)return;yield cu(e,r)}function*uu(e,t,r){if(ap(t))return yield*Xj(e,t,r);if(N(t))return yield*Yj(e,t,r);if(fr(t))return yield*Qj(e,t,r);if(Wt(t))return yield*Zj(e,t,r);throw new au(t,"Unable to diff value")}function sI(e,t){return[...uu("",e,t)]}function ez(e){return e.length>0&&e[0].path===""&&e[0].type==="update"}function tz(e){return e.length===0}function aI(e,t){if(ez(t)){return de(t[0].value)}if(tz(t)){return de(e)}const r=de(e);for(const o of t){switch(o.type){case"insert":{Kr.Set(r,o.path,o.value);break}case"update":{Kr.Set(r,o.path,o.value);break}case"delete":{Kr.Delete(r,o.path);break}}}return r}function cI(...e){const[t,r,o]=e.length===3?[e[0],e[1],e[2]]:[e[0],[],e[1]];const n=Ln(t,r)?ou(t,r,o):o;if(!q(t,r,n))throw new ru(t,n,Jo(t,r,n).First());return n}function lu(e){return D(e)&&!N(e)}var du=class extends j{constructor(t){super(t)}};function rz(e,t,r,o){if(!lu(r)){Kr.Set(e,t,de(o))}else{const n=Object.getOwnPropertyNames(r);const i=Object.getOwnPropertyNames(o);for(const s of n){if(!i.includes(s)){delete r[s]}}for(const s of i){if(!n.includes(s)){r[s]=null}}for(const s of i){Jp(e,`${t}/${s}`,r[s],o[s])}}}function oz(e,t,r,o){if(!N(r)){Kr.Set(e,t,de(o))}else{for(let n=0;n<o.length;n++){Jp(e,`${t}/${n}`,r[n],o[n])}r.splice(o.length)}}function nz(e,t,r,o){if(fr(r)&&r.length===o.length){for(let n=0;n<r.length;n++){r[n]=o[n]}}else{Kr.Set(e,t,de(o))}}function iz(e,t,r,o){if(r===o)return;Kr.Set(e,t,o)}function Jp(e,t,r,o){if(N(o))return oz(e,t,r,o);if(fr(o))return nz(e,t,r,o);if(lu(o))return rz(e,t,r,o);if(Wt(o))return iz(e,t,r,o)}function uI(e){return fr(e)||Wt(e)}function sz(e,t){return lu(e)&&N(t)||N(e)&&lu(t)}function lI(e,t){if(uI(e)||uI(t))throw new du("Only object and array types can be mutated at the root level");if(sz(e,t))throw new du("Cannot assign due type mismatch of assignable values");Jp(e,"",e,t)}var pu=class extends j{constructor(t){super(t)}};var Xp;(function(e){const t=new Map([["Assert",(i,s,a)=>{Jc(i,s,a);return a}],["Cast",(i,s,a)=>sa(i,s,a)],["Clean",(i,s,a)=>Yc(i,s,a)],["Clone",(i,s,a)=>de(a)],["Convert",(i,s,a)=>Zc(i,s,a)],["Decode",(i,s,a)=>Ln(i,s)?tu(i,s,a):a],["Default",(i,s,a)=>nu(i,s,a)],["Encode",(i,s,a)=>Ln(i,s)?ou(i,s,a):a]]);function r(i){t.delete(i)}e.Delete=r;function o(i,s){t.set(i,s)}e.Set=o;function n(i){return t.get(i)}e.Get=n})(Xp||(Xp={}));var dI=["Clone","Clean","Default","Convert","Assert","Decode"];function az(e,t,r,o){return e.reduce((n,i)=>{const s=Xp.Get(i);if($e(s))throw new pu(`Unable to find Parse operation '${i}'`);return s(t,r,n)},o)}function pI(...e){const[t,r,o,n]=e.length===4?[e[0],e[1],e[2],e[3]]:e.length===3?N(e[0])?[e[0],e[1],[],e[2]]:[dI,e[0],e[1],e[2]]:e.length===2?[dI,e[0],[],e[1]]:(()=>{throw new pu("Invalid Arguments")})();return az(t,r,o,n)}var Kn={};xn(Kn,{Assert:()=>Jc,Cast:()=>sa,Check:()=>q,Clean:()=>Yc,Clone:()=>de,Convert:()=>Zc,Create:()=>zr,Decode:()=>eI,Default:()=>nu,Diff:()=>sI,Edit:()=>oI,Encode:()=>cI,Equal:()=>qn,Errors:()=>Jo,Hash:()=>Qi,Mutate:()=>lI,Parse:()=>pI,Patch:()=>aI,ValueErrorIterator:()=>Wo});var fI=new Map;function cz(e,t){return(r,o,n)=>{if(r.api!==e){throw new Error(`Mismatched api: ${r.api} expected ${e}`)}return t(r,o,n)}}function uz(e,t){return(r,o,n)=>{if(r.api!==e){throw new Error(`Mismatched api: ${r.api} expected ${e}`)}return t(r,o,n)}}function Gr(e,t){fI.set(e.api,{provider:{api:e.api,stream:cz(e.api,e.stream),streamSimple:uz(e.api,e.streamSimple)},sourceId:t})}function mI(e){return fI.get(e)?.provider}var mu=null;var Qp=null;var Zp=null;var Yp=e=>import(e);var lz="node:fs";var dz="node:os";var pz="node:path";if(typeof process!=="undefined"&&(process.versions?.node||process.versions?.bun)){Yp(lz).then(e=>{mu=e.existsSync});Yp(dz).then(e=>{Qp=e.homedir});Yp(pz).then(e=>{Zp=e.join})}var fu=null;function or(e){if(!process.versions?.bun)return void 0;if(typeof process==="undefined")return void 0;if(Object.keys(process.env).length>0)return void 0;if(fu===null){fu=new Map;try{const{readFileSync:t}=tw("node:fs");const r=t("/proc/self/environ","utf-8");for(const o of r.split("\0")){const n=o.indexOf("=");if(n>0){fu.set(o.slice(0,n),o.slice(n+1))}}}catch{}}return fu.get(e)}var la=null;function fz(){if(la===null){if(!mu||!Qp||!Zp){const t=typeof process!=="undefined"&&(process.versions?.node||process.versions?.bun);if(!t){la=false}return false}const e=process.env.GOOGLE_APPLICATION_CREDENTIALS||or("GOOGLE_APPLICATION_CREDENTIALS");if(e){la=mu(e)}else{la=mu(Zp(Qp(),".config","gcloud","application_default_credentials.json"))}}return la}function mz(e){if(e==="github-copilot"){return["COPILOT_GITHUB_TOKEN"]}if(e==="anthropic"){return["ANTHROPIC_OAUTH_TOKEN","ANTHROPIC_API_KEY"]}const t={"ant-ling":"ANT_LING_API_KEY",openai:"OPENAI_API_KEY","azure-openai-responses":"AZURE_OPENAI_API_KEY",nvidia:"NVIDIA_API_KEY",deepseek:"DEEPSEEK_API_KEY",google:"GEMINI_API_KEY","google-vertex":"GOOGLE_CLOUD_API_KEY",groq:"GROQ_API_KEY",cerebras:"CEREBRAS_API_KEY",xai:"XAI_API_KEY",openrouter:"OPENROUTER_API_KEY","vercel-ai-gateway":"AI_GATEWAY_API_KEY",zai:"ZAI_API_KEY","zai-coding-cn":"ZAI_CODING_CN_API_KEY",mistral:"MISTRAL_API_KEY",alran:"ALRAN_API_KEY","alran-cn":"ALRAN_CN_API_KEY",moonshotai:"MOONSHOT_API_KEY","moonshotai-cn":"MOONSHOT_API_KEY",huggingface:"HF_TOKEN",fireworks:"FIREWORKS_API_KEY",together:"TOGETHER_API_KEY",opencode:"OPENCODE_API_KEY","opencode-go":"OPENCODE_API_KEY","kimi-coding":"KIMI_API_KEY","cloudflare-workers-ai":"CLOUDFLARE_API_KEY","cloudflare-ai-gateway":"CLOUDFLARE_API_KEY",xiaomi:"XIAOMI_API_KEY","xiaomi-token-plan-cn":"XIAOMI_TOKEN_PLAN_CN_API_KEY","xiaomi-token-plan-ams":"XIAOMI_TOKEN_PLAN_AMS_API_KEY","xiaomi-token-plan-sgp":"XIAOMI_TOKEN_PLAN_SGP_API_KEY"};const r=t[e];return r?[r]:void 0}function hz(e){const t=mz(e);if(!t)return void 0;const r=t.filter(o=>!!process.env[o]||!!or(o));return r.length>0?r:void 0}function ef(e){const t=hz(e);if(t?.[0]){return process.env[t[0]]||or(t[0])}if(e==="google-vertex"){const r=fz();const o=!!(process.env.GOOGLE_CLOUD_PROJECT||process.env.GCLOUD_PROJECT||or("GOOGLE_CLOUD_PROJECT")||or("GCLOUD_PROJECT"));const n=!!(process.env.GOOGLE_CLOUD_LOCATION||or("GOOGLE_CLOUD_LOCATION"));if(r&&o&&n){return"<authenticated>"}}if(e==="amazon-bedrock"){if(process.env.AWS_PROFILE||process.env.AWS_ACCESS_KEY_ID&&process.env.AWS_SECRET_ACCESS_KEY||process.env.AWS_BEARER_TOKEN_BEDROCK||process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI||process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI||process.env.AWS_WEB_IDENTITY_TOKEN_FILE||or("AWS_PROFILE")||or("AWS_ACCESS_KEY_ID")&&or("AWS_SECRET_ACCESS_KEY")||or("AWS_BEARER_TOKEN_BEDROCK")||or("AWS_CONTAINER_CREDENTIALS_RELATIVE_URI")||or("AWS_CONTAINER_CREDENTIALS_FULL_URI")||or("AWS_WEB_IDENTITY_TOKEN_FILE")){return"<authenticated>"}}return void 0}var hI={openrouter:{"black-forest-labs/flux.2-flex":{id:"black-forest-labs/flux.2-flex",name:"Black Forest Labs: FLUX.2 Flex",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"black-forest-labs/flux.2-klein-4b":{id:"black-forest-labs/flux.2-klein-4b",name:"Black Forest Labs: FLUX.2 Klein 4B",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"black-forest-labs/flux.2-max":{id:"black-forest-labs/flux.2-max",name:"Black Forest Labs: FLUX.2 Max",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"black-forest-labs/flux.2-pro":{id:"black-forest-labs/flux.2-pro",name:"Black Forest Labs: FLUX.2 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"bytedance-seed/seedream-4.5":{id:"bytedance-seed/seedream-4.5",name:"ByteDance Seed: Seedream 4.5",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"google/gemini-2.5-flash-image":{id:"google/gemini-2.5-flash-image",name:"Google: Nano Banana (Gemini 2.5 Flash Image)",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:.3,output:2.5,cacheRead:.03,cacheWrite:.08333333333333334}},"google/gemini-3-pro-image-preview":{id:"google/gemini-3-pro-image-preview",name:"Google: Nano Banana Pro (Gemini 3 Pro Image Preview)",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:2,output:12,cacheRead:.19999999999999998,cacheWrite:.375}},"google/gemini-3.1-flash-image-preview":{id:"google/gemini-3.1-flash-image-preview",name:"Google: Nano Banana 2 (Gemini 3.1 Flash Image Preview)",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:.5,output:3,cacheRead:0,cacheWrite:0}},"microsoft/mai-image-2.5":{id:"microsoft/mai-image-2.5",name:"Microsoft: MAI-Image-2.5",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:5,output:0,cacheRead:0,cacheWrite:0}},"openai/gpt-5-image":{id:"openai/gpt-5-image",name:"OpenAI: GPT-5 Image",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:10,output:10,cacheRead:1.25,cacheWrite:0}},"openai/gpt-5-image-mini":{id:"openai/gpt-5-image-mini",name:"OpenAI: GPT-5 Image Mini",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:2.5,output:2,cacheRead:.25,cacheWrite:0}},"openai/gpt-5.4-image-2":{id:"openai/gpt-5.4-image-2",name:"OpenAI: GPT-5.4 Image 2",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["image","text"],output:["image","text"],cost:{input:8,output:15,cacheRead:2,cacheWrite:0}},"openrouter/auto":{id:"openrouter/auto",name:"Auto Router",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["text","image"],cost:{input:-1e6,output:-1e6,cacheRead:0,cacheWrite:0}},"recraft/recraft-v3":{id:"recraft/recraft-v3",name:"Recraft: Recraft V3",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4":{id:"recraft/recraft-v4",name:"Recraft: Recraft V4",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4-pro":{id:"recraft/recraft-v4-pro",name:"Recraft: Recraft V4 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4-pro-vector":{id:"recraft/recraft-v4-pro-vector",name:"Recraft: Recraft V4 Pro Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4-vector":{id:"recraft/recraft-v4-vector",name:"Recraft: Recraft V4 Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1":{id:"recraft/recraft-v4.1",name:"Recraft: Recraft V4.1",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-pro":{id:"recraft/recraft-v4.1-pro",name:"Recraft: Recraft V4.1 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-pro-vector":{id:"recraft/recraft-v4.1-pro-vector",name:"Recraft: Recraft V4.1 Pro Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-utility":{id:"recraft/recraft-v4.1-utility",name:"Recraft: Recraft V4.1 Utility",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-utility-pro":{id:"recraft/recraft-v4.1-utility-pro",name:"Recraft: Recraft V4.1 Utility Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"recraft/recraft-v4.1-vector":{id:"recraft/recraft-v4.1-vector",name:"Recraft: Recraft V4.1 Vector",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-fast":{id:"sourceful/riverflow-v2-fast",name:"Sourceful: Riverflow V2 Fast",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-fast-preview":{id:"sourceful/riverflow-v2-fast-preview",name:"Sourceful: Riverflow V2 Fast Preview",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-max-preview":{id:"sourceful/riverflow-v2-max-preview",name:"Sourceful: Riverflow V2 Max Preview",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-pro":{id:"sourceful/riverflow-v2-pro",name:"Sourceful: Riverflow V2 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2-standard-preview":{id:"sourceful/riverflow-v2-standard-preview",name:"Sourceful: Riverflow V2 Standard Preview",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2.5-fast":{id:"sourceful/riverflow-v2.5-fast",name:"Sourceful: Riverflow V2.5 Fast",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"sourceful/riverflow-v2.5-pro":{id:"sourceful/riverflow-v2.5-pro",name:"Sourceful: Riverflow V2.5 Pro",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}},"x-ai/grok-imagine-image-quality":{id:"x-ai/grok-imagine-image-quality",name:"xAI: Grok Imagine Image Quality",api:"openrouter-images",provider:"openrouter",baseUrl:"https://openrouter.ai/api/v1",input:["text","image"],output:["image"],cost:{input:0,output:0,cacheRead:0,cacheWrite:0}}}};var gz=new Map;for(const[e,t]of Object.entries(hI)){const r=new Map;for(const[o,n]of Object.entries(t)){r.set(o,n)}gz.set(e,r)}var yz=new Map;function xz(e,t){return(r,o,n)=>{if(r.api!==e){throw new Error(`Mismatched api: ${r.api} expected ${e}`)}return t(r,o,n)}}function gI(e,t){yz.set(e.api,{provider:{api:e.api,generateImages:xz(e.api,e.generateImages)},sourceId:t})}var yI;function _z(e,t){return{api:e.api,provider:e.provider,model:e.id,output:[],stopReason:"error",errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}function Iz(){yI||=import("./openrouter-G2EHY5BD.js").then(e=>e);return yI}var bz=async(e,t,r)=>{try{const o=await Iz();return await o.generateImagesOpenRouter(e,t,r)}catch(o){return _z(e,o)}};function wz(){gI({api:"openrouter-images",generateImages:bz})}wz();var Tz=e=>{const t=__alran_tuiPackageEntryUrl.endsWith(".js")?e.replace(/\.ts$/,".js"):e;return import(t)};var xI;var _I;var II;var bI;var wI;var TI;var SI;var MI;var RI;var OI;function PI(e,t){(async()=>{for await(const r of t){e.push(r)}e.end()})()}function AI(e,t){return{role:"assistant",content:[],api:e.api,provider:e.provider,model:e.id,usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"error",errorMessage:t instanceof Error?t.message:String(t),timestamp:Date.now()}}function To(e){return(t,r,o)=>{const n=new Ou;e().then(i=>{const s=i.stream(t,r,o);PI(n,s)}).catch(i=>{Pu(o?.onProviderError,i,t);const s=AI(t,i);n.push({type:"error",reason:"error",error:s});n.end(s)});return n}}function So(e){return(t,r,o)=>{const n=new Ou;e().then(i=>{const s=i.streamSimple(t,r,o);PI(n,s)}).catch(i=>{const s=AI(t,i);n.push({type:"error",reason:"error",error:s});n.end(s)});return n}}function kI(){xI||=import("./anthropic-MN33DP4E.js").then(e=>{const t=e;return{stream:t.streamAnthropic,streamSimple:t.streamSimpleAnthropic}});return xI}function EI(){_I||=import("./azure-openai-responses-OWHMUNKC.js").then(e=>{const t=e;return{stream:t.streamAzureOpenAIResponses,streamSimple:t.streamSimpleAzureOpenAIResponses}});return _I}function $I(){II||=import("./google-UJAPMFAB.js").then(e=>{const t=e;return{stream:t.streamGoogle,streamSimple:t.streamSimpleGoogle}});return II}function vI(){bI||=import("./google-vertex-VLSF55PW.js").then(e=>{const t=e;return{stream:t.streamGoogleVertex,streamSimple:t.streamSimpleGoogleVertex}});return bI}function CI(){wI||=import("./mistral-ZJZUEF2X.js").then(e=>{const t=e;return{stream:t.streamMistral,streamSimple:t.streamSimpleMistral}});return wI}function FI(){TI||=import("./openai-codex-responses-FPCDNRL5.js").then(e=>{const t=e;return{stream:t.streamOpenAICodexResponses,streamSimple:t.streamSimpleOpenAICodexResponses}});return TI}function NI(){SI||=import("./openai-completions-D32YW6KL.js").then(e=>{const t=e;return{stream:t.streamOpenAICompletions,streamSimple:t.streamSimpleOpenAICompletions}});return SI}function jI(){MI||=import("./openai-responses-ZCGSENM4.js").then(e=>{const t=e;return{stream:t.streamOpenAIResponses,streamSimple:t.streamSimpleOpenAIResponses}});return MI}function zI(){if(RI){return Promise.resolve(RI)}OI||=Tz("./amazon-bedrock.ts").then(e=>{const t=e;return{stream:t.streamBedrock,streamSimple:t.streamSimpleBedrock}});return OI}var Sz=To(kI);var Mz=So(kI);var Rz=To(EI);var Oz=So(EI);var Pz=To($I);var Az=So($I);var kz=To(vI);var Ez=So(vI);var $z=To(CI);var vz=So(CI);var Cz=To(FI);var Fz=So(FI);var Nz=To(NI);var jz=So(NI);var zz=To(jI);var Dz=So(jI);var Uz=To(zI);var Lz=So(zI);function qz(){Gr({api:"anthropic-messages",stream:Sz,streamSimple:Mz});Gr({api:"openai-completions",stream:Nz,streamSimple:jz});Gr({api:"mistral-conversations",stream:$z,streamSimple:vz});Gr({api:"openai-responses",stream:zz,streamSimple:Dz});Gr({api:"azure-openai-responses",stream:Rz,streamSimple:Oz});Gr({api:"openai-codex-responses",stream:Cz,streamSimple:Fz});Gr({api:"google-generative-ai",stream:Pz,streamSimple:Az});Gr({api:"google-vertex",stream:kz,streamSimple:Ez});Gr({api:"bedrock-converse-stream",stream:Uz,streamSimple:Lz})}qz();function Kz(e){return typeof e==="string"&&e.trim().length>0}function Gz(e,t){if(Kz(t?.apiKey))return t;const r=ef(e.provider);if(!r)return t;return{...t,apiKey:r}}function Bz(e){const t=mI(e);if(!t){throw new Error(`No API provider registered for api: ${e}`)}return t}function Vz(e,t,r){const o=Bz(e.api);return o.streamSimple(e,t,Gz(e,r))}async function kX(e,t,r){const o=Vz(e,t,r);return o.result()}var Hz=[/prompt is too long/i,/request_too_large/i,/input is too long for requested model/i,/exceeds the context window/i,/exceeds (?:the )?(?:model'?s )?maximum context length of [\d,]+ tokens?/i,/input token count.*exceeds the maximum/i,/maximum prompt length is \d+/i,/reduce the length of the messages/i,/maximum context length is \d+ tokens/i,/exceeds (?:the )?maximum allowed input length of [\d,]+ tokens?/i,/input \(\d+ tokens\) is longer than the model'?s context length \(\d+ tokens\)/i,/exceeds the limit of \d+/i,/exceeds the available context size/i,/greater than the context length/i,/context window exceeds limit/i,/exceeded model token limit/i,/too large for model with \d+ maximum context length/i,/model_context_window_exceeded/i,/prompt too long; exceeded (?:max )?context length/i,/context[_ ]length[_ ]exceeded/i,/too many tokens/i,/token limit exceeded/i,/^4(?:00|13)\s*(?:status code)?\s*\(no body\)/i];var Wz=[/^(Throttling error|Service unavailable):/i,/rate limit/i,/too many requests/i];function vX(e,t){if(e.stopReason==="error"&&e.errorMessage){const r=Wz.some(o=>o.test(e.errorMessage));if(!r&&Hz.some(o=>o.test(e.errorMessage))){return true}}if(t&&e.stopReason==="stop"){const r=e.usage.input+e.usage.cacheRead;if(r>t){return true}}if(t&&e.stopReason==="length"&&e.usage.output===0){const r=e.usage.input+e.usage.cacheRead;if(r>=t*.99){return true}}return false}var DI=new WeakMap;var Xz=Symbol.for("TypeBox.Kind");function Gn(e){return typeof e==="object"&&e!==null}function tf(e){return Gn(e)}function Yz(e){return Gn(e)&&Object.getOwnPropertySymbols(e).includes(Xz)}function Qz(e){if(typeof e.type==="string"){return[e.type]}if(Array.isArray(e.type)){return e.type.filter(t=>typeof t==="string")}return[]}function Zz(e,t){switch(t){case"number":return typeof e==="number";case"integer":return typeof e==="number"&&Number.isInteger(e);case"boolean":return typeof e==="boolean";case"string":return typeof e==="string";case"null":return e===null;case"array":return Array.isArray(e);case"object":return Gn(e)&&!Array.isArray(e);default:return false}}function eD(e){return Gn(e)}function tD(e){if(!eD(e)){return void 0}try{return LI(e)}catch{return void 0}}function rD(e,t){switch(t){case"number":{if(e===null){return 0}if(typeof e==="string"&&e.trim()!==""){const r=Number(e);if(Number.isFinite(r)){return r}}if(typeof e==="boolean"){return e?1:0}return e}case"integer":{if(e===null){return 0}if(typeof e==="string"&&e.trim()!==""){const r=Number(e);if(Number.isInteger(r)){return r}}if(typeof e==="boolean"){return e?1:0}return e}case"boolean":{if(e===null){return false}if(typeof e==="string"){if(e==="true"){return true}if(e==="false"){return false}}if(typeof e==="number"){if(e===1){return true}if(e===0){return false}}return e}case"string":{if(e===null){return""}if(typeof e==="number"||typeof e==="boolean"){return String(e)}return e}case"null":{if(e===""||e===0||e===false){return null}return e}default:return e}}function oD(e,t){const r=t.properties;const o=new Set(r?Object.keys(r):[]);if(r){for(const[n,i]of Object.entries(r)){if(!(n in e)){continue}e[n]=Bn(e[n],i)}}if(t.additionalProperties&&tf(t.additionalProperties)){for(const[n,i]of Object.entries(e)){if(o.has(n)){continue}e[n]=Bn(i,t.additionalProperties)}}}function nD(e,t){if(Array.isArray(t.items)){for(let r=0;r<e.length;r++){const o=t.items[r];if(!o){continue}e[r]=Bn(e[r],o)}return}if(tf(t.items)){for(let r=0;r<e.length;r++){e[r]=Bn(e[r],t.items)}}}function UI(e,t){for(const r of t){const o=structuredClone(e);const n=Bn(o,r);const i=tD(r);if(i?.Check(n)){return n}}return e}function Bn(e,t){let r=e;if(Array.isArray(t.allOf)){for(const i of t.allOf){r=Bn(r,i)}}if(Array.isArray(t.anyOf)){r=UI(r,t.anyOf)}if(Array.isArray(t.oneOf)){r=UI(r,t.oneOf)}const o=Qz(t);const n=o.length>1&&o.some(i=>Zz(r,i));if(o.length>0&&!n){for(const i of o){const s=rD(r,i);if(s!==r){r=s;break}}}if(o.includes("object")&&Gn(r)&&!Array.isArray(r)){oD(r,t)}if(o.includes("array")&&Array.isArray(r)){nD(r,t)}return r}function LI(e){const t=e;const r=DI.get(t);if(r){return r}const o=Kf(e);DI.set(t,o);return o}function iD(e){if(e.keyword==="required"){const r=e.params.requiredProperties;const o=r?.[0];if(o){const n=e.instancePath.replace(/^\//,"").replace(/\//g,".");return n?`${n}.${o}`:o}}const t=e.instancePath.replace(/^\//,"").replace(/\//g,".");return t||"root"}function qI(e,t){const r=structuredClone(t.arguments);qf.Convert(e.parameters,r);const o=LI(e.parameters);if(!Yz(e.parameters)&&tf(e.parameters)){const s=Bn(r,e.parameters);if(s!==r){if(Gn(r)&&Gn(s)){for(const a of Object.keys(r)){delete r[a]}Object.assign(r,s)}else{return o.Check(s)?s:r}}}if(o.Check(r)){return r}const n=o.Errors(r).map(s=>` - ${iD(s)}: ${s.message}`).join("\n")||"Unknown validation error";const i=`Validation failed for tool "${t.name}":
|
|
9
|
-
${n}
|
|
10
|
-
|
|
11
|
-
Received arguments:
|
|
12
|
-
${JSON.stringify(t.arguments,null,2)}`;throw new Error(i)}function sD(e,t){if(!aD(e)||!hu(t))return t;const r=w in e;if(r&&Kn.Check(e,t))return t;let o;try{o=qI(uD(dD(e)),lD(t))}catch{return t}if(!rf(t,o))return t;if(r)return Kn.Check(e,o)?o:t;return cD(t,o)?t:o}function rf(e,t){if(Object.is(e,t))return true;if(typeof e==="string"){return typeof t==="number"&&Number.isFinite(t)&&String(t)===e.trim()}if(Array.isArray(e)){return Array.isArray(t)&&t.length===e.length&&e.every((r,o)=>rf(r,t[o]))}if(hu(e)){if(!hu(t))return false;const r=Object.keys(e);if(r.length!==Object.keys(t).length)return false;return r.every(o=>Object.hasOwn(t,o)&&rf(e[o],t[o]))}return false}var KI=new WeakMap;function aD(e){return hu(e)}function cD(e,t){return JSON.stringify(e)===JSON.stringify(t)}function uD(e){return{name:"nested",description:"",parameters:e}}function lD(e){return{type:"toolCall",id:"nested",name:"nested",arguments:e}}function dD(e){if(!(w in e))return e;let t=KI.get(e);if(t===void 0){t=JSON.parse(JSON.stringify(e));KI.set(e,t)}return t}function hu(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function pD(e,t,r){const o=e.find(n=>n.def.name===t);return Boolean(o&&Kn.Check(o.def.schema,r))}var mD={name:"read",executionMode:"parallel",description:"Read the contents of a file. Supports text, images (jpg, png, gif, webp), and video (mp4, avi, mov, mkv) when the active model declares video support; otherwise video files are read as a text-only placeholder. Output is truncated to a maximum number of lines/bytes \u2014 use `offset` and `limit` to page through long files.",schema:p.Object({path:p.String({description:"Absolute or workspace-relative file path."}),offset:p.Optional(p.Number({description:"The line number to start reading from (1-indexed). Only provide if the file is too large to read at once."})),limit:p.Optional(p.Number({description:"The number of lines to read. Only provide if the file is too large to read at once."}))})};var hD={name:"write",executionMode:"sequential",description:"Write content to a file. Creates the file if it does not exist, overwrites it if it does, and creates parent directories as needed. Prefer the edit tool for modifying existing files; only use write for new files or complete rewrites. If the file already exists, read it first before overwriting; writing replaces the entire previous content. Content is written literally, including line endings; NEVER include the line-number prefixes shown by the read tool. Do not proactively create documentation files (*.md, README) unless explicitly requested.",schema:p.Object({path:p.String({description:"Absolute or workspace-relative file path."}),content:p.String({description:"Full file content to write."})})};var xY=p.Object({path:p.String({description:"Absolute or workspace-relative file path."}),edits:p.Array(p.Object({oldText:p.String({description:"Exact existing text to replace."}),newText:p.String({description:"Replacement text."})}),{description:"Ordered list of replacements; all must succeed."})});var gD={name:"bash",executionMode:"sequential",description:"Execute a bash command. Returns combined stdout + stderr after the command exits. Supports an optional timeout in seconds. IMPORTANT: each invocation is stateless with respect to the working directory \u2014 every command starts from the same fixed default directory in a fresh shell, NOT from where a previous command left off. A `cd` (e.g. `cd ..`) only affects that single command and does NOT change the cwd of the next call. To operate in a different directory, scope it within the same call (e.g. `cd subdir && some-command`) or use absolute paths.",schema:p.Object({command:p.String({description:"Shell command line to execute."}),timeout:p.Optional(p.Number({description:"Timeout in seconds. Default is host-defined."}))})};var yD={name:"grep",executionMode:"parallel",description:"Search file contents for a regex pattern using ripgrep. Respects .gitignore. Output is truncated to a maximum number of matches/bytes; long lines are clipped.",schema:p.Object({pattern:p.String({description:"Regex pattern (or literal if `literal=true`)."}),path:p.Optional(p.String({description:"Directory or file to search. Defaults to cwd."})),glob:p.Optional(p.String({description:"File-glob filter, e.g. '*.ts' or '**/*.spec.ts'."})),ignoreCase:p.Optional(p.Boolean({description:"Case-insensitive search."})),literal:p.Optional(p.Boolean({description:"Treat pattern as literal string instead of regex."})),context:p.Optional(p.Number({description:"Lines of context before and after each match."})),limit:p.Optional(p.Number({description:"Maximum number of matches to return."}))})};var xD={name:"glob",executionMode:"parallel",description:"Search for files by glob pattern. Respects .gitignore. Returns file paths relative to the search root, truncated when results exceed the limit.",schema:p.Object({pattern:p.String({description:"Glob pattern, e.g. '**/*.ts' or 'src/**/*.tsx'."}),path:p.Optional(p.String({description:"Search root. Defaults to cwd."})),limit:p.Optional(p.Number({description:"Maximum number of file paths to return."}))})};var _D={name:"todowrite",executionMode:"sequential",description:"Create or update a structured task list for a complex coding session. Use it for multi-step work or explicit user task lists; skip it for single, trivial, or purely conversational requests. Keep exactly one task in_progress and update statuses as work progresses.",schema:p.Object({todos:p.Array(p.Object({content:p.String({description:"Brief description of the task"}),status:p.String({description:"Current status of the task: pending, in_progress, completed, cancelled"}),priority:p.String({description:"Priority level of the task: high, medium, low"})}),{description:"The updated todo list"})})};var ID=`Launch a new agent to handle complex, multistep tasks autonomously.
|
|
13
|
-
|
|
14
|
-
Use this for broad research, parallelizable investigation, or delegated implementation. Do not use it for targeted file reads, grep-style code searches, or work that is simpler to do directly.
|
|
15
|
-
|
|
16
|
-
Each invocation is a stateless, one-shot task. The sub-agent's result is returned only to you, so summarize any user-visible outcome yourself.`;var bD={name:"task",executionMode:"sequential",description:ID,schema:p.Object({description:p.String({description:"A short (3-5 words) description of the task"}),prompt:p.String({description:"The task for the agent to perform"}),subagent_type:p.String({description:"The type of specialized agent to use for this task"})})};var GI={name:"web_search",description:["Search the web for external facts and current information such as news, prices, places, and recent posts.","Use before answering or asking for clarification when external facts are unfamiliar or unsupported, including recent, changeable, niche, or user-provided claims. Skip verification when facts are clearly stable or already supported by the conversation, local files, or stable general knowledge.","Prefer primary or authoritative sources. For important, surprising, disputed, or source-dependent claims, cross-check key facts across multiple reliable sources when practical. State when sources conflict or only one reliable source is available.","Search misses do not prove non-existence. If results are inconclusive, inspect an authoritative source with an available page-reading tool, or state that the claim could not be verified.","Report only searches actually performed and cite URLs returned by tools. A search result does not establish that its source page was opened or verified; claim that only after a tool actually read the page."].join("\n"),schema:p.Object({query:p.String({description:"Search query."}),count:p.Optional(p.Integer({description:"Max results (default 10)."})),freshness:p.Optional(p.String({description:"noLimit (default) | day | week | month | year."})),search_type:p.Optional(p.String({description:"search (default) | videos | places | news | shopping."}))})};var wD=p.Object({file_path:p.String({description:"Local workspace path of the image file to analyze."}),prompt:p.Optional(p.String({description:'Defaults to "Describe this content" if omitted.'}))});var BI=p.Object({file_path:p.String({description:"Local workspace path of the audio file to analyze."}),prompt:p.Optional(p.String({description:'Defaults to "Describe this content" if omitted.'}))});var TD=p.Object({file_path:p.String({description:"Local workspace path of the video file to analyze."}),prompt:p.Optional(p.String({description:'Defaults to "Describe this content" if omitted.'}))});var Zi=GI;var Xo={name:"images_understand",description:"Offload local image FILES to a separate vision model for text descriptions. You are already multimodal: if an image is visible in this conversation (you can see it, or it was already loaded/read), describe it yourself and do NOT call this tool. Use this ONLY for image files on disk whose pixels you have not actually seen \u2014 never to re-analyze an image already in your context.",schema:p.Object({image_info:p.Array(wD,{description:"Batch of local image file inputs (up to 10). Always batch when you have multiple images. Include only images you cannot already see directly."})})};var io="Paths outside the session workspace (e.g. /tmp or input attachment directories) are rejected.";var SD=p.Object({prompt:p.String({description:"Synthesis prompt."}),output_file_path:p.String({description:`Where to save the generated image: a workspace-relative path like "art/cover.png". ${io}`}),input_file_paths:p.Optional(p.Array(p.String(),{description:"Local workspace paths of reference images (max 4)."})),aspect_ratio:p.Optional(p.String({description:'e.g. "16:9", "1:1".'})),resolution:p.Optional(p.String({description:'"1K" | "2K" | "4K".'}))});var Hn={name:"image_synthesize",description:"Generate images from prompts, optionally conditioned on local reference images.",schema:p.Object({requests:p.Array(SD,{description:"Up to 10 synthesis requests."})})};var MD=p.Object({query:p.String({description:"Search keywords."}),output_dir_path:p.String({description:`Directory to save this query's downloaded images (created if missing): a workspace-relative path like "downloads/cats". ${io}`}),prompt:p.Optional(p.String({description:"Description of desired images; server defaults to `query` when empty."}))});var Wn={name:"images_search_and_download",description:"Search the web for images and save top hits to local disk.",schema:p.Object({queries:p.Array(MD,{description:"Up to 10 image search queries."}),providers:p.Optional(p.Array(p.String(),{description:'Override auto-selection, e.g. ["tencent","serper"].'}))})};var Jn={name:"image_reverse_search",description:"Given a local image, find visually similar images and pages on the web. Writes a markdown report of the matches to `output_file_path`.",schema:p.Object({image_file_path:p.String({description:"Local workspace path of the image to reverse search."}),output_file_path:p.String({description:`Where to write the formatted markdown report: a workspace-relative .md path like "reports/matches.md". ${io}`})})};var gu=7e3;var nf=3;var sf=12;var Ir="Alran-H3";var ct="Alran-Video-2.3";function Gt(e){return e===Ir}var of="Across reference_image_paths, reference_video_paths, and reference_audio_paths, allow at most 12 files total.";var RD="Required and must be chosen in a separate first step. We recommend Alran-H3 for quality: it is newer and more capable. Alran-H3 natively generates synchronized audio together with the video directly from the prompt, without reference_audio_paths; reference audio is optional guidance, not a prerequisite for sound. Alran-Video-2.3 accepts exactly one image; Alran-H3 supports either first/last-frame keyframes or multimodal references: 1-9 reference images, 1-3 reference videos, and 1-3 reference audio files only together with reference images/videos, with at most 12 files total across all reference collections. If the user did not choose a model, explain only these model differences and ask which model to use. Do not ask about resolution, duration, keyframes, or reference media until the model is selected. After Alran-H3 is selected, ask for input mode, an integer duration from 4 through 15, and a resolution of 768P or 2K; offer a concrete ratio for text-only mode and adaptive or a concrete ratio for reference mode. Use Alran-H3 as the Tool and Matrix model value.";var VI=p.Union([p.Literal(Ir),p.Literal(ct)],{description:RD});var Xn={name:"submit_video_generation",description:["Submit exactly one asynchronous video task and return task_id immediately.","For Alran-H3 this Tool adapts the official POST /v2/video_generation contract to the current Matrix MCP wrapper: one required non-empty prompt becomes the single text content item, and frame/reference path fields become image_url/video_url/audio_url content roles.","Use a strict two-step conversation: first resolve the video model; after the user selects a model, ask only that model's remaining applicable options.","The video model choice is mandatory unless the current user request or terminal `<video-generation-options>` explicitly names H3.0 (Alran-H3) or H2.3 (Alran-Video-2.3). Never infer a default model from the Plugin name, a recommendation, or an omitted value.",'When the video model is missing and the `ask_user` tool is available, make one actual `ask_user` tool call before any submission. Use this exact call shape, keeping `steps` and every `options` value as literal JSON arrays: { "mode": "questionnaire", "title": "Video specifications", "steps": [{ "question": "Which model?", "options": [{ "label": "H3.0 (Recommended)" }, { "label": "H2.3" }], "selectionMode": "single" }] }. Never wrap either array in an `item` container such as `{ "item": [...] }`. Use `selectionMode`; never `multiSelect`.',"Write the questionnaire in the same language as the user. H3.0 maps to `Alran-H3`; H2.3 maps to `Alran-Video-2.3`. Do not call `submit_video_generation` until the user replies. When `ask_user` is unavailable, ask the same unresolved choices in concise prose and wait for the reply.","Alran-H3 is recommended for quality and supports 768P or 2K; ask the user to choose a resolution unless it is already explicit or delegated. When the user delegates or omits the choice, use 2K.","Alran-H3 natively generates synchronized audio together with the video. Put requested dialogue, ambience, and sound effects in the prompt; native sound works without reference_audio_paths. Reference audio is optional guidance, not a prerequisite for an audible video. Do not use a separate audio-generation tool unless the user explicitly asks for a separate audio output.","After Alran-H3 is selected, first ask whether the input mode is text-only, first-frame, last-frame, first+last-frame, or multimodal reference, then ask for an integer duration from 4 through 15 and a resolution. Text-only mode uses one non-adaptive ratio from 21:9, 16:9, 4:3, 1:1, 3:4, or 9:16 and defaults to 16:9 when omitted or delegated. Keyframe mode is always adaptive. Reference mode defaults to adaptive and also accepts any concrete ratio.","Reference images allow 1-9 items, reference videos allow 1-3 items, reference audio allows 1-3 items and must accompany reference images or videos, and all reference collections together allow at most 12 files total. Do not submit until duration and applicable media choices are explicit; ratio and resolution may use their documented defaults when omitted or delegated.","The official V2 video_url content item contains only url and role. The current Matrix wrapper additionally requires duration_seconds on each reference_videos item; this is Matrix wrapper metadata, not a Video Generation V2 content field. Workspace MP4/MOV duration is inspected automatically before upload; for public reference-video URLs, supply reference_video_duration_seconds in the same order because those URLs must not be downloaded or re-uploaded.","Every media input accepts either a public HTTP/HTTPS URL or a workspace-relative path. Public URLs are passed through unchanged without downloading or uploading them again. Every workspace media path, including first/last keyframes and image/video/audio references, is fenced, validated, and uploaded through the dedicated temporary public upload flow before submission; internal OSS hosts are never sent upstream. The agent Tool intentionally does not expose mm_file:// or data URI inputs because its supported local-file path must use the workspace fence and real temporary public upload flow.","A submit attempt is terminal for that exact request in the current turn. If submit returns any error, timeout, or HTTP failure, report it without inferring that a task was created and never retry submit automatically. Retry only after a new explicit user request in a later turn. Call `query_video_generation` only when submit returned a task_id; never repeat submit to check status."].join(" "),schema:p.Object({model:VI,prompt:p.String({minLength:1,maxLength:gu,description:"The one required non-empty V2 text/prompt item, up to 7000 characters. For Alran-H3 native audio generation, describe the desired dialogue, ambience, and sound effects here; reference audio is optional."}),input_image_path:p.Optional(p.String({description:"Optional public HTTP/HTTPS URL or workspace-relative path to a first-frame or last-frame image. Public URLs pass through unchanged; a workspace path is automatically uploaded to a temporary public URL before submission. Alran-H3 accepts .jpg/.jpeg/.png/.webp/.heic/.heif. Alran-Video-2.3 accepts .jpg/.png/.webp and exactly one image for first-frame or legacy subject mode. Alran-H3 uses this only for a keyframe, not as multimodal reference media. Cannot be combined with reference collections."})),last_frame_image_path:p.Optional(p.String({description:"Alran-H3 first+last-frame mode only. Public HTTP/HTTPS URL or workspace-relative .jpg/.jpeg/.png/.webp/.heic/.heif path for the ending frame. Public URLs pass through unchanged; a workspace path is automatically uploaded to a temporary public URL. Requires input_image_path as the first frame; reference_type must be first_frame or omitted. Cannot be combined with reference collections."})),reference_type:p.Optional(p.Union([p.Literal("first_frame"),p.Literal("last_frame"),p.Literal("subject")],{description:"How input_image_path is used. Alran-H3 supports first_frame or last_frame keyframes; omit it to default input_image_path to first_frame. Alran-Video-2.3 supports first_frame or legacy subject mode. Requires input_image_path and cannot be combined with reference collections."})),reference_image_paths:p.Optional(p.Array(p.String(),{minItems:1,maxItems:9,description:`Alran-H3 only. 1-9 public HTTP/HTTPS URLs or workspace-relative reference image paths; local paths are automatically uploaded to temporary public URLs. Each must be .jpg/.jpeg/.png/.webp/.heic/.heif, no larger than 30 MB, with width and height each in [256, 5760] and width/height ratio in [0.4, 2.5]. ${of} Alran-Video-2.3 does not accept this collection. Cannot be combined with keyframes.`})),reference_video_paths:p.Optional(p.Array(p.String(),{minItems:1,maxItems:3,description:`Alran-H3 only. 1-3 public HTTP/HTTPS URLs or workspace-relative .mp4/.mov video paths; local paths are automatically uploaded to temporary public URLs. Videos must use H.264/AVC or H.265/HEVC (embedded audio AAC/MP3); each no larger than 50 MB and 2-15 seconds, total video duration at most 15 seconds, width and height each in [256, 5760], aspect ratio in [0.4, 2.5], and frame rate in [23.976, 60]. ${of} Workspace MP4/MOV size and duration are checked before upload. Every public URL requires a same-index value in reference_video_duration_seconds. Dimensions, frame rate, and codecs are validated upstream. Cannot be combined with keyframes.`})),reference_video_duration_seconds:p.Optional(p.Array(p.Number({minimum:2,maximum:15}),{minItems:1,maxItems:3,description:"Alran-H3 Matrix-wrapper reference-video durations in seconds, in the same order as reference_video_paths. A value is required for every public URL because URLs are passed through without downloading; workspace MP4/MOV durations are inspected automatically when this field is omitted. When provided, the array length must equal reference_video_paths length and every value must be between 2 and 15."})),reference_audio_paths:p.Optional(p.Array(p.String(),{minItems:1,maxItems:nf,description:`Alran-H3 only. Optional audio guidance; it is not required for native audio generation because Alran-H3 can generate synchronized sound directly from the prompt. Accepts 1-3 public HTTP/HTTPS URLs or workspace-relative .wav/.mp3 reference audio paths; local paths are automatically uploaded to temporary public URLs. Each must be no larger than 15 MB and 2-15 seconds, with total audio duration at most 15 seconds. ${of} Reference audio cannot be used alone: include at least one reference image or video. Duration is validated upstream. Cannot be combined with keyframes.`})),duration:p.Integer({minimum:4,maximum:15,description:"Required after model selection. Alran-H3 supports an integer from 4 through 15 seconds. Alran-Video-2.3 supports exactly 6s or 10s."}),resolution:p.Optional(p.Union([p.Literal("768P"),p.Literal("1080P"),p.Literal("2K")],{description:"Alran-H3 supports 768P or 2K and defaults to 2K when omitted or delegated. Alran-Video-2.3 supports 768P (default) or 1080P; 10s requires 768P."})),ratio:p.Optional(p.Union([p.Literal("21:9"),p.Literal("16:9"),p.Literal("4:3"),p.Literal("1:1"),p.Literal("3:4"),p.Literal("9:16"),p.Literal("adaptive")],{description:"Alran-H3 text-only mode accepts 21:9, 16:9, 4:3, 1:1, 3:4, or 9:16, defaults to 16:9 when omitted, and cannot use adaptive. Keyframe mode is forced to adaptive. Reference mode defaults to adaptive and also accepts any concrete ratio."})),aigc_watermark:p.Optional(p.Boolean({description:"Alran-H3 V2 AIGC watermark switch. Omit or set false for the upstream default; set true only when the user requests the AIGC watermark.",default:false}))},{additionalProperties:false})};var Yn={name:"query_video_generation",description:"Query one previously submitted video task once. This read-only call does not create another charge. Pass the same model returned by submit and keep using the same output_file_path while polling. Returns queued/running/failed/cancelled without writing a file. When status is succeeded, downloads video_url immediately to output_file_path because Alran-H3 signed URLs are valid for only about 9 hours.",schema:p.Object({task_id:p.String({description:"Task ID returned by submit_video_generation."}),model:VI,output_file_path:p.String({description:`Required workspace-relative path for the generated mp4, such as "videos/result.mp4". Keep the same path on every query; the file is written only after status becomes succeeded. ${io}`})},{additionalProperties:false})};var OD=p.Object({prompt:p.String({description:"Video prompt."}),output_file_path:p.String({description:`Where to save the generated video: a workspace-relative path like "clips/intro.mp4". ${io}`}),input_image_path:p.Optional(p.String({description:"Local workspace path of a reference image (image-to-video). Omit for pure text-to-video."})),reference_type:p.Optional(p.String({description:'"first_frame" (default) | "last_frame".'})),duration:p.Optional(p.Integer({description:"6 (default) | 10."})),resolution:p.Optional(p.String({description:'"768P" (default) | "1080P".'})),model:p.Optional(p.String({description:"Override default model."}))});var Qn={name:"gen_videos",description:"Generate videos from prompts, optionally seeded with a local reference image. Generation is async on the server and may take many minutes.",schema:p.Object({requests:p.Array(OD,{description:"Up to 5 video generation requests."})})};var Zn={name:"batch_text_to_video",description:"Batch text-to-video using parallel lists. Items at the same index form one video.",schema:p.Object({prompt_list:p.Array(p.String(),{description:"One prompt per video."}),output_file_path_list:p.Array(p.String(),{description:`One workspace-relative output path per video (e.g. "clips/scene-1.mp4"), parallel to \`prompt_list\`. ${io}`}),duration_list:p.Optional(p.Array(p.Integer(),{description:"Optional durations, parallel to `prompt_list`."})),resolution_list:p.Optional(p.Array(p.String(),{description:"Optional resolutions, parallel to `prompt_list`."}))})};var ei={name:"batch_image_to_video",description:"Batch image-to-video using each local image as the first frame. Items at the same index form one video.",schema:p.Object({image_file_path_list:p.Array(p.String(),{description:"Local workspace paths of input images (first_frame source) per video."}),output_file_path_list:p.Array(p.String(),{description:`One workspace-relative output path per video (e.g. "clips/scene-1.mp4"), parallel to \`image_file_path_list\`. ${io}`}),prompt_list:p.Optional(p.Array(p.String(),{description:"Optional prompts, parallel to `image_file_path_list`."})),reference_type_list:p.Optional(p.Array(p.String(),{description:"Optional reference types, parallel to `image_file_path_list`."})),duration_list:p.Optional(p.Array(p.Integer(),{description:"Optional durations, parallel to `image_file_path_list`."})),resolution_list:p.Optional(p.Array(p.String(),{description:"Optional resolutions, parallel to `image_file_path_list`."}))})};var Yo={name:"get_voice_list",description:"List the voice presets (voice_id + voice_name) available to `synthesize_speech` and the batch TTS tools.",schema:p.Object({})};var HI=p.Object({text:p.String({description:"Text to synthesize."}),output_file_path:p.String({description:`Where to save the generated mp3: a workspace-relative path like "audio/speech.mp3". ${io}`}),voice_id:p.Optional(p.String({description:'Default "male-qn-qingse".'})),speed:p.Optional(p.Number({description:"[0.5, 2.0] default 1.0."})),volume:p.Optional(p.Number({description:"[0.0, 10.0] default 1.0."})),pitch:p.Optional(p.Integer({description:"[-12, 12] default 0."})),emotion:p.Optional(p.String({description:"happy | sad | angry | fearful | disgusted | surprised | neutral."}))});var ti={name:"batch_text_to_audio",description:"Batch text-to-speech, with voice and audio parameters configurable per request.",schema:p.Object({requests:p.Array(HI,{description:"Up to 10 TTS requests."})})};var PD=p.Object({prompt:p.String({description:"Music prompt, length [10, 300]."}),output_file_path:p.String({description:`Where to save the generated music file: a workspace-relative path like "music/track.mp3". ${io}`}),lyrics:p.Optional(p.String({description:"Lyrics text, length [10, 600] when set; omit for pure instrumental / background music."})),sample_rate:p.Optional(p.Integer({description:"{16000, 24000, 32000, 44100}."})),bitrate:p.Optional(p.Integer({description:"{32000, 64000, 128000, 256000}."})),format:p.Optional(p.String({description:"mp3 | wav | pcm."}))});var ri={name:"batch_text_to_music",description:"Generate music tracks from text prompts, optionally with lyrics.",schema:p.Object({requests:p.Array(PD,{description:"Up to 5 music generation requests."})})};var oi={name:"synthesize_speech",description:"Convert a single text input to speech. Use `batch_synthesize_speech` for multiple texts.",schema:p.Object({text:p.String({description:"Text to synthesize."}),output_file_path:p.String({description:`Where to save the generated mp3: a workspace-relative path like "audio/speech.mp3". ${io}`}),voice_id:p.Optional(p.String()),speed:p.Optional(p.Number({description:"[0.5, 2.0] default 1.0."})),volume:p.Optional(p.Number({description:"[0.0, 10.0] default 1.0."})),pitch:p.Optional(p.Integer({description:"[-12, 12] default 0."})),emotion:p.Optional(p.String({description:"happy | sad | angry | fearful | disgusted | surprised | neutral."}))})};var ni={name:"batch_synthesize_speech",description:"Batch text-to-speech. Prefer this over calling `synthesize_speech` in a loop.",schema:p.Object({requests:p.Array(HI,{description:"Up to 10 synthesize requests."})})};var ii={name:"audios_understand",description:"Analyze local audio files and return one description per audio.",schema:p.Object({audio_info:p.Array(BI,{description:"Batch of audio inputs (up to 10). Always batch when you have multiple audios."})})};var Qo={name:"videos_understand",description:"Offload local video FILES to a separate vision model for text descriptions. If a video (or its frames) is already visible in this conversation, or you have already analyzed it, describe it yourself and do NOT call this tool. Use this ONLY for video files on disk whose content you have not actually seen \u2014 never to re-analyze a video already in your context.",schema:p.Object({video_info:p.Array(TD,{description:"Batch of local video file inputs (up to 5). Always batch when you have multiple videos. Include only videos you cannot already see directly."})})};var Mo={name:"transcribe_audio",description:"Transcribe a single local audio file to text.",schema:p.Object({audio_info:BI})};var Y={[Zi.name]:"/matrix/api/v1/mcp/web_search",[Xo.name]:"/matrix/api/v1/mcp/images_understand",[Hn.name]:"/matrix/api/v1/mcp/image_synthesize",[Wn.name]:"/matrix/api/v1/mcp/images_search_and_download",[Jn.name]:"/matrix/api/v1/mcp/image_reverse_search",[Xn.name]:"/matrix/api/v1/mcp/submit_video_generation",[Yn.name]:"/matrix/api/v1/mcp/query_video_generation",[Qn.name]:"/matrix/api/v1/mcp/gen_videos",[Zn.name]:"/matrix/api/v1/mcp/batch_text_to_video",[ei.name]:"/matrix/api/v1/mcp/batch_image_to_video",[Yo.name]:"/matrix/api/v1/mcp/get_voice_list",[ti.name]:"/matrix/api/v1/mcp/batch_text_to_audio",[ri.name]:"/matrix/api/v1/mcp/batch_text_to_music",[oi.name]:"/matrix/api/v1/mcp/synthesize_speech",[ni.name]:"/matrix/api/v1/mcp/batch_synthesize_speech",[ii.name]:"/matrix/api/v1/mcp/audios_understand",[Qo.name]:"/matrix/api/v1/mcp/videos_understand",[Mo.name]:"/matrix/api/v1/mcp/listen_audio"};var Br=6e5;var Vn=12e4;var WI={[Zi.name]:Vn,[Xo.name]:Vn,[Hn.name]:Br,[Wn.name]:Br,[Jn.name]:Br,[Xn.name]:Br,[Yn.name]:Vn,[Qn.name]:Br,[Zn.name]:Br,[ei.name]:Br,[Yo.name]:Vn,[ti.name]:Br,[ri.name]:Br,[oi.name]:Br,[ni.name]:Br,[ii.name]:Vn,[Qo.name]:Vn,[Mo.name]:Vn};var XI="MATRIX_TOOL_REQUEST_FAILED";var YI="MATRIX_TOOL_BUSINESS_FAILED";var JI="MATRIX_TOOL_REQUEST_FAILED: Matrix tool request failed.";var AD="MATRIX_TOOL_BUSINESS_FAILED: Matrix tool request was rejected.";async function nr(e){const{toolName:t,path:r,input:o,archonServer:n,signal:i}=e;if(i?.aborted)throw new Error("Operation aborted");const s=Date.now();ZI(e);let a;try{a=await n.postJson(r,o,i,{timeoutMs:cf(e)})}catch(x){const y=ob(x);tb(e,s,y);if(i?.aborted)throw x;return rb(t,r,y)}const c=QI(a.base_resp)?a.base_resp:void 0;const l=c?.status_code??0;eb(e,s,a,l);if(l!==0){return af(t,r,{statusCode:l})}const u={...a};delete u.base_resp;const d=JSON.stringify(u,null,2);return{tool_name:t,text:d,content:[{type:"text",text:d}],details:{ok:true,path:r},programmatic:{data:u}}}async function Fe(e){const{toolName:t,path:r,input:o,archonServer:n,signal:i}=e;if(i?.aborted)throw new Error("Operation aborted");const s=Date.now();ZI(e);let a;try{a=await n.postJson(r,o,i,{timeoutMs:cf(e)})}catch(x){const y=ob(x);tb(e,s,y);if(i?.aborted)throw x;return{ok:false,result:rb(t,r,y)}}const c=QI(a.base_resp)?a.base_resp:void 0;const l=c?.status_code??0;eb(e,s,a,l);if(l!==0){return{ok:false,result:af(t,r,{statusCode:l})}}const u={...a};delete u.base_resp;const d=typeof u.code==="number"&&Number.isInteger(u.code)?u.code:0;if(d!==0){e.ctx.matrixLogger?.warn(e.ctx,`matrix-tools biz_error tool=${t} path=${r} code=${YI} payload_code=${d} session=${e.ctx.sessionId} turn=${e.ctx.turnId}`);return{ok:false,result:af(t,r,{payloadCode:d})}}return{ok:true,response:u}}function cf(e){if(typeof e.timeoutMs==="number"&&Number.isFinite(e.timeoutMs)&&e.timeoutMs>0){return e.timeoutMs}return WI[e.toolName]}function QI(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)}function ZI(e){const{toolName:t,path:r,ctx:o}=e;const n=nb(e.input);const i=cf(e);o.matrixLogger?.info(o,`matrix-tools request tool=${t} path=${r} body_bytes=${n} timeout_ms=${i??"default"} session=${o.sessionId} turn=${o.turnId}`)}function eb(e,t,r,o){const{toolName:n,path:i,ctx:s}=e;const a=Date.now()-t;const c=nb(r);const l=o===0;s.matrixLogger?.info(s,`matrix-tools response tool=${n} path=${i} ok=${l} status_code=${o} duration_ms=${a} resp_bytes=${c} session=${s.sessionId} turn=${s.turnId}`)}function tb(e,t,r){const{toolName:o,path:n,ctx:i,signal:s}=e;const a=Date.now()-t;i.matrixLogger?.warn(i,`matrix-tools error tool=${o} path=${n} stage=request code=${XI} http_status=${r??"none"} duration_ms=${a} aborted=${s?.aborted===true} session=${i.sessionId} turn=${i.turnId}`)}function rb(e,t,r){return{tool_name:e,text:JI,content:[{type:"text",text:JI}],details:{ok:false,path:t,error_code:XI,...r!==void 0?{http_status:r}:{}}}}function af(e,t,r){const o=r.payloadCode===402?"Insufficient credits (code 402): account credits are insufficient. Please top up credits first. Do NOT retry the same request until credits are available.":AD;return{tool_name:e,text:o,content:[{type:"text",text:o}],details:{ok:false,path:t,error_code:YI,...r.statusCode!==void 0?{status_code:r.statusCode}:{},...r.payloadCode!==void 0?{code:r.payloadCode}:{}}}}function ob(e){if(!(e instanceof Error))return void 0;const t=/\bHTTP\s+(\d{3})\b/i.exec(e.message);return t?Number(t[1]):void 0}function nb(e){try{return Buffer.byteLength(JSON.stringify(e)??"","utf8")}catch{return-1}}import{writeFile as CD}from"node:fs/promises";import{fileURLToPath as FD}from"node:url";var $t=class extends Error{constructor(r,o,n){super(o);this.kind=r;this.name="MatrixMediaError";if(n!==void 0)this.underlying=n}kind;underlying};function da(e){if(e instanceof $t)return e.kind;if(e&&typeof e==="object"){const t=e.kind;return typeof t==="string"?t:void 0}return void 0}import{realpath as ib}from"node:fs/promises";import{basename as kD,dirname as ED,isAbsolute as uf,relative as $D,resolve as yu,sep as vD}from"node:path";function pa(e){return typeof e==="string"?e:e.workspaceRoot}function fa(e){if(typeof e==="string")return[e];return[e.workspaceRoot,...e.extraInputRoots??[]]}async function xu(e,t){const r=uf(e)?e:yu(pa(t),e);let o;for(const n of fa(t)){try{await sb(r,n);return r}catch(i){o??=i}}throw o instanceof Error?o:new Error(`Workspace path escapes Matrix tool root: ${e}`)}async function sb(e,t){const r=await ib(t);let o=yu(e);const n=[];while(true){let i;try{i=await ib(o)}catch(c){const l=c.code;if(l!=="ENOENT"&&l!=="ENOTDIR")throw c;const u=ED(o);if(u===o){throw new Error(`Workspace path escapes Matrix tool root: ${e}`)}n.unshift(kD(o));o=u;continue}const s=n.length===0?i:yu(i,...n);const a=$D(r,s);if(a===".."||a.startsWith(`..${vD}`)||uf(a)){throw new Error(`Workspace path escapes Matrix tool root: ${e}`)}return}}async function lf(e,t){const r=uf(e)?e:yu(t,e);await sb(r,t);return r}var E=class extends Error{kind;underlying;constructor(t,r,o){super(r);this.name="FileTransferError";this.kind=t;if(o!==void 0)this.underlying=o}};async function Vr(e,t,r,o){const n=ND(e);let i;try{i=await xu(n,t)}catch(s){throw new E("path_escapes_workspace",`Input file path '${e}' is outside the workspace. Provide a path under one of: '${fa(t).join("', '")}'.`,s)}try{const{ossKey:s,signedUrl:a,inlineData:c,mimeType:l,bytes:u}=await r.uploadFile(i,o);return{absolutePath:i,signedUrl:a,inlineData:c,mimeType:l,ossKey:s,bytes:u}}catch(s){if(da(s)==="file_not_found"){throw new E("input_not_found",`Input file does not exist at '${i}'. Make sure the file was written before calling this tool.`,s)}throw new E("input_upload_failed",`Failed to upload input file '${i}' to temporary storage: ${_u(s)}. Please retry.`,s)}}async function Hr(e,t,r,o){const n=[];for(const i of e){n.push(await Vr(i,t,r,o))}return n}function ir(e,t){const r={};if(e.inlineData){r.data=e.inlineData;if(e.mimeType)r.mime_type=e.mimeType}else if(e.signedUrl){r.url=e.signedUrl;if(e.mimeType)r.mime_type=e.mimeType}else{throw new E("input_upload_failed",`Failed to prepare input file '${e.absolutePath}': no URL or inline data was returned.`)}if(t!==void 0)r.prompt=t;return r}function si(e){if(e.signedUrl)return e.signedUrl;throw new E("input_upload_failed",`Failed to upload input file '${e.absolutePath}' to temporary storage: no URL was returned.`)}async function Je(e,t,r,o,n){const i=pa(r);let s;try{s=await lf(t,i)}catch(a){throw new E("path_escapes_workspace",`Output file path '${t}' is outside the workspace. Provide a path under '${i}'.`,a)}try{const{bytes:a}=await o.downloadToFile(e,s,{...n?.signal?{signal:n.signal}:{},...n?.timeoutMs!==void 0?{timeoutMs:n.timeoutMs}:{}});return{absolutePath:s,bytes:a}}catch(a){if(da(a)==="aborted"){throw a}if(da(a)==="write_failed"){throw new E("output_write_failed",`Failed to write output file '${s}': ${_u(a)}.`,a)}throw new E("output_download_failed",`Failed to download generated content from server to '${s}': ${_u(a)}. The remote content may have expired or the network failed; please retry the tool.`,a)}}async function df(e,t,r){const o=pa(r);let n;try{n=await lf(t,o)}catch(s){throw new E("path_escapes_workspace",`Output file path '${t}' is outside the workspace. Provide a path under '${o}'.`,s)}const i=Buffer.from(e,"utf8");try{await CD(n,i)}catch(s){throw new E("output_write_failed",`Failed to write output file '${n}': ${_u(s)}.`,s)}return{absolutePath:n,bytes:i.length}}function ne(e,t,r){return{tool_name:e,text:r.message,content:[{type:"text",text:r.message}],details:{ok:false,path:t,reason:r.kind}}}function _u(e){if(e===null||e===void 0)return"unknown error";if(e instanceof Error)return e.message||e.name;if(typeof e==="string")return e;return String(e)}function ND(e){if(!e.startsWith("file://"))return e;return FD(e)}var ab,pf;ab=[W(ii)];var Zo=class{constructor(t,r,o){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o}archonServer;ossMediaClient;workspaceScope;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=ii.name;const i=Y[n];try{const s=await Hr(r.audio_info.map(c=>c.file_path),this.workspaceScope,this.ossMediaClient);const a={audio_info:r.audio_info.map((c,l)=>ir(s[l],c.prompt))};return await nr({toolName:n,path:i,input:a,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}})}catch(s){if(s instanceof E){return ne(n,i,s)}throw s}}};pf=Q(null);Zo=ee(pf,0,"MatrixAudiosUnderstandTool",ab,Zo);Z(pf,1,Zo);import{basename as zD}from"node:path";var jD="cloud-runtime/v5-aigc";async function ht(e){const t=e.oss.clean_oss_key;if(!t)return;if(!e.registerService)return;try{await e.registerService.registerDownloadedAsset({oss:e.oss,absolutePath:e.absolutePath,fileName:e.fileName,sizeBytes:e.sizeBytes,mime:e.mime,sessionId:e.sessionId,toolName:e.toolName,producerVersion:jD})}catch(r){void r}}function gt(e){const t=e.toLowerCase();if(t.endsWith(".png"))return"image/png";if(t.endsWith(".jpg")||t.endsWith(".jpeg"))return"image/jpeg";if(t.endsWith(".webp"))return"image/webp";if(t.endsWith(".mp4"))return"video/mp4";if(t.endsWith(".mov"))return"video/quicktime";if(t.endsWith(".webm"))return"video/webm";if(t.endsWith(".mp3"))return"audio/mpeg";if(t.endsWith(".wav"))return"audio/wav";if(t.endsWith(".flac"))return"audio/flac";if(t.endsWith(".m4a"))return"audio/m4a";if(t.endsWith(".pcm"))return"audio/pcm";if(t.endsWith(".ogg")||t.endsWith(".oga"))return"audio/ogg";return"application/octet-stream"}function cb(e){if(typeof e!=="string")return null;const t=e.match(/^slot_(\d+)\./);return t?Number(t[1]):null}var ub,ff;ub=[W(ei)];var en=class{constructor(t,r,o,n=null){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o;this.aigcRegisterServiceGetter=n}archonServer;ossMediaClient;workspaceScope;aigcRegisterServiceGetter;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=ei.name;const i=Y[n];const s=r.image_file_path_list.length;const a=r.output_file_path_list.length;if(s!==a){const _=`image_file_path_list (${s} items) and output_file_path_list (${a} items) must be the same length.`;return{tool_name:n,text:_,content:[{type:"text",text:_}],details:{ok:false,path:i,reason:"length_mismatch"}}}let c;try{const _=await Hr(r.image_file_path_list,this.workspaceScope,this.ossMediaClient);c=_.map(I=>ir(I))}catch(_){if(_ instanceof E){return ne(n,i,_)}throw _}const l={image_list:c,output_file_list:r.output_file_path_list.map((_,I)=>`slot_${I}.mp4`)};if(r.prompt_list!==void 0)l.prompt_list=r.prompt_list;if(r.reference_type_list!==void 0)l.reference_type_list=r.reference_type_list;if(r.duration_list!==void 0)l.duration_list=r.duration_list;if(r.resolution_list!==void 0)l.resolution_list=r.resolution_list;const u=await Fe({toolName:n,path:i,input:l,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!u.ok)return u.result;const d=Array.isArray(u.response.success_items)?u.response.success_items:[];const x=Array.isArray(u.response.failed_items)?u.response.failed_items:[];const y=r.output_file_path_list.map((_,I)=>({index:I,output_file_path:_,status:"missing"}));for(const _ of d){const I=cb(_.output_file);if(I===null||I<0||I>=y.length)continue;const R=y[I];const C=_.output_url??"";if(!C){R.status="failed";R.error="server reported success but output_url is empty";continue}try{const k=await Je(C,R.output_file_path,this.workspaceScope,this.ossMediaClient,{...o?{signal:o}:{}});R.status="downloaded";R.bytes=k.bytes;R.output_file_path=k.absolutePath;await ht({oss:{clean_oss_key:_.clean_oss_key,visible_oss_key:_.visible_oss_key},absolutePath:k.absolutePath,fileName:zD(k.absolutePath),sizeBytes:k.bytes,mime:gt(k.absolutePath),sessionId:t.sessionId,toolName:n,registerService:this.aigcRegisterServiceGetter?this.aigcRegisterServiceGetter():null})}catch(k){if(k instanceof E){if(k.kind==="path_escapes_workspace"){return ne(n,i,k)}R.status="failed";R.error=k.message;continue}throw k}}for(const _ of x){const I=cb(_.output_file);if(I===null||I<0||I>=y.length)continue;const R=y[I];R.status="failed";R.error=_.error_msg??"unknown server error"}const m=y.filter(_=>_.status==="downloaded").length;const f=y.filter(_=>_.status!=="downloaded").length;const h=`${m}/${y.length} videos saved (${f} failed/missing).`;return{tool_name:n,text:h,content:[{type:"text",text:h}],details:{ok:true,path:i,total_succeeded:m,total_failed:f,per_request:y}}}};ff=Q(null);en=ee(ff,0,"MatrixBatchImageToVideoTool",ub,en);Z(ff,1,en);import{basename as DD}from"node:path";function lb(e){if(typeof e!=="string")return null;const t=e.match(/^slot_(\d+)\./);return t?Number(t[1]):null}var db,mf;db=[W(ni)];var tn=class{constructor(t,r,o,n=null){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o;this.aigcRegisterServiceGetter=n}archonServer;ossMediaClient;workspaceScope;aigcRegisterServiceGetter;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=ni.name;const i=Y[n];const s={requests:r.requests.map((m,f)=>{const h={text:m.text,output_file:`slot_${f}.mp3`};if(m.voice_id!==void 0)h.voice_id=m.voice_id;if(m.speed!==void 0)h.speed=m.speed;if(m.volume!==void 0)h.volume=m.volume;if(m.pitch!==void 0)h.pitch=m.pitch;if(m.emotion!==void 0)h.emotion=m.emotion;return h})};const a=await Fe({toolName:n,path:i,input:s,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!a.ok)return a.result;const c=Array.isArray(a.response.success_items)?a.response.success_items:[];const l=Array.isArray(a.response.failed_items)?a.response.failed_items:[];const u=r.requests.map((m,f)=>({index:f,output_file_path:m.output_file_path,status:"missing"}));for(const m of c){const f=lb(m.output_file);if(f===null||f<0||f>=u.length)continue;const h=u[f];const _=m.output_url??"";if(!_){h.status="failed";h.error="server reported success but output_url is empty";continue}try{const I=await Je(_,h.output_file_path,this.workspaceScope,this.ossMediaClient,{...o?{signal:o}:{}});h.status="downloaded";h.bytes=I.bytes;h.output_file_path=I.absolutePath;await ht({oss:{clean_oss_key:m.clean_oss_key,visible_oss_key:m.visible_oss_key},absolutePath:I.absolutePath,fileName:DD(I.absolutePath),sizeBytes:I.bytes,mime:gt(I.absolutePath),sessionId:t.sessionId,toolName:n,registerService:this.aigcRegisterServiceGetter?this.aigcRegisterServiceGetter():null})}catch(I){if(I instanceof E){if(I.kind==="path_escapes_workspace"){return ne(n,i,I)}h.status="failed";h.error=I.message;continue}throw I}}for(const m of l){const f=lb(m.output_file);if(f===null||f<0||f>=u.length)continue;const h=u[f];h.status="failed";h.error=m.error_msg??"unknown server error"}const d=u.filter(m=>m.status==="downloaded").length;const x=u.filter(m=>m.status!=="downloaded").length;const y=`${d}/${u.length} succeeded (${x} failed/missing).`;return{tool_name:n,text:y,content:[{type:"text",text:y}],details:{ok:true,path:i,total_succeeded:d,total_failed:x,per_request:u}}}};mf=Q(null);tn=ee(mf,0,"MatrixBatchSynthesizeSpeechTool",db,tn);Z(mf,1,tn);import{basename as UD}from"node:path";function pb(e){if(typeof e!=="string")return null;const t=e.match(/^slot_(\d+)\./);return t?Number(t[1]):null}var fb,hf;fb=[W(ti)];var rn=class{constructor(t,r,o,n=null){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o;this.aigcRegisterServiceGetter=n}archonServer;ossMediaClient;workspaceScope;aigcRegisterServiceGetter;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=ti.name;const i=Y[n];const s={requests:r.requests.map((m,f)=>{const h={text:m.text,output_file:`slot_${f}.mp3`};if(m.voice_id!==void 0)h.voice_id=m.voice_id;if(m.speed!==void 0)h.speed=m.speed;if(m.volume!==void 0)h.volume=m.volume;if(m.pitch!==void 0)h.pitch=m.pitch;if(m.emotion!==void 0)h.emotion=m.emotion;return h})};const a=await Fe({toolName:n,path:i,input:s,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!a.ok)return a.result;const c=Array.isArray(a.response.success_items)?a.response.success_items:[];const l=Array.isArray(a.response.failed_items)?a.response.failed_items:[];const u=r.requests.map((m,f)=>({index:f,output_file_path:m.output_file_path,status:"missing"}));for(const m of c){const f=pb(m.output_file);if(f===null||f<0||f>=u.length)continue;const h=u[f];const _=m.output_url??"";if(!_){h.status="failed";h.error="server reported success but output_url is empty";continue}try{const I=await Je(_,h.output_file_path,this.workspaceScope,this.ossMediaClient,{...o?{signal:o}:{}});h.status="downloaded";h.bytes=I.bytes;h.output_file_path=I.absolutePath;await ht({oss:{clean_oss_key:m.clean_oss_key,visible_oss_key:m.visible_oss_key},absolutePath:I.absolutePath,fileName:UD(I.absolutePath),sizeBytes:I.bytes,mime:gt(I.absolutePath),sessionId:t.sessionId,toolName:n,registerService:this.aigcRegisterServiceGetter?this.aigcRegisterServiceGetter():null})}catch(I){if(I instanceof E){if(I.kind==="path_escapes_workspace"){return ne(n,i,I)}h.status="failed";h.error=I.message;continue}throw I}}for(const m of l){const f=pb(m.output_file);if(f===null||f<0||f>=u.length)continue;const h=u[f];h.status="failed";h.error=m.error_msg??"unknown server error"}const d=u.filter(m=>m.status==="downloaded").length;const x=u.filter(m=>m.status!=="downloaded").length;const y=`${d}/${u.length} succeeded (${x} failed/missing).`;return{tool_name:n,text:y,content:[{type:"text",text:y}],details:{ok:true,path:i,total_succeeded:d,total_failed:x,per_request:u}}}};hf=Q(null);rn=ee(hf,0,"MatrixBatchTextToAudioTool",fb,rn);Z(hf,1,rn);import{basename as LD}from"node:path";function qD(e){const t=(e??"mp3").toLowerCase();return t==="wav"||t==="pcm"?t:"mp3"}function mb(e){if(typeof e!=="string")return null;const t=e.match(/^slot_(\d+)\./);return t?Number(t[1]):null}var hb,gf;hb=[W(ri)];var on=class{constructor(t,r,o,n=null){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o;this.aigcRegisterServiceGetter=n}archonServer;ossMediaClient;workspaceScope;aigcRegisterServiceGetter;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=ri.name;const i=Y[n];const s={requests:r.requests.map((m,f)=>{const h={prompt:m.prompt,output_file:`slot_${f}.${qD(m.format)}`};if(m.lyrics!==void 0)h.lyrics=m.lyrics;if(m.sample_rate!==void 0)h.sample_rate=m.sample_rate;if(m.bitrate!==void 0)h.bitrate=m.bitrate;if(m.format!==void 0)h.format=m.format;return h})};const a=await Fe({toolName:n,path:i,input:s,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!a.ok)return a.result;const c=Array.isArray(a.response.success_items)?a.response.success_items:[];const l=Array.isArray(a.response.failed_items)?a.response.failed_items:[];const u=r.requests.map((m,f)=>({index:f,output_file_path:m.output_file_path,status:"missing"}));for(const m of c){const f=mb(m.output_file);if(f===null||f<0||f>=u.length)continue;const h=u[f];const _=m.output_url??"";if(!_){h.status="failed";h.error="server reported success but output_url is empty";continue}try{const I=await Je(_,h.output_file_path,this.workspaceScope,this.ossMediaClient,{...o?{signal:o}:{}});h.status="downloaded";h.bytes=I.bytes;h.output_file_path=I.absolutePath;await ht({oss:{clean_oss_key:m.clean_oss_key,visible_oss_key:m.visible_oss_key},absolutePath:I.absolutePath,fileName:LD(I.absolutePath),sizeBytes:I.bytes,mime:gt(I.absolutePath),sessionId:t.sessionId,toolName:n,registerService:this.aigcRegisterServiceGetter?this.aigcRegisterServiceGetter():null})}catch(I){if(I instanceof E){if(I.kind==="path_escapes_workspace"){return ne(n,i,I)}h.status="failed";h.error=I.message;continue}throw I}}for(const m of l){const f=mb(m.output_file);if(f===null||f<0||f>=u.length)continue;const h=u[f];h.status="failed";h.error=m.error_msg??"unknown server error"}const d=u.filter(m=>m.status==="downloaded").length;const x=u.filter(m=>m.status!=="downloaded").length;const y=`${d}/${u.length} succeeded (${x} failed/missing).`;return{tool_name:n,text:y,content:[{type:"text",text:y}],details:{ok:true,path:i,total_succeeded:d,total_failed:x,per_request:u}}}};gf=Q(null);on=ee(gf,0,"MatrixBatchTextToMusicTool",hb,on);Z(gf,1,on);import{basename as KD}from"node:path";function gb(e){if(typeof e!=="string")return null;const t=e.match(/^slot_(\d+)\./);return t?Number(t[1]):null}var yb,yf;yb=[W(Zn)];var nn=class{constructor(t,r,o,n=null){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o;this.aigcRegisterServiceGetter=n}archonServer;ossMediaClient;workspaceScope;aigcRegisterServiceGetter;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=Zn.name;const i=Y[n];const s=r.prompt_list.length;const a=r.output_file_path_list.length;if(s!==a){const h=`prompt_list (${s} items) and output_file_path_list (${a} items) must be the same length.`;return{tool_name:n,text:h,content:[{type:"text",text:h}],details:{ok:false,path:i,reason:"length_mismatch"}}}const c={prompt_list:r.prompt_list,output_file_list:r.prompt_list.map((h,_)=>`slot_${_}.mp4`)};if(r.duration_list!==void 0)c.duration_list=r.duration_list;if(r.resolution_list!==void 0)c.resolution_list=r.resolution_list;const l=await Fe({toolName:n,path:i,input:c,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!l.ok)return l.result;const u=Array.isArray(l.response.success_items)?l.response.success_items:[];const d=Array.isArray(l.response.failed_items)?l.response.failed_items:[];const x=r.output_file_path_list.map((h,_)=>({index:_,output_file_path:h,status:"missing"}));for(const h of u){const _=gb(h.output_file);if(_===null||_<0||_>=x.length)continue;const I=x[_];const R=h.output_url??"";if(!R){I.status="failed";I.error="server reported success but output_url is empty";continue}try{const C=await Je(R,I.output_file_path,this.workspaceScope,this.ossMediaClient,{...o?{signal:o}:{}});I.status="downloaded";I.bytes=C.bytes;I.output_file_path=C.absolutePath;await ht({oss:{clean_oss_key:h.clean_oss_key,visible_oss_key:h.visible_oss_key},absolutePath:C.absolutePath,fileName:KD(C.absolutePath),sizeBytes:C.bytes,mime:gt(C.absolutePath),sessionId:t.sessionId,toolName:n,registerService:this.aigcRegisterServiceGetter?this.aigcRegisterServiceGetter():null})}catch(C){if(C instanceof E){if(C.kind==="path_escapes_workspace"){return ne(n,i,C)}I.status="failed";I.error=C.message;continue}throw C}}for(const h of d){const _=gb(h.output_file);if(_===null||_<0||_>=x.length)continue;const I=x[_];I.status="failed";I.error=h.error_msg??"unknown server error"}const y=x.filter(h=>h.status==="downloaded").length;const m=x.filter(h=>h.status!=="downloaded").length;const f=`${y}/${x.length} succeeded (${m} failed/missing).`;return{tool_name:n,text:f,content:[{type:"text",text:f}],details:{ok:true,path:i,total_succeeded:y,total_failed:m,per_request:x}}}};yf=Q(null);nn=ee(yf,0,"MatrixBatchTextToVideoTool",yb,nn);Z(yf,1,nn);import{basename as GD}from"node:path";function xb(e){if(typeof e!=="string")return null;const t=e.match(/^slot_(\d+)\./);return t?Number(t[1]):null}var _b,xf;_b=[W(Qn)];var sn=class{constructor(t,r,o,n=null){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o;this.aigcRegisterServiceGetter=n}archonServer;ossMediaClient;workspaceScope;aigcRegisterServiceGetter;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=Qn.name;const i=Y[n];const s=[];try{for(const f of r.requests){if(f.input_image_path){const h=await Vr(f.input_image_path,this.workspaceScope,this.ossMediaClient);s.push(ir(h))}else{s.push(void 0)}}}catch(f){if(f instanceof E){return ne(n,i,f)}throw f}const a={requests:r.requests.map((f,h)=>{const _={prompt:f.prompt,output_file:`slot_${h}.mp4`};const I=s[h];if(I)_.input_image=I;if(f.reference_type!==void 0)_.reference_type=f.reference_type;if(f.duration!==void 0)_.duration=f.duration;if(f.resolution!==void 0)_.resolution=f.resolution;if(f.model!==void 0)_.model=f.model;return _})};const c=await Fe({toolName:n,path:i,input:a,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!c.ok)return c.result;const l=Array.isArray(c.response.success_items)?c.response.success_items:[];const u=Array.isArray(c.response.failed_items)?c.response.failed_items:[];const d=r.requests.map((f,h)=>({index:h,output_file_path:f.output_file_path,status:"missing"}));for(const f of l){const h=xb(f.output_file);if(h===null||h<0||h>=d.length)continue;const _=d[h];const I=f.output_url??"";if(!I){_.status="failed";_.error="server reported success but output_url is empty";continue}try{const R=await Je(I,_.output_file_path,this.workspaceScope,this.ossMediaClient,{...o?{signal:o}:{}});_.status="downloaded";_.bytes=R.bytes;_.output_file_path=R.absolutePath;await ht({oss:{clean_oss_key:f.clean_oss_key,visible_oss_key:f.visible_oss_key},absolutePath:R.absolutePath,fileName:GD(R.absolutePath),sizeBytes:R.bytes,mime:gt(R.absolutePath),sessionId:t.sessionId,toolName:n,registerService:this.aigcRegisterServiceGetter?this.aigcRegisterServiceGetter():null})}catch(R){if(R instanceof E){if(R.kind==="path_escapes_workspace"){return ne(n,i,R)}_.status="failed";_.error=R.message;continue}throw R}}for(const f of u){const h=xb(f.output_file);if(h===null||h<0||h>=d.length)continue;const _=d[h];_.status="failed";_.error=f.error_msg??"unknown server error"}const x=d.filter(f=>f.status==="downloaded").length;const y=d.filter(f=>f.status!=="downloaded").length;const m=`${x}/${d.length} videos saved (${y} failed/missing).`;return{tool_name:n,text:m,content:[{type:"text",text:m}],details:{ok:true,path:i,total_succeeded:x,total_failed:y,per_request:d}}}};xf=Q(null);sn=ee(xf,0,"MatrixGenVideosTool",_b,sn);Z(xf,1,sn);var Ib,_f;Ib=[W(Yo)];var an=class{constructor(t,r,o){this.archonServer=t;this._ossMediaClient=r;this._workspaceScope=o}archonServer;_ossMediaClient;_workspaceScope;execute(t,r,o){return nr({toolName:Yo.name,path:Y[Yo.name],input:r,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}})}};_f=Q(null);an=ee(_f,0,"MatrixGetVoiceListTool",Ib,an);Z(_f,1,an);function BD(e){const t=["# Reverse Image Search Results",""];if(e.length===0){t.push("_No results._","");return t.join("\n")}e.forEach((r,o)=>{const n=`## ${o+1}. ${r.title??"(untitled)"}`;t.push(n);if(r.link)t.push(`- **Link:** ${r.link}`);if(r.source)t.push(`- **Source:** ${r.source}`);if(r.image_url)t.push(`- **Image:** ${r.image_url}`);if(r.snippet)t.push(`- **Snippet:** ${r.snippet}`);t.push("")});return t.join("\n")}var bb,If;bb=[W(Jn)];var cn=class{constructor(t,r,o){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o}archonServer;ossMediaClient;workspaceScope;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=Jn.name;const i=Y[n];try{const s=await Vr(r.image_file_path,this.workspaceScope,this.ossMediaClient,{forceRemoteUrl:true});const a={image_url:si(s)};const c=await Fe({toolName:n,path:i,input:a,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!c.ok)return c.result;const l=Array.isArray(c.response.data)?c.response.data:[];const u=BD(l);const d=await df(u,r.output_file_path,this.workspaceScope);const x=`wrote ${l.length} result(s) (${d.bytes} bytes) to ${d.absolutePath}.`;return{tool_name:n,text:x,content:[{type:"text",text:x}],details:{ok:true,path:i,output_file_path:d.absolutePath,bytes:d.bytes,result_count:l.length}}}catch(s){if(s instanceof E){return ne(n,i,s)}throw s}}};If=Q(null);cn=ee(If,0,"MatrixImageReverseSearchTool",bb,cn);Z(If,1,cn);import{basename as VD}from"node:path";function wb(e){if(typeof e!=="string")return null;const t=e.match(/^slot_(\d+)\./);return t?Number(t[1]):null}var Tb,bf;Tb=[W(Hn)];var un=class{constructor(t,r,o,n=null){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o;this.aigcRegisterServiceGetter=n}archonServer;ossMediaClient;workspaceScope;aigcRegisterServiceGetter;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=Hn.name;const i=Y[n];const s=[];try{for(const f of r.requests){if(f.input_file_paths&&f.input_file_paths.length>0){const h=await Hr(f.input_file_paths,this.workspaceScope,this.ossMediaClient,{forceRemoteUrl:true});s.push(h.map(_=>si(_)))}else{s.push([])}}}catch(f){if(f instanceof E){return ne(n,i,f)}throw f}const a={requests:r.requests.map((f,h)=>{const _={prompt:f.prompt,output_file:`slot_${h}.png`};if(s[h].length>0){_.input_urls=s[h]}if(f.aspect_ratio!==void 0)_.aspect_ratio=f.aspect_ratio;if(f.resolution!==void 0)_.resolution=f.resolution;return _})};const c=await Fe({toolName:n,path:i,input:a,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!c.ok)return c.result;const l=Array.isArray(c.response.success_items)?c.response.success_items:[];const u=Array.isArray(c.response.failed_items)?c.response.failed_items:[];const d=r.requests.map((f,h)=>({index:h,output_file_path:f.output_file_path,status:"missing"}));for(const f of l){const h=wb(f.output_file);if(h===null||h<0||h>=d.length)continue;const _=d[h];if(f.text_response)_.text_response=f.text_response;const I=f.output_url??"";if(!I||f.has_image_output===false){_.status="failed";_.error=f.text_response?`server returned text only (no image): ${f.text_response}`:"server reported success but no output_url";continue}try{const R=await Je(I,_.output_file_path,this.workspaceScope,this.ossMediaClient,{...o?{signal:o}:{}});_.status="downloaded";_.bytes=R.bytes;_.output_file_path=R.absolutePath;await ht({oss:{clean_oss_key:f.clean_oss_key,visible_oss_key:f.visible_oss_key},absolutePath:R.absolutePath,fileName:VD(R.absolutePath),sizeBytes:R.bytes,mime:gt(R.absolutePath),sessionId:t.sessionId,toolName:n,registerService:this.aigcRegisterServiceGetter?this.aigcRegisterServiceGetter():null})}catch(R){if(R instanceof E){if(R.kind==="path_escapes_workspace"){return ne(n,i,R)}_.status="failed";_.error=R.message;continue}throw R}}for(const f of u){const h=wb(f.output_file);if(h===null||h<0||h>=d.length)continue;const _=d[h];_.status="failed";const I=f.err_code?` [${f.err_code}]`:"";_.error=(f.error_msg??"unknown server error")+I}const x=d.filter(f=>f.status==="downloaded").length;const y=d.filter(f=>f.status!=="downloaded").length;const m=`${x}/${d.length} images saved (${y} failed/missing).`;return{tool_name:n,text:m,content:[{type:"text",text:m}],details:{ok:true,path:i,total_succeeded:x,total_failed:y,per_request:d}}}};bf=Q(null);un=ee(bf,0,"MatrixImageSynthesizeTool",Tb,un);Z(bf,1,un);import{extname as HD}from"node:path";var Sb=".jpg";function WD(e){try{const t=HD(new URL(e).pathname).toLowerCase();if(!t||t.length>5)return Sb;return t}catch{return Sb}}var Mb,wf;Mb=[W(Wn)];var ln=class{constructor(t,r,o){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o}archonServer;ossMediaClient;workspaceScope;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=Wn.name;const i=Y[n];const s={queries:r.queries.map(y=>({query:y.query,...y.prompt!==void 0?{prompt:y.prompt}:{}}))};if(r.providers!==void 0)s.providers=r.providers;const a=await Fe({toolName:n,path:i,input:s,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!a.ok)return a.result;const c=Array.isArray(a.response.results)?a.response.results:[];const l=[];for(let y=0;y<r.queries.length;y++){const m=r.queries[y];const f=c[y];const h={query:m.query,output_dir_path:m.output_dir_path,downloaded:[],failed:[]};if(f?.error)h.server_error=f.error;const _=Array.isArray(f?.images)?f.images:[];for(let I=0;I<_.length;I++){const R=_[I]?.image_url;if(!R){h.failed.push({index:I,image_url:"",reason:"missing image_url in response"});continue}const C=`${m.output_dir_path.replace(/\/+$/,"")}/${I}${WD(R)}`;try{const k=await Je(R,C,this.workspaceScope,this.ossMediaClient,{...o?{signal:o}:{}});h.downloaded.push({index:I,image_url:R,local_path:k.absolutePath,bytes:k.bytes})}catch(k){if(k instanceof E){if(k.kind==="path_escapes_workspace"){return ne(n,i,k)}h.failed.push({index:I,image_url:R,reason:k.message});continue}throw k}}l.push(h)}const u=l.reduce((y,m)=>y+m.downloaded.length,0);const d=l.reduce((y,m)=>y+m.failed.length,0);const x=`${u} image(s) saved across ${l.length} query(ies); ${d} failure(s).`;return{tool_name:n,text:x,content:[{type:"text",text:x}],details:{ok:true,path:i,total_downloaded:u,total_failed:d,per_query:l}}}};wf=Q(null);ln=ee(wf,0,"MatrixImagesSearchAndDownloadTool",Mb,ln);Z(wf,1,ln);var Rb,Tf;Rb=[W(Xo)];var dn=class{constructor(t,r,o){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o}archonServer;ossMediaClient;workspaceScope;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=Xo.name;const i=Y[n];try{const s=await Hr(r.image_info.map(c=>c.file_path),this.workspaceScope,this.ossMediaClient);const a={image_info:r.image_info.map((c,l)=>ir(s[l],c.prompt))};return await nr({toolName:n,path:i,input:a,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}})}catch(s){if(s instanceof E){return ne(n,i,s)}throw s}}};Tf=Q(null);dn=ee(Tf,0,"MatrixImagesUnderstandTool",Rb,dn);Z(Tf,1,dn);var Ob,Sf;Ob=[W(Yn)];var pn=class{constructor(t,r,o){this.archonServer=t;this.mediaClient=r;this.workspaceScope=o}archonServer;mediaClient;workspaceScope;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=Yn.name;const i=Y[n];if(!Gt(r.model)&&r.model!==ct){const c=`Invalid video query: model must be ${Ir} or ${ct}.`;return{tool_name:n,text:c,content:[{type:"text",text:c}],isError:true,details:{ok:false,path:i,reason:"invalid_video_request"}}}const s=await Fe({toolName:n,path:i,input:{task_id:r.task_id,model:r.model},ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!s.ok)return s.result;if(s.response.status==="succeeded"){const c=typeof s.response.video_url==="string"?s.response.video_url:"";if(!c){const l="Video task succeeded but the server response did not include video_url, so no local file was written.";return{tool_name:n,text:l,content:[{type:"text",text:l}],isError:true,details:{ok:false,path:i,reason:"missing_video_url",response:s.response}}}try{const l=await Je(c,r.output_file_path,this.workspaceScope,this.mediaClient,{...o?{signal:o}:{}});const u=`Video generation succeeded. Wrote ${l.bytes} bytes to ${l.absolutePath}.`;return{tool_name:n,text:u,content:[{type:"text",text:u}],details:{ok:true,path:i,response:s.response,output_file_path:l.absolutePath,bytes:l.bytes}}}catch(l){if(l instanceof E){return ne(n,i,l)}throw l}}const a=JSON.stringify(s.response,null,2);return{tool_name:n,text:a,content:[{type:"text",text:a}],details:{ok:true,path:i,response:s.response}}}};Sf=Q(null);pn=ee(Sf,0,"MatrixQueryVideoGenerationTool",Ob,pn);Z(Sf,1,pn);import{stat as YD}from"node:fs/promises";import{isIP as QD}from"node:net";import{extname as ZD}from"node:path";import{fileURLToPath as eU}from"node:url";import{open as JD}from"node:fs/promises";async function kb(e){const t=await JD(e,"r");try{const r=(await t.stat()).size;for await(const o of Pb(t,0,r)){if(o.type!=="moov")continue;const n=o.start+o.headerSize;const i=o.start+o.size;for await(const s of Pb(t,n,i)){if(s.type==="mvhd")return XD(t,s)}}return void 0}finally{await t.close()}}async function*Pb(e,t,r){let o=t;while(o+8<=r){const n=await Mf(e,o,8);const i=n.readUInt32BE(0);const s=n.toString("ascii",4,8);let a=8;let c;if(i===1){const l=await Mf(e,o+8,8);const u=l.readBigUInt64BE(0);if(u>BigInt(Number.MAX_SAFE_INTEGER))return;c=Number(u);a=16}else{c=i===0?r-o:i}if(c<a||o+c>r)return;yield{type:s,start:o,size:c,headerSize:a};o+=c}}async function XD(e,t){const r=t.size-t.headerSize;if(r<20)return void 0;const o=await Mf(e,t.start+t.headerSize,Math.min(r,32));const n=o.readUInt8(0);if(n===0&&o.length>=20){return Ab(o.readUInt32BE(12),BigInt(o.readUInt32BE(16)))}if(n===1&&o.length>=32){return Ab(o.readUInt32BE(20),o.readBigUInt64BE(24))}return void 0}function Ab(e,t){if(e<=0)return void 0;const r=Number(t)/e;return Number.isFinite(r)&&r>0?r:void 0}async function Mf(e,t,r){const o=Buffer.allocUnsafe(r);const{bytesRead:n}=await e.read(o,0,r,t);if(n!==r)throw new Error("Unexpected end of ISO BMFF file");return o}var tU="16:9";var rU=new Set(["21:9","16:9","4:3","1:1","3:4","9:16"]);var oU=new Set([...rU,"adaptive"]);var jb={forceRemoteUrl:true,category:"user_file_upload_tmp"};var Rf=new Set([".jpg",".jpeg",".png",".webp",".heic",".heif"]);var nU=new Set([".jpg",".png",".webp"]);var iU=new Set([".mp4",".mov"]);var sU=new Set([".wav",".mp3"]);var Of=30*1024*1024;var Eb=50*1024*1024;var aU=15*1024*1024;var Pf=new Set;var Nb,kf;Nb=[W(Xn)];var fn=class{constructor(t,r,o){this.archonServer=t;this.videoMediaClient=r;this.workspaceScope=o}archonServer;videoMediaClient;workspaceScope;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=Xn.name;const i=Y[n];const s=dU(r);if(s)return mU(n,i,s);const a=r.input_image_path!==void 0||r.last_frame_image_path!==void 0;const c=pU(r);const l=Gt(r.model)?a?"adaptive":c?r.ratio??"adaptive":r.ratio??tU:r.ratio;const u=Gt(r.model)?r.resolution??"2K":r.resolution;const d={...r,ratio:l,resolution:u};const x=`${t.sessionId}:${t.turnId}:${vf(d)}`;if(Pf.has(x)){return Cb(n,i)}let y;let m;let f;let h;let _;try{if(r.input_image_path){y=await bu(r.input_image_path,this.workspaceScope,this.videoMediaClient,Of,"input_image_path")}if(r.last_frame_image_path){m=await bu(r.last_frame_image_path,this.workspaceScope,this.videoMediaClient,Of,"last_frame_image_path")}f=await $b(r.reference_image_paths,this.workspaceScope,this.videoMediaClient,Of,"reference_image_paths");h=await cU(r.reference_video_paths,r.reference_video_duration_seconds,this.workspaceScope,this.videoMediaClient);_=await $b(r.reference_audio_paths,this.workspaceScope,this.videoMediaClient,aU,"reference_audio_paths")}catch(C){if(C instanceof E){return ne(n,i,C)}throw C}const I={model:r.model,prompt:r.prompt};if(y)I.input_image=y;if(y){I.reference_type=r.reference_type??"first_frame"}if(m)I.last_frame_image=m;if(f!==void 0)I.reference_images=f;if(h!==void 0)I.reference_videos=h;if(_!==void 0)I.reference_audios=_;I.duration=r.duration;if(u!==void 0)I.resolution=u;if(l!==void 0){I.ratio=l}if(r.aigc_watermark!==void 0)I.aigc_watermark=r.aigc_watermark;if(Pf.has(x)){return Cb(n,i)}Pf.add(x);let R;try{R=await Fe({toolName:n,path:i,input:I,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}})}catch(C){return Fb(n,i,C)}if(!R.ok)return Fb(n,i,R.result.text,R.result);return hU(n,i,R.response)}};kf=Q(null);fn=ee(kf,0,"MatrixSubmitVideoGenerationTool",Nb,fn);Z(kf,1,fn);async function $b(e,t,r,o,n){if(e===void 0)return void 0;const i=[];for(const[s,a]of e.entries()){i.push(await bu(a,t,r,o,`${n}[${s}]`))}return i}async function cU(e,t,r,o){if(e===void 0)return void 0;const n=[];for(const[s,a]of e.entries()){const c=t?.[s];if(wu(a)&&c===void 0){throw new E("input_upload_failed",`reference_video_duration_seconds[${s}] is required for public reference video URL '${a}'.`)}let l;let u=c;if(wu(a)){l=await bu(a,r,o,Eb,`reference_video_paths[${s}]`)}else{const d=await zb(a,r,Eb,`reference_video_paths[${s}]`);let x;try{x=await kb(d.absolutePath)}catch(m){throw new E("input_upload_failed",`Could not read duration_seconds for reference_video_paths[${s}] '${a}'. Provide a valid MP4/MOV workspace file or use a public URL with reference_video_duration_seconds[${s}].`,m)}if(x===void 0){throw new E("input_upload_failed",`Could not read duration_seconds for reference_video_paths[${s}] '${a}'. Provide a valid MP4/MOV workspace file or use a public URL with reference_video_duration_seconds[${s}].`)}u=x;const y=await Vr(a,r,o,jb);l=Db(y);if(l.url&&!Ef(l.url)){throw new E("input_upload_failed",`Failed to prepare video media '${a}': temporary URL host is not publicly reachable.`)}}if(u===void 0){throw new E("input_upload_failed",`Could not read duration_seconds for reference_video_paths[${s}] '${a}'. Provide reference_video_duration_seconds[${s}] explicitly.`)}if(u<2||u>15){throw new E("input_upload_failed",`reference video duration_seconds must be between 2 and 15; reference_video_paths[${s}] is ${u}.`)}n.push({...l,duration_seconds:u})}const i=n.reduce((s,a)=>s+a.duration_seconds,0);if(i>15){throw new E("input_upload_failed",`reference video duration_seconds total must be at most 15; received ${i}.`)}return n}async function bu(e,t,r,o,n){if(wu(e)){if(!Ef(e)){throw new E("input_upload_failed",`Failed to prepare video media '${e}': URL host is not publicly reachable.`)}return{url:e}}await zb(e,t,o,n);const i=Db(await Vr(e,t,r,jb));if(i.url&&!Ef(i.url)){throw new E("input_upload_failed",`Failed to prepare video media '${e}': temporary URL host is not publicly reachable.`)}return i}async function zb(e,t,r,o){let n;try{n=e.startsWith("file://")?eU(e):e}catch(a){throw new E("input_not_found",`Input file URL is invalid: '${e}'. Provide a workspace-relative path or valid file:// URL.`,a)}let i;try{i=await xu(n,t)}catch(a){throw new E("path_escapes_workspace",`Input file path '${e}' is outside the workspace. Provide a path under one of: '${fa(t).join("', '")}'.`,a)}let s;try{s=await YD(i)}catch(a){throw new E("input_not_found",`Input file does not exist at '${i}'. Make sure the file was written before calling this tool.`,a)}if(!s.isFile()){throw new E("input_not_found",`Input path is not a file: ${i}`)}if(s.size>r){throw new E("input_upload_failed",`${o} is ${vb(s.size)}, above the Video Generation V2 limit of ${vb(r)}.`)}return{absolutePath:i,bytes:s.size}}function vb(e){return`${(e/(1024*1024)).toFixed(1)} MiB`}function Db(e){return{url:si(e),...e.mimeType?{mime_type:e.mimeType}:{}}}function wu(e){try{const t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"}catch{return false}}function Ef(e){try{const t=new URL(e);if(t.protocol!=="http:"&&t.protocol!=="https:")return false;const r=t.hostname.toLowerCase().replace(/^\[|\]$/gu,"");const o=QD(r);if(o===4)return uU(r);if(o===6)return lU(r);if(r==="localhost"||!r.includes(".")||[".localhost",".local",".internal",".home.arpa",".invalid"].some(n=>r.endsWith(n))||r.endsWith("-internal.aliyuncs.com")){return false}return true}catch{return false}}function uU(e){const t=e.split(".").map(Number);if(t.length!==4||t.some(i=>!Number.isInteger(i)||i<0||i>255)){return false}const[r=0,o=0,n=0]=t;if(r===0||r===10||r===127||r>=224)return false;if(r===100&&o>=64&&o<=127)return false;if(r===169&&o===254)return false;if(r===172&&o>=16&&o<=31)return false;if(r===192&&o===168)return false;if(r===192&&o===0&&[0,2].includes(n))return false;if(r===198&&[18,19,51].includes(o))return false;if(r===203&&o===0&&n===113)return false;return true}function lU(e){const t=e.toLowerCase();return!(t==="::"||t==="::1"||t.startsWith("fc")||t.startsWith("fd")||/^fe[89ab]/u.test(t)||t.startsWith("ff")||t.startsWith("2001:db8:")||t.startsWith("::ffff:"))}function dU(e){if(!Gt(e.model)&&e.model!==ct){return`model must be ${Ir} or ${ct}`}if(!e.prompt?.trim())return"prompt is required";if(Array.from(e.prompt).length>gu){return`prompt may contain at most ${gu} characters`}if(!Number.isInteger(e.duration)){return"duration is required after model selection and must be an integer number of seconds"}if(Gt(e.model)&&(e.duration<4||e.duration>15)){return`${Ir} duration must be between 4 and 15 seconds`}const t=Iu(e.reference_image_paths,"reference_image_paths",9)??Iu(e.reference_video_paths,"reference_video_paths",3)??Iu(e.reference_video_duration_seconds,"reference_video_duration_seconds",3)??Iu(e.reference_audio_paths,"reference_audio_paths",nf);if(t)return t;if(e.reference_video_duration_seconds!==void 0&&e.reference_video_paths===void 0){return"reference_video_duration_seconds requires reference_video_paths"}if(e.reference_video_duration_seconds!==void 0&&e.reference_video_duration_seconds.length!==e.reference_video_paths?.length){return"reference_video_duration_seconds must contain the same number of items as reference_video_paths"}if(e.reference_video_duration_seconds!==void 0){for(const[a,c]of e.reference_video_duration_seconds.entries()){if(!Number.isFinite(c)||c<2||c>15){return`reference_video_duration_seconds[${a}] must be between 2 and 15`}}const s=e.reference_video_duration_seconds.reduce((a,c)=>a+c,0);if(s>15){return`reference_video_duration_seconds total must be at most 15; received ${s}`}}const r=(e.reference_image_paths?.length??0)+(e.reference_video_paths?.length??0)+(e.reference_audio_paths?.length??0);if(Gt(e.model)&&r>sf){return`reference collections may contain at most ${sf} files in total`}const o=e.reference_image_paths!==void 0||e.reference_video_paths!==void 0||e.reference_audio_paths!==void 0;if(e.model===ct&&o){return`${ct} accepts exactly one input_image_path; reference collections are supported only by ${Ir}`}if(e.model===ct&&!e.input_image_path?.trim()){return`${ct} requires exactly one input_image_path`}if(o&&(e.input_image_path!==void 0||e.last_frame_image_path!==void 0||e.reference_type!==void 0)){return"reference collections cannot be combined with keyframe image paths or reference_type"}if((e.reference_audio_paths?.length??0)>0&&(e.reference_image_paths?.length??0)===0&&(e.reference_video_paths?.length??0)===0){return"reference_audio_paths cannot be used alone; add at least one reference image or video"}if(e.reference_type!==void 0&&e.input_image_path===void 0){return"reference_type requires input_image_path"}if(e.last_frame_image_path!==void 0){if(!Gt(e.model)){return"last_frame_image_path is supported only by Alran-H3"}if(e.input_image_path===void 0){return"last_frame_image_path requires input_image_path as the first frame"}if(e.reference_type!==void 0&&e.reference_type!=="first_frame"){return"first+last-frame mode requires reference_type first_frame or omitted"}}if(Gt(e.model)&&e.reference_type!==void 0&&e.reference_type!=="first_frame"&&e.reference_type!=="last_frame"){return`${Ir} supports first_frame or last_frame keyframe mode`}if(e.model===ct&&e.reference_type!==void 0&&e.reference_type!=="first_frame"&&e.reference_type!=="subject"){return`${ct} supports first_frame or legacy subject mode`}if(Gt(e.model)&&e.resolution!==void 0&&e.resolution!=="768P"&&e.resolution!=="2K"){return`${Ir} supports 768P or 2K`}if(e.model===ct&&e.resolution!==void 0&&e.resolution!=="768P"&&e.resolution!=="1080P"){return`${ct} supports 768P or 1080P`}if(e.model===ct){if(e.duration!==6&&e.duration!==10){return`${ct} supports 6s or 10s`}if(e.duration===10&&e.resolution==="1080P"){return`${ct} 10s generation requires 768P`}}if(Gt(e.model)&&e.ratio!==void 0&&!oU.has(e.ratio)){return`${Ir} ratio must be adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, or 9:16`}const n=e.input_image_path!==void 0||e.last_frame_image_path!==void 0;if(Gt(e.model)&&!n&&!o&&e.ratio==="adaptive"){return`${Ir} text-only ratio cannot be adaptive`}const i=$f(e.input_image_path,"input_image_path",Gt(e.model)?Rf:nU)??$f(e.last_frame_image_path,"last_frame_image_path",Rf)??Af(e.reference_image_paths,"reference_image_paths",Rf)??Af(e.reference_video_paths,"reference_video_paths",iU)??Af(e.reference_audio_paths,"reference_audio_paths",sU);return i}function pU(e){return e.reference_image_paths!==void 0||e.reference_video_paths!==void 0||e.reference_audio_paths!==void 0}function Iu(e,t,r){if(e===void 0)return void 0;if(e.length===0)return`${t} must be a non-empty array when provided`;if(r!==void 0&&e.length>r){return`${t} may contain at most ${r} items`}return void 0}function Af(e,t,r){if(e===void 0)return void 0;for(let o=0;o<e.length;o+=1){const n=$f(e[o],`${t}[${o}]`,r);if(n)return n}return void 0}function $f(e,t,r){if(e===void 0)return void 0;const o=ZD(fU(e)).toLowerCase();if(!r.has(o)){return`${t} must use ${[...r].join(", ")} media`}return void 0}function fU(e){if(wu(e))return new URL(e).pathname;return e.split(/[?#]/u,1)[0]??""}function mU(e,t,r){const o=`Invalid video request: ${r}. No file was read and no paid task was submitted.`;return{tool_name:e,text:o,content:[{type:"text",text:o}],isError:true,details:{ok:false,path:t,reason:"invalid_video_request"}}}function Cb(e,t){const r="Duplicate paid submission blocked: this exact video request was already attempted in this turn. Do not wait and do not call submit_video_generation again. If the original attempt returned a task_id, call query_video_generation with that task_id and the same model. If it returned an error, report that original failure; never infer that a task was created. Retry only after a new explicit user request in a later turn.";return{tool_name:e,text:r,content:[{type:"text",text:r}],isError:true,details:{ok:false,path:t,reason:"duplicate_paid_submission"}}}function Fb(e,t,r,o){const n=r instanceof Error?r.message:String(r);const i=`Video submit failed: ${n}. No task_id was returned. Do not infer that a task was created, do not wait for a duplicate lock to expire, and do not retry submit_video_generation automatically. Report this failure to the user. Retry only after a new explicit user request in a later turn.`;return{tool_name:e,text:i,content:[{type:"text",text:i}],isError:true,details:{...o?.details??{},ok:false,path:t,reason:"video_submit_failed",...o?.details?{upstream:o.details}:{}}}}function hU(e,t,r){const o=JSON.stringify(r,null,2);return{tool_name:e,text:o,content:[{type:"text",text:o}],details:{ok:true,path:t,response:r}}}function vf(e){if(Array.isArray(e))return`[${e.map(t=>vf(t)).join(",")}]`;if(e&&typeof e==="object"){const t=Object.entries(e).filter(([,r])=>r!==void 0).sort(([r],[o])=>r.localeCompare(o));return`{${t.map(([r,o])=>`${JSON.stringify(r)}:${vf(o)}`).join(",")}}`}return JSON.stringify(e)??"null"}var Ub,Cf;Ub=[W(Mo)];var mn=class{constructor(t,r,o){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o}archonServer;ossMediaClient;workspaceScope;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=Y[Mo.name];try{const i=await Vr(r.audio_info.file_path,this.workspaceScope,this.ossMediaClient);const s={audio_info:ir(i,r.audio_info.prompt)};return await nr({toolName:Mo.name,path:n,input:s,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}})}catch(i){if(i instanceof E){return ne(Mo.name,n,i)}throw i}}};Cf=Q(null);mn=ee(Cf,0,"MatrixTranscribeAudioTool",Ub,mn);Z(Cf,1,mn);import{basename as gU}from"node:path";var Lb,Ff;Lb=[W(oi)];var hn=class{constructor(t,r,o,n=null){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o;this.aigcRegisterServiceGetter=n}archonServer;ossMediaClient;workspaceScope;aigcRegisterServiceGetter;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=oi.name;const i=Y[n];const{output_file_path:s,...a}=r;const c=await Fe({toolName:n,path:i,input:a,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}});if(!c.ok)return c.result;const l=typeof c.response.output_url==="string"?c.response.output_url:"";if(!l){const u=typeof c.response.error==="string"?c.response.error:"";const d=`server response missing output_url${u?` (server error: ${u})`:". Cannot download generated audio."}`;return{tool_name:n,text:d,content:[{type:"text",text:d}],details:{ok:false,path:i,reason:"missing_output_url",response:c.response}}}try{const u=await Je(l,r.output_file_path,this.workspaceScope,this.ossMediaClient,{...o?{signal:o}:{}});const d=typeof c.response.clean_oss_key==="string"?c.response.clean_oss_key:void 0;const x=typeof c.response.visible_oss_key==="string"?c.response.visible_oss_key:void 0;await ht({oss:{clean_oss_key:d,visible_oss_key:x},absolutePath:u.absolutePath,fileName:gU(u.absolutePath),sizeBytes:u.bytes,mime:gt(u.absolutePath),sessionId:t.sessionId,toolName:n,registerService:this.aigcRegisterServiceGetter?this.aigcRegisterServiceGetter():null});const y=`wrote ${u.bytes} bytes to ${u.absolutePath}.`;return{tool_name:n,text:y,content:[{type:"text",text:y}],details:{ok:true,path:i,output_file_path:u.absolutePath,bytes:u.bytes}}}catch(u){if(u instanceof E){return ne(n,i,u)}throw u}}};Ff=Q(null);hn=ee(Ff,0,"MatrixSynthesizeSpeechTool",Lb,hn);Z(Ff,1,hn);var qb,Nf;qb=[W(Qo)];var gn=class{constructor(t,r,o){this.archonServer=t;this.ossMediaClient=r;this.workspaceScope=o}archonServer;ossMediaClient;workspaceScope;async execute(t,r,o){if(o?.aborted)throw new Error("Operation aborted");const n=Qo.name;const i=Y[n];try{const s=await Hr(r.video_info.map(c=>c.file_path),this.workspaceScope,this.ossMediaClient);const a={video_info:r.video_info.map((c,l)=>ir(s[l],c.prompt))};return await nr({toolName:n,path:i,input:a,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}})}catch(s){if(s instanceof E){return ne(n,i,s)}throw s}}};Nf=Q(null);gn=ee(Nf,0,"MatrixVideosUnderstandTool",qb,gn);Z(Nf,1,gn);var Kb,jf;Kb=[W(Zi)];var yn=class{constructor(t,r,o){this.archonServer=t;this._ossMediaClient=r;this._workspaceScope=o}archonServer;_ossMediaClient;_workspaceScope;execute(t,r,o){return nr({toolName:Zi.name,path:Y[Zi.name],input:r,ctx:t,archonServer:this.archonServer,...o?{signal:o}:{}})}};jf=Q(null);yn=ee(jf,0,"MatrixWebSearchTool",Kb,yn);Z(jf,1,yn);var jZ=[Xo.name,Hn.name,Wn.name,Jn.name,Xn.name,Yn.name,Qn.name,Zn.name,ei.name,Yo.name,ti.name,ri.name,oi.name,ni.name,ii.name,Qo.name,Mo.name];function Gb(e,t,r,o=null,n={}){const i=[Xe(new yn(e,t,r)),Xe(new dn(e,t,r)),Xe(new un(e,t,r,o)),Xe(new ln(e,t,r)),Xe(new cn(e,t,r)),Xe(new fn(e,n.videoMediaClient??t,r)),Xe(new pn(e,t,r)),Xe(new sn(e,t,r,o)),Xe(new nn(e,t,r,o)),Xe(new en(e,t,r,o)),Xe(new an(e,t,r)),Xe(new rn(e,t,r,o)),Xe(new on(e,t,r,o)),Xe(new hn(e,t,r,o)),Xe(new tn(e,t,r,o)),Xe(new Zo(e,t,r)),Xe(new gn(e,t,r)),Xe(new mn(e,t,r))];const{matrixLogger:s}=n;if(!s)return i;return i.map(a=>yU(a,s))}function yU(e,t){return{def:e.def,impl:{execute(r,o,n,i){return e.impl.execute({...r,matrixLogger:r.matrixLogger??t},o,n,i)}}}}var zZ={supportImage:[Xo.name],supportVideo:[Qo.name]};var MU=600*1024;var Wb=500*1024*1024;var RU="/alran/api/v1/mcp/get_upload_url";var Jb=15e5;var es=class{constructor(t){this.client=t}client;async uploadFile(t,r={}){let o;try{o=await Bb(t)}catch(l){throw new $t("file_not_found",`Input file does not exist: ${t}`,l)}if(!o.isFile()){throw new $t("file_not_found",`Input path is not a file: ${t}`)}if(o.size>Wb){throw new $t("file_too_large",`${Vb(t)} is ${Xb(o.size)}, above the Matrix upload limit of ${Xb(Wb)}.`)}const n=PU(r.filename??Vb(t));const i=r.mimeType??OU(n);if(!r.forceRemoteUrl&&o.size<=MU){const l=(await bU(t)).toString("base64");return{ossKey:"",inlineData:l,mimeType:i,bytes:o.size}}const s=await this.client.postGatewayJson(RU,{filename:n,mime_type:i,...r.ttlSeconds!==void 0?{ttl_seconds:r.ttlSeconds}:{},...r.category!==void 0?{category:r.category}:{},size_bytes:o.size},void 0,Jb);if((s.code??0)!==0||!s.put_url||!s.cdn_url){const l=s.error||s.message||"no put_url returned";throw new $t("upload_failed",`Matrix get_upload_url failed: code=${s.code??"unknown"} ${l}`)}const a=s.content_type||i;const c=Hb.toWeb(xU(t));try{await this.client.putBytes(s.put_url,c,{"Content-Type":a,"Content-Length":String(o.size)},void 0,Jb)}catch(l){throw new $t("upload_failed",Df(l),l)}return{ossKey:s.oss_key??"",signedUrl:s.cdn_url,mimeType:a,bytes:o.size}}async downloadToFile(t,r,o){let n;try{n=await this.client.getStream(t,o?.signal,o?.timeoutMs)}catch(i){throw AU(i)}try{await IU(wU(r),{recursive:true});await SU(Hb.fromWeb(n.body),_U(r));const i=await Bb(r);return{bytes:i.size}}catch(i){if(o?.signal?.aborted){throw new $t("aborted","Matrix download aborted",i)}throw new $t("write_failed",Df(i),i)}finally{n.dispose()}}};function OU(e){const t=TU(e).toLowerCase();return kU[t]??"application/octet-stream"}function PU(e){if(!e)return"file";const t=e.lastIndexOf(".");let r;let o;if(t<=0||t===e.length-1){r=zf(e);o=""}else{r=zf(e.slice(0,t));o=zf(e.slice(t+1))}if(!r)r="file";if(t>0&&t<e.length-1){if(!o)o="bin";return`${r}.${o}`}return r}function zf(e){return e.replace(/[^A-Za-z0-9_-]/gu,"_")}function Xb(e){return`${(e/(1024*1024)).toFixed(1)} MiB`}function AU(e){if(e instanceof $t)return e;if(e instanceof Error&&e.name==="AbortError"){return new $t("aborted","Matrix download aborted",e)}return new $t("download_failed",Df(e),e)}function Df(e){if(e instanceof Error)return e.message||e.name;if(typeof e==="string")return e;return String(e)}var kU={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".bmp":"image/bmp",".svg":"image/svg+xml",".heic":"image/heic",".mp3":"audio/mpeg",".wav":"audio/wav",".ogg":"audio/ogg",".flac":"audio/flac",".m4a":"audio/mp4",".aac":"audio/aac",".mp4":"video/mp4",".mov":"video/quicktime",".webm":"video/webm",".mkv":"video/x-matroska",".avi":"video/x-msvideo",".pdf":"application/pdf",".txt":"text/plain",".json":"application/json",".zip":"application/zip"};function Yb(e){const t=e.executor??new eo({...e.baseUrl?{baseUrl:e.baseUrl}:{},...e.accessToken?{accessToken:e.accessToken}:{},...e.authContext?{authContext:e.authContext}:{},...e.fetchImpl?{fetchImpl:e.fetchImpl}:{}});const r=e.mediaClient??new es(t instanceof eo?t:new eo({...e.baseUrl?{baseUrl:e.baseUrl}:{},...e.accessToken?{accessToken:e.accessToken}:{},...e.authContext?{authContext:e.authContext}:{},...e.fetchImpl?{fetchImpl:e.fetchImpl}:{}}));const o=e.extraInputRoots?.length?{workspaceRoot:e.workspaceRoot,extraInputRoots:e.extraInputRoots}:e.workspaceRoot;return Gb(t,r,o,null,{...e.matrixLogger?{matrixLogger:e.matrixLogger}:{}})}var EU=/^[A-Za-z0-9._-]+$/u;function Qb(e,t){if(t!=="dev"&&t!=="test"&&t!=="staging")return{};const r=e?.bedrockLane?.trim();return r&&EU.test(r)?{"bedrock-lane":r,bedrock_lane:r}:{}}function vU(e){const t=e.executor??new eo({...e.baseUrl?{baseUrl:e.baseUrl}:{},...e.accessToken?{accessToken:e.accessToken}:{},...e.authContext?{authContext:e.authContext}:{},...e.fetchImpl?{fetchImpl:e.fetchImpl}:{},...e.routingHeadersGetter?{routingHeadersGetter:e.routingHeadersGetter}:{}});const r=e.mediaClient??new es(t instanceof eo?t:new eo({...e.baseUrl?{baseUrl:e.baseUrl}:{},...e.accessToken?{accessToken:e.accessToken}:{},...e.authContext?{authContext:e.authContext}:{},...e.fetchImpl?{fetchImpl:e.fetchImpl}:{},...e.routingHeadersGetter?{routingHeadersGetter:e.routingHeadersGetter}:{}}));const o=Yb({workspaceRoot:e.workspaceRoot,...e.extraInputRoots?.length?{extraInputRoots:e.extraInputRoots}:{},executor:t,mediaClient:r});return{tools:o,workspaceRoot:e.workspaceRoot,createContext:e.createContext??(()=>({sessionId:"matrix-mcp-stdio",turnId:`matrix-mcp-${Date.now()}`,workspaceRoot:e.workspaceRoot}))}}function CU(e=process.env,t={}){const r=e.ALRAN_MATRIX_WORKSPACE_ROOT||e.WORKSPACE_ROOT||process.cwd();const o=(e.ALRAN_MATRIX_EXTRA_INPUT_ROOTS??"").split($U).map(s=>s.trim()).filter(s=>s.length>0);const n=_c(e);const i=n.managed&&(e.ALRAN_MATRIX_ACCESS_TOKEN||e.MATRIX_ACCESS_TOKEN);return vU({workspaceRoot:r,...o.length>0?{extraInputRoots:o}:{},baseUrl:n.baseUrl,...n.explicitToken?{accessToken:n.explicitToken}:{},...i?{authContext:{accessToken:i}}:{},...t.fetchImpl?{fetchImpl:t.fetchImpl}:{},routingHeadersGetter:()=>Qb({bedrockLane:e.ALRAN_MATRIX_BEDROCK_LANE},e.ALRAN_BUILD_ENV)})}function FU(e){return e.tools.map(t=>({name:t.def.name,description:t.def.description,inputSchema:Zb(t.def.schema)?t.def.schema:{type:"object"}}))}async function NU(e,t,r={},o){const n=e.tools.find(i=>i.def.name===t);if(!n){return{isError:true,content:[{type:"text",text:`Unknown Matrix MCP tool: ${t}`}],_meta:{matrix:{server:"matrix",tool:t}}}}try{const i=n.def.prepareArguments?n.def.prepareArguments(r):r;const s=await n.impl.execute(e.createContext(),i,o);return zU(t,s)}catch(i){return{isError:true,content:[{type:"text",text:`Matrix MCP tool failed: ${UU(i)}`}],_meta:{matrix:{server:"matrix",tool:t}}}}}function jU(e){const t=new gc({name:"alran-matrix-mcp-server",version:"0.2.1"},{capabilities:{tools:{}}});t.setRequestHandler(Hu,async()=>({tools:FU(e)}));t.setRequestHandler(ls,async r=>{const o=r.params.name;const n=Zb(r.params.arguments)?r.params.arguments:{};return NU(e,o,n)});return t}async function Eee(e=CU()){const t=jU(e);const r=new xc;await t.connect(r);process.stderr.write("[alran-matrix-mcp-server] ready\n")}function zU(e,t){const r=t.content.flatMap(o=>DU(o));if(r.length===0&&t.text){r.push({type:"text",text:t.text})}return{content:r,isError:t.isError===true,_meta:{matrix:{server:"matrix",tool:e},...t.details?{details:t.details}:{},...t.output?{output:t.output}:{}}}}function DU(e){if(e.type==="text"){return[{type:"text",text:e.text}]}if(e.type==="image"){return[{type:"image",data:e.data,mimeType:e.mimeType}]}return[{type:"text",text:`[matrix] non-text block omitted from MCP preview: type=video`}]}function Zb(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function UU(e){return e instanceof Error?e.message:String(e)}export{qd as a,dA as b,pA as c,fA as d,mA as e,hA as f,gA as g,yA as h,ep as i,tp as j,xA as k,_A as l,IA as m,bA as n,TA as o,Ry as p,MA as q,RA as r,W as s,Xe as t,Ee as u,p as v,Kn as w,hz as x,ef as y,Vz as z,kX as A,vX as B,qI as C,sD as D,pD as E,GI as F,_c as G,Xd as H,Qd as I,eo as J,Qb as K,Y as L,WI as M,nr as N,uy as O,vU as P,FU as Q,Eee as R};
|