@jsrepo/mcp 0.0.9 → 0.0.11
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/dist/index.mjs +118 -0
- package/dist/{sqids-BjCHarkR.js → sqids-BiDaWurc.mjs} +2 -2
- package/package.json +14 -14
- package/dist/index.js +0 -101
- /package/dist/{index.d.ts → index.d.mts} +0 -0
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
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)),ne=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)+`
|
|
3
|
+
`)})),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)+`
|
|
4
|
+
`)})),this.#t.add(this.#e.on(`loglevelchange`,({level:e})=>{this.#n.logLevel=e})),this.#t.add(this.#e.on(`subscription`,({uri:e,action:t})=>{this.#r??={resource:[]},t===`remove`?this.#r.resource=this.#r.resource?.filter(t=>t!==e):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(`
|
|
5
|
+
`);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)+`
|
|
6
|
+
`)}catch{}}),e.stdin.on(`end`,()=>{this.#i()}),e.on(`SIGINT`,()=>{this.#i()}),e.on(`SIGTERM`,()=>{this.#i()})}},S=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),C=class{toJsonSchema(e){throw Error(`toJsonSchema method not implemented`)}};Object.freeze({status:`aborted`});function w(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}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 T=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},re=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};const ie={};function E(e){return e&&Object.assign(ie,e),ie}function ae(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 D(e,t){return typeof t==`bigint`?t.toString():t}function oe(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function O(e){return e==null}function se(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function ce(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 k=Symbol(`evaluating`);function A(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==k)return r===void 0&&(r=k,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function le(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function j(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function M(e){return JSON.stringify(e)}function ue(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}const de=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function fe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const pe=oe(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function me(e){if(fe(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(fe(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function he(e){return me(e)?{...e}:Array.isArray(e)?[...e]:e}const ge=new Set([`string`,`number`,`symbol`]);function _e(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ve(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function N(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 ye(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}const be={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function xe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return ve(e,j(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 le(this,`shape`,e),e},checks:[]}))}function Se(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return ve(e,j(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 le(this,`shape`,r),r},checks:[]}))}function Ce(e,t){if(!me(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ve(e,j(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return le(this,`shape`,n),n}}))}function we(e,t){if(!me(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ve(e,j(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return le(this,`shape`,n),n}}))}function Te(e,t){return ve(e,j(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return le(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function Ee(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return ve(t,j(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 le(this,`shape`,i),i},checks:[]}))}function De(e,t,n){return ve(t,j(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 le(this,`shape`,i),i}}))}function Oe(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 ke(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ae(e){return typeof e==`string`?e:e?.message}function je(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=Ae(e.inst?._zod.def?.error?.(e))??Ae(t?.error?.(e))??Ae(n.customError?.(e))??Ae(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function Me(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Ne(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}const Pe=(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,D,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Fe=w(`$ZodError`,Pe),Ie=w(`$ZodError`,Pe,{Parent:Error});function Le(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 Re(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 ze=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 T;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>je(e,a,E())));throw de(t,i?.callee),t}return o.value},Be=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=>je(e,a,E())));throw de(t,i?.callee),t}return o.value},Ve=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 T;return a.issues.length?{success:!1,error:new(e??Fe)(a.issues.map(e=>je(e,i,E())))}:{success:!0,data:a.value}},He=Ve(Ie),Ue=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=>je(e,i,E())))}:{success:!0,data:a.value}},We=Ue(Ie),Ge=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return ze(e)(t,n,i)},Ke=e=>(t,n,r)=>ze(e)(t,n,r),qe=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Be(e)(t,n,i)},Je=e=>async(t,n,r)=>Be(e)(t,n,r),Ye=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Ve(e)(t,n,i)},Xe=e=>(t,n,r)=>Ve(e)(t,n,r),Ze=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Ue(e)(t,n,i)},Qe=e=>async(t,n,r)=>Ue(e)(t,n,r),$e=/^[cC][^\s-]{8,}$/,et=/^[0-9a-z]+$/,tt=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,nt=/^[0-9a-vA-V]{20}$/,rt=/^[A-Za-z0-9]{27}$/,it=/^[a-zA-Z0-9_-]{21}$/,at=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ot=/^([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})$/,st=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)$/,ct=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;function lt(){return RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)}const 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])$/,dt=/^(([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}|:))$/,ft=/^((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])$/,pt=/^(([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])$/,mt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ht=/^[A-Za-z0-9_-]*$/,gt=/^\+[1-9]\d{6,14}$/,_t=`(?:(?:\\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])))`,vt=RegExp(`^${_t}$`);function yt(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 bt(e){return RegExp(`^${yt(e)}$`)}function xt(e){let t=yt({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(`^${_t}T(?:${r})$`)}const St=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},Ct=/^-?\d+$/,wt=/^-?\d+(?:\.\d+)?$/,Tt=/^(?:true|false)$/i,Et=/^[^A-Z]*$/,Dt=/^[^a-z]*$/,P=w(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Ot={number:`number`,bigint:`bigint`,object:`date`},kt=w(`$ZodCheckLessThan`,(e,t)=>{P.init(e,t);let n=Ot[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:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),At=w(`$ZodCheckGreaterThan`,(e,t)=>{P.init(e,t);let n=Ot[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:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),jt=w(`$ZodCheckMultipleOf`,(e,t)=>{P.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):ce(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})}}),Mt=w(`$ZodCheckNumberFormat`,(e,t)=>{P.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=be[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=Ct)}),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,inclusive:!0,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,inclusive:!0,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,inclusive:!0,inst:e,continue:!t.abort})}}),Nt=w(`$ZodCheckMaxLength`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!O(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=Me(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Pt=w(`$ZodCheckMinLength`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!O(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=Me(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ft=w(`$ZodCheckLengthEquals`,(e,t)=>{var n;P.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!O(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=Me(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})}}),It=w(`$ZodCheckStringFormat`,(e,t)=>{var n,r;P.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=()=>{})}),Lt=w(`$ZodCheckRegex`,(e,t)=>{It.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})}}),Rt=w(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=Et,It.init(e,t)}),zt=w(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Dt,It.init(e,t)}),Bt=w(`$ZodCheckIncludes`,(e,t)=>{P.init(e,t);let n=_e(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})}}),Vt=w(`$ZodCheckStartsWith`,(e,t)=>{P.init(e,t);let n=RegExp(`^${_e(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})}}),Ht=w(`$ZodCheckEndsWith`,(e,t)=>{P.init(e,t);let n=RegExp(`.*${_e(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})}}),Ut=w(`$ZodCheckOverwrite`,(e,t)=>{P.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});var Wt=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(`
|
|
7
|
+
`).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(`
|
|
8
|
+
`))}};const Gt={major:4,minor:3,patch:5},F=w(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Gt;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=Oe(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 T;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Oe(e,t))});else{if(e.issues.length===t)continue;r||=Oe(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Oe(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new T;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 T;return o.then(e=>t(e,r,a))}return t(o,r,a)}}A(e,`~standard`,()=>({validate:t=>{try{let n=He(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return We(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Kt=w(`$ZodString`,(e,t)=>{F.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??St(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}}),I=w(`$ZodStringFormat`,(e,t)=>{It.init(e,t),Kt.init(e,t)}),qt=w(`$ZodGUID`,(e,t)=>{t.pattern??=ot,I.init(e,t)}),Jt=w(`$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??=st(e)}else t.pattern??=st();I.init(e,t)}),Yt=w(`$ZodEmail`,(e,t)=>{t.pattern??=ct,I.init(e,t)}),Xt=w(`$ZodURL`,(e,t)=>{I.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:t.hostname.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})}}}),Zt=w(`$ZodEmoji`,(e,t)=>{t.pattern??=lt(),I.init(e,t)}),Qt=w(`$ZodNanoID`,(e,t)=>{t.pattern??=it,I.init(e,t)}),$t=w(`$ZodCUID`,(e,t)=>{t.pattern??=$e,I.init(e,t)}),en=w(`$ZodCUID2`,(e,t)=>{t.pattern??=et,I.init(e,t)}),tn=w(`$ZodULID`,(e,t)=>{t.pattern??=tt,I.init(e,t)}),nn=w(`$ZodXID`,(e,t)=>{t.pattern??=nt,I.init(e,t)}),rn=w(`$ZodKSUID`,(e,t)=>{t.pattern??=rt,I.init(e,t)}),an=w(`$ZodISODateTime`,(e,t)=>{t.pattern??=xt(t),I.init(e,t)}),on=w(`$ZodISODate`,(e,t)=>{t.pattern??=vt,I.init(e,t)}),sn=w(`$ZodISOTime`,(e,t)=>{t.pattern??=bt(t),I.init(e,t)}),cn=w(`$ZodISODuration`,(e,t)=>{t.pattern??=at,I.init(e,t)}),ln=w(`$ZodIPv4`,(e,t)=>{t.pattern??=ut,I.init(e,t),e._zod.bag.format=`ipv4`}),un=w(`$ZodIPv6`,(e,t)=>{t.pattern??=dt,I.init(e,t),e._zod.bag.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})}}}),dn=w(`$ZodCIDRv4`,(e,t)=>{t.pattern??=ft,I.init(e,t)}),fn=w(`$ZodCIDRv6`,(e,t)=>{t.pattern??=pt,I.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 pn(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const mn=w(`$ZodBase64`,(e,t)=>{t.pattern??=mt,I.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{pn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function hn(e){if(!ht.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return pn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}const gn=w(`$ZodBase64URL`,(e,t)=>{t.pattern??=ht,I.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{hn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),_n=w(`$ZodE164`,(e,t)=>{t.pattern??=gt,I.init(e,t)});function vn(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 yn=w(`$ZodJWT`,(e,t)=>{I.init(e,t),e._zod.check=n=>{vn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),bn=w(`$ZodNumber`,(e,t)=>{F.init(e,t),e._zod.pattern=e._zod.bag.pattern??wt,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}}),xn=w(`$ZodNumberFormat`,(e,t)=>{Mt.init(e,t),bn.init(e,t)}),Sn=w(`$ZodBoolean`,(e,t)=>{F.init(e,t),e._zod.pattern=Tt,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}}),Cn=w(`$ZodUnknown`,(e,t)=>{F.init(e,t),e._zod.parse=e=>e}),wn=w(`$ZodNever`,(e,t)=>{F.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Tn(e,t,n){e.issues.length&&t.issues.push(...ke(n,e.issues)),t.value[n]=e.value}const En=w(`$ZodArray`,(e,t)=>{F.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=>Tn(t,n,e))):Tn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Dn(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...ke(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function On(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=ye(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function kn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in 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=>Dn(e,n,i,t,u))):Dn(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}const An=w(`$ZodObject`,(e,t)=>{if(F.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=oe(()=>On(t));A(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=fe,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],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>Dn(n,t,e,s,r))):Dn(i,t,e,s,r)}return i?kn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),jn=w(`$ZodObjectJIT`,(e,t)=>{An.init(e,t);let n=e._zod.parse,r=oe(()=>On(t)),i=e=>{let t=new Wt([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=M(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 r of n.keys){let n=a[r],o=M(r),s=e[r]?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),s?t.write(`
|
|
9
|
+
if (${n}.issues.length) {
|
|
10
|
+
if (${o} in input) {
|
|
11
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
12
|
+
...iss,
|
|
13
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
14
|
+
})));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (${n}.value === undefined) {
|
|
19
|
+
if (${o} in input) {
|
|
20
|
+
newResult[${o}] = undefined;
|
|
21
|
+
}
|
|
22
|
+
} else {
|
|
23
|
+
newResult[${o}] = ${n}.value;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
`):t.write(`
|
|
27
|
+
if (${n}.issues.length) {
|
|
28
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
29
|
+
...iss,
|
|
30
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
31
|
+
})));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (${n}.value === undefined) {
|
|
35
|
+
if (${o} in input) {
|
|
36
|
+
newResult[${o}] = undefined;
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
newResult[${o}] = ${n}.value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=fe,s=!ie.jitless,c=s&&pe.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?kn([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function Mn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Oe(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>je(e,r,E())))}),t)}const Nn=w(`$ZodUnion`,(e,t)=>{F.init(e,t),A(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),A(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),A(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),A(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>se(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Mn(t,i,e,a)):Mn(s,i,e,a)}}),Pn=w(`$ZodIntersection`,(e,t)=>{F.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>In(e,t,n)):In(e,i,a)}});function Fn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(me(e)&&me(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Fn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Fn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function In(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),Oe(e))return e;let o=Fn(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const Ln=w(`$ZodEnum`,(e,t)=>{F.init(e,t);let n=ae(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ge.has(typeof e)).map(e=>typeof e==`string`?_e(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Rn=w(`$ZodTransform`,(e,t)=>{F.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new re(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new T;return n.value=i,n}});function zn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const Bn=w(`$ZodOptional`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),A(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${se(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>zn(t,e.value)):zn(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Vn=w(`$ZodExactOptional`,(e,t)=>{Bn.init(e,t),A(e._zod,`values`,()=>t.innerType._zod.values),A(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Hn=w(`$ZodNullable`,(e,t)=>{F.init(e,t),A(e._zod,`optin`,()=>t.innerType._zod.optin),A(e._zod,`optout`,()=>t.innerType._zod.optout),A(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${se(e.source)}|null)$`):void 0}),A(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Un=w(`$ZodDefault`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Wn(e,t)):Wn(r,t)}});function Wn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Gn=w(`$ZodPrefault`,(e,t)=>{F.init(e,t),e._zod.optin=`optional`,A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Kn=w(`$ZodNonOptional`,(e,t)=>{F.init(e,t),A(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>qn(t,e)):qn(i,e)}});function qn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Jn=w(`$ZodCatch`,(e,t)=>{F.init(e,t),A(e._zod,`optin`,()=>t.innerType._zod.optin),A(e._zod,`optout`,()=>t.innerType._zod.optout),A(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>je(e,n,E()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>je(e,n,E()))},input:e.value}),e.issues=[]),e)}}),Yn=w(`$ZodPipe`,(e,t)=>{F.init(e,t),A(e._zod,`values`,()=>t.in._zod.values),A(e._zod,`optin`,()=>t.in._zod.optin),A(e._zod,`optout`,()=>t.out._zod.optout),A(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Xn(e,t.in,n)):Xn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Xn(e,t.out,n)):Xn(r,t.out,n)}});function Xn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Zn=w(`$ZodReadonly`,(e,t)=>{F.init(e,t),A(e._zod,`propValues`,()=>t.innerType._zod.propValues),A(e._zod,`values`,()=>t.innerType._zod.values),A(e._zod,`optin`,()=>t.innerType?._zod?.optin),A(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Qn):Qn(r)}});function Qn(e){return e.value=Object.freeze(e.value),e}const $n=w(`$ZodCustom`,(e,t)=>{P.init(e,t),F.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>er(t,n,r,e));er(i,n,r,e)}});function er(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ne(e))}}var tr,nr=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function rr(){return new nr}(tr=globalThis).__zod_globalRegistry??(tr.__zod_globalRegistry=rr());const ir=globalThis.__zod_globalRegistry;function ar(e,t){return new e({type:`string`,...N(t)})}function or(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...N(t)})}function sr(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...N(t)})}function cr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...N(t)})}function lr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...N(t)})}function ur(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...N(t)})}function dr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...N(t)})}function fr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...N(t)})}function pr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...N(t)})}function mr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...N(t)})}function hr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...N(t)})}function gr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...N(t)})}function _r(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...N(t)})}function vr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...N(t)})}function yr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...N(t)})}function br(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...N(t)})}function xr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...N(t)})}function Sr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...N(t)})}function Cr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...N(t)})}function wr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...N(t)})}function Tr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...N(t)})}function Er(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...N(t)})}function Dr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...N(t)})}function Or(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...N(t)})}function kr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...N(t)})}function Ar(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...N(t)})}function jr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...N(t)})}function Mr(e,t){return new e({type:`number`,checks:[],...N(t)})}function Nr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...N(t)})}function Pr(e,t){return new e({type:`boolean`,...N(t)})}function Fr(e){return new e({type:`unknown`})}function Ir(e,t){return new e({type:`never`,...N(t)})}function Lr(e,t){return new kt({check:`less_than`,...N(t),value:e,inclusive:!1})}function Rr(e,t){return new kt({check:`less_than`,...N(t),value:e,inclusive:!0})}function zr(e,t){return new At({check:`greater_than`,...N(t),value:e,inclusive:!1})}function Br(e,t){return new At({check:`greater_than`,...N(t),value:e,inclusive:!0})}function Vr(e,t){return new jt({check:`multiple_of`,...N(t),value:e})}function Hr(e,t){return new Nt({check:`max_length`,...N(t),maximum:e})}function Ur(e,t){return new Pt({check:`min_length`,...N(t),minimum:e})}function Wr(e,t){return new Ft({check:`length_equals`,...N(t),length:e})}function Gr(e,t){return new Lt({check:`string_format`,format:`regex`,...N(t),pattern:e})}function Kr(e){return new Rt({check:`string_format`,format:`lowercase`,...N(e)})}function qr(e){return new zt({check:`string_format`,format:`uppercase`,...N(e)})}function Jr(e,t){return new Bt({check:`string_format`,format:`includes`,...N(t),includes:e})}function Yr(e,t){return new Vt({check:`string_format`,format:`starts_with`,...N(t),prefix:e})}function Xr(e,t){return new Ht({check:`string_format`,format:`ends_with`,...N(t),suffix:e})}function Zr(e){return new Ut({check:`overwrite`,tx:e})}function Qr(e){return Zr(t=>t.normalize(e))}function $r(){return Zr(e=>e.trim())}function ei(){return Zr(e=>e.toLowerCase())}function ti(){return Zr(e=>e.toUpperCase())}function ni(){return Zr(e=>ue(e))}function ri(e,t,n){return new e({type:`array`,element:t,...N(n)})}function ii(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...N(n)})}function ai(e){let t=oi(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Ne(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Ne(r))}},e(n.value,n)));return t}function oi(e,t){let n=new P({check:`custom`,...N(t)});return n._zod.check=e,n}function si(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??ir,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function L(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,L(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&R(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ci(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
43
|
+
|
|
44
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function li(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:di(t,`input`,e.processors),output:di(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function R(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return R(r.element,n);if(r.type===`set`)return R(r.valueType,n);if(r.type===`lazy`)return R(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return R(r.innerType,n);if(r.type===`intersection`)return R(r.left,n)||R(r.right,n);if(r.type===`record`||r.type===`map`)return R(r.keyType,n)||R(r.valueType,n);if(r.type===`pipe`)return R(r.in,n)||R(r.out,n);if(r.type===`object`){for(let e in r.shape)if(R(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(R(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(R(e,n))return!0;return!!(r.rest&&R(r.rest,n))}return!1}const ui=(e,t={})=>n=>{let r=si({...n,processors:t});return L(e,r),ci(r,e),li(r,e)},di=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=si({...i??{},target:a,io:t,processors:n});return L(e,o),ci(o,e),li(o,e)},fi={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},pi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=fi[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},mi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},hi=(e,t,n,r)=>{n.type=`boolean`},gi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`)},_i=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`)},vi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},yi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},bi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`)},xi=(e,t,n,r)=>{n.not={}},Si=(e,t,n,r)=>{},Ci=(e,t,n,r)=>{},wi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`)},Ti=(e,t,n,r)=>{let i=e._zod.def,a=ae(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},Ei=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},Di=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`)},Oi=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},ki=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},Ai=(e,t,n,r)=>{n.type=`boolean`},ji=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Mi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`)},Ni=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Pi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`)},Fi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`)},Ii=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=L(a.element,t,{...r,path:[...r.path,`items`]})},Li=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=L(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=L(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ri=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>L(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},zi=(e,t,n,r)=>{let i=e._zod.def,a=L(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=L(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Bi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>L(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?L(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null;t.target===`draft-2020-12`?(i.prefixItems=c,l&&(i.items=l)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),i.minItems=c.length,l||(i.maxItems=c.length)):(i.items=c,l&&(i.additionalItems=l));let{minimum:u,maximum:d}=e._zod.bag;typeof u==`number`&&(i.minItems=u),typeof d==`number`&&(i.maxItems=d)},Vi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=L(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=L(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=L(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Hi=(e,t,n,r)=>{let i=e._zod.def,a=L(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ui=(e,t,n,r)=>{let i=e._zod.def;L(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Wi=(e,t,n,r)=>{let i=e._zod.def;L(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},Gi=(e,t,n,r)=>{let i=e._zod.def;L(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Ki=(e,t,n,r)=>{let i=e._zod.def;L(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},qi=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;L(a,t,r);let o=t.seen.get(e);o.ref=a},Ji=(e,t,n,r)=>{let i=e._zod.def;L(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Yi=(e,t,n,r)=>{let i=e._zod.def;L(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Xi=(e,t,n,r)=>{let i=e._zod.def;L(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Zi={string:pi,number:mi,boolean:hi,bigint:gi,symbol:_i,null:vi,undefined:yi,void:bi,never:xi,any:Si,unknown:Ci,date:wi,enum:Ti,literal:Ei,nan:Di,template_literal:Oi,file:ki,success:Ai,custom:ji,function:Mi,transform:Ni,map:Pi,set:Fi,array:Ii,object:Li,union:Ri,intersection:zi,tuple:Bi,record:Vi,nullable:Hi,nonoptional:Ui,default:Wi,prefault:Gi,catch:Ki,pipe:qi,readonly:Ji,promise:Yi,optional:Xi,lazy:(e,t,n,r)=>{let i=e._zod.innerType;L(i,t,r);let a=t.seen.get(e);a.ref=i}};function Qi(e,t){if(`_idmap`in e){let n=e,r=si({...t,processors:Zi}),i={};for(let e of n._idmap.entries()){let[t,n]=e;L(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;ci(r,n),a[t]=li(r,n)}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=si({...t,processors:Zi});return L(e,n),ci(n,e),li(n,e)}const $i=w(`ZodISODateTime`,(e,t)=>{an.init(e,t),V.init(e,t)});function ea(e){return Or($i,e)}const ta=w(`ZodISODate`,(e,t)=>{on.init(e,t),V.init(e,t)});function na(e){return kr(ta,e)}const ra=w(`ZodISOTime`,(e,t)=>{sn.init(e,t),V.init(e,t)});function ia(e){return Ar(ra,e)}const aa=w(`ZodISODuration`,(e,t)=>{cn.init(e,t),V.init(e,t)});function oa(e){return jr(aa,e)}const sa=(e,t)=>{Fe.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Re(e,t)},flatten:{value:t=>Le(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,D,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,D,2)}},isEmpty:{get(){return e.issues.length===0}}})};w(`ZodError`,sa);const z=w(`ZodError`,sa,{Parent:Error}),ca=ze(z),la=Be(z),ua=Ve(z),da=Ue(z),fa=Ge(z),pa=Ke(z),ma=qe(z),ha=Je(z),ga=Ye(z),_a=Xe(z),va=Ze(z),ya=Qe(z),B=w(`ZodType`,(e,t)=>(F.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:di(e,`input`),output:di(e,`output`)}}),e.toJSONSchema=ui(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(j(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>ve(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>ca(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>ua(e,t,n),e.parseAsync=async(t,n)=>la(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>da(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>fa(e,t,n),e.decode=(t,n)=>pa(e,t,n),e.encodeAsync=async(t,n)=>ma(e,t,n),e.decodeAsync=async(t,n)=>ha(e,t,n),e.safeEncode=(t,n)=>ga(e,t,n),e.safeDecode=(t,n)=>_a(e,t,n),e.safeEncodeAsync=async(t,n)=>va(e,t,n),e.safeDecodeAsync=async(t,n)=>ya(e,t,n),e.refine=(t,n)=>e.check(Ao(t,n)),e.superRefine=t=>e.check(jo(t)),e.overwrite=t=>e.check(Zr(t)),e.optional=()=>fo(e),e.exactOptional=()=>mo(e),e.nullable=()=>go(e),e.nullish=()=>fo(go(e)),e.nonoptional=t=>So(e,t),e.array=()=>$a(e),e.or=t=>ro([e,t]),e.and=t=>ao(e,t),e.transform=t=>Eo(e,lo(t)),e.default=t=>vo(e,t),e.prefault=t=>bo(e,t),e.catch=t=>wo(e,t),e.pipe=t=>Eo(e,t),e.readonly=()=>Oo(e),e.describe=t=>{let n=e.clone();return ir.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return ir.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return ir.get(e);let n=e.clone();return ir.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),ba=w(`_ZodString`,(e,t)=>{Kt.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Gr(...t)),e.includes=(...t)=>e.check(Jr(...t)),e.startsWith=(...t)=>e.check(Yr(...t)),e.endsWith=(...t)=>e.check(Xr(...t)),e.min=(...t)=>e.check(Ur(...t)),e.max=(...t)=>e.check(Hr(...t)),e.length=(...t)=>e.check(Wr(...t)),e.nonempty=(...t)=>e.check(Ur(1,...t)),e.lowercase=t=>e.check(Kr(t)),e.uppercase=t=>e.check(qr(t)),e.trim=()=>e.check($r()),e.normalize=(...t)=>e.check(Qr(...t)),e.toLowerCase=()=>e.check(ei()),e.toUpperCase=()=>e.check(ti()),e.slugify=()=>e.check(ni())}),xa=w(`ZodString`,(e,t)=>{Kt.init(e,t),ba.init(e,t),e.email=t=>e.check(or(Ca,t)),e.url=t=>e.check(fr(Ea,t)),e.jwt=t=>e.check(Dr(Va,t)),e.emoji=t=>e.check(pr(Da,t)),e.guid=t=>e.check(sr(wa,t)),e.uuid=t=>e.check(cr(Ta,t)),e.uuidv4=t=>e.check(lr(Ta,t)),e.uuidv6=t=>e.check(ur(Ta,t)),e.uuidv7=t=>e.check(dr(Ta,t)),e.nanoid=t=>e.check(mr(Oa,t)),e.guid=t=>e.check(sr(wa,t)),e.cuid=t=>e.check(hr(ka,t)),e.cuid2=t=>e.check(gr(Aa,t)),e.ulid=t=>e.check(_r(ja,t)),e.base64=t=>e.check(wr(Ra,t)),e.base64url=t=>e.check(Tr(za,t)),e.xid=t=>e.check(vr(Ma,t)),e.ksuid=t=>e.check(yr(Na,t)),e.ipv4=t=>e.check(br(Pa,t)),e.ipv6=t=>e.check(xr(Fa,t)),e.cidrv4=t=>e.check(Sr(Ia,t)),e.cidrv6=t=>e.check(Cr(La,t)),e.e164=t=>e.check(Er(Ba,t)),e.datetime=t=>e.check(ea(t)),e.date=t=>e.check(na(t)),e.time=t=>e.check(ia(t)),e.duration=t=>e.check(oa(t))});function Sa(e){return ar(xa,e)}const V=w(`ZodStringFormat`,(e,t)=>{I.init(e,t),ba.init(e,t)}),Ca=w(`ZodEmail`,(e,t)=>{Yt.init(e,t),V.init(e,t)}),wa=w(`ZodGUID`,(e,t)=>{qt.init(e,t),V.init(e,t)}),Ta=w(`ZodUUID`,(e,t)=>{Jt.init(e,t),V.init(e,t)}),Ea=w(`ZodURL`,(e,t)=>{Xt.init(e,t),V.init(e,t)}),Da=w(`ZodEmoji`,(e,t)=>{Zt.init(e,t),V.init(e,t)}),Oa=w(`ZodNanoID`,(e,t)=>{Qt.init(e,t),V.init(e,t)}),ka=w(`ZodCUID`,(e,t)=>{$t.init(e,t),V.init(e,t)}),Aa=w(`ZodCUID2`,(e,t)=>{en.init(e,t),V.init(e,t)}),ja=w(`ZodULID`,(e,t)=>{tn.init(e,t),V.init(e,t)}),Ma=w(`ZodXID`,(e,t)=>{nn.init(e,t),V.init(e,t)}),Na=w(`ZodKSUID`,(e,t)=>{rn.init(e,t),V.init(e,t)}),Pa=w(`ZodIPv4`,(e,t)=>{ln.init(e,t),V.init(e,t)}),Fa=w(`ZodIPv6`,(e,t)=>{un.init(e,t),V.init(e,t)}),Ia=w(`ZodCIDRv4`,(e,t)=>{dn.init(e,t),V.init(e,t)}),La=w(`ZodCIDRv6`,(e,t)=>{fn.init(e,t),V.init(e,t)}),Ra=w(`ZodBase64`,(e,t)=>{mn.init(e,t),V.init(e,t)}),za=w(`ZodBase64URL`,(e,t)=>{gn.init(e,t),V.init(e,t)}),Ba=w(`ZodE164`,(e,t)=>{_n.init(e,t),V.init(e,t)}),Va=w(`ZodJWT`,(e,t)=>{yn.init(e,t),V.init(e,t)}),Ha=w(`ZodNumber`,(e,t)=>{bn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r),e.gt=(t,n)=>e.check(zr(t,n)),e.gte=(t,n)=>e.check(Br(t,n)),e.min=(t,n)=>e.check(Br(t,n)),e.lt=(t,n)=>e.check(Lr(t,n)),e.lte=(t,n)=>e.check(Rr(t,n)),e.max=(t,n)=>e.check(Rr(t,n)),e.int=t=>e.check(Ga(t)),e.safe=t=>e.check(Ga(t)),e.positive=t=>e.check(zr(0,t)),e.nonnegative=t=>e.check(Br(0,t)),e.negative=t=>e.check(Lr(0,t)),e.nonpositive=t=>e.check(Rr(0,t)),e.multipleOf=(t,n)=>e.check(Vr(t,n)),e.step=(t,n)=>e.check(Vr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Ua(e){return Mr(Ha,e)}const Wa=w(`ZodNumberFormat`,(e,t)=>{xn.init(e,t),Ha.init(e,t)});function Ga(e){return Nr(Wa,e)}const Ka=w(`ZodBoolean`,(e,t)=>{Sn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r)});function qa(e){return Pr(Ka,e)}const Ja=w(`ZodUnknown`,(e,t)=>{Cn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function Ya(){return Fr(Ja)}const Xa=w(`ZodNever`,(e,t)=>{wn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r)});function Za(e){return Ir(Xa,e)}const Qa=w(`ZodArray`,(e,t)=>{En.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ii(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Ur(t,n)),e.nonempty=t=>e.check(Ur(1,t)),e.max=(t,n)=>e.check(Hr(t,n)),e.length=(t,n)=>e.check(Wr(t,n)),e.unwrap=()=>e.element});function $a(e,t){return ri(Qa,e,t)}const eo=w(`ZodObject`,(e,t)=>{jn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Li(e,t,n,r),A(e,`shape`,()=>t.shape),e.keyof=()=>so(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:Ya()}),e.loose=()=>e.clone({...e._zod.def,catchall:Ya()}),e.strict=()=>e.clone({...e._zod.def,catchall:Za()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>Ce(e,t),e.safeExtend=t=>we(e,t),e.merge=t=>Te(e,t),e.pick=t=>xe(e,t),e.omit=t=>Se(e,t),e.partial=(...t)=>Ee(uo,e,t[0]),e.required=(...t)=>De(xo,e,t[0])});function to(e,t){return new eo({type:`object`,shape:e??{},...N(t)})}const no=w(`ZodUnion`,(e,t)=>{Nn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ri(e,t,n,r),e.options=t.options});function ro(e,t){return new no({type:`union`,options:e,...N(t)})}const io=w(`ZodIntersection`,(e,t)=>{Pn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zi(e,t,n,r)});function ao(e,t){return new io({type:`intersection`,left:e,right:t})}const oo=w(`ZodEnum`,(e,t)=>{Ln.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new oo({...t,checks:[],...N(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new oo({...t,checks:[],...N(r),entries:i})}});function so(e,t){return new oo({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...N(t)})}const co=w(`ZodTransform`,(e,t)=>{Rn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new re(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ne(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(Ne(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function lo(e){return new co({type:`transform`,transform:e})}const uo=w(`ZodOptional`,(e,t)=>{Bn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function fo(e){return new uo({type:`optional`,innerType:e})}const po=w(`ZodExactOptional`,(e,t)=>{Vn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mo(e){return new po({type:`optional`,innerType:e})}const ho=w(`ZodNullable`,(e,t)=>{Hn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function go(e){return new ho({type:`nullable`,innerType:e})}const _o=w(`ZodDefault`,(e,t)=>{Un.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Wi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function vo(e,t){return new _o({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():he(t)}})}const yo=w(`ZodPrefault`,(e,t)=>{Gn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Gi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function bo(e,t){return new yo({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():he(t)}})}const xo=w(`ZodNonOptional`,(e,t)=>{Kn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ui(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function So(e,t){return new xo({type:`nonoptional`,innerType:e,...N(t)})}const Co=w(`ZodCatch`,(e,t)=>{Jn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ki(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function wo(e,t){return new Co({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const To=w(`ZodPipe`,(e,t)=>{Yn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>qi(e,t,n,r),e.in=t.in,e.out=t.out});function Eo(e,t){return new To({type:`pipe`,in:e,out:t})}const Do=w(`ZodReadonly`,(e,t)=>{Zn.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ji(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Oo(e){return new Do({type:`readonly`,innerType:e})}const ko=w(`ZodCustom`,(e,t)=>{$n.init(e,t),B.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r)});function Ao(e,t={}){return ii(ko,e,t)}function jo(e){return ai(e)}var Mo=class extends C{async toJsonSchema(e){return Qi(e,{target:`draft-7`})}};function No(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Po(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?No(Object(n),!0).forEach(function(t){Fo(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):No(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Fo(e,t,n){return t=Io(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Io(e){var t=Lo(e,`string`);return typeof t==`symbol`?t:String(t)}function Lo(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Ro=zo({});function zo(e){return t.withOptions=t=>zo(Po(Po({},e),t)),t;function t(t,...n){let r=typeof t==`string`?[t]:t.raw,{alignValues:i=!1,escapeSpecialCharacters:a=Array.isArray(t),trimWhitespace:o=!0}=e,s=``;for(let e=0;e<r.length;e++){let t=r[e];if(a&&(t=t.replace(/\\\n[ \t]*/g,``).replace(/\\`/g,"`").replace(/\\\$/g,`$`).replace(/\\\{/g,`{`)),s+=t,e<n.length){let t=i?Bo(n[e],s):n[e];s+=t}}let c=s.split(`
|
|
45
|
+
`),l=null;for(let e of c){let t=e.match(/^(\s+)\S+/);if(t){let e=t[1].length;l=l?Math.min(l,e):e}}if(l!==null){let e=l;s=c.map(t=>t[0]===` `||t[0]===` `?t.slice(e):t).join(`
|
|
46
|
+
`)}return o&&(s=s.trim()),a&&(s=s.replace(/\\n/g,`
|
|
47
|
+
`)),typeof Bun<`u`&&(s=s.replace(/\\u(?:\{([\da-fA-F]{1,6})\}|([\da-fA-F]{4}))/g,(e,t,n)=>{let r=t??n??``;return String.fromCodePoint(parseInt(r,16))})),s}}function Bo(e,t){if(typeof e!=`string`||!e.includes(`
|
|
48
|
+
`))return e;let n=t.slice(t.lastIndexOf(`
|
|
49
|
+
`)+1).match(/^(\s+)/);if(n){let t=n[1];return e.replace(/\n/g,`\n${t}`)}return e}var Vo=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 O;var n=p(e);E(t)||(t=f(t));var r=n.bitflags;return(r&t._bitflags)===r?h(n,t):O},n=(e,t,n)=>{if(!e)return n?.all?m(t,n):oe;var r=p(e),i=r.bitflags,a=r.containsSpace,o=u(n?.threshold||0),c=n?.limit||ae,l=0,d=0,ee=t.length;function g(e){l<c?(ce.add(e),++l):(++d,e._score>ce.peek()._score&&ce.replaceTop(e))}if(n?.key)for(var _=n.key,v=0;v<ee;++v){var te=t[v],y=ie(te,_);if(y&&(E(y)||(y=f(y)),(i&y._bitflags)===i)){var b=h(r,y);b!==O&&(b._score<o||(b.obj=te,g(b)))}}else if(n?.keys){var x=n.keys,ne=x.length;outer:for(var v=0;v<ee;++v){for(var te=t[v],S=0,k=0;k<ne;++k){var _=x[k],y=ie(te,_);if(!y){T[k]=se;continue}E(y)||(y=f(y)),T[k]=y,S|=y._bitflags}if((i&S)===i){if(a)for(let e=0;e<r.spaceSearches.length;e++)C[e]=D;for(var k=0;k<ne;++k){if(y=T[k],y===se){re[k]=se;continue}if(re[k]=h(r,y,!1,a),re[k]===O){re[k]=se;continue}if(a)for(let e=0;e<r.spaceSearches.length;e++){if(w[e]>-1e3&&C[e]>D){var A=(C[e]+w[e])/4;A>C[e]&&(C[e]=A)}w[e]>C[e]&&(C[e]=w[e])}}if(a){for(let e=0;e<r.spaceSearches.length;e++)if(C[e]===D)continue outer}else{var le=!1;for(let e=0;e<ne;e++)if(re[e]._score!==D){le=!0;break}if(!le)continue}var j=new s(ne);for(let e=0;e<ne;e++)j[e]=re[e];if(a){var M=0;for(let e=0;e<r.spaceSearches.length;e++)M+=C[e]}else{var M=D;for(let e=0;e<ne;e++){var b=j[e];if(b._score>-1e3&&M>D){var A=(M+b._score)/4;A>M&&(M=A)}b._score>M&&(M=b._score)}}if(j.obj=te,j._score=M,n?.scoreFn){if(M=n.scoreFn(j),!M)continue;M=u(M),j._score=M}M<o||g(j)}}}else for(var v=0;v<ee;++v){var y=t[v];if(y&&(E(y)||(y=f(y)),(i&y._bitflags)===i)){var b=h(r,y);b!==O&&(b._score<o||g(b))}}if(l===0)return oe;for(var ue=Array(l),v=l-1;v>=0;--v)ue[v]=ce.poll();return ue.total=l+d,ue},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??O,n._score=t._score??D,n._indexes=t._indexes??[],n._targetLower=t._targetLower??``,n._targetLowerCodes=t._targetLowerCodes??O,n._nextBeginningIndexes=t._nextBeginningIndexes??O,n._bitflags=t._bitflags??0,n},l=e=>e===D?0:e>1?e:Math.E**(((-e+1)**.04307-1)*-2),u=e=>e===0?D: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||ae;if(t?.key)for(var i=0;i<e.length;i++){var a=e[i],o=ie(a,t.key);if(o!=O){E(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=ie(a,t.keys[d]);if(!o){u[d]=se;continue}E(o)||(o=f(o)),o._score=D,o._indexes.len=0,u[d]=o}if(u.obj=a,u._score=D,n.push(u),n.length>=r)return n}else for(var i=0;i<e.length;i++){var o=e[i];if(o!=O&&(E(o)||(o=f(o)),o._score=D,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 O}var d=0,h=!1,g=0,_=t._nextBeginningIndexes;_===O&&(_=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=ne[--g];f=_[y]}else{var m=a[d]===c[f];if(m){if(ne[g++]=f,++d,d===l){h=!0;break}++f}else f=_[f]}var b=l<=1?-1:t._targetLower.indexOf(i,x[0]),S=!!~b,C=S?b===0||t._nextBeginningIndexes[b-1]===b:!1;if(S&&!C){for(var w=0;w<_.length;w=_[w])if(!(w<=b)){for(var T=0;T<l&&a[T]===t._targetLowerCodes[w+T];T++);if(T===l){b=w,C=!0;break}}}var re=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,S&&(t/=1+l*l*1),C&&(t/=1+l*l*1),t-=(u-l)/2,t};if(h)if(C){for(var w=0;w<l;++w)x[w]=b+w;var ie=x,E=re(x)}else var ie=ne,E=re(ne);else{if(S)for(var w=0;w<l;++w)x[w]=b+w;var ie=x,E=re(ie)}t._score=E;for(var w=0;w<l;++w)t._indexes[w]=ie[w];t._indexes.len=l;let ae=new o;return ae.target=t.target,ae._score=t._score,ae._indexes=t._indexes,ae},ee=(e,t,n)=>{for(var r=new Set,i=0,a=O,o=0,s=e.spaceSearches,c=s.length,l=0,u=()=>{for(let e=l-1;e>=0;e--)t._nextBeginningIndexes[S[e*2+0]]=S[e*2+1]},d=!1,f=0;f<c;++f){w[f]=D;var p=s[f];if(a=h(p,t),n){if(a===O)continue;d=!0}else if(a===O)return u(),O;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,S[l*2+0]=e,S[l*2+1]=_,l++}}i+=a._score/c,w[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 O;u();var te=h(e,t,!0);if(te!==O&&te._score>i){if(n)for(var f=0;f<c;++f)w[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=[],ne=[],S=[],C=[],w=[],T=[],re=[],ie=(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},E=e=>typeof e==`object`&&typeof e._bitflags==`number`,ae=1/0,D=-ae,oe=[];oe.total=0;var O=null,se=i(``),ce=(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}})})),Ho=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}}})),Uo=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DefaultErrorCode=void 0,e.DefaultErrorCode=0})),Wo=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=Ho(),i=Uo();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}})),Go=y((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),Ko=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=Ho(),o=Uo(),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`))}})),qo=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=Ho();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}()})),Jo=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(Wo(),e),n(Go(),e),n(Ho(),e),n(Ko(),e),n(qo(),e)}));function Yo(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=Xo(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 Xo(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:Zo(i).map(Qo),operator:r}}function Zo(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 Qo(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 $o(e,t){let n={},r=es(e,0,t.parts,0,n);return!r||r.uri_index!==e.length?null:n}function es(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)?es(e,t+a.value.length,n,r+1,i):null;{let o=n[r+1],s=ts(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(ns(s,a,c,e,t)){let t=es(e,o,n,r+1,c);if(t)return Object.assign(i,c),t}}return null}}function ts(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 ns(e,t,n,r,i){if(t.type!==`expression`)return!1;switch(t.operator){case`+`:return is(e,t,n);case`#`:return rs(e,t,n);case`.`:return os(e,t,n);case`/`:return ss(e,t,n);case`;`:return cs(e,t,n);case`?`:case`&`:return ls(e,t,n);default:return as(e,t,n,r,i)}}function rs(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 is(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 as(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 os(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 ss(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 cs(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 ls(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 us=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=Yo(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=$o(e,t);if(n!==null)return{template:t.template,params:n}}return null}clear(){this.templates=[]}all(){return this.templates.map(e=>e.template)}},ds=Jo(),fs=x(Vo(),1),ps;function ms(e){return{lang:e?.lang??ps?.lang,message:e?.message,abortEarly:e?.abortEarly??ps?.abortEarly,abortPipeEarly:e?.abortPipeEarly??ps?.abortPipeEarly}}var hs;function gs(e){return hs?.get(e)}var _s;function vs(e){return _s?.get(e)}var ys;function bs(e,t){return ys?.get(e)?.get(t)}function xs(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??xs(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??bs(e.reference,c.lang)??(l?vs(c.lang):null)??r.message??gs(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},ms())}}}function Ss(e,t){return Object.hasOwn(e,t)&&t!==`__proto__`&&t!==`prototype`&&t!==`constructor`}function Cs(e,t){let n=[...new Set(e)];return n.length>1?`(${n.join(` ${t} `)})`:n[0]??`never`}var ws=class extends Error{constructor(e){super(e[0].message),this.name=`ValiError`,this.issues=e}},Ts=/^(?:[\da-z+/]{4})*(?:[\da-z+/]{2}==|[\da-z+/]{3}=)?$/iu;function Es(e){return{kind:`validation`,type:`base64`,reference:Es,async:!1,expects:null,requirement:Ts,message:e,"~run"(e,t){return e.typed&&!this.requirement.test(e.value)&&H(this,`Base64`,e,t),e}}}function Ds(e,t){return{kind:`validation`,type:`check`,reference:Ds,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 Os(e){return{kind:`validation`,type:`integer`,reference:Os,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 ks(e,t){return{kind:`validation`,type:`max_length`,reference:ks,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 As(e,t){return{kind:`validation`,type:`max_value`,reference:As,async:!1,expects:`<=${e instanceof Date?e.toJSON():xs(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():xs(e.value)}),e}}}function js(e,t){return{kind:`validation`,type:`min_value`,reference:js,async:!1,expects:`>=${e instanceof Date?e.toJSON():xs(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():xs(e.value)}),e}}}function Ms(e,t){return{kind:`validation`,type:`regex`,reference:Ms,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 Ns(e,t){return{kind:`validation`,type:`starts_with`,reference:Ns,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 Ps(e,t,n){return typeof e.fallback==`function`?e.fallback(t,n):e.fallback}function Fs(e,t,n){return typeof e.default==`function`?e.default(t,n):e.default}function Is(e,t){return{kind:`schema`,type:`array`,reference:Is,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 Ls(e){return{kind:`schema`,type:`boolean`,reference:Ls,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 Rs(e,t){return{kind:`schema`,type:`literal`,reference:Rs,expects:xs(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]:Fs(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]=Ps(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)Ss(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]:Fs(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]=Ps(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=Fs(this,e,t)),e.value===void 0)?(e.typed=!0,e):this.wrapped[`~run`](e,t)}}}function zs(e,t){return{kind:`schema`,type:`picklist`,reference:zs,expects:Cs(e.map(xs),`|`),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 Bs(e,t,n){return{kind:`schema`,type:`record`,reference:Bs,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(Ss(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 Vs(e,t){return{kind:`schema`,type:`strict_object`,reference:Vs,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]:Fs(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]=Ps(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 Hs(e){let t;if(e)for(let n of e)t?t.push(...n.issues):t=n.issues;return t}function Us(e,t){return{kind:`schema`,type:`union`,reference:Us,expects:Cs(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:Hs(r)}),e.typed=!0}else if(i?.length===1)return i[0];else H(this,`type`,e,t,{issues:Hs(i)});return e}}}function Ws(){return{kind:`schema`,type:`unknown`,reference:Ws,expects:`unknown`,async:!1,get"~standard"(){return U(this)},"~run"(e){return e.typed=!0,e}}}function Gs(e,t,n){return{kind:`schema`,type:`variant`,reference:Gs,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:Cs(o,`|`),path:[{type:`object`,origin:`value`,input:n,key:a,value:n[a]}]})}else H(this,`type`,e,t);return e}}}function Ks(e,t,n){let r=e[`~run`]({value:t},ms(n));if(r.issues)throw new ws(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 qs(e,t,n){let r=e[`~run`]({value:t},ms(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 Js=Us([J(),Y(G(),Os())]),Ys=J(),Z=W({_meta:q(W({progressToken:q(Js)}))}),Q=K({method:J(),params:q(Z)}),Xs=W({_meta:q(W({}))}),Zs=K({method:J(),params:q(Xs)}),$=W({_meta:q(W({}))}),Qs=Us([J(),Y(G(),Os())]),$s=K({jsonrpc:Rs(`2.0`),id:Qs,...Q.entries}),ec=K({jsonrpc:Rs(`2.0`),...Zs.entries}),tc=Vs({jsonrpc:Rs(`2.0`),id:Qs,result:$}),nc=Vs({jsonrpc:Rs(`2.0`),id:Qs,error:K({code:Y(G(),Os()),message:J(),data:q(Ws())})});({...$.entries}),{...Zs.entries},{...Xs.entries};const rc=K({name:J(),title:q(J())}),ic=K({icons:q(Is(K({src:J(),mimeType:q(J()),sizes:q(Is(J()))})))}),ac=K({...rc.entries,version:J(),websiteUrl:q(J()),...ic.entries}),oc=K({experimental:q(K({})),sampling:q(K({})),elicitation:q(K({})),roots:q(K({listChanged:q(Ls())}))}),sc=K({...Z.entries,protocolVersion:J(),capabilities:oc,clientInfo:ac});({...Q.entries}),{...$.entries},{...Zs.entries},{...Q.entries};const cc=K({progress:G(),total:q(G()),message:q(J())});({...Zs.entries}),{...Xs.entries,...cc.entries};const lc=K({...Q.entries,params:q(K({...Z.entries,cursor:q(Ys)}))}),uc=K({...$.entries,nextCursor:q(Ys)}),dc=K({uri:J(),mimeType:q(J()),_meta:q(W({}))}),fc=K({...dc.entries,text:J()}),pc=K({...dc.entries,blob:Y(J(),Es())}),mc=K({...rc.entries,uri:J(),description:q(J()),mimeType:q(J()),_meta:q(W({})),...ic.entries});({...rc.entries}),{...ic.entries},{...lc.entries},{...uc.entries},{...lc.entries},{...uc.entries},{...Q.entries},{...Z.entries};const hc=K({...$.entries,contents:Is(Us([fc,pc]))});({...Zs.entries}),{...Q.entries},{...Z.entries},{...Q.entries},{...Z.entries},{...Zs.entries},{...Xs.entries},{...rc.entries},{...ic.entries},{...lc.entries},{...uc.entries},{...Q.entries},{...Z.entries};const gc=K({type:Rs(`text`),text:J(),_meta:q(W({}))}),_c=K({type:Rs(`image`),data:Y(J(),Es()),mimeType:J(),_meta:q(W({}))}),vc=K({type:Rs(`audio`),data:Y(J(),Es()),mimeType:J(),_meta:q(W({}))}),yc=K({type:Rs(`resource`),resource:Us([fc,pc]),_meta:q(W({}))}),bc=Us([gc,_c,vc,K({...mc.entries,type:Rs(`resource_link`)}),yc]),xc=K({role:zs([`user`,`assistant`]),content:bc}),Sc=K({...$.entries,description:q(J()),messages:Is(xc)});({...Zs.entries}),{...rc.entries},{...ic.entries},{...lc.entries},{...uc.entries};const Cc=K({...$.entries,content:q(Is(bc),[]),structuredContent:q(W({})),isError:q(Ls())});({...$.entries}),{...Q.entries},{...Z.entries},{...Zs.entries},{...Q.entries},{...Z.entries},{...Zs.entries},{...Xs.entries};const wc=K({hints:q(Is(K({name:q(J())}))),costPriority:q(Y(G(),js(0),As(1))),speedPriority:q(Y(G(),js(0),As(1))),intelligencePriority:q(Y(G(),js(0),As(1)))}),Tc=K({role:zs([`user`,`assistant`]),content:Us([gc,_c,vc])}),Ec=K({...Z.entries,messages:Is(Tc),systemPrompt:q(J()),includeContext:q(zs([`none`,`thisServer`,`allServers`])),temperature:q(G()),maxTokens:Y(G(),Os()),stopSequences:q(Is(J())),metadata:q(K({})),modelPreferences:q(wc)});({...Q.entries});const Dc=K({...$.entries,model:J(),stopReason:q(Us([zs([`endTurn`,`stopSequence`,`maxTokens`]),J()])),role:zs([`user`,`assistant`]),content:Gs(`type`,[gc,_c,vc])});({...Q.entries}),{...Z.entries};const Oc=K({...$.entries,action:zs([`accept`,`decline`,`cancel`]),content:q(Bs(J(),Ws()))});({...Q.entries}),{...Z.entries};const kc=K({...$.entries,completion:K({values:Y(Is(J()),ks(100)),total:q(Y(G(),Os())),hasMore:q(Ls())})});({...Q.entries}),{...$.entries},{...Zs.entries};const Ac=[`2025-06-18`,`2025-03-26`,`2024-11-05`],jc=Ac[0];function Mc(e){return Ac.includes(e)}function Nc(){return jc}function Pc(){return[...Ac]}function Fc(e){return Mc(e)?e:Nc()}function Ic(e){try{let t=new Date(e);return!/^\d{4}-\d{2}-\d{2}$/.test(e)||isNaN(t.getTime())}catch{return!0}}function Lc(e,t){return new CustomEvent(e,{detail:t})}let Rc;async function zc(){return Rc||=new(await(import(`./sqids-BiDaWurc.mjs`))).default,Rc}async function Bc(e){return(await zc()).encode([e])}async function Vc(e){let[t]=(await zc()).decode(e);return t}async function Hc(e){try{return await e()}catch{return!1}}var Uc=class{#e=new ds.JSONRPCServer;#t;#n;#r=new Map;#i=new Map;#a=new Map;#o=new us;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=Ks(sc,n);if(Ic(r.protocolVersion))throw new X(-32602,`Invalid protocol version format`);let i=Fc(r.protocolVersion);return this.#c.dispatchEvent(Lc(`initialize`,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: ${Pc().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 ds.JSONRPCClient((e,t)=>{if(t===`broadcast`){this.#c.dispatchEvent(Lc(`broadcast`,{request:e}));return}this.#c.dispatchEvent(Lc(`send`,{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({cursor:e}={})=>{let t=(await Promise.all([...this.#r].map(async([e,t])=>t.enabled!=null&&await Hc(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),n=this.#n.pagination?.tools;if(!n||n.size==null)return{tools:t};let r=n.size,i=e?await Vc(e):0,a=i+r,o=t.slice(i,a),s=a<t.length?await Bc(a):null;return{tools:o,...s&&{nextCursor:s}}}),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=Ks(Cc,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 Hc(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 Vc(e):0,a=i+r,o=t.slice(i,a),s=a<t.length?await Bc(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 Ks(Sc,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 Ks(Sc,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(Lc(`subscription`,{uri:e,action:`add`})),{})),this.#e.addMethod(`resources/unsubscribe`,async({uri:e})=>(this.#c.dispatchEvent(Lc(`subscription`,{uri:e,action:`remove`})),{}))),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 Hc(o.enabled)===!1)continue;let e=await o.list_resources();t.push(...e)}}else{if(o.enabled!=null&&await Hc(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 Vc(e):0,a=i+r,o=t.slice(i,a),s=a<t.length?await Bc(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 Hc(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 Ks(hc,await t.execute(e,n))}return Ks(hc,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?Ks(kc,await a(e.value,n)):null})}#b(){this.#n.capabilities?.logging&&this.#e.addMethod(`logging/setLevel`,({level:e})=>(this.#c.dispatchEvent(Lc(`loglevelchange`,{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`)}tools(e){for(let t of e)this.tool({name:t.name,description:t.description,title:t.title,schema:t.schema,outputSchema:t.outputSchema,annotations:t.annotations,enabled:t.enabled,icons:t.icons,_meta:t._meta},t.execute)}prompts(e){for(let t of e)this.prompt({name:t.name,description:t.description,title:t.title,schema:t.schema,complete:t.complete,enabled:t.enabled,icons:t.icons},t.execute)}resources(e){for(let t of e)this.resource({name:t.name,description:t.description,title:t.title,uri:t.uri,enabled:t.enabled,icons:t.icons},t.execute)}templates(e){for(let t of e)this.template({name:t.name,description:t.description,title:t.title,uri:t.uri,complete:t.complete,list:t.list,enabled:t.enabled,icons:t.icons},t.execute)}tool({name:e,description:t,title:n,schema:r,outputSchema:i,annotations:a,enabled:o,icons:s,_meta:c,...l},u){`execute`in l&&(u=l.execute),this.#x(),this.#r.set(e,{description:t,title:n,enabled:o,schema:r,outputSchema:i,execute:u,annotations:a,icons:s,_meta:c})}prompt({name:e,description:t,title:n,schema:r,complete:i,enabled:a,icons:o,...s},c){`execute`in s&&(c=s.execute),i&&this.#s[`ref/prompt`].set(e,i),this.#S(),this.#i.set(e,{description:t,title:n,schema:r,execute:c,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},s){`execute`in o&&(s=o.execute),this.#w({name:e,description:t,title:n,uri:r,execute:s,enabled:i,icons:a,template:!1})}template({name:e,description:t,title:n,uri:r,complete:i,list:a,enabled:o,icons:s,...c},l){`execute`in c&&(l=c.execute),this.#w({name:e,enabled:o,description:t,title:n,uri:r,execute:l,complete:i,icons:s,list_resources:a,template:!0})}receive(e,t){let n=qs(Us([$s,ec]),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=Ks(Us([tc,nc]),e);return this.#f(),this.#l.run(t??{},async()=>this.#t?.receive(r))}async request({method:e,params:t}){return this.#f(),this.#t?.request(e,t,`standalone`)}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=Ks(Oc,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=Ks(Ec,e);return Ks(Dc,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)}},Wc=`0.0.11`;const Gc={cwd:Sa().describe(`The path of the current working directory. Used to find the jsrepo.config file.`)},Kc=new Mo,qc=new Uc({name:`jsrepo`,version:Wc,description:`An MCP server for adding, viewing, and searching items from jsrepo registries.`},{adapter:Kc,capabilities:{tools:{listChanged:!0}}});qc.tool({name:`add_item_to_project`,description:`Add a registry item or items to the users project.`,schema:to({cwd:Gc.cwd,itemNames:$a(Sa().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:qa().optional().describe(`Add items with examples.`),withDocs:qa().optional().describe(`Add items with docs.`),withTests:qa().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:Ro`
|
|
50
|
+
Failed to get paths for items: ${v.error.message}.
|
|
51
|
+
You will need to add the paths to the users config file (if they aren't already added) like so:
|
|
52
|
+
\`\`\`
|
|
53
|
+
import { defineConfig } from "jsrepo";
|
|
54
|
+
|
|
55
|
+
export default defineConfig({
|
|
56
|
+
// ...
|
|
57
|
+
paths: {
|
|
58
|
+
// ...
|
|
59
|
+
${_.map(e=>`"${r(e.type)}": "put the expected path here",`).join(`
|
|
60
|
+
`)}
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
\`\`\`
|
|
64
|
+
`}]};let{itemPaths:te}=v.value,{neededDependencies:y,neededEnvVars:b,neededFiles:x}=(await i({configResult:m,options:{cwd:t.cwd,yes:!0,withExamples:t.withExamples??!1,withDocs:t.withDocs??!1,withTests:t.withTests??!1},itemPaths:te,items:_})).match(e=>e,e=>{throw e});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(y,{options:{cwd:t.cwd,yes:!0},config:m?.config}),{content:[{type:`text`,text:Ro`Added ${_.length} items to the users project:
|
|
65
|
+
${_.map(e=>Jc(e)).join(`
|
|
66
|
+
`)}`}]}}),qc.tool({name:`view_registry_item`,description:`View the code and information about a registry item.`,schema:to({cwd:Gc.cwd,item:Sa().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:Jc(ee)}]}}),qc.tool({name:`list_items_in_registry`,description:`List items in a registry. You can optionally provide a query to filter the results.`,schema:to({cwd:Gc.cwd,registries:$a(Sa()).describe(`The registries to search for items in. i.e. ["github/ieedan/std", "@ieedan/std"]`),query:Sa().optional().describe(`The query to search for. i.e. "math"`),limit:Ua().optional().describe(`The maximum number of items to return. Defaults to 10.`),offset:Ua().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=fs.default.go(n,u,{keys:[`item.name`,`item.description`,`item.type`,`item.categories`]});if(e.length===0)return{content:[{type:`text`,text:Ro`
|
|
67
|
+
No results found for "${n}".
|
|
68
|
+
`}]};d=e.map(e=>e.obj)}else d=u;let p=d.slice(o,Math.min(o+a,d.length));function m(e){return Ro`
|
|
69
|
+
## ${e.registry.url}/${e.item.name} - ${e.item.type}
|
|
70
|
+
${e.item.description??``}
|
|
71
|
+
|
|
72
|
+
Files:
|
|
73
|
+
${e.item.files.map(e=>`- ${e.path}`).join(`
|
|
74
|
+
`)}
|
|
75
|
+
`}return{content:[{type:`text`,text:Ro`
|
|
76
|
+
# Search results
|
|
77
|
+
Found ${d.length} results for "${n}".
|
|
78
|
+
Showing ${p.length} results.
|
|
79
|
+
|
|
80
|
+
${p.map(m).join(`
|
|
81
|
+
`)}
|
|
82
|
+
`}]}});function Jc(e){return Ro`
|
|
83
|
+
# ${e.name} - ${e.type}${e.categories?` (Categories: ${e.categories.join(`, `)})`:``}
|
|
84
|
+
${e.description??``}
|
|
85
|
+
|
|
86
|
+
## Files
|
|
87
|
+
${e.files?.filter(e=>e.role===void 0||e.role===`file`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
88
|
+
`)}
|
|
89
|
+
|
|
90
|
+
## Dependencies
|
|
91
|
+
${e.dependencies?.map(e=>`- ${typeof e==`string`?e:e.name}`).join(`
|
|
92
|
+
`)}
|
|
93
|
+
|
|
94
|
+
## Examples
|
|
95
|
+
${e.files?.filter(e=>e.role===`example`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
96
|
+
`)}
|
|
97
|
+
|
|
98
|
+
## Docs
|
|
99
|
+
${e.files?.filter(e=>e.role===`doc`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
100
|
+
`)}
|
|
101
|
+
|
|
102
|
+
## Tests
|
|
103
|
+
${e.files?.filter(e=>e.role===`test`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
104
|
+
`)}
|
|
105
|
+
|
|
106
|
+
## Environment Variables
|
|
107
|
+
Environment variables are required for the item to work. Blank variables will need to be filled in.
|
|
108
|
+
\`\`\`env
|
|
109
|
+
${Object.entries(e.envVars??{}).map(([e,t])=>`${e}="${t}"`).join(`
|
|
110
|
+
`)}
|
|
111
|
+
\`\`\`
|
|
112
|
+
|
|
113
|
+
Additional info:
|
|
114
|
+
${Object.entries(e.meta??{}).map(([e,t])=>`- ${e}: ${t}`).join(`
|
|
115
|
+
`)}
|
|
116
|
+
`}new ne(qc).listen(),process.stdout.write(`Server running...
|
|
117
|
+
`),process.stdout.write(S.default.dim(`Press ${S.default.bold(`Ctrl+C`)} to exit\n`));export{};
|
|
118
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={alphabet:`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`,minLength:0,blocklist:new Set(`0rgasm.1d10t.1d1ot.1di0t.1diot.1eccacu10.1eccacu1o.1eccacul0.1eccaculo.1mbec11e.1mbec1le.1mbeci1e.1mbecile.a11upat0.a11upato.a1lupat0.a1lupato.aand.ah01e.ah0le.aho1e.ahole.al1upat0.al1upato.allupat0.allupato.ana1.ana1e.anal.anale.anus.arrapat0.arrapato.arsch.arse.ass.b00b.b00be.b01ata.b0ceta.b0iata.b0ob.b0obe.b0sta.b1tch.b1te.b1tte.ba1atkar.balatkar.bastard0.bastardo.batt0na.battona.bitch.bite.bitte.bo0b.bo0be.bo1ata.boceta.boiata.boob.boobe.bosta.bran1age.bran1er.bran1ette.bran1eur.bran1euse.branlage.branler.branlette.branleur.branleuse.c0ck.c0g110ne.c0g11one.c0g1i0ne.c0g1ione.c0gl10ne.c0gl1one.c0gli0ne.c0glione.c0na.c0nnard.c0nnasse.c0nne.c0u111es.c0u11les.c0u1l1es.c0u1lles.c0ui11es.c0ui1les.c0uil1es.c0uilles.c11t.c11t0.c11to.c1it.c1it0.c1ito.cabr0n.cabra0.cabrao.cabron.caca.cacca.cacete.cagante.cagar.cagare.cagna.cara1h0.cara1ho.caracu10.caracu1o.caracul0.caraculo.caralh0.caralho.cazz0.cazz1mma.cazzata.cazzimma.cazzo.ch00t1a.ch00t1ya.ch00tia.ch00tiya.ch0d.ch0ot1a.ch0ot1ya.ch0otia.ch0otiya.ch1asse.ch1avata.ch1er.ch1ng0.ch1ngadaz0s.ch1ngadazos.ch1ngader1ta.ch1ngaderita.ch1ngar.ch1ngo.ch1ngues.ch1nk.chatte.chiasse.chiavata.chier.ching0.chingadaz0s.chingadazos.chingader1ta.chingaderita.chingar.chingo.chingues.chink.cho0t1a.cho0t1ya.cho0tia.cho0tiya.chod.choot1a.choot1ya.chootia.chootiya.cl1t.cl1t0.cl1to.clit.clit0.clito.cock.cog110ne.cog11one.cog1i0ne.cog1ione.cogl10ne.cogl1one.cogli0ne.coglione.cona.connard.connasse.conne.cou111es.cou11les.cou1l1es.cou1lles.coui11es.coui1les.couil1es.couilles.cracker.crap.cu10.cu1att0ne.cu1attone.cu1er0.cu1ero.cu1o.cul0.culatt0ne.culattone.culer0.culero.culo.cum.cunt.d11d0.d11do.d1ck.d1ld0.d1ldo.damn.de1ch.deich.depp.di1d0.di1do.dick.dild0.dildo.dyke.encu1e.encule.enema.enf01re.enf0ire.enfo1re.enfoire.estup1d0.estup1do.estupid0.estupido.etr0n.etron.f0da.f0der.f0ttere.f0tters1.f0ttersi.f0tze.f0utre.f1ca.f1cker.f1ga.fag.fica.ficker.figa.foda.foder.fottere.fotters1.fottersi.fotze.foutre.fr0c10.fr0c1o.fr0ci0.fr0cio.fr0sc10.fr0sc1o.fr0sci0.fr0scio.froc10.froc1o.froci0.frocio.frosc10.frosc1o.frosci0.froscio.fuck.g00.g0o.g0u1ne.g0uine.gandu.go0.goo.gou1ne.gouine.gr0gnasse.grognasse.haram1.harami.haramzade.hund1n.hundin.id10t.id1ot.idi0t.idiot.imbec11e.imbec1le.imbeci1e.imbecile.j1zz.jerk.jizz.k1ke.kam1ne.kamine.kike.leccacu10.leccacu1o.leccacul0.leccaculo.m1erda.m1gn0tta.m1gnotta.m1nch1a.m1nchia.m1st.mam0n.mamahuev0.mamahuevo.mamon.masturbat10n.masturbat1on.masturbate.masturbati0n.masturbation.merd0s0.merd0so.merda.merde.merdos0.merdoso.mierda.mign0tta.mignotta.minch1a.minchia.mist.musch1.muschi.n1gger.neger.negr0.negre.negro.nerch1a.nerchia.nigger.orgasm.p00p.p011a.p01la.p0l1a.p0lla.p0mp1n0.p0mp1no.p0mpin0.p0mpino.p0op.p0rca.p0rn.p0rra.p0uff1asse.p0uffiasse.p1p1.p1pi.p1r1a.p1rla.p1sc10.p1sc1o.p1sci0.p1scio.p1sser.pa11e.pa1le.pal1e.palle.pane1e1r0.pane1e1ro.pane1eir0.pane1eiro.panele1r0.panele1ro.paneleir0.paneleiro.patakha.pec0r1na.pec0rina.pecor1na.pecorina.pen1s.pendej0.pendejo.penis.pip1.pipi.pir1a.pirla.pisc10.pisc1o.pisci0.piscio.pisser.po0p.po11a.po1la.pol1a.polla.pomp1n0.pomp1no.pompin0.pompino.poop.porca.porn.porra.pouff1asse.pouffiasse.pr1ck.prick.pussy.put1za.puta.puta1n.putain.pute.putiza.puttana.queca.r0mp1ba11e.r0mp1ba1le.r0mp1bal1e.r0mp1balle.r0mpiba11e.r0mpiba1le.r0mpibal1e.r0mpiballe.rand1.randi.rape.recch10ne.recch1one.recchi0ne.recchione.retard.romp1ba11e.romp1ba1le.romp1bal1e.romp1balle.rompiba11e.rompiba1le.rompibal1e.rompiballe.ruff1an0.ruff1ano.ruffian0.ruffiano.s1ut.sa10pe.sa1aud.sa1ope.sacanagem.sal0pe.salaud.salope.saugnapf.sb0rr0ne.sb0rra.sb0rrone.sbattere.sbatters1.sbattersi.sborr0ne.sborra.sborrone.sc0pare.sc0pata.sch1ampe.sche1se.sche1sse.scheise.scheisse.schlampe.schwachs1nn1g.schwachs1nnig.schwachsinn1g.schwachsinnig.schwanz.scopare.scopata.sexy.sh1t.shit.slut.sp0mp1nare.sp0mpinare.spomp1nare.spompinare.str0nz0.str0nza.str0nzo.stronz0.stronza.stronzo.stup1d.stupid.succh1am1.succh1ami.succhiam1.succhiami.sucker.t0pa.tapette.test1c1e.test1cle.testic1e.testicle.tette.topa.tr01a.tr0ia.tr0mbare.tr1ng1er.tr1ngler.tring1er.tringler.tro1a.troia.trombare.turd.twat.vaffancu10.vaffancu1o.vaffancul0.vaffanculo.vag1na.vagina.verdammt.verga.w1chsen.wank.wichsen.x0ch0ta.x0chota.xana.xoch0ta.xochota.z0cc01a.z0cc0la.z0cco1a.z0ccola.z1z1.z1zi.ziz1.zizi.zocc01a.zocc0la.zocco1a.zoccola`.split(`.`))};var t=class{constructor(t){let n=t?.alphabet??e.alphabet,r=t?.minLength??e.minLength,i=t?.blocklist??e.blocklist;if(new Blob([n]).size!==n.length)throw Error(`Alphabet cannot contain multibyte characters`);if(n.length<3)throw Error(`Alphabet length must be at least 3`);if(new Set(n).size!==n.length)throw Error(`Alphabet must contain unique characters`);if(typeof r!=`number`||r<0||r>255)throw Error(`Minimum length has to be between 0 and 255`);let a=new Set,o=n.toLowerCase().split(``);for(let e of i)if(e.length>=3){let t=e.toLowerCase(),n=t.split(``);n.filter(e=>o.includes(e)).length===n.length&&a.add(t)}this.alphabet=this.shuffle(n),this.minLength=r,this.blocklist=a}encode(e){if(e.length===0)return``;if(e.filter(e=>e>=0&&e<=this.maxValue()).length!==e.length)throw Error(`Encoding supports numbers between 0 and ${this.maxValue()}`);return this.encodeNumbers(e)}decode(e){let t=[];if(e===``)return t;let n=this.alphabet.split(``);for(let r of e.split(``))if(!n.includes(r))return t;let r=e.charAt(0),i=this.alphabet.indexOf(r),a=this.alphabet.slice(i)+this.alphabet.slice(0,i);a=a.split(``).reverse().join(``);let o=e.slice(1);for(;o.length>0;){let e=a.slice(0,1),n=o.split(e);if(n.length>0){if(n[0]===``)return t;t.push(this.toNumber(n[0],a.slice(1))),n.length>1&&(a=this.shuffle(a))}o=n.slice(1).join(e)}return t}encodeNumbers(e,t=0){if(t>this.alphabet.length)throw Error(`Reached max attempts to re-generate the ID`);let n=e.reduce((e,t,n)=>this.alphabet[t%this.alphabet.length].codePointAt(0)+n+e,e.length)%this.alphabet.length;n=(n+t)%this.alphabet.length;let r=this.alphabet.slice(n)+this.alphabet.slice(0,n),i=r.charAt(0);r=r.split(``).reverse().join(``);let a=[i];for(let t=0;t!==e.length;t++){let n=e[t];a.push(this.toId(n,r.slice(1))),t<e.length-1&&(a.push(r.slice(0,1)),r=this.shuffle(r))}let o=a.join(``);if(this.minLength>o.length)for(o+=r.slice(0,1);this.minLength-o.length>0;)r=this.shuffle(r),o+=r.slice(0,Math.min(this.minLength-o.length,r.length));return this.isBlockedId(o)&&(o=this.encodeNumbers(e,t+1)),o}shuffle(e){let t=e.split(``);for(let e=0,n=t.length-1;n>0;e++,n--){let r=(e*n+t[e].codePointAt(0)+t[n].codePointAt(0))%t.length;[t[e],t[r]]=[t[r],t[e]]}return t.join(``)}toId(e,t){let n=[],r=t.split(``),i=e;do n.unshift(r[i%r.length]),i=Math.floor(i/r.length);while(i>0);return n.join(``)}toNumber(e,t){let n=t.split(``);return e.split(``).reduce((e,t)=>e*n.length+n.indexOf(t),0)}isBlockedId(e){let t=e.toLowerCase();for(let e of this.blocklist)if(e.length<=t.length){if(t.length<=3||e.length<=3){if(t===e)return!0}else if(/\d/.test(e)){if(t.startsWith(e)||t.endsWith(e))return!0}else if(t.includes(e))return!0}return!1}maxValue(){return 2**53-1}};export{t as default
|
|
2
|
-
//# sourceMappingURL=sqids-
|
|
1
|
+
const e={alphabet:`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`,minLength:0,blocklist:new Set(`0rgasm.1d10t.1d1ot.1di0t.1diot.1eccacu10.1eccacu1o.1eccacul0.1eccaculo.1mbec11e.1mbec1le.1mbeci1e.1mbecile.a11upat0.a11upato.a1lupat0.a1lupato.aand.ah01e.ah0le.aho1e.ahole.al1upat0.al1upato.allupat0.allupato.ana1.ana1e.anal.anale.anus.arrapat0.arrapato.arsch.arse.ass.b00b.b00be.b01ata.b0ceta.b0iata.b0ob.b0obe.b0sta.b1tch.b1te.b1tte.ba1atkar.balatkar.bastard0.bastardo.batt0na.battona.bitch.bite.bitte.bo0b.bo0be.bo1ata.boceta.boiata.boob.boobe.bosta.bran1age.bran1er.bran1ette.bran1eur.bran1euse.branlage.branler.branlette.branleur.branleuse.c0ck.c0g110ne.c0g11one.c0g1i0ne.c0g1ione.c0gl10ne.c0gl1one.c0gli0ne.c0glione.c0na.c0nnard.c0nnasse.c0nne.c0u111es.c0u11les.c0u1l1es.c0u1lles.c0ui11es.c0ui1les.c0uil1es.c0uilles.c11t.c11t0.c11to.c1it.c1it0.c1ito.cabr0n.cabra0.cabrao.cabron.caca.cacca.cacete.cagante.cagar.cagare.cagna.cara1h0.cara1ho.caracu10.caracu1o.caracul0.caraculo.caralh0.caralho.cazz0.cazz1mma.cazzata.cazzimma.cazzo.ch00t1a.ch00t1ya.ch00tia.ch00tiya.ch0d.ch0ot1a.ch0ot1ya.ch0otia.ch0otiya.ch1asse.ch1avata.ch1er.ch1ng0.ch1ngadaz0s.ch1ngadazos.ch1ngader1ta.ch1ngaderita.ch1ngar.ch1ngo.ch1ngues.ch1nk.chatte.chiasse.chiavata.chier.ching0.chingadaz0s.chingadazos.chingader1ta.chingaderita.chingar.chingo.chingues.chink.cho0t1a.cho0t1ya.cho0tia.cho0tiya.chod.choot1a.choot1ya.chootia.chootiya.cl1t.cl1t0.cl1to.clit.clit0.clito.cock.cog110ne.cog11one.cog1i0ne.cog1ione.cogl10ne.cogl1one.cogli0ne.coglione.cona.connard.connasse.conne.cou111es.cou11les.cou1l1es.cou1lles.coui11es.coui1les.couil1es.couilles.cracker.crap.cu10.cu1att0ne.cu1attone.cu1er0.cu1ero.cu1o.cul0.culatt0ne.culattone.culer0.culero.culo.cum.cunt.d11d0.d11do.d1ck.d1ld0.d1ldo.damn.de1ch.deich.depp.di1d0.di1do.dick.dild0.dildo.dyke.encu1e.encule.enema.enf01re.enf0ire.enfo1re.enfoire.estup1d0.estup1do.estupid0.estupido.etr0n.etron.f0da.f0der.f0ttere.f0tters1.f0ttersi.f0tze.f0utre.f1ca.f1cker.f1ga.fag.fica.ficker.figa.foda.foder.fottere.fotters1.fottersi.fotze.foutre.fr0c10.fr0c1o.fr0ci0.fr0cio.fr0sc10.fr0sc1o.fr0sci0.fr0scio.froc10.froc1o.froci0.frocio.frosc10.frosc1o.frosci0.froscio.fuck.g00.g0o.g0u1ne.g0uine.gandu.go0.goo.gou1ne.gouine.gr0gnasse.grognasse.haram1.harami.haramzade.hund1n.hundin.id10t.id1ot.idi0t.idiot.imbec11e.imbec1le.imbeci1e.imbecile.j1zz.jerk.jizz.k1ke.kam1ne.kamine.kike.leccacu10.leccacu1o.leccacul0.leccaculo.m1erda.m1gn0tta.m1gnotta.m1nch1a.m1nchia.m1st.mam0n.mamahuev0.mamahuevo.mamon.masturbat10n.masturbat1on.masturbate.masturbati0n.masturbation.merd0s0.merd0so.merda.merde.merdos0.merdoso.mierda.mign0tta.mignotta.minch1a.minchia.mist.musch1.muschi.n1gger.neger.negr0.negre.negro.nerch1a.nerchia.nigger.orgasm.p00p.p011a.p01la.p0l1a.p0lla.p0mp1n0.p0mp1no.p0mpin0.p0mpino.p0op.p0rca.p0rn.p0rra.p0uff1asse.p0uffiasse.p1p1.p1pi.p1r1a.p1rla.p1sc10.p1sc1o.p1sci0.p1scio.p1sser.pa11e.pa1le.pal1e.palle.pane1e1r0.pane1e1ro.pane1eir0.pane1eiro.panele1r0.panele1ro.paneleir0.paneleiro.patakha.pec0r1na.pec0rina.pecor1na.pecorina.pen1s.pendej0.pendejo.penis.pip1.pipi.pir1a.pirla.pisc10.pisc1o.pisci0.piscio.pisser.po0p.po11a.po1la.pol1a.polla.pomp1n0.pomp1no.pompin0.pompino.poop.porca.porn.porra.pouff1asse.pouffiasse.pr1ck.prick.pussy.put1za.puta.puta1n.putain.pute.putiza.puttana.queca.r0mp1ba11e.r0mp1ba1le.r0mp1bal1e.r0mp1balle.r0mpiba11e.r0mpiba1le.r0mpibal1e.r0mpiballe.rand1.randi.rape.recch10ne.recch1one.recchi0ne.recchione.retard.romp1ba11e.romp1ba1le.romp1bal1e.romp1balle.rompiba11e.rompiba1le.rompibal1e.rompiballe.ruff1an0.ruff1ano.ruffian0.ruffiano.s1ut.sa10pe.sa1aud.sa1ope.sacanagem.sal0pe.salaud.salope.saugnapf.sb0rr0ne.sb0rra.sb0rrone.sbattere.sbatters1.sbattersi.sborr0ne.sborra.sborrone.sc0pare.sc0pata.sch1ampe.sche1se.sche1sse.scheise.scheisse.schlampe.schwachs1nn1g.schwachs1nnig.schwachsinn1g.schwachsinnig.schwanz.scopare.scopata.sexy.sh1t.shit.slut.sp0mp1nare.sp0mpinare.spomp1nare.spompinare.str0nz0.str0nza.str0nzo.stronz0.stronza.stronzo.stup1d.stupid.succh1am1.succh1ami.succhiam1.succhiami.sucker.t0pa.tapette.test1c1e.test1cle.testic1e.testicle.tette.topa.tr01a.tr0ia.tr0mbare.tr1ng1er.tr1ngler.tring1er.tringler.tro1a.troia.trombare.turd.twat.vaffancu10.vaffancu1o.vaffancul0.vaffanculo.vag1na.vagina.verdammt.verga.w1chsen.wank.wichsen.x0ch0ta.x0chota.xana.xoch0ta.xochota.z0cc01a.z0cc0la.z0cco1a.z0ccola.z1z1.z1zi.ziz1.zizi.zocc01a.zocc0la.zocco1a.zoccola`.split(`.`))};var t=class{constructor(t){let n=t?.alphabet??e.alphabet,r=t?.minLength??e.minLength,i=t?.blocklist??e.blocklist;if(new Blob([n]).size!==n.length)throw Error(`Alphabet cannot contain multibyte characters`);if(n.length<3)throw Error(`Alphabet length must be at least 3`);if(new Set(n).size!==n.length)throw Error(`Alphabet must contain unique characters`);if(typeof r!=`number`||r<0||r>255)throw Error(`Minimum length has to be between 0 and 255`);let a=new Set,o=n.toLowerCase().split(``);for(let e of i)if(e.length>=3){let t=e.toLowerCase(),n=t.split(``);n.filter(e=>o.includes(e)).length===n.length&&a.add(t)}this.alphabet=this.shuffle(n),this.minLength=r,this.blocklist=a}encode(e){if(e.length===0)return``;if(e.filter(e=>e>=0&&e<=this.maxValue()).length!==e.length)throw Error(`Encoding supports numbers between 0 and ${this.maxValue()}`);return this.encodeNumbers(e)}decode(e){let t=[];if(e===``)return t;let n=this.alphabet.split(``);for(let r of e.split(``))if(!n.includes(r))return t;let r=e.charAt(0),i=this.alphabet.indexOf(r),a=this.alphabet.slice(i)+this.alphabet.slice(0,i);a=a.split(``).reverse().join(``);let o=e.slice(1);for(;o.length>0;){let e=a.slice(0,1),n=o.split(e);if(n.length>0){if(n[0]===``)return t;t.push(this.toNumber(n[0],a.slice(1))),n.length>1&&(a=this.shuffle(a))}o=n.slice(1).join(e)}return t}encodeNumbers(e,t=0){if(t>this.alphabet.length)throw Error(`Reached max attempts to re-generate the ID`);let n=e.reduce((e,t,n)=>this.alphabet[t%this.alphabet.length].codePointAt(0)+n+e,e.length)%this.alphabet.length;n=(n+t)%this.alphabet.length;let r=this.alphabet.slice(n)+this.alphabet.slice(0,n),i=r.charAt(0);r=r.split(``).reverse().join(``);let a=[i];for(let t=0;t!==e.length;t++){let n=e[t];a.push(this.toId(n,r.slice(1))),t<e.length-1&&(a.push(r.slice(0,1)),r=this.shuffle(r))}let o=a.join(``);if(this.minLength>o.length)for(o+=r.slice(0,1);this.minLength-o.length>0;)r=this.shuffle(r),o+=r.slice(0,Math.min(this.minLength-o.length,r.length));return this.isBlockedId(o)&&(o=this.encodeNumbers(e,t+1)),o}shuffle(e){let t=e.split(``);for(let e=0,n=t.length-1;n>0;e++,n--){let r=(e*n+t[e].codePointAt(0)+t[n].codePointAt(0))%t.length;[t[e],t[r]]=[t[r],t[e]]}return t.join(``)}toId(e,t){let n=[],r=t.split(``),i=e;do n.unshift(r[i%r.length]),i=Math.floor(i/r.length);while(i>0);return n.join(``)}toNumber(e,t){let n=t.split(``);return e.split(``).reduce((e,t)=>e*n.length+n.indexOf(t),0)}isBlockedId(e){let t=e.toLowerCase();for(let e of this.blocklist)if(e.length<=t.length){if(t.length<=3||e.length<=3){if(t===e)return!0}else if(/\d/.test(e)){if(t.startsWith(e)||t.endsWith(e))return!0}else if(t.includes(e))return!0}return!1}maxValue(){return 2**53-1}};export{t as default};
|
|
2
|
+
//# sourceMappingURL=sqids-BiDaWurc.mjs.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.
|
|
4
|
+
"version": "0.0.11",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://jsrepo.dev/docs/mcp",
|
|
7
7
|
"author": {
|
|
@@ -22,36 +22,36 @@
|
|
|
22
22
|
"ai"
|
|
23
23
|
],
|
|
24
24
|
"type": "module",
|
|
25
|
-
"bin": "./dist/index.
|
|
26
|
-
"main": "./dist/index.
|
|
25
|
+
"bin": "./dist/index.mjs",
|
|
26
|
+
"main": "./dist/index.mjs",
|
|
27
27
|
"files": [
|
|
28
28
|
"dist/**/*",
|
|
29
29
|
"!dist/**/*.map"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"jsrepo": "3.0.
|
|
32
|
+
"jsrepo": "3.0.10"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@tmcp/adapter-zod": "^0.1.7",
|
|
36
|
-
"@tmcp/transport-in-memory": "^0.0.
|
|
37
|
-
"@tmcp/transport-stdio": "^0.4.
|
|
38
|
-
"@types/node": "^
|
|
39
|
-
"dedent": "^1.7.
|
|
36
|
+
"@tmcp/transport-in-memory": "^0.0.5",
|
|
37
|
+
"@tmcp/transport-stdio": "^0.4.1",
|
|
38
|
+
"@types/node": "^25.0.3",
|
|
39
|
+
"dedent": "^1.7.1",
|
|
40
40
|
"fuzzysort": "^3.1.0",
|
|
41
41
|
"picocolors": "^1.1.1",
|
|
42
|
-
"tmcp": "^1.
|
|
43
|
-
"tsdown": "
|
|
42
|
+
"tmcp": "^1.19.0",
|
|
43
|
+
"tsdown": "0.19.0-beta.3",
|
|
44
44
|
"typescript": "^5.9.3",
|
|
45
45
|
"vitest": "^4.0.7",
|
|
46
|
-
"zod": "^4.
|
|
46
|
+
"zod": "^4.3.5"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsdown",
|
|
50
50
|
"dev": "tsdown --watch",
|
|
51
|
-
"start": "node ./dist/index.
|
|
51
|
+
"start": "node ./dist/index.mjs mcp",
|
|
52
52
|
"check": "tsc --noEmit",
|
|
53
|
-
"mcp:inspector": "pnpm dlx @modelcontextprotocol/inspector node ./dist/index.
|
|
53
|
+
"mcp:inspector": "pnpm dlx @modelcontextprotocol/inspector node ./dist/index.mjs mcp",
|
|
54
54
|
"test": "vitest",
|
|
55
|
-
"bundle-analyze": "FORCE_COLOR=1 node ../../bundle-analyzer/dist/index.
|
|
55
|
+
"bundle-analyze": "FORCE_COLOR=1 node ../../bundle-analyzer/dist/index.mjs analyze ."
|
|
56
56
|
}
|
|
57
57
|
}
|
package/dist/index.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
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,y=Object.prototype.hasOwnProperty,b=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),x=(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],!y.call(e,s)&&s!==n&&ee(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=g(t,s))||r.enumerable});return e},S=(e,t,n)=>(n=e==null?{}:h(v(e)),x(t||!e||!e.__esModule?ee(n,`default`,{value:e,enumerable:!0}):n,e)),te=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)+`
|
|
3
|
-
`)})),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)+`
|
|
4
|
-
`)})),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(`
|
|
5
|
-
`);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)+`
|
|
6
|
-
`)}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(`
|
|
7
|
-
`).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(`
|
|
8
|
-
`))}};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(`
|
|
9
|
-
if (${n}.issues.length) {
|
|
10
|
-
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
11
|
-
...iss,
|
|
12
|
-
path: iss.path ? [${r}, ...iss.path] : [${r}]
|
|
13
|
-
})));
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (${n}.value === undefined) {
|
|
18
|
-
if (${r} in input) {
|
|
19
|
-
newResult[${r}] = undefined;
|
|
20
|
-
}
|
|
21
|
-
} else {
|
|
22
|
-
newResult[${r}] = ${n}.value;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,o=ue,s=!re.jitless,c=s&&de.value,l=t.catchall,u;e._zod.parse=(d,f)=>{u??=r.value;let p=d.value;return o(p)?s&&c&&f?.async===!1&&f.jitless!==!0?(a||=i(t.shape),d=a(d,f),l?On([],p,d,f,u,e):d):n(d,f):(d.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),d)}});function jn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Ee(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>ke(e,r,D())))}),t)}const Mn=T(`$ZodUnion`,(e,t)=>{I.init(e,t),j(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),j(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),j(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),j(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>oe(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>jn(t,i,e,a)):jn(s,i,e,a)}}),Nn=T(`$ZodIntersection`,(e,t)=>{I.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Fn(e,t,n)):Fn(e,i,a)}});function Pn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(fe(e)&&fe(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Pn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Pn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Fn(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),Ee(e))return e;let r=Pn(t.value,n.value);if(!r.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const In=T(`$ZodEnum`,(e,t)=>{I.init(e,t);let n=ie(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>me.has(typeof e)).map(e=>typeof e==`string`?he(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Ln=T(`$ZodTransform`,(e,t)=>{I.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ne(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new E;return n.value=i,n}});function Rn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const zn=T(`$ZodOptional`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),j(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${oe(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>Rn(t,e.value)):Rn(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Bn=T(`$ZodNullable`,(e,t)=>{I.init(e,t),j(e._zod,`optin`,()=>t.innerType._zod.optin),j(e._zod,`optout`,()=>t.innerType._zod.optout),j(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${oe(e.source)}|null)$`):void 0}),j(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Vn=T(`$ZodDefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Hn(e,t)):Hn(r,t)}});function Hn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Un=T(`$ZodPrefault`,(e,t)=>{I.init(e,t),e._zod.optin=`optional`,j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Wn=T(`$ZodNonOptional`,(e,t)=>{I.init(e,t),j(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Gn(t,e)):Gn(i,e)}});function Gn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}const Kn=T(`$ZodCatch`,(e,t)=>{I.init(e,t),j(e._zod,`optin`,()=>t.innerType._zod.optin),j(e._zod,`optout`,()=>t.innerType._zod.optout),j(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>ke(e,n,D()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>ke(e,n,D()))},input:e.value}),e.issues=[]),e)}}),qn=T(`$ZodPipe`,(e,t)=>{I.init(e,t),j(e._zod,`values`,()=>t.in._zod.values),j(e._zod,`optin`,()=>t.in._zod.optin),j(e._zod,`optout`,()=>t.out._zod.optout),j(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Jn(e,t.in,n)):Jn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Jn(e,t.out,n)):Jn(r,t.out,n)}});function Jn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Yn=T(`$ZodReadonly`,(e,t)=>{I.init(e,t),j(e._zod,`propValues`,()=>t.innerType._zod.propValues),j(e._zod,`values`,()=>t.innerType._zod.values),j(e._zod,`optin`,()=>t.innerType._zod.optin),j(e._zod,`optout`,()=>t.innerType._zod.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Xn):Xn(r)}});function Xn(e){return e.value=Object.freeze(e.value),e}const Zn=T(`$ZodCustom`,(e,t)=>{F.init(e,t),I.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Qn(t,n,r,e));Qn(i,n,r,e)}});function Qn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(je(e))}}var $n=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];if(this._map.set(e,n),n&&typeof n==`object`&&`id`in n){if(this._idmap.has(n.id))throw Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function er(){return new $n}const tr=er();function nr(e,t){return new e({type:`string`,...P(t)})}function rr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...P(t)})}function ir(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...P(t)})}function ar(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...P(t)})}function or(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...P(t)})}function sr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...P(t)})}function cr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...P(t)})}function lr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...P(t)})}function ur(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...P(t)})}function dr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...P(t)})}function fr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...P(t)})}function pr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...P(t)})}function mr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...P(t)})}function hr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...P(t)})}function gr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...P(t)})}function _r(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...P(t)})}function vr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...P(t)})}function yr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...P(t)})}function br(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...P(t)})}function xr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...P(t)})}function Sr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...P(t)})}function Cr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...P(t)})}function wr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...P(t)})}function Tr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...P(t)})}function Er(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...P(t)})}function Dr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...P(t)})}function Or(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...P(t)})}function kr(e,t){return new e({type:`number`,checks:[],...P(t)})}function Ar(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...P(t)})}function jr(e,t){return new e({type:`boolean`,...P(t)})}function Mr(e){return new e({type:`unknown`})}function Nr(e,t){return new e({type:`never`,...P(t)})}function Pr(e,t){return new Ot({check:`less_than`,...P(t),value:e,inclusive:!1})}function Fr(e,t){return new Ot({check:`less_than`,...P(t),value:e,inclusive:!0})}function Ir(e,t){return new kt({check:`greater_than`,...P(t),value:e,inclusive:!1})}function Lr(e,t){return new kt({check:`greater_than`,...P(t),value:e,inclusive:!0})}function Rr(e,t){return new At({check:`multiple_of`,...P(t),value:e})}function zr(e,t){return new Mt({check:`max_length`,...P(t),maximum:e})}function Br(e,t){return new Nt({check:`min_length`,...P(t),minimum:e})}function Vr(e,t){return new Pt({check:`length_equals`,...P(t),length:e})}function Hr(e,t){return new It({check:`string_format`,format:`regex`,...P(t),pattern:e})}function Ur(e){return new Lt({check:`string_format`,format:`lowercase`,...P(e)})}function Wr(e){return new Rt({check:`string_format`,format:`uppercase`,...P(e)})}function Gr(e,t){return new zt({check:`string_format`,format:`includes`,...P(t),includes:e})}function Kr(e,t){return new Bt({check:`string_format`,format:`starts_with`,...P(t),prefix:e})}function qr(e,t){return new Vt({check:`string_format`,format:`ends_with`,...P(t),suffix:e})}function Jr(e){return new Ht({check:`overwrite`,tx:e})}function Yr(e){return Jr(t=>t.normalize(e))}function Xr(){return Jr(e=>e.trim())}function Zr(){return Jr(e=>e.toLowerCase())}function Qr(){return Jr(e=>e.toUpperCase())}function $r(e,t,n){return new e({type:`array`,element:t,...P(n)})}function ei(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...P(n)})}function ti(e){let t=ni(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(je(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(je(r))}},e(n.value,n)));return t}function ni(e,t){let n=new F({check:`custom`,...P(t)});return n._zod.check=e,n}var ri=class{constructor(e){this.counter=0,this.metadataRegistry=e?.metadata??tr,this.target=e?.target??`draft-2020-12`,this.unrepresentable=e?.unrepresentable??`throw`,this.override=e?.override??(()=>{}),this.io=e?.io??`output`,this.seen=new Map}process(e,t={path:[],schemaPath:[]}){var n;let r=e._zod.def,i={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},a=this.seen.get(e);if(a)return a.count++,t.schemaPath.includes(e)&&(a.cycle=t.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:t.path};this.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let n={...t,schemaPath:[...t.schemaPath,e],path:t.path},a=e._zod.parent;if(a)o.ref=a,this.process(a,n),this.seen.get(a).isParent=!0;else{let t=o.schema;switch(r.type){case`string`:{let n=t;n.type=`string`;let{minimum:r,maximum:a,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof r==`number`&&(n.minLength=r),typeof a==`number`&&(n.maxLength=a),s&&(n.format=i[s]??s,n.format===``&&delete n.format),l&&(n.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?n.pattern=e[0].source:e.length>1&&(o.schema.allOf=[...e.map(e=>({...this.target===`draft-7`||this.target===`draft-4`||this.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}break}case`number`:{let n=t,{minimum:r,maximum:i,format:a,multipleOf:o,exclusiveMaximum:s,exclusiveMinimum:c}=e._zod.bag;typeof a==`string`&&a.includes(`int`)?n.type=`integer`:n.type=`number`,typeof c==`number`&&(this.target===`draft-4`||this.target===`openapi-3.0`?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c),typeof r==`number`&&(n.minimum=r,typeof c==`number`&&this.target!==`draft-4`&&(c>=r?delete n.minimum:delete n.exclusiveMinimum)),typeof s==`number`&&(this.target===`draft-4`||this.target===`openapi-3.0`?(n.maximum=s,n.exclusiveMaximum=!0):n.exclusiveMaximum=s),typeof i==`number`&&(n.maximum=i,typeof s==`number`&&this.target!==`draft-4`&&(s<=i?delete n.maximum:delete n.exclusiveMaximum)),typeof o==`number`&&(n.multipleOf=o);break}case`boolean`:{let e=t;e.type=`boolean`;break}case`bigint`:if(this.unrepresentable===`throw`)throw Error(`BigInt cannot be represented in JSON Schema`);break;case`symbol`:if(this.unrepresentable===`throw`)throw Error(`Symbols cannot be represented in JSON Schema`);break;case`null`:this.target===`openapi-3.0`?(t.type=`string`,t.nullable=!0,t.enum=[null]):t.type=`null`;break;case`any`:break;case`unknown`:break;case`undefined`:if(this.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`);break;case`void`:if(this.unrepresentable===`throw`)throw Error(`Void cannot be represented in JSON Schema`);break;case`never`:t.not={};break;case`date`:if(this.unrepresentable===`throw`)throw Error(`Date cannot be represented in JSON Schema`);break;case`array`:{let i=t,{minimum:a,maximum:o}=e._zod.bag;typeof a==`number`&&(i.minItems=a),typeof o==`number`&&(i.maxItems=o),i.type=`array`,i.items=this.process(r.element,{...n,path:[...n.path,`items`]});break}case`object`:{let e=t;e.type=`object`,e.properties={};let i=r.shape;for(let t in i)e.properties[t]=this.process(i[t],{...n,path:[...n.path,`properties`,t]});let a=new Set(Object.keys(i)),o=new Set([...a].filter(e=>{let t=r.shape[e]._zod;return this.io===`input`?t.optin===void 0:t.optout===void 0}));o.size>0&&(e.required=Array.from(o)),r.catchall?._zod.def.type===`never`?e.additionalProperties=!1:r.catchall?r.catchall&&(e.additionalProperties=this.process(r.catchall,{...n,path:[...n.path,`additionalProperties`]})):this.io===`output`&&(e.additionalProperties=!1);break}case`union`:{let e=t;e.anyOf=r.options.map((e,t)=>this.process(e,{...n,path:[...n.path,`anyOf`,t]}));break}case`intersection`:{let e=t,i=this.process(r.left,{...n,path:[...n.path,`allOf`,0]}),a=this.process(r.right,{...n,path:[...n.path,`allOf`,1]}),o=e=>`allOf`in e&&Object.keys(e).length===1;e.allOf=[...o(i)?i.allOf:[i],...o(a)?a.allOf:[a]];break}case`tuple`:{let i=t;i.type=`array`;let a=this.target===`draft-2020-12`?`prefixItems`:`items`,o=this.target===`draft-2020-12`||this.target===`openapi-3.0`?`items`:`additionalItems`,s=r.items.map((e,t)=>this.process(e,{...n,path:[...n.path,a,t]})),c=r.rest?this.process(r.rest,{...n,path:[...n.path,o,...this.target===`openapi-3.0`?[r.items.length]:[]]}):null;this.target===`draft-2020-12`?(i.prefixItems=s,c&&(i.items=c)):this.target===`openapi-3.0`?(i.items={anyOf:s},c&&i.items.anyOf.push(c),i.minItems=s.length,c||(i.maxItems=s.length)):(i.items=s,c&&(i.additionalItems=c));let{minimum:l,maximum:u}=e._zod.bag;typeof l==`number`&&(i.minItems=l),typeof u==`number`&&(i.maxItems=u);break}case`record`:{let e=t;e.type=`object`,(this.target===`draft-7`||this.target===`draft-2020-12`)&&(e.propertyNames=this.process(r.keyType,{...n,path:[...n.path,`propertyNames`]})),e.additionalProperties=this.process(r.valueType,{...n,path:[...n.path,`additionalProperties`]});break}case`map`:if(this.unrepresentable===`throw`)throw Error(`Map cannot be represented in JSON Schema`);break;case`set`:if(this.unrepresentable===`throw`)throw Error(`Set cannot be represented in JSON Schema`);break;case`enum`:{let e=t,n=ie(r.entries);n.every(e=>typeof e==`number`)&&(e.type=`number`),n.every(e=>typeof e==`string`)&&(e.type=`string`),e.enum=n;break}case`literal`:{let e=t,n=[];for(let e of r.values)if(e===void 0){if(this.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(this.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);n.push(Number(e))}else n.push(e);if(n.length!==0)if(n.length===1){let t=n[0];e.type=t===null?`null`:typeof t,this.target===`draft-4`||this.target===`openapi-3.0`?e.enum=[t]:e.const=t}else n.every(e=>typeof e==`number`)&&(e.type=`number`),n.every(e=>typeof e==`string`)&&(e.type=`string`),n.every(e=>typeof e==`boolean`)&&(e.type=`string`),n.every(e=>e===null)&&(e.type=`null`),e.enum=n;break}case`file`:{let n=t,r={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:i,maximum:a,mime:o}=e._zod.bag;i!==void 0&&(r.minLength=i),a!==void 0&&(r.maxLength=a),o?o.length===1?(r.contentMediaType=o[0],Object.assign(n,r)):n.anyOf=o.map(e=>({...r,contentMediaType:e})):Object.assign(n,r);break}case`transform`:if(this.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`);break;case`nullable`:{let e=this.process(r.innerType,n);this.target===`openapi-3.0`?(o.ref=r.innerType,t.nullable=!0):t.anyOf=[e,{type:`null`}];break}case`nonoptional`:this.process(r.innerType,n),o.ref=r.innerType;break;case`success`:{let e=t;e.type=`boolean`;break}case`default`:this.process(r.innerType,n),o.ref=r.innerType,t.default=JSON.parse(JSON.stringify(r.defaultValue));break;case`prefault`:this.process(r.innerType,n),o.ref=r.innerType,this.io===`input`&&(t._prefault=JSON.parse(JSON.stringify(r.defaultValue)));break;case`catch`:{this.process(r.innerType,n),o.ref=r.innerType;let e;try{e=r.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}t.default=e;break}case`nan`:if(this.unrepresentable===`throw`)throw Error(`NaN cannot be represented in JSON Schema`);break;case`template_literal`:{let n=t,r=e._zod.pattern;if(!r)throw Error(`Pattern not found in template literal`);n.type=`string`,n.pattern=r.source;break}case`pipe`:{let e=this.io===`input`?r.in._zod.def.type===`transform`?r.out:r.in:r.out;this.process(e,n),o.ref=e;break}case`readonly`:this.process(r.innerType,n),o.ref=r.innerType,t.readOnly=!0;break;case`promise`:this.process(r.innerType,n),o.ref=r.innerType;break;case`optional`:this.process(r.innerType,n),o.ref=r.innerType;break;case`lazy`:{let t=e._zod.innerType;this.process(t,n),o.ref=t;break}case`custom`:if(this.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`);break;case`function`:if(this.unrepresentable===`throw`)throw Error(`Function types cannot be represented in JSON Schema`);break;default:}}}let c=this.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),this.io===`input`&&R(e)&&(delete o.schema.examples,delete o.schema.default),this.io===`input`&&o.schema._prefault&&((n=o.schema).default??(n.default=o.schema._prefault)),delete o.schema._prefault,this.seen.get(e).schema}emit(e,t){let n={cycles:t?.cycles??`ref`,reused:t?.reused??`inline`,external:t?.external??void 0},r=this.seen.get(e);if(!r)throw Error(`Unprocessed schema. This is a bug in Zod.`);let i=e=>{let t=this.target===`draft-2020-12`?`$defs`:`definitions`;if(n.external){let r=n.external.registry.get(e[0])?.id,i=n.external.uri??(e=>e);if(r)return{ref:i(r)};let a=e[1].defId??e[1].schema.id??`schema${this.counter++}`;return e[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${t}/${a}`}}if(e[1]===r)return{ref:`#`};let i=`#/${t}/`,a=e[1].schema.id??`__schema${this.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(n.cycles===`throw`)for(let e of this.seen.entries()){let t=e[1];if(t.cycle)throw Error(`Cycle detected: #/${t.cycle?.join(`/`)}/<root>
|
|
26
|
-
|
|
27
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let t of this.seen.entries()){let r=t[1];if(e===t[0]){a(t);continue}if(n.external){let r=n.external.registry.get(t[0])?.id;if(e!==t[0]&&r){a(t);continue}}if(this.metadataRegistry.get(t[0])?.id){a(t);continue}if(r.cycle){a(t);continue}if(r.count>1&&n.reused===`ref`){a(t);continue}}let o=(e,t)=>{let n=this.seen.get(e),r=n.def??n.schema,i={...r};if(n.ref===null)return;let a=n.ref;if(n.ref=null,a){o(a,t);let e=this.seen.get(a).schema;e.$ref&&(t.target===`draft-7`||t.target===`draft-4`||t.target===`openapi-3.0`)?(r.allOf=r.allOf??[],r.allOf.push(e)):(Object.assign(r,e),Object.assign(r,i))}n.isParent||this.override({zodSchema:e,jsonSchema:r,path:n.path??[]})};for(let e of[...this.seen.entries()].reverse())o(e[0],{target:this.target});let s={};if(this.target===`draft-2020-12`?s.$schema=`https://json-schema.org/draft/2020-12/schema`:this.target===`draft-7`?s.$schema=`http://json-schema.org/draft-07/schema#`:this.target===`draft-4`?s.$schema=`http://json-schema.org/draft-04/schema#`:this.target===`openapi-3.0`||console.warn(`Invalid target: ${this.target}`),n.external?.uri){let t=n.external.registry.get(e)?.id;if(!t)throw Error("Schema is missing an `id` property");s.$id=n.external.uri(t)}Object.assign(s,r.def);let c=n.external?.defs??{};for(let e of this.seen.entries()){let t=e[1];t.def&&t.defId&&(c[t.defId]=t.def)}n.external||Object.keys(c).length>0&&(this.target===`draft-2020-12`?s.$defs=c:s.definitions=c);try{return JSON.parse(JSON.stringify(s))}catch{throw Error(`Error converting schema to JSON.`)}}};function ii(e,t){if(e instanceof $n){let n=new ri(t),r={};for(let t of e._idmap.entries()){let[e,r]=t;n.process(r)}let i={},a={registry:e,uri:t?.uri,defs:r};for(let r of e._idmap.entries()){let[e,o]=r;i[e]=n.emit(o,{...t,external:a})}return Object.keys(r).length>0&&(i.__shared={[n.target===`draft-2020-12`?`$defs`:`definitions`]:r}),{schemas:i}}let n=new ri(t);return n.process(e),n.emit(e,t)}function R(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;switch(r.type){case`string`:case`number`:case`bigint`:case`boolean`:case`date`:case`symbol`:case`undefined`:case`null`:case`any`:case`unknown`:case`never`:case`void`:case`literal`:case`enum`:case`nan`:case`file`:case`template_literal`:return!1;case`array`:return R(r.element,n);case`object`:for(let e in r.shape)if(R(r.shape[e],n))return!0;return!1;case`union`:for(let e of r.options)if(R(e,n))return!0;return!1;case`intersection`:return R(r.left,n)||R(r.right,n);case`tuple`:for(let e of r.items)if(R(e,n))return!0;return!!(r.rest&&R(r.rest,n));case`record`:return R(r.keyType,n)||R(r.valueType,n);case`map`:return R(r.keyType,n)||R(r.valueType,n);case`set`:return R(r.valueType,n);case`promise`:case`optional`:case`nonoptional`:case`nullable`:case`readonly`:return R(r.innerType,n);case`lazy`:return R(r.getter(),n);case`default`:return R(r.innerType,n);case`prefault`:return R(r.innerType,n);case`custom`:return!1;case`transform`:return!0;case`pipe`:return R(r.in,n)||R(r.out,n);case`success`:return!1;case`catch`:return!1;case`function`:return!1;default:}throw Error(`Unknown schema type: ${r.type}`)}const ai=T(`ZodISODateTime`,(e,t)=>{rn.init(e,t),V.init(e,t)});function oi(e){return Tr(ai,e)}const si=T(`ZodISODate`,(e,t)=>{an.init(e,t),V.init(e,t)});function ci(e){return Er(si,e)}const li=T(`ZodISOTime`,(e,t)=>{on.init(e,t),V.init(e,t)});function ui(e){return Dr(li,e)}const di=T(`ZodISODuration`,(e,t)=>{sn.init(e,t),V.init(e,t)});function fi(e){return Or(di,e)}const pi=(e,t)=>{Ne.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ie(e,t)},flatten:{value:t=>Fe(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,O,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,O,2)}},isEmpty:{get(){return e.issues.length===0}}})};T(`ZodError`,pi);const z=T(`ZodError`,pi,{Parent:Error}),mi=Le(z),hi=Re(z),gi=ze(z),_i=Ve(z),vi=Ue(z),yi=We(z),bi=Ge(z),xi=Ke(z),Si=qe(z),Ci=Je(z),wi=Ye(z),Ti=Xe(z),B=T(`ZodType`,(e,t)=>(I.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(M(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]})),e.clone=(t,n)=>ge(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>mi(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>gi(e,t,n),e.parseAsync=async(t,n)=>hi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>_i(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>vi(e,t,n),e.decode=(t,n)=>yi(e,t,n),e.encodeAsync=async(t,n)=>bi(e,t,n),e.decodeAsync=async(t,n)=>xi(e,t,n),e.safeEncode=(t,n)=>Si(e,t,n),e.safeDecode=(t,n)=>Ci(e,t,n),e.safeEncodeAsync=async(t,n)=>wi(e,t,n),e.safeDecodeAsync=async(t,n)=>Ti(e,t,n),e.refine=(t,n)=>e.check(Na(t,n)),e.superRefine=t=>e.check(Pa(t)),e.overwrite=t=>e.check(Jr(t)),e.optional=()=>_a(e),e.nullable=()=>ya(e),e.nullish=()=>_a(ya(e)),e.nonoptional=t=>Ta(e,t),e.array=()=>aa(e),e.or=t=>la([e,t]),e.and=t=>da(e,t),e.transform=t=>ka(e,ha(t)),e.default=t=>xa(e,t),e.prefault=t=>Ca(e,t),e.catch=t=>Da(e,t),e.pipe=t=>ka(e,t),e.readonly=()=>ja(e),e.describe=t=>{let n=e.clone();return tr.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return tr.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return tr.get(e);let n=e.clone();return tr.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Ei=T(`_ZodString`,(e,t)=>{Gt.init(e,t),B.init(e,t);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Hr(...t)),e.includes=(...t)=>e.check(Gr(...t)),e.startsWith=(...t)=>e.check(Kr(...t)),e.endsWith=(...t)=>e.check(qr(...t)),e.min=(...t)=>e.check(Br(...t)),e.max=(...t)=>e.check(zr(...t)),e.length=(...t)=>e.check(Vr(...t)),e.nonempty=(...t)=>e.check(Br(1,...t)),e.lowercase=t=>e.check(Ur(t)),e.uppercase=t=>e.check(Wr(t)),e.trim=()=>e.check(Xr()),e.normalize=(...t)=>e.check(Yr(...t)),e.toLowerCase=()=>e.check(Zr()),e.toUpperCase=()=>e.check(Qr())}),Di=T(`ZodString`,(e,t)=>{Gt.init(e,t),Ei.init(e,t),e.email=t=>e.check(rr(ki,t)),e.url=t=>e.check(lr(Mi,t)),e.jwt=t=>e.check(wr(qi,t)),e.emoji=t=>e.check(ur(Ni,t)),e.guid=t=>e.check(ir(Ai,t)),e.uuid=t=>e.check(ar(ji,t)),e.uuidv4=t=>e.check(or(ji,t)),e.uuidv6=t=>e.check(sr(ji,t)),e.uuidv7=t=>e.check(cr(ji,t)),e.nanoid=t=>e.check(dr(Pi,t)),e.guid=t=>e.check(ir(Ai,t)),e.cuid=t=>e.check(fr(Fi,t)),e.cuid2=t=>e.check(pr(Ii,t)),e.ulid=t=>e.check(mr(Li,t)),e.base64=t=>e.check(xr(Wi,t)),e.base64url=t=>e.check(Sr(Gi,t)),e.xid=t=>e.check(hr(Ri,t)),e.ksuid=t=>e.check(gr(zi,t)),e.ipv4=t=>e.check(_r(Bi,t)),e.ipv6=t=>e.check(vr(Vi,t)),e.cidrv4=t=>e.check(yr(Hi,t)),e.cidrv6=t=>e.check(br(Ui,t)),e.e164=t=>e.check(Cr(Ki,t)),e.datetime=t=>e.check(oi(t)),e.date=t=>e.check(ci(t)),e.time=t=>e.check(ui(t)),e.duration=t=>e.check(fi(t))});function Oi(e){return nr(Di,e)}const V=T(`ZodStringFormat`,(e,t)=>{L.init(e,t),Ei.init(e,t)}),ki=T(`ZodEmail`,(e,t)=>{Jt.init(e,t),V.init(e,t)}),Ai=T(`ZodGUID`,(e,t)=>{Kt.init(e,t),V.init(e,t)}),ji=T(`ZodUUID`,(e,t)=>{qt.init(e,t),V.init(e,t)}),Mi=T(`ZodURL`,(e,t)=>{Yt.init(e,t),V.init(e,t)}),Ni=T(`ZodEmoji`,(e,t)=>{Xt.init(e,t),V.init(e,t)}),Pi=T(`ZodNanoID`,(e,t)=>{Zt.init(e,t),V.init(e,t)}),Fi=T(`ZodCUID`,(e,t)=>{Qt.init(e,t),V.init(e,t)}),Ii=T(`ZodCUID2`,(e,t)=>{$t.init(e,t),V.init(e,t)}),Li=T(`ZodULID`,(e,t)=>{en.init(e,t),V.init(e,t)}),Ri=T(`ZodXID`,(e,t)=>{tn.init(e,t),V.init(e,t)}),zi=T(`ZodKSUID`,(e,t)=>{nn.init(e,t),V.init(e,t)}),Bi=T(`ZodIPv4`,(e,t)=>{cn.init(e,t),V.init(e,t)}),Vi=T(`ZodIPv6`,(e,t)=>{ln.init(e,t),V.init(e,t)}),Hi=T(`ZodCIDRv4`,(e,t)=>{un.init(e,t),V.init(e,t)}),Ui=T(`ZodCIDRv6`,(e,t)=>{dn.init(e,t),V.init(e,t)}),Wi=T(`ZodBase64`,(e,t)=>{pn.init(e,t),V.init(e,t)}),Gi=T(`ZodBase64URL`,(e,t)=>{hn.init(e,t),V.init(e,t)}),Ki=T(`ZodE164`,(e,t)=>{gn.init(e,t),V.init(e,t)}),qi=T(`ZodJWT`,(e,t)=>{vn.init(e,t),V.init(e,t)}),Ji=T(`ZodNumber`,(e,t)=>{yn.init(e,t),B.init(e,t),e.gt=(t,n)=>e.check(Ir(t,n)),e.gte=(t,n)=>e.check(Lr(t,n)),e.min=(t,n)=>e.check(Lr(t,n)),e.lt=(t,n)=>e.check(Pr(t,n)),e.lte=(t,n)=>e.check(Fr(t,n)),e.max=(t,n)=>e.check(Fr(t,n)),e.int=t=>e.check(Zi(t)),e.safe=t=>e.check(Zi(t)),e.positive=t=>e.check(Ir(0,t)),e.nonnegative=t=>e.check(Lr(0,t)),e.negative=t=>e.check(Pr(0,t)),e.nonpositive=t=>e.check(Fr(0,t)),e.multipleOf=(t,n)=>e.check(Rr(t,n)),e.step=(t,n)=>e.check(Rr(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Yi(e){return kr(Ji,e)}const Xi=T(`ZodNumberFormat`,(e,t)=>{bn.init(e,t),Ji.init(e,t)});function Zi(e){return Ar(Xi,e)}const Qi=T(`ZodBoolean`,(e,t)=>{xn.init(e,t),B.init(e,t)});function $i(e){return jr(Qi,e)}const ea=T(`ZodUnknown`,(e,t)=>{Sn.init(e,t),B.init(e,t)});function ta(){return Mr(ea)}const na=T(`ZodNever`,(e,t)=>{Cn.init(e,t),B.init(e,t)});function ra(e){return Nr(na,e)}const ia=T(`ZodArray`,(e,t)=>{Tn.init(e,t),B.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(Br(t,n)),e.nonempty=t=>e.check(Br(1,t)),e.max=(t,n)=>e.check(zr(t,n)),e.length=(t,n)=>e.check(Vr(t,n)),e.unwrap=()=>e.element});function aa(e,t){return $r(ia,e,t)}const oa=T(`ZodObject`,(e,t)=>{An.init(e,t),B.init(e,t),j(e,`shape`,()=>t.shape),e.keyof=()=>pa(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ta()}),e.loose=()=>e.clone({...e._zod.def,catchall:ta()}),e.strict=()=>e.clone({...e._zod.def,catchall:ra()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>xe(e,t),e.safeExtend=t=>Se(e,t),e.merge=t=>Ce(e,t),e.pick=t=>ye(e,t),e.omit=t=>be(e,t),e.partial=(...t)=>we(ga,e,t[0]),e.required=(...t)=>Te(wa,e,t[0])});function sa(e,t){return new oa({type:`object`,shape:e??{},...P(t)})}const ca=T(`ZodUnion`,(e,t)=>{Mn.init(e,t),B.init(e,t),e.options=t.options});function la(e,t){return new ca({type:`union`,options:e,...P(t)})}const ua=T(`ZodIntersection`,(e,t)=>{Nn.init(e,t),B.init(e,t)});function da(e,t){return new ua({type:`intersection`,left:e,right:t})}const fa=T(`ZodEnum`,(e,t)=>{In.init(e,t),B.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new fa({...t,checks:[],...P(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new fa({...t,checks:[],...P(r),entries:i})}});function pa(e,t){return new fa({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...P(t)})}const ma=T(`ZodTransform`,(e,t)=>{Ln.init(e,t),B.init(e,t),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ne(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(je(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(je(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function ha(e){return new ma({type:`transform`,transform:e})}const ga=T(`ZodOptional`,(e,t)=>{zn.init(e,t),B.init(e,t),e.unwrap=()=>e._zod.def.innerType});function _a(e){return new ga({type:`optional`,innerType:e})}const va=T(`ZodNullable`,(e,t)=>{Bn.init(e,t),B.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ya(e){return new va({type:`nullable`,innerType:e})}const ba=T(`ZodDefault`,(e,t)=>{Vn.init(e,t),B.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function xa(e,t){return new ba({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():pe(t)}})}const Sa=T(`ZodPrefault`,(e,t)=>{Un.init(e,t),B.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ca(e,t){return new Sa({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():pe(t)}})}const wa=T(`ZodNonOptional`,(e,t)=>{Wn.init(e,t),B.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Ta(e,t){return new wa({type:`nonoptional`,innerType:e,...P(t)})}const Ea=T(`ZodCatch`,(e,t)=>{Kn.init(e,t),B.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Da(e,t){return new Ea({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}const Oa=T(`ZodPipe`,(e,t)=>{qn.init(e,t),B.init(e,t),e.in=t.in,e.out=t.out});function ka(e,t){return new Oa({type:`pipe`,in:e,out:t})}const Aa=T(`ZodReadonly`,(e,t)=>{Yn.init(e,t),B.init(e,t),e.unwrap=()=>e._zod.def.innerType});function ja(e){return new Aa({type:`readonly`,innerType:e})}const Ma=T(`ZodCustom`,(e,t)=>{Zn.init(e,t),B.init(e,t)});function Na(e,t={}){return ei(Ma,e,t)}function Pa(e){return ti(e)}var Fa=class extends w{async toJsonSchema(e){return ii(e,{target:`draft-7`})}};function Ia(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function La(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ia(Object(n),!0).forEach(function(t){Ra(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ia(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ra(e,t,n){return t=za(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function za(e){var t=Ba(e,`string`);return typeof t==`symbol`?t:String(t)}function Ba(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Va=Ha({});function Ha(e){return t.withOptions=t=>Ha(La(La({},e),t)),t;function t(t,...n){let r=typeof t==`string`?[t]:t.raw,{alignValues:i=!1,escapeSpecialCharacters:a=Array.isArray(t),trimWhitespace:o=!0}=e,s=``;for(let e=0;e<r.length;e++){let t=r[e];if(a&&(t=t.replace(/\\\n[ \t]*/g,``).replace(/\\`/g,"`").replace(/\\\$/g,`$`).replace(/\\\{/g,`{`)),s+=t,e<n.length){let t=i?Ua(n[e],s):n[e];s+=t}}let c=s.split(`
|
|
28
|
-
`),l=null;for(let e of c){let t=e.match(/^(\s+)\S+/);if(t){let e=t[1].length;l=l?Math.min(l,e):e}}if(l!==null){let e=l;s=c.map(t=>t[0]===` `||t[0]===` `?t.slice(e):t).join(`
|
|
29
|
-
`)}return o&&(s=s.trim()),a&&(s=s.replace(/\\n/g,`
|
|
30
|
-
`)),s}}function Ua(e,t){if(typeof e!=`string`||!e.includes(`
|
|
31
|
-
`))return e;let n=t.slice(t.lastIndexOf(`
|
|
32
|
-
`)+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,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 y=t[v],b=re(y,_);if(b&&(D(b)||(b=f(b)),(i&b._bitflags)===i)){var x=h(r,b);x!==k&&(x._score<o||(x.obj=y,g(x)))}}else if(n?.keys){var S=n.keys,te=S.length;outer:for(var v=0;v<ee;++v){for(var y=t[v],C=0,A=0;A<te;++A){var _=S[A],b=re(y,_);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=y,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 b=t[v];if(b&&(D(b)||(b=f(b)),(i&b._bitflags)===i)){var x=h(r,b);x!==k&&(x._score<o||g(x))}}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=()=>{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=_(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=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 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(S[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=y(t.target)),f=S[0]===0?0:_[S[0]-1];var v=0;if(f!==u)for(;;)if(f>=u){if(d<=0||(++v,v>200))break;--d;var b=te[--g];f=_[b]}else{var m=a[d]===c[f];if(m){if(te[g++]=f,++d,d===l){h=!0;break}++f}else f=_[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<_.length;T=_[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=_[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)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},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 y=h(e,t,!0);if(y!==k&&y._score>i){if(n)for(var f=0;f<c;++f)T[f]=y._score/c;return y}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},y=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},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.9`;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`
|
|
33
|
-
Failed to get paths for items: ${v.error.message}.
|
|
34
|
-
You will need to add the paths to the users config file (if they aren't already added) like so:
|
|
35
|
-
\`\`\`
|
|
36
|
-
import { defineConfig } from "jsrepo";
|
|
37
|
-
|
|
38
|
-
export default defineConfig({
|
|
39
|
-
// ...
|
|
40
|
-
paths: {
|
|
41
|
-
// ...
|
|
42
|
-
${_.map(e=>`"${r(e.type)}": "put the expected path here",`).join(`
|
|
43
|
-
`)}
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
\`\`\`
|
|
47
|
-
`}]};let{itemPaths: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: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:
|
|
48
|
-
${_.map(e=>Zs(e)).join(`
|
|
49
|
-
`)}`}]}}),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`,`item.categories`]});if(e.length===0)return{content:[{type:`text`,text:Va`
|
|
50
|
-
No results found for "${n}".
|
|
51
|
-
`}]};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`
|
|
52
|
-
## ${e.registry.url}/${e.item.name} - ${e.item.type}
|
|
53
|
-
${e.item.description??``}
|
|
54
|
-
|
|
55
|
-
Files:
|
|
56
|
-
${e.item.files.map(e=>`- ${e.path}`).join(`
|
|
57
|
-
`)}
|
|
58
|
-
`}return{content:[{type:`text`,text:Va`
|
|
59
|
-
# Search results
|
|
60
|
-
Found ${d.length} results for "${n}".
|
|
61
|
-
Showing ${p.length} results.
|
|
62
|
-
|
|
63
|
-
${p.map(m).join(`
|
|
64
|
-
`)}
|
|
65
|
-
`}]}});function Zs(e){return Va`
|
|
66
|
-
# ${e.name} - ${e.type}${e.categories?` (Categories: ${e.categories.join(`, `)})`:``}
|
|
67
|
-
${e.description??``}
|
|
68
|
-
|
|
69
|
-
## Files
|
|
70
|
-
${e.files?.filter(e=>e.role===void 0||e.role===`file`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
71
|
-
`)}
|
|
72
|
-
|
|
73
|
-
## Dependencies
|
|
74
|
-
${e.dependencies?.map(e=>`- ${typeof e==`string`?e:e.name}`).join(`
|
|
75
|
-
`)}
|
|
76
|
-
|
|
77
|
-
## Examples
|
|
78
|
-
${e.files?.filter(e=>e.role===`example`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
79
|
-
`)}
|
|
80
|
-
|
|
81
|
-
## Docs
|
|
82
|
-
${e.files?.filter(e=>e.role===`doc`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
83
|
-
`)}
|
|
84
|
-
|
|
85
|
-
## Tests
|
|
86
|
-
${e.files?.filter(e=>e.role===`test`).map(e=>`\`\`\`${e.path}\n${e.content}\n\`\`\``).join(`
|
|
87
|
-
`)}
|
|
88
|
-
|
|
89
|
-
## Environment Variables
|
|
90
|
-
Environment variables are required for the item to work. Blank variables will need to be filled in.
|
|
91
|
-
\`\`\`env
|
|
92
|
-
${Object.entries(e.envVars??{}).map(([e,t])=>`${e}="${t}"`).join(`
|
|
93
|
-
`)}
|
|
94
|
-
\`\`\`
|
|
95
|
-
|
|
96
|
-
Additional info:
|
|
97
|
-
${Object.entries(e.meta??{}).map(([e,t])=>`- ${e}: ${t}`).join(`
|
|
98
|
-
`)}
|
|
99
|
-
`}new te(Xs).listen(),process.stdout.write(`Server running...
|
|
100
|
-
`),process.stdout.write(C.default.dim(`Press ${C.default.bold(`Ctrl+C`)} to exit\n`));export{};
|
|
101
|
-
//# sourceMappingURL=index.js.map
|
|
File without changes
|