mboaai-sdk 1.0.11 → 1.0.13
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/mboaai-sdk.esm.js +1 -1
- package/dist/mboaai-sdk.umd.js +1 -1
- package/package.json +1 -1
package/dist/mboaai-sdk.esm.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{MCPClient as e}from"mcp-client";class t{static async init(a){if(!(null==a?void 0:a.apiKey))throw new Error("MboaAI-SDK: apiKey is required");if(t.ready)return;const{apiKey:r,mcpUrl:n="https://api.filparty.com:8001/mcp",name:i="MboaAI-SDK",version:o="1.0.0",defaultType:l="standard"}=a;t.client=new e({name:i,version:o}),await t.client.connect({type:"stdio",url:n,headers:{"x-api-key":r}}),t.apiKey=r,t.defaultType=l,t.ready=!0}static async translate(e,a,r){var n,i,o;if(!t.ready)throw new Error("MboaAI-SDK: call init() first");const l=`Translate "${e}" into ${a} for ${null!=r?r:t.defaultType}`;try{const a=await t.client.callTool({name:"run_translate",arguments:{message:l,api_key:t.apiKey}}),r=String(null!==(o=null===(i=null===(n=null==a?void 0:a.content)||void 0===n?void 0:n[0])||void 0===i?void 0:i.text)&&void 0!==o?o:"");if((e=>{const t=e.trim().charAt(0);return"{"===t||"["===t})(r))try{const t=JSON.parse(r);return t.reply||t.text||e}catch(e){}return r||e}catch(t){return console.error("[MboaAI-SDK] translate error → returning source",t),e}}}t.ready=!1,t.defaultType="standard",t.apiKey="","undefined"!=typeof window&&(window.MboaAI=window.MboaAI||{},window.MboaAI.T=t);export{t as T,t as default};
|
1
|
+
import{MCPClient as e}from"mcp-client";import t from"pkce-challenge";var s,a;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},e.getValidEnumValues=t=>{const s=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),a={};for(const e of s)a[e]=t[e];return e.objectValues(a)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},e.find=(e,t)=>{for(const s of e)if(t(s))return s},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(s||(s={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(a||(a={}));const n=s.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),r=e=>{switch(typeof e){case"undefined":return n.undefined;case"string":return n.string;case"number":return Number.isNaN(e)?n.nan:n.number;case"boolean":return n.boolean;case"function":return n.function;case"bigint":return n.bigint;case"symbol":return n.symbol;case"object":return Array.isArray(e)?n.array:null===e?n.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?n.promise:"undefined"!=typeof Map&&e instanceof Map?n.map:"undefined"!=typeof Set&&e instanceof Set?n.set:"undefined"!=typeof Date&&e instanceof Date?n.date:n.object;default:return n.unknown}},i=s.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class o extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof o))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,s.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}o.create=e=>new o(e);const d=(e,t)=>{let a;switch(e.code){case i.invalid_type:a=e.received===n.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case i.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,s.jsonStringifyReplacer)}`;break;case i.unrecognized_keys:a=`Unrecognized key(s) in object: ${s.joinValues(e.keys,", ")}`;break;case i.invalid_union:a="Invalid input";break;case i.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${s.joinValues(e.options)}`;break;case i.invalid_enum_value:a=`Invalid enum value. Expected ${s.joinValues(e.options)}, received '${e.received}'`;break;case i.invalid_arguments:a="Invalid function arguments";break;case i.invalid_return_type:a="Invalid function return type";break;case i.invalid_date:a="Invalid date";break;case i.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:s.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case i.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case i.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case i.custom:a="Invalid input";break;case i.invalid_intersection_types:a="Intersection results could not be merged";break;case i.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case i.not_finite:a="Number must be finite";break;default:a=t.defaultError,s.assertNever(e)}return{message:a}};let c=d;function u(e,t){const s=c,a=(e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,r=[...s,...n.path||[]],i={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:r,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===d?void 0:d].filter((e=>!!e))});e.common.issues.push(a)}class l{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const a of t){if("aborted"===a.status)return h;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return l.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status)return h;if("aborted"===n.status)return h;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!a.alwaysSet||(s[t.value]=n.value)}return{status:e.value,value:s}}}const h=Object.freeze({status:"aborted"}),p=e=>({status:"dirty",value:e}),m=e=>({status:"valid",value:e}),f=e=>"aborted"===e.status,_=e=>"dirty"===e.status,g=e=>"valid"===e.status,y=e=>"undefined"!=typeof Promise&&e instanceof Promise;var v;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(v||(v={}));class x{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const k=(e,t)=>{if(g(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new o(e.common.issues);return this._error=t,this._error}}};function w(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:a,description:n}=e;if(t&&(s||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{const{message:r}=e;return"invalid_enum_value"===t.code?{message:r??n.defaultError}:void 0===n.data?{message:r??a??n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:r??s??n.defaultError}},description:n}}class b{get description(){return this._def.description}_getType(e){return r(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new l,ctx:{common:e.parent.common,data:e.data,parsedType:r(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(y(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},a=this._parseSync({data:e,path:s.path,parent:s});return k(s,a)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return g(s)?{value:s.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((e=>g(e)?{value:e.value}:{issues:t.common.issues}))}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:r(e)},a=this._parse({data:e,path:s.path,parent:s}),n=await(y(a)?a:Promise.resolve(a));return k(s,n)}refine(e,t){const s=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const n=e(t),r=()=>a.addIssue({code:i.custom,...s(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then((e=>!!e||(r(),!1))):!!n||(r(),!1)}))}refinement(e,t){return this._refinement(((s,a)=>!!e(s)||(a.addIssue("function"==typeof t?t(s,a):t),!1)))}_refinement(e){return new we({schema:this,typeName:Ee.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return be.create(this,this._def)}nullable(){return Te.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ne.create(this)}promise(){return ke.create(this,this._def)}or(e){return oe.create([this,e],this._def)}and(e){return le.create(this,e,this._def)}transform(e){return new we({...w(this._def),schema:this,typeName:Ee.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Oe({...w(this._def),innerType:this,defaultValue:t,typeName:Ee.ZodDefault})}brand(){return new Ae({typeName:Ee.ZodBranded,type:this,...w(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Ce({...w(this._def),innerType:this,catchValue:t,typeName:Ee.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Ze.create(this,e)}readonly(){return Ie.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const T=/^c[^\s-]{8,}$/i,O=/^[0-9a-z]+$/,C=/^[0-9A-HJKMNP-TV-Z]{26}$/i,S=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,A=/^[a-z0-9_-]{21}$/i,Z=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,I=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,E=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let j;const R=/^(?:(?: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])$/,P=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,N=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,$=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,M=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,U=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,z="((\\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])))",L=new RegExp(`^${z}$`);function F(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function D(e){let t=`${z}T${F(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function V(e,t){if(!Z.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return"object"==typeof n&&null!==n&&((!("typ"in n)||"JWT"===n?.typ)&&(!!n.alg&&(!t||n.alg===t)))}catch{return!1}}function K(e,t){return!("v4"!==t&&t||!P.test(e))||!("v6"!==t&&t||!$.test(e))}class q extends b{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==n.string){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.string,received:t.parsedType}),h}const t=new l;let a;for(const n of this._def.checks)if("min"===n.kind)e.data.length<n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:i.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("max"===n.kind)e.data.length>n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:i.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if("length"===n.kind){const s=e.data.length>n.value,r=e.data.length<n.value;(s||r)&&(a=this._getOrReturnCtx(e,a),s?u(a,{code:i.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):r&&u(a,{code:i.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if("email"===n.kind)E.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"email",code:i.invalid_string,message:n.message}),t.dirty());else if("emoji"===n.kind)j||(j=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),j.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"emoji",code:i.invalid_string,message:n.message}),t.dirty());else if("uuid"===n.kind)S.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"uuid",code:i.invalid_string,message:n.message}),t.dirty());else if("nanoid"===n.kind)A.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"nanoid",code:i.invalid_string,message:n.message}),t.dirty());else if("cuid"===n.kind)T.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid",code:i.invalid_string,message:n.message}),t.dirty());else if("cuid2"===n.kind)O.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid2",code:i.invalid_string,message:n.message}),t.dirty());else if("ulid"===n.kind)C.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"ulid",code:i.invalid_string,message:n.message}),t.dirty());else if("url"===n.kind)try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),u(a,{validation:"url",code:i.invalid_string,message:n.message}),t.dirty()}else if("regex"===n.kind){n.regex.lastIndex=0;n.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"regex",code:i.invalid_string,message:n.message}),t.dirty())}else if("trim"===n.kind)e.data=e.data.trim();else if("includes"===n.kind)e.data.includes(n.value,n.position)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty());else if("toLowerCase"===n.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===n.kind)e.data=e.data.toUpperCase();else if("startsWith"===n.kind)e.data.startsWith(n.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty());else if("endsWith"===n.kind)e.data.endsWith(n.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty());else if("datetime"===n.kind){D(n).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:"datetime",message:n.message}),t.dirty())}else if("date"===n.kind){L.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:"date",message:n.message}),t.dirty())}else if("time"===n.kind){new RegExp(`^${F(n)}$`).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:i.invalid_string,validation:"time",message:n.message}),t.dirty())}else"duration"===n.kind?I.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"duration",code:i.invalid_string,message:n.message}),t.dirty()):"ip"===n.kind?(r=e.data,("v4"!==(o=n.version)&&o||!R.test(r))&&("v6"!==o&&o||!N.test(r))&&(a=this._getOrReturnCtx(e,a),u(a,{validation:"ip",code:i.invalid_string,message:n.message}),t.dirty())):"jwt"===n.kind?V(e.data,n.alg)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"jwt",code:i.invalid_string,message:n.message}),t.dirty()):"cidr"===n.kind?K(e.data,n.version)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cidr",code:i.invalid_string,message:n.message}),t.dirty()):"base64"===n.kind?M.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64",code:i.invalid_string,message:n.message}),t.dirty()):"base64url"===n.kind?U.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64url",code:i.invalid_string,message:n.message}),t.dirty()):s.assertNever(n);var r,o;return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:i.invalid_string,...v.errToObj(s)})}_addCheck(e){return new q({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...v.errToObj(e)})}url(e){return this._addCheck({kind:"url",...v.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...v.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...v.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...v.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...v.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...v.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...v.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...v.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...v.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...v.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...v.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...v.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...v.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...v.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...v.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...v.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...v.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...v.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...v.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...v.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...v.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...v.errToObj(t)})}nonempty(e){return this.min(1,v.errToObj(e))}trim(){return new q({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new q({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isCIDR(){return!!this._def.checks.find((e=>"cidr"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get isBase64url(){return!!this._def.checks.find((e=>"base64url"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function W(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}q.create=e=>new q({checks:[],typeName:Ee.ZodString,coerce:e?.coerce??!1,...w(e)});class H extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==n.number){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.number,received:t.parsedType}),h}let t;const a=new l;for(const n of this._def.checks)if("int"===n.kind)s.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),u(t,{code:i.invalid_type,expected:"integer",received:"float",message:n.message}),a.dirty());else if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),a.dirty())}else"multipleOf"===n.kind?0!==W(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),u(t,{code:i.not_finite,message:n.message}),a.dirty()):s.assertNever(n);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,s,a){return new H({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:v.toString(a)}]})}_addCheck(e){return new H({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:v.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:v.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:v.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:v.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&s.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}H.create=e=>new H({checks:[],typeName:Ee.ZodNumber,coerce:e?.coerce||!1,...w(e)});class B extends b{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==n.bigint)return this._getInvalidInput(e);let t;const a=new l;for(const n of this._def.checks)if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),a.dirty())}else"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),u(t,{code:i.not_multiple_of,multipleOf:n.value,message:n.message}),a.dirty()):s.assertNever(n);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.bigint,received:t.parsedType}),h}gte(e,t){return this.setLimit("min",e,!0,v.toString(t))}gt(e,t){return this.setLimit("min",e,!1,v.toString(t))}lte(e,t){return this.setLimit("max",e,!0,v.toString(t))}lt(e,t){return this.setLimit("max",e,!1,v.toString(t))}setLimit(e,t,s,a){return new B({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:v.toString(a)}]})}_addCheck(e){return new B({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:v.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:v.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:v.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:v.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:v.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}B.create=e=>new B({checks:[],typeName:Ee.ZodBigInt,coerce:e?.coerce??!1,...w(e)});class J extends b{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==n.boolean){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.boolean,received:t.parsedType}),h}return m(e.data)}}J.create=e=>new J({typeName:Ee.ZodBoolean,coerce:e?.coerce||!1,...w(e)});class G extends b{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==n.date){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.date,received:t.parsedType}),h}if(Number.isNaN(e.data.getTime())){return u(this._getOrReturnCtx(e),{code:i.invalid_date}),h}const t=new l;let a;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:i.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:i.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):s.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new G({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:v.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:v.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}G.create=e=>new G({checks:[],coerce:e?.coerce||!1,typeName:Ee.ZodDate,...w(e)});class Y extends b{_parse(e){if(this._getType(e)!==n.symbol){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.symbol,received:t.parsedType}),h}return m(e.data)}}Y.create=e=>new Y({typeName:Ee.ZodSymbol,...w(e)});class X extends b{_parse(e){if(this._getType(e)!==n.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.undefined,received:t.parsedType}),h}return m(e.data)}}X.create=e=>new X({typeName:Ee.ZodUndefined,...w(e)});class Q extends b{_parse(e){if(this._getType(e)!==n.null){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.null,received:t.parsedType}),h}return m(e.data)}}Q.create=e=>new Q({typeName:Ee.ZodNull,...w(e)});class ee extends b{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}}ee.create=e=>new ee({typeName:Ee.ZodAny,...w(e)});class te extends b{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}}te.create=e=>new te({typeName:Ee.ZodUnknown,...w(e)});class se extends b{_parse(e){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.never,received:t.parsedType}),h}}se.create=e=>new se({typeName:Ee.ZodNever,...w(e)});class ae extends b{_parse(e){if(this._getType(e)!==n.undefined){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.void,received:t.parsedType}),h}return m(e.data)}}ae.create=e=>new ae({typeName:Ee.ZodVoid,...w(e)});class ne extends b{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==n.array)return u(t,{code:i.invalid_type,expected:n.array,received:t.parsedType}),h;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(u(t,{code:e?i.too_big:i.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(u(t,{code:i.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(u(t,{code:i.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map(((e,s)=>a.type._parseAsync(new x(t,e,t.path,s))))).then((e=>l.mergeArray(s,e)));const r=[...t.data].map(((e,s)=>a.type._parseSync(new x(t,e,t.path,s))));return l.mergeArray(s,r)}get element(){return this._def.type}min(e,t){return new ne({...this._def,minLength:{value:e,message:v.toString(t)}})}max(e,t){return new ne({...this._def,maxLength:{value:e,message:v.toString(t)}})}length(e,t){return new ne({...this._def,exactLength:{value:e,message:v.toString(t)}})}nonempty(e){return this.min(1,e)}}function re(e){if(e instanceof ie){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=be.create(re(a))}return new ie({...e._def,shape:()=>t})}return e instanceof ne?new ne({...e._def,type:re(e.element)}):e instanceof be?be.create(re(e.unwrap())):e instanceof Te?Te.create(re(e.unwrap())):e instanceof he?he.create(e.items.map((e=>re(e)))):e}ne.create=(e,t)=>new ne({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ee.ZodArray,...w(t)});class ie extends b{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=s.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==n.object){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),h}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:r}=this._getCached(),o=[];if(!(this._def.catchall instanceof se&&"strip"===this._def.unknownKeys))for(const e in s.data)r.includes(e)||o.push(e);const d=[];for(const e of r){const t=a[e],n=s.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new x(s,n,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof se){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of o)d.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)o.length>0&&(u(s,{code:i.unrecognized_keys,keys:o}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of o){const a=s.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new x(s,a,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of d){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>l.mergeObjectSync(t,e))):l.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return v.errToObj,new ie({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{const a=this._def.errorMap?.(t,s).message??s.defaultError;return"unrecognized_keys"===t.code?{message:v.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new ie({...this._def,unknownKeys:"strip"})}passthrough(){return new ie({...this._def,unknownKeys:"passthrough"})}extend(e){return new ie({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ie({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ee.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ie({...this._def,catchall:e})}pick(e){const t={};for(const a of s.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new ie({...this._def,shape:()=>t})}omit(e){const t={};for(const a of s.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new ie({...this._def,shape:()=>t})}deepPartial(){return re(this)}partial(e){const t={};for(const a of s.objectKeys(this.shape)){const s=this.shape[a];e&&!e[a]?t[a]=s:t[a]=s.optional()}return new ie({...this._def,shape:()=>t})}required(e){const t={};for(const a of s.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let e=this.shape[a];for(;e instanceof be;)e=e._def.innerType;t[a]=e}return new ie({...this._def,shape:()=>t})}keyof(){return ye(s.objectKeys(this.shape))}}ie.create=(e,t)=>new ie({shape:()=>e,unknownKeys:"strip",catchall:se.create(),typeName:Ee.ZodObject,...w(t)}),ie.strictCreate=(e,t)=>new ie({shape:()=>e,unknownKeys:"strict",catchall:se.create(),typeName:Ee.ZodObject,...w(t)}),ie.lazycreate=(e,t)=>new ie({shape:e,unknownKeys:"strip",catchall:se.create(),typeName:Ee.ZodObject,...w(t)});class oe extends b{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map((e=>new o(e.ctx.common.issues)));return u(t,{code:i.invalid_union,unionErrors:s}),h}));{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},r=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=a.map((e=>new o(e)));return u(t,{code:i.invalid_union,unionErrors:n}),h}}get options(){return this._def.options}}oe.create=(e,t)=>new oe({options:e,typeName:Ee.ZodUnion,...w(t)});const de=e=>e instanceof _e?de(e.schema):e instanceof we?de(e.innerType()):e instanceof ge?[e.value]:e instanceof ve?e.options:e instanceof xe?s.objectValues(e.enum):e instanceof Oe?de(e._def.innerType):e instanceof X?[void 0]:e instanceof Q?[null]:e instanceof be?[void 0,...de(e.unwrap())]:e instanceof Te?[null,...de(e.unwrap())]:e instanceof Ae||e instanceof Ie?de(e.unwrap()):e instanceof Ce?de(e._def.innerType):[];class ce extends b{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.object)return u(t,{code:i.invalid_type,expected:n.object,received:t.parsedType}),h;const s=this.discriminator,a=t.data[s],r=this.optionsMap.get(a);return r?t.common.async?r._parseAsync({data:t.data,path:t.path,parent:t}):r._parseSync({data:t.data,path:t.path,parent:t}):(u(t,{code:i.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),h)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=de(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,s)}}return new ce({typeName:Ee.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...w(s)})}}function ue(e,t){const a=r(e),i=r(t);if(e===t)return{valid:!0,data:e};if(a===n.object&&i===n.object){const a=s.objectKeys(t),n=s.objectKeys(e).filter((e=>-1!==a.indexOf(e))),r={...e,...t};for(const s of n){const a=ue(e[s],t[s]);if(!a.valid)return{valid:!1};r[s]=a.data}return{valid:!0,data:r}}if(a===n.array&&i===n.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const n=ue(e[a],t[a]);if(!n.valid)return{valid:!1};s.push(n.data)}return{valid:!0,data:s}}return a===n.date&&i===n.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}class le extends b{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(f(e)||f(a))return h;const n=ue(e.value,a.value);return n.valid?((_(e)||_(a))&&t.dirty(),{status:t.value,value:n.data}):(u(s,{code:i.invalid_intersection_types}),h)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then((([e,t])=>a(e,t))):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}le.create=(e,t,s)=>new le({left:e,right:t,typeName:Ee.ZodIntersection,...w(s)});class he extends b{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==n.array)return u(s,{code:i.invalid_type,expected:n.array,received:s.parsedType}),h;if(s.data.length<this._def.items.length)return u(s,{code:i.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&s.data.length>this._def.items.length&&(u(s,{code:i.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new x(s,e,s.path,t)):null})).filter((e=>!!e));return s.common.async?Promise.all(a).then((e=>l.mergeArray(t,e))):l.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new he({...this._def,rest:e})}}he.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new he({items:e,typeName:Ee.ZodTuple,rest:null,...w(t)})};class pe extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==n.object)return u(s,{code:i.invalid_type,expected:n.object,received:s.parsedType}),h;const a=[],r=this._def.keyType,o=this._def.valueType;for(const e in s.data)a.push({key:r._parse(new x(s,e,s.path,e)),value:o._parse(new x(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?l.mergeObjectAsync(t,a):l.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return new pe(t instanceof b?{keyType:e,valueType:t,typeName:Ee.ZodRecord,...w(s)}:{keyType:q.create(),valueType:e,typeName:Ee.ZodRecord,...w(t)})}}class me extends b{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==n.map)return u(s,{code:i.invalid_type,expected:n.map,received:s.parsedType}),h;const a=this._def.keyType,r=this._def.valueType,o=[...s.data.entries()].map((([e,t],n)=>({key:a._parse(new x(s,e,s.path,[n,"key"])),value:r._parse(new x(s,t,s.path,[n,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of o){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return h;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const s of o){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return h;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}me.create=(e,t,s)=>new me({valueType:t,keyType:e,typeName:Ee.ZodMap,...w(s)});class fe extends b{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==n.set)return u(s,{code:i.invalid_type,expected:n.set,received:s.parsedType}),h;const a=this._def;null!==a.minSize&&s.data.size<a.minSize.value&&(u(s,{code:i.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&s.data.size>a.maxSize.value&&(u(s,{code:i.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const r=this._def.valueType;function o(e){const s=new Set;for(const a of e){if("aborted"===a.status)return h;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const d=[...s.data.values()].map(((e,t)=>r._parse(new x(s,e,s.path,t))));return s.common.async?Promise.all(d).then((e=>o(e))):o(d)}min(e,t){return new fe({...this._def,minSize:{value:e,message:v.toString(t)}})}max(e,t){return new fe({...this._def,maxSize:{value:e,message:v.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}fe.create=(e,t)=>new fe({valueType:e,minSize:null,maxSize:null,typeName:Ee.ZodSet,...w(t)});class _e extends b{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}_e.create=(e,t)=>new _e({getter:e,typeName:Ee.ZodLazy,...w(t)});class ge extends b{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return u(t,{received:t.data,code:i.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ye(e,t){return new ve({values:e,typeName:Ee.ZodEnum,...w(t)})}ge.create=(e,t)=>new ge({value:e,typeName:Ee.ZodLiteral,...w(t)});class ve extends b{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),a=this._def.values;return u(t,{expected:s.joinValues(a),received:t.parsedType,code:i.invalid_type}),h}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return u(t,{received:t.data,code:i.invalid_enum_value,options:s}),h}return m(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return ve.create(e,{...this._def,...t})}exclude(e,t=this._def){return ve.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}ve.create=ye;class xe extends b{_parse(e){const t=s.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==n.string&&a.parsedType!==n.number){const e=s.objectValues(t);return u(a,{expected:s.joinValues(e),received:a.parsedType,code:i.invalid_type}),h}if(this._cache||(this._cache=new Set(s.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=s.objectValues(t);return u(a,{received:a.data,code:i.invalid_enum_value,options:e}),h}return m(e.data)}get enum(){return this._def.values}}xe.create=(e,t)=>new xe({values:e,typeName:Ee.ZodNativeEnum,...w(t)});class ke extends b{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==n.promise&&!1===t.common.async)return u(t,{code:i.invalid_type,expected:n.promise,received:t.parsedType}),h;const s=t.parsedType===n.promise?t.data:Promise.resolve(t.data);return m(s.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}ke.create=(e,t)=>new ke({type:e,typeName:Ee.ZodPromise,...w(t)});class we extends b{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ee.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),n=this._def.effect||null,r={addIssue:e=>{u(a,e),e.fatal?t.abort():t.dirty()},get path(){return a.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===n.type){const e=n.transform(a.data,r);if(a.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return h;const s=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===s.status?h:"dirty"===s.status||"dirty"===t.value?p(s.value):s}));{if("aborted"===t.value)return h;const s=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===s.status?h:"dirty"===s.status||"dirty"===t.value?p(s.value):s}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,r);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){const s=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===s.status?h:("dirty"===s.status&&t.dirty(),e(s.value),{status:t.value,value:s.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((s=>"aborted"===s.status?h:("dirty"===s.status&&t.dirty(),e(s.value).then((()=>({status:t.value,value:s.value}))))))}if("transform"===n.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!g(e))return h;const s=n.transform(e.value,r);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:s}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((e=>g(e)?Promise.resolve(n.transform(e.value,r)).then((e=>({status:t.value,value:e}))):h))}s.assertNever(n)}}we.create=(e,t,s)=>new we({schema:e,typeName:Ee.ZodEffects,effect:t,...w(s)}),we.createWithPreprocess=(e,t,s)=>new we({schema:t,effect:{type:"preprocess",transform:e},typeName:Ee.ZodEffects,...w(s)});class be extends b{_parse(e){return this._getType(e)===n.undefined?m(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}be.create=(e,t)=>new be({innerType:e,typeName:Ee.ZodOptional,...w(t)});class Te extends b{_parse(e){return this._getType(e)===n.null?m(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Te.create=(e,t)=>new Te({innerType:e,typeName:Ee.ZodNullable,...w(t)});class Oe extends b{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===n.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Oe.create=(e,t)=>new Oe({innerType:e,typeName:Ee.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...w(t)});class Ce extends b{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return y(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new o(s.common.issues)},input:s.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new o(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ce.create=(e,t)=>new Ce({innerType:e,typeName:Ee.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...w(t)});class Se extends b{_parse(e){if(this._getType(e)!==n.nan){const t=this._getOrReturnCtx(e);return u(t,{code:i.invalid_type,expected:n.nan,received:t.parsedType}),h}return{status:"valid",value:e.data}}}Se.create=e=>new Se({typeName:Ee.ZodNaN,...w(e)});class Ae extends b{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ze extends b{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?h:"dirty"===e.status?(t.dirty(),p(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})()}{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?h:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new Ze({in:e,out:t,typeName:Ee.ZodPipeline})}}class Ie extends b{_parse(e){const t=this._def.innerType._parse(e),s=e=>(g(e)&&(e.value=Object.freeze(e.value)),e);return y(t)?t.then((e=>s(e))):s(t)}unwrap(){return this._def.innerType}}var Ee;Ie.create=(e,t)=>new Ie({innerType:e,typeName:Ee.ZodReadonly,...w(t)}),function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Ee||(Ee={}));const je=q.create,Re=H.create,Pe=J.create,Ne=ee.create,$e=te.create;se.create;const Me=ne.create,Ue=ie.create,ze=oe.create,Le=ce.create;le.create,he.create;const Fe=pe.create,De=ge.create,Ve=ve.create;ke.create;const Ke=be.create;Te.create;const qe="2025-03-26",We="2.0",He=ze([je(),Re().int()]),Be=je(),Je=Ue({progressToken:Ke(He)}).passthrough(),Ge=Ue({_meta:Ke(Je)}).passthrough(),Ye=Ue({method:je(),params:Ke(Ge)}),Xe=Ue({_meta:Ke(Ue({}).passthrough())}).passthrough(),Qe=Ue({method:je(),params:Ke(Xe)}),et=Ue({_meta:Ke(Ue({}).passthrough())}).passthrough(),tt=ze([je(),Re().int()]),st=Ue({jsonrpc:De(We),id:tt}).merge(Ye).strict(),at=Ue({jsonrpc:De(We)}).merge(Qe).strict(),nt=Ue({jsonrpc:De(We),id:tt,result:et}).strict();var rt;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError"}(rt||(rt={}));const it=Ue({jsonrpc:De(We),id:tt,error:Ue({code:Re().int(),message:je(),data:Ke($e())})}).strict(),ot=ze([st,at,nt,it]),dt=et.strict(),ct=Qe.extend({method:De("notifications/cancelled"),params:Xe.extend({requestId:tt,reason:je().optional()})}),ut=Ue({name:je(),version:je()}).passthrough(),lt=Ue({experimental:Ke(Ue({}).passthrough()),sampling:Ke(Ue({}).passthrough()),roots:Ke(Ue({listChanged:Ke(Pe())}).passthrough())}).passthrough(),ht=Ye.extend({method:De("initialize"),params:Ge.extend({protocolVersion:je(),capabilities:lt,clientInfo:ut})}),pt=Ue({experimental:Ke(Ue({}).passthrough()),logging:Ke(Ue({}).passthrough()),completions:Ke(Ue({}).passthrough()),prompts:Ke(Ue({listChanged:Ke(Pe())}).passthrough()),resources:Ke(Ue({subscribe:Ke(Pe()),listChanged:Ke(Pe())}).passthrough()),tools:Ke(Ue({listChanged:Ke(Pe())}).passthrough())}).passthrough(),mt=et.extend({protocolVersion:je(),capabilities:pt,serverInfo:ut,instructions:Ke(je())}),ft=Qe.extend({method:De("notifications/initialized")}),_t=Ye.extend({method:De("ping")}),gt=Ue({progress:Re(),total:Ke(Re()),message:Ke(je())}).passthrough(),yt=Qe.extend({method:De("notifications/progress"),params:Xe.merge(gt).extend({progressToken:He})}),vt=Ye.extend({params:Ge.extend({cursor:Ke(Be)}).optional()}),xt=et.extend({nextCursor:Ke(Be)}),kt=Ue({uri:je(),mimeType:Ke(je())}).passthrough(),wt=kt.extend({text:je()}),bt=kt.extend({blob:je().base64()}),Tt=Ue({uri:je(),name:je(),description:Ke(je()),mimeType:Ke(je())}).passthrough(),Ot=Ue({uriTemplate:je(),name:je(),description:Ke(je()),mimeType:Ke(je())}).passthrough(),Ct=vt.extend({method:De("resources/list")}),St=xt.extend({resources:Me(Tt)}),At=vt.extend({method:De("resources/templates/list")}),Zt=xt.extend({resourceTemplates:Me(Ot)}),It=Ye.extend({method:De("resources/read"),params:Ge.extend({uri:je()})}),Et=et.extend({contents:Me(ze([wt,bt]))}),jt=Qe.extend({method:De("notifications/resources/list_changed")}),Rt=Ye.extend({method:De("resources/subscribe"),params:Ge.extend({uri:je()})}),Pt=Ye.extend({method:De("resources/unsubscribe"),params:Ge.extend({uri:je()})}),Nt=Qe.extend({method:De("notifications/resources/updated"),params:Xe.extend({uri:je()})}),$t=Ue({name:je(),description:Ke(je()),required:Ke(Pe())}).passthrough(),Mt=Ue({name:je(),description:Ke(je()),arguments:Ke(Me($t))}).passthrough(),Ut=vt.extend({method:De("prompts/list")}),zt=xt.extend({prompts:Me(Mt)}),Lt=Ye.extend({method:De("prompts/get"),params:Ge.extend({name:je(),arguments:Ke(Fe(je()))})}),Ft=Ue({type:De("text"),text:je()}).passthrough(),Dt=Ue({type:De("image"),data:je().base64(),mimeType:je()}).passthrough(),Vt=Ue({type:De("audio"),data:je().base64(),mimeType:je()}).passthrough(),Kt=Ue({type:De("resource"),resource:ze([wt,bt])}).passthrough(),qt=Ue({role:Ve(["user","assistant"]),content:ze([Ft,Dt,Vt,Kt])}).passthrough(),Wt=et.extend({description:Ke(je()),messages:Me(qt)}),Ht=Qe.extend({method:De("notifications/prompts/list_changed")}),Bt=Ue({title:Ke(je()),readOnlyHint:Ke(Pe()),destructiveHint:Ke(Pe()),idempotentHint:Ke(Pe()),openWorldHint:Ke(Pe())}).passthrough(),Jt=Ue({name:je(),description:Ke(je()),inputSchema:Ue({type:De("object"),properties:Ke(Ue({}).passthrough()),required:Ke(Me(je()))}).passthrough(),outputSchema:Ke(Ue({type:De("object"),properties:Ke(Ue({}).passthrough()),required:Ke(Me(je()))}).passthrough()),annotations:Ke(Bt)}).passthrough(),Gt=vt.extend({method:De("tools/list")}),Yt=xt.extend({tools:Me(Jt)}),Xt=et.extend({content:Me(ze([Ft,Dt,Vt,Kt])).default([]),structuredContent:Ue({}).passthrough().optional(),isError:Ke(Pe())});Xt.or(et.extend({toolResult:$e()}));const Qt=Ye.extend({method:De("tools/call"),params:Ge.extend({name:je(),arguments:Ke(Fe($e()))})}),es=Qe.extend({method:De("notifications/tools/list_changed")}),ts=Ve(["debug","info","notice","warning","error","critical","alert","emergency"]),ss=Ye.extend({method:De("logging/setLevel"),params:Ge.extend({level:ts})}),as=Qe.extend({method:De("notifications/message"),params:Xe.extend({level:ts,logger:Ke(je()),data:$e()})}),ns=Ue({name:je().optional()}).passthrough(),rs=Ue({hints:Ke(Me(ns)),costPriority:Ke(Re().min(0).max(1)),speedPriority:Ke(Re().min(0).max(1)),intelligencePriority:Ke(Re().min(0).max(1))}).passthrough(),is=Ue({role:Ve(["user","assistant"]),content:ze([Ft,Dt,Vt])}).passthrough(),os=Ye.extend({method:De("sampling/createMessage"),params:Ge.extend({messages:Me(is),systemPrompt:Ke(je()),includeContext:Ke(Ve(["none","thisServer","allServers"])),temperature:Ke(Re()),maxTokens:Re().int(),stopSequences:Ke(Me(je())),metadata:Ke(Ue({}).passthrough()),modelPreferences:Ke(rs)})}),ds=et.extend({model:je(),stopReason:Ke(Ve(["endTurn","stopSequence","maxTokens"]).or(je())),role:Ve(["user","assistant"]),content:Le("type",[Ft,Dt,Vt])}),cs=Ue({type:De("ref/resource"),uri:je()}).passthrough(),us=Ue({type:De("ref/prompt"),name:je()}).passthrough(),ls=Ye.extend({method:De("completion/complete"),params:Ge.extend({ref:ze([us,cs]),argument:Ue({name:je(),value:je()}).passthrough()})}),hs=et.extend({completion:Ue({values:Me(je()).max(100),total:Ke(Re().int()),hasMore:Ke(Pe())}).passthrough()}),ps=Ue({uri:je().startsWith("file://"),name:Ke(je())}).passthrough(),ms=Ye.extend({method:De("roots/list")}),fs=et.extend({roots:Me(ps)}),_s=Qe.extend({method:De("notifications/roots/list_changed")});ze([_t,ht,ls,ss,Lt,Ut,Ct,At,It,Rt,Pt,Qt,Gt]),ze([ct,yt,ft,_s]),ze([dt,ds,fs]),ze([_t,os,ms]),ze([ct,yt,as,Nt,jt,es,Ht]),ze([dt,mt,hs,Wt,zt,St,Zt,Et,Xt,Yt]);const gs=Ue({resource:je().url(),authorization_servers:Me(je().url()).optional(),jwks_uri:je().url().optional(),scopes_supported:Me(je()).optional(),bearer_methods_supported:Me(je()).optional(),resource_signing_alg_values_supported:Me(je()).optional(),resource_name:je().optional(),resource_documentation:je().optional(),resource_policy_uri:je().url().optional(),resource_tos_uri:je().url().optional(),tls_client_certificate_bound_access_tokens:Pe().optional(),authorization_details_types_supported:Me(je()).optional(),dpop_signing_alg_values_supported:Me(je()).optional(),dpop_bound_access_tokens_required:Pe().optional()}).passthrough(),ys=Ue({issuer:je(),authorization_endpoint:je(),token_endpoint:je(),registration_endpoint:je().optional(),scopes_supported:Me(je()).optional(),response_types_supported:Me(je()),response_modes_supported:Me(je()).optional(),grant_types_supported:Me(je()).optional(),token_endpoint_auth_methods_supported:Me(je()).optional(),token_endpoint_auth_signing_alg_values_supported:Me(je()).optional(),service_documentation:je().optional(),revocation_endpoint:je().optional(),revocation_endpoint_auth_methods_supported:Me(je()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Me(je()).optional(),introspection_endpoint:je().optional(),introspection_endpoint_auth_methods_supported:Me(je()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Me(je()).optional(),code_challenge_methods_supported:Me(je()).optional()}).passthrough(),vs=Ue({access_token:je(),token_type:je(),expires_in:Re().optional(),scope:je().optional(),refresh_token:je().optional()}).strip();Ue({error:je(),error_description:je().optional(),error_uri:je().optional()});const xs=Ue({redirect_uris:Me(je()).refine((e=>e.every((e=>URL.canParse(e)))),{message:"redirect_uris must contain valid URLs"}),token_endpoint_auth_method:je().optional(),grant_types:Me(je()).optional(),response_types:Me(je()).optional(),client_name:je().optional(),client_uri:je().optional(),logo_uri:je().optional(),scope:je().optional(),contacts:Me(je()).optional(),tos_uri:je().optional(),policy_uri:je().optional(),jwks_uri:je().optional(),jwks:Ne().optional(),software_id:je().optional(),software_version:je().optional()}).strip(),ks=Ue({client_id:je(),client_secret:je().optional(),client_id_issued_at:Re().optional(),client_secret_expires_at:Re().optional()}).strip(),ws=xs.merge(ks);Ue({error:je(),error_description:je().optional()}).strip(),Ue({token:je(),token_type_hint:je().optional()}).strip();class bs extends Error{constructor(e){super(null!=e?e:"Unauthorized")}}async function Ts(e,{serverUrl:s,authorizationCode:a,scope:n,resourceMetadataUrl:r}){let i=s;try{const e=await async function(e,t){var s;let a,n;a=new URL("/.well-known/oauth-protected-resource",e);try{n=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(s=null==t?void 0:t.protocolVersion)&&void 0!==s?s:qe}})}catch(e){if(!(e instanceof TypeError))throw e;n=await fetch(a)}if(404===n.status)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return gs.parse(await n.json())}(r||s);e.authorization_servers&&e.authorization_servers.length>0&&(i=e.authorization_servers[0])}catch(e){console.warn("Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server",e)}const o=await async function(e,t){var s;const a=new URL("/.well-known/oauth-authorization-server",e);let n;try{n=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(s=null==t?void 0:t.protocolVersion)&&void 0!==s?s:qe}})}catch(e){if(!(e instanceof TypeError))throw e;n=await fetch(a)}if(404===n.status)return;if(!n.ok)throw new Error(`HTTP ${n.status} trying to load well-known OAuth metadata`);return ys.parse(await n.json())}(i);let d=await Promise.resolve(e.clientInformation());if(!d){if(void 0!==a)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const t=await async function(e,{metadata:t,clientMetadata:s}){let a;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");a=new URL(t.registration_endpoint)}else a=new URL("/register",e);const n=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!n.ok)throw new Error(`Dynamic client registration failed: HTTP ${n.status}`);return ws.parse(await n.json())}(i,{metadata:o,clientMetadata:e.clientMetadata});await e.saveClientInformation(t),d=t}if(void 0!==a){const t=await e.codeVerifier(),s=await async function(e,{metadata:t,clientInformation:s,authorizationCode:a,codeVerifier:n,redirectUri:r}){const i="authorization_code";let o;if(t){if(o=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(i))throw new Error(`Incompatible auth server: does not support grant type ${i}`)}else o=new URL("/token",e);const d=new URLSearchParams({grant_type:i,client_id:s.client_id,code:a,code_verifier:n,redirect_uri:String(r)});s.client_secret&&d.set("client_secret",s.client_secret);const c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:d});if(!c.ok)throw new Error(`Token exchange failed: HTTP ${c.status}`);return vs.parse(await c.json())}(i,{metadata:o,clientInformation:d,authorizationCode:a,codeVerifier:t,redirectUri:e.redirectUrl});return await e.saveTokens(s),"AUTHORIZED"}const c=await e.tokens();if(null==c?void 0:c.refresh_token)try{const t=await async function(e,{metadata:t,clientInformation:s,refreshToken:a}){const n="refresh_token";let r;if(t){if(r=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(n))throw new Error(`Incompatible auth server: does not support grant type ${n}`)}else r=new URL("/token",e);const i=new URLSearchParams({grant_type:n,client_id:s.client_id,refresh_token:a});s.client_secret&&i.set("client_secret",s.client_secret);const o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i});if(!o.ok)throw new Error(`Token refresh failed: HTTP ${o.status}`);return vs.parse({refresh_token:a,...await o.json()})}(i,{metadata:o,clientInformation:d,refreshToken:c.refresh_token});return await e.saveTokens(t),"AUTHORIZED"}catch(e){console.error("Could not refresh OAuth tokens:",e)}const u=e.state?await e.state():void 0,{authorizationUrl:l,codeVerifier:h}=await async function(e,{metadata:s,clientInformation:a,redirectUrl:n,scope:r,state:i}){const o="code",d="S256";let c;if(s){if(c=new URL(s.authorization_endpoint),!s.response_types_supported.includes(o))throw new Error(`Incompatible auth server: does not support response type ${o}`);if(!s.code_challenge_methods_supported||!s.code_challenge_methods_supported.includes(d))throw new Error(`Incompatible auth server: does not support code challenge method ${d}`)}else c=new URL("/authorize",e);const u=await t(),l=u.code_verifier,h=u.code_challenge;c.searchParams.set("response_type",o),c.searchParams.set("client_id",a.client_id),c.searchParams.set("code_challenge",h),c.searchParams.set("code_challenge_method",d),c.searchParams.set("redirect_uri",String(n)),i&&c.searchParams.set("state",i);r&&c.searchParams.set("scope",r);return{authorizationUrl:c,codeVerifier:l}}(i,{metadata:o,clientInformation:d,state:u,redirectUrl:e.redirectUrl,scope:n||e.clientMetadata.scope});return await e.saveCodeVerifier(h),await e.redirectToAuthorization(l),"REDIRECT"}class Os extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function Cs(e){}function Ss(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Cs,onError:s=Cs,onRetry:a=Cs,onComment:n}=e;let r,i="",o=!0,d="",c="";function u(e){if(""===e)return d.length>0&&t({id:r,event:c||void 0,data:d.endsWith("\n")?d.slice(0,-1):d}),r=void 0,d="",void(c="");if(e.startsWith(":"))return void(n&&n(e.slice(e.startsWith(": ")?2:1)));const s=e.indexOf(":");if(-1===s)l(e,"",e);else{const t=e.slice(0,s),a=" "===e[s+1]?2:1;l(t,e.slice(s+a),e)}}function l(e,t,n){switch(e){case"event":c=t;break;case"data":d=`${d}${t}\n`;break;case"id":r=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?a(parseInt(t,10)):s(new Os(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:n}));break;default:s(new Os(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:"unknown-field",field:e,value:t,line:n}))}}return{feed:function(e){const t=o?e.replace(/^\xEF\xBB\xBF/,""):e,[s,a]=function(e){const t=[];let s="",a=0;for(;a<e.length;){const n=e.indexOf("\r",a),r=e.indexOf("\n",a);let i=-1;if(-1!==n&&-1!==r?i=Math.min(n,r):-1!==n?i=n:-1!==r&&(i=r),-1===i){s=e.slice(a);break}{const s=e.slice(a,i);t.push(s),a=i+1,"\r"===e[a-1]&&"\n"===e[a]&&a++}}return[t,s]}(`${i}${t}`);for(const e of s)u(e);i=a,o=!1},reset:function(e={}){i&&e.consume&&u(i),o=!0,r=void 0,d="",c="",i=""}}}class As extends TransformStream{constructor({onError:e,onRetry:t,onComment:s}={}){let a;super({start(n){a=Ss({onEvent:e=>{n.enqueue(e)},onError(t){"terminate"===e?n.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:s})},transform(e){a.feed(e)}})}}const Zs={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Is extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class Es{constructor(e,t){var s;this._url=e,this._resourceMetadataUrl=void 0,this._requestInit=null==t?void 0:t.requestInit,this._authProvider=null==t?void 0:t.authProvider,this._sessionId=null==t?void 0:t.sessionId,this._reconnectionOptions=null!==(s=null==t?void 0:t.reconnectionOptions)&&void 0!==s?s:Zs}async _authThenStart(){var e;if(!this._authProvider)throw new bs("No auth provider");let t;try{t=await Ts(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl})}catch(t){throw null===(e=this.onerror)||void 0===e||e.call(this,t),t}if("AUTHORIZED"!==t)throw new bs;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var e;const t={};if(this._authProvider){const e=await this._authProvider.tokens();e&&(t.Authorization=`Bearer ${e.access_token}`)}return this._sessionId&&(t["mcp-session-id"]=this._sessionId),new Headers({...t,...null===(e=this._requestInit)||void 0===e?void 0:e.headers})}async _startOrAuthSse(e){var t,s;const{resumptionToken:a}=e;try{const s=await this._commonHeaders();s.set("Accept","text/event-stream"),a&&s.set("last-event-id",a);const n=await fetch(this._url,{method:"GET",headers:s,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal});if(!n.ok){if(401===n.status&&this._authProvider)return await this._authThenStart();if(405===n.status)return;throw new Is(n.status,`Failed to open SSE stream: ${n.statusText}`)}this._handleSseStream(n.body,e)}catch(e){throw null===(s=this.onerror)||void 0===s||s.call(this,e),e}}_getNextReconnectionDelay(e){const t=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(s,e),a)}_scheduleReconnection(e,t=0){var s;const a=this._reconnectionOptions.maxRetries;if(a>0&&t>=a)return void(null===(s=this.onerror)||void 0===s||s.call(this,new Error(`Maximum reconnection attempts (${a}) exceeded.`)));const n=this._getNextReconnectionDelay(t);setTimeout((()=>{this._startOrAuthSse(e).catch((s=>{var a;null===(a=this.onerror)||void 0===a||a.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(e,t+1)}))}),n)}_handleSseStream(e,t){if(!e)return;const{onresumptiontoken:s,replayMessageId:a}=t;let n;(async()=>{var t,r,i,o,d;try{const i=e.pipeThrough(new TextDecoderStream).pipeThrough(new As).getReader();for(;;){const{value:e,done:o}=await i.read();if(o)break;if(e.id&&(n=e.id,null==s||s(e.id)),!e.event||"message"===e.event)try{const s=ot.parse(JSON.parse(e.data));void 0!==a&&(d=s,nt.safeParse(d).success)&&(s.id=a),null===(t=this.onmessage)||void 0===t||t.call(this,s)}catch(e){null===(r=this.onerror)||void 0===r||r.call(this,e)}}}catch(e){if(null===(i=this.onerror)||void 0===i||i.call(this,new Error(`SSE stream disconnected: ${e}`)),this._abortController&&!this._abortController.signal.aborted&&void 0!==n)try{this._scheduleReconnection({resumptionToken:n,onresumptiontoken:s,replayMessageId:a},0)}catch(e){null===(o=this.onerror)||void 0===o||o.call(this,new Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new bs("No auth provider");if("AUTHORIZED"!==await Ts(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl}))throw new bs("Failed to authorize")}async close(){var e,t;null===(e=this._abortController)||void 0===e||e.abort(),null===(t=this.onclose)||void 0===t||t.call(this)}async send(e,t){var s,a,n,r;try{const{resumptionToken:n,onresumptiontoken:i}=t||{};if(n)return void this._startOrAuthSse({resumptionToken:n,replayMessageId:(r=e,st.safeParse(r).success?e.id:void 0)}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)}));const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const d={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(e),signal:null===(s=this._abortController)||void 0===s?void 0:s.signal},c=await fetch(this._url,d),u=c.headers.get("mcp-session-id");if(u&&(this._sessionId=u),!c.ok){if(401===c.status&&this._authProvider){this._resourceMetadataUrl=function(e){const t=e.headers.get("WWW-Authenticate");if(!t)return;const[s,a]=t.split(" ");if("bearer"!==s.toLowerCase()||!a)return void console.log("Invalid WWW-Authenticate header format, expected 'Bearer'");const n=/resource_metadata="([^"]*)"/.exec(t);if(n)try{return new URL(n[1])}catch(e){return void console.log("Invalid resource metadata url: ",n[1])}}(c);if("AUTHORIZED"!==await Ts(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl}))throw new bs;return this.send(e)}const t=await c.text().catch((()=>null));throw new Error(`Error POSTing to endpoint (HTTP ${c.status}): ${t}`)}if(202===c.status)return void((e=>ft.safeParse(e).success)(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)})));const l=(Array.isArray(e)?e:[e]).filter((e=>"method"in e&&"id"in e&&void 0!==e.id)).length>0,h=c.headers.get("content-type");if(l)if(null==h?void 0:h.includes("text/event-stream"))this._handleSseStream(c.body,{onresumptiontoken:i});else{if(!(null==h?void 0:h.includes("application/json")))throw new Is(-1,`Unexpected content type: ${h}`);{const e=await c.json(),t=Array.isArray(e)?e.map((e=>ot.parse(e))):[ot.parse(e)];for(const e of t)null===(a=this.onmessage)||void 0===a||a.call(this,e)}}}catch(e){throw null===(n=this.onerror)||void 0===n||n.call(this,e),e}}get sessionId(){return this._sessionId}async terminateSession(){var e,t;if(this._sessionId)try{const t=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:t,signal:null===(e=this._abortController)||void 0===e?void 0:e.signal},a=await fetch(this._url,s);if(!a.ok&&405!==a.status)throw new Is(a.status,`Failed to terminate session: ${a.statusText}`);this._sessionId=void 0}catch(e){throw null===(t=this.onerror)||void 0===t||t.call(this,e),e}}}class js{static async init(t){if(!(null==t?void 0:t.apiKey))throw new Error("MboaAI-SDK: apiKey is required");if(js.ready)return;const{apiKey:s,mcpUrl:a="https://api.filparty.com:8001/mcp",name:n="MboaAI-SDK",version:r="1.0.0",defaultType:i="standard"}=t;js.client=new e({name:n,version:r}),await js.client.connect(new Es(new URL(a),{requestInit:{headers:{"x-api-key":s}}})),js.apiKey=s,js.defaultType=i,js.ready=!0}static async translate(e,t,s){var a,n,r;if(!js.ready)throw new Error("MboaAI-SDK: call init() first");const i=`Translate "${e}" into ${t} for ${null!=s?s:js.defaultType}`;try{const t=await js.client.callTool({name:"run_translate",arguments:{message:i,api_key:js.apiKey}}),s=String(null!==(r=null===(n=null===(a=null==t?void 0:t.content)||void 0===a?void 0:a[0])||void 0===n?void 0:n.text)&&void 0!==r?r:"");if((e=>{const t=e.trim().charAt(0);return"{"===t||"["===t})(s))try{const t=JSON.parse(s);return t.reply||t.text||e}catch(e){}return s||e}catch(t){return console.error("[MboaAI-SDK] translate error → returning source",t),e}}}js.ready=!1,js.defaultType="standard",js.apiKey="","undefined"!=typeof window&&(window.MboaAI=window.MboaAI||{},window.MboaAI.T=js);export{js as T,js as default};
|
package/dist/mboaai-sdk.umd.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("mcp-client")):"function"==typeof define&&define.amd?define(["exports","mcp-client"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MboaAI={},e.MCPClient)}(this,(function(e,t){"use strict";class n{static async init(e){if(!(null==e?void 0:e.apiKey))throw new Error("MboaAI-SDK: apiKey is required");if(n.ready)return;const{apiKey:a,mcpUrl:i="https://api.filparty.com:8001/mcp",name:r="MboaAI-SDK",version:o="1.0.0",defaultType:l="standard"}=e;n.client=new t.MCPClient({name:r,version:o}),await n.client.connect({type:"stdio",url:i,headers:{"x-api-key":a}}),n.apiKey=a,n.defaultType=l,n.ready=!0}static async translate(e,t,a){var i,r,o;if(!n.ready)throw new Error("MboaAI-SDK: call init() first");const l=`Translate "${e}" into ${t} for ${null!=a?a:n.defaultType}`;try{const t=await n.client.callTool({name:"run_translate",arguments:{message:l,api_key:n.apiKey}}),a=String(null!==(o=null===(r=null===(i=null==t?void 0:t.content)||void 0===i?void 0:i[0])||void 0===r?void 0:r.text)&&void 0!==o?o:"");if((e=>{const t=e.trim().charAt(0);return"{"===t||"["===t})(a))try{const t=JSON.parse(a);return t.reply||t.text||e}catch(e){}return a||e}catch(t){return console.error("[MboaAI-SDK] translate error → returning source",t),e}}}n.ready=!1,n.defaultType="standard",n.apiKey="","undefined"!=typeof window&&(window.MboaAI=window.MboaAI||{},window.MboaAI.T=n),e.T=n,e.default=n,Object.defineProperty(e,"__esModule",{value:!0})}));
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("mcp-client"),require("pkce-challenge")):"function"==typeof define&&define.amd?define(["exports","mcp-client","pkce-challenge"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MboaAI={},e.MCPClient,e.pkceChallenge)}(this,(function(e,t,s){"use strict";var a,n;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},e.getValidEnumValues=t=>{const s=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),a={};for(const e of s)a[e]=t[e];return e.objectValues(a)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},e.find=(e,t)=>{for(const s of e)if(t(s))return s},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(a||(a={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(n||(n={}));const r=a.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),i=e=>{switch(typeof e){case"undefined":return r.undefined;case"string":return r.string;case"number":return Number.isNaN(e)?r.nan:r.number;case"boolean":return r.boolean;case"function":return r.function;case"bigint":return r.bigint;case"symbol":return r.symbol;case"object":return Array.isArray(e)?r.array:null===e?r.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?r.promise:"undefined"!=typeof Map&&e instanceof Map?r.map:"undefined"!=typeof Set&&e instanceof Set?r.set:"undefined"!=typeof Date&&e instanceof Date?r.date:r.object;default:return r.unknown}},o=a.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class d extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof d))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,a.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}d.create=e=>new d(e);const c=(e,t)=>{let s;switch(e.code){case o.invalid_type:s=e.received===r.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case o.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,a.jsonStringifyReplacer)}`;break;case o.unrecognized_keys:s=`Unrecognized key(s) in object: ${a.joinValues(e.keys,", ")}`;break;case o.invalid_union:s="Invalid input";break;case o.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${a.joinValues(e.options)}`;break;case o.invalid_enum_value:s=`Invalid enum value. Expected ${a.joinValues(e.options)}, received '${e.received}'`;break;case o.invalid_arguments:s="Invalid function arguments";break;case o.invalid_return_type:s="Invalid function return type";break;case o.invalid_date:s="Invalid date";break;case o.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(s=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(s=`${s} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?s=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?s=`Invalid input: must end with "${e.validation.endsWith}"`:a.assertNever(e.validation):s="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case o.too_small:s="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case o.too_big:s="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case o.custom:s="Invalid input";break;case o.invalid_intersection_types:s="Intersection results could not be merged";break;case o.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case o.not_finite:s="Number must be finite";break;default:s=t.defaultError,a.assertNever(e)}return{message:s}};let u=c;function l(e,t){const s=u,a=(e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,r=[...s,...n.path||[]],i={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:r,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===c?void 0:c].filter((e=>!!e))});e.common.issues.push(a)}class h{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const a of t){if("aborted"===a.status)return p;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return h.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status)return p;if("aborted"===n.status)return p;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!a.alwaysSet||(s[t.value]=n.value)}return{status:e.value,value:s}}}const p=Object.freeze({status:"aborted"}),m=e=>({status:"dirty",value:e}),f=e=>({status:"valid",value:e}),_=e=>"aborted"===e.status,g=e=>"dirty"===e.status,y=e=>"valid"===e.status,v=e=>"undefined"!=typeof Promise&&e instanceof Promise;var x;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(x||(x={}));class k{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const w=(e,t)=>{if(y(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new d(e.common.issues);return this._error=t,this._error}}};function b(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:a,description:n}=e;if(t&&(s||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{const{message:r}=e;return"invalid_enum_value"===t.code?{message:r??n.defaultError}:void 0===n.data?{message:r??a??n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:r??s??n.defaultError}},description:n}}class T{get description(){return this._def.description}_getType(e){return i(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new h,ctx:{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(v(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)},a=this._parseSync({data:e,path:s.path,parent:s});return w(s,a)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return y(s)?{value:s.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((e=>y(e)?{value:e.value}:{issues:t.common.issues}))}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)},a=this._parse({data:e,path:s.path,parent:s}),n=await(v(a)?a:Promise.resolve(a));return w(s,n)}refine(e,t){const s=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const n=e(t),r=()=>a.addIssue({code:o.custom,...s(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then((e=>!!e||(r(),!1))):!!n||(r(),!1)}))}refinement(e,t){return this._refinement(((s,a)=>!!e(s)||(a.addIssue("function"==typeof t?t(s,a):t),!1)))}_refinement(e){return new be({schema:this,typeName:je.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Te.create(this,this._def)}nullable(){return Ce.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return re.create(this)}promise(){return we.create(this,this._def)}or(e){return de.create([this,e],this._def)}and(e){return he.create(this,e,this._def)}transform(e){return new be({...b(this._def),schema:this,typeName:je.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Oe({...b(this._def),innerType:this,defaultValue:t,typeName:je.ZodDefault})}brand(){return new Ze({typeName:je.ZodBranded,type:this,...b(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Se({...b(this._def),innerType:this,catchValue:t,typeName:je.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Ie.create(this,e)}readonly(){return Ee.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C=/^c[^\s-]{8,}$/i,O=/^[0-9a-z]+$/,S=/^[0-9A-HJKMNP-TV-Z]{26}$/i,A=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Z=/^[a-z0-9_-]{21}$/i,I=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,E=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,j=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let P;const R=/^(?:(?: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])$/,N=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,$=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,M=/^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,U=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,z=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,L="((\\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])))",F=new RegExp(`^${L}$`);function D(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function V(e){let t=`${L}T${D(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function q(e,t){if(!I.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return"object"==typeof n&&null!==n&&((!("typ"in n)||"JWT"===n?.typ)&&(!!n.alg&&(!t||n.alg===t)))}catch{return!1}}function K(e,t){return!("v4"!==t&&t||!N.test(e))||!("v6"!==t&&t||!M.test(e))}class W extends T{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==r.string){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.string,received:t.parsedType}),p}const t=new h;let s;for(const r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:o.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("max"===r.kind)e.data.length>r.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:o.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("length"===r.kind){const a=e.data.length>r.value,n=e.data.length<r.value;(a||n)&&(s=this._getOrReturnCtx(e,s),a?l(s,{code:o.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):n&&l(s,{code:o.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if("email"===r.kind)j.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"email",code:o.invalid_string,message:r.message}),t.dirty());else if("emoji"===r.kind)P||(P=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),P.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"emoji",code:o.invalid_string,message:r.message}),t.dirty());else if("uuid"===r.kind)A.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"uuid",code:o.invalid_string,message:r.message}),t.dirty());else if("nanoid"===r.kind)Z.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"nanoid",code:o.invalid_string,message:r.message}),t.dirty());else if("cuid"===r.kind)C.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid",code:o.invalid_string,message:r.message}),t.dirty());else if("cuid2"===r.kind)O.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid2",code:o.invalid_string,message:r.message}),t.dirty());else if("ulid"===r.kind)S.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ulid",code:o.invalid_string,message:r.message}),t.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),l(s,{validation:"url",code:o.invalid_string,message:r.message}),t.dirty()}else if("regex"===r.kind){r.regex.lastIndex=0;r.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"regex",code:o.invalid_string,message:r.message}),t.dirty())}else if("trim"===r.kind)e.data=e.data.trim();else if("includes"===r.kind)e.data.includes(r.value,r.position)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty());else if("toLowerCase"===r.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===r.kind)e.data=e.data.toUpperCase();else if("startsWith"===r.kind)e.data.startsWith(r.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty());else if("endsWith"===r.kind)e.data.endsWith(r.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty());else if("datetime"===r.kind){V(r).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:"datetime",message:r.message}),t.dirty())}else if("date"===r.kind){F.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:"date",message:r.message}),t.dirty())}else if("time"===r.kind){new RegExp(`^${D(r)}$`).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:"time",message:r.message}),t.dirty())}else"duration"===r.kind?E.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"duration",code:o.invalid_string,message:r.message}),t.dirty()):"ip"===r.kind?(n=e.data,("v4"!==(i=r.version)&&i||!R.test(n))&&("v6"!==i&&i||!$.test(n))&&(s=this._getOrReturnCtx(e,s),l(s,{validation:"ip",code:o.invalid_string,message:r.message}),t.dirty())):"jwt"===r.kind?q(e.data,r.alg)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"jwt",code:o.invalid_string,message:r.message}),t.dirty()):"cidr"===r.kind?K(e.data,r.version)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cidr",code:o.invalid_string,message:r.message}),t.dirty()):"base64"===r.kind?U.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64",code:o.invalid_string,message:r.message}),t.dirty()):"base64url"===r.kind?z.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64url",code:o.invalid_string,message:r.message}),t.dirty()):a.assertNever(r);var n,i;return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:o.invalid_string,...x.errToObj(s)})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...x.errToObj(e)})}url(e){return this._addCheck({kind:"url",...x.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...x.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...x.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...x.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...x.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...x.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...x.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...x.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...x.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...x.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...x.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...x.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...x.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...x.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...x.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...x.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...x.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...x.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...x.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...x.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...x.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...x.errToObj(t)})}nonempty(e){return this.min(1,x.errToObj(e))}trim(){return new W({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isCIDR(){return!!this._def.checks.find((e=>"cidr"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get isBase64url(){return!!this._def.checks.find((e=>"base64url"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function H(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}W.create=e=>new W({checks:[],typeName:je.ZodString,coerce:e?.coerce??!1,...b(e)});class B extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==r.number){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.number,received:t.parsedType}),p}let t;const s=new h;for(const n of this._def.checks)if("int"===n.kind)a.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),l(t,{code:o.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty());else if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty())}else"multipleOf"===n.kind?0!==H(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),l(t,{code:o.not_finite,message:n.message}),s.dirty()):a.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,s,a){return new B({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:x.toString(a)}]})}_addCheck(e){return new B({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:x.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:x.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&a.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}B.create=e=>new B({checks:[],typeName:je.ZodNumber,coerce:e?.coerce||!1,...b(e)});class J extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==r.bigint)return this._getInvalidInput(e);let t;const s=new h;for(const n of this._def.checks)if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty())}else"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):a.assertNever(n);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.bigint,received:t.parsedType}),p}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,s,a){return new J({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:x.toString(a)}]})}_addCheck(e){return new J({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}J.create=e=>new J({checks:[],typeName:je.ZodBigInt,coerce:e?.coerce??!1,...b(e)});class G extends T{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==r.boolean){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.boolean,received:t.parsedType}),p}return f(e.data)}}G.create=e=>new G({typeName:je.ZodBoolean,coerce:e?.coerce||!1,...b(e)});class Y extends T{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==r.date){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.date,received:t.parsedType}),p}if(Number.isNaN(e.data.getTime())){return l(this._getOrReturnCtx(e),{code:o.invalid_date}),p}const t=new h;let s;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:o.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:o.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):a.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:x.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:x.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Y.create=e=>new Y({checks:[],coerce:e?.coerce||!1,typeName:je.ZodDate,...b(e)});class X extends T{_parse(e){if(this._getType(e)!==r.symbol){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.symbol,received:t.parsedType}),p}return f(e.data)}}X.create=e=>new X({typeName:je.ZodSymbol,...b(e)});class Q extends T{_parse(e){if(this._getType(e)!==r.undefined){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.undefined,received:t.parsedType}),p}return f(e.data)}}Q.create=e=>new Q({typeName:je.ZodUndefined,...b(e)});class ee extends T{_parse(e){if(this._getType(e)!==r.null){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.null,received:t.parsedType}),p}return f(e.data)}}ee.create=e=>new ee({typeName:je.ZodNull,...b(e)});class te extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return f(e.data)}}te.create=e=>new te({typeName:je.ZodAny,...b(e)});class se extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return f(e.data)}}se.create=e=>new se({typeName:je.ZodUnknown,...b(e)});class ae extends T{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.never,received:t.parsedType}),p}}ae.create=e=>new ae({typeName:je.ZodNever,...b(e)});class ne extends T{_parse(e){if(this._getType(e)!==r.undefined){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.void,received:t.parsedType}),p}return f(e.data)}}ne.create=e=>new ne({typeName:je.ZodVoid,...b(e)});class re extends T{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==r.array)return l(t,{code:o.invalid_type,expected:r.array,received:t.parsedType}),p;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(l(t,{code:e?o.too_big:o.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(l(t,{code:o.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(l(t,{code:o.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map(((e,s)=>a.type._parseAsync(new k(t,e,t.path,s))))).then((e=>h.mergeArray(s,e)));const n=[...t.data].map(((e,s)=>a.type._parseSync(new k(t,e,t.path,s))));return h.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new re({...this._def,minLength:{value:e,message:x.toString(t)}})}max(e,t){return new re({...this._def,maxLength:{value:e,message:x.toString(t)}})}length(e,t){return new re({...this._def,exactLength:{value:e,message:x.toString(t)}})}nonempty(e){return this.min(1,e)}}function ie(e){if(e instanceof oe){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=Te.create(ie(a))}return new oe({...e._def,shape:()=>t})}return e instanceof re?new re({...e._def,type:ie(e.element)}):e instanceof Te?Te.create(ie(e.unwrap())):e instanceof Ce?Ce.create(ie(e.unwrap())):e instanceof pe?pe.create(e.items.map((e=>ie(e)))):e}re.create=(e,t)=>new re({type:e,minLength:null,maxLength:null,exactLength:null,typeName:je.ZodArray,...b(t)});class oe extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=a.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==r.object){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.object,received:t.parsedType}),p}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:n}=this._getCached(),i=[];if(!(this._def.catchall instanceof ae&&"strip"===this._def.unknownKeys))for(const e in s.data)n.includes(e)||i.push(e);const d=[];for(const e of n){const t=a[e],n=s.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new k(s,n,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof ae){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)d.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)i.length>0&&(l(s,{code:o.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of i){const a=s.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new k(s,a,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of d){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>h.mergeObjectSync(t,e))):h.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return x.errToObj,new oe({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{const a=this._def.errorMap?.(t,s).message??s.defaultError;return"unrecognized_keys"===t.code?{message:x.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new oe({...this._def,unknownKeys:"strip"})}passthrough(){return new oe({...this._def,unknownKeys:"passthrough"})}extend(e){return new oe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new oe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:je.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new oe({...this._def,catchall:e})}pick(e){const t={};for(const s of a.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new oe({...this._def,shape:()=>t})}omit(e){const t={};for(const s of a.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new oe({...this._def,shape:()=>t})}deepPartial(){return ie(this)}partial(e){const t={};for(const s of a.objectKeys(this.shape)){const a=this.shape[s];e&&!e[s]?t[s]=a:t[s]=a.optional()}return new oe({...this._def,shape:()=>t})}required(e){const t={};for(const s of a.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let e=this.shape[s];for(;e instanceof Te;)e=e._def.innerType;t[s]=e}return new oe({...this._def,shape:()=>t})}keyof(){return ve(a.objectKeys(this.shape))}}oe.create=(e,t)=>new oe({shape:()=>e,unknownKeys:"strip",catchall:ae.create(),typeName:je.ZodObject,...b(t)}),oe.strictCreate=(e,t)=>new oe({shape:()=>e,unknownKeys:"strict",catchall:ae.create(),typeName:je.ZodObject,...b(t)}),oe.lazycreate=(e,t)=>new oe({shape:e,unknownKeys:"strip",catchall:ae.create(),typeName:je.ZodObject,...b(t)});class de extends T{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map((e=>new d(e.ctx.common.issues)));return l(t,{code:o.invalid_union,unionErrors:s}),p}));{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},r=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=a.map((e=>new d(e)));return l(t,{code:o.invalid_union,unionErrors:n}),p}}get options(){return this._def.options}}de.create=(e,t)=>new de({options:e,typeName:je.ZodUnion,...b(t)});const ce=e=>e instanceof ge?ce(e.schema):e instanceof be?ce(e.innerType()):e instanceof ye?[e.value]:e instanceof xe?e.options:e instanceof ke?a.objectValues(e.enum):e instanceof Oe?ce(e._def.innerType):e instanceof Q?[void 0]:e instanceof ee?[null]:e instanceof Te?[void 0,...ce(e.unwrap())]:e instanceof Ce?[null,...ce(e.unwrap())]:e instanceof Ze||e instanceof Ee?ce(e.unwrap()):e instanceof Se?ce(e._def.innerType):[];class ue extends T{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.object)return l(t,{code:o.invalid_type,expected:r.object,received:t.parsedType}),p;const s=this.discriminator,a=t.data[s],n=this.optionsMap.get(a);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:o.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),p)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=ce(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,s)}}return new ue({typeName:je.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...b(s)})}}function le(e,t){const s=i(e),n=i(t);if(e===t)return{valid:!0,data:e};if(s===r.object&&n===r.object){const s=a.objectKeys(t),n=a.objectKeys(e).filter((e=>-1!==s.indexOf(e))),r={...e,...t};for(const s of n){const a=le(e[s],t[s]);if(!a.valid)return{valid:!1};r[s]=a.data}return{valid:!0,data:r}}if(s===r.array&&n===r.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const n=le(e[a],t[a]);if(!n.valid)return{valid:!1};s.push(n.data)}return{valid:!0,data:s}}return s===r.date&&n===r.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}class he extends T{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(_(e)||_(a))return p;const n=le(e.value,a.value);return n.valid?((g(e)||g(a))&&t.dirty(),{status:t.value,value:n.data}):(l(s,{code:o.invalid_intersection_types}),p)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then((([e,t])=>a(e,t))):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}he.create=(e,t,s)=>new he({left:e,right:t,typeName:je.ZodIntersection,...b(s)});class pe extends T{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==r.array)return l(s,{code:o.invalid_type,expected:r.array,received:s.parsedType}),p;if(s.data.length<this._def.items.length)return l(s,{code:o.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),p;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:o.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new k(s,e,s.path,t)):null})).filter((e=>!!e));return s.common.async?Promise.all(a).then((e=>h.mergeArray(t,e))):h.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new pe({...this._def,rest:e})}}pe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pe({items:e,typeName:je.ZodTuple,rest:null,...b(t)})};class me extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==r.object)return l(s,{code:o.invalid_type,expected:r.object,received:s.parsedType}),p;const a=[],n=this._def.keyType,i=this._def.valueType;for(const e in s.data)a.push({key:n._parse(new k(s,e,s.path,e)),value:i._parse(new k(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?h.mergeObjectAsync(t,a):h.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return new me(t instanceof T?{keyType:e,valueType:t,typeName:je.ZodRecord,...b(s)}:{keyType:W.create(),valueType:e,typeName:je.ZodRecord,...b(t)})}}class fe extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==r.map)return l(s,{code:o.invalid_type,expected:r.map,received:s.parsedType}),p;const a=this._def.keyType,n=this._def.valueType,i=[...s.data.entries()].map((([e,t],r)=>({key:a._parse(new k(s,e,s.path,[r,"key"])),value:n._parse(new k(s,t,s.path,[r,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of i){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return p;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const s of i){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return p;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}fe.create=(e,t,s)=>new fe({valueType:t,keyType:e,typeName:je.ZodMap,...b(s)});class _e extends T{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==r.set)return l(s,{code:o.invalid_type,expected:r.set,received:s.parsedType}),p;const a=this._def;null!==a.minSize&&s.data.size<a.minSize.value&&(l(s,{code:o.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&s.data.size>a.maxSize.value&&(l(s,{code:o.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const n=this._def.valueType;function i(e){const s=new Set;for(const a of e){if("aborted"===a.status)return p;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const d=[...s.data.values()].map(((e,t)=>n._parse(new k(s,e,s.path,t))));return s.common.async?Promise.all(d).then((e=>i(e))):i(d)}min(e,t){return new _e({...this._def,minSize:{value:e,message:x.toString(t)}})}max(e,t){return new _e({...this._def,maxSize:{value:e,message:x.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_e.create=(e,t)=>new _e({valueType:e,minSize:null,maxSize:null,typeName:je.ZodSet,...b(t)});class ge extends T{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ge.create=(e,t)=>new ge({getter:e,typeName:je.ZodLazy,...b(t)});class ye extends T{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:o.invalid_literal,expected:this._def.value}),p}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ve(e,t){return new xe({values:e,typeName:je.ZodEnum,...b(t)})}ye.create=(e,t)=>new ye({value:e,typeName:je.ZodLiteral,...b(t)});class xe extends T{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{expected:a.joinValues(s),received:t.parsedType,code:o.invalid_type}),p}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{received:t.data,code:o.invalid_enum_value,options:s}),p}return f(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return xe.create(e,{...this._def,...t})}exclude(e,t=this._def){return xe.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}xe.create=ve;class ke extends T{_parse(e){const t=a.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==r.string&&s.parsedType!==r.number){const e=a.objectValues(t);return l(s,{expected:a.joinValues(e),received:s.parsedType,code:o.invalid_type}),p}if(this._cache||(this._cache=new Set(a.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=a.objectValues(t);return l(s,{received:s.data,code:o.invalid_enum_value,options:e}),p}return f(e.data)}get enum(){return this._def.values}}ke.create=(e,t)=>new ke({values:e,typeName:je.ZodNativeEnum,...b(t)});class we extends T{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.promise&&!1===t.common.async)return l(t,{code:o.invalid_type,expected:r.promise,received:t.parsedType}),p;const s=t.parsedType===r.promise?t.data:Promise.resolve(t.data);return f(s.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}we.create=(e,t)=>new we({type:e,typeName:je.ZodPromise,...b(t)});class be extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===je.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,r={addIssue:e=>{l(s,e),e.fatal?t.abort():t.dirty()},get path(){return s.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===n.type){const e=n.transform(s.data,r);if(s.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return p;const a=await this._def.schema._parseAsync({data:e,path:s.path,parent:s});return"aborted"===a.status?p:"dirty"===a.status||"dirty"===t.value?m(a.value):a}));{if("aborted"===t.value)return p;const a=this._def.schema._parseSync({data:e,path:s.path,parent:s});return"aborted"===a.status?p:"dirty"===a.status||"dirty"===t.value?m(a.value):a}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,r);if(s.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===s.common.async){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===a.status?p:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((s=>"aborted"===s.status?p:("dirty"===s.status&&t.dirty(),e(s.value).then((()=>({status:t.value,value:s.value}))))))}if("transform"===n.type){if(!1===s.common.async){const e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!y(e))return p;const a=n.transform(e.value,r);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((e=>y(e)?Promise.resolve(n.transform(e.value,r)).then((e=>({status:t.value,value:e}))):p))}a.assertNever(n)}}be.create=(e,t,s)=>new be({schema:e,typeName:je.ZodEffects,effect:t,...b(s)}),be.createWithPreprocess=(e,t,s)=>new be({schema:t,effect:{type:"preprocess",transform:e},typeName:je.ZodEffects,...b(s)});class Te extends T{_parse(e){return this._getType(e)===r.undefined?f(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Te.create=(e,t)=>new Te({innerType:e,typeName:je.ZodOptional,...b(t)});class Ce extends T{_parse(e){return this._getType(e)===r.null?f(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ce.create=(e,t)=>new Ce({innerType:e,typeName:je.ZodNullable,...b(t)});class Oe extends T{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===r.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Oe.create=(e,t)=>new Oe({innerType:e,typeName:je.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...b(t)});class Se extends T{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return v(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new d(s.common.issues)},input:s.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new d(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Se.create=(e,t)=>new Se({innerType:e,typeName:je.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...b(t)});class Ae extends T{_parse(e){if(this._getType(e)!==r.nan){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.nan,received:t.parsedType}),p}return{status:"valid",value:e.data}}}Ae.create=e=>new Ae({typeName:je.ZodNaN,...b(e)});class Ze extends T{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ie extends T{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?p:"dirty"===e.status?(t.dirty(),m(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})()}{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?p:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new Ie({in:e,out:t,typeName:je.ZodPipeline})}}class Ee extends T{_parse(e){const t=this._def.innerType._parse(e),s=e=>(y(e)&&(e.value=Object.freeze(e.value)),e);return v(t)?t.then((e=>s(e))):s(t)}unwrap(){return this._def.innerType}}var je;Ee.create=(e,t)=>new Ee({innerType:e,typeName:je.ZodReadonly,...b(t)}),function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(je||(je={}));const Pe=W.create,Re=B.create,Ne=G.create,$e=te.create,Me=se.create;ae.create;const Ue=re.create,ze=oe.create,Le=de.create,Fe=ue.create;he.create,pe.create;const De=me.create,Ve=ye.create,qe=xe.create;we.create;const Ke=Te.create;Ce.create;const We="2025-03-26",He="2.0",Be=Le([Pe(),Re().int()]),Je=Pe(),Ge=ze({progressToken:Ke(Be)}).passthrough(),Ye=ze({_meta:Ke(Ge)}).passthrough(),Xe=ze({method:Pe(),params:Ke(Ye)}),Qe=ze({_meta:Ke(ze({}).passthrough())}).passthrough(),et=ze({method:Pe(),params:Ke(Qe)}),tt=ze({_meta:Ke(ze({}).passthrough())}).passthrough(),st=Le([Pe(),Re().int()]),at=ze({jsonrpc:Ve(He),id:st}).merge(Xe).strict(),nt=ze({jsonrpc:Ve(He)}).merge(et).strict(),rt=ze({jsonrpc:Ve(He),id:st,result:tt}).strict();var it;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError"}(it||(it={}));const ot=ze({jsonrpc:Ve(He),id:st,error:ze({code:Re().int(),message:Pe(),data:Ke(Me())})}).strict(),dt=Le([at,nt,rt,ot]),ct=tt.strict(),ut=et.extend({method:Ve("notifications/cancelled"),params:Qe.extend({requestId:st,reason:Pe().optional()})}),lt=ze({name:Pe(),version:Pe()}).passthrough(),ht=ze({experimental:Ke(ze({}).passthrough()),sampling:Ke(ze({}).passthrough()),roots:Ke(ze({listChanged:Ke(Ne())}).passthrough())}).passthrough(),pt=Xe.extend({method:Ve("initialize"),params:Ye.extend({protocolVersion:Pe(),capabilities:ht,clientInfo:lt})}),mt=ze({experimental:Ke(ze({}).passthrough()),logging:Ke(ze({}).passthrough()),completions:Ke(ze({}).passthrough()),prompts:Ke(ze({listChanged:Ke(Ne())}).passthrough()),resources:Ke(ze({subscribe:Ke(Ne()),listChanged:Ke(Ne())}).passthrough()),tools:Ke(ze({listChanged:Ke(Ne())}).passthrough())}).passthrough(),ft=tt.extend({protocolVersion:Pe(),capabilities:mt,serverInfo:lt,instructions:Ke(Pe())}),_t=et.extend({method:Ve("notifications/initialized")}),gt=Xe.extend({method:Ve("ping")}),yt=ze({progress:Re(),total:Ke(Re()),message:Ke(Pe())}).passthrough(),vt=et.extend({method:Ve("notifications/progress"),params:Qe.merge(yt).extend({progressToken:Be})}),xt=Xe.extend({params:Ye.extend({cursor:Ke(Je)}).optional()}),kt=tt.extend({nextCursor:Ke(Je)}),wt=ze({uri:Pe(),mimeType:Ke(Pe())}).passthrough(),bt=wt.extend({text:Pe()}),Tt=wt.extend({blob:Pe().base64()}),Ct=ze({uri:Pe(),name:Pe(),description:Ke(Pe()),mimeType:Ke(Pe())}).passthrough(),Ot=ze({uriTemplate:Pe(),name:Pe(),description:Ke(Pe()),mimeType:Ke(Pe())}).passthrough(),St=xt.extend({method:Ve("resources/list")}),At=kt.extend({resources:Ue(Ct)}),Zt=xt.extend({method:Ve("resources/templates/list")}),It=kt.extend({resourceTemplates:Ue(Ot)}),Et=Xe.extend({method:Ve("resources/read"),params:Ye.extend({uri:Pe()})}),jt=tt.extend({contents:Ue(Le([bt,Tt]))}),Pt=et.extend({method:Ve("notifications/resources/list_changed")}),Rt=Xe.extend({method:Ve("resources/subscribe"),params:Ye.extend({uri:Pe()})}),Nt=Xe.extend({method:Ve("resources/unsubscribe"),params:Ye.extend({uri:Pe()})}),$t=et.extend({method:Ve("notifications/resources/updated"),params:Qe.extend({uri:Pe()})}),Mt=ze({name:Pe(),description:Ke(Pe()),required:Ke(Ne())}).passthrough(),Ut=ze({name:Pe(),description:Ke(Pe()),arguments:Ke(Ue(Mt))}).passthrough(),zt=xt.extend({method:Ve("prompts/list")}),Lt=kt.extend({prompts:Ue(Ut)}),Ft=Xe.extend({method:Ve("prompts/get"),params:Ye.extend({name:Pe(),arguments:Ke(De(Pe()))})}),Dt=ze({type:Ve("text"),text:Pe()}).passthrough(),Vt=ze({type:Ve("image"),data:Pe().base64(),mimeType:Pe()}).passthrough(),qt=ze({type:Ve("audio"),data:Pe().base64(),mimeType:Pe()}).passthrough(),Kt=ze({type:Ve("resource"),resource:Le([bt,Tt])}).passthrough(),Wt=ze({role:qe(["user","assistant"]),content:Le([Dt,Vt,qt,Kt])}).passthrough(),Ht=tt.extend({description:Ke(Pe()),messages:Ue(Wt)}),Bt=et.extend({method:Ve("notifications/prompts/list_changed")}),Jt=ze({title:Ke(Pe()),readOnlyHint:Ke(Ne()),destructiveHint:Ke(Ne()),idempotentHint:Ke(Ne()),openWorldHint:Ke(Ne())}).passthrough(),Gt=ze({name:Pe(),description:Ke(Pe()),inputSchema:ze({type:Ve("object"),properties:Ke(ze({}).passthrough()),required:Ke(Ue(Pe()))}).passthrough(),outputSchema:Ke(ze({type:Ve("object"),properties:Ke(ze({}).passthrough()),required:Ke(Ue(Pe()))}).passthrough()),annotations:Ke(Jt)}).passthrough(),Yt=xt.extend({method:Ve("tools/list")}),Xt=kt.extend({tools:Ue(Gt)}),Qt=tt.extend({content:Ue(Le([Dt,Vt,qt,Kt])).default([]),structuredContent:ze({}).passthrough().optional(),isError:Ke(Ne())});Qt.or(tt.extend({toolResult:Me()}));const es=Xe.extend({method:Ve("tools/call"),params:Ye.extend({name:Pe(),arguments:Ke(De(Me()))})}),ts=et.extend({method:Ve("notifications/tools/list_changed")}),ss=qe(["debug","info","notice","warning","error","critical","alert","emergency"]),as=Xe.extend({method:Ve("logging/setLevel"),params:Ye.extend({level:ss})}),ns=et.extend({method:Ve("notifications/message"),params:Qe.extend({level:ss,logger:Ke(Pe()),data:Me()})}),rs=ze({name:Pe().optional()}).passthrough(),is=ze({hints:Ke(Ue(rs)),costPriority:Ke(Re().min(0).max(1)),speedPriority:Ke(Re().min(0).max(1)),intelligencePriority:Ke(Re().min(0).max(1))}).passthrough(),os=ze({role:qe(["user","assistant"]),content:Le([Dt,Vt,qt])}).passthrough(),ds=Xe.extend({method:Ve("sampling/createMessage"),params:Ye.extend({messages:Ue(os),systemPrompt:Ke(Pe()),includeContext:Ke(qe(["none","thisServer","allServers"])),temperature:Ke(Re()),maxTokens:Re().int(),stopSequences:Ke(Ue(Pe())),metadata:Ke(ze({}).passthrough()),modelPreferences:Ke(is)})}),cs=tt.extend({model:Pe(),stopReason:Ke(qe(["endTurn","stopSequence","maxTokens"]).or(Pe())),role:qe(["user","assistant"]),content:Fe("type",[Dt,Vt,qt])}),us=ze({type:Ve("ref/resource"),uri:Pe()}).passthrough(),ls=ze({type:Ve("ref/prompt"),name:Pe()}).passthrough(),hs=Xe.extend({method:Ve("completion/complete"),params:Ye.extend({ref:Le([ls,us]),argument:ze({name:Pe(),value:Pe()}).passthrough()})}),ps=tt.extend({completion:ze({values:Ue(Pe()).max(100),total:Ke(Re().int()),hasMore:Ke(Ne())}).passthrough()}),ms=ze({uri:Pe().startsWith("file://"),name:Ke(Pe())}).passthrough(),fs=Xe.extend({method:Ve("roots/list")}),_s=tt.extend({roots:Ue(ms)}),gs=et.extend({method:Ve("notifications/roots/list_changed")});Le([gt,pt,hs,as,Ft,zt,St,Zt,Et,Rt,Nt,es,Yt]),Le([ut,vt,_t,gs]),Le([ct,cs,_s]),Le([gt,ds,fs]),Le([ut,vt,ns,$t,Pt,ts,Bt]),Le([ct,ft,ps,Ht,Lt,At,It,jt,Qt,Xt]);const ys=ze({resource:Pe().url(),authorization_servers:Ue(Pe().url()).optional(),jwks_uri:Pe().url().optional(),scopes_supported:Ue(Pe()).optional(),bearer_methods_supported:Ue(Pe()).optional(),resource_signing_alg_values_supported:Ue(Pe()).optional(),resource_name:Pe().optional(),resource_documentation:Pe().optional(),resource_policy_uri:Pe().url().optional(),resource_tos_uri:Pe().url().optional(),tls_client_certificate_bound_access_tokens:Ne().optional(),authorization_details_types_supported:Ue(Pe()).optional(),dpop_signing_alg_values_supported:Ue(Pe()).optional(),dpop_bound_access_tokens_required:Ne().optional()}).passthrough(),vs=ze({issuer:Pe(),authorization_endpoint:Pe(),token_endpoint:Pe(),registration_endpoint:Pe().optional(),scopes_supported:Ue(Pe()).optional(),response_types_supported:Ue(Pe()),response_modes_supported:Ue(Pe()).optional(),grant_types_supported:Ue(Pe()).optional(),token_endpoint_auth_methods_supported:Ue(Pe()).optional(),token_endpoint_auth_signing_alg_values_supported:Ue(Pe()).optional(),service_documentation:Pe().optional(),revocation_endpoint:Pe().optional(),revocation_endpoint_auth_methods_supported:Ue(Pe()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Ue(Pe()).optional(),introspection_endpoint:Pe().optional(),introspection_endpoint_auth_methods_supported:Ue(Pe()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Ue(Pe()).optional(),code_challenge_methods_supported:Ue(Pe()).optional()}).passthrough(),xs=ze({access_token:Pe(),token_type:Pe(),expires_in:Re().optional(),scope:Pe().optional(),refresh_token:Pe().optional()}).strip();ze({error:Pe(),error_description:Pe().optional(),error_uri:Pe().optional()});const ks=ze({redirect_uris:Ue(Pe()).refine((e=>e.every((e=>URL.canParse(e)))),{message:"redirect_uris must contain valid URLs"}),token_endpoint_auth_method:Pe().optional(),grant_types:Ue(Pe()).optional(),response_types:Ue(Pe()).optional(),client_name:Pe().optional(),client_uri:Pe().optional(),logo_uri:Pe().optional(),scope:Pe().optional(),contacts:Ue(Pe()).optional(),tos_uri:Pe().optional(),policy_uri:Pe().optional(),jwks_uri:Pe().optional(),jwks:$e().optional(),software_id:Pe().optional(),software_version:Pe().optional()}).strip(),ws=ze({client_id:Pe(),client_secret:Pe().optional(),client_id_issued_at:Re().optional(),client_secret_expires_at:Re().optional()}).strip(),bs=ks.merge(ws);ze({error:Pe(),error_description:Pe().optional()}).strip(),ze({token:Pe(),token_type_hint:Pe().optional()}).strip();class Ts extends Error{constructor(e){super(null!=e?e:"Unauthorized")}}async function Cs(e,{serverUrl:t,authorizationCode:a,scope:n,resourceMetadataUrl:r}){let i=t;try{const e=await async function(e,t){var s;let a,n;a=new URL("/.well-known/oauth-protected-resource",e);try{n=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(s=null==t?void 0:t.protocolVersion)&&void 0!==s?s:We}})}catch(e){if(!(e instanceof TypeError))throw e;n=await fetch(a)}if(404===n.status)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return ys.parse(await n.json())}(r||t);e.authorization_servers&&e.authorization_servers.length>0&&(i=e.authorization_servers[0])}catch(e){console.warn("Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server",e)}const o=await async function(e,t){var s;const a=new URL("/.well-known/oauth-authorization-server",e);let n;try{n=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(s=null==t?void 0:t.protocolVersion)&&void 0!==s?s:We}})}catch(e){if(!(e instanceof TypeError))throw e;n=await fetch(a)}if(404===n.status)return;if(!n.ok)throw new Error(`HTTP ${n.status} trying to load well-known OAuth metadata`);return vs.parse(await n.json())}(i);let d=await Promise.resolve(e.clientInformation());if(!d){if(void 0!==a)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const t=await async function(e,{metadata:t,clientMetadata:s}){let a;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");a=new URL(t.registration_endpoint)}else a=new URL("/register",e);const n=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!n.ok)throw new Error(`Dynamic client registration failed: HTTP ${n.status}`);return bs.parse(await n.json())}(i,{metadata:o,clientMetadata:e.clientMetadata});await e.saveClientInformation(t),d=t}if(void 0!==a){const t=await e.codeVerifier(),s=await async function(e,{metadata:t,clientInformation:s,authorizationCode:a,codeVerifier:n,redirectUri:r}){const i="authorization_code";let o;if(t){if(o=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(i))throw new Error(`Incompatible auth server: does not support grant type ${i}`)}else o=new URL("/token",e);const d=new URLSearchParams({grant_type:i,client_id:s.client_id,code:a,code_verifier:n,redirect_uri:String(r)});s.client_secret&&d.set("client_secret",s.client_secret);const c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:d});if(!c.ok)throw new Error(`Token exchange failed: HTTP ${c.status}`);return xs.parse(await c.json())}(i,{metadata:o,clientInformation:d,authorizationCode:a,codeVerifier:t,redirectUri:e.redirectUrl});return await e.saveTokens(s),"AUTHORIZED"}const c=await e.tokens();if(null==c?void 0:c.refresh_token)try{const t=await async function(e,{metadata:t,clientInformation:s,refreshToken:a}){const n="refresh_token";let r;if(t){if(r=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(n))throw new Error(`Incompatible auth server: does not support grant type ${n}`)}else r=new URL("/token",e);const i=new URLSearchParams({grant_type:n,client_id:s.client_id,refresh_token:a});s.client_secret&&i.set("client_secret",s.client_secret);const o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i});if(!o.ok)throw new Error(`Token refresh failed: HTTP ${o.status}`);return xs.parse({refresh_token:a,...await o.json()})}(i,{metadata:o,clientInformation:d,refreshToken:c.refresh_token});return await e.saveTokens(t),"AUTHORIZED"}catch(e){console.error("Could not refresh OAuth tokens:",e)}const u=e.state?await e.state():void 0,{authorizationUrl:l,codeVerifier:h}=await async function(e,{metadata:t,clientInformation:a,redirectUrl:n,scope:r,state:i}){const o="code",d="S256";let c;if(t){if(c=new URL(t.authorization_endpoint),!t.response_types_supported.includes(o))throw new Error(`Incompatible auth server: does not support response type ${o}`);if(!t.code_challenge_methods_supported||!t.code_challenge_methods_supported.includes(d))throw new Error(`Incompatible auth server: does not support code challenge method ${d}`)}else c=new URL("/authorize",e);const u=await s(),l=u.code_verifier,h=u.code_challenge;c.searchParams.set("response_type",o),c.searchParams.set("client_id",a.client_id),c.searchParams.set("code_challenge",h),c.searchParams.set("code_challenge_method",d),c.searchParams.set("redirect_uri",String(n)),i&&c.searchParams.set("state",i);r&&c.searchParams.set("scope",r);return{authorizationUrl:c,codeVerifier:l}}(i,{metadata:o,clientInformation:d,state:u,redirectUrl:e.redirectUrl,scope:n||e.clientMetadata.scope});return await e.saveCodeVerifier(h),await e.redirectToAuthorization(l),"REDIRECT"}class Os extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function Ss(e){}function As(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Ss,onError:s=Ss,onRetry:a=Ss,onComment:n}=e;let r,i="",o=!0,d="",c="";function u(e){if(""===e)return d.length>0&&t({id:r,event:c||void 0,data:d.endsWith("\n")?d.slice(0,-1):d}),r=void 0,d="",void(c="");if(e.startsWith(":"))return void(n&&n(e.slice(e.startsWith(": ")?2:1)));const s=e.indexOf(":");if(-1===s)l(e,"",e);else{const t=e.slice(0,s),a=" "===e[s+1]?2:1;l(t,e.slice(s+a),e)}}function l(e,t,n){switch(e){case"event":c=t;break;case"data":d=`${d}${t}\n`;break;case"id":r=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?a(parseInt(t,10)):s(new Os(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:n}));break;default:s(new Os(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:"unknown-field",field:e,value:t,line:n}))}}return{feed:function(e){const t=o?e.replace(/^\xEF\xBB\xBF/,""):e,[s,a]=function(e){const t=[];let s="",a=0;for(;a<e.length;){const n=e.indexOf("\r",a),r=e.indexOf("\n",a);let i=-1;if(-1!==n&&-1!==r?i=Math.min(n,r):-1!==n?i=n:-1!==r&&(i=r),-1===i){s=e.slice(a);break}{const s=e.slice(a,i);t.push(s),a=i+1,"\r"===e[a-1]&&"\n"===e[a]&&a++}}return[t,s]}(`${i}${t}`);for(const e of s)u(e);i=a,o=!1},reset:function(e={}){i&&e.consume&&u(i),o=!0,r=void 0,d="",c="",i=""}}}class Zs extends TransformStream{constructor({onError:e,onRetry:t,onComment:s}={}){let a;super({start(n){a=As({onEvent:e=>{n.enqueue(e)},onError(t){"terminate"===e?n.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:s})},transform(e){a.feed(e)}})}}const Is={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Es extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class js{constructor(e,t){var s;this._url=e,this._resourceMetadataUrl=void 0,this._requestInit=null==t?void 0:t.requestInit,this._authProvider=null==t?void 0:t.authProvider,this._sessionId=null==t?void 0:t.sessionId,this._reconnectionOptions=null!==(s=null==t?void 0:t.reconnectionOptions)&&void 0!==s?s:Is}async _authThenStart(){var e;if(!this._authProvider)throw new Ts("No auth provider");let t;try{t=await Cs(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl})}catch(t){throw null===(e=this.onerror)||void 0===e||e.call(this,t),t}if("AUTHORIZED"!==t)throw new Ts;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var e;const t={};if(this._authProvider){const e=await this._authProvider.tokens();e&&(t.Authorization=`Bearer ${e.access_token}`)}return this._sessionId&&(t["mcp-session-id"]=this._sessionId),new Headers({...t,...null===(e=this._requestInit)||void 0===e?void 0:e.headers})}async _startOrAuthSse(e){var t,s;const{resumptionToken:a}=e;try{const s=await this._commonHeaders();s.set("Accept","text/event-stream"),a&&s.set("last-event-id",a);const n=await fetch(this._url,{method:"GET",headers:s,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal});if(!n.ok){if(401===n.status&&this._authProvider)return await this._authThenStart();if(405===n.status)return;throw new Es(n.status,`Failed to open SSE stream: ${n.statusText}`)}this._handleSseStream(n.body,e)}catch(e){throw null===(s=this.onerror)||void 0===s||s.call(this,e),e}}_getNextReconnectionDelay(e){const t=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(s,e),a)}_scheduleReconnection(e,t=0){var s;const a=this._reconnectionOptions.maxRetries;if(a>0&&t>=a)return void(null===(s=this.onerror)||void 0===s||s.call(this,new Error(`Maximum reconnection attempts (${a}) exceeded.`)));const n=this._getNextReconnectionDelay(t);setTimeout((()=>{this._startOrAuthSse(e).catch((s=>{var a;null===(a=this.onerror)||void 0===a||a.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(e,t+1)}))}),n)}_handleSseStream(e,t){if(!e)return;const{onresumptiontoken:s,replayMessageId:a}=t;let n;(async()=>{var t,r,i,o,d;try{const i=e.pipeThrough(new TextDecoderStream).pipeThrough(new Zs).getReader();for(;;){const{value:e,done:o}=await i.read();if(o)break;if(e.id&&(n=e.id,null==s||s(e.id)),!e.event||"message"===e.event)try{const s=dt.parse(JSON.parse(e.data));void 0!==a&&(d=s,rt.safeParse(d).success)&&(s.id=a),null===(t=this.onmessage)||void 0===t||t.call(this,s)}catch(e){null===(r=this.onerror)||void 0===r||r.call(this,e)}}}catch(e){if(null===(i=this.onerror)||void 0===i||i.call(this,new Error(`SSE stream disconnected: ${e}`)),this._abortController&&!this._abortController.signal.aborted&&void 0!==n)try{this._scheduleReconnection({resumptionToken:n,onresumptiontoken:s,replayMessageId:a},0)}catch(e){null===(o=this.onerror)||void 0===o||o.call(this,new Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Ts("No auth provider");if("AUTHORIZED"!==await Cs(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl}))throw new Ts("Failed to authorize")}async close(){var e,t;null===(e=this._abortController)||void 0===e||e.abort(),null===(t=this.onclose)||void 0===t||t.call(this)}async send(e,t){var s,a,n,r;try{const{resumptionToken:n,onresumptiontoken:i}=t||{};if(n)return void this._startOrAuthSse({resumptionToken:n,replayMessageId:(r=e,at.safeParse(r).success?e.id:void 0)}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)}));const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const d={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(e),signal:null===(s=this._abortController)||void 0===s?void 0:s.signal},c=await fetch(this._url,d),u=c.headers.get("mcp-session-id");if(u&&(this._sessionId=u),!c.ok){if(401===c.status&&this._authProvider){this._resourceMetadataUrl=function(e){const t=e.headers.get("WWW-Authenticate");if(!t)return;const[s,a]=t.split(" ");if("bearer"!==s.toLowerCase()||!a)return void console.log("Invalid WWW-Authenticate header format, expected 'Bearer'");const n=/resource_metadata="([^"]*)"/.exec(t);if(n)try{return new URL(n[1])}catch(e){return void console.log("Invalid resource metadata url: ",n[1])}}(c);if("AUTHORIZED"!==await Cs(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl}))throw new Ts;return this.send(e)}const t=await c.text().catch((()=>null));throw new Error(`Error POSTing to endpoint (HTTP ${c.status}): ${t}`)}if(202===c.status)return void((e=>_t.safeParse(e).success)(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)})));const l=(Array.isArray(e)?e:[e]).filter((e=>"method"in e&&"id"in e&&void 0!==e.id)).length>0,h=c.headers.get("content-type");if(l)if(null==h?void 0:h.includes("text/event-stream"))this._handleSseStream(c.body,{onresumptiontoken:i});else{if(!(null==h?void 0:h.includes("application/json")))throw new Es(-1,`Unexpected content type: ${h}`);{const e=await c.json(),t=Array.isArray(e)?e.map((e=>dt.parse(e))):[dt.parse(e)];for(const e of t)null===(a=this.onmessage)||void 0===a||a.call(this,e)}}}catch(e){throw null===(n=this.onerror)||void 0===n||n.call(this,e),e}}get sessionId(){return this._sessionId}async terminateSession(){var e,t;if(this._sessionId)try{const t=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:t,signal:null===(e=this._abortController)||void 0===e?void 0:e.signal},a=await fetch(this._url,s);if(!a.ok&&405!==a.status)throw new Es(a.status,`Failed to terminate session: ${a.statusText}`);this._sessionId=void 0}catch(e){throw null===(t=this.onerror)||void 0===t||t.call(this,e),e}}}class Ps{static async init(e){if(!(null==e?void 0:e.apiKey))throw new Error("MboaAI-SDK: apiKey is required");if(Ps.ready)return;const{apiKey:s,mcpUrl:a="https://api.filparty.com:8001/mcp",name:n="MboaAI-SDK",version:r="1.0.0",defaultType:i="standard"}=e;Ps.client=new t.MCPClient({name:n,version:r}),await Ps.client.connect(new js(new URL(a),{requestInit:{headers:{"x-api-key":s}}})),Ps.apiKey=s,Ps.defaultType=i,Ps.ready=!0}static async translate(e,t,s){var a,n,r;if(!Ps.ready)throw new Error("MboaAI-SDK: call init() first");const i=`Translate "${e}" into ${t} for ${null!=s?s:Ps.defaultType}`;try{const t=await Ps.client.callTool({name:"run_translate",arguments:{message:i,api_key:Ps.apiKey}}),s=String(null!==(r=null===(n=null===(a=null==t?void 0:t.content)||void 0===a?void 0:a[0])||void 0===n?void 0:n.text)&&void 0!==r?r:"");if((e=>{const t=e.trim().charAt(0);return"{"===t||"["===t})(s))try{const t=JSON.parse(s);return t.reply||t.text||e}catch(e){}return s||e}catch(t){return console.error("[MboaAI-SDK] translate error → returning source",t),e}}}Ps.ready=!1,Ps.defaultType="standard",Ps.apiKey="","undefined"!=typeof window&&(window.MboaAI=window.MboaAI||{},window.MboaAI.T=Ps),e.T=Ps,e.default=Ps,Object.defineProperty(e,"__esModule",{value:!0})}));
|