@jsrepo/mcp 0.0.1-beta.2 → 0.0.1-beta.21
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/README.md +4 -1
- package/dist/index.js +51 -32
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# @jsrepo/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://npmjs.com/package/@jsrepo/mcp)
|
|
4
|
+
[](https://npmjs.com/package/@jsrepo/mcp)
|
|
5
|
+
|
|
6
|
+
The MCP server for **jsrepo**.
|
|
4
7
|
|
|
5
8
|
## Usage
|
|
6
9
|
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import e from"node:process";import{
|
|
1
|
+
import e from"node:process";import{RegistryItemNotFoundError as t,getPathsForItems as n,normalizeItemTypeForPath as r,prepareUpdates as i,promptAddEnvVars as a,resolveAndFetchAllItems as o,updateFiles as s}from"jsrepo";import{loadConfigSearch as c}from"jsrepo/config";import{DEFAULT_PROVIDERS as l}from"jsrepo/providers";import{parseWantedItems as u,promptInstallDependenciesByEcosystem as d,resolveRegistries as f,resolveWantedItems as p}from"jsrepo/utils";import{AsyncLocalStorage as m}from"node:async_hooks";var h=Object.create,ee=Object.defineProperty,g=Object.getOwnPropertyDescriptor,_=Object.getOwnPropertyNames,v=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,y=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),b=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=_(t),a=0,o=i.length,s;a<o;a++)s=i[a],!te.call(e,s)&&s!==n&&ee(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e},x=(e,t,n)=>(n=e==null?{}:h(v(e)),b(t||!e||!e.__esModule?ee(n,`default`,{value:e,enumerable:!0}):n,e)),S=class{#e;#t=new Set;#n={};#r={resource:[]};constructor(t){this.#e=t,this.#t.add(this.#e.on(`initialize`,({capabilities:t,clientInfo:n})=>{this.#n.clientCapabilities=t,this.#n.clientInfo=n,this.#t.add(this.#e.on(`send`,({request:t})=>{e.stdout.write(JSON.stringify(t)+`
|
|
2
2
|
`)})),this.#t.add(this.#e.on(`broadcast`,({request:t})=>{t.method===`notifications/resources/updated`&&!this.#r.resource.includes(t.params.uri)||e.stdout.write(JSON.stringify(t)+`
|
|
3
3
|
`)})),this.#t.add(this.#e.on(`loglevelchange`,({level:e})=>{this.#n.logLevel=e})),this.#t.add(this.#e.on(`subscription`,({uri:e})=>{this.#r??={resource:[]},this.#r.resource?.push(e)}))}))}#i(){for(let e of this.#t)e();e.exit(0)}listen(t){e.stdin.setEncoding(`utf8`);let n=``;e.stdin.on(`data`,async r=>{n+=r;let i=n.split(`
|
|
4
4
|
`);n=i.pop()||``;for(let n of i)if(n.trim())try{let r=JSON.parse(n),i=await this.#e.receive(r,{custom:t,sessionInfo:this.#n});i&&e.stdout.write(JSON.stringify(i)+`
|
|
5
|
-
`)}catch{}}),e.stdin.on(`end`,()=>{this.#i()}),e.on(`SIGINT`,()=>{this.#i()}),e.on(`SIGTERM`,()=>{this.#i()})}},C=S(b(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}))(),1),w=class{toJsonSchema(e){throw Error(`toJsonSchema method not implemented`)}};Object.freeze({status:`aborted`});function T(e,t,n){function r(n,r){var i;for(let a in Object.defineProperty(n,`_zod`,{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),o.prototype)a in n||Object.defineProperty(n,a,{value:o.prototype[a].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var E=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ne=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};const re={};function D(e){return e&&Object.assign(re,e),re}function ie(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function O(e,t){return typeof t==`bigint`?t.toString():t}function ae(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function k(e){return e==null}function oe(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function se(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}const A=Symbol(`evaluating`);function j(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==A)return r===void 0&&(r=A,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ce(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function M(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function N(e){return JSON.stringify(e)}const le=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const de=ae(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function fe(e){if(ue(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(ue(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function pe(e){return fe(e)?{...e}:Array.isArray(e)?[...e]:e}const me=new Set([`string`,`number`,`symbol`]);function he(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ge(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function P(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function _e(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const ve={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ye(e,t){let n=e._zod.def;return ge(e,M(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return ce(this,`shape`,e),e},checks:[]}))}function be(e,t){let n=e._zod.def;return ge(e,M(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return ce(this,`shape`,r),r},checks:[]}))}function xe(e,t){if(!fe(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return ge(e,M(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ce(this,`shape`,n),n},checks:[]}))}function Se(e,t){if(!fe(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ge(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return ce(this,`shape`,n),n},checks:e._zod.def.checks})}function Ce(e,t){return ge(e,M(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ce(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function we(e,t,n){return ge(t,M(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return ce(this,`shape`,i),i},checks:[]}))}function Te(e,t,n){return ge(t,M(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return ce(this,`shape`,i),i},checks:[]}))}function Ee(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function De(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Oe(e){return typeof e==`string`?e:e?.message}function ke(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Oe(e.inst?._zod.def?.error?.(e))??Oe(t?.error?.(e))??Oe(n.customError?.(e))??Oe(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ae(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function je(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Me=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,O,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Ne=T(`$ZodError`,Me),Pe=T(`$ZodError`,Me,{Parent:Error});function Fe(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ie(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}const Le=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new E;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>ke(e,a,D())));throw le(t,i?.callee),t}return o.value},Re=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>ke(e,a,D())));throw le(t,i?.callee),t}return o.value},ze=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new E;return a.issues.length?{success:!1,error:new(e??Ne)(a.issues.map(e=>ke(e,i,D())))}:{success:!0,data:a.value}},Be=ze(Pe),Ve=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>ke(e,i,D())))}:{success:!0,data:a.value}},He=Ve(Pe),Ue=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Le(e)(t,n,i)},We=e=>(t,n,r)=>Le(e)(t,n,r),Ge=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Re(e)(t,n,i)},Ke=e=>async(t,n,r)=>Re(e)(t,n,r),qe=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return ze(e)(t,n,i)},Je=e=>(t,n,r)=>ze(e)(t,n,r),Ye=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Ve(e)(t,n,i)},Xe=e=>async(t,n,r)=>Ve(e)(t,n,r),Ze=/^[cC][^\s-]{8,}$/,Qe=/^[0-9a-z]+$/,$e=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,et=/^[0-9a-vA-V]{20}$/,tt=/^[A-Za-z0-9]{27}$/,nt=/^[a-zA-Z0-9_-]{21}$/,rt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,it=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,at=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ot=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function st(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const ct=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,lt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ut=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,dt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ft=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,pt=/^[A-Za-z0-9_-]*$/,mt=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,ht=/^\+(?:[0-9]){6,14}[0-9]$/,gt=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,_t=RegExp(`^${gt}$`);function vt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function yt(e){return RegExp(`^${vt(e)}$`)}function bt(e){let t=vt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${gt}T(?:${r})$`)}const xt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},St=/^-?\d+$/,Ct=/^-?\d+(?:\.\d+)?/,wt=/^(?:true|false)$/i,Tt=/^[^A-Z]*$/,Et=/^[^a-z]*$/,F=T(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Dt={number:`number`,bigint:`bigint`,object:`date`},Ot=T(`$ZodCheckLessThan`,(e,t)=>{F.init(e,t);let n=Dt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),kt=T(`$ZodCheckGreaterThan`,(e,t)=>{F.init(e,t);let n=Dt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),At=T(`$ZodCheckMultipleOf`,(e,t)=>{F.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):se(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),jt=T(`$ZodCheckNumberFormat`,(e,t)=>{F.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ve[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=St)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Mt=T(`$ZodCheckMaxLength`,(e,t)=>{var n;F.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!k(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Ae(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Nt=T(`$ZodCheckMinLength`,(e,t)=>{var n;F.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!k(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Ae(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Pt=T(`$ZodCheckLengthEquals`,(e,t)=>{var n;F.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!k(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Ae(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ft=T(`$ZodCheckStringFormat`,(e,t)=>{var n,r;F.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),It=T(`$ZodCheckRegex`,(e,t)=>{Ft.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Lt=T(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Tt,Ft.init(e,t)}),Rt=T(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Et,Ft.init(e,t)}),zt=T(`$ZodCheckIncludes`,(e,t)=>{F.init(e,t);let n=he(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Bt=T(`$ZodCheckStartsWith`,(e,t)=>{F.init(e,t);let n=RegExp(`^${he(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Vt=T(`$ZodCheckEndsWith`,(e,t)=>{F.init(e,t);let n=RegExp(`.*${he(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ht=T(`$ZodCheckOverwrite`,(e,t)=>{F.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Ut=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
5
|
+
`)}catch{}}),e.stdin.on(`end`,()=>{this.#i()}),e.on(`SIGINT`,()=>{this.#i()}),e.on(`SIGTERM`,()=>{this.#i()})}},C=x(y(((e,t)=>{let n=process||{},r=n.argv||[],i=n.env||{},a=!(i.NO_COLOR||r.includes(`--no-color`))&&(!!i.FORCE_COLOR||r.includes(`--color`)||n.platform===`win32`||(n.stdout||{}).isTTY&&i.TERM!==`dumb`||!!i.CI),o=(e,t,n=e)=>r=>{let i=``+r,a=i.indexOf(t,e.length);return~a?e+s(i,t,n,a)+t:e+i+t},s=(e,t,n,r)=>{let i=``,a=0;do i+=e.substring(a,r)+n,a=r+t.length,r=e.indexOf(t,a);while(~r);return i+e.substring(a)},c=(e=a)=>{let t=e?o:()=>String;return{isColorSupported:e,reset:t(`\x1B[0m`,`\x1B[0m`),bold:t(`\x1B[1m`,`\x1B[22m`,`\x1B[22m\x1B[1m`),dim:t(`\x1B[2m`,`\x1B[22m`,`\x1B[22m\x1B[2m`),italic:t(`\x1B[3m`,`\x1B[23m`),underline:t(`\x1B[4m`,`\x1B[24m`),inverse:t(`\x1B[7m`,`\x1B[27m`),hidden:t(`\x1B[8m`,`\x1B[28m`),strikethrough:t(`\x1B[9m`,`\x1B[29m`),black:t(`\x1B[30m`,`\x1B[39m`),red:t(`\x1B[31m`,`\x1B[39m`),green:t(`\x1B[32m`,`\x1B[39m`),yellow:t(`\x1B[33m`,`\x1B[39m`),blue:t(`\x1B[34m`,`\x1B[39m`),magenta:t(`\x1B[35m`,`\x1B[39m`),cyan:t(`\x1B[36m`,`\x1B[39m`),white:t(`\x1B[37m`,`\x1B[39m`),gray:t(`\x1B[90m`,`\x1B[39m`),bgBlack:t(`\x1B[40m`,`\x1B[49m`),bgRed:t(`\x1B[41m`,`\x1B[49m`),bgGreen:t(`\x1B[42m`,`\x1B[49m`),bgYellow:t(`\x1B[43m`,`\x1B[49m`),bgBlue:t(`\x1B[44m`,`\x1B[49m`),bgMagenta:t(`\x1B[45m`,`\x1B[49m`),bgCyan:t(`\x1B[46m`,`\x1B[49m`),bgWhite:t(`\x1B[47m`,`\x1B[49m`),blackBright:t(`\x1B[90m`,`\x1B[39m`),redBright:t(`\x1B[91m`,`\x1B[39m`),greenBright:t(`\x1B[92m`,`\x1B[39m`),yellowBright:t(`\x1B[93m`,`\x1B[39m`),blueBright:t(`\x1B[94m`,`\x1B[39m`),magentaBright:t(`\x1B[95m`,`\x1B[39m`),cyanBright:t(`\x1B[96m`,`\x1B[39m`),whiteBright:t(`\x1B[97m`,`\x1B[39m`),bgBlackBright:t(`\x1B[100m`,`\x1B[49m`),bgRedBright:t(`\x1B[101m`,`\x1B[49m`),bgGreenBright:t(`\x1B[102m`,`\x1B[49m`),bgYellowBright:t(`\x1B[103m`,`\x1B[49m`),bgBlueBright:t(`\x1B[104m`,`\x1B[49m`),bgMagentaBright:t(`\x1B[105m`,`\x1B[49m`),bgCyanBright:t(`\x1B[106m`,`\x1B[49m`),bgWhiteBright:t(`\x1B[107m`,`\x1B[49m`)}};t.exports=c(),t.exports.createColors=c}))(),1),w=class{toJsonSchema(e){throw Error(`toJsonSchema method not implemented`)}};Object.freeze({status:`aborted`});function T(e,t,n){function r(n,r){var i;for(let a in Object.defineProperty(n,`_zod`,{value:n._zod??{},enumerable:!1}),(i=n._zod).traits??(i.traits=new Set),n._zod.traits.add(e),t(n,r),o.prototype)a in n||Object.defineProperty(n,a,{value:o.prototype[a].bind(n)});n._zod.constr=o,n._zod.def=r}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var E=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ne=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};const re={};function D(e){return e&&Object.assign(re,e),re}function ie(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function O(e,t){return typeof t==`bigint`?t.toString():t}function ae(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function k(e){return e==null}function oe(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function se(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}const A=Symbol(`evaluating`);function j(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==A)return r===void 0&&(r=A,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function ce(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function M(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function N(e){return JSON.stringify(e)}const le=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const de=ae(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function fe(e){if(ue(e)===!1)return!1;let t=e.constructor;if(t===void 0)return!0;let n=t.prototype;return!(ue(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function pe(e){return fe(e)?{...e}:Array.isArray(e)?[...e]:e}const me=new Set([`string`,`number`,`symbol`]);function he(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ge(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function P(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function _e(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const ve={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ye(e,t){let n=e._zod.def;return ge(e,M(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return ce(this,`shape`,e),e},checks:[]}))}function be(e,t){let n=e._zod.def;return ge(e,M(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return ce(this,`shape`,r),r},checks:[]}))}function xe(e,t){if(!fe(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0)throw Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");return ge(e,M(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return ce(this,`shape`,n),n},checks:[]}))}function Se(e,t){if(!fe(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ge(e,{...e._zod.def,get shape(){let n={...e._zod.def.shape,...t};return ce(this,`shape`,n),n},checks:e._zod.def.checks})}function Ce(e,t){return ge(e,M(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return ce(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function we(e,t,n){return ge(t,M(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return ce(this,`shape`,i),i},checks:[]}))}function Te(e,t,n){return ge(t,M(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return ce(this,`shape`,i),i},checks:[]}))}function Ee(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function De(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Oe(e){return typeof e==`string`?e:e?.message}function ke(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Oe(e.inst?._zod.def?.error?.(e))??Oe(t?.error?.(e))??Oe(n.customError?.(e))??Oe(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Ae(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function je(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Me=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,O,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Ne=T(`$ZodError`,Me),Pe=T(`$ZodError`,Me,{Parent:Error});function Fe(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ie(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}const Le=e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new E;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>ke(e,a,D())));throw le(t,i?.callee),t}return o.value},Re=e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>ke(e,a,D())));throw le(t,i?.callee),t}return o.value},ze=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new E;return a.issues.length?{success:!1,error:new(e??Ne)(a.issues.map(e=>ke(e,i,D())))}:{success:!0,data:a.value}},Be=ze(Pe),Ve=e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>ke(e,i,D())))}:{success:!0,data:a.value}},He=Ve(Pe),Ue=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Le(e)(t,n,i)},We=e=>(t,n,r)=>Le(e)(t,n,r),Ge=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Re(e)(t,n,i)},Ke=e=>async(t,n,r)=>Re(e)(t,n,r),qe=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return ze(e)(t,n,i)},Je=e=>(t,n,r)=>ze(e)(t,n,r),Ye=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Ve(e)(t,n,i)},Xe=e=>async(t,n,r)=>Ve(e)(t,n,r),Ze=/^[cC][^\s-]{8,}$/,Qe=/^[0-9a-z]+$/,$e=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,et=/^[0-9a-vA-V]{20}$/,tt=/^[A-Za-z0-9]{27}$/,nt=/^[a-zA-Z0-9_-]{21}$/,rt=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,it=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,at=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ot=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function st(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const ct=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,lt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ut=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,dt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ft=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,pt=/^[A-Za-z0-9_-]*$/,mt=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,ht=/^\+(?:[0-9]){6,14}[0-9]$/,gt=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,_t=RegExp(`^${gt}$`);function vt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function yt(e){return RegExp(`^${vt(e)}$`)}function bt(e){let t=vt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${gt}T(?:${r})$`)}const xt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},St=/^-?\d+$/,Ct=/^-?\d+(?:\.\d+)?/,wt=/^(?:true|false)$/i,Tt=/^[^A-Z]*$/,Et=/^[^a-z]*$/,F=T(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Dt={number:`number`,bigint:`bigint`,object:`date`},Ot=T(`$ZodCheckLessThan`,(e,t)=>{F.init(e,t);let n=Dt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),kt=T(`$ZodCheckGreaterThan`,(e,t)=>{F.init(e,t);let n=Dt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),At=T(`$ZodCheckMultipleOf`,(e,t)=>{F.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):se(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),jt=T(`$ZodCheckNumberFormat`,(e,t)=>{F.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ve[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=St)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inst:e})}}),Mt=T(`$ZodCheckMaxLength`,(e,t)=>{var n;F.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!k(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=Ae(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Nt=T(`$ZodCheckMinLength`,(e,t)=>{var n;F.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!k(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=Ae(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Pt=T(`$ZodCheckLengthEquals`,(e,t)=>{var n;F.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!k(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=Ae(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ft=T(`$ZodCheckStringFormat`,(e,t)=>{var n,r;F.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),It=T(`$ZodCheckRegex`,(e,t)=>{Ft.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Lt=T(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Tt,Ft.init(e,t)}),Rt=T(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Et,Ft.init(e,t)}),zt=T(`$ZodCheckIncludes`,(e,t)=>{F.init(e,t);let n=he(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Bt=T(`$ZodCheckStartsWith`,(e,t)=>{F.init(e,t);let n=RegExp(`^${he(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Vt=T(`$ZodCheckEndsWith`,(e,t)=>{F.init(e,t);let n=RegExp(`.*${he(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ht=T(`$ZodCheckOverwrite`,(e,t)=>{F.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Ut=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
6
6
|
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
7
7
|
`))}};const Wt={major:4,minor:1,patch:12},I=T(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Wt;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Ee(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new E;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Ee(e,t))});else{if(e.issues.length===t)continue;r||=Ee(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Ee(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new E;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new E;return o.then(e=>t(e,r,a))}return t(o,r,a)}}e[`~standard`]={validate:t=>{try{let n=Be(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return He(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}}),Gt=T(`$ZodString`,(e,t)=>{I.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??xt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),L=T(`$ZodStringFormat`,(e,t)=>{Ft.init(e,t),Gt.init(e,t)}),Kt=T(`$ZodGUID`,(e,t)=>{t.pattern??=it,L.init(e,t)}),qt=T(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=at(e)}else t.pattern??=at();L.init(e,t)}),Jt=T(`$ZodEmail`,(e,t)=>{t.pattern??=ot,L.init(e,t)}),Yt=T(`$ZodURL`,(e,t)=>{L.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:mt.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Xt=T(`$ZodEmoji`,(e,t)=>{t.pattern??=st(),L.init(e,t)}),Zt=T(`$ZodNanoID`,(e,t)=>{t.pattern??=nt,L.init(e,t)}),Qt=T(`$ZodCUID`,(e,t)=>{t.pattern??=Ze,L.init(e,t)}),$t=T(`$ZodCUID2`,(e,t)=>{t.pattern??=Qe,L.init(e,t)}),en=T(`$ZodULID`,(e,t)=>{t.pattern??=$e,L.init(e,t)}),tn=T(`$ZodXID`,(e,t)=>{t.pattern??=et,L.init(e,t)}),nn=T(`$ZodKSUID`,(e,t)=>{t.pattern??=tt,L.init(e,t)}),rn=T(`$ZodISODateTime`,(e,t)=>{t.pattern??=bt(t),L.init(e,t)}),an=T(`$ZodISODate`,(e,t)=>{t.pattern??=_t,L.init(e,t)}),on=T(`$ZodISOTime`,(e,t)=>{t.pattern??=yt(t),L.init(e,t)}),sn=T(`$ZodISODuration`,(e,t)=>{t.pattern??=rt,L.init(e,t)}),cn=T(`$ZodIPv4`,(e,t)=>{t.pattern??=ct,L.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv4`})}),ln=T(`$ZodIPv6`,(e,t)=>{t.pattern??=lt,L.init(e,t),e._zod.onattach.push(e=>{let t=e._zod.bag;t.format=`ipv6`}),e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),un=T(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ut,L.init(e,t)}),dn=T(`$ZodCIDRv6`,(e,t)=>{t.pattern??=dt,L.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function fn(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const pn=T(`$ZodBase64`,(e,t)=>{t.pattern??=ft,L.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64`}),e._zod.check=n=>{fn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function mn(e){if(!pt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return fn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const hn=T(`$ZodBase64URL`,(e,t)=>{t.pattern??=pt,L.init(e,t),e._zod.onattach.push(e=>{e._zod.bag.contentEncoding=`base64url`}),e._zod.check=n=>{mn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),gn=T(`$ZodE164`,(e,t)=>{t.pattern??=ht,L.init(e,t)});function _n(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}const vn=T(`$ZodJWT`,(e,t)=>{L.init(e,t),e._zod.check=n=>{_n(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),yn=T(`$ZodNumber`,(e,t)=>{I.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ct,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),bn=T(`$ZodNumber`,(e,t)=>{jt.init(e,t),yn.init(e,t)}),xn=T(`$ZodBoolean`,(e,t)=>{I.init(e,t),e._zod.pattern=wt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Sn=T(`$ZodUnknown`,(e,t)=>{I.init(e,t),e._zod.parse=e=>e}),Cn=T(`$ZodNever`,(e,t)=>{I.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function wn(e,t,n){e.issues.length&&t.issues.push(...De(n,e.issues)),t.value[n]=e.value}const Tn=T(`$ZodArray`,(e,t)=>{I.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>wn(t,n,e))):wn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function En(e,t,n,r){e.issues.length&&t.issues.push(...De(n,e.issues)),e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Dn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=_e(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function On(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type;for(let i of Object.keys(t)){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>En(e,n,i,t))):En(a,n,i,t)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const kn=T(`$ZodObject`,(e,t)=>{if(I.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=ae(()=>Dn(t));j(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=ue,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e]._zod.run({value:s[e],issues:[]},o);n instanceof Promise?c.push(n.then(n=>En(n,t,e,s))):En(n,t,e,s)}return i?On(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),An=T(`$ZodObjectJIT`,(e,t)=>{kn.init(e,t);let n=e._zod.parse,r=ae(()=>Dn(t)),i=e=>{let t=new Ut([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=N(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let e of n.keys){let n=a[e],r=N(e);t.write(`const ${n} = ${i(e)};`),t.write(`
|
|
8
8
|
if (${n}.issues.length) {
|
|
@@ -28,50 +28,69 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
28
28
|
`)}return o&&(s=s.trim()),a&&(s=s.replace(/\\n/g,`
|
|
29
29
|
`)),s}}function Ua(e,t){if(typeof e!=`string`||!e.includes(`
|
|
30
30
|
`))return e;let n=t.slice(t.lastIndexOf(`
|
|
31
|
-
`)+1).match(/^(\s+)/);if(n){let t=n[1];return e.replace(/\n/g,`\n${t}`)}return e}var Wa=b(((e,t)=>{((e,n)=>{typeof define==`function`&&define.amd?define([],n):typeof t==`object`&&t.exports?t.exports=n():e.fuzzysort=n()})(e,e=>{var t=(e,t)=>{if(!e||!t)return k;var n=p(e);D(t)||(t=f(t));var r=n.bitflags;return(r&t._bitflags)===r?h(n,t):k},n=(e,t,n)=>{if(!e)return n?.all?m(t,n):ae;var r=p(e),i=r.bitflags,a=r.containsSpace,o=u(n?.threshold||0),c=n?.limit||ie,l=0,d=0,g=t.length;function _(e){l<c?(se.add(e),++l):(++d,e._score>se.peek()._score&&se.replaceTop(e))}if(n?.key)for(var v=n.key,y=0;y<g;++y){var ee=t[y],b=re(ee,v);if(b&&(D(b)||(b=f(b)),(i&b._bitflags)===i)){var x=h(r,b);x!==k&&(x._score<o||(x.obj=ee,_(x)))}}else if(n?.keys){var S=n.keys,te=S.length;outer:for(var y=0;y<g;++y){for(var ee=t[y],C=0,A=0;A<te;++A){var v=S[A],b=re(ee,v);if(!b){E[A]=oe;continue}D(b)||(b=f(b)),E[A]=b,C|=b._bitflags}if((i&C)===i){if(a)for(let e=0;e<r.spaceSearches.length;e++)w[e]=O;for(var A=0;A<te;++A){if(b=E[A],b===oe){ne[A]=oe;continue}if(ne[A]=h(r,b,!1,a),ne[A]===k){ne[A]=oe;continue}if(a)for(let e=0;e<r.spaceSearches.length;e++){if(T[e]>-1e3&&w[e]>O){var j=(w[e]+T[e])/4;j>w[e]&&(w[e]=j)}T[e]>w[e]&&(w[e]=T[e])}}if(a){for(let e=0;e<r.spaceSearches.length;e++)if(w[e]===O)continue outer}else{var ce=!1;for(let e=0;e<te;e++)if(ne[e]._score!==O){ce=!0;break}if(!ce)continue}var M=new s(te);for(let e=0;e<te;e++)M[e]=ne[e];if(a){var N=0;for(let e=0;e<r.spaceSearches.length;e++)N+=w[e]}else{var N=O;for(let e=0;e<te;e++){var x=M[e];if(x._score>-1e3&&N>O){var j=(N+x._score)/4;j>N&&(N=j)}x._score>N&&(N=x._score)}}if(M.obj=ee,M._score=N,n?.scoreFn){if(N=n.scoreFn(M),!N)continue;N=u(N),M._score=N}N<o||_(M)}}}else for(var y=0;y<g;++y){var b=t[y];if(b&&(D(b)||(b=f(b)),(i&b._bitflags)===i)){var x=h(r,b);x!==k&&(x._score<o||_(x))}}if(l===0)return ae;for(var le=Array(l),y=l-1;y>=0;--y)le[y]=se.poll();return le.total=l+d,le},r=(e,t=`<b>`,n=`</b>`)=>{for(var r=typeof t==`function`?t:void 0,i=e.target,a=i.length,o=e.indexes,s=``,c=0,l=0,u=!1,d=[],f=0;f<a;++f){var p=i[f];if(o[l]===f){if(++l,u||(u=!0,r?(d.push(s),s=``):s+=t),l===o.length){r?(s+=p,d.push(r(s,c++)),s=``,d.push(i.substr(f+1))):s+=p+n+i.substr(f+1);break}}else u&&(u=!1,r?(d.push(r(s,c++)),s=``):s+=n);s+=p}return r?d:s},i=e=>{typeof e==`number`?e=``+e:typeof e!=`string`&&(e=``);var t=v(e);return c(e,{_targetLower:t._lower,_targetLowerCodes:t.lowerCodes,_bitflags:t.bitflags})},a=()=>{b.clear(),x.clear()};class o{get indexes(){return this._indexes.slice(0,this._indexes.len).sort((e,t)=>e-t)}set indexes(e){return this._indexes=e}highlight(e,t){return r(this,e,t)}get score(){return l(this._score)}set score(e){this._score=u(e)}}class s extends Array{get score(){return l(this._score)}set score(e){this._score=u(e)}}var c=(e,t)=>{let n=new o;return n.target=e,n.obj=t.obj??k,n._score=t._score??O,n._indexes=t._indexes??[],n._targetLower=t._targetLower??``,n._targetLowerCodes=t._targetLowerCodes??k,n._nextBeginningIndexes=t._nextBeginningIndexes??k,n._bitflags=t._bitflags??0,n},l=e=>e===O?0:e>1?e:Math.E**(((-e+1)**.04307-1)*-2),u=e=>e===0?O:e>1?e:1-(Math.log(e)/-2+1)**(1/.04307),d=e=>{typeof e==`number`?e=``+e:typeof e!=`string`&&(e=``),e=e.trim();var t=v(e),n=[];if(t.containsSpace){var r=e.split(/\s+/);r=[...new Set(r)];for(var i=0;i<r.length;i++)if(r[i]!==``){var a=v(r[i]);n.push({lowerCodes:a.lowerCodes,_lower:r[i].toLowerCase(),containsSpace:!1})}}return{lowerCodes:t.lowerCodes,_lower:t._lower,containsSpace:t.containsSpace,bitflags:t.bitflags,spaceSearches:n}},f=e=>{if(e.length>999)return i(e);var t=b.get(e);return t===void 0?(t=i(e),b.set(e,t),t):t},p=e=>{if(e.length>999)return d(e);var t=x.get(e);return t===void 0?(t=d(e),x.set(e,t),t):t},m=(e,t)=>{var n=[];n.total=e.length;var r=t?.limit||ie;if(t?.key)for(var i=0;i<e.length;i++){var a=e[i],o=re(a,t.key);if(o!=k){D(o)||(o=f(o));var l=c(o.target,{_score:o._score,obj:a});if(n.push(l),n.length>=r)return n}}else if(t?.keys)for(var i=0;i<e.length;i++){for(var a=e[i],u=new s(t.keys.length),d=t.keys.length-1;d>=0;--d){var o=re(a,t.keys[d]);if(!o){u[d]=oe;continue}D(o)||(o=f(o)),o._score=O,o._indexes.len=0,u[d]=o}if(u.obj=a,u._score=O,n.push(u),n.length>=r)return n}else for(var i=0;i<e.length;i++){var o=e[i];if(o!=k&&(D(o)||(o=f(o)),o._score=O,o._indexes.len=0,n.push(o),n.length>=r))return n}return n},h=(e,t,n=!1,r=!1)=>{if(n===!1&&e.containsSpace)return g(e,t,r);for(var i=e._lower,a=e.lowerCodes,s=a[0],c=t._targetLowerCodes,l=a.length,u=c.length,d=0,f=0,p=0;;){var m=s===c[f];if(m){if(S[p++]=f,++d,d===l)break;s=a[d]}if(++f,f>=u)return k}var d=0,h=!1,_=0,v=t._nextBeginningIndexes;v===k&&(v=t._nextBeginningIndexes=ee(t.target)),f=S[0]===0?0:v[S[0]-1];var y=0;if(f!==u)for(;;)if(f>=u){if(d<=0||(++y,y>200))break;--d;var b=te[--_];f=v[b]}else{var m=a[d]===c[f];if(m){if(te[_++]=f,++d,d===l){h=!0;break}++f}else f=v[f]}var x=l<=1?-1:t._targetLower.indexOf(i,S[0]),C=!!~x,w=C?x===0||t._nextBeginningIndexes[x-1]===x:!1;if(C&&!w){for(var T=0;T<v.length;T=v[T])if(!(T<=x)){for(var E=0;E<l&&a[E]===t._targetLowerCodes[T+E];E++);if(E===l){x=T,w=!0;break}}}var ne=e=>{for(var t=0,n=0,r=1;r<l;++r)e[r]-e[r-1]!==1&&(t-=e[r],++n);var i=e[l-1]-e[0]-(l-1);if(t-=(12+i)*n,e[0]!==0&&(t-=e[0]*e[0]*.2),!h)t*=1e3;else{for(var a=1,r=v[0];r<u;r=v[r])++a;a>24&&(t*=(a-24)*10)}return t-=(u-l)/2,C&&(t/=1+l*l*1),w&&(t/=1+l*l*1),t-=(u-l)/2,t};if(h)if(w){for(var T=0;T<l;++T)S[T]=x+T;var re=S,D=ne(S)}else var re=te,D=ne(te);else{if(C)for(var T=0;T<l;++T)S[T]=x+T;var re=S,D=ne(re)}t._score=D;for(var T=0;T<l;++T)t._indexes[T]=re[T];t._indexes.len=l;let ie=new o;return ie.target=t.target,ie._score=t._score,ie._indexes=t._indexes,ie},g=(e,t,n)=>{for(var r=new Set,i=0,a=k,o=0,s=e.spaceSearches,c=s.length,l=0,u=()=>{for(let e=l-1;e>=0;e--)t._nextBeginningIndexes[C[e*2+0]]=C[e*2+1]},d=!1,f=0;f<c;++f){T[f]=O;var p=s[f];if(a=h(p,t),n){if(a===k)continue;d=!0}else if(a===k)return u(),k;if(f!==c-1){var m=a._indexes,g=!0;for(let e=0;e<m.len-1;e++)if(m[e+1]-m[e]!==1){g=!1;break}if(g){var _=m[m.len-1]+1,v=t._nextBeginningIndexes[_-1];for(let e=_-1;e>=0&&v===t._nextBeginningIndexes[e];e--)t._nextBeginningIndexes[e]=_,C[l*2+0]=e,C[l*2+1]=v,l++}}i+=a._score/c,T[f]=a._score/c,a._indexes[0]<o&&(i-=(o-a._indexes[0])*2),o=a._indexes[0];for(var y=0;y<a._indexes.len;++y)r.add(a._indexes[y])}if(n&&!d)return k;u();var ee=h(e,t,!0);if(ee!==k&&ee._score>i){if(n)for(var f=0;f<c;++f)T[f]=ee._score/c;return ee}n&&(a=t),a._score=i;var f=0;for(let e of r)a._indexes[f++]=e;return a._indexes.len=f,a},_=e=>e.replace(/\p{Script=Latin}+/gu,e=>e.normalize(`NFD`)).replace(/[\u0300-\u036f]/g,``),v=e=>{e=_(e);for(var t=e.length,n=e.toLowerCase(),r=[],i=0,a=!1,o=0;o<t;++o){var s=r[o]=n.charCodeAt(o);if(s===32){a=!0;continue}var c=s>=97&&s<=122?s-97:s>=48&&s<=57?26:s<=127?30:31;i|=1<<c}return{lowerCodes:r,bitflags:i,containsSpace:a,_lower:n}},y=e=>{for(var t=e.length,n=[],r=0,i=!1,a=!1,o=0;o<t;++o){var s=e.charCodeAt(o),c=s>=65&&s<=90,l=c||s>=97&&s<=122||s>=48&&s<=57,u=c&&!i||!a||!l;i=c,a=l,u&&(n[r++]=o)}return n},ee=e=>{e=_(e);for(var t=e.length,n=y(e),r=[],i=n[0],a=0,o=0;o<t;++o)i>o?r[o]=i:(i=n[++a],r[o]=i===void 0?t:i);return r},b=new Map,x=new Map,S=[],te=[],C=[],w=[],T=[],E=[],ne=[],re=(e,t)=>{var n=e[t];if(n!==void 0)return n;if(typeof t==`function`)return t(e);var r=t;Array.isArray(t)||(r=t.split(`.`));for(var i=r.length,a=-1;e&&++a<i;)e=e[r[a]];return e},D=e=>typeof e==`object`&&typeof e._bitflags==`number`,ie=1/0,O=-ie,ae=[];ae.total=0;var k=null,oe=i(``),se=(e=>{var t=[],n=0,r={},i=e=>{for(var r=0,i=t[r],a=1;a<n;){var o=a+1;r=a,o<n&&t[o]._score<t[a]._score&&(r=o),t[r-1>>1]=t[r],a=1+(r<<1)}for(var s=r-1>>1;r>0&&i._score<t[s]._score;s=(r=s)-1>>1)t[r]=t[s];t[r]=i};return r.add=(e=>{var r=n;t[n++]=e;for(var i=r-1>>1;r>0&&e._score<t[i]._score;i=(r=i)-1>>1)t[r]=t[i];t[r]=e}),r.poll=(e=>{if(n!==0){var r=t[0];return t[0]=t[--n],i(),r}}),r.peek=(e=>{if(n!==0)return t[0]}),r.replaceTop=(e=>{t[0]=e,i()}),r})();return{single:t,go:n,prepare:i,cleanup:a}})})),Ga=b((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(e,`__esModule`,{value:!0}),e.createJSONRPCNotification=e.createJSONRPCRequest=e.createJSONRPCSuccessResponse=e.createJSONRPCErrorResponse=e.JSONRPCErrorCode=e.JSONRPCErrorException=e.isJSONRPCResponses=e.isJSONRPCResponse=e.isJSONRPCRequests=e.isJSONRPCRequest=e.isJSONRPCID=e.JSONRPC=void 0,e.JSONRPC=`2.0`,e.isJSONRPCID=function(e){return typeof e==`string`||typeof e==`number`||e===null},e.isJSONRPCRequest=function(t){return t.jsonrpc===e.JSONRPC&&t.method!==void 0&&t.result===void 0&&t.error===void 0},e.isJSONRPCRequests=function(t){return Array.isArray(t)&&t.every(e.isJSONRPCRequest)},e.isJSONRPCResponse=function(t){return t.jsonrpc===e.JSONRPC&&t.id!==void 0&&(t.result!==void 0||t.error!==void 0)},e.isJSONRPCResponses=function(t){return Array.isArray(t)&&t.every(e.isJSONRPCResponse)};var n=function(e,t,n){var r={code:e,message:t};return n!=null&&(r.data=n),r};e.JSONRPCErrorException=function(e){t(r,e);function r(t,n,i){var a=e.call(this,t)||this;return Object.setPrototypeOf(a,r.prototype),a.code=n,a.data=i,a}return r.prototype.toObject=function(){return n(this.code,this.message,this.data)},r}(Error),(function(e){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.JSONRPCErrorCode||={}),e.createJSONRPCErrorResponse=function(t,r,i,a){return{jsonrpc:e.JSONRPC,id:t,error:n(r,i,a)}},e.createJSONRPCSuccessResponse=function(t,n){return{jsonrpc:e.JSONRPC,id:t,result:n??null}},e.createJSONRPCRequest=function(t,n,r){return{jsonrpc:e.JSONRPC,id:t,method:n,params:r}},e.createJSONRPCNotification=function(t,n){return{jsonrpc:e.JSONRPC,method:t,params:n}}})),Ka=b((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DefaultErrorCode=void 0,e.DefaultErrorCode=0})),qa=b((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(e,`__esModule`,{value:!0}),e.JSONRPCClient=void 0;var r=Ga(),i=Ka();e.JSONRPCClient=function(){function e(e,t){this._send=e,this.createID=t,this.idToResolveMap=new Map,this.id=0}return e.prototype._createID=function(){return this.createID?this.createID():++this.id},e.prototype.timeout=function(e,t){var n=this;t===void 0&&(t=function(e){return(0,r.createJSONRPCErrorResponse)(e,i.DefaultErrorCode,`Request timeout`)});var o=function(r,i){var a=setTimeout(function(){r.forEach(function(e){var r=n.idToResolveMap.get(e);r&&(n.idToResolveMap.delete(e),r(t(e)))})},e);return i().then(function(e){return clearTimeout(a),e},function(e){return clearTimeout(a),Promise.reject(e)})},s=function(e,t){return o((Array.isArray(e)?e:[e]).map(function(e){return e.id}).filter(a),function(){return n.requestAdvanced(e,t)})};return{request:function(e,t,r){var i=n._createID();return o([i],function(){return n.requestWithID(e,t,r,i)})},requestAdvanced:function(e,t){return s(e,t)}}},e.prototype.request=function(e,t,n){return this.requestWithID(e,t,n,this._createID())},e.prototype.requestWithID=function(e,i,a,o){return t(this,void 0,void 0,function(){var t,s;return n(this,function(n){switch(n.label){case 0:return t=(0,r.createJSONRPCRequest)(o,e,i),[4,this.requestAdvanced(t,a)];case 1:return s=n.sent(),s.result!==void 0&&!s.error?[2,s.result]:s.result===void 0&&s.error?[2,Promise.reject(new r.JSONRPCErrorException(s.error.message,s.error.code,s.error.data))]:[2,Promise.reject(Error(`An unexpected error occurred`))]}})})},e.prototype.requestAdvanced=function(e,t){var n=this,o=Array.isArray(e);Array.isArray(e)||(e=[e]);var s=e.filter(function(e){return a(e.id)}),c=s.map(function(e){return new Promise(function(t){return n.idToResolveMap.set(e.id,t)})}),l=Promise.all(c).then(function(e){return o||!e.length?e:e[0]});return this.send(o?e:e[0],t).then(function(){return l},function(e){return s.forEach(function(t){n.receive((0,r.createJSONRPCErrorResponse)(t.id,i.DefaultErrorCode,e&&e.message||`Failed to send a request`))}),l})},e.prototype.notify=function(e,t,n){var i=(0,r.createJSONRPCNotification)(e,t);this.send(i,n).then(void 0,function(){})},e.prototype.send=function(e,r){return t(this,void 0,void 0,function(){return n(this,function(t){return[2,this._send(e,r)]})})},e.prototype.rejectAllPendingRequests=function(e){this.idToResolveMap.forEach(function(t,n){return t((0,r.createJSONRPCErrorResponse)(n,i.DefaultErrorCode,e))}),this.idToResolveMap.clear()},e.prototype.receive=function(e){var t=this;Array.isArray(e)||(e=[e]),e.forEach(function(e){var n=t.idToResolveMap.get(e.id);n&&(t.idToResolveMap.delete(e.id),n(e))})},e}();var a=function(e){return e!=null}})),Ja=b((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),Ya=b((e=>{var t=e&&e.__assign||function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)},n=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},r=e&&e.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},i=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,`__esModule`,{value:!0}),e.JSONRPCServer=void 0;var a=Ga(),o=Ka(),s=function(){return(0,a.createJSONRPCErrorResponse)(null,a.JSONRPCErrorCode.ParseError,`Parse error`)},c=function(e){return(0,a.createJSONRPCErrorResponse)((0,a.isJSONRPCID)(e.id)?e.id:null,a.JSONRPCErrorCode.InvalidRequest,`Invalid Request`)},l=function(e){return(0,a.createJSONRPCErrorResponse)(e,a.JSONRPCErrorCode.MethodNotFound,`Method not found`)};e.JSONRPCServer=function(){function e(e){e===void 0&&(e={}),this.mapErrorToJSONRPCErrorResponse=p,this.nameToMethodDictionary={},this.middleware=null,this.errorListener=e.errorListener??console.warn}return e.prototype.hasMethod=function(e){return!!this.nameToMethodDictionary[e]},e.prototype.addMethod=function(e,t){this.addMethodAdvanced(e,this.toJSONRPCMethod(t))},e.prototype.removeMethod=function(e){delete this.nameToMethodDictionary[e]},e.prototype.toJSONRPCMethod=function(e){return function(t,n){var r=e(t.params,n);return Promise.resolve(r).then(function(e){return f(t.id,e)})}},e.prototype.addMethodAdvanced=function(e,n){var r;this.nameToMethodDictionary=t(t({},this.nameToMethodDictionary),(r={},r[e]=n,r))},e.prototype.receiveJSON=function(e,t){var n=this.tryParseRequestJSON(e);return n?this.receive(n,t):Promise.resolve(s())},e.prototype.tryParseRequestJSON=function(e){try{return JSON.parse(e)}catch{return null}},e.prototype.receive=function(e,t){return Array.isArray(e)?this.receiveMultiple(e,t):this.receiveSingle(e,t)},e.prototype.receiveMultiple=function(e,t){return n(this,void 0,void 0,function(){var n,i=this;return r(this,function(r){switch(r.label){case 0:return[4,Promise.all(e.map(function(e){return i.receiveSingle(e,t)}))];case 1:return n=r.sent().filter(u),n.length===1?[2,n[0]]:n.length?[2,n]:[2,null]}})})},e.prototype.receiveSingle=function(e,t){return n(this,void 0,void 0,function(){var n,i;return r(this,function(r){switch(r.label){case 0:return n=this.nameToMethodDictionary[e.method],(0,a.isJSONRPCRequest)(e)?[3,1]:[2,c(e)];case 1:return[4,this.callMethod(n,e,t)];case 2:return i=r.sent(),[2,m(e,i)]}})})},e.prototype.applyMiddleware=function(){var e=[...arguments];this.middleware?this.middleware=this.combineMiddlewares(i([this.middleware],e,!0)):this.middleware=this.combineMiddlewares(e)},e.prototype.combineMiddlewares=function(e){return e.length?e.reduce(this.middlewareReducer):null},e.prototype.middlewareReducer=function(e,t){return function(n,r,i){return e(function(e,r){return t(n,e,r)},r,i)}},e.prototype.callMethod=function(e,t,n){var r=this,i=function(t,n){return e?e(t,n):t.id===void 0?Promise.resolve(null):Promise.resolve(l(t.id))},a=function(e){return r.errorListener(`An unexpected error occurred while executing "${t.method}" JSON-RPC method:`,e),Promise.resolve(r.mapErrorToJSONRPCErrorResponseIfNecessary(t.id,e))};try{return(this.middleware||d)(i,t,n).then(void 0,a)}catch(e){return a(e)}},e.prototype.mapErrorToJSONRPCErrorResponseIfNecessary=function(e,t){return e===void 0?null:this.mapErrorToJSONRPCErrorResponse(e,t)},e}();var u=function(e){return e!==null},d=function(e,t,n){return e(t,n)},f=function(e,t){return e===void 0?null:(0,a.createJSONRPCSuccessResponse)(e,t)},p=function(e,t){var n=t?.message??`An unexpected error occurred`,r=o.DefaultErrorCode,i;return t instanceof a.JSONRPCErrorException&&(r=t.code,i=t.data),(0,a.createJSONRPCErrorResponse)(e,r,n,i)},m=function(e,t){return t||(e.id===void 0?null:(0,a.createJSONRPCErrorResponse)(e.id,a.JSONRPCErrorCode.InternalError,`Internal error`))}})),Xa=b((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(e,`__esModule`,{value:!0}),e.JSONRPCServerAndClient=void 0;var r=Ga();e.JSONRPCServerAndClient=function(){function e(e,t,n){n===void 0&&(n={}),this.server=e,this.client=t,this.errorListener=n.errorListener??console.warn}return e.prototype.applyServerMiddleware=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this.server).applyMiddleware.apply(e,t)},e.prototype.hasMethod=function(e){return this.server.hasMethod(e)},e.prototype.addMethod=function(e,t){this.server.addMethod(e,t)},e.prototype.addMethodAdvanced=function(e,t){this.server.addMethodAdvanced(e,t)},e.prototype.removeMethod=function(e){this.server.removeMethod(e)},e.prototype.timeout=function(e){return this.client.timeout(e)},e.prototype.request=function(e,t,n){return this.client.request(e,t,n)},e.prototype.requestAdvanced=function(e,t){return this.client.requestAdvanced(e,t)},e.prototype.notify=function(e,t,n){this.client.notify(e,t,n)},e.prototype.rejectAllPendingRequests=function(e){this.client.rejectAllPendingRequests(e)},e.prototype.receiveAndSend=function(e,i,a){return t(this,void 0,void 0,function(){var t,o;return n(this,function(n){switch(n.label){case 0:return(0,r.isJSONRPCResponse)(e)||(0,r.isJSONRPCResponses)(e)?(this.client.receive(e),[3,4]):[3,1];case 1:return(0,r.isJSONRPCRequest)(e)||(0,r.isJSONRPCRequests)(e)?[4,this.server.receive(e,i)]:[3,3];case 2:return t=n.sent(),t?[2,this.client.send(t,a)]:[3,4];case 3:return o=`Received an invalid JSON-RPC message`,this.errorListener(o,e),[2,Promise.reject(Error(o))];case 4:return[2]}})})},e}()})),Za=b((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(qa(),e),n(Ja(),e),n(Ga(),e),n(Ya(),e),n(Xa(),e)}));function Qa(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`{`){n&&=(t.push({type:`literal`,value:n}),``);let i=r+1,a=i,o=1;for(;a<e.length&&o>0;)e[a]===`{`?o++:e[a]===`}`&&o--,a++;if(o>0)throw Error(`Unclosed expression in template: ${e}`);let s=$a(e.slice(i,a-1));t.push(s),r=a}else n+=i,r++}return n&&t.push({type:`literal`,value:n}),{template:e,parts:t}}function $a(e){if(!e.trim())throw Error(`Empty expression`);let t=e[0],n=[`+`,`#`,`.`,`/`,`;`,`?`,`&`],r,i=e;return n.includes(t)&&(r=t,i=e.slice(1)),{type:`expression`,expressions:eo(i).map(to),operator:r}}function eo(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];i===`,`?n.trim()&&(t.push(n.trim()),n=``):n+=i,r++}return n.trim()&&t.push(n.trim()),t}function to(e){let t=e,n,r=!1;t.endsWith(`*`)&&(r=!0,t=t.slice(0,-1));let i=t.indexOf(`:`);if(i!==-1){let e=t.slice(i+1);if(n=parseInt(e,10),isNaN(n)||n<0)throw Error(`Invalid prefix length: ${e}`);t=t.slice(0,i)}if(!t)throw Error(`Empty variable name`);return{name:t,prefix:n,explode:r}}function no(e,t){let n={},r=ro(e,0,t.parts,0,n);return!r||r.uri_index!==e.length?null:n}function ro(e,t,n,r,i){if(r>=n.length)return{uri_index:t};let a=n[r];if(a.type===`literal`)return e.slice(t).startsWith(a.value)?ro(e,t+a.value.length,n,r+1,i):null;{let o=n[r+1],s=io(e,t,o).sort((e,t)=>o&&o.type===`expression`&&!o.operator?t-e:e-t);for(let o of s){let s=e.slice(t,o),c={...i};if(ao(s,a,c,e,t)){let t=ro(e,o,n,r+1,c);if(t)return Object.assign(i,c),t}}return null}}function io(e,t,n){let r=[];if(n&&n.type===`literal`){let i=t;for(;i<e.length;){let t=e.indexOf(n.value,i);if(t===-1)break;r.push(t),i=t+1}if(r.length===0)return[]}else if(n&&n.type===`expression`){let i=n;if(i.operator===`.`){for(let n=t;n<e.length;n++)e[n]===`.`&&r.push(n);r.push(e.length)}else if(i.operator===`/`)for(let n=t;n<e.length;n++)e[n]===`/`&&r.push(n);else for(let n=t;n<=e.length;n++)r.push(n)}else r.push(e.length);return r.sort((e,t)=>e-t)}function ao(e,t,n,r,i){if(t.type!==`expression`)return!1;switch(t.operator){case`+`:return so(e,t,n);case`#`:return oo(e,t,n);case`.`:return lo(e,t,n);case`/`:return uo(e,t,n);case`;`:return fo(e,t,n);case`?`:case`&`:return po(e,t,n);default:return co(e,t,n,r,i)}}function oo(e,t,n){if(t.type!==`expression`)return!1;if(!e.startsWith(`#`)){for(let e of t.expressions)n[e.name]=``;return e===``}let r=e.slice(1);if(t.expressions.length===1){let e=t.expressions[0],i=r;return e.prefix&&i.length>e.prefix&&(i=i.slice(0,e.prefix)),n[e.name]=decodeURIComponent(i),!0}else{let e=r.split(`,`);for(let r=0;r<t.expressions.length;r++){let i=t.expressions[r],a=e[r]||``;i.prefix&&a.length>i.prefix&&(a=a.slice(0,i.prefix)),n[i.name]=decodeURIComponent(a)}return!0}}function so(e,t,n){if(t.type!==`expression`)return!1;if(t.expressions.length===1){let r=t.expressions[0],i=e;return r.prefix&&i.length>r.prefix&&(i=i.slice(0,r.prefix)),n[r.name]=decodeURIComponent(i),!0}else{let r=e.split(`,`);for(let e=0;e<t.expressions.length;e++){let i=t.expressions[e],a=r[e]||``;i.prefix&&a.length>i.prefix&&(a=a.slice(0,i.prefix)),n[i.name]=decodeURIComponent(a)}return!0}}function co(e,t,n,r,i){if(t.type!==`expression`)return!1;if(t.expressions.length===1){let a=t.expressions[0],o=e;return o.includes(`/`)||o===``&&i+e.length===r.length&&r.endsWith(`/`)?!1:(a.prefix&&o.length>a.prefix&&(o=o.slice(0,a.prefix)),n[a.name]=decodeURIComponent(o),!0)}else{let r=e.split(`,`);for(let e=0;e<t.expressions.length;e++){let i=t.expressions[e],a=r[e]||``;if(a.includes(`/`))return!1;i.prefix&&a.length>i.prefix&&(a=a.slice(0,i.prefix)),n[i.name]=decodeURIComponent(a)}return!0}}function lo(e,t,n){if(t.type!==`expression`)return!1;if(e===``){for(let e of t.expressions)n[e.name]=``;return!0}let r=e.startsWith(`.`)?e.slice(1):e;if(t.expressions.length===1){let e=t.expressions[0];if(e.explode){let t=r.split(`.`);n[e.name]=t.map(e=>decodeURIComponent(e))}else n[e.name]=decodeURIComponent(r);return!0}else{let e=r.split(`.`);for(let r=0;r<t.expressions.length;r++){let i=t.expressions[r],a=e[r]||``;i.prefix&&a.length>i.prefix&&(a=a.slice(0,i.prefix)),n[i.name]=decodeURIComponent(a)}return!0}}function uo(e,t,n){if(t.type!==`expression`)return!1;let r=e.startsWith(`/`)?e.slice(1):e;if(t.expressions.length===1){let e=t.expressions[0];return n[e.name]=decodeURIComponent(r),!0}else{let e=r.split(`,`);for(let r=0;r<t.expressions.length;r++){let i=t.expressions[r],a=e[r]||``;i.prefix&&a.length>i.prefix&&(a=a.slice(0,i.prefix)),n[i.name]=decodeURIComponent(a)}return!0}}function fo(e,t,n){if(t.type!==`expression`)return!1;let r=e.split(`;`).filter(e=>e);for(let e of r){let r=e.indexOf(`=`);if(r!==-1){let i=e.slice(0,r),a=e.slice(r+1),o=t.expressions.find(e=>e.name===i);o&&(n[o.name]=decodeURIComponent(a))}}return!0}function po(e,t,n){if(t.type!==`expression`)return!1;let r=e.replace(/^[?&]/,``);if(t.expressions.length===1){let e=t.expressions[0];if(e.explode){let t=r.split(`&`);n[e.name]=t.map(e=>decodeURIComponent(e))}else{let t=r.split(`&`);for(let r of t){let t=r.indexOf(`=`);if(t!==-1){let i=r.slice(0,t),a=r.slice(t+1);i===e.name&&(n[e.name]=decodeURIComponent(a))}}}}else{let e=r.split(`&`);for(let r of e){let e=r.indexOf(`=`);if(e!==-1){let i=r.slice(0,e),a=r.slice(e+1),o=t.expressions.find(e=>e.name===i);o&&(n[o.name]=decodeURIComponent(a))}}}return!0}var mo=class{constructor(){this.templates=[]}add(e){if(typeof e!=`string`)throw Error(`Template must be a string`);if(e!==``&&e.trim()===``)throw Error(`Template cannot be empty`);try{let t=Qa(e);this.templates.push(t)}catch(t){throw Error(`Invalid template: ${e} - ${t instanceof Error?t.message:String(t)}`)}}match(e){if(typeof e!=`string`)throw Error(`URI must be a string`);for(let t of this.templates){let n=no(e,t);if(n!==null)return{template:t.template,params:n}}return null}clear(){this.templates=[]}all(){return this.templates.map(e=>e.template)}},ho=S(Za(),1),go=S(Wa(),1),_o;function vo(e){return{lang:e?.lang??_o?.lang,message:e?.message,abortEarly:e?.abortEarly??_o?.abortEarly,abortPipeEarly:e?.abortPipeEarly??_o?.abortPipeEarly}}var yo;function bo(e){return yo?.get(e)}var xo;function So(e){return xo?.get(e)}var Co;function wo(e,t){return Co?.get(e)?.get(t)}function To(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function H(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??To(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??wo(e.reference,c.lang)??(l?So(c.lang):null)??r.message??bo(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function U(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},vo())}}}function Eo(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function Do(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var Oo=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}},ko=/^(?:[\da-z+/]{4})*(?:[\da-z+/]{2}==|[\da-z+/]{3}=)?$/iu;function Ao(e){return{kind:`validation`,type:`base64`,reference:Ao,async:!1,expects:null,requirement:ko,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&H(this,`Base64`,e,t),e}}}function jo(e,t){return{kind:`validation`,type:`check`,reference:jo,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&H(this,`input`,e,t),e}}}function Mo(e){return{kind:`validation`,type:`integer`,reference:Mo,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&H(this,`integer`,e,t),e}}}function No(e,t){return{kind:`validation`,type:`max_length`,reference:No,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&H(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function Po(e,t){return{kind:`validation`,type:`max_value`,reference:Po,async:!1,expects:`<=${e instanceof Date?e.toJSON():To(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&H(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():To(e.value)}),e}}}function Fo(e,t){return{kind:`validation`,type:`min_value`,reference:Fo,async:!1,expects:`>=${e instanceof Date?e.toJSON():To(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&H(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():To(e.value)}),e}}}function Io(e,t){return{kind:`validation`,type:`regex`,reference:Io,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&H(this,`format`,e,t),e}}}function Lo(e,t){return{kind:`validation`,type:`starts_with`,reference:Lo,async:!1,expects:`"${e}"`,requirement:e,message:t,"~run"(e,t){return e.typed&&!e.value.startsWith(this.requirement)&&H(this,`start`,e,t,{received:`"${e.value.slice(0,this.requirement.length)}"`}),e}}}function Ro(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function zo(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Bo(e,t){return{kind:`schema`,type:`array`,reference:Bo,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else H(this,`type`,e,t);return e}}}function Vo(e){return{kind:`schema`,type:`boolean`,reference:Vo,expects:`boolean`,async:!1,message:e,get"~standard"(){return U(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:H(this,`type`,e,t),e}}}function Ho(e,t){return{kind:`schema`,type:`literal`,reference:Ho,expects:To(e),async:!1,literal:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:H(this,`type`,e,t),e}}}function W(e,t){return{kind:`schema`,type:`loose_object`,reference:W,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:zo(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Ro(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(H(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly)for(let t in n)Eo(n,t)&&!(t in this.entries)&&(e.value[t]=n[t])}else H(this,`type`,e,t);return e}}}function G(e){return{kind:`schema`,type:`number`,reference:G,expects:`number`,async:!1,message:e,get"~standard"(){return U(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:H(this,`type`,e,t),e}}}function K(e,t){return{kind:`schema`,type:`object`,reference:K,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`)for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:zo(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Ro(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(H(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}else H(this,`type`,e,t);return e}}}function q(e,t){return{kind:`schema`,type:`optional`,reference:q,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return U(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=zo(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function Uo(e,t){return{kind:`schema`,type:`picklist`,reference:Uo,expects:Do(e.map(To),`|`),async:!1,options:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:H(this,`type`,e,t),e}}}function Wo(e,t,n){return{kind:`schema`,type:`record`,reference:Wo,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(Eo(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else H(this,`type`,e,t);return e}}}function Go(e,t){return{kind:`schema`,type:`strict_object`,reference:Go,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:zo(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Ro(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(H(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly){for(let r in n)if(!(r in this.entries)){H(this,`key`,e,t,{input:r,expected:`never`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]});break}}}else H(this,`type`,e,t);return e}}}function J(e){return{kind:`schema`,type:`string`,reference:J,expects:`string`,async:!1,message:e,get"~standard"(){return U(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:H(this,`type`,e,t),e}}}function Ko(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function qo(e,t){return{kind:`schema`,type:`union`,reference:qo,expects:Do(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){let n,r,i;for(let a of this.options){let o=a[`~run`]({value:e.value},t);if(o.typed)if(o.issues)r?r.push(o):r=[o];else{n=o;break}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];H(this,`type`,e,t,{issues:Ko(r)}),e.typed=!0}else if(i?.length===1)return i[0];else H(this,`type`,e,t,{issues:Ko(i)});return e}}}function Jo(){return{kind:`schema`,type:`unknown`,reference:Jo,expects:`unknown`,async:!1,get"~standard"(){return U(this)},"~run"(e){return e.typed=!0,e}}}function Yo(e,t,n){return{kind:`schema`,type:`variant`,reference:Yo,expects:`Object`,async:!1,key:e,options:t,message:n,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){let r,i=0,a=this.key,o=[],s=(e,c)=>{for(let l of e.options){if(l.type===`variant`)s(l,new Set(c).add(l.key));else{let e=!0,s=0;for(let t of c){let r=l.entries[t];if(t in n?r[`~run`]({typed:!1,value:n[t]},{abortEarly:!0}).issues:r.type!==`exact_optional`&&r.type!==`optional`&&r.type!==`nullish`){e=!1,a!==t&&(i<s||i===s&&t in n&&!(a in n))&&(i=s,a=t,o=[]),a===t&&o.push(l.entries[t].expects);break}s++}if(e){let e=l[`~run`]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(s(this,new Set([this.key])),r)return r;H(this,`type`,e,t,{input:n[a],expected:Do(o,`|`),path:[{type:`object`,origin:`value`,input:n,key:a,value:n[a]}]})}else H(this,`type`,e,t);return e}}}function Xo(e,t,n){let r=e[`~run`]({value:t},vo(n));if(r.issues)throw new Oo(r.issues);return r.value}function Y(...e){return{...e[0],pipe:e,get"~standard"(){return U(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function Zo(e,t,n){let r=e[`~run`]({value:t},vo(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var X=class extends Error{constructor(e,t){super(`MCP error ${e}: ${t}`),this.name=`McpError`}};const Qo=qo([J(),Y(G(),Mo())]),$o=J(),Z=W({_meta:q(W({progressToken:q(Qo)}))}),Q=K({method:J(),params:q(Z)}),es=W({_meta:q(W({}))}),ts=K({method:J(),params:q(es)}),$=W({_meta:q(W({}))}),ns=qo([J(),Y(G(),Mo())]),rs=K({jsonrpc:Ho(`2.0`),id:ns,...Q.entries}),is=K({jsonrpc:Ho(`2.0`),...ts.entries}),as=Go({jsonrpc:Ho(`2.0`),id:ns,result:$}),os=Go({jsonrpc:Ho(`2.0`),id:ns,error:K({code:Y(G(),Mo()),message:J(),data:q(Jo())})});({...$.entries}),{...ts.entries},{...es.entries};const ss=K({name:J(),title:q(J())}),cs=K({icons:q(Bo(K({src:J(),mimeType:q(J()),sizes:q(Bo(J()))})))}),ls=K({...ss.entries,version:J(),websiteUrl:q(J()),...cs.entries}),us=K({experimental:q(K({})),sampling:q(K({})),elicitation:q(K({})),roots:q(K({listChanged:q(Vo())}))}),ds=K({...Z.entries,protocolVersion:J(),capabilities:us,clientInfo:ls});({...Q.entries}),{...$.entries},{...ts.entries},{...Q.entries};const fs=K({progress:G(),total:q(G()),message:q(J())});({...ts.entries}),{...es.entries,...fs.entries};const ps=K({...Q.entries,params:q(K({...Z.entries,cursor:q($o)}))}),ms=K({...$.entries,nextCursor:q($o)}),hs=K({uri:J(),mimeType:q(J()),_meta:q(W({}))}),gs=K({...hs.entries,text:J()}),_s=K({...hs.entries,blob:Y(J(),Ao())}),vs=K({...ss.entries,uri:J(),description:q(J()),mimeType:q(J()),_meta:q(W({})),...cs.entries});({...ss.entries}),{...cs.entries},{...ps.entries},{...ms.entries},{...ps.entries},{...ms.entries},{...Q.entries},{...Z.entries};const ys=K({...$.entries,contents:Bo(qo([gs,_s]))});({...ts.entries}),{...Q.entries},{...Z.entries},{...Q.entries},{...Z.entries},{...ts.entries},{...es.entries},{...ss.entries},{...cs.entries},{...ps.entries},{...ms.entries},{...Q.entries},{...Z.entries};const bs=K({type:Ho(`text`),text:J(),_meta:q(W({}))}),xs=K({type:Ho(`image`),data:Y(J(),Ao()),mimeType:J(),_meta:q(W({}))}),Ss=K({type:Ho(`audio`),data:Y(J(),Ao()),mimeType:J(),_meta:q(W({}))}),Cs=K({type:Ho(`resource`),resource:qo([gs,_s]),_meta:q(W({}))}),ws=qo([bs,xs,Ss,K({...vs.entries,type:Ho(`resource_link`)}),Cs]),Ts=K({role:Uo([`user`,`assistant`]),content:ws}),Es=K({...$.entries,description:q(J()),messages:Bo(Ts)});({...ts.entries}),{...ss.entries},{...cs.entries},{...ps.entries},{...ms.entries};const Ds=K({...$.entries,content:q(Bo(ws),[]),structuredContent:q(W({})),isError:q(Vo())});({...$.entries}),{...Q.entries},{...Z.entries},{...ts.entries},{...Q.entries},{...Z.entries},{...ts.entries},{...es.entries};const Os=K({hints:q(Bo(K({name:q(J())}))),costPriority:q(Y(G(),Fo(0),Po(1))),speedPriority:q(Y(G(),Fo(0),Po(1))),intelligencePriority:q(Y(G(),Fo(0),Po(1)))}),ks=K({role:Uo([`user`,`assistant`]),content:qo([bs,xs,Ss])}),As=K({...Z.entries,messages:Bo(ks),systemPrompt:q(J()),includeContext:q(Uo([`none`,`thisServer`,`allServers`])),temperature:q(G()),maxTokens:Y(G(),Mo()),stopSequences:q(Bo(J())),metadata:q(K({})),modelPreferences:q(Os)});({...Q.entries});const js=K({...$.entries,model:J(),stopReason:q(qo([Uo([`endTurn`,`stopSequence`,`maxTokens`]),J()])),role:Uo([`user`,`assistant`]),content:Yo(`type`,[bs,xs,Ss])});({...Q.entries}),{...Z.entries};const Ms=K({...$.entries,action:Uo([`accept`,`decline`,`cancel`]),content:q(Wo(J(),Jo()))});({...Q.entries}),{...Z.entries};const Ns=K({...$.entries,completion:K({values:Y(Bo(J()),No(100)),total:q(Y(G(),Mo())),hasMore:q(Vo())})});({...Q.entries}),{...$.entries},{...ts.entries};const Ps=[`2025-06-18`,`2025-03-26`,`2024-11-05`],Fs=Ps[0];function Is(e){return Ps.includes(e)}function Ls(){return Fs}function Rs(){return[...Ps]}function zs(e){return Is(e)?e:Ls()}function Bs(e){try{let t=new Date(e);return!/^\d{4}-\d{2}-\d{2}$/.test(e)||isNaN(t.getTime())}catch{return!0}}let Vs;async function Hs(){return Vs||=new(await(import(`./sqids-BjCHarkR.js`))).default,Vs}async function Us(e){return(await Hs()).encode([e])}async function Ws(e){let[t]=(await Hs()).decode(e);return t}async function Gs(e){try{return await e()}catch{return!1}}var Ks=class{#e=new ho.JSONRPCServer;#t;#n;#r=new Map;#i=new Map;#a=new Map;#o=new mo;roots=[];#s={"ref/prompt":new Map,"ref/resource":new Map};#c=new EventTarget;#l=new m;constructor(e,t){this.#n=t,this.#e.addMethod(`initialize`,n=>{try{let r=Xo(ds,n);if(Bs(r.protocolVersion))throw new X(-32602,`Invalid protocol version format`);let i=zs(r.protocolVersion);return this.#c.dispatchEvent(new CustomEvent(`initialize`,{detail:r})),{protocolVersion:i,...t,serverInfo:e}}catch(e){throw e instanceof X?e:e.message?.includes(`Protocol version`)?new X(-32602,`Protocol version validation failed: ${e.message}. Server supports: ${Rs().join(`, `)}`):new X(-32603,`Initialization failed: ${e.message}`)}}),this.#e.addMethod(`ping`,()=>({})),this.#e.addMethod(`notifications/initialized`,()=>null),this.#m(),this.#h(),this.#g(),this.#_(),this.#y(),this.#b()}withContext(){return this}get#u(){return this.#l.getStore()?.progress_token}get ctx(){let{progress_token:e,...t}=this.#l.getStore()??{};return t}get#d(){return this.#l.getStore()?.sessionInfo?.clientCapabilities}currentClientInfo(){return this.#l.getStore()?.sessionInfo?.clientInfo}currentClientCapabilities(){return this.#d}#f(){this.#t||=new ho.JSONRPCClient((e,t)=>{if(t===`broadcast`){this.#c.dispatchEvent(new CustomEvent(`broadcast`,{detail:{request:e}}));return}this.#c.dispatchEvent(new CustomEvent(`send`,{detail:{request:e}}))})}on(e,t,n){(e===`send`||e===`broadcast`)&&this.#f();let r=e=>{t(e.detail)};return this.#c.addEventListener(e,r,n),()=>{this.#c.removeEventListener(e,r,n)}}#p(e,t,n=`standalone`){this.#t?.notify(e,t,n)}#m(){this.#n.capabilities?.tools&&(this.#e.addMethod(`tools/list`,async()=>({tools:(await Promise.all([...this.#r].map(async([e,t])=>t.enabled!=null&&await Gs(t.enabled)===!1?null:{name:e,title:t.title||t.description,description:t.description,icons:t.icons,_meta:t._meta,inputSchema:t.schema&&this.#n.adapter?await this.#n.adapter.toJsonSchema(t.schema):{type:`object`,properties:{}},...t.outputSchema&&this.#n.adapter?{outputSchema:await this.#n.adapter.toJsonSchema(t.outputSchema)}:{},...t.annotations?{annotations:t.annotations}:{}}))).filter(e=>e!==null)})),this.#e.addMethod(`tools/call`,async({name:e,arguments:t})=>{let n=this.#r.get(e);if(!n)return{isError:!0,content:[{type:`text`,text:`Tool ${e} not found`}]};let r=t;if(n.schema){let i=n.schema[`~standard`].validate(t);if(i instanceof Promise&&(i=await i),i.issues)return{isError:!0,content:[{type:`text`,text:`Invalid arguments for tool ${e}: ${JSON.stringify(i.issues)}`}]};r=i.value}let i=Xo(Ds,n.schema?await n.execute(r):await n.execute());if(n.outputSchema&&i.structuredContent!==void 0){let t=n.outputSchema[`~standard`].validate(i.structuredContent);if(t instanceof Promise&&(t=await t),t.issues)return{isError:!0,content:[{type:`text`,text:`Tool ${e} returned invalid structured content: ${JSON.stringify(t.issues)}`}]};i.structuredContent=t.value}return i}))}#h(){this.#n.capabilities?.prompts&&(this.#e.addMethod(`prompts/list`,async({cursor:e}={})=>{let t=(await Promise.all([...this.#i].map(async([e,t])=>{if(t.enabled!=null&&await Gs(t.enabled)===!1)return null;let n=t.schema&&this.#n.adapter?await this.#n.adapter.toJsonSchema(t.schema):{type:`object`,properties:{},required:[]},r=Object.keys(n.properties??{}),i=n.required??[];return{name:e,title:t.title||t.description,icons:t.icons,description:t.description,arguments:r.map(e=>{let t=n.properties?.[e],r=t&&t!==!0?t.description:e;return{name:e,required:i.includes(e),description:r}})}}))).filter(e=>e!==null),n=this.#n.pagination?.prompts;if(!n||n.size==null)return{prompts:t};let r=n.size,i=e?await Ws(e):0,a=i+r,o=t.slice(i,a),s=a<t.length?await Us(a):null;return{prompts:o,...s&&{nextCursor:s}}}),this.#e.addMethod(`prompts/get`,async({name:e,arguments:t})=>{let n=this.#i.get(e);if(!n)throw new X(-32601,`Prompt ${e} not found`);if(!n.schema)return Xo(Es,await n.execute());let r=n.schema[`~standard`].validate(t);if(r instanceof Promise&&(r=await r),r.issues)throw new X(-32602,`Invalid arguments for prompt ${e}: ${JSON.stringify(r.issues)}`);return Xo(Es,await n.execute(r.value))}))}#g(){this.#n.capabilities?.resources&&(this.#n.capabilities?.resources?.subscribe&&this.#e.addMethod(`resources/subscribe`,async({uri:e})=>(this.#c.dispatchEvent(new CustomEvent(`subscription`,{detail:{uri:e}})),{})),this.#e.addMethod(`resources/list`,async({cursor:e}={})=>{let t=[];for(let[e,{description:n,name:r,title:i,icons:a,...o}]of this.#a)if(o.template){if(o.list_resources){if(o.enabled!=null&&await Gs(o.enabled)===!1)continue;let e=await o.list_resources();t.push(...e)}}else{if(o.enabled!=null&&await Gs(o.enabled)===!1)continue;t.push({name:r,title:i||n,description:n,uri:e,icons:a})}let n=this.#n.pagination?.resources;if(!n||n.size==null)return{resources:t};let r=n.size,i=e?await Ws(e):0,a=i+r,o=t.slice(i,a),s=a<t.length?await Us(a):null;return{resources:o,...s&&{nextCursor:s}}}),this.#e.addMethod(`resources/templates/list`,async()=>({resourceTemplates:(await Promise.all([...this.#a].map(async([e,{description:t,name:n,title:r,template:i,icons:a,enabled:o}])=>!i||o!=null&&await Gs(o)===!1?null:{name:n,icons:a,title:r||t,description:t,uriTemplate:e}))).filter(e=>e!=null)})),this.#e.addMethod(`resources/read`,async({uri:e})=>{let t=this.#a.get(e),n;if(!t){let r=this.#o.match(e);if(r&&(t=this.#a.get(r.template),n=r.params),!t)throw new X(-32601,`Resource ${e} not found`)}if(t.template){if(!n)throw new X(-32602,`Missing parameters for template resource`);return Xo(ys,await t.execute(e,n))}return Xo(ys,await t.execute(e))}))}#_(){this.#e.addMethod(`notifications/roots/list_changed`,()=>(this.#v(),null))}async#v(){if(this.#d?.roots){this.#f();try{this.roots=(await this.#t?.request(`roots/list`,void 0,`standalone`))?.roots||[]}catch{this.roots=[]}}}#y(){this.#e.addMethod(`completion/complete`,async({argument:e,ref:t,context:n})=>{let r=this.#s[t.type];if(!r)return null;let i=r.get(t.uri??t.name);if(!i)return null;let a=i[e.name];return a?Xo(Ns,await a(e.value,n)):null})}#b(){this.#n.capabilities?.logging&&this.#e.addMethod(`logging/setLevel`,({level:e})=>(this.#c.dispatchEvent(new CustomEvent(`loglevelchange`,{detail:{level:e}})),{}))}#x(){this.#n.capabilities?.tools?.listChanged&&this.#p(`notifications/tools/list_changed`,{},`broadcast`)}#S(){this.#n.capabilities?.prompts?.listChanged&&this.#p(`notifications/prompts/list_changed`,{},`broadcast`)}#C(){this.#n.capabilities?.resources?.listChanged&&this.#p(`notifications/resources/list_changed`,{},`broadcast`)}tool({name:e,description:t,title:n,schema:r,outputSchema:i,annotations:a,enabled:o,icons:s,_meta:c},l){this.#x(),this.#r.set(e,{description:t,title:n,enabled:o,schema:r,outputSchema:i,execute:l,annotations:a,icons:s,_meta:c})}prompt({name:e,description:t,title:n,schema:r,complete:i,enabled:a,icons:o},s){i&&this.#s[`ref/prompt`].set(e,i),this.#S(),this.#i.set(e,{description:t,title:n,schema:r,execute:s,enabled:a,icons:o})}#w({uri:e,complete:t,...n}){t&&this.#s[`ref/resource`].set(e,t),n.template&&this.#o.add(e),this.#C(),this.#a.set(e,n)}resource({name:e,description:t,title:n,uri:r,enabled:i,icons:a},o){this.#w({name:e,description:t,title:n,uri:r,execute:o,enabled:i,icons:a,template:!1})}template({name:e,description:t,title:n,uri:r,complete:i,list:a,enabled:o,icons:s},c){this.#w({name:e,enabled:o,description:t,title:n,uri:r,execute:c,complete:i,icons:s,list_resources:a,template:!0})}receive(e,t){let n=Zo(qo([rs,is]),e);if(n.success){let e=n.output.params?._meta?.progressToken;return this.#l.run({...t??{},progress_token:e},async()=>await this.#e.receive(n.output))}let r=Xo(qo([as,os]),e);return this.#f(),this.#l.run(t??{},async()=>this.#t?.receive(r))}changed(...e){let[t,n]=e;if(t===`prompts`)this.#S();else if(t===`tools`)this.#x();else if(t===`resources`)this.#C();else{let e=this.#a.get(n);if(!e)return;this.#p(`notifications/resources/updated`,{uri:n,title:e.name},`broadcast`)}}async refreshRoots(){await this.#v()}async elicitation(e,t){if(!this.#d?.elicitation)throw new X(-32601,`Client doesn't support elicitation`);this.#f();let n=Xo(Ms,await this.#t?.request(`elicitation/create`,{message:e,requestedSchema:await this.#n.adapter?.toJsonSchema(t)},`standalone`)),r=t[`~standard`].validate(n.content);if(r instanceof Promise&&(r=await r),r.issues)throw new X(-32603,`Invalid elicitation result: ${JSON.stringify(r.issues)}`);return{...n,content:r.value}}async message(e){if(!this.#d?.sampling)throw new X(-32601,`Client doesn't support sampling`);this.#f();let t=Xo(As,e);return Xo(js,await this.#t?.request(`sampling/createMessage`,t,`standalone`))}progress(e,t=1,n=void 0){this.#u!=null&&this.#p(`notifications/progress`,{progress:e,total:t,message:n,progressToken:this.#u})}log(e,t,n){if(!this.#n.capabilities?.logging)throw new X(-32601,`The server doesn't support logging, please enable it in capabilities`);let r=this.#l.getStore()?.sessionInfo?.logLevel??this.#n.logging?.default??`info`;r&&this.#T(e,r)&&this.#p(`notifications/message`,{level:e,data:t,logger:n})}#T(e,t){let n=[`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`];return n.indexOf(e)>=n.indexOf(t)}},qs=`0.0.1-beta.2`;const Js={cwd:Oi().describe(`The path of the current working directory. Used to find the jsrepo.config file.`)},Ys=new Fa,Xs=new Ks({name:`jsrepo`,version:qs,description:`An MCP server for adding, viewing, and searching items from jsrepo registries.`},{adapter:Ys,capabilities:{tools:{listChanged:!0}}});Xs.tool({name:`add_item_to_project`,description:`Add a registry item or items to the users project.`,schema:sa({cwd:Js.cwd,itemNames:aa(Oi().describe('The registry and name of the item to add `<registry>/<item-name>`. i.e. "github/ieedan/std/math", "@ieedan/std/math", "https://example.com/registry/math"')).describe(`Fully qualifed registry items to add. i.e. ["github/ieedan/std/math", "@ieedan/std/math", "https://example.com/registry/math"]`),withExamples:$i().optional().describe(`Add items with examples.`),withDocs:$i().optional().describe(`Add items with docs.`),withTests:$i().optional().describe(`Add items with tests.`)}),outputSchema:sa({addedItems:aa(sa({name:Oi(),description:Oi().optional(),type:Oi(),files:aa(sa({code:Oi(),path:Oi()}))}))})},async({itemNames:e,...t})=>{let n=await c({cwd:t.cwd,promptForContinueIfNull:!1}),m=n?.config?.providers??l,{wantedItems:h,neededRegistries:g}=u(e,{providers:m,registries:n?.config?.registries??[]}).match(e=>e,e=>{throw e}),_=(await o((await p(h,{resolvedRegistries:(await f(g,{cwd:t.cwd,providers:m})).match(e=>e,e=>{throw e}),nonInteractive:!0})).match(e=>e,e=>{throw e}))).match(e=>e,e=>{throw e}),{itemPaths:v,resolvedPaths:y}=(await r({items:_,config:n?.config,options:{cwd:t.cwd,yes:!0}})).match(e=>e,e=>{throw e}),{neededDependencies:ee,neededEnvVars:b,neededFiles:x}=await i({configResult:n,options:{cwd:t.cwd,yes:!0,withExamples:t.withExamples??!1,withDocs:t.withDocs??!1,withTests:t.withTests??!1},itemPaths:v,resolvedPaths:y,items:_});return await s({files:x,options:{overwrite:!0,cwd:t.cwd,expand:!1,maxUnchanged:10}}),b&&await a(b,{options:{cwd:t.cwd,yes:!0}}),await d(ee,{options:{cwd:t.cwd,yes:!0},config:n?.config}),{structuredContent:{addedItems:_.map(e=>({name:e.name,description:e.description,type:e.type,files:e.files?.map(e=>({code:e.contents,path:e.path}))}))}}}),Xs.tool({name:`view_registry_item`,description:`View the code and information about a registry item.`,schema:sa({cwd:Js.cwd,item:Oi().describe('The registry and name of the item to add `<registry>/<item-name>`. i.e. "github/ieedan/std/math", "@ieedan/std/math", "https://example.com/registry/math"')})},async({cwd:e,item:r})=>{let i=await c({cwd:e,promptForContinueIfNull:!1}),a=i?.config?.providers??l,s=i?.config?.registries??[],{wantedItems:d,neededRegistries:m}=u([r],{providers:a,registries:s}).match(e=>e,e=>{throw e}),h=(await o((await p(d,{resolvedRegistries:(await f(m,{cwd:e,providers:a})).match(e=>e,e=>{throw e}),nonInteractive:!0})).match(e=>e,e=>{throw e}))).match(e=>e,e=>{throw e}),g=d[0],_=h.find(e=>e.name===g.itemName);if(!_)throw new n(g.itemName,g.registryUrl);return{content:[{type:`text`,text:Va`
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
`)+1).match(/^(\s+)/);if(n){let t=n[1];return e.replace(/\n/g,`\n${t}`)}return e}var Wa=y(((e,t)=>{((e,n)=>{typeof define==`function`&&define.amd?define([],n):typeof t==`object`&&t.exports?t.exports=n():e.fuzzysort=n()})(e,e=>{var t=(e,t)=>{if(!e||!t)return k;var n=p(e);D(t)||(t=f(t));var r=n.bitflags;return(r&t._bitflags)===r?h(n,t):k},n=(e,t,n)=>{if(!e)return n?.all?m(t,n):ae;var r=p(e),i=r.bitflags,a=r.containsSpace,o=u(n?.threshold||0),c=n?.limit||ie,l=0,d=0,ee=t.length;function g(e){l<c?(se.add(e),++l):(++d,e._score>se.peek()._score&&se.replaceTop(e))}if(n?.key)for(var _=n.key,v=0;v<ee;++v){var te=t[v],y=re(te,_);if(y&&(D(y)||(y=f(y)),(i&y._bitflags)===i)){var b=h(r,y);b!==k&&(b._score<o||(b.obj=te,g(b)))}}else if(n?.keys){var x=n.keys,S=x.length;outer:for(var v=0;v<ee;++v){for(var te=t[v],C=0,A=0;A<S;++A){var _=x[A],y=re(te,_);if(!y){E[A]=oe;continue}D(y)||(y=f(y)),E[A]=y,C|=y._bitflags}if((i&C)===i){if(a)for(let e=0;e<r.spaceSearches.length;e++)w[e]=O;for(var A=0;A<S;++A){if(y=E[A],y===oe){ne[A]=oe;continue}if(ne[A]=h(r,y,!1,a),ne[A]===k){ne[A]=oe;continue}if(a)for(let e=0;e<r.spaceSearches.length;e++){if(T[e]>-1e3&&w[e]>O){var j=(w[e]+T[e])/4;j>w[e]&&(w[e]=j)}T[e]>w[e]&&(w[e]=T[e])}}if(a){for(let e=0;e<r.spaceSearches.length;e++)if(w[e]===O)continue outer}else{var ce=!1;for(let e=0;e<S;e++)if(ne[e]._score!==O){ce=!0;break}if(!ce)continue}var M=new s(S);for(let e=0;e<S;e++)M[e]=ne[e];if(a){var N=0;for(let e=0;e<r.spaceSearches.length;e++)N+=w[e]}else{var N=O;for(let e=0;e<S;e++){var b=M[e];if(b._score>-1e3&&N>O){var j=(N+b._score)/4;j>N&&(N=j)}b._score>N&&(N=b._score)}}if(M.obj=te,M._score=N,n?.scoreFn){if(N=n.scoreFn(M),!N)continue;N=u(N),M._score=N}N<o||g(M)}}}else for(var v=0;v<ee;++v){var y=t[v];if(y&&(D(y)||(y=f(y)),(i&y._bitflags)===i)){var b=h(r,y);b!==k&&(b._score<o||g(b))}}if(l===0)return ae;for(var le=Array(l),v=l-1;v>=0;--v)le[v]=se.poll();return le.total=l+d,le},r=(e,t=`<b>`,n=`</b>`)=>{for(var r=typeof t==`function`?t:void 0,i=e.target,a=i.length,o=e.indexes,s=``,c=0,l=0,u=!1,d=[],f=0;f<a;++f){var p=i[f];if(o[l]===f){if(++l,u||(u=!0,r?(d.push(s),s=``):s+=t),l===o.length){r?(s+=p,d.push(r(s,c++)),s=``,d.push(i.substr(f+1))):s+=p+n+i.substr(f+1);break}}else u&&(u=!1,r?(d.push(r(s,c++)),s=``):s+=n);s+=p}return r?d:s},i=e=>{typeof e==`number`?e=``+e:typeof e!=`string`&&(e=``);var t=_(e);return c(e,{_targetLower:t._lower,_targetLowerCodes:t.lowerCodes,_bitflags:t.bitflags})},a=()=>{y.clear(),b.clear()};class o{get indexes(){return this._indexes.slice(0,this._indexes.len).sort((e,t)=>e-t)}set indexes(e){return this._indexes=e}highlight(e,t){return r(this,e,t)}get score(){return l(this._score)}set score(e){this._score=u(e)}}class s extends Array{get score(){return l(this._score)}set score(e){this._score=u(e)}}var c=(e,t)=>{let n=new o;return n.target=e,n.obj=t.obj??k,n._score=t._score??O,n._indexes=t._indexes??[],n._targetLower=t._targetLower??``,n._targetLowerCodes=t._targetLowerCodes??k,n._nextBeginningIndexes=t._nextBeginningIndexes??k,n._bitflags=t._bitflags??0,n},l=e=>e===O?0:e>1?e:Math.E**(((-e+1)**.04307-1)*-2),u=e=>e===0?O:e>1?e:1-(Math.log(e)/-2+1)**(1/.04307),d=e=>{typeof e==`number`?e=``+e:typeof e!=`string`&&(e=``),e=e.trim();var t=_(e),n=[];if(t.containsSpace){var r=e.split(/\s+/);r=[...new Set(r)];for(var i=0;i<r.length;i++)if(r[i]!==``){var a=_(r[i]);n.push({lowerCodes:a.lowerCodes,_lower:r[i].toLowerCase(),containsSpace:!1})}}return{lowerCodes:t.lowerCodes,_lower:t._lower,containsSpace:t.containsSpace,bitflags:t.bitflags,spaceSearches:n}},f=e=>{if(e.length>999)return i(e);var t=y.get(e);return t===void 0?(t=i(e),y.set(e,t),t):t},p=e=>{if(e.length>999)return d(e);var t=b.get(e);return t===void 0?(t=d(e),b.set(e,t),t):t},m=(e,t)=>{var n=[];n.total=e.length;var r=t?.limit||ie;if(t?.key)for(var i=0;i<e.length;i++){var a=e[i],o=re(a,t.key);if(o!=k){D(o)||(o=f(o));var l=c(o.target,{_score:o._score,obj:a});if(n.push(l),n.length>=r)return n}}else if(t?.keys)for(var i=0;i<e.length;i++){for(var a=e[i],u=new s(t.keys.length),d=t.keys.length-1;d>=0;--d){var o=re(a,t.keys[d]);if(!o){u[d]=oe;continue}D(o)||(o=f(o)),o._score=O,o._indexes.len=0,u[d]=o}if(u.obj=a,u._score=O,n.push(u),n.length>=r)return n}else for(var i=0;i<e.length;i++){var o=e[i];if(o!=k&&(D(o)||(o=f(o)),o._score=O,o._indexes.len=0,n.push(o),n.length>=r))return n}return n},h=(e,t,n=!1,r=!1)=>{if(n===!1&&e.containsSpace)return ee(e,t,r);for(var i=e._lower,a=e.lowerCodes,s=a[0],c=t._targetLowerCodes,l=a.length,u=c.length,d=0,f=0,p=0;;){var m=s===c[f];if(m){if(x[p++]=f,++d,d===l)break;s=a[d]}if(++f,f>=u)return k}var d=0,h=!1,g=0,_=t._nextBeginningIndexes;_===k&&(_=t._nextBeginningIndexes=te(t.target)),f=x[0]===0?0:_[x[0]-1];var v=0;if(f!==u)for(;;)if(f>=u){if(d<=0||(++v,v>200))break;--d;var y=S[--g];f=_[y]}else{var m=a[d]===c[f];if(m){if(S[g++]=f,++d,d===l){h=!0;break}++f}else f=_[f]}var b=l<=1?-1:t._targetLower.indexOf(i,x[0]),C=!!~b,w=C?b===0||t._nextBeginningIndexes[b-1]===b:!1;if(C&&!w){for(var T=0;T<_.length;T=_[T])if(!(T<=b)){for(var E=0;E<l&&a[E]===t._targetLowerCodes[T+E];E++);if(E===l){b=T,w=!0;break}}}var ne=e=>{for(var t=0,n=0,r=1;r<l;++r)e[r]-e[r-1]!==1&&(t-=e[r],++n);var i=e[l-1]-e[0]-(l-1);if(t-=(12+i)*n,e[0]!==0&&(t-=e[0]*e[0]*.2),!h)t*=1e3;else{for(var a=1,r=_[0];r<u;r=_[r])++a;a>24&&(t*=(a-24)*10)}return t-=(u-l)/2,C&&(t/=1+l*l*1),w&&(t/=1+l*l*1),t-=(u-l)/2,t};if(h)if(w){for(var T=0;T<l;++T)x[T]=b+T;var re=x,D=ne(x)}else var re=S,D=ne(S);else{if(C)for(var T=0;T<l;++T)x[T]=b+T;var re=x,D=ne(re)}t._score=D;for(var T=0;T<l;++T)t._indexes[T]=re[T];t._indexes.len=l;let ie=new o;return ie.target=t.target,ie._score=t._score,ie._indexes=t._indexes,ie},ee=(e,t,n)=>{for(var r=new Set,i=0,a=k,o=0,s=e.spaceSearches,c=s.length,l=0,u=()=>{for(let e=l-1;e>=0;e--)t._nextBeginningIndexes[C[e*2+0]]=C[e*2+1]},d=!1,f=0;f<c;++f){T[f]=O;var p=s[f];if(a=h(p,t),n){if(a===k)continue;d=!0}else if(a===k)return u(),k;if(f!==c-1){var m=a._indexes,ee=!0;for(let e=0;e<m.len-1;e++)if(m[e+1]-m[e]!==1){ee=!1;break}if(ee){var g=m[m.len-1]+1,_=t._nextBeginningIndexes[g-1];for(let e=g-1;e>=0&&_===t._nextBeginningIndexes[e];e--)t._nextBeginningIndexes[e]=g,C[l*2+0]=e,C[l*2+1]=_,l++}}i+=a._score/c,T[f]=a._score/c,a._indexes[0]<o&&(i-=(o-a._indexes[0])*2),o=a._indexes[0];for(var v=0;v<a._indexes.len;++v)r.add(a._indexes[v])}if(n&&!d)return k;u();var te=h(e,t,!0);if(te!==k&&te._score>i){if(n)for(var f=0;f<c;++f)T[f]=te._score/c;return te}n&&(a=t),a._score=i;var f=0;for(let e of r)a._indexes[f++]=e;return a._indexes.len=f,a},g=e=>e.replace(/\p{Script=Latin}+/gu,e=>e.normalize(`NFD`)).replace(/[\u0300-\u036f]/g,``),_=e=>{e=g(e);for(var t=e.length,n=e.toLowerCase(),r=[],i=0,a=!1,o=0;o<t;++o){var s=r[o]=n.charCodeAt(o);if(s===32){a=!0;continue}var c=s>=97&&s<=122?s-97:s>=48&&s<=57?26:s<=127?30:31;i|=1<<c}return{lowerCodes:r,bitflags:i,containsSpace:a,_lower:n}},v=e=>{for(var t=e.length,n=[],r=0,i=!1,a=!1,o=0;o<t;++o){var s=e.charCodeAt(o),c=s>=65&&s<=90,l=c||s>=97&&s<=122||s>=48&&s<=57,u=c&&!i||!a||!l;i=c,a=l,u&&(n[r++]=o)}return n},te=e=>{e=g(e);for(var t=e.length,n=v(e),r=[],i=n[0],a=0,o=0;o<t;++o)i>o?r[o]=i:(i=n[++a],r[o]=i===void 0?t:i);return r},y=new Map,b=new Map,x=[],S=[],C=[],w=[],T=[],E=[],ne=[],re=(e,t)=>{var n=e[t];if(n!==void 0)return n;if(typeof t==`function`)return t(e);var r=t;Array.isArray(t)||(r=t.split(`.`));for(var i=r.length,a=-1;e&&++a<i;)e=e[r[a]];return e},D=e=>typeof e==`object`&&typeof e._bitflags==`number`,ie=1/0,O=-ie,ae=[];ae.total=0;var k=null,oe=i(``),se=(e=>{var t=[],n=0,r={},i=e=>{for(var r=0,i=t[r],a=1;a<n;){var o=a+1;r=a,o<n&&t[o]._score<t[a]._score&&(r=o),t[r-1>>1]=t[r],a=1+(r<<1)}for(var s=r-1>>1;r>0&&i._score<t[s]._score;s=(r=s)-1>>1)t[r]=t[s];t[r]=i};return r.add=(e=>{var r=n;t[n++]=e;for(var i=r-1>>1;r>0&&e._score<t[i]._score;i=(r=i)-1>>1)t[r]=t[i];t[r]=e}),r.poll=(e=>{if(n!==0){var r=t[0];return t[0]=t[--n],i(),r}}),r.peek=(e=>{if(n!==0)return t[0]}),r.replaceTop=(e=>{t[0]=e,i()}),r})();return{single:t,go:n,prepare:i,cleanup:a}})})),Ga=y((e=>{var t=e&&e.__extends||(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if(typeof n!=`function`&&n!==null)throw TypeError(`Class extends value `+String(n)+` is not a constructor or null`);e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})();Object.defineProperty(e,`__esModule`,{value:!0}),e.createJSONRPCNotification=e.createJSONRPCRequest=e.createJSONRPCSuccessResponse=e.createJSONRPCErrorResponse=e.JSONRPCErrorCode=e.JSONRPCErrorException=e.isJSONRPCResponses=e.isJSONRPCResponse=e.isJSONRPCRequests=e.isJSONRPCRequest=e.isJSONRPCID=e.JSONRPC=void 0,e.JSONRPC=`2.0`,e.isJSONRPCID=function(e){return typeof e==`string`||typeof e==`number`||e===null},e.isJSONRPCRequest=function(t){return t.jsonrpc===e.JSONRPC&&t.method!==void 0&&t.result===void 0&&t.error===void 0},e.isJSONRPCRequests=function(t){return Array.isArray(t)&&t.every(e.isJSONRPCRequest)},e.isJSONRPCResponse=function(t){return t.jsonrpc===e.JSONRPC&&t.id!==void 0&&(t.result!==void 0||t.error!==void 0)},e.isJSONRPCResponses=function(t){return Array.isArray(t)&&t.every(e.isJSONRPCResponse)};var n=function(e,t,n){var r={code:e,message:t};return n!=null&&(r.data=n),r};e.JSONRPCErrorException=function(e){t(r,e);function r(t,n,i){var a=e.call(this,t)||this;return Object.setPrototypeOf(a,r.prototype),a.code=n,a.data=i,a}return r.prototype.toObject=function(){return n(this.code,this.message,this.data)},r}(Error),(function(e){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.JSONRPCErrorCode||={}),e.createJSONRPCErrorResponse=function(t,r,i,a){return{jsonrpc:e.JSONRPC,id:t,error:n(r,i,a)}},e.createJSONRPCSuccessResponse=function(t,n){return{jsonrpc:e.JSONRPC,id:t,result:n??null}},e.createJSONRPCRequest=function(t,n,r){return{jsonrpc:e.JSONRPC,id:t,method:n,params:r}},e.createJSONRPCNotification=function(t,n){return{jsonrpc:e.JSONRPC,method:t,params:n}}})),Ka=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DefaultErrorCode=void 0,e.DefaultErrorCode=0})),qa=y((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(e,`__esModule`,{value:!0}),e.JSONRPCClient=void 0;var r=Ga(),i=Ka();e.JSONRPCClient=function(){function e(e,t){this._send=e,this.createID=t,this.idToResolveMap=new Map,this.id=0}return e.prototype._createID=function(){return this.createID?this.createID():++this.id},e.prototype.timeout=function(e,t){var n=this;t===void 0&&(t=function(e){return(0,r.createJSONRPCErrorResponse)(e,i.DefaultErrorCode,`Request timeout`)});var o=function(r,i){var a=setTimeout(function(){r.forEach(function(e){var r=n.idToResolveMap.get(e);r&&(n.idToResolveMap.delete(e),r(t(e)))})},e);return i().then(function(e){return clearTimeout(a),e},function(e){return clearTimeout(a),Promise.reject(e)})},s=function(e,t){return o((Array.isArray(e)?e:[e]).map(function(e){return e.id}).filter(a),function(){return n.requestAdvanced(e,t)})};return{request:function(e,t,r){var i=n._createID();return o([i],function(){return n.requestWithID(e,t,r,i)})},requestAdvanced:function(e,t){return s(e,t)}}},e.prototype.request=function(e,t,n){return this.requestWithID(e,t,n,this._createID())},e.prototype.requestWithID=function(e,i,a,o){return t(this,void 0,void 0,function(){var t,s;return n(this,function(n){switch(n.label){case 0:return t=(0,r.createJSONRPCRequest)(o,e,i),[4,this.requestAdvanced(t,a)];case 1:return s=n.sent(),s.result!==void 0&&!s.error?[2,s.result]:s.result===void 0&&s.error?[2,Promise.reject(new r.JSONRPCErrorException(s.error.message,s.error.code,s.error.data))]:[2,Promise.reject(Error(`An unexpected error occurred`))]}})})},e.prototype.requestAdvanced=function(e,t){var n=this,o=Array.isArray(e);Array.isArray(e)||(e=[e]);var s=e.filter(function(e){return a(e.id)}),c=s.map(function(e){return new Promise(function(t){return n.idToResolveMap.set(e.id,t)})}),l=Promise.all(c).then(function(e){return o||!e.length?e:e[0]});return this.send(o?e:e[0],t).then(function(){return l},function(e){return s.forEach(function(t){n.receive((0,r.createJSONRPCErrorResponse)(t.id,i.DefaultErrorCode,e&&e.message||`Failed to send a request`))}),l})},e.prototype.notify=function(e,t,n){var i=(0,r.createJSONRPCNotification)(e,t);this.send(i,n).then(void 0,function(){})},e.prototype.send=function(e,r){return t(this,void 0,void 0,function(){return n(this,function(t){return[2,this._send(e,r)]})})},e.prototype.rejectAllPendingRequests=function(e){this.idToResolveMap.forEach(function(t,n){return t((0,r.createJSONRPCErrorResponse)(n,i.DefaultErrorCode,e))}),this.idToResolveMap.clear()},e.prototype.receive=function(e){var t=this;Array.isArray(e)||(e=[e]),e.forEach(function(e){var n=t.idToResolveMap.get(e.id);n&&(t.idToResolveMap.delete(e.id),n(e))})},e}();var a=function(e){return e!=null}})),Ja=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),Ya=y((e=>{var t=e&&e.__assign||function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)},n=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},r=e&&e.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}},i=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,`__esModule`,{value:!0}),e.JSONRPCServer=void 0;var a=Ga(),o=Ka(),s=function(){return(0,a.createJSONRPCErrorResponse)(null,a.JSONRPCErrorCode.ParseError,`Parse error`)},c=function(e){return(0,a.createJSONRPCErrorResponse)((0,a.isJSONRPCID)(e.id)?e.id:null,a.JSONRPCErrorCode.InvalidRequest,`Invalid Request`)},l=function(e){return(0,a.createJSONRPCErrorResponse)(e,a.JSONRPCErrorCode.MethodNotFound,`Method not found`)};e.JSONRPCServer=function(){function e(e){e===void 0&&(e={}),this.mapErrorToJSONRPCErrorResponse=p,this.nameToMethodDictionary={},this.middleware=null,this.errorListener=e.errorListener??console.warn}return e.prototype.hasMethod=function(e){return!!this.nameToMethodDictionary[e]},e.prototype.addMethod=function(e,t){this.addMethodAdvanced(e,this.toJSONRPCMethod(t))},e.prototype.removeMethod=function(e){delete this.nameToMethodDictionary[e]},e.prototype.toJSONRPCMethod=function(e){return function(t,n){var r=e(t.params,n);return Promise.resolve(r).then(function(e){return f(t.id,e)})}},e.prototype.addMethodAdvanced=function(e,n){var r;this.nameToMethodDictionary=t(t({},this.nameToMethodDictionary),(r={},r[e]=n,r))},e.prototype.receiveJSON=function(e,t){var n=this.tryParseRequestJSON(e);return n?this.receive(n,t):Promise.resolve(s())},e.prototype.tryParseRequestJSON=function(e){try{return JSON.parse(e)}catch{return null}},e.prototype.receive=function(e,t){return Array.isArray(e)?this.receiveMultiple(e,t):this.receiveSingle(e,t)},e.prototype.receiveMultiple=function(e,t){return n(this,void 0,void 0,function(){var n,i=this;return r(this,function(r){switch(r.label){case 0:return[4,Promise.all(e.map(function(e){return i.receiveSingle(e,t)}))];case 1:return n=r.sent().filter(u),n.length===1?[2,n[0]]:n.length?[2,n]:[2,null]}})})},e.prototype.receiveSingle=function(e,t){return n(this,void 0,void 0,function(){var n,i;return r(this,function(r){switch(r.label){case 0:return n=this.nameToMethodDictionary[e.method],(0,a.isJSONRPCRequest)(e)?[3,1]:[2,c(e)];case 1:return[4,this.callMethod(n,e,t)];case 2:return i=r.sent(),[2,m(e,i)]}})})},e.prototype.applyMiddleware=function(){var e=[...arguments];this.middleware?this.middleware=this.combineMiddlewares(i([this.middleware],e,!0)):this.middleware=this.combineMiddlewares(e)},e.prototype.combineMiddlewares=function(e){return e.length?e.reduce(this.middlewareReducer):null},e.prototype.middlewareReducer=function(e,t){return function(n,r,i){return e(function(e,r){return t(n,e,r)},r,i)}},e.prototype.callMethod=function(e,t,n){var r=this,i=function(t,n){return e?e(t,n):t.id===void 0?Promise.resolve(null):Promise.resolve(l(t.id))},a=function(e){return r.errorListener(`An unexpected error occurred while executing "${t.method}" JSON-RPC method:`,e),Promise.resolve(r.mapErrorToJSONRPCErrorResponseIfNecessary(t.id,e))};try{return(this.middleware||d)(i,t,n).then(void 0,a)}catch(e){return a(e)}},e.prototype.mapErrorToJSONRPCErrorResponseIfNecessary=function(e,t){return e===void 0?null:this.mapErrorToJSONRPCErrorResponse(e,t)},e}();var u=function(e){return e!==null},d=function(e,t,n){return e(t,n)},f=function(e,t){return e===void 0?null:(0,a.createJSONRPCSuccessResponse)(e,t)},p=function(e,t){var n=t?.message??`An unexpected error occurred`,r=o.DefaultErrorCode,i;return t instanceof a.JSONRPCErrorException&&(r=t.code,i=t.data),(0,a.createJSONRPCErrorResponse)(e,r,n,i)},m=function(e,t){return t||(e.id===void 0?null:(0,a.createJSONRPCErrorResponse)(e.id,a.JSONRPCErrorCode.InternalError,`Internal error`))}})),Xa=y((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})},n=e&&e.__generator||function(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}};Object.defineProperty(e,`__esModule`,{value:!0}),e.JSONRPCServerAndClient=void 0;var r=Ga();e.JSONRPCServerAndClient=function(){function e(e,t,n){n===void 0&&(n={}),this.server=e,this.client=t,this.errorListener=n.errorListener??console.warn}return e.prototype.applyServerMiddleware=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=this.server).applyMiddleware.apply(e,t)},e.prototype.hasMethod=function(e){return this.server.hasMethod(e)},e.prototype.addMethod=function(e,t){this.server.addMethod(e,t)},e.prototype.addMethodAdvanced=function(e,t){this.server.addMethodAdvanced(e,t)},e.prototype.removeMethod=function(e){this.server.removeMethod(e)},e.prototype.timeout=function(e){return this.client.timeout(e)},e.prototype.request=function(e,t,n){return this.client.request(e,t,n)},e.prototype.requestAdvanced=function(e,t){return this.client.requestAdvanced(e,t)},e.prototype.notify=function(e,t,n){this.client.notify(e,t,n)},e.prototype.rejectAllPendingRequests=function(e){this.client.rejectAllPendingRequests(e)},e.prototype.receiveAndSend=function(e,i,a){return t(this,void 0,void 0,function(){var t,o;return n(this,function(n){switch(n.label){case 0:return(0,r.isJSONRPCResponse)(e)||(0,r.isJSONRPCResponses)(e)?(this.client.receive(e),[3,4]):[3,1];case 1:return(0,r.isJSONRPCRequest)(e)||(0,r.isJSONRPCRequests)(e)?[4,this.server.receive(e,i)]:[3,3];case 2:return t=n.sent(),t?[2,this.client.send(t,a)]:[3,4];case 3:return o=`Received an invalid JSON-RPC message`,this.errorListener(o,e),[2,Promise.reject(Error(o))];case 4:return[2]}})})},e}()})),Za=y((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(qa(),e),n(Ja(),e),n(Ga(),e),n(Ya(),e),n(Xa(),e)}));function Qa(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`{`){n&&=(t.push({type:`literal`,value:n}),``);let i=r+1,a=i,o=1;for(;a<e.length&&o>0;)e[a]===`{`?o++:e[a]===`}`&&o--,a++;if(o>0)throw Error(`Unclosed expression in template: ${e}`);let s=$a(e.slice(i,a-1));t.push(s),r=a}else n+=i,r++}return n&&t.push({type:`literal`,value:n}),{template:e,parts:t}}function $a(e){if(!e.trim())throw Error(`Empty expression`);let t=e[0],n=[`+`,`#`,`.`,`/`,`;`,`?`,`&`],r,i=e;return n.includes(t)&&(r=t,i=e.slice(1)),{type:`expression`,expressions:eo(i).map(to),operator:r}}function eo(e){let t=[],n=``,r=0;for(;r<e.length;){let i=e[r];i===`,`?n.trim()&&(t.push(n.trim()),n=``):n+=i,r++}return n.trim()&&t.push(n.trim()),t}function to(e){let t=e,n,r=!1;t.endsWith(`*`)&&(r=!0,t=t.slice(0,-1));let i=t.indexOf(`:`);if(i!==-1){let e=t.slice(i+1);if(n=parseInt(e,10),isNaN(n)||n<0)throw Error(`Invalid prefix length: ${e}`);t=t.slice(0,i)}if(!t)throw Error(`Empty variable name`);return{name:t,prefix:n,explode:r}}function no(e,t){let n={},r=ro(e,0,t.parts,0,n);return!r||r.uri_index!==e.length?null:n}function ro(e,t,n,r,i){if(r>=n.length)return{uri_index:t};let a=n[r];if(a.type===`literal`)return e.slice(t).startsWith(a.value)?ro(e,t+a.value.length,n,r+1,i):null;{let o=n[r+1],s=io(e,t,o).sort((e,t)=>o&&o.type===`expression`&&!o.operator?t-e:e-t);for(let o of s){let s=e.slice(t,o),c={...i};if(ao(s,a,c,e,t)){let t=ro(e,o,n,r+1,c);if(t)return Object.assign(i,c),t}}return null}}function io(e,t,n){let r=[];if(n&&n.type===`literal`){let i=t;for(;i<e.length;){let t=e.indexOf(n.value,i);if(t===-1)break;r.push(t),i=t+1}if(r.length===0)return[]}else if(n&&n.type===`expression`){let i=n;if(i.operator===`.`){for(let n=t;n<e.length;n++)e[n]===`.`&&r.push(n);r.push(e.length)}else if(i.operator===`/`)for(let n=t;n<e.length;n++)e[n]===`/`&&r.push(n);else for(let n=t;n<=e.length;n++)r.push(n)}else r.push(e.length);return r.sort((e,t)=>e-t)}function ao(e,t,n,r,i){if(t.type!==`expression`)return!1;switch(t.operator){case`+`:return so(e,t,n);case`#`:return oo(e,t,n);case`.`:return lo(e,t,n);case`/`:return uo(e,t,n);case`;`:return fo(e,t,n);case`?`:case`&`:return po(e,t,n);default:return co(e,t,n,r,i)}}function oo(e,t,n){if(t.type!==`expression`)return!1;if(!e.startsWith(`#`)){for(let e of t.expressions)n[e.name]=``;return e===``}let r=e.slice(1);if(t.expressions.length===1){let e=t.expressions[0],i=r;return e.prefix&&i.length>e.prefix&&(i=i.slice(0,e.prefix)),n[e.name]=decodeURIComponent(i),!0}else{let e=r.split(`,`);for(let r=0;r<t.expressions.length;r++){let i=t.expressions[r],a=e[r]||``;i.prefix&&a.length>i.prefix&&(a=a.slice(0,i.prefix)),n[i.name]=decodeURIComponent(a)}return!0}}function so(e,t,n){if(t.type!==`expression`)return!1;if(t.expressions.length===1){let r=t.expressions[0],i=e;return r.prefix&&i.length>r.prefix&&(i=i.slice(0,r.prefix)),n[r.name]=decodeURIComponent(i),!0}else{let r=e.split(`,`);for(let e=0;e<t.expressions.length;e++){let i=t.expressions[e],a=r[e]||``;i.prefix&&a.length>i.prefix&&(a=a.slice(0,i.prefix)),n[i.name]=decodeURIComponent(a)}return!0}}function co(e,t,n,r,i){if(t.type!==`expression`)return!1;if(t.expressions.length===1){let a=t.expressions[0],o=e;return o.includes(`/`)||o===``&&i+e.length===r.length&&r.endsWith(`/`)?!1:(a.prefix&&o.length>a.prefix&&(o=o.slice(0,a.prefix)),n[a.name]=decodeURIComponent(o),!0)}else{let r=e.split(`,`);for(let e=0;e<t.expressions.length;e++){let i=t.expressions[e],a=r[e]||``;if(a.includes(`/`))return!1;i.prefix&&a.length>i.prefix&&(a=a.slice(0,i.prefix)),n[i.name]=decodeURIComponent(a)}return!0}}function lo(e,t,n){if(t.type!==`expression`)return!1;if(e===``){for(let e of t.expressions)n[e.name]=``;return!0}let r=e.startsWith(`.`)?e.slice(1):e;if(t.expressions.length===1){let e=t.expressions[0];if(e.explode){let t=r.split(`.`);n[e.name]=t.map(e=>decodeURIComponent(e))}else n[e.name]=decodeURIComponent(r);return!0}else{let e=r.split(`.`);for(let r=0;r<t.expressions.length;r++){let i=t.expressions[r],a=e[r]||``;i.prefix&&a.length>i.prefix&&(a=a.slice(0,i.prefix)),n[i.name]=decodeURIComponent(a)}return!0}}function uo(e,t,n){if(t.type!==`expression`)return!1;let r=e.startsWith(`/`)?e.slice(1):e;if(t.expressions.length===1){let e=t.expressions[0];return n[e.name]=decodeURIComponent(r),!0}else{let e=r.split(`,`);for(let r=0;r<t.expressions.length;r++){let i=t.expressions[r],a=e[r]||``;i.prefix&&a.length>i.prefix&&(a=a.slice(0,i.prefix)),n[i.name]=decodeURIComponent(a)}return!0}}function fo(e,t,n){if(t.type!==`expression`)return!1;let r=e.split(`;`).filter(e=>e);for(let e of r){let r=e.indexOf(`=`);if(r!==-1){let i=e.slice(0,r),a=e.slice(r+1),o=t.expressions.find(e=>e.name===i);o&&(n[o.name]=decodeURIComponent(a))}}return!0}function po(e,t,n){if(t.type!==`expression`)return!1;let r=e.replace(/^[?&]/,``);if(t.expressions.length===1){let e=t.expressions[0];if(e.explode){let t=r.split(`&`);n[e.name]=t.map(e=>decodeURIComponent(e))}else{let t=r.split(`&`);for(let r of t){let t=r.indexOf(`=`);if(t!==-1){let i=r.slice(0,t),a=r.slice(t+1);i===e.name&&(n[e.name]=decodeURIComponent(a))}}}}else{let e=r.split(`&`);for(let r of e){let e=r.indexOf(`=`);if(e!==-1){let i=r.slice(0,e),a=r.slice(e+1),o=t.expressions.find(e=>e.name===i);o&&(n[o.name]=decodeURIComponent(a))}}}return!0}var mo=class{constructor(){this.templates=[]}add(e){if(typeof e!=`string`)throw Error(`Template must be a string`);if(e!==``&&e.trim()===``)throw Error(`Template cannot be empty`);try{let t=Qa(e);this.templates.push(t)}catch(t){throw Error(`Invalid template: ${e} - ${t instanceof Error?t.message:String(t)}`)}}match(e){if(typeof e!=`string`)throw Error(`URI must be a string`);for(let t of this.templates){let n=no(e,t);if(n!==null)return{template:t.template,params:n}}return null}clear(){this.templates=[]}all(){return this.templates.map(e=>e.template)}},ho=x(Za(),1),go=x(Wa(),1),_o;function vo(e){return{lang:e?.lang??_o?.lang,message:e?.message,abortEarly:e?.abortEarly??_o?.abortEarly,abortPipeEarly:e?.abortPipeEarly??_o?.abortPipeEarly}}var yo;function bo(e){return yo?.get(e)}var xo;function So(e){return xo?.get(e)}var Co;function wo(e,t){return Co?.get(e)?.get(t)}function To(e){let t=typeof e;return t===`string`?`"${e}"`:t===`number`||t===`bigint`||t===`boolean`?`${e}`:t===`object`||t===`function`?(e&&Object.getPrototypeOf(e)?.constructor?.name)??`null`:t}function H(e,t,n,r,i){let a=i&&`input`in i?i.input:n.value,o=i?.expected??e.expects??null,s=i?.received??To(a),c={kind:e.kind,type:e.type,input:a,expected:o,received:s,message:`Invalid ${t}: ${o?`Expected ${o} but r`:`R`}eceived ${s}`,requirement:e.requirement,path:i?.path,issues:i?.issues,lang:r.lang,abortEarly:r.abortEarly,abortPipeEarly:r.abortPipeEarly},l=e.kind===`schema`,u=i?.message??e.message??wo(e.reference,c.lang)??(l?So(c.lang):null)??r.message??bo(c.lang);u!==void 0&&(c.message=typeof u==`function`?u(c):u),l&&(n.typed=!1),n.issues?n.issues.push(c):n.issues=[c]}function U(e){return{version:1,vendor:`valibot`,validate(t){return e[`~run`]({value:t},vo())}}}function Eo(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function Do(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var Oo=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}},ko=/^(?:[\da-z+/]{4})*(?:[\da-z+/]{2}==|[\da-z+/]{3}=)?$/iu;function Ao(e){return{kind:`validation`,type:`base64`,reference:Ao,async:!1,expects:null,requirement:ko,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&H(this,`Base64`,e,t),e}}}function jo(e,t){return{kind:`validation`,type:`check`,reference:jo,async:!1,expects:null,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&H(this,`input`,e,t),e}}}function Mo(e){return{kind:`validation`,type:`integer`,reference:Mo,async:!1,expects:null,requirement:Number.isInteger,message:e,"~run"(e,t){return e.typed&&!this.requirement(e.value)&&H(this,`integer`,e,t),e}}}function No(e,t){return{kind:`validation`,type:`max_length`,reference:No,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&e.value.length>this.requirement&&H(this,`length`,e,t,{received:`${e.value.length}`}),e}}}function Po(e,t){return{kind:`validation`,type:`max_value`,reference:Po,async:!1,expects:`<=${e instanceof Date?e.toJSON():To(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value<=this.requirement)&&H(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():To(e.value)}),e}}}function Fo(e,t){return{kind:`validation`,type:`min_value`,reference:Fo,async:!1,expects:`>=${e instanceof Date?e.toJSON():To(e)}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!(e.value>=this.requirement)&&H(this,`value`,e,t,{received:e.value instanceof Date?e.value.toJSON():To(e.value)}),e}}}function Io(e,t){return{kind:`validation`,type:`regex`,reference:Io,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&H(this,`format`,e,t),e}}}function Lo(e,t){return{kind:`validation`,type:`starts_with`,reference:Lo,async:!1,expects:`"${e}"`,requirement:e,message:t,"~run"(e,t){return e.typed&&!e.value.startsWith(this.requirement)&&H(this,`start`,e,t,{received:`"${e.value.slice(0,this.requirement.length)}"`}),e}}}function Ro(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function zo(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Bo(e,t){return{kind:`schema`,type:`array`,reference:Bo,expects:`Array`,async:!1,item:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(Array.isArray(n)){e.typed=!0,e.value=[];for(let r=0;r<n.length;r++){let i=n[r],a=this.item[`~run`]({value:i},t);if(a.issues){let o={type:`array`,origin:`value`,input:n,key:r,value:i};for(let t of a.issues)t.path?t.path.unshift(o):t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}a.typed||(e.typed=!1),e.value.push(a.value)}}else H(this,`type`,e,t);return e}}}function Vo(e){return{kind:`schema`,type:`boolean`,reference:Vo,expects:`boolean`,async:!1,message:e,get"~standard"(){return U(this)},"~run"(e,t){return typeof e.value==`boolean`?e.typed=!0:H(this,`type`,e,t),e}}}function Ho(e,t){return{kind:`schema`,type:`literal`,reference:Ho,expects:To(e),async:!1,literal:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){return e.value===this.literal?e.typed=!0:H(this,`type`,e,t),e}}}function W(e,t){return{kind:`schema`,type:`loose_object`,reference:W,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:zo(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Ro(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(H(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly)for(let t in n)Eo(n,t)&&!(t in this.entries)&&(e.value[t]=n[t])}else H(this,`type`,e,t);return e}}}function G(e){return{kind:`schema`,type:`number`,reference:G,expects:`number`,async:!1,message:e,get"~standard"(){return U(this)},"~run"(e,t){return typeof e.value==`number`&&!isNaN(e.value)?e.typed=!0:H(this,`type`,e,t),e}}}function K(e,t){return{kind:`schema`,type:`object`,reference:K,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`)for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:zo(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Ro(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(H(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}else H(this,`type`,e,t);return e}}}function q(e,t){return{kind:`schema`,type:`optional`,reference:q,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,get"~standard"(){return U(this)},"~run"(e,t){return e.value===void 0&&(this.default!==void 0&&(e.value=zo(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function Uo(e,t){return{kind:`schema`,type:`picklist`,reference:Uo,expects:Do(e.map(To),`|`),async:!1,options:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){return this.options.includes(e.value)?e.typed=!0:H(this,`type`,e,t),e}}}function Wo(e,t,n){return{kind:`schema`,type:`record`,reference:Wo,expects:`Object`,async:!1,key:e,value:t,message:n,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},n)if(Eo(n,r)){let i=n[r],a=this.key[`~run`]({value:r},t);if(a.issues){let o={type:`object`,origin:`key`,input:n,key:r,value:i};for(let t of a.issues)t.path=[o],e.issues?.push(t);if(e.issues||=a.issues,t.abortEarly){e.typed=!1;break}}let o=this.value[`~run`]({value:i},t);if(o.issues){let a={type:`object`,origin:`value`,input:n,key:r,value:i};for(let t of o.issues)t.path?t.path.unshift(a):t.path=[a],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}(!a.typed||!o.typed)&&(e.typed=!1),a.typed&&(e.value[a.value]=o.value)}}else H(this,`type`,e,t);return e}}}function Go(e,t){return{kind:`schema`,type:`strict_object`,reference:Go,expects:`Object`,async:!1,entries:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){for(let r in e.typed=!0,e.value={},this.entries){let i=this.entries[r];if(r in n||(i.type===`exact_optional`||i.type===`optional`||i.type===`nullish`)&&i.default!==void 0){let a=r in n?n[r]:zo(i),o=i[`~run`]({value:a},t);if(o.issues){let i={type:`object`,origin:`value`,input:n,key:r,value:a};for(let t of o.issues)t.path?t.path.unshift(i):t.path=[i],e.issues?.push(t);if(e.issues||=o.issues,t.abortEarly){e.typed=!1;break}}o.typed||(e.typed=!1),e.value[r]=o.value}else if(i.fallback!==void 0)e.value[r]=Ro(i);else if(i.type!==`exact_optional`&&i.type!==`optional`&&i.type!==`nullish`&&(H(this,`key`,e,t,{input:void 0,expected:`"${r}"`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]}),t.abortEarly))break}if(!e.issues||!t.abortEarly){for(let r in n)if(!(r in this.entries)){H(this,`key`,e,t,{input:r,expected:`never`,path:[{type:`object`,origin:`key`,input:n,key:r,value:n[r]}]});break}}}else H(this,`type`,e,t);return e}}}function J(e){return{kind:`schema`,type:`string`,reference:J,expects:`string`,async:!1,message:e,get"~standard"(){return U(this)},"~run"(e,t){return typeof e.value==`string`?e.typed=!0:H(this,`type`,e,t),e}}}function Ko(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function qo(e,t){return{kind:`schema`,type:`union`,reference:qo,expects:Do(e.map(e=>e.expects),`|`),async:!1,options:e,message:t,get"~standard"(){return U(this)},"~run"(e,t){let n,r,i;for(let a of this.options){let o=a[`~run`]({value:e.value},t);if(o.typed)if(o.issues)r?r.push(o):r=[o];else{n=o;break}else i?i.push(o):i=[o]}if(n)return n;if(r){if(r.length===1)return r[0];H(this,`type`,e,t,{issues:Ko(r)}),e.typed=!0}else if(i?.length===1)return i[0];else H(this,`type`,e,t,{issues:Ko(i)});return e}}}function Jo(){return{kind:`schema`,type:`unknown`,reference:Jo,expects:`unknown`,async:!1,get"~standard"(){return U(this)},"~run"(e){return e.typed=!0,e}}}function Yo(e,t,n){return{kind:`schema`,type:`variant`,reference:Yo,expects:`Object`,async:!1,key:e,options:t,message:n,get"~standard"(){return U(this)},"~run"(e,t){let n=e.value;if(n&&typeof n==`object`){let r,i=0,a=this.key,o=[],s=(e,c)=>{for(let l of e.options){if(l.type===`variant`)s(l,new Set(c).add(l.key));else{let e=!0,s=0;for(let t of c){let r=l.entries[t];if(t in n?r[`~run`]({typed:!1,value:n[t]},{abortEarly:!0}).issues:r.type!==`exact_optional`&&r.type!==`optional`&&r.type!==`nullish`){e=!1,a!==t&&(i<s||i===s&&t in n&&!(a in n))&&(i=s,a=t,o=[]),a===t&&o.push(l.entries[t].expects);break}s++}if(e){let e=l[`~run`]({value:n},t);(!r||!r.typed&&e.typed)&&(r=e)}}if(r&&!r.issues)break}};if(s(this,new Set([this.key])),r)return r;H(this,`type`,e,t,{input:n[a],expected:Do(o,`|`),path:[{type:`object`,origin:`value`,input:n,key:a,value:n[a]}]})}else H(this,`type`,e,t);return e}}}function Xo(e,t,n){let r=e[`~run`]({value:t},vo(n));if(r.issues)throw new Oo(r.issues);return r.value}function Y(...e){return{...e[0],pipe:e,get"~standard"(){return U(this)},"~run"(t,n){for(let r of e)if(r.kind!==`metadata`){if(t.issues&&(r.kind===`schema`||r.kind===`transformation`)){t.typed=!1;break}(!t.issues||!n.abortEarly&&!n.abortPipeEarly)&&(t=r[`~run`](t,n))}return t}}}function Zo(e,t,n){let r=e[`~run`]({value:t},vo(n));return{typed:r.typed,success:!r.issues,output:r.value,issues:r.issues}}var X=class extends Error{constructor(e,t){super(`MCP error ${e}: ${t}`),this.name=`McpError`}};const Qo=qo([J(),Y(G(),Mo())]),$o=J(),Z=W({_meta:q(W({progressToken:q(Qo)}))}),Q=K({method:J(),params:q(Z)}),es=W({_meta:q(W({}))}),ts=K({method:J(),params:q(es)}),$=W({_meta:q(W({}))}),ns=qo([J(),Y(G(),Mo())]),rs=K({jsonrpc:Ho(`2.0`),id:ns,...Q.entries}),is=K({jsonrpc:Ho(`2.0`),...ts.entries}),as=Go({jsonrpc:Ho(`2.0`),id:ns,result:$}),os=Go({jsonrpc:Ho(`2.0`),id:ns,error:K({code:Y(G(),Mo()),message:J(),data:q(Jo())})});({...$.entries}),{...ts.entries},{...es.entries};const ss=K({name:J(),title:q(J())}),cs=K({icons:q(Bo(K({src:J(),mimeType:q(J()),sizes:q(Bo(J()))})))}),ls=K({...ss.entries,version:J(),websiteUrl:q(J()),...cs.entries}),us=K({experimental:q(K({})),sampling:q(K({})),elicitation:q(K({})),roots:q(K({listChanged:q(Vo())}))}),ds=K({...Z.entries,protocolVersion:J(),capabilities:us,clientInfo:ls});({...Q.entries}),{...$.entries},{...ts.entries},{...Q.entries};const fs=K({progress:G(),total:q(G()),message:q(J())});({...ts.entries}),{...es.entries,...fs.entries};const ps=K({...Q.entries,params:q(K({...Z.entries,cursor:q($o)}))}),ms=K({...$.entries,nextCursor:q($o)}),hs=K({uri:J(),mimeType:q(J()),_meta:q(W({}))}),gs=K({...hs.entries,text:J()}),_s=K({...hs.entries,blob:Y(J(),Ao())}),vs=K({...ss.entries,uri:J(),description:q(J()),mimeType:q(J()),_meta:q(W({})),...cs.entries});({...ss.entries}),{...cs.entries},{...ps.entries},{...ms.entries},{...ps.entries},{...ms.entries},{...Q.entries},{...Z.entries};const ys=K({...$.entries,contents:Bo(qo([gs,_s]))});({...ts.entries}),{...Q.entries},{...Z.entries},{...Q.entries},{...Z.entries},{...ts.entries},{...es.entries},{...ss.entries},{...cs.entries},{...ps.entries},{...ms.entries},{...Q.entries},{...Z.entries};const bs=K({type:Ho(`text`),text:J(),_meta:q(W({}))}),xs=K({type:Ho(`image`),data:Y(J(),Ao()),mimeType:J(),_meta:q(W({}))}),Ss=K({type:Ho(`audio`),data:Y(J(),Ao()),mimeType:J(),_meta:q(W({}))}),Cs=K({type:Ho(`resource`),resource:qo([gs,_s]),_meta:q(W({}))}),ws=qo([bs,xs,Ss,K({...vs.entries,type:Ho(`resource_link`)}),Cs]),Ts=K({role:Uo([`user`,`assistant`]),content:ws}),Es=K({...$.entries,description:q(J()),messages:Bo(Ts)});({...ts.entries}),{...ss.entries},{...cs.entries},{...ps.entries},{...ms.entries};const Ds=K({...$.entries,content:q(Bo(ws),[]),structuredContent:q(W({})),isError:q(Vo())});({...$.entries}),{...Q.entries},{...Z.entries},{...ts.entries},{...Q.entries},{...Z.entries},{...ts.entries},{...es.entries};const Os=K({hints:q(Bo(K({name:q(J())}))),costPriority:q(Y(G(),Fo(0),Po(1))),speedPriority:q(Y(G(),Fo(0),Po(1))),intelligencePriority:q(Y(G(),Fo(0),Po(1)))}),ks=K({role:Uo([`user`,`assistant`]),content:qo([bs,xs,Ss])}),As=K({...Z.entries,messages:Bo(ks),systemPrompt:q(J()),includeContext:q(Uo([`none`,`thisServer`,`allServers`])),temperature:q(G()),maxTokens:Y(G(),Mo()),stopSequences:q(Bo(J())),metadata:q(K({})),modelPreferences:q(Os)});({...Q.entries});const js=K({...$.entries,model:J(),stopReason:q(qo([Uo([`endTurn`,`stopSequence`,`maxTokens`]),J()])),role:Uo([`user`,`assistant`]),content:Yo(`type`,[bs,xs,Ss])});({...Q.entries}),{...Z.entries};const Ms=K({...$.entries,action:Uo([`accept`,`decline`,`cancel`]),content:q(Wo(J(),Jo()))});({...Q.entries}),{...Z.entries};const Ns=K({...$.entries,completion:K({values:Y(Bo(J()),No(100)),total:q(Y(G(),Mo())),hasMore:q(Vo())})});({...Q.entries}),{...$.entries},{...ts.entries};const Ps=[`2025-06-18`,`2025-03-26`,`2024-11-05`],Fs=Ps[0];function Is(e){return Ps.includes(e)}function Ls(){return Fs}function Rs(){return[...Ps]}function zs(e){return Is(e)?e:Ls()}function Bs(e){try{let t=new Date(e);return!/^\d{4}-\d{2}-\d{2}$/.test(e)||isNaN(t.getTime())}catch{return!0}}let Vs;async function Hs(){return Vs||=new(await(import(`./sqids-BjCHarkR.js`))).default,Vs}async function Us(e){return(await Hs()).encode([e])}async function Ws(e){let[t]=(await Hs()).decode(e);return t}async function Gs(e){try{return await e()}catch{return!1}}var Ks=class{#e=new ho.JSONRPCServer;#t;#n;#r=new Map;#i=new Map;#a=new Map;#o=new mo;roots=[];#s={"ref/prompt":new Map,"ref/resource":new Map};#c=new EventTarget;#l=new m;constructor(e,t){this.#n=t,this.#e.addMethod(`initialize`,n=>{try{let r=Xo(ds,n);if(Bs(r.protocolVersion))throw new X(-32602,`Invalid protocol version format`);let i=zs(r.protocolVersion);return this.#c.dispatchEvent(new CustomEvent(`initialize`,{detail:r})),{protocolVersion:i,...t,serverInfo:e}}catch(e){throw e instanceof X?e:e.message?.includes(`Protocol version`)?new X(-32602,`Protocol version validation failed: ${e.message}. Server supports: ${Rs().join(`, `)}`):new X(-32603,`Initialization failed: ${e.message}`)}}),this.#e.addMethod(`ping`,()=>({})),this.#e.addMethod(`notifications/initialized`,()=>null),this.#m(),this.#h(),this.#g(),this.#_(),this.#y(),this.#b()}withContext(){return this}get#u(){return this.#l.getStore()?.progress_token}get ctx(){let{progress_token:e,...t}=this.#l.getStore()??{};return t}get#d(){return this.#l.getStore()?.sessionInfo?.clientCapabilities}currentClientInfo(){return this.#l.getStore()?.sessionInfo?.clientInfo}currentClientCapabilities(){return this.#d}#f(){this.#t||=new ho.JSONRPCClient((e,t)=>{if(t===`broadcast`){this.#c.dispatchEvent(new CustomEvent(`broadcast`,{detail:{request:e}}));return}this.#c.dispatchEvent(new CustomEvent(`send`,{detail:{request:e}}))})}on(e,t,n){(e===`send`||e===`broadcast`)&&this.#f();let r=e=>{t(e.detail)};return this.#c.addEventListener(e,r,n),()=>{this.#c.removeEventListener(e,r,n)}}#p(e,t,n=`standalone`){this.#t?.notify(e,t,n)}#m(){this.#n.capabilities?.tools&&(this.#e.addMethod(`tools/list`,async()=>({tools:(await Promise.all([...this.#r].map(async([e,t])=>t.enabled!=null&&await Gs(t.enabled)===!1?null:{name:e,title:t.title||t.description,description:t.description,icons:t.icons,_meta:t._meta,inputSchema:t.schema&&this.#n.adapter?await this.#n.adapter.toJsonSchema(t.schema):{type:`object`,properties:{}},...t.outputSchema&&this.#n.adapter?{outputSchema:await this.#n.adapter.toJsonSchema(t.outputSchema)}:{},...t.annotations?{annotations:t.annotations}:{}}))).filter(e=>e!==null)})),this.#e.addMethod(`tools/call`,async({name:e,arguments:t})=>{let n=this.#r.get(e);if(!n)return{isError:!0,content:[{type:`text`,text:`Tool ${e} not found`}]};let r=t;if(n.schema){let i=n.schema[`~standard`].validate(t);if(i instanceof Promise&&(i=await i),i.issues)return{isError:!0,content:[{type:`text`,text:`Invalid arguments for tool ${e}: ${JSON.stringify(i.issues)}`}]};r=i.value}let i=Xo(Ds,n.schema?await n.execute(r):await n.execute());if(n.outputSchema&&i.structuredContent!==void 0){let t=n.outputSchema[`~standard`].validate(i.structuredContent);if(t instanceof Promise&&(t=await t),t.issues)return{isError:!0,content:[{type:`text`,text:`Tool ${e} returned invalid structured content: ${JSON.stringify(t.issues)}`}]};i.structuredContent=t.value}return i}))}#h(){this.#n.capabilities?.prompts&&(this.#e.addMethod(`prompts/list`,async({cursor:e}={})=>{let t=(await Promise.all([...this.#i].map(async([e,t])=>{if(t.enabled!=null&&await Gs(t.enabled)===!1)return null;let n=t.schema&&this.#n.adapter?await this.#n.adapter.toJsonSchema(t.schema):{type:`object`,properties:{},required:[]},r=Object.keys(n.properties??{}),i=n.required??[];return{name:e,title:t.title||t.description,icons:t.icons,description:t.description,arguments:r.map(e=>{let t=n.properties?.[e],r=t&&t!==!0?t.description:e;return{name:e,required:i.includes(e),description:r}})}}))).filter(e=>e!==null),n=this.#n.pagination?.prompts;if(!n||n.size==null)return{prompts:t};let r=n.size,i=e?await Ws(e):0,a=i+r,o=t.slice(i,a),s=a<t.length?await Us(a):null;return{prompts:o,...s&&{nextCursor:s}}}),this.#e.addMethod(`prompts/get`,async({name:e,arguments:t})=>{let n=this.#i.get(e);if(!n)throw new X(-32601,`Prompt ${e} not found`);if(!n.schema)return Xo(Es,await n.execute());let r=n.schema[`~standard`].validate(t);if(r instanceof Promise&&(r=await r),r.issues)throw new X(-32602,`Invalid arguments for prompt ${e}: ${JSON.stringify(r.issues)}`);return Xo(Es,await n.execute(r.value))}))}#g(){this.#n.capabilities?.resources&&(this.#n.capabilities?.resources?.subscribe&&this.#e.addMethod(`resources/subscribe`,async({uri:e})=>(this.#c.dispatchEvent(new CustomEvent(`subscription`,{detail:{uri:e}})),{})),this.#e.addMethod(`resources/list`,async({cursor:e}={})=>{let t=[];for(let[e,{description:n,name:r,title:i,icons:a,...o}]of this.#a)if(o.template){if(o.list_resources){if(o.enabled!=null&&await Gs(o.enabled)===!1)continue;let e=await o.list_resources();t.push(...e)}}else{if(o.enabled!=null&&await Gs(o.enabled)===!1)continue;t.push({name:r,title:i||n,description:n,uri:e,icons:a})}let n=this.#n.pagination?.resources;if(!n||n.size==null)return{resources:t};let r=n.size,i=e?await Ws(e):0,a=i+r,o=t.slice(i,a),s=a<t.length?await Us(a):null;return{resources:o,...s&&{nextCursor:s}}}),this.#e.addMethod(`resources/templates/list`,async()=>({resourceTemplates:(await Promise.all([...this.#a].map(async([e,{description:t,name:n,title:r,template:i,icons:a,enabled:o}])=>!i||o!=null&&await Gs(o)===!1?null:{name:n,icons:a,title:r||t,description:t,uriTemplate:e}))).filter(e=>e!=null)})),this.#e.addMethod(`resources/read`,async({uri:e})=>{let t=this.#a.get(e),n;if(!t){let r=this.#o.match(e);if(r&&(t=this.#a.get(r.template),n=r.params),!t)throw new X(-32601,`Resource ${e} not found`)}if(t.template){if(!n)throw new X(-32602,`Missing parameters for template resource`);return Xo(ys,await t.execute(e,n))}return Xo(ys,await t.execute(e))}))}#_(){this.#e.addMethod(`notifications/roots/list_changed`,()=>(this.#v(),null))}async#v(){if(this.#d?.roots){this.#f();try{this.roots=(await this.#t?.request(`roots/list`,void 0,`standalone`))?.roots||[]}catch{this.roots=[]}}}#y(){this.#e.addMethod(`completion/complete`,async({argument:e,ref:t,context:n})=>{let r=this.#s[t.type];if(!r)return null;let i=r.get(t.uri??t.name);if(!i)return null;let a=i[e.name];return a?Xo(Ns,await a(e.value,n)):null})}#b(){this.#n.capabilities?.logging&&this.#e.addMethod(`logging/setLevel`,({level:e})=>(this.#c.dispatchEvent(new CustomEvent(`loglevelchange`,{detail:{level:e}})),{}))}#x(){this.#n.capabilities?.tools?.listChanged&&this.#p(`notifications/tools/list_changed`,{},`broadcast`)}#S(){this.#n.capabilities?.prompts?.listChanged&&this.#p(`notifications/prompts/list_changed`,{},`broadcast`)}#C(){this.#n.capabilities?.resources?.listChanged&&this.#p(`notifications/resources/list_changed`,{},`broadcast`)}tool({name:e,description:t,title:n,schema:r,outputSchema:i,annotations:a,enabled:o,icons:s,_meta:c},l){this.#x(),this.#r.set(e,{description:t,title:n,enabled:o,schema:r,outputSchema:i,execute:l,annotations:a,icons:s,_meta:c})}prompt({name:e,description:t,title:n,schema:r,complete:i,enabled:a,icons:o},s){i&&this.#s[`ref/prompt`].set(e,i),this.#S(),this.#i.set(e,{description:t,title:n,schema:r,execute:s,enabled:a,icons:o})}#w({uri:e,complete:t,...n}){t&&this.#s[`ref/resource`].set(e,t),n.template&&this.#o.add(e),this.#C(),this.#a.set(e,n)}resource({name:e,description:t,title:n,uri:r,enabled:i,icons:a},o){this.#w({name:e,description:t,title:n,uri:r,execute:o,enabled:i,icons:a,template:!1})}template({name:e,description:t,title:n,uri:r,complete:i,list:a,enabled:o,icons:s},c){this.#w({name:e,enabled:o,description:t,title:n,uri:r,execute:c,complete:i,icons:s,list_resources:a,template:!0})}receive(e,t){let n=Zo(qo([rs,is]),e);if(n.success){let e=n.output.params?._meta?.progressToken;return this.#l.run({...t??{},progress_token:e},async()=>await this.#e.receive(n.output))}let r=Xo(qo([as,os]),e);return this.#f(),this.#l.run(t??{},async()=>this.#t?.receive(r))}changed(...e){let[t,n]=e;if(t===`prompts`)this.#S();else if(t===`tools`)this.#x();else if(t===`resources`)this.#C();else{let e=this.#a.get(n);if(!e)return;this.#p(`notifications/resources/updated`,{uri:n,title:e.name},`broadcast`)}}async refreshRoots(){await this.#v()}async elicitation(e,t){if(!this.#d?.elicitation)throw new X(-32601,`Client doesn't support elicitation`);this.#f();let n=Xo(Ms,await this.#t?.request(`elicitation/create`,{message:e,requestedSchema:await this.#n.adapter?.toJsonSchema(t)},`standalone`)),r=t[`~standard`].validate(n.content);if(r instanceof Promise&&(r=await r),r.issues)throw new X(-32603,`Invalid elicitation result: ${JSON.stringify(r.issues)}`);return{...n,content:r.value}}async message(e){if(!this.#d?.sampling)throw new X(-32601,`Client doesn't support sampling`);this.#f();let t=Xo(As,e);return Xo(js,await this.#t?.request(`sampling/createMessage`,t,`standalone`))}progress(e,t=1,n=void 0){this.#u!=null&&this.#p(`notifications/progress`,{progress:e,total:t,message:n,progressToken:this.#u})}log(e,t,n){if(!this.#n.capabilities?.logging)throw new X(-32601,`The server doesn't support logging, please enable it in capabilities`);let r=this.#l.getStore()?.sessionInfo?.logLevel??this.#n.logging?.default??`info`;r&&this.#T(e,r)&&this.#p(`notifications/message`,{level:e,data:t,logger:n})}#T(e,t){let n=[`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`];return n.indexOf(e)>=n.indexOf(t)}},qs=`0.0.1-beta.21`;const Js={cwd:Oi().describe(`The path of the current working directory. Used to find the jsrepo.config file.`)},Ys=new Fa,Xs=new Ks({name:`jsrepo`,version:qs,description:`An MCP server for adding, viewing, and searching items from jsrepo registries.`},{adapter:Ys,capabilities:{tools:{listChanged:!0}}});Xs.tool({name:`add_item_to_project`,description:`Add a registry item or items to the users project.`,schema:sa({cwd:Js.cwd,itemNames:aa(Oi().describe('The registry and name of the item to add `<registry>/<item-name>`. i.e. "github/ieedan/std/math", "@ieedan/std/math", "https://example.com/registry/math"')).describe(`Fully qualifed registry items to add. i.e. ["github/ieedan/std/math", "@ieedan/std/math", "https://example.com/registry/math"]`),withExamples:$i().optional().describe(`Add items with examples.`),withDocs:$i().optional().describe(`Add items with docs.`),withTests:$i().optional().describe(`Add items with tests.`)})},async({itemNames:e,...t})=>{let m=await c({cwd:t.cwd,promptForContinueIfNull:!1}),h=m?.config?.providers??l,{wantedItems:ee,neededRegistries:g}=u(e,{providers:h,registries:m?.config?.registries??[]}).match(e=>e,e=>{throw e}),_=(await o((await p(ee,{resolvedRegistries:(await f(g,{cwd:t.cwd,providers:h})).match(e=>e,e=>{throw e}),nonInteractive:!0})).match(e=>e,e=>{throw e}),{options:{withExamples:t.withExamples??!1,withDocs:t.withDocs??!1,withTests:t.withTests??!1}})).match(e=>e,e=>{throw e}),v=await n({items:_,config:m?.config,options:{cwd:t.cwd,yes:!0}});if(v.isErr())return{content:[{type:`text`,text:Va`
|
|
32
|
+
Failed to get paths for items: ${v.error.message}.
|
|
33
|
+
You will need to add the paths to the users config file (if they aren't already added) like so:
|
|
34
|
+
\`\`\`
|
|
35
|
+
import { defineConfig } from "jsrepo";
|
|
34
36
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
+
export default defineConfig({
|
|
38
|
+
// ...
|
|
39
|
+
paths: {
|
|
40
|
+
// ...
|
|
41
|
+
${_.map(e=>`"${r(e.type)}": "put the expected path here",`).join(`
|
|
37
42
|
`)}
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
\`\`\`
|
|
46
|
+
`}]};let{itemPaths:te,resolvedPaths:y}=v.value,{neededDependencies:b,neededEnvVars:x,neededFiles:S}=(await i({configResult:m,options:{cwd:t.cwd,yes:!0,withExamples:t.withExamples??!1,withDocs:t.withDocs??!1,withTests:t.withTests??!1},itemPaths:te,resolvedPaths:y,items:_})).match(e=>e,e=>{throw e});return await s({files:S,options:{overwrite:!0,cwd:t.cwd,expand:!1,maxUnchanged:10}}),x&&await a(x,{options:{cwd:t.cwd,yes:!0}}),await d(b,{options:{cwd:t.cwd,yes:!0},config:m?.config}),{content:[{type:`text`,text:Va`Added ${_.length} items to the users project:
|
|
47
|
+
${_.map(e=>Zs(e)).join(`
|
|
48
|
+
`)}`}]}}),Xs.tool({name:`view_registry_item`,description:`View the code and information about a registry item.`,schema:sa({cwd:Js.cwd,item:Oi().describe('The registry and name of the item to add `<registry>/<item-name>`. i.e. "github/ieedan/std/math", "@ieedan/std/math", "https://example.com/registry/math"')})},async({cwd:e,item:n})=>{let r=await c({cwd:e,promptForContinueIfNull:!1}),i=r?.config?.providers??l,a=r?.config?.registries??[],{wantedItems:s,neededRegistries:d}=u([n],{providers:i,registries:a}).match(e=>e,e=>{throw e}),m=(await o((await p(s,{resolvedRegistries:(await f(d,{cwd:e,providers:i})).match(e=>e,e=>{throw e}),nonInteractive:!0})).match(e=>e,e=>{throw e}),{options:{withExamples:!1,withDocs:!1,withTests:!1}})).match(e=>e,e=>{throw e}),h=s[0],ee=m.find(e=>e.name===h.itemName);if(!ee)throw new t(h.itemName,h.registryUrl);return{content:[{type:`text`,text:Zs(ee)}]}}),Xs.tool({name:`list_items_in_registry`,description:`List items in a registry. You can optionally provide a query to filter the results.`,schema:sa({cwd:Js.cwd,registries:aa(Oi()).describe(`The registries to search for items in. i.e. ["github/ieedan/std", "@ieedan/std"]`),query:Oi().optional().describe(`The query to search for. i.e. "math"`),limit:Yi().optional().describe(`The maximum number of items to return. Defaults to 10.`),offset:Yi().optional().describe(`The numbers to skip for pagination.`)})},async({cwd:e,registries:t,query:n,limit:r,offset:i})=>{let a=r??10,o=i??0,s=(await f(t,{cwd:e,providers:(await c({cwd:e,promptForContinueIfNull:!1}))?.config?.providers??l})).match(e=>e,e=>{throw e}),u=Array.from(s.values()).flatMap(e=>e.manifest.items.map(t=>({item:t,registry:e}))),d;if(n){let e=go.default.go(n,u,{keys:[`item.name`,`item.description`,`item.type`]});if(e.length===0)return{content:[{type:`text`,text:Va`
|
|
49
|
+
No results found for "${n}".
|
|
50
|
+
`}]};d=e.map(e=>e.obj)}else d=u;let p=d.slice(o,Math.min(o+a,d.length));function m(e){return Va`
|
|
51
|
+
## ${e.registry.url}/${e.item.name} - ${e.item.type}
|
|
52
|
+
${e.item.description??``}
|
|
38
53
|
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
Files:
|
|
55
|
+
${e.item.files.map(e=>`- ${e.path}`).join(`
|
|
41
56
|
`)}
|
|
57
|
+
`}return{content:[{type:`text`,text:Va`
|
|
58
|
+
# Search results
|
|
59
|
+
Found ${d.length} results for "${n}".
|
|
60
|
+
Showing ${p.length} results.
|
|
42
61
|
|
|
43
|
-
|
|
44
|
-
${_.files?.filter(e=>e.type===`registry:example`).map(e=>`\`\`\`${e.path}\n${e.contents}\n\`\`\``).join(`
|
|
62
|
+
${p.map(m).join(`
|
|
45
63
|
`)}
|
|
64
|
+
`}]}});function Zs(e){return Va`
|
|
65
|
+
# ${e.name} - ${e.type}
|
|
66
|
+
${e.description??``}
|
|
46
67
|
|
|
47
|
-
|
|
48
|
-
|
|
68
|
+
## Files
|
|
69
|
+
${e.files?.filter(e=>e.role===void 0||e.role===`file`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
49
70
|
`)}
|
|
50
71
|
|
|
51
|
-
|
|
52
|
-
|
|
72
|
+
## Dependencies
|
|
73
|
+
${e.dependencies?.map(e=>`- ${typeof e==`string`?e:e.name}`).join(`
|
|
53
74
|
`)}
|
|
54
75
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
\`\`\`env
|
|
58
|
-
${Object.entries(_.envVars??{}).map(([e,t])=>`${e}="${t}"`).join(`
|
|
76
|
+
## Examples
|
|
77
|
+
${e.files?.filter(e=>e.role===`example`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
59
78
|
`)}
|
|
60
|
-
\`\`\`
|
|
61
|
-
`}]}}),Xs.tool({name:`search_items_in_registry`,description:`Search for a registry item.`,schema:sa({cwd:Js.cwd,registries:aa(Oi()).describe(`The registries to search for items in. i.e. ["github/ieedan/std", "@ieedan/std"]`),query:Oi().describe(`The query to search for. i.e. "math"`),limit:Yi().optional().describe(`The maximum number of items to return. Defaults to 10.`),offset:Yi().optional().describe(`The numbers to skip for pagination.`)})},async({cwd:e,registries:t,query:n,limit:r,offset:i})=>{let a=r??10,o=i??0,s=(await f(t,{cwd:e,providers:(await c({cwd:e,promptForContinueIfNull:!1}))?.config?.providers??l})).match(e=>e,e=>{throw e}),u=Array.from(s.values()).flatMap(e=>e.manifest.items.map(t=>({item:t,registry:e}))),d=go.default.go(n,u,{keys:[`item.name`,`item.description`,`item.type`]});if(d.length===0)return{content:[{type:`text`,text:Va`
|
|
62
|
-
No results found for "${n}".
|
|
63
|
-
`}]};let p=d.slice(o,Math.min(o+a,d.length)).map(e=>e.obj);function m(e){return Va`
|
|
64
|
-
## ${e.item.name} - ${e.item.type}
|
|
65
|
-
${e.item.description}
|
|
66
79
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
Found ${d.length} results for "${n}".
|
|
71
|
-
Showing ${p.length} results.
|
|
80
|
+
## Docs
|
|
81
|
+
${e.files?.filter(e=>e.role===`doc`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
82
|
+
`)}
|
|
72
83
|
|
|
73
|
-
|
|
84
|
+
## Tests
|
|
85
|
+
${e.files?.filter(e=>e.role===`test`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
86
|
+
`)}
|
|
87
|
+
|
|
88
|
+
## Environment Variables
|
|
89
|
+
Environment variables are required for the item to work. Blank variables will need to be filled in.
|
|
90
|
+
\`\`\`env
|
|
91
|
+
${Object.entries(e.envVars??{}).map(([e,t])=>`${e}="${t}"`).join(`
|
|
74
92
|
`)}
|
|
75
|
-
|
|
93
|
+
\`\`\`
|
|
94
|
+
`}new S(Xs).listen(),process.stdout.write(`Server running...
|
|
76
95
|
`),process.stdout.write(C.default.dim(`Press ${C.default.bold(`Ctrl+C`)} to exit\n`));export{};
|
|
77
96
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsrepo/mcp",
|
|
3
3
|
"description": "An MCP server for jsrepo.",
|
|
4
|
-
"version": "0.0.1-beta.
|
|
4
|
+
"version": "0.0.1-beta.21",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://v3.jsrepo.dev/docs/mcp",
|
|
7
7
|
"author": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"!dist/**/*.map"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"jsrepo": "3.0.0-beta.
|
|
32
|
+
"jsrepo": "3.0.0-beta.20"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@tmcp/adapter-zod": "^0.1.7",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"start": "node ./dist/index.js mcp",
|
|
52
52
|
"check": "tsc --noEmit",
|
|
53
53
|
"mcp:inspector": "pnpm dlx @modelcontextprotocol/inspector node ./dist/index.js mcp",
|
|
54
|
-
"test": "vitest"
|
|
54
|
+
"test": "vitest",
|
|
55
|
+
"bundle-analyze": "FORCE_COLOR=1 node ../../bundle-analyzer/dist/index.js analyze ."
|
|
55
56
|
}
|
|
56
57
|
}
|