@xyd-js/ask-ai 0.0.0-build-1760f84-20251129221538 → 0.0.0-build-aebf977-20251203155725

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{env as e}from"node:process";import{streamText as t,stepCountIs as n}from"ai";import{experimental_createMCPClient as r}from"@ai-sdk/mcp";import{_ as a,a as i,b as s,c as o,d as u,e as c,f as d,g as l,h,i as f,j as p,k as v,l as m}from"../_rollupPluginBabelHelpers-B0vHBMb8.js";import y from"pkce-challenge";import{createAnthropic as _}from"@ai-sdk/anthropic";import{createOpenAI as g}from"@ai-sdk/openai";var k,w;!function(e){e.assertEqual=function(e){},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=function(e){var t,n={},r=i(e);try{for(r.s();!(t=r.n()).done;){var a=t.value;n[a]=a}}catch(e){r.e(e)}finally{r.f()}return n},e.getValidEnumValues=function(t){var n,r=e.objectKeys(t).filter(function(e){return"number"!=typeof t[t[e]]}),a={},s=i(r);try{for(s.s();!(n=s.n()).done;){var o=n.value;a[o]=t[o]}}catch(e){s.e(e)}finally{s.f()}return e.objectValues(a)},e.objectValues=function(t){return e.objectKeys(t).map(function(e){return t[e]})},e.objectKeys="function"==typeof Object.keys?function(e){return Object.keys(e)}:function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=function(e,t){var n,r=i(e);try{for(r.s();!(n=r.n()).done;){var a=n.value;if(t(a))return a}}catch(e){r.e(e)}finally{r.f()}},e.isInteger="function"==typeof Number.isInteger?function(e){return Number.isInteger(e)}:function(e){return"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e},e.joinValues=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:" | ";return e.map(function(e){return"string"==typeof e?"'".concat(e,"'"):e}).join(t)},e.jsonStringifyReplacer=function(e,t){return"bigint"==typeof t?t.toString():t}}(k||(k={})),function(e){e.mergeShapes=function(e,t){return s(s({},e),t)}}(w||(w={}));var b=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),x=function(e){switch(a(e)){case"undefined":return b.undefined;case"string":return b.string;case"number":return Number.isNaN(e)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(e)?b.array:null===e?b.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?b.promise:"undefined"!=typeof Map&&e instanceof Map?b.map:"undefined"!=typeof Set&&e instanceof Set?b.set:"undefined"!=typeof Date&&e instanceof Date?b.date:b.object;default:return b.unknown}},T=k.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"]),C=function(e){function t(e){var n;d(this,t),(n=l(this,t)).issues=[],n.addIssue=function(e){n.issues=[].concat(h(n.issues),[e])},n.addIssues=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];n.issues=[].concat(h(n.issues),h(e))};var r=(this instanceof t?this.constructor:void 0).prototype;return Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,n.name="ZodError",n.issues=e,n}return o(t,e),u(t,[{key:"errors",get:function(){return this.issues}},{key:"format",value:function(e){var t=e||function(e){return e.message},n={_errors:[]},r=function(e){var a,s=i(e.issues);try{for(s.s();!(a=s.n()).done;){var o=a.value;if("invalid_union"===o.code)o.unionErrors.map(r);else if("invalid_return_type"===o.code)r(o.returnTypeError);else if("invalid_arguments"===o.code)r(o.argumentsError);else if(0===o.path.length)n._errors.push(t(o));else for(var u=n,c=0;c<o.path.length;){var d=o.path[c];c===o.path.length-1?(u[d]=u[d]||{_errors:[]},u[d]._errors.push(t(o))):u[d]=u[d]||{_errors:[]},u=u[d],c++}}}catch(e){s.e(e)}finally{s.f()}};return r(this),n}},{key:"toString",value:function(){return this.message}},{key:"message",get:function(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}},{key:"isEmpty",get:function(){return 0===this.issues.length}},{key:"flatten",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(e){return e.message},n={},r=[],a=i(this.issues);try{for(a.s();!(e=a.n()).done;){var s=e.value;if(s.path.length>0){var o=s.path[0];n[o]=n[o]||[],n[o].push(t(s))}else r.push(t(s))}}catch(e){a.e(e)}finally{a.f()}return{formErrors:r,fieldErrors:n}}},{key:"formErrors",get:function(){return this.flatten()}}],[{key:"assert",value:function(e){if(!(e instanceof t))throw new Error("Not a ZodError: ".concat(e))}}])}(c(Error));C.create=function(e){return new C(e)};var O=function(e,t){var n;switch(e.code){case T.invalid_type:n=e.received===b.undefined?"Required":"Expected ".concat(e.expected,", received ").concat(e.received);break;case T.invalid_literal:n="Invalid literal value, expected ".concat(JSON.stringify(e.expected,k.jsonStringifyReplacer));break;case T.unrecognized_keys:n="Unrecognized key(s) in object: ".concat(k.joinValues(e.keys,", "));break;case T.invalid_union:n="Invalid input";break;case T.invalid_union_discriminator:n="Invalid discriminator value. Expected ".concat(k.joinValues(e.options));break;case T.invalid_enum_value:n="Invalid enum value. Expected ".concat(k.joinValues(e.options),", received '").concat(e.received,"'");break;case T.invalid_arguments:n="Invalid function arguments";break;case T.invalid_return_type:n="Invalid function return type";break;case T.invalid_date:n="Invalid date";break;case T.invalid_string:"object"===a(e.validation)?"includes"in e.validation?(n='Invalid input: must include "'.concat(e.validation.includes,'"'),"number"==typeof e.validation.position&&(n="".concat(n," at one or more positions greater than or equal to ").concat(e.validation.position))):"startsWith"in e.validation?n='Invalid input: must start with "'.concat(e.validation.startsWith,'"'):"endsWith"in e.validation?n='Invalid input: must end with "'.concat(e.validation.endsWith,'"'):k.assertNever(e.validation):n="regex"!==e.validation?"Invalid ".concat(e.validation):"Invalid";break;case T.too_small:n="array"===e.type?"Array must contain ".concat(e.exact?"exactly":e.inclusive?"at least":"more than"," ").concat(e.minimum," element(s)"):"string"===e.type?"String must contain ".concat(e.exact?"exactly":e.inclusive?"at least":"over"," ").concat(e.minimum," character(s)"):"number"===e.type||"bigint"===e.type?"Number must be ".concat(e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than ").concat(e.minimum):"date"===e.type?"Date must be ".concat(e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than ").concat(new Date(Number(e.minimum))):"Invalid input";break;case T.too_big:n="array"===e.type?"Array must contain ".concat(e.exact?"exactly":e.inclusive?"at most":"less than"," ").concat(e.maximum," element(s)"):"string"===e.type?"String must contain ".concat(e.exact?"exactly":e.inclusive?"at most":"under"," ").concat(e.maximum," character(s)"):"number"===e.type?"Number must be ".concat(e.exact?"exactly":e.inclusive?"less than or equal to":"less than"," ").concat(e.maximum):"bigint"===e.type?"BigInt must be ".concat(e.exact?"exactly":e.inclusive?"less than or equal to":"less than"," ").concat(e.maximum):"date"===e.type?"Date must be ".concat(e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"," ").concat(new Date(Number(e.maximum))):"Invalid input";break;case T.custom:n="Invalid input";break;case T.invalid_intersection_types:n="Intersection results could not be merged";break;case T.not_multiple_of:n="Number must be a multiple of ".concat(e.multipleOf);break;case T.not_finite:n="Number must be finite";break;default:n=t.defaultError,k.assertNever(e)}return{message:n}},A=O;function R(){return A}var S=function(e){var t=e.data,n=e.path,r=e.errorMaps,a=e.issueData,o=[].concat(h(n),h(a.path||[])),u=s(s({},a),{},{path:o});if(void 0!==a.message)return s(s({},a),{},{path:o,message:a.message});var c,d="",l=r.filter(function(e){return!!e}).slice().reverse(),f=i(l);try{for(f.s();!(c=f.n()).done;){d=(0,c.value)(u,{data:t,defaultError:d}).message}}catch(e){f.e(e)}finally{f.f()}return s(s({},a),{},{path:o,message:d})};function E(e,t){var n=R(),r=S({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===O?void 0:O].filter(function(e){return!!e})});e.common.issues.push(r)}var I,Z=function(){function e(){d(this,e),this.value="valid"}return u(e,[{key:"dirty",value:function(){"valid"===this.value&&(this.value="dirty")}},{key:"abort",value:function(){"aborted"!==this.value&&(this.value="aborted")}}],[{key:"mergeArray",value:function(e,t){var n,r=[],a=i(t);try{for(a.s();!(n=a.n()).done;){var s=n.value;if("aborted"===s.status)return j;"dirty"===s.status&&e.dirty(),r.push(s.value)}}catch(e){a.e(e)}finally{a.f()}return{status:e.value,value:r}}},{key:"mergeObjectAsync",value:(t=f(p().m(function t(n,r){var a,s,o,u,c,d,l;return p().w(function(t){for(;;)switch(t.p=t.n){case 0:a=[],s=i(r),t.p=1,s.s();case 2:if((o=s.n()).done){t.n=6;break}return u=o.value,t.n=3,u.key;case 3:return c=t.v,t.n=4,u.value;case 4:d=t.v,a.push({key:c,value:d});case 5:t.n=2;break;case 6:t.n=8;break;case 7:t.p=7,l=t.v,s.e(l);case 8:return t.p=8,s.f(),t.f(8);case 9:return t.a(2,e.mergeObjectSync(n,a))}},t,null,[[1,7,8,9]])})),function(e,n){return t.apply(this,arguments)})},{key:"mergeObjectSync",value:function(e,t){var n,r={},a=i(t);try{for(a.s();!(n=a.n()).done;){var s=n.value,o=s.key,u=s.value;if("aborted"===o.status)return j;if("aborted"===u.status)return j;"dirty"===o.status&&e.dirty(),"dirty"===u.status&&e.dirty(),"__proto__"===o.value||void 0===u.value&&!s.alwaysSet||(r[o.value]=u.value)}}catch(e){a.e(e)}finally{a.f()}return{status:e.value,value:r}}}]);var t}(),j=Object.freeze({status:"aborted"}),P=function(e){return{status:"dirty",value:e}},N=function(e){return{status:"valid",value:e}},U=function(e){return"aborted"===e.status},M=function(e){return"dirty"===e.status},L=function(e){return"valid"===e.status},F=function(e){return"undefined"!=typeof Promise&&e instanceof Promise};!function(e){e.errToObj=function(e){return"string"==typeof e?{message:e}:e||{}},e.toString=function(e){return"string"==typeof e?e:null==e?void 0:e.message}}(I||(I={}));var z=function(){return u(function e(t,n,r,a){d(this,e),this._cachedPath=[],this.parent=t,this.data=n,this._path=r,this._key=a},[{key:"path",get:function(){var e,t;this._cachedPath.length||(Array.isArray(this._key)?(e=this._cachedPath).push.apply(e,h(this._path).concat(h(this._key))):(t=this._cachedPath).push.apply(t,h(this._path).concat([this._key])));return this._cachedPath}}])}(),D=function(e,t){if(L(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;var t=new C(e.common.issues);return this._error=t,this._error}}};function V(e){if(!e)return{};var t=e.errorMap,n=e.invalid_type_error,r=e.required_error,a=e.description;if(t&&(n||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:a};return{errorMap:function(t,a){var i,s,o=e.message;return"invalid_enum_value"===t.code?{message:null!=o?o:a.defaultError}:void 0===a.data?{message:null!==(s=null!=o?o:r)&&void 0!==s?s:a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:null!==(i=null!=o?o:n)&&void 0!==i?i:a.defaultError}},description:a}}var q,H=function(){return u(function e(t){var n=this;d(this,e),this.spa=this.safeParseAsync,this._def=t,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:function(e){return n["~validate"](e)}}},[{key:"description",get:function(){return this._def.description}},{key:"_getType",value:function(e){return x(e.data)}},{key:"_getOrReturnCtx",value:function(e,t){return t||{common:e.parent.common,data:e.data,parsedType:x(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}},{key:"_processInputParams",value:function(e){return{status:new Z,ctx:{common:e.parent.common,data:e.data,parsedType:x(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}},{key:"_parseSync",value:function(e){var t=this._parse(e);if(F(t))throw new Error("Synchronous parse encountered promise.");return t}},{key:"_parseAsync",value:function(e){var t=this._parse(e);return Promise.resolve(t)}},{key:"parse",value:function(e,t){var n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}},{key:"safeParse",value:function(e,t){var n,r={common:{issues:[],async:null!==(n=null==t?void 0:t.async)&&void 0!==n&&n,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:x(e)},a=this._parseSync({data:e,path:r.path,parent:r});return D(r,a)}},{key:"~validate",value:function(e){var t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:x(e)};if(!this["~standard"].async)try{var n=this._parseSync({data:e,path:[],parent:t});return L(n)?{value:n.value}:{issues:t.common.issues}}catch(e){var r;null!=e&&null!==(r=e.message)&&void 0!==r&&null!==(r=r.toLowerCase())&&void 0!==r&&r.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(function(e){return L(e)?{value:e.value}:{issues:t.common.issues}})}},{key:"parseAsync",value:(t=f(p().m(function e(t,n){var r;return p().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,this.safeParseAsync(t,n);case 1:if(!(r=e.v).success){e.n=2;break}return e.a(2,r.data);case 2:throw r.error;case 3:return e.a(2)}},e,this)})),function(e,n){return t.apply(this,arguments)})},{key:"safeParseAsync",value:(e=f(p().m(function e(t,n){var r,a,i;return p().w(function(e){for(;;)switch(e.n){case 0:return r={common:{issues:[],contextualErrorMap:null==n?void 0:n.errorMap,async:!0},path:(null==n?void 0:n.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:x(t)},a=this._parse({data:t,path:r.path,parent:r}),e.n=1,F(a)?a:Promise.resolve(a);case 1:return i=e.v,e.a(2,D(r,i))}},e,this)})),function(t,n){return e.apply(this,arguments)})},{key:"refine",value:function(e,t){return this._refinement(function(n,r){var a=e(n),i=function(){return r.addIssue(s({code:T.custom},function(e){return"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t}(n)))};return"undefined"!=typeof Promise&&a instanceof Promise?a.then(function(e){return!!e||(i(),!1)}):!!a||(i(),!1)})}},{key:"refinement",value:function(e,t){return this._refinement(function(n,r){return!!e(n)||(r.addIssue("function"==typeof t?t(n,r):t),!1)})}},{key:"_refinement",value:function(e){return new We({schema:this,typeName:Ye.ZodEffects,effect:{type:"refinement",refinement:e}})}},{key:"superRefine",value:function(e){return this._refinement(e)}},{key:"optional",value:function(){return Ke.create(this,this._def)}},{key:"nullable",value:function(){return Be.create(this,this._def)}},{key:"nullish",value:function(){return this.nullable().optional()}},{key:"array",value:function(){return Oe.create(this)}},{key:"promise",value:function(){return He.create(this,this._def)}},{key:"or",value:function(e){return Se.create([this,e],this._def)}},{key:"and",value:function(e){return je.create(this,e,this._def)}},{key:"transform",value:function(e){return new We(s(s({},V(this._def)),{},{schema:this,typeName:Ye.ZodEffects,effect:{type:"transform",transform:e}}))}},{key:"default",value:function(e){var t="function"==typeof e?e:function(){return e};return new $e(s(s({},V(this._def)),{},{innerType:this,defaultValue:t,typeName:Ye.ZodDefault}))}},{key:"brand",value:function(){return new Xe(s({typeName:Ye.ZodBranded,type:this},V(this._def)))}},{key:"catch",value:function(e){var t="function"==typeof e?e:function(){return e};return new Je(s(s({},V(this._def)),{},{innerType:this,catchValue:t,typeName:Ye.ZodCatch}))}},{key:"describe",value:function(e){return new(0,this.constructor)(s(s({},this._def),{},{description:e}))}},{key:"pipe",value:function(e){return Qe.create(this,e)}},{key:"readonly",value:function(){return et.create(this)}},{key:"isOptional",value:function(){return this.safeParse(void 0).success}},{key:"isNullable",value:function(){return this.safeParse(null).success}}]);var e,t}(),W=/^c[^\s-]{8,}$/i,K=/^[0-9a-z]+$/,B=/^[0-9A-HJKMNP-TV-Z]{26}$/i,$=/^[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,J=/^[a-z0-9_-]{21}$/i,G=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Y=/^[-+]?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)?)??$/,X=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Q=/^(?:(?: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])$/,ee=/^(?:(?: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])$/,te=/^(([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]))$/,ne=/^(([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])$/,re=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ae=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ie="((\\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])))",se=new RegExp("^".concat(ie,"$"));function oe(e){var t="[0-5]\\d";e.precision?t="".concat(t,"\\.\\d{").concat(e.precision,"}"):null==e.precision&&(t="".concat(t,"(\\.\\d+)?"));var n=e.precision?"+":"?";return"([01]\\d|2[0-3]):[0-5]\\d(:".concat(t,")").concat(n)}function ue(e){return new RegExp("^".concat(oe(e),"$"))}function ce(e){var t="".concat(ie,"T").concat(oe(e)),n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t="".concat(t,"(").concat(n.join("|"),")"),new RegExp("^".concat(t,"$"))}function de(e,t){return!("v4"!==t&&t||!Q.test(e))||!("v6"!==t&&t||!te.test(e))}function le(e,t){if(!G.test(e))return!1;try{var n=e.split("."),r=m(n,1)[0];if(!r)return!1;var i=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(i));return"object"===a(s)&&null!==s&&((!("typ"in s)||"JWT"===(null==s?void 0:s.typ))&&(!!s.alg&&(!t||s.alg===t)))}catch(e){return!1}}function he(e,t){return!("v4"!==t&&t||!ee.test(e))||!("v6"!==t&&t||!ne.test(e))}var fe=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.string,received:t.parsedType}),j}var n,r=new Z,a=void 0,s=i(this._def.checks);try{for(s.s();!(n=s.n()).done;){var o=n.value;if("min"===o.kind)e.data.length<o.value&&(E(a=this._getOrReturnCtx(e,a),{code:T.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if("max"===o.kind)e.data.length>o.value&&(E(a=this._getOrReturnCtx(e,a),{code:T.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),r.dirty());else if("length"===o.kind){var u=e.data.length>o.value,c=e.data.length<o.value;(u||c)&&(a=this._getOrReturnCtx(e,a),u?E(a,{code:T.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):c&&E(a,{code:T.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),r.dirty())}else if("email"===o.kind)X.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"email",code:T.invalid_string,message:o.message}),r.dirty());else if("emoji"===o.kind)q||(q=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),q.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"emoji",code:T.invalid_string,message:o.message}),r.dirty());else if("uuid"===o.kind)$.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"uuid",code:T.invalid_string,message:o.message}),r.dirty());else if("nanoid"===o.kind)J.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"nanoid",code:T.invalid_string,message:o.message}),r.dirty());else if("cuid"===o.kind)W.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"cuid",code:T.invalid_string,message:o.message}),r.dirty());else if("cuid2"===o.kind)K.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"cuid2",code:T.invalid_string,message:o.message}),r.dirty());else if("ulid"===o.kind)B.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"ulid",code:T.invalid_string,message:o.message}),r.dirty());else if("url"===o.kind)try{new URL(e.data)}catch(t){E(a=this._getOrReturnCtx(e,a),{validation:"url",code:T.invalid_string,message:o.message}),r.dirty()}else if("regex"===o.kind){o.regex.lastIndex=0,o.regex.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"regex",code:T.invalid_string,message:o.message}),r.dirty())}else if("trim"===o.kind)e.data=e.data.trim();else if("includes"===o.kind)e.data.includes(o.value,o.position)||(E(a=this._getOrReturnCtx(e,a),{code:T.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),r.dirty());else if("toLowerCase"===o.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===o.kind)e.data=e.data.toUpperCase();else if("startsWith"===o.kind)e.data.startsWith(o.value)||(E(a=this._getOrReturnCtx(e,a),{code:T.invalid_string,validation:{startsWith:o.value},message:o.message}),r.dirty());else if("endsWith"===o.kind)e.data.endsWith(o.value)||(E(a=this._getOrReturnCtx(e,a),{code:T.invalid_string,validation:{endsWith:o.value},message:o.message}),r.dirty());else if("datetime"===o.kind){ce(o).test(e.data)||(E(a=this._getOrReturnCtx(e,a),{code:T.invalid_string,validation:"datetime",message:o.message}),r.dirty())}else if("date"===o.kind){se.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{code:T.invalid_string,validation:"date",message:o.message}),r.dirty())}else if("time"===o.kind){ue(o).test(e.data)||(E(a=this._getOrReturnCtx(e,a),{code:T.invalid_string,validation:"time",message:o.message}),r.dirty())}else"duration"===o.kind?Y.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"duration",code:T.invalid_string,message:o.message}),r.dirty()):"ip"===o.kind?de(e.data,o.version)||(E(a=this._getOrReturnCtx(e,a),{validation:"ip",code:T.invalid_string,message:o.message}),r.dirty()):"jwt"===o.kind?le(e.data,o.alg)||(E(a=this._getOrReturnCtx(e,a),{validation:"jwt",code:T.invalid_string,message:o.message}),r.dirty()):"cidr"===o.kind?he(e.data,o.version)||(E(a=this._getOrReturnCtx(e,a),{validation:"cidr",code:T.invalid_string,message:o.message}),r.dirty()):"base64"===o.kind?re.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"base64",code:T.invalid_string,message:o.message}),r.dirty()):"base64url"===o.kind?ae.test(e.data)||(E(a=this._getOrReturnCtx(e,a),{validation:"base64url",code:T.invalid_string,message:o.message}),r.dirty()):k.assertNever(o)}}catch(e){s.e(e)}finally{s.f()}return{status:r.value,value:e.data}}},{key:"_regex",value:function(e,t,n){return this.refinement(function(t){return e.test(t)},s({validation:t,code:T.invalid_string},I.errToObj(n)))}},{key:"_addCheck",value:function(t){return new e(s(s({},this._def),{},{checks:[].concat(h(this._def.checks),[t])}))}},{key:"email",value:function(e){return this._addCheck(s({kind:"email"},I.errToObj(e)))}},{key:"url",value:function(e){return this._addCheck(s({kind:"url"},I.errToObj(e)))}},{key:"emoji",value:function(e){return this._addCheck(s({kind:"emoji"},I.errToObj(e)))}},{key:"uuid",value:function(e){return this._addCheck(s({kind:"uuid"},I.errToObj(e)))}},{key:"nanoid",value:function(e){return this._addCheck(s({kind:"nanoid"},I.errToObj(e)))}},{key:"cuid",value:function(e){return this._addCheck(s({kind:"cuid"},I.errToObj(e)))}},{key:"cuid2",value:function(e){return this._addCheck(s({kind:"cuid2"},I.errToObj(e)))}},{key:"ulid",value:function(e){return this._addCheck(s({kind:"ulid"},I.errToObj(e)))}},{key:"base64",value:function(e){return this._addCheck(s({kind:"base64"},I.errToObj(e)))}},{key:"base64url",value:function(e){return this._addCheck(s({kind:"base64url"},I.errToObj(e)))}},{key:"jwt",value:function(e){return this._addCheck(s({kind:"jwt"},I.errToObj(e)))}},{key:"ip",value:function(e){return this._addCheck(s({kind:"ip"},I.errToObj(e)))}},{key:"cidr",value:function(e){return this._addCheck(s({kind:"cidr"},I.errToObj(e)))}},{key:"datetime",value:function(e){var t,n;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(s({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(n=null==e?void 0:e.local)&&void 0!==n&&n},I.errToObj(null==e?void 0:e.message)))}},{key:"date",value:function(e){return this._addCheck({kind:"date",message:e})}},{key:"time",value:function(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(s({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision},I.errToObj(null==e?void 0:e.message)))}},{key:"duration",value:function(e){return this._addCheck(s({kind:"duration"},I.errToObj(e)))}},{key:"regex",value:function(e,t){return this._addCheck(s({kind:"regex",regex:e},I.errToObj(t)))}},{key:"includes",value:function(e,t){return this._addCheck(s({kind:"includes",value:e,position:null==t?void 0:t.position},I.errToObj(null==t?void 0:t.message)))}},{key:"startsWith",value:function(e,t){return this._addCheck(s({kind:"startsWith",value:e},I.errToObj(t)))}},{key:"endsWith",value:function(e,t){return this._addCheck(s({kind:"endsWith",value:e},I.errToObj(t)))}},{key:"min",value:function(e,t){return this._addCheck(s({kind:"min",value:e},I.errToObj(t)))}},{key:"max",value:function(e,t){return this._addCheck(s({kind:"max",value:e},I.errToObj(t)))}},{key:"length",value:function(e,t){return this._addCheck(s({kind:"length",value:e},I.errToObj(t)))}},{key:"nonempty",value:function(e){return this.min(1,I.errToObj(e))}},{key:"trim",value:function(){return new e(s(s({},this._def),{},{checks:[].concat(h(this._def.checks),[{kind:"trim"}])}))}},{key:"toLowerCase",value:function(){return new e(s(s({},this._def),{},{checks:[].concat(h(this._def.checks),[{kind:"toLowerCase"}])}))}},{key:"toUpperCase",value:function(){return new e(s(s({},this._def),{},{checks:[].concat(h(this._def.checks),[{kind:"toUpperCase"}])}))}},{key:"isDatetime",get:function(){return!!this._def.checks.find(function(e){return"datetime"===e.kind})}},{key:"isDate",get:function(){return!!this._def.checks.find(function(e){return"date"===e.kind})}},{key:"isTime",get:function(){return!!this._def.checks.find(function(e){return"time"===e.kind})}},{key:"isDuration",get:function(){return!!this._def.checks.find(function(e){return"duration"===e.kind})}},{key:"isEmail",get:function(){return!!this._def.checks.find(function(e){return"email"===e.kind})}},{key:"isURL",get:function(){return!!this._def.checks.find(function(e){return"url"===e.kind})}},{key:"isEmoji",get:function(){return!!this._def.checks.find(function(e){return"emoji"===e.kind})}},{key:"isUUID",get:function(){return!!this._def.checks.find(function(e){return"uuid"===e.kind})}},{key:"isNANOID",get:function(){return!!this._def.checks.find(function(e){return"nanoid"===e.kind})}},{key:"isCUID",get:function(){return!!this._def.checks.find(function(e){return"cuid"===e.kind})}},{key:"isCUID2",get:function(){return!!this._def.checks.find(function(e){return"cuid2"===e.kind})}},{key:"isULID",get:function(){return!!this._def.checks.find(function(e){return"ulid"===e.kind})}},{key:"isIP",get:function(){return!!this._def.checks.find(function(e){return"ip"===e.kind})}},{key:"isCIDR",get:function(){return!!this._def.checks.find(function(e){return"cidr"===e.kind})}},{key:"isBase64",get:function(){return!!this._def.checks.find(function(e){return"base64"===e.kind})}},{key:"isBase64url",get:function(){return!!this._def.checks.find(function(e){return"base64url"===e.kind})}},{key:"minLength",get:function(){var e,t=null,n=i(this._def.checks);try{for(n.s();!(e=n.n()).done;){var r=e.value;"min"===r.kind&&(null===t||r.value>t)&&(t=r.value)}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"maxLength",get:function(){var e,t=null,n=i(this._def.checks);try{for(n.s();!(e=n.n()).done;){var r=e.value;"max"===r.kind&&(null===t||r.value<t)&&(t=r.value)}}catch(e){n.e(e)}finally{n.f()}return t}}])}();function pe(e,t){var n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,a=n>r?n:r;return Number.parseInt(e.toFixed(a).replace(".",""))%Number.parseInt(t.toFixed(a).replace(".",""))/Math.pow(10,a)}fe.create=function(e){var t;return new fe(s({checks:[],typeName:Ye.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t},V(e)))};var ve=function(){function e(){var t;return d(this,e),(t=l(this,e,arguments)).min=t.gte,t.max=t.lte,t.step=t.multipleOf,t}return o(e,H),u(e,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==b.number){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.number,received:t.parsedType}),j}var n,r=void 0,a=new Z,s=i(this._def.checks);try{for(s.s();!(n=s.n()).done;){var o=n.value;if("int"===o.kind)k.isInteger(e.data)||(E(r=this._getOrReturnCtx(e,r),{code:T.invalid_type,expected:"integer",received:"float",message:o.message}),a.dirty());else if("min"===o.kind){(o.inclusive?e.data<o.value:e.data<=o.value)&&(E(r=this._getOrReturnCtx(e,r),{code:T.too_small,minimum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty())}else if("max"===o.kind){(o.inclusive?e.data>o.value:e.data>=o.value)&&(E(r=this._getOrReturnCtx(e,r),{code:T.too_big,maximum:o.value,type:"number",inclusive:o.inclusive,exact:!1,message:o.message}),a.dirty())}else"multipleOf"===o.kind?0!==pe(e.data,o.value)&&(E(r=this._getOrReturnCtx(e,r),{code:T.not_multiple_of,multipleOf:o.value,message:o.message}),a.dirty()):"finite"===o.kind?Number.isFinite(e.data)||(E(r=this._getOrReturnCtx(e,r),{code:T.not_finite,message:o.message}),a.dirty()):k.assertNever(o)}}catch(e){s.e(e)}finally{s.f()}return{status:a.value,value:e.data}}},{key:"gte",value:function(e,t){return this.setLimit("min",e,!0,I.toString(t))}},{key:"gt",value:function(e,t){return this.setLimit("min",e,!1,I.toString(t))}},{key:"lte",value:function(e,t){return this.setLimit("max",e,!0,I.toString(t))}},{key:"lt",value:function(e,t){return this.setLimit("max",e,!1,I.toString(t))}},{key:"setLimit",value:function(t,n,r,a){return new e(s(s({},this._def),{},{checks:[].concat(h(this._def.checks),[{kind:t,value:n,inclusive:r,message:I.toString(a)}])}))}},{key:"_addCheck",value:function(t){return new e(s(s({},this._def),{},{checks:[].concat(h(this._def.checks),[t])}))}},{key:"int",value:function(e){return this._addCheck({kind:"int",message:I.toString(e)})}},{key:"positive",value:function(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:I.toString(e)})}},{key:"negative",value:function(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:I.toString(e)})}},{key:"nonpositive",value:function(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:I.toString(e)})}},{key:"nonnegative",value:function(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:I.toString(e)})}},{key:"multipleOf",value:function(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.toString(t)})}},{key:"finite",value:function(e){return this._addCheck({kind:"finite",message:I.toString(e)})}},{key:"safe",value:function(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:I.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:I.toString(e)})}},{key:"minValue",get:function(){var e,t=null,n=i(this._def.checks);try{for(n.s();!(e=n.n()).done;){var r=e.value;"min"===r.kind&&(null===t||r.value>t)&&(t=r.value)}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"maxValue",get:function(){var e,t=null,n=i(this._def.checks);try{for(n.s();!(e=n.n()).done;){var r=e.value;"max"===r.kind&&(null===t||r.value<t)&&(t=r.value)}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"isInt",get:function(){return!!this._def.checks.find(function(e){return"int"===e.kind||"multipleOf"===e.kind&&k.isInteger(e.value)})}},{key:"isFinite",get:function(){var e,t=null,n=null,r=i(this._def.checks);try{for(r.s();!(e=r.n()).done;){var a=e.value;if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===n||a.value>n)&&(n=a.value):"max"===a.kind&&(null===t||a.value<t)&&(t=a.value)}}catch(e){r.e(e)}finally{r.f()}return Number.isFinite(n)&&Number.isFinite(t)}}])}();ve.create=function(e){return new ve(s({checks:[],typeName:Ye.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1},V(e)))};var me=function(){function e(){var t;return d(this,e),(t=l(this,e,arguments)).min=t.gte,t.max=t.lte,t}return o(e,H),u(e,[{key:"_parse",value:function(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(t){return this._getInvalidInput(e)}if(this._getType(e)!==b.bigint)return this._getInvalidInput(e);var t,n=void 0,r=new Z,a=i(this._def.checks);try{for(a.s();!(t=a.n()).done;){var s=t.value;if("min"===s.kind)(s.inclusive?e.data<s.value:e.data<=s.value)&&(E(n=this._getOrReturnCtx(e,n),{code:T.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty());else if("max"===s.kind){(s.inclusive?e.data>s.value:e.data>=s.value)&&(E(n=this._getOrReturnCtx(e,n),{code:T.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),r.dirty())}else"multipleOf"===s.kind?e.data%s.value!==BigInt(0)&&(E(n=this._getOrReturnCtx(e,n),{code:T.not_multiple_of,multipleOf:s.value,message:s.message}),r.dirty()):k.assertNever(s)}}catch(e){a.e(e)}finally{a.f()}return{status:r.value,value:e.data}}},{key:"_getInvalidInput",value:function(e){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.bigint,received:t.parsedType}),j}},{key:"gte",value:function(e,t){return this.setLimit("min",e,!0,I.toString(t))}},{key:"gt",value:function(e,t){return this.setLimit("min",e,!1,I.toString(t))}},{key:"lte",value:function(e,t){return this.setLimit("max",e,!0,I.toString(t))}},{key:"lt",value:function(e,t){return this.setLimit("max",e,!1,I.toString(t))}},{key:"setLimit",value:function(t,n,r,a){return new e(s(s({},this._def),{},{checks:[].concat(h(this._def.checks),[{kind:t,value:n,inclusive:r,message:I.toString(a)}])}))}},{key:"_addCheck",value:function(t){return new e(s(s({},this._def),{},{checks:[].concat(h(this._def.checks),[t])}))}},{key:"positive",value:function(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:I.toString(e)})}},{key:"negative",value:function(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:I.toString(e)})}},{key:"nonpositive",value:function(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:I.toString(e)})}},{key:"nonnegative",value:function(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:I.toString(e)})}},{key:"multipleOf",value:function(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.toString(t)})}},{key:"minValue",get:function(){var e,t=null,n=i(this._def.checks);try{for(n.s();!(e=n.n()).done;){var r=e.value;"min"===r.kind&&(null===t||r.value>t)&&(t=r.value)}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"maxValue",get:function(){var e,t=null,n=i(this._def.checks);try{for(n.s();!(e=n.n()).done;){var r=e.value;"max"===r.kind&&(null===t||r.value<t)&&(t=r.value)}}catch(e){n.e(e)}finally{n.f()}return t}}])}();me.create=function(e){var t;return new me(s({checks:[],typeName:Ye.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t},V(e)))};var ye=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==b.boolean){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.boolean,received:t.parsedType}),j}return N(e.data)}}])}();ye.create=function(e){return new ye(s({typeName:Ye.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1},V(e)))};var _e=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.date,received:t.parsedType}),j}if(Number.isNaN(e.data.getTime()))return E(this._getOrReturnCtx(e),{code:T.invalid_date}),j;var n,r=new Z,a=void 0,s=i(this._def.checks);try{for(s.s();!(n=s.n()).done;){var o=n.value;"min"===o.kind?e.data.getTime()<o.value&&(E(a=this._getOrReturnCtx(e,a),{code:T.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),r.dirty()):"max"===o.kind?e.data.getTime()>o.value&&(E(a=this._getOrReturnCtx(e,a),{code:T.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),r.dirty()):k.assertNever(o)}}catch(e){s.e(e)}finally{s.f()}return{status:r.value,value:new Date(e.data.getTime())}}},{key:"_addCheck",value:function(t){return new e(s(s({},this._def),{},{checks:[].concat(h(this._def.checks),[t])}))}},{key:"min",value:function(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:I.toString(t)})}},{key:"max",value:function(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:I.toString(t)})}},{key:"minDate",get:function(){var e,t=null,n=i(this._def.checks);try{for(n.s();!(e=n.n()).done;){var r=e.value;"min"===r.kind&&(null===t||r.value>t)&&(t=r.value)}}catch(e){n.e(e)}finally{n.f()}return null!=t?new Date(t):null}},{key:"maxDate",get:function(){var e,t=null,n=i(this._def.checks);try{for(n.s();!(e=n.n()).done;){var r=e.value;"max"===r.kind&&(null===t||r.value<t)&&(t=r.value)}}catch(e){n.e(e)}finally{n.f()}return null!=t?new Date(t):null}}])}();_e.create=function(e){return new _e(s({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:Ye.ZodDate},V(e)))};var ge=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){if(this._getType(e)!==b.symbol){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.symbol,received:t.parsedType}),j}return N(e.data)}}])}();ge.create=function(e){return new ge(s({typeName:Ye.ZodSymbol},V(e)))};var ke=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){if(this._getType(e)!==b.undefined){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.undefined,received:t.parsedType}),j}return N(e.data)}}])}();ke.create=function(e){return new ke(s({typeName:Ye.ZodUndefined},V(e)))};var we=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){if(this._getType(e)!==b.null){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.null,received:t.parsedType}),j}return N(e.data)}}])}();we.create=function(e){return new we(s({typeName:Ye.ZodNull},V(e)))};var be=function(){function e(){var t;return d(this,e),(t=l(this,e,arguments))._any=!0,t}return o(e,H),u(e,[{key:"_parse",value:function(e){return N(e.data)}}])}();be.create=function(e){return new be(s({typeName:Ye.ZodAny},V(e)))};var xe=function(){function e(){var t;return d(this,e),(t=l(this,e,arguments))._unknown=!0,t}return o(e,H),u(e,[{key:"_parse",value:function(e){return N(e.data)}}])}();xe.create=function(e){return new xe(s({typeName:Ye.ZodUnknown},V(e)))};var Te=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.never,received:t.parsedType}),j}}])}();Te.create=function(e){return new Te(s({typeName:Ye.ZodNever},V(e)))};var Ce=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){if(this._getType(e)!==b.undefined){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.void,received:t.parsedType}),j}return N(e.data)}}])}();Ce.create=function(e){return new Ce(s({typeName:Ye.ZodVoid},V(e)))};var Oe=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this._processInputParams(e),n=t.ctx,r=t.status,a=this._def;if(n.parsedType!==b.array)return E(n,{code:T.invalid_type,expected:b.array,received:n.parsedType}),j;if(null!==a.exactLength){var i=n.data.length>a.exactLength.value,s=n.data.length<a.exactLength.value;(i||s)&&(E(n,{code:i?T.too_big:T.too_small,minimum:s?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(null!==a.minLength&&n.data.length<a.minLength.value&&(E(n,{code:T.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),null!==a.maxLength&&n.data.length>a.maxLength.value&&(E(n,{code:T.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),n.common.async)return Promise.all(h(n.data).map(function(e,t){return a.type._parseAsync(new z(n,e,n.path,t))})).then(function(e){return Z.mergeArray(r,e)});var o=h(n.data).map(function(e,t){return a.type._parseSync(new z(n,e,n.path,t))});return Z.mergeArray(r,o)}},{key:"element",get:function(){return this._def.type}},{key:"min",value:function(t,n){return new e(s(s({},this._def),{},{minLength:{value:t,message:I.toString(n)}}))}},{key:"max",value:function(t,n){return new e(s(s({},this._def),{},{maxLength:{value:t,message:I.toString(n)}}))}},{key:"length",value:function(t,n){return new e(s(s({},this._def),{},{exactLength:{value:t,message:I.toString(n)}}))}},{key:"nonempty",value:function(e){return this.min(1,e)}}])}();function Ae(e){if(e instanceof Re){var t={};for(var n in e.shape){var r=e.shape[n];t[n]=Ke.create(Ae(r))}return new Re(s(s({},e._def),{},{shape:function(){return t}}))}return e instanceof Oe?new Oe(s(s({},e._def),{},{type:Ae(e.element)})):e instanceof Ke?Ke.create(Ae(e.unwrap())):e instanceof Be?Be.create(Ae(e.unwrap())):e instanceof Pe?Pe.create(e.items.map(function(e){return Ae(e)})):e}Oe.create=function(e,t){return new Oe(s({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ye.ZodArray},V(t)))};var Re=function(){function e(){var t;return d(this,e),(t=l(this,e,arguments))._cached=null,t.nonstrict=t.passthrough,t.augment=t.extend,t}return o(e,H),u(e,[{key:"_getCached",value:function(){if(null!==this._cached)return this._cached;var e=this._def.shape(),t=k.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}},{key:"_parse",value:function(e){if(this._getType(e)!==b.object){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.object,received:t.parsedType}),j}var n=this._processInputParams(e),r=n.status,a=n.ctx,s=this._getCached(),o=s.shape,u=s.keys,c=[];if(!(this._def.catchall instanceof Te&&"strip"===this._def.unknownKeys))for(var d in a.data)u.includes(d)||c.push(d);var l,h=[],v=i(u);try{for(v.s();!(l=v.n()).done;){var m=l.value,y=o[m],_=a.data[m];h.push({key:{status:"valid",value:m},value:y._parse(new z(a,_,a.path,m)),alwaysSet:m in a.data})}}catch(e){v.e(e)}finally{v.f()}if(this._def.catchall instanceof Te){var g=this._def.unknownKeys;if("passthrough"===g){var k,w=i(c);try{for(w.s();!(k=w.n()).done;){var x=k.value;h.push({key:{status:"valid",value:x},value:{status:"valid",value:a.data[x]}})}}catch(e){w.e(e)}finally{w.f()}}else if("strict"===g)c.length>0&&(E(a,{code:T.unrecognized_keys,keys:c}),r.dirty());else if("strip"!==g)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{var C,O=this._def.catchall,A=i(c);try{for(A.s();!(C=A.n()).done;){var R=C.value,S=a.data[R];h.push({key:{status:"valid",value:R},value:O._parse(new z(a,S,a.path,R)),alwaysSet:R in a.data})}}catch(e){A.e(e)}finally{A.f()}}return a.common.async?Promise.resolve().then(f(p().m(function e(){var t,n,r,a,s,o,u;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:t=[],n=i(h),e.p=1,n.s();case 2:if((r=n.n()).done){e.n=6;break}return a=r.value,e.n=3,a.key;case 3:return s=e.v,e.n=4,a.value;case 4:o=e.v,t.push({key:s,value:o,alwaysSet:a.alwaysSet});case 5:e.n=2;break;case 6:e.n=8;break;case 7:e.p=7,u=e.v,n.e(u);case 8:return e.p=8,n.f(),e.f(8);case 9:return e.a(2,t)}},e,null,[[1,7,8,9]])}))).then(function(e){return Z.mergeObjectSync(r,e)}):Z.mergeObjectSync(r,h)}},{key:"shape",get:function(){return this._def.shape()}},{key:"strict",value:function(t){var n=this;return I.errToObj,new e(s(s({},this._def),{},{unknownKeys:"strict"},void 0!==t?{errorMap:function(e,r){var a,i,s,o,u=null!==(a=null===(i=(s=n._def).errorMap)||void 0===i?void 0:i.call(s,e,r).message)&&void 0!==a?a:r.defaultError;return"unrecognized_keys"===e.code?{message:null!==(o=I.errToObj(t).message)&&void 0!==o?o:u}:{message:u}}}:{}))}},{key:"strip",value:function(){return new e(s(s({},this._def),{},{unknownKeys:"strip"}))}},{key:"passthrough",value:function(){return new e(s(s({},this._def),{},{unknownKeys:"passthrough"}))}},{key:"extend",value:function(t){var n=this;return new e(s(s({},this._def),{},{shape:function(){return s(s({},n._def.shape()),t)}}))}},{key:"merge",value:function(t){var n=this;return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:function(){return s(s({},n._def.shape()),t._def.shape())},typeName:Ye.ZodObject})}},{key:"setKey",value:function(e,t){return this.augment(v({},e,t))}},{key:"catchall",value:function(t){return new e(s(s({},this._def),{},{catchall:t}))}},{key:"pick",value:function(t){var n,r={},a=i(k.objectKeys(t));try{for(a.s();!(n=a.n()).done;){var o=n.value;t[o]&&this.shape[o]&&(r[o]=this.shape[o])}}catch(e){a.e(e)}finally{a.f()}return new e(s(s({},this._def),{},{shape:function(){return r}}))}},{key:"omit",value:function(t){var n,r={},a=i(k.objectKeys(this.shape));try{for(a.s();!(n=a.n()).done;){var o=n.value;t[o]||(r[o]=this.shape[o])}}catch(e){a.e(e)}finally{a.f()}return new e(s(s({},this._def),{},{shape:function(){return r}}))}},{key:"deepPartial",value:function(){return Ae(this)}},{key:"partial",value:function(t){var n,r={},a=i(k.objectKeys(this.shape));try{for(a.s();!(n=a.n()).done;){var o=n.value,u=this.shape[o];t&&!t[o]?r[o]=u:r[o]=u.optional()}}catch(e){a.e(e)}finally{a.f()}return new e(s(s({},this._def),{},{shape:function(){return r}}))}},{key:"required",value:function(t){var n,r={},a=i(k.objectKeys(this.shape));try{for(a.s();!(n=a.n()).done;){var o=n.value;if(t&&!t[o])r[o]=this.shape[o];else{for(var u=this.shape[o];u instanceof Ke;)u=u._def.innerType;r[o]=u}}}catch(e){a.e(e)}finally{a.f()}return new e(s(s({},this._def),{},{shape:function(){return r}}))}},{key:"keyof",value:function(){return De(k.objectKeys(this.shape))}}])}();Re.create=function(e,t){return new Re(s({shape:function(){return e},unknownKeys:"strip",catchall:Te.create(),typeName:Ye.ZodObject},V(t)))},Re.strictCreate=function(e,t){return new Re(s({shape:function(){return e},unknownKeys:"strict",catchall:Te.create(),typeName:Ye.ZodObject},V(t)))},Re.lazycreate=function(e,t){return new Re(s({shape:e,unknownKeys:"strip",catchall:Te.create(),typeName:Ye.ZodObject},V(t)))};var Se=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx,n=this._def.options;if(t.common.async)return Promise.all(n.map(function(){var e=f(p().m(function e(n){var r,a,i;return p().w(function(e){for(;;)switch(e.n){case 0:return r=s(s({},t),{},{common:s(s({},t.common),{},{issues:[]}),parent:null}),e.n=1,n._parseAsync({data:t.data,path:t.path,parent:r});case 1:return a=e.v,i=r,e.a(2,{result:a,ctx:i})}},e)}));return function(t){return e.apply(this,arguments)}}())).then(function(e){var n,r=i(e);try{for(r.s();!(n=r.n()).done;){var a=n.value;if("valid"===a.result.status)return a.result}}catch(e){r.e(e)}finally{r.f()}var s,o=i(e);try{for(o.s();!(s=o.n()).done;){var u,c=s.value;if("dirty"===c.result.status)return(u=t.common.issues).push.apply(u,h(c.ctx.common.issues)),c.result}}catch(e){o.e(e)}finally{o.f()}var d=e.map(function(e){return new C(e.ctx.common.issues)});return E(t,{code:T.invalid_union,unionErrors:d}),j});var r,a,o=void 0,u=[],c=i(n);try{for(c.s();!(r=c.n()).done;){var d=r.value,l=s(s({},t),{},{common:s(s({},t.common),{},{issues:[]}),parent:null}),v=d._parseSync({data:t.data,path:t.path,parent:l});if("valid"===v.status)return v;"dirty"!==v.status||o||(o={result:v,ctx:l}),l.common.issues.length&&u.push(l.common.issues)}}catch(e){c.e(e)}finally{c.f()}if(o)return(a=t.common.issues).push.apply(a,h(o.ctx.common.issues)),o.result;var m=u.map(function(e){return new C(e)});return E(t,{code:T.invalid_union,unionErrors:m}),j}},{key:"options",get:function(){return this._def.options}}])}();Se.create=function(e,t){return new Se(s({options:e,typeName:Ye.ZodUnion},V(t)))};var Ee=function(e){return e instanceof Fe?Ee(e.schema):e instanceof We?Ee(e.innerType()):e instanceof ze?[e.value]:e instanceof Ve?e.options:e instanceof qe?k.objectValues(e.enum):e instanceof $e?Ee(e._def.innerType):e instanceof ke?[void 0]:e instanceof we?[null]:e instanceof Ke?[void 0].concat(h(Ee(e.unwrap()))):e instanceof Be?[null].concat(h(Ee(e.unwrap()))):e instanceof Xe||e instanceof et?Ee(e.unwrap()):e instanceof Je?Ee(e._def.innerType):[]},Ie=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx;if(t.parsedType!==b.object)return E(t,{code:T.invalid_type,expected:b.object,received:t.parsedType}),j;var n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(E(t,{code:T.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),j)}},{key:"discriminator",get:function(){return this._def.discriminator}},{key:"options",get:function(){return this._def.options}},{key:"optionsMap",get:function(){return this._def.optionsMap}}],[{key:"create",value:function(t,n,r){var a,o=new Map,u=i(n);try{for(u.s();!(a=u.n()).done;){var c=a.value,d=Ee(c.shape[t]);if(!d.length)throw new Error("A discriminator value for key `".concat(t,"` could not be extracted from all schema options"));var l,h=i(d);try{for(h.s();!(l=h.n()).done;){var f=l.value;if(o.has(f))throw new Error("Discriminator property ".concat(String(t)," has duplicate value ").concat(String(f)));o.set(f,c)}}catch(e){h.e(e)}finally{h.f()}}}catch(e){u.e(e)}finally{u.f()}return new e(s({typeName:Ye.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:o},V(r)))}}])}();function Ze(e,t){var n=x(e),r=x(t);if(e===t)return{valid:!0,data:e};if(n===b.object&&r===b.object){var a,o=k.objectKeys(t),u=k.objectKeys(e).filter(function(e){return-1!==o.indexOf(e)}),c=s(s({},e),t),d=i(u);try{for(d.s();!(a=d.n()).done;){var l=a.value,h=Ze(e[l],t[l]);if(!h.valid)return{valid:!1};c[l]=h.data}}catch(e){d.e(e)}finally{d.f()}return{valid:!0,data:c}}if(n===b.array&&r===b.array){if(e.length!==t.length)return{valid:!1};for(var f=[],p=0;p<e.length;p++){var v=Ze(e[p],t[p]);if(!v.valid)return{valid:!1};f.push(v.data)}return{valid:!0,data:f}}return n===b.date&&r===b.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}var je=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this._processInputParams(e),n=t.status,r=t.ctx,a=function(e,t){if(U(e)||U(t))return j;var a=Ze(e.value,t.value);return a.valid?((M(e)||M(t))&&n.dirty(),{status:n.value,value:a.data}):(E(r,{code:T.invalid_intersection_types}),j)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(function(e){var t=m(e,2),n=t[0],r=t[1];return a(n,r)}):a(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}])}();je.create=function(e,t,n){return new je(s({left:e,right:t,typeName:Ye.ZodIntersection},V(n)))};var Pe=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this,n=this._processInputParams(e),r=n.status,a=n.ctx;if(a.parsedType!==b.array)return E(a,{code:T.invalid_type,expected:b.array,received:a.parsedType}),j;if(a.data.length<this._def.items.length)return E(a,{code:T.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),j;!this._def.rest&&a.data.length>this._def.items.length&&(E(a,{code:T.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());var i=h(a.data).map(function(e,n){var r=t._def.items[n]||t._def.rest;return r?r._parse(new z(a,e,a.path,n)):null}).filter(function(e){return!!e});return a.common.async?Promise.all(i).then(function(e){return Z.mergeArray(r,e)}):Z.mergeArray(r,i)}},{key:"items",get:function(){return this._def.items}},{key:"rest",value:function(t){return new e(s(s({},this._def),{},{rest:t}))}}])}();Pe.create=function(e,t){if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pe(s({items:e,typeName:Ye.ZodTuple,rest:null},V(t)))};var Ne=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"keySchema",get:function(){return this._def.keyType}},{key:"valueSchema",get:function(){return this._def.valueType}},{key:"_parse",value:function(e){var t=this._processInputParams(e),n=t.status,r=t.ctx;if(r.parsedType!==b.object)return E(r,{code:T.invalid_type,expected:b.object,received:r.parsedType}),j;var a=[],i=this._def.keyType,s=this._def.valueType;for(var o in r.data)a.push({key:i._parse(new z(r,o,r.path,o)),value:s._parse(new z(r,r.data[o],r.path,o)),alwaysSet:o in r.data});return r.common.async?Z.mergeObjectAsync(n,a):Z.mergeObjectSync(n,a)}},{key:"element",get:function(){return this._def.valueType}}],[{key:"create",value:function(t,n,r){return new e(n instanceof H?s({keyType:t,valueType:n,typeName:Ye.ZodRecord},V(r)):s({keyType:fe.create(),valueType:t,typeName:Ye.ZodRecord},V(n)))}}])}(),Ue=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"keySchema",get:function(){return this._def.keyType}},{key:"valueSchema",get:function(){return this._def.valueType}},{key:"_parse",value:function(e){var t=this._processInputParams(e),n=t.status,r=t.ctx;if(r.parsedType!==b.map)return E(r,{code:T.invalid_type,expected:b.map,received:r.parsedType}),j;var a=this._def.keyType,s=this._def.valueType,o=h(r.data.entries()).map(function(e,t){var n=m(e,2),i=n[0],o=n[1];return{key:a._parse(new z(r,i,r.path,[t,"key"])),value:s._parse(new z(r,o,r.path,[t,"value"]))}});if(r.common.async){var u=new Map;return Promise.resolve().then(f(p().m(function e(){var t,r,a,s,c,d;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:t=i(o),e.p=1,t.s();case 2:if((r=t.n()).done){e.n=7;break}return a=r.value,e.n=3,a.key;case 3:return s=e.v,e.n=4,a.value;case 4:if(c=e.v,"aborted"!==s.status&&"aborted"!==c.status){e.n=5;break}return e.a(2,j);case 5:"dirty"!==s.status&&"dirty"!==c.status||n.dirty(),u.set(s.value,c.value);case 6:e.n=2;break;case 7:e.n=9;break;case 8:e.p=8,d=e.v,t.e(d);case 9:return e.p=9,t.f(),e.f(9);case 10:return e.a(2,{status:n.value,value:u})}},e,null,[[1,8,9,10]])})))}var c,d=new Map,l=i(o);try{for(l.s();!(c=l.n()).done;){var v=c.value,y=v.key,_=v.value;if("aborted"===y.status||"aborted"===_.status)return j;"dirty"!==y.status&&"dirty"!==_.status||n.dirty(),d.set(y.value,_.value)}}catch(e){l.e(e)}finally{l.f()}return{status:n.value,value:d}}}])}();Ue.create=function(e,t,n){return new Ue(s({valueType:t,keyType:e,typeName:Ye.ZodMap},V(n)))};var Me=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this._processInputParams(e),n=t.status,r=t.ctx;if(r.parsedType!==b.set)return E(r,{code:T.invalid_type,expected:b.set,received:r.parsedType}),j;var a=this._def;null!==a.minSize&&r.data.size<a.minSize.value&&(E(r,{code:T.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),n.dirty()),null!==a.maxSize&&r.data.size>a.maxSize.value&&(E(r,{code:T.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),n.dirty());var s=this._def.valueType;function o(e){var t,r=new Set,a=i(e);try{for(a.s();!(t=a.n()).done;){var s=t.value;if("aborted"===s.status)return j;"dirty"===s.status&&n.dirty(),r.add(s.value)}}catch(e){a.e(e)}finally{a.f()}return{status:n.value,value:r}}var u=h(r.data.values()).map(function(e,t){return s._parse(new z(r,e,r.path,t))});return r.common.async?Promise.all(u).then(function(e){return o(e)}):o(u)}},{key:"min",value:function(t,n){return new e(s(s({},this._def),{},{minSize:{value:t,message:I.toString(n)}}))}},{key:"max",value:function(t,n){return new e(s(s({},this._def),{},{maxSize:{value:t,message:I.toString(n)}}))}},{key:"size",value:function(e,t){return this.min(e,t).max(e,t)}},{key:"nonempty",value:function(e){return this.min(1,e)}}])}();Me.create=function(e,t){return new Me(s({valueType:e,minSize:null,maxSize:null,typeName:Ye.ZodSet},V(t)))};var Le=function(){function e(){var t;return d(this,e),(t=l(this,e,arguments)).validate=t.implement,t}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx;if(t.parsedType!==b.function)return E(t,{code:T.invalid_type,expected:b.function,received:t.parsedType}),j;function n(e,n){return S({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,R(),O].filter(function(e){return!!e}),issueData:{code:T.invalid_arguments,argumentsError:n}})}function r(e,n){return S({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,R(),O].filter(function(e){return!!e}),issueData:{code:T.invalid_return_type,returnTypeError:n}})}var a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof He){var s=this;return N(f(p().m(function e(){var t,o,u,c,d,l,h,f=arguments;return p().w(function(e){for(;;)switch(e.n){case 0:for(t=f.length,o=new Array(t),u=0;u<t;u++)o[u]=f[u];return c=new C([]),e.n=1,s._def.args.parseAsync(o,a).catch(function(e){throw c.addIssue(n(o,e)),c});case 1:return d=e.v,e.n=2,Reflect.apply(i,this,d);case 2:return l=e.v,e.n=3,s._def.returns._def.type.parseAsync(l,a).catch(function(e){throw c.addIssue(r(l,e)),c});case 3:return h=e.v,e.a(2,h)}},e,this)})))}var o=this;return N(function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];var u=o._def.args.safeParse(t,a);if(!u.success)throw new C([n(t,u.error)]);var c=Reflect.apply(i,this,u.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new C([r(c,d.error)]);return d.data})}},{key:"parameters",value:function(){return this._def.args}},{key:"returnType",value:function(){return this._def.returns}},{key:"args",value:function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return new e(s(s({},this._def),{},{args:Pe.create(n).rest(xe.create())}))}},{key:"returns",value:function(t){return new e(s(s({},this._def),{},{returns:t}))}},{key:"implement",value:function(e){return this.parse(e)}},{key:"strictImplement",value:function(e){return this.parse(e)}}],[{key:"create",value:function(t,n,r){return new e(s({args:t||Pe.create([]).rest(xe.create()),returns:n||xe.create(),typeName:Ye.ZodFunction},V(r)))}}])}(),Fe=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"schema",get:function(){return this._def.getter()}},{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx;return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}])}();Fe.create=function(e,t){return new Fe(s({getter:e,typeName:Ye.ZodLazy},V(t)))};var ze=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){if(e.data!==this._def.value){var t=this._getOrReturnCtx(e);return E(t,{received:t.data,code:T.invalid_literal,expected:this._def.value}),j}return{status:"valid",value:e.data}}},{key:"value",get:function(){return this._def.value}}])}();function De(e,t){return new Ve(s({values:e,typeName:Ye.ZodEnum},V(t)))}ze.create=function(e,t){return new ze(s({value:e,typeName:Ye.ZodLiteral},V(t)))};var Ve=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){if("string"!=typeof e.data){var t=this._getOrReturnCtx(e),n=this._def.values;return E(t,{expected:k.joinValues(n),received:t.parsedType,code:T.invalid_type}),j}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){var r=this._getOrReturnCtx(e),a=this._def.values;return E(r,{received:r.data,code:T.invalid_enum_value,options:a}),j}return N(e.data)}},{key:"options",get:function(){return this._def.values}},{key:"enum",get:function(){var e,t={},n=i(this._def.values);try{for(n.s();!(e=n.n()).done;){var r=e.value;t[r]=r}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"Values",get:function(){var e,t={},n=i(this._def.values);try{for(n.s();!(e=n.n()).done;){var r=e.value;t[r]=r}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"Enum",get:function(){var e,t={},n=i(this._def.values);try{for(n.s();!(e=n.n()).done;){var r=e.value;t[r]=r}}catch(e){n.e(e)}finally{n.f()}return t}},{key:"extract",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._def;return e.create(t,s(s({},this._def),n))}},{key:"exclude",value:function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._def;return e.create(this.options.filter(function(e){return!t.includes(e)}),s(s({},this._def),n))}}])}();Ve.create=De;var qe=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==b.string&&n.parsedType!==b.number){var r=k.objectValues(t);return E(n,{expected:k.joinValues(r),received:n.parsedType,code:T.invalid_type}),j}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){var a=k.objectValues(t);return E(n,{received:n.data,code:T.invalid_enum_value,options:a}),j}return N(e.data)}},{key:"enum",get:function(){return this._def.values}}])}();qe.create=function(e,t){return new qe(s({values:e,typeName:Ye.ZodNativeEnum},V(t)))};var He=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"unwrap",value:function(){return this._def.type}},{key:"_parse",value:function(e){var t=this,n=this._processInputParams(e).ctx;if(n.parsedType!==b.promise&&!1===n.common.async)return E(n,{code:T.invalid_type,expected:b.promise,received:n.parsedType}),j;var r=n.parsedType===b.promise?n.data:Promise.resolve(n.data);return N(r.then(function(e){return t._def.type.parseAsync(e,{path:n.path,errorMap:n.common.contextualErrorMap})}))}}])}();He.create=function(e,t){return new He(s({type:e,typeName:Ye.ZodPromise},V(t)))};var We=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"innerType",value:function(){return this._def.schema}},{key:"sourceType",value:function(){return this._def.schema._def.typeName===Ye.ZodEffects?this._def.schema.sourceType():this._def.schema}},{key:"_parse",value:function(e){var t=this,n=this._processInputParams(e),r=n.status,a=n.ctx,i=this._def.effect||null,s={addIssue:function(e){E(a,e),e.fatal?r.abort():r.dirty()},get path(){return a.path}};if(s.addIssue=s.addIssue.bind(s),"preprocess"===i.type){var o=i.transform(a.data,s);if(a.common.async)return Promise.resolve(o).then(function(){var e=f(p().m(function e(n){var i;return p().w(function(e){for(;;)switch(e.n){case 0:if("aborted"!==r.value){e.n=1;break}return e.a(2,j);case 1:return e.n=2,t._def.schema._parseAsync({data:n,path:a.path,parent:a});case 2:if("aborted"!==(i=e.v).status){e.n=3;break}return e.a(2,j);case 3:if("dirty"!==i.status){e.n=4;break}return e.a(2,P(i.value));case 4:if("dirty"!==r.value){e.n=5;break}return e.a(2,P(i.value));case 5:return e.a(2,i)}},e)}));return function(t){return e.apply(this,arguments)}}());if("aborted"===r.value)return j;var u=this._def.schema._parseSync({data:o,path:a.path,parent:a});return"aborted"===u.status?j:"dirty"===u.status||"dirty"===r.value?P(u.value):u}if("refinement"===i.type){var c=function(e){var t=i.refinement(e,s);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){var d=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===d.status?j:("dirty"===d.status&&r.dirty(),c(d.value),{status:r.value,value:d.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(function(e){return"aborted"===e.status?j:("dirty"===e.status&&r.dirty(),c(e.value).then(function(){return{status:r.value,value:e.value}}))})}if("transform"===i.type){if(!1===a.common.async){var l=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!L(l))return j;var h=i.transform(l.value,s);if(h instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:h}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then(function(e){return L(e)?Promise.resolve(i.transform(e.value,s)).then(function(e){return{status:r.value,value:e}}):j})}k.assertNever(i)}}])}();We.create=function(e,t,n){return new We(s({schema:e,typeName:Ye.ZodEffects,effect:t},V(n)))},We.createWithPreprocess=function(e,t,n){return new We(s({schema:t,effect:{type:"preprocess",transform:e},typeName:Ye.ZodEffects},V(n)))};var Ke=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){return this._getType(e)===b.undefined?N(void 0):this._def.innerType._parse(e)}},{key:"unwrap",value:function(){return this._def.innerType}}])}();Ke.create=function(e,t){return new Ke(s({innerType:e,typeName:Ye.ZodOptional},V(t)))};var Be=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){return this._getType(e)===b.null?N(null):this._def.innerType._parse(e)}},{key:"unwrap",value:function(){return this._def.innerType}}])}();Be.create=function(e,t){return new Be(s({innerType:e,typeName:Ye.ZodNullable},V(t)))};var $e=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx,n=t.data;return t.parsedType===b.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}},{key:"removeDefault",value:function(){return this._def.innerType}}])}();$e.create=function(e,t){return new $e(s({innerType:e,typeName:Ye.ZodDefault,defaultValue:"function"==typeof t.default?t.default:function(){return t.default}},V(t)))};var Je=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this,n=this._processInputParams(e).ctx,r=s(s({},n),{},{common:s(s({},n.common),{},{issues:[]})}),a=this._def.innerType._parse({data:r.data,path:r.path,parent:s({},r)});return F(a)?a.then(function(e){return{status:"valid",value:"valid"===e.status?e.value:t._def.catchValue({get error(){return new C(r.common.issues)},input:r.data})}}):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new C(r.common.issues)},input:r.data})}}},{key:"removeCatch",value:function(){return this._def.innerType}}])}();Je.create=function(e,t){return new Je(s({innerType:e,typeName:Ye.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:function(){return t.catch}},V(t)))};var Ge=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){if(this._getType(e)!==b.nan){var t=this._getOrReturnCtx(e);return E(t,{code:T.invalid_type,expected:b.nan,received:t.parsedType}),j}return{status:"valid",value:e.data}}}])}();Ge.create=function(e){return new Ge(s({typeName:Ye.ZodNaN},V(e)))};var Ye,Xe=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx,n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}},{key:"unwrap",value:function(){return this._def.type}}])}(),Qe=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this,n=this._processInputParams(e),r=n.status,a=n.ctx;if(a.common.async){var i=function(){var e=f(p().m(function e(){var n;return p().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,t._def.in._parseAsync({data:a.data,path:a.path,parent:a});case 1:if("aborted"!==(n=e.v).status){e.n=2;break}return e.a(2,j);case 2:if("dirty"!==n.status){e.n=3;break}return r.dirty(),e.a(2,P(n.value));case 3:return e.a(2,t._def.out._parseAsync({data:n.value,path:a.path,parent:a}));case 4:return e.a(2)}},e)}));return function(){return e.apply(this,arguments)}}();return i()}var s=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===s.status?j:"dirty"===s.status?(r.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:a.path,parent:a})}}],[{key:"create",value:function(t,n){return new e({in:t,out:n,typeName:Ye.ZodPipeline})}}])}(),et=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,H),u(e,[{key:"_parse",value:function(e){var t=this._def.innerType._parse(e),n=function(e){return L(e)&&(e.value=Object.freeze(e.value)),e};return F(t)?t.then(function(e){return n(e)}):n(t)}},{key:"unwrap",value:function(){return this._def.innerType}}])}();et.create=function(e,t){return new et(s({innerType:e,typeName:Ye.ZodReadonly},V(t)))},Re.lazycreate,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"}(Ye||(Ye={}));var tt=fe.create,nt=ve.create;Ge.create,me.create;var rt=ye.create;_e.create,ge.create,ke.create,we.create;var at=be.create,it=xe.create;Te.create,Ce.create;var st=Oe.create,ot=Re.create;Re.strictCreate;var ut=Se.create,ct=Ie.create;je.create,Pe.create;var dt=Ne.create;Ue.create,Me.create,Le.create,Fe.create;var lt=ze.create,ht=Ve.create;qe.create,He.create,We.create;var ft=Ke.create;Be.create,We.createWithPreprocess,Qe.create;var pt,vt=j,mt="2025-06-18",yt="2.0",_t=ut([tt(),nt().int()]),gt=tt(),kt=ot({progressToken:ft(_t)}).passthrough(),wt=ot({_meta:ft(kt)}).passthrough(),bt=ot({method:tt(),params:ft(wt)}),xt=ot({_meta:ft(ot({}).passthrough())}).passthrough(),Tt=ot({method:tt(),params:ft(xt)}),Ct=ot({_meta:ft(ot({}).passthrough())}).passthrough(),Ot=ut([tt(),nt().int()]),At=ot({jsonrpc:lt(yt),id:Ot}).merge(bt).strict(),Rt=function(e){return At.safeParse(e).success},St=ot({jsonrpc:lt(yt)}).merge(Tt).strict(),Et=ot({jsonrpc:lt(yt),id:Ot,result:Ct}).strict(),It=function(e){return Et.safeParse(e).success};!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"}(pt||(pt={}));var Zt=ot({jsonrpc:lt(yt),id:Ot,error:ot({code:nt().int(),message:tt(),data:ft(it())})}).strict(),jt=ut([At,St,Et,Zt]),Pt=Ct.strict(),Nt=Tt.extend({method:lt("notifications/cancelled"),params:xt.extend({requestId:Ot,reason:tt().optional()})}),Ut=ot({src:tt(),mimeType:ft(tt()),sizes:ft(st(tt()))}).passthrough(),Mt=ot({icons:st(Ut).optional()}).passthrough(),Lt=ot({name:tt(),title:ft(tt())}).passthrough(),Ft=Lt.extend({version:tt(),websiteUrl:ft(tt())}).merge(Mt),zt=ot({experimental:ft(ot({}).passthrough()),sampling:ft(ot({}).passthrough()),elicitation:ft(ot({}).passthrough()),roots:ft(ot({listChanged:ft(rt())}).passthrough())}).passthrough(),Dt=bt.extend({method:lt("initialize"),params:wt.extend({protocolVersion:tt(),capabilities:zt,clientInfo:Ft})}),Vt=ot({experimental:ft(ot({}).passthrough()),logging:ft(ot({}).passthrough()),completions:ft(ot({}).passthrough()),prompts:ft(ot({listChanged:ft(rt())}).passthrough()),resources:ft(ot({subscribe:ft(rt()),listChanged:ft(rt())}).passthrough()),tools:ft(ot({listChanged:ft(rt())}).passthrough())}).passthrough(),qt=Ct.extend({protocolVersion:tt(),capabilities:Vt,serverInfo:Ft,instructions:ft(tt())}),Ht=Tt.extend({method:lt("notifications/initialized")}),Wt=function(e){return Ht.safeParse(e).success},Kt=bt.extend({method:lt("ping")}),Bt=ot({progress:nt(),total:ft(nt()),message:ft(tt())}).passthrough(),$t=Tt.extend({method:lt("notifications/progress"),params:xt.merge(Bt).extend({progressToken:_t})}),Jt=bt.extend({params:wt.extend({cursor:ft(gt)}).optional()}),Gt=Ct.extend({nextCursor:ft(gt)}),Yt=ot({uri:tt(),mimeType:ft(tt()),_meta:ft(ot({}).passthrough())}).passthrough(),Xt=Yt.extend({text:tt()}),Qt=tt().refine(function(e){try{return atob(e),!0}catch(e){return!1}},{message:"Invalid Base64 string"}),en=Yt.extend({blob:Qt}),tn=Lt.extend({uri:tt(),description:ft(tt()),mimeType:ft(tt()),_meta:ft(ot({}).passthrough())}).merge(Mt),nn=Lt.extend({uriTemplate:tt(),description:ft(tt()),mimeType:ft(tt()),_meta:ft(ot({}).passthrough())}).merge(Mt),rn=Jt.extend({method:lt("resources/list")}),an=Gt.extend({resources:st(tn)}),sn=Jt.extend({method:lt("resources/templates/list")}),on=Gt.extend({resourceTemplates:st(nn)}),un=bt.extend({method:lt("resources/read"),params:wt.extend({uri:tt()})}),cn=Ct.extend({contents:st(ut([Xt,en]))}),dn=Tt.extend({method:lt("notifications/resources/list_changed")}),ln=bt.extend({method:lt("resources/subscribe"),params:wt.extend({uri:tt()})}),hn=bt.extend({method:lt("resources/unsubscribe"),params:wt.extend({uri:tt()})}),fn=Tt.extend({method:lt("notifications/resources/updated"),params:xt.extend({uri:tt()})}),pn=ot({name:tt(),description:ft(tt()),required:ft(rt())}).passthrough(),vn=Lt.extend({description:ft(tt()),arguments:ft(st(pn)),_meta:ft(ot({}).passthrough())}).merge(Mt),mn=Jt.extend({method:lt("prompts/list")}),yn=Gt.extend({prompts:st(vn)}),_n=bt.extend({method:lt("prompts/get"),params:wt.extend({name:tt(),arguments:ft(dt(tt()))})}),gn=ot({type:lt("text"),text:tt(),_meta:ft(ot({}).passthrough())}).passthrough(),kn=ot({type:lt("image"),data:Qt,mimeType:tt(),_meta:ft(ot({}).passthrough())}).passthrough(),wn=ot({type:lt("audio"),data:Qt,mimeType:tt(),_meta:ft(ot({}).passthrough())}).passthrough(),bn=ot({type:lt("resource"),resource:ut([Xt,en]),_meta:ft(ot({}).passthrough())}).passthrough(),xn=ut([gn,kn,wn,tn.extend({type:lt("resource_link")}),bn]),Tn=ot({role:ht(["user","assistant"]),content:xn}).passthrough(),Cn=Ct.extend({description:ft(tt()),messages:st(Tn)}),On=Tt.extend({method:lt("notifications/prompts/list_changed")}),An=ot({title:ft(tt()),readOnlyHint:ft(rt()),destructiveHint:ft(rt()),idempotentHint:ft(rt()),openWorldHint:ft(rt())}).passthrough(),Rn=Lt.extend({description:ft(tt()),inputSchema:ot({type:lt("object"),properties:ft(ot({}).passthrough()),required:ft(st(tt()))}).passthrough(),outputSchema:ft(ot({type:lt("object"),properties:ft(ot({}).passthrough()),required:ft(st(tt()))}).passthrough()),annotations:ft(An),_meta:ft(ot({}).passthrough())}).merge(Mt),Sn=Jt.extend({method:lt("tools/list")}),En=Gt.extend({tools:st(Rn)}),In=Ct.extend({content:st(xn).default([]),structuredContent:ot({}).passthrough().optional(),isError:ft(rt())});In.or(Ct.extend({toolResult:it()}));var Zn=bt.extend({method:lt("tools/call"),params:wt.extend({name:tt(),arguments:ft(dt(it()))})}),jn=Tt.extend({method:lt("notifications/tools/list_changed")}),Pn=ht(["debug","info","notice","warning","error","critical","alert","emergency"]),Nn=bt.extend({method:lt("logging/setLevel"),params:wt.extend({level:Pn})}),Un=Tt.extend({method:lt("notifications/message"),params:xt.extend({level:Pn,logger:ft(tt()),data:it()})}),Mn=ot({name:tt().optional()}).passthrough(),Ln=ot({hints:ft(st(Mn)),costPriority:ft(nt().min(0).max(1)),speedPriority:ft(nt().min(0).max(1)),intelligencePriority:ft(nt().min(0).max(1))}).passthrough(),Fn=ot({role:ht(["user","assistant"]),content:ut([gn,kn,wn])}).passthrough(),zn=bt.extend({method:lt("sampling/createMessage"),params:wt.extend({messages:st(Fn),systemPrompt:ft(tt()),includeContext:ft(ht(["none","thisServer","allServers"])),temperature:ft(nt()),maxTokens:nt().int(),stopSequences:ft(st(tt())),metadata:ft(ot({}).passthrough()),modelPreferences:ft(Ln)})}),Dn=Ct.extend({model:tt(),stopReason:ft(ht(["endTurn","stopSequence","maxTokens"]).or(tt())),role:ht(["user","assistant"]),content:ct("type",[gn,kn,wn])}),Vn=ut([ot({type:lt("boolean"),title:ft(tt()),description:ft(tt()),default:ft(rt())}).passthrough(),ot({type:lt("string"),title:ft(tt()),description:ft(tt()),minLength:ft(nt()),maxLength:ft(nt()),format:ft(ht(["email","uri","date","date-time"]))}).passthrough(),ot({type:ht(["number","integer"]),title:ft(tt()),description:ft(tt()),minimum:ft(nt()),maximum:ft(nt())}).passthrough(),ot({type:lt("string"),title:ft(tt()),description:ft(tt()),enum:st(tt()),enumNames:ft(st(tt()))}).passthrough()]),qn=bt.extend({method:lt("elicitation/create"),params:wt.extend({message:tt(),requestedSchema:ot({type:lt("object"),properties:dt(tt(),Vn),required:ft(st(tt()))}).passthrough()})}),Hn=Ct.extend({action:ht(["accept","decline","cancel"]),content:ft(dt(tt(),it()))}),Wn=ot({type:lt("ref/resource"),uri:tt()}).passthrough(),Kn=ot({type:lt("ref/prompt"),name:tt()}).passthrough(),Bn=bt.extend({method:lt("completion/complete"),params:wt.extend({ref:ut([Kn,Wn]),argument:ot({name:tt(),value:tt()}).passthrough(),context:ft(ot({arguments:ft(dt(tt(),tt()))}))})}),$n=Ct.extend({completion:ot({values:st(tt()).max(100),total:ft(nt().int()),hasMore:ft(rt())}).passthrough()}),Jn=ot({uri:tt().startsWith("file://"),name:ft(tt()),_meta:ft(ot({}).passthrough())}).passthrough(),Gn=bt.extend({method:lt("roots/list")}),Yn=Ct.extend({roots:st(Jn)}),Xn=Tt.extend({method:lt("notifications/roots/list_changed")});ut([Kt,Dt,Bn,Nn,_n,mn,rn,sn,un,ln,hn,Zn,Sn]),ut([Nt,$t,Ht,Xn]),ut([Pt,Dn,Hn,Yn]),ut([Kt,zn,qn,Gn]),ut([Nt,$t,Un,fn,dn,jn,On]),ut([Pt,qt,$n,Cn,yn,an,on,cn,In,En]);var Qn,er=tt().url().superRefine(function(e,t){if(!URL.canParse(e))return t.addIssue({code:T.custom,message:"URL must be parseable",fatal:!0}),vt}).refine(function(e){var t=new URL(e);return"javascript:"!==t.protocol&&"data:"!==t.protocol&&"vbscript:"!==t.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),tr=ot({resource:tt().url(),authorization_servers:st(er).optional(),jwks_uri:tt().url().optional(),scopes_supported:st(tt()).optional(),bearer_methods_supported:st(tt()).optional(),resource_signing_alg_values_supported:st(tt()).optional(),resource_name:tt().optional(),resource_documentation:tt().optional(),resource_policy_uri:tt().url().optional(),resource_tos_uri:tt().url().optional(),tls_client_certificate_bound_access_tokens:rt().optional(),authorization_details_types_supported:st(tt()).optional(),dpop_signing_alg_values_supported:st(tt()).optional(),dpop_bound_access_tokens_required:rt().optional()}).passthrough(),nr=ot({issuer:tt(),authorization_endpoint:er,token_endpoint:er,registration_endpoint:er.optional(),scopes_supported:st(tt()).optional(),response_types_supported:st(tt()),response_modes_supported:st(tt()).optional(),grant_types_supported:st(tt()).optional(),token_endpoint_auth_methods_supported:st(tt()).optional(),token_endpoint_auth_signing_alg_values_supported:st(tt()).optional(),service_documentation:er.optional(),revocation_endpoint:er.optional(),revocation_endpoint_auth_methods_supported:st(tt()).optional(),revocation_endpoint_auth_signing_alg_values_supported:st(tt()).optional(),introspection_endpoint:tt().optional(),introspection_endpoint_auth_methods_supported:st(tt()).optional(),introspection_endpoint_auth_signing_alg_values_supported:st(tt()).optional(),code_challenge_methods_supported:st(tt()).optional()}).passthrough(),rr=ot({issuer:tt(),authorization_endpoint:er,token_endpoint:er,userinfo_endpoint:er.optional(),jwks_uri:er,registration_endpoint:er.optional(),scopes_supported:st(tt()).optional(),response_types_supported:st(tt()),response_modes_supported:st(tt()).optional(),grant_types_supported:st(tt()).optional(),acr_values_supported:st(tt()).optional(),subject_types_supported:st(tt()),id_token_signing_alg_values_supported:st(tt()),id_token_encryption_alg_values_supported:st(tt()).optional(),id_token_encryption_enc_values_supported:st(tt()).optional(),userinfo_signing_alg_values_supported:st(tt()).optional(),userinfo_encryption_alg_values_supported:st(tt()).optional(),userinfo_encryption_enc_values_supported:st(tt()).optional(),request_object_signing_alg_values_supported:st(tt()).optional(),request_object_encryption_alg_values_supported:st(tt()).optional(),request_object_encryption_enc_values_supported:st(tt()).optional(),token_endpoint_auth_methods_supported:st(tt()).optional(),token_endpoint_auth_signing_alg_values_supported:st(tt()).optional(),display_values_supported:st(tt()).optional(),claim_types_supported:st(tt()).optional(),claims_supported:st(tt()).optional(),service_documentation:tt().optional(),claims_locales_supported:st(tt()).optional(),ui_locales_supported:st(tt()).optional(),claims_parameter_supported:rt().optional(),request_parameter_supported:rt().optional(),request_uri_parameter_supported:rt().optional(),require_request_uri_registration:rt().optional(),op_policy_uri:er.optional(),op_tos_uri:er.optional()}).passthrough().merge(nr.pick({code_challenge_methods_supported:!0})),ar=ot({access_token:tt(),id_token:tt().optional(),token_type:tt(),expires_in:nt().optional(),scope:tt().optional(),refresh_token:tt().optional()}).strip(),ir=ot({error:tt(),error_description:tt().optional(),error_uri:tt().optional()}),sr=ot({redirect_uris:st(er),token_endpoint_auth_method:tt().optional(),grant_types:st(tt()).optional(),response_types:st(tt()).optional(),client_name:tt().optional(),client_uri:er.optional(),logo_uri:er.optional(),scope:tt().optional(),contacts:st(tt()).optional(),tos_uri:er.optional(),policy_uri:tt().optional(),jwks_uri:er.optional(),jwks:at().optional(),software_id:tt().optional(),software_version:tt().optional(),software_statement:tt().optional()}).strip(),or=ot({client_id:tt(),client_secret:tt().optional(),client_id_issued_at:nt().optional(),client_secret_expires_at:nt().optional()}).strip(),ur=sr.merge(or);function cr(e){var t="string"==typeof e?new URL(e):new URL(e.href);return t.hash="",t}function dr(e){var t=e.requestedResource,n=e.configuredResource,r="string"==typeof t?new URL(t):new URL(t.href),a="string"==typeof n?new URL(n):new URL(n.href);if(r.origin!==a.origin)return!1;if(r.pathname.length<a.pathname.length)return!1;var i=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",s=a.pathname.endsWith("/")?a.pathname:a.pathname+"/";return i.startsWith(s)}ot({error:tt(),error_description:tt().optional()}).strip(),ot({token:tt(),token_type_hint:tt().optional()}).strip();var lr=function(e){function t(e,n){var r;return d(this,t),(r=l(this,t,[e])).errorUri=n,r.name=r.constructor.name,r}return o(t,e),u(t,[{key:"toResponseObject",value:function(){var e={error:this.errorCode,error_description:this.message};return this.errorUri&&(e.error_uri=this.errorUri),e}},{key:"errorCode",get:function(){return this.constructor.errorCode}}])}(c(Error)),hr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();hr.errorCode="invalid_request";var fr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();fr.errorCode="invalid_client";var pr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();pr.errorCode="invalid_grant";var vr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();vr.errorCode="unauthorized_client";var mr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();mr.errorCode="unsupported_grant_type";var yr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();yr.errorCode="invalid_scope";var _r=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();_r.errorCode="access_denied";var gr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();gr.errorCode="server_error";var kr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();kr.errorCode="temporarily_unavailable";var wr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();wr.errorCode="unsupported_response_type";var br=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();br.errorCode="unsupported_token_type";var xr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();xr.errorCode="invalid_token";var Tr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();Tr.errorCode="method_not_allowed";var Cr=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();Cr.errorCode="too_many_requests";var Or=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();Or.errorCode="invalid_client_metadata";var Ar=function(){function e(){return d(this,e),l(this,e,arguments)}return o(e,lr),u(e)}();Ar.errorCode="insufficient_scope";var Rr=(v(v(v(v(v(v(v(v(v(v(Qn={},hr.errorCode,hr),fr.errorCode,fr),pr.errorCode,pr),vr.errorCode,vr),mr.errorCode,mr),yr.errorCode,yr),_r.errorCode,_r),gr.errorCode,gr),kr.errorCode,kr),wr.errorCode,wr),v(v(v(v(v(v(Qn,br.errorCode,br),xr.errorCode,xr),Tr.errorCode,Tr),Cr.errorCode,Cr),Or.errorCode,Or),Ar.errorCode,Ar)),Sr=function(e){function t(e){return d(this,t),l(this,t,[null!=e?e:"Unauthorized"])}return o(t,e),u(t)}(c(Error)),Er="code",Ir="S256";function Zr(e,t){var n=void 0!==e.client_secret;return 0===t.length?n?"client_secret_post":"none":n&&t.includes("client_secret_basic")?"client_secret_basic":n&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":n?"client_secret_post":"none"}function jr(e,t,n,r){var a=t.client_id,i=t.client_secret;switch(e){case"client_secret_basic":return void function(e,t,n){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");var r=btoa("".concat(e,":").concat(t));n.set("Authorization","Basic ".concat(r))}(a,i,n);case"client_secret_post":return void function(e,t,n){n.set("client_id",e),t&&n.set("client_secret",t)}(a,i,r);case"none":return void function(e,t){t.set("client_id",e)}(a,r);default:throw new Error("Unsupported client authentication method: ".concat(e))}}function Pr(e){return Nr.apply(this,arguments)}function Nr(){return(Nr=f(p().m(function e(t){var n,r,a,i,s,o,u,c,d,l;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:if(n=t instanceof Response?t.status:void 0,!(t instanceof Response)){e.n=2;break}return e.n=1,t.text();case 1:d=e.v,e.n=3;break;case 2:d=t;case 3:return r=d,e.p=4,a=ir.parse(JSON.parse(r)),i=a.error,s=a.error_description,o=a.error_uri,u=Rr[i]||gr,e.a(2,new u(s||"",o));case 5:return e.p=5,l=e.v,c="".concat(n?"HTTP ".concat(n,": "):"","Invalid OAuth error response: ").concat(l,". Raw body: ").concat(r),e.a(2,new gr(c))}},e,null,[[4,5]])}))).apply(this,arguments)}function Ur(e,t){return Mr.apply(this,arguments)}function Mr(){return(Mr=f(p().m(function e(t,n){var r,a,i;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:return e.p=0,e.n=1,Lr(t,n);case 1:case 4:case 7:return e.a(2,e.v);case 2:if(e.p=2,!((i=e.v)instanceof fr||i instanceof vr)){e.n=5;break}return e.n=3,null===(r=t.invalidateCredentials)||void 0===r?void 0:r.call(t,"all");case 3:return e.n=4,Lr(t,n);case 5:if(!(i instanceof pr)){e.n=8;break}return e.n=6,null===(a=t.invalidateCredentials)||void 0===a?void 0:a.call(t,"tokens");case 6:return e.n=7,Lr(t,n);case 8:throw i;case 9:return e.a(2)}},e,null,[[0,2]])}))).apply(this,arguments)}function Lr(e,t){return Fr.apply(this,arguments)}function Fr(){return(Fr=f(p().m(function e(t,n){var r,a,i,s,o,u,c,d,l,h,f,v,m,y,_,g,k,w,b,x,T;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=n.serverUrl,a=n.authorizationCode,i=n.scope,s=n.resourceMetadataUrl,o=n.fetchFn,e.p=1,e.n=2,qr(r,{resourceMetadataUrl:s},o);case 2:(u=e.v).authorization_servers&&u.authorization_servers.length>0&&(c=u.authorization_servers[0]),e.n=4;break;case 3:e.p=3,e.v;case 4:return c||(c=r),e.n=5,zr(r,t,u);case 5:return d=e.v,e.n=6,ea(c,{fetchFn:o});case 6:return l=e.v,e.n=7,Promise.resolve(t.clientInformation());case 7:if(h=e.v){e.n=12;break}if(void 0===a){e.n=8;break}throw new Error("Existing OAuth client information is required when exchanging an authorization code");case 8:if(t.saveClientInformation){e.n=9;break}throw new Error("OAuth client information must be saveable for dynamic registration");case 9:return e.n=10,ua(c,{metadata:l,clientMetadata:t.clientMetadata,fetchFn:o});case 10:return f=e.v,e.n=11,t.saveClientInformation(f);case 11:h=f;case 12:if(void 0===a){e.n=16;break}return e.n=13,t.codeVerifier();case 13:return v=e.v,e.n=14,aa(c,{metadata:l,clientInformation:h,authorizationCode:a,codeVerifier:v,redirectUri:t.redirectUrl,resource:d,addClientAuthentication:t.addClientAuthentication,fetchFn:o});case 14:return m=e.v,e.n=15,t.saveTokens(m);case 15:return e.a(2,"AUTHORIZED");case 16:return e.n=17,t.tokens();case 17:if(!(null==(y=e.v)?void 0:y.refresh_token)){e.n=23;break}return e.p=18,e.n=19,sa(c,{metadata:l,clientInformation:h,refreshToken:y.refresh_token,resource:d,addClientAuthentication:t.addClientAuthentication,fetchFn:o});case 19:return _=e.v,e.n=20,t.saveTokens(_);case 20:return e.a(2,"AUTHORIZED");case 21:if(e.p=21,(x=e.v)instanceof lr&&!(x instanceof gr)){e.n=22;break}e.n=23;break;case 22:throw x;case 23:if(!t.state){e.n=25;break}return e.n=24,t.state();case 24:T=e.v,e.n=26;break;case 25:T=void 0;case 26:return g=T,e.n=27,na(c,{metadata:l,clientInformation:h,state:g,redirectUrl:t.redirectUrl,scope:i||t.clientMetadata.scope,resource:d});case 27:return k=e.v,w=k.authorizationUrl,b=k.codeVerifier,e.n=28,t.saveCodeVerifier(b);case 28:return e.n=29,t.redirectToAuthorization(w);case 29:return e.a(2,"REDIRECT")}},e,null,[[18,21],[1,3]])}))).apply(this,arguments)}function zr(e,t,n){return Dr.apply(this,arguments)}function Dr(){return(Dr=f(p().m(function e(t,n,r){var a;return p().w(function(e){for(;;)switch(e.n){case 0:if(a=cr(t),!n.validateResourceURL){e.n=2;break}return e.n=1,n.validateResourceURL(a,null==r?void 0:r.resource);case 1:return e.a(2,e.v);case 2:if(r){e.n=3;break}return e.a(2,void 0);case 3:if(dr({requestedResource:a,configuredResource:r.resource})){e.n=4;break}throw new Error("Protected resource ".concat(r.resource," does not match expected ").concat(a," (or origin)"));case 4:return e.a(2,new URL(r.resource))}},e)}))).apply(this,arguments)}function Vr(e){var t=e.headers.get("WWW-Authenticate");if(t){var n=t.split(" "),r=m(n,2),a=r[0],i=r[1];if("bearer"===a.toLowerCase()&&i){var s=/resource_metadata="([^"]*)"/.exec(t);if(s)try{return new URL(s[1])}catch(e){return}}}}function qr(e,t){return Hr.apply(this,arguments)}function Hr(){return Hr=f(p().m(function e(t,n){var r,a,i,s=arguments;return p().w(function(e){for(;;)switch(e.n){case 0:return r=s.length>2&&void 0!==s[2]?s[2]:fetch,e.n=1,Yr(t,"oauth-protected-resource",r,{protocolVersion:null==n?void 0:n.protocolVersion,metadataUrl:null==n?void 0:n.resourceMetadataUrl});case 1:if((a=e.v)&&404!==a.status){e.n=2;break}throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");case 2:if(a.ok){e.n=3;break}throw new Error("HTTP ".concat(a.status," trying to load well-known OAuth protected resource metadata."));case 3:return i=tr,e.n=4,a.json();case 4:return e.a(2,i.parse.call(i,e.v))}},e)})),Hr.apply(this,arguments)}function Wr(e,t){return Kr.apply(this,arguments)}function Kr(){return Kr=f(p().m(function e(t,n){var r,a,i=arguments;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:return r=i.length>2&&void 0!==i[2]?i[2]:fetch,e.p=1,e.n=2,r(t,{headers:n});case 2:return e.a(2,e.v);case 3:if(e.p=3,!((a=e.v)instanceof TypeError)){e.n=5;break}if(!n){e.n=4;break}return e.a(2,Wr(t,void 0,r));case 4:return e.a(2,void 0);case 5:throw a;case 6:return e.a(2)}},e,null,[[1,3]])})),Kr.apply(this,arguments)}function Br(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return t.endsWith("/")&&(t=t.slice(0,-1)),n.prependPathname?"".concat(t,"/.well-known/").concat(e):"/.well-known/".concat(e).concat(t)}function $r(e,t){return Jr.apply(this,arguments)}function Jr(){return Jr=f(p().m(function e(t,n){var r,a,i=arguments;return p().w(function(e){for(;;)switch(e.n){case 0:return r=i.length>2&&void 0!==i[2]?i[2]:fetch,a={"MCP-Protocol-Version":n},e.n=1,Wr(t,a,r);case 1:return e.a(2,e.v)}},e)})),Jr.apply(this,arguments)}function Gr(e,t){return!e||e.status>=400&&e.status<500&&"/"!==t}function Yr(e,t,n,r){return Xr.apply(this,arguments)}function Xr(){return(Xr=f(p().m(function e(t,n,r,a){var i,s,o,u,c,d,l,h;return p().w(function(e){for(;;)switch(e.n){case 0:return o=new URL(t),u=null!==(i=null==a?void 0:a.protocolVersion)&&void 0!==i?i:mt,(null==a?void 0:a.metadataUrl)?c=new URL(a.metadataUrl):(d=Br(n,o.pathname),(c=new URL(d,null!==(s=null==a?void 0:a.metadataServerUrl)&&void 0!==s?s:o)).search=o.search),e.n=1,$r(c,u,r);case 1:if(l=e.v,(null==a?void 0:a.metadataUrl)||!Gr(l,o.pathname)){e.n=3;break}return h=new URL("/.well-known/".concat(n),o),e.n=2,$r(h,u,r);case 2:l=e.v;case 3:return e.a(2,l)}},e)}))).apply(this,arguments)}function Qr(e){var t="string"==typeof e?new URL(e):e,n=[];if(!("/"!==t.pathname))return n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),n;var r=t.pathname;return r.endsWith("/")&&(r=r.slice(0,-1)),n.push({url:new URL("/.well-known/oauth-authorization-server".concat(r),t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),n.push({url:new URL("/.well-known/openid-configuration".concat(r),t.origin),type:"oidc"}),n.push({url:new URL("".concat(r,"/.well-known/openid-configuration"),t.origin),type:"oidc"}),n}function ea(e){return ta.apply(this,arguments)}function ta(){return ta=f(p().m(function e(t){var n,r,a,s,o,u,c,d,l,h,f,v,m,y,_,g=arguments;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:r=(n=g.length>1&&void 0!==g[1]?g[1]:{}).fetchFn,a=void 0===r?fetch:r,s=n.protocolVersion,o={"MCP-Protocol-Version":void 0===s?mt:s},u=Qr(t),c=i(u),e.p=1,c.s();case 2:if((d=c.n()).done){e.n=11;break}return l=d.value,h=l.url,f=l.type,e.n=3,Wr(h,o,a);case 3:if(v=e.v){e.n=4;break}return e.a(3,10);case 4:if(v.ok){e.n=6;break}if(!(v.status>=400&&v.status<500)){e.n=5;break}return e.a(3,10);case 5:throw new Error("HTTP ".concat(v.status," trying to load ").concat("oauth"===f?"OAuth":"OpenID provider"," metadata from ").concat(h));case 6:if("oauth"!==f){e.n=8;break}return m=nr,e.n=7,v.json();case 7:return e.a(2,m.parse.call(m,e.v));case 8:return y=rr,e.n=9,v.json();case 9:return e.a(2,y.parse.call(y,e.v));case 10:e.n=2;break;case 11:e.n=13;break;case 12:e.p=12,_=e.v,c.e(_);case 13:return e.p=13,c.f(),e.f(13);case 14:return e.a(2,void 0)}},e,null,[[1,12,13,14]])})),ta.apply(this,arguments)}function na(e,t){return ra.apply(this,arguments)}function ra(){return(ra=f(p().m(function e(t,n){var r,a,i,s,o,u,c,d,l,h;return p().w(function(e){for(;;)switch(e.n){case 0:if(r=n.metadata,a=n.clientInformation,i=n.redirectUrl,s=n.scope,o=n.state,u=n.resource,!r){e.n=3;break}if(c=new URL(r.authorization_endpoint),r.response_types_supported.includes(Er)){e.n=1;break}throw new Error("Incompatible auth server: does not support response type ".concat(Er));case 1:if(!r.code_challenge_methods_supported||r.code_challenge_methods_supported.includes(Ir)){e.n=2;break}throw new Error("Incompatible auth server: does not support code challenge method ".concat(Ir));case 2:e.n=4;break;case 3:c=new URL("/authorize",t);case 4:return e.n=5,y();case 5:return d=e.v,l=d.code_verifier,h=d.code_challenge,c.searchParams.set("response_type",Er),c.searchParams.set("client_id",a.client_id),c.searchParams.set("code_challenge",h),c.searchParams.set("code_challenge_method",Ir),c.searchParams.set("redirect_uri",String(i)),o&&c.searchParams.set("state",o),s&&c.searchParams.set("scope",s),(null==s?void 0:s.includes("offline_access"))&&c.searchParams.append("prompt","consent"),u&&c.searchParams.set("resource",u.href),e.a(2,{authorizationUrl:c,codeVerifier:l})}},e)}))).apply(this,arguments)}function aa(e,t){return ia.apply(this,arguments)}function ia(){return(ia=f(p().m(function e(t,n){var r,a,i,s,o,u,c,d,l,h,f,v,m,y,_,g;return p().w(function(e){for(;;)switch(e.n){case 0:if(r=n.metadata,a=n.clientInformation,i=n.authorizationCode,s=n.codeVerifier,o=n.redirectUri,u=n.resource,c=n.addClientAuthentication,d=n.fetchFn,h="authorization_code",f=(null==r?void 0:r.token_endpoint)?new URL(r.token_endpoint):new URL("/token",t),!(null==r?void 0:r.grant_types_supported)||r.grant_types_supported.includes(h)){e.n=1;break}throw new Error("Incompatible auth server: does not support grant type ".concat(h));case 1:return v=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),m=new URLSearchParams({grant_type:h,code:i,code_verifier:s,redirect_uri:String(o)}),c?c(v,m,t,r):(y=null!==(l=null==r?void 0:r.token_endpoint_auth_methods_supported)&&void 0!==l?l:[],jr(Zr(a,y),a,v,m)),u&&m.set("resource",u.href),e.n=2,(null!=d?d:fetch)(f,{method:"POST",headers:v,body:m});case 2:if((_=e.v).ok){e.n=4;break}return e.n=3,Pr(_);case 3:throw e.v;case 4:return g=ar,e.n=5,_.json();case 5:return e.a(2,g.parse.call(g,e.v))}},e)}))).apply(this,arguments)}function sa(e,t){return oa.apply(this,arguments)}function oa(){return(oa=f(p().m(function e(t,n){var r,a,i,o,u,c,d,l,h,f,v,m,y,_,g,k;return p().w(function(e){for(;;)switch(e.n){case 0:if(r=n.metadata,a=n.clientInformation,i=n.refreshToken,o=n.resource,u=n.addClientAuthentication,c=n.fetchFn,l="refresh_token",!r){e.n=2;break}if(h=new URL(r.token_endpoint),!r.grant_types_supported||r.grant_types_supported.includes(l)){e.n=1;break}throw new Error("Incompatible auth server: does not support grant type ".concat(l));case 1:e.n=3;break;case 2:h=new URL("/token",t);case 3:return f=new Headers({"Content-Type":"application/x-www-form-urlencoded"}),v=new URLSearchParams({grant_type:l,refresh_token:i}),u?u(f,v,t,r):(m=null!==(d=null==r?void 0:r.token_endpoint_auth_methods_supported)&&void 0!==d?d:[],jr(Zr(a,m),a,f,v)),o&&v.set("resource",o.href),e.n=4,(null!=c?c:fetch)(h,{method:"POST",headers:f,body:v});case 4:if((y=e.v).ok){e.n=6;break}return e.n=5,Pr(y);case 5:throw e.v;case 6:return _=ar,g=s,k={refresh_token:i},e.n=7,y.json();case 7:return e.a(2,_.parse.call(_,g(k,e.v)))}},e)}))).apply(this,arguments)}function ua(e,t){return ca.apply(this,arguments)}function ca(){return(ca=f(p().m(function e(t,n){var r,a,i,s,o,u;return p().w(function(e){for(;;)switch(e.n){case 0:if(r=n.metadata,a=n.clientMetadata,i=n.fetchFn,!r){e.n=2;break}if(r.registration_endpoint){e.n=1;break}throw new Error("Incompatible auth server: does not support dynamic client registration");case 1:s=new URL(r.registration_endpoint),e.n=3;break;case 2:s=new URL("/register",t);case 3:return e.n=4,(null!=i?i:fetch)(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)});case 4:if((o=e.v).ok){e.n=6;break}return e.n=5,Pr(o);case 5:throw e.v;case 6:return u=ur,e.n=7,o.json();case 7:return e.a(2,u.parse.call(u,e.v))}},e)}))).apply(this,arguments)}var da=function(e){function t(e,n){var r;return d(this,t),(r=l(this,t,[e])).name="ParseError",r.type=n.type,r.field=n.field,r.value=n.value,r.line=n.line,r}return o(t,e),u(t)}(c(Error));function la(e){}function ha(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");var t,n=e.onEvent,r=void 0===n?la:n,a=e.onError,s=void 0===a?la:a,o=e.onRetry,u=void 0===o?la:o,c=e.onComment,d="",l=!0,h="",f="";function p(e){if(""===e)return h.length>0&&r({id:t,event:f||void 0,data:h.endsWith("\n")?h.slice(0,-1):h}),t=void 0,h="",void(f="");if(e.startsWith(":"))c&&c(e.slice(e.startsWith(": ")?2:1));else{var n=e.indexOf(":");if(-1===n)v(e,"",e);else{var a=e.slice(0,n),i=" "===e[n+1]?2:1;v(a,e.slice(n+i),e)}}}function v(e,n,r){switch(e){case"event":f=n;break;case"data":h="".concat(h).concat(n,"\n");break;case"id":t=n.includes("\0")?void 0:n;break;case"retry":/^\d+$/.test(n)?u(parseInt(n,10)):s(new da('Invalid `retry` value: "'.concat(n,'"'),{type:"invalid-retry",value:n,line:r}));break;default:s(new da('Unknown field "'.concat(e.length>20?"".concat(e.slice(0,20),"…"):e,'"'),{type:"unknown-field",field:e,value:n,line:r}))}}return{feed:function(e){var t,n=l?e.replace(/^\xEF\xBB\xBF/,""):e,r=function(e){for(var t=[],n="",r=0;r<e.length;){var a=e.indexOf("\r",r),i=e.indexOf("\n",r),s=-1;if(-1!==a&&-1!==i?s=Math.min(a,i):-1!==a?s=a===e.length-1?-1:a:-1!==i&&(s=i),-1===s){n=e.slice(r);break}var o=e.slice(r,s);t.push(o),"\r"===e[(r=s+1)-1]&&"\n"===e[r]&&r++}return[t,n]}("".concat(d).concat(n)),a=m(r,2),s=a[0],o=a[1],u=i(s);try{for(u.s();!(t=u.n()).done;){p(t.value)}}catch(e){u.e(e)}finally{u.f()}d=o,l=!1},reset:function(){d&&(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).consume&&p(d),l=!0,t=void 0,h="",f="",d=""}}}var fa=function(e){function t(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=n.onError,a=n.onRetry,i=n.onComment;return d(this,t),l(this,t,[{start:function(t){e=ha({onEvent:function(e){t.enqueue(e)},onError:function(e){"terminate"===r?t.error(e):"function"==typeof r&&r(e)},onRetry:a,onComment:i})},transform:function(t){e.feed(t)}}])}return o(t,e),u(t)}(c(TransformStream)),pa={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},va=function(e){function t(e,n){var r;return d(this,t),(r=l(this,t,["Streamable HTTP error: ".concat(n)])).code=e,r}return o(t,e),u(t)}(c(Error)),ma=function(){return u(function e(t,n){var r;d(this,e),this._hasCompletedAuthFlow=!1,this._url=t,this._resourceMetadataUrl=void 0,this._requestInit=null==n?void 0:n.requestInit,this._authProvider=null==n?void 0:n.authProvider,this._fetch=null==n?void 0:n.fetch,this._sessionId=null==n?void 0:n.sessionId,this._reconnectionOptions=null!==(r=null==n?void 0:n.reconnectionOptions)&&void 0!==r?r:pa},[{key:"_authThenStart",value:(l=f(p().m(function e(){var t,n,r;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this._authProvider){e.n=1;break}throw new Sr("No auth provider");case 1:return e.p=1,e.n=2,Ur(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,fetchFn:this._fetch});case 2:n=e.v,e.n=4;break;case 3:throw e.p=3,r=e.v,null===(t=this.onerror)||void 0===t||t.call(this,r),r;case 4:if("AUTHORIZED"===n){e.n=5;break}throw new Sr;case 5:return e.n=6,this._startOrAuthSse({resumptionToken:void 0});case 6:return e.a(2,e.v)}},e,this,[[1,3]])})),function(){return l.apply(this,arguments)})},{key:"_commonHeaders",value:(c=f(p().m(function e(){var t,n,r,a;return p().w(function(e){for(;;)switch(e.n){case 0:if(n={},!this._authProvider){e.n=2;break}return e.n=1,this._authProvider.tokens();case 1:(r=e.v)&&(n.Authorization="Bearer ".concat(r.access_token));case 2:return this._sessionId&&(n["mcp-session-id"]=this._sessionId),this._protocolVersion&&(n["mcp-protocol-version"]=this._protocolVersion),a=this._normalizeHeaders(null===(t=this._requestInit)||void 0===t?void 0:t.headers),e.a(2,new Headers(s(s({},n),a)))}},e,this)})),function(){return c.apply(this,arguments)})},{key:"_startOrAuthSse",value:(o=f(p().m(function e(t){var n,r,a,i,s,o,u;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:return i=t.resumptionToken,e.p=1,e.n=2,this._commonHeaders();case 2:return(s=e.v).set("Accept","text/event-stream"),i&&s.set("last-event-id",i),e.n=3,(null!==(n=this._fetch)&&void 0!==n?n:fetch)(this._url,{method:"GET",headers:s,signal:null===(r=this._abortController)||void 0===r?void 0:r.signal});case 3:if((o=e.v).ok){e.n=7;break}if(401!==o.status||!this._authProvider){e.n=5;break}return e.n=4,this._authThenStart();case 4:return e.a(2,e.v);case 5:if(405!==o.status){e.n=6;break}return e.a(2);case 6:throw new va(o.status,"Failed to open SSE stream: ".concat(o.statusText));case 7:this._handleSseStream(o.body,t,!0),e.n=9;break;case 8:throw e.p=8,u=e.v,null===(a=this.onerror)||void 0===a||a.call(this,u),u;case 9:return e.a(2)}},e,this,[[1,8]])})),function(e){return o.apply(this,arguments)})},{key:"_getNextReconnectionDelay",value:function(e){var t=this._reconnectionOptions.initialReconnectionDelay,n=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(n,e),r)}},{key:"_normalizeHeaders",value:function(e){return e?e instanceof Headers?Object.fromEntries(e.entries()):Array.isArray(e)?Object.fromEntries(e):s({},e):{}}},{key:"_scheduleReconnection",value:function(e){var t,n=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=this._reconnectionOptions.maxRetries;if(a>0&&r>=a)null===(t=this.onerror)||void 0===t||t.call(this,new Error("Maximum reconnection attempts (".concat(a,") exceeded.")));else{var i=this._getNextReconnectionDelay(r);setTimeout(function(){n._startOrAuthSse(e).catch(function(t){var a;null===(a=n.onerror)||void 0===a||a.call(n,new Error("Failed to reconnect SSE stream: ".concat(t instanceof Error?t.message:String(t)))),n._scheduleReconnection(e,r+1)})},i)}}},{key:"_handleSseStream",value:function(e,t,n){var r=this;if(e){var a,i=t.onresumptiontoken,s=t.replayMessageId,o=function(){var t=f(p().m(function t(){var o,u,c,d,l,h,f,v,m;return p().w(function(t){for(;;)switch(t.p=t.n){case 0:t.p=0,l=e.pipeThrough(new TextDecoderStream).pipeThrough(new fa).getReader();case 1:return t.n=2,l.read();case 2:if(h=t.v,f=h.value,!h.done){t.n=3;break}return t.a(3,4);case 3:if(f.id&&(a=f.id,null==i||i(f.id)),!f.event||"message"===f.event)try{v=jt.parse(JSON.parse(f.data)),void 0!==s&&It(v)&&(v.id=s),null===(o=r.onmessage)||void 0===o||o.call(r,v)}catch(e){null===(u=r.onerror)||void 0===u||u.call(r,e)}t.n=1;break;case 4:t.n=6;break;case 5:if(t.p=5,m=t.v,null===(c=r.onerror)||void 0===c||c.call(r,new Error("SSE stream disconnected: ".concat(m))),n&&r._abortController&&!r._abortController.signal.aborted)try{r._scheduleReconnection({resumptionToken:a,onresumptiontoken:i,replayMessageId:s},0)}catch(e){null===(d=r.onerror)||void 0===d||d.call(r,new Error("Failed to reconnect: ".concat(e instanceof Error?e.message:String(e))))}case 6:return t.a(2)}},t,null,[[0,5]])}));return function(){return t.apply(this,arguments)}}();o()}}},{key:"start",value:(a=f(p().m(function e(){return p().w(function(e){for(;;)switch(e.n){case 0:if(!this._abortController){e.n=1;break}throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");case 1:this._abortController=new AbortController;case 2:return e.a(2)}},e,this)})),function(){return a.apply(this,arguments)})},{key:"finishAuth",value:(r=f(p().m(function e(t){return p().w(function(e){for(;;)switch(e.n){case 0:if(this._authProvider){e.n=1;break}throw new Sr("No auth provider");case 1:return e.n=2,Ur(this._authProvider,{serverUrl:this._url,authorizationCode:t,resourceMetadataUrl:this._resourceMetadataUrl,fetchFn:this._fetch});case 2:if("AUTHORIZED"===e.v){e.n=3;break}throw new Sr("Failed to authorize");case 3:return e.a(2)}},e,this)})),function(e){return r.apply(this,arguments)})},{key:"close",value:(n=f(p().m(function e(){var t,n;return p().w(function(e){for(;;)switch(e.n){case 0:null===(t=this._abortController)||void 0===t||t.abort(),null===(n=this.onclose)||void 0===n||n.call(this);case 1:return e.a(2)}},e,this)})),function(){return n.apply(this,arguments)})},{key:"send",value:(t=f(p().m(function e(t,n){var r,a,o,u,c,d,l,h,f,v,m,y,_,g,k,w,b,x,T,C,O,A=this;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:if(e.p=0,d=(c=n||{}).resumptionToken,l=c.onresumptiontoken,!d){e.n=1;break}return this._startOrAuthSse({resumptionToken:d,replayMessageId:Rt(t)?t.id:void 0}).catch(function(e){var t;return null===(t=A.onerror)||void 0===t?void 0:t.call(A,e)}),e.a(2);case 1:return e.n=2,this._commonHeaders();case 2:return(h=e.v).set("content-type","application/json"),h.set("accept","application/json, text/event-stream"),f=s(s({},this._requestInit),{},{method:"POST",headers:h,body:JSON.stringify(t),signal:null===(r=this._abortController)||void 0===r?void 0:r.signal}),e.n=3,(null!==(a=this._fetch)&&void 0!==a?a:fetch)(this._url,f);case 3:if(v=e.v,(m=v.headers.get("mcp-session-id"))&&(this._sessionId=m),v.ok){e.n=9;break}if(401!==v.status||!this._authProvider){e.n=7;break}if(!this._hasCompletedAuthFlow){e.n=4;break}throw new va(401,"Server returned 401 after successful authentication");case 4:return this._resourceMetadataUrl=Vr(v),e.n=5,Ur(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,fetchFn:this._fetch});case 5:if("AUTHORIZED"===e.v){e.n=6;break}throw new Sr;case 6:return this._hasCompletedAuthFlow=!0,e.a(2,this.send(t));case 7:return e.n=8,v.text().catch(function(){return null});case 8:throw y=e.v,new Error("Error POSTing to endpoint (HTTP ".concat(v.status,"): ").concat(y));case 9:if(this._hasCompletedAuthFlow=!1,202!==v.status){e.n=10;break}return Wt(t)&&this._startOrAuthSse({resumptionToken:void 0}).catch(function(e){var t;return null===(t=A.onerror)||void 0===t?void 0:t.call(A,e)}),e.a(2);case 10:if(_=Array.isArray(t)?t:[t],g=_.filter(function(e){return"method"in e&&"id"in e&&void 0!==e.id}).length>0,k=v.headers.get("content-type"),!g){e.n=14;break}if(!(null==k?void 0:k.includes("text/event-stream"))){e.n=11;break}this._handleSseStream(v.body,{onresumptiontoken:l},!1),e.n=14;break;case 11:if(!(null==k?void 0:k.includes("application/json"))){e.n=13;break}return e.n=12,v.json();case 12:w=e.v,b=Array.isArray(w)?w.map(function(e){return jt.parse(e)}):[jt.parse(w)],x=i(b);try{for(x.s();!(T=x.n()).done;)C=T.value,null===(o=this.onmessage)||void 0===o||o.call(this,C)}catch(e){x.e(e)}finally{x.f()}e.n=14;break;case 13:throw new va(-1,"Unexpected content type: ".concat(k));case 14:e.n=16;break;case 15:throw e.p=15,O=e.v,null===(u=this.onerror)||void 0===u||u.call(this,O),O;case 16:return e.a(2)}},e,this,[[0,15]])})),function(e,n){return t.apply(this,arguments)})},{key:"sessionId",get:function(){return this._sessionId}},{key:"terminateSession",value:(e=f(p().m(function e(){var t,n,r,a,i,o,u;return p().w(function(e){for(;;)switch(e.p=e.n){case 0:if(this._sessionId){e.n=1;break}return e.a(2);case 1:return e.p=1,e.n=2,this._commonHeaders();case 2:return a=e.v,i=s(s({},this._requestInit),{},{method:"DELETE",headers:a,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal}),e.n=3,(null!==(n=this._fetch)&&void 0!==n?n:fetch)(this._url,i);case 3:if((o=e.v).ok||405===o.status){e.n=4;break}throw new va(o.status,"Failed to terminate session: ".concat(o.statusText));case 4:this._sessionId=void 0,e.n=6;break;case 5:throw e.p=5,u=e.v,null===(r=this.onerror)||void 0===r||r.call(this,u),u;case 6:return e.a(2)}},e,this,[[1,5]])})),function(){return e.apply(this,arguments)})},{key:"setProtocolVersion",value:function(e){this._protocolVersion=e}},{key:"protocolVersion",get:function(){return this._protocolVersion}}]);var e,t,n,r,a,o,c,l}();let ya,_a,ga;async function ka(e,a,i,s,o){try{if(!ya){const t=new ma(new URL(e||"http://localhost:3000/mcp"));ya=await r({transport:t})}if(!_a)switch(a){case"openai":const e=g({apiKey:s});_a=e(i);break;case"anthropic":const t=_({apiKey:s});_a=t(i);break;default:throw new Error("Invalid AI provider")}ga||(ga=await ya.tools());return(await t({model:_a,tools:ga,stopWhen:n(5),messages:[{role:"user",content:[{type:"text",text:o}]}]})).textStream}catch(e){throw console.error(e),e}}class wa{constructor(e){this.config=e,this.corsHeaders=e.corsHeaders||{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"Content-Type","Access-Control-Allow-Methods":"POST, OPTIONS"}}static defaultConfig(){return{mcpUrl:e.MCP_URL||"",aiProvider:e.AI_PROVIDER||"",aiModel:e.AI_MODEL||"",aiToken:e.AI_TOKEN||""}}static New(e){const t=new wa(e);return e=>t.handle(e)}async handle(t){if("OPTIONS"===t.method)return new Response("",{status:200,headers:this.corsHeaders});if("POST"!==t.method)return this.error(405,"Method not allowed");try{const n=(await t.json()).prompt;if(!n)return this.error(400,"Missing prompt");const r=[this.config.mcpUrl||e.MCP_URL||"",this.config.aiProvider||e.AI_PROVIDER||"",this.config.aiModel||e.AI_MODEL||"",this.config.aiToken||e.AI_TOKEN||"",n],a=await ka(r[0],r[1],r[2],r[3],r[4]),i=new TextEncoder,s=new ReadableStream({async start(e){try{for await(const t of a)e.enqueue(i.encode(t));e.close()}catch(t){e.error(t)}}});return new Response(s,{headers:{...this.corsHeaders,"Content-Type":"text/plain; charset=utf-8","Transfer-Encoding":"chunked"}})}catch(e){const t=e;return console.error("Catch error:",t),this.error(500,t.message)}}error(e,t){return console.error("Error:",{status:e,message:t}),new Response(JSON.stringify({error:t}),{status:e,headers:{...this.corsHeaders,"Content-Type":"application/json"}})}}function ba(e){if(e instanceof Request){return wa.New({...wa.defaultConfig()})(e)}return wa.New(e)}export{ka as askPrompt,ba as handler};
1
+ import{env as n}from"node:process";import{streamText as e,stepCountIs as t}from"ai";import{experimental_createMCPClient as r}from"@ai-sdk/mcp";import{k as o,f as i,i as a,c as u,a as s,_ as c,b as l,h as d,g as p,j as f,e as h,d as v,l as m,m as _}from"../_rollupPluginBabelHelpers-DdRaffu0.js";import y from"pkce-challenge";import{createAnthropic as g}from"@ai-sdk/anthropic";import{createOpenAI as w}from"@ai-sdk/openai";function k(n){return n?n instanceof Headers?Object.fromEntries(n.entries()):Array.isArray(n)?Object.fromEntries(n):o({},n):{}}var b=Object.freeze({status:"aborted"});function z(n,e,t){var r;function o(t,r){var o,i,u;for(var s in Object.defineProperty(t,"_zod",{value:null!==(o=t._zod)&&void 0!==o?o:{},enumerable:!1}),null!==(i=(u=t._zod).traits)&&void 0!==i||(u.traits=new Set),t._zod.traits.add(n),e(t,r),a.prototype)s in t||Object.defineProperty(t,s,{value:a.prototype[s].bind(t)});t._zod.constr=a,t._zod.def=r}var i=function(n){function e(){return l(this,e),d(this,e,arguments)}return u(e,n),s(e)}(null!==(r=null==t?void 0:t.Parent)&&void 0!==r?r:Object);function a(n){var e,r,a=null!=t&&t.Parent?new i:this;o(a,n),null!==(e=(r=a._zod).deferred)&&void 0!==e||(r.deferred=[]);var u,s=c(a._zod.deferred);try{for(s.s();!(u=s.n()).done;){(0,u.value)()}}catch(n){s.e(n)}finally{s.f()}return a}return Object.defineProperty(i,"name",{value:n}),Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:function(e){var r;return!!(null!=t&&t.Parent&&e instanceof t.Parent)||(null==e||null===(r=e._zod)||void 0===r||null===(r=r.traits)||void 0===r?void 0:r.has(n))}}),Object.defineProperty(a,"name",{value:n}),a}var x=function(n){function e(){return l(this,e),d(this,e,["Encountered Promise during synchronous parse. Use .parseAsync() instead."])}return u(e,n),s(e)}(p(Error)),I={};function T(n){return I}function E(n,e){return"bigint"==typeof e?e.toString():e}function P(n){return{get value(){var e=n();return Object.defineProperty(this,"value",{value:e}),e}}}function Z(n){return null==n}function C(n){var e=n.startsWith("^")?1:0,t=n.endsWith("$")?n.length-1:n.length;return n.slice(e,t)}function A(n,e,t){Object.defineProperty(n,e,{get:function(){var r=t();return n[e]=r,r},set:function(t){Object.defineProperty(n,e,{value:t})},configurable:!0})}function U(n,e,t){Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0})}function R(n){return JSON.stringify(n)}var S=Error.captureStackTrace?Error.captureStackTrace:function(){};function O(n){return"object"===f(n)&&null!==n&&!Array.isArray(n)}var $=P(function(){var n;if("undefined"!=typeof navigator&&null!==(n=navigator)&&void 0!==n&&null!==(n=n.userAgent)&&void 0!==n&&n.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(n){return!1}});function j(n){if(!1===O(n))return!1;var e=n.constructor;if(void 0===e)return!0;var t=e.prototype;return!1!==O(t)&&!1!==Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")}var N=new Set(["string","number","symbol"]);function M(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function F(n,e,t){var r=new n._zod.constr(null!=e?e:n._zod.def);return(!e||null!=t&&t.parent)&&(r._zod.parent=n),r}function L(n){var e=n;if(!e)return{};if("string"==typeof e)return{error:function(){return e}};if(void 0!==(null==e?void 0:e.message)){if(void 0!==(null==e?void 0:e.error))throw new Error("Cannot specify both `message` and `error` params");e.error=e.message}return delete e.message,"string"==typeof e.error?o(o({},e),{},{error:function(){return e.error}}):e}var D={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function V(n){for(var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;e<n.issues.length;e++){var t;if(!0!==(null===(t=n.issues[e])||void 0===t?void 0:t.continue))return!0}return!1}function q(n,e){return e.map(function(e){var t,r;return null!==(t=(r=e).path)&&void 0!==t||(r.path=[]),e.path.unshift(n),e})}function W(n){return"string"==typeof n?n:null==n?void 0:n.message}function H(n,e,t){var r,i=o(o({},n),{},{path:null!==(r=n.path)&&void 0!==r?r:[]});if(!n.message){var a,u,s,c,l,d,p,f,h,v=null!==(a=null!==(u=null!==(s=null!==(c=W(null===(l=n.inst)||void 0===l||null===(l=l._zod.def)||void 0===l||null===(d=l.error)||void 0===d?void 0:d.call(l,n)))&&void 0!==c?c:W(null==e||null===(p=e.error)||void 0===p?void 0:p.call(e,n)))&&void 0!==s?s:W(null===(f=t.customError)||void 0===f?void 0:f.call(t,n)))&&void 0!==u?u:W(null===(h=t.localeError)||void 0===h?void 0:h.call(t,n)))&&void 0!==a?a:"Invalid input";i.message=v}return delete i.inst,delete i.continue,null!=e&&e.reportInput||delete i.input,i}function B(n){return n instanceof Set?"set":n instanceof Map?"map":n instanceof File?"file":"unknown"}function G(n){return Array.isArray(n)?"array":"string"==typeof n?"string":"unknown"}function J(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];var r=e[0],i=e[1],a=e[2];return"string"==typeof r?{message:r,code:"custom",input:i,inst:a}:o({},r)}var K=function(n,e){n.name="$ZodError",Object.defineProperty(n,"_zod",{value:n._zod,enumerable:!1}),Object.defineProperty(n,"issues",{value:e,enumerable:!1}),Object.defineProperty(n,"message",{get:function(){return JSON.stringify(e,E,2)},enumerable:!0}),Object.defineProperty(n,"toString",{value:function(){return n.message},enumerable:!1})},Y=z("$ZodError",K),X=z("$ZodError",K,{Parent:Error});var Q=function(n){return function(e,t,r,o){var i=r?Object.assign(r,{async:!1}):{async:!1},a=e._zod.run({value:t,issues:[]},i);if(a instanceof Promise)throw new x;if(a.issues.length){var u,s=new(null!==(u=null==o?void 0:o.Err)&&void 0!==u?u:n)(a.issues.map(function(n){return H(n,i,T())}));throw S(s,null==o?void 0:o.callee),s}return a.value}},nn=function(n){return function(){var e=i(a().m(function e(t,r,o,i){var u,s,c,l;return a().w(function(e){for(;;)switch(e.n){case 0:if(u=o?Object.assign(o,{async:!0}):{async:!0},!((s=t._zod.run({value:r,issues:[]},u))instanceof Promise)){e.n=2;break}return e.n=1,s;case 1:s=e.v;case 2:if(!s.issues.length){e.n=3;break}throw l=new(null!==(c=null==i?void 0:i.Err)&&void 0!==c?c:n)(s.issues.map(function(n){return H(n,u,T())})),S(l,null==i?void 0:i.callee),l;case 3:return e.a(2,s.value)}},e)}));return function(n,t,r,o){return e.apply(this,arguments)}}()},en=function(n){return function(e,t,r){var i=r?o(o({},r),{},{async:!1}):{async:!1},a=e._zod.run({value:t,issues:[]},i);if(a instanceof Promise)throw new x;return a.issues.length?{success:!1,error:new(null!=n?n:Y)(a.issues.map(function(n){return H(n,i,T())}))}:{success:!0,data:a.value}}},tn=en(X),rn=function(n){return function(){var e=i(a().m(function e(t,r,o){var i,u;return a().w(function(e){for(;;)switch(e.n){case 0:if(i=o?Object.assign(o,{async:!0}):{async:!0},!((u=t._zod.run({value:r,issues:[]},i))instanceof Promise)){e.n=2;break}return e.n=1,u;case 1:u=e.v;case 2:return e.a(2,u.issues.length?{success:!1,error:new n(u.issues.map(function(n){return H(n,i,T())}))}:{success:!0,data:u.value})}},e)}));return function(n,t,r){return e.apply(this,arguments)}}()},on=rn(X),an=/^[cC][^\s-]{8,}$/,un=/^[0-9a-z]+$/,sn=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,cn=/^[0-9a-vA-V]{20}$/,ln=/^[A-Za-z0-9]{27}$/,dn=/^[a-zA-Z0-9_-]{21}$/,pn=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,fn=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,hn=function(n){return n?new RegExp("^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-".concat(n,"[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$")):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/},vn=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;var mn=/^(?:(?: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=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})$/,yn=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,gn=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,wn=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,kn=/^[A-Za-z0-9_-]*$/,bn=/^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+$/,zn=/^\+(?:[0-9]){6,14}[0-9]$/,xn="(?:(?:\\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])))",In=new RegExp("^".concat(xn,"$"));function Tn(n){var e="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof n.precision?-1===n.precision?"".concat(e):0===n.precision?"".concat(e,":[0-5]\\d"):"".concat(e,":[0-5]\\d\\.\\d{").concat(n.precision,"}"):"".concat(e,"(?::[0-5]\\d(?:\\.\\d+)?)?")}var En=/^\d+$/,Pn=/^-?\d+(?:\.\d+)?/i,Zn=/true|false/i,Cn=/^[^A-Z]*$/,An=/^[^a-z]*$/,Un=z("$ZodCheck",function(n,e){var t,r,o;null!==(t=n._zod)&&void 0!==t||(n._zod={}),n._zod.def=e,null!==(r=(o=n._zod).onattach)&&void 0!==r||(o.onattach=[])}),Rn={number:"number",bigint:"bigint",object:"date"},Sn=z("$ZodCheckLessThan",function(n,e){Un.init(n,e);var t=Rn[f(e.value)];n._zod.onattach.push(function(n){var t,r=n._zod.bag,o=null!==(t=e.inclusive?r.maximum:r.exclusiveMaximum)&&void 0!==t?t:Number.POSITIVE_INFINITY;e.value<o&&(e.inclusive?r.maximum=e.value:r.exclusiveMaximum=e.value)}),n._zod.check=function(r){(e.inclusive?r.value<=e.value:r.value<e.value)||r.issues.push({origin:t,code:"too_big",maximum:e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),On=z("$ZodCheckGreaterThan",function(n,e){Un.init(n,e);var t=Rn[f(e.value)];n._zod.onattach.push(function(n){var t,r=n._zod.bag,o=null!==(t=e.inclusive?r.minimum:r.exclusiveMinimum)&&void 0!==t?t:Number.NEGATIVE_INFINITY;e.value>o&&(e.inclusive?r.minimum=e.value:r.exclusiveMinimum=e.value)}),n._zod.check=function(r){(e.inclusive?r.value>=e.value:r.value>e.value)||r.issues.push({origin:t,code:"too_small",minimum:e.value,input:r.value,inclusive:e.inclusive,inst:n,continue:!e.abort})}}),$n=z("$ZodCheckMultipleOf",function(n,e){Un.init(n,e),n._zod.onattach.push(function(n){var t,r;null!==(t=(r=n._zod.bag).multipleOf)&&void 0!==t||(r.multipleOf=e.value)}),n._zod.check=function(t){if(f(t.value)!==f(e.value))throw new Error("Cannot mix number and bigint in multiple_of check.");var r,o,i,a,u;("bigint"==typeof t.value?t.value%e.value===BigInt(0):0===(r=t.value,o=e.value,i=(r.toString().split(".")[1]||"").length,a=(o.toString().split(".")[1]||"").length,u=i>a?i:a,Number.parseInt(r.toFixed(u).replace(".",""))%Number.parseInt(o.toFixed(u).replace(".",""))/Math.pow(10,u)))||t.issues.push({origin:f(t.value),code:"not_multiple_of",divisor:e.value,input:t.value,inst:n,continue:!e.abort})}}),jn=z("$ZodCheckNumberFormat",function(n,e){var t;Un.init(n,e),e.format=e.format||"float64";var r=null===(t=e.format)||void 0===t?void 0:t.includes("int"),o=r?"int":"number",i=h(D[e.format],2),a=i[0],u=i[1];n._zod.onattach.push(function(n){var t=n._zod.bag;t.format=e.format,t.minimum=a,t.maximum=u,r&&(t.pattern=En)}),n._zod.check=function(t){var i=t.value;if(r){if(!Number.isInteger(i))return void t.issues.push({expected:o,format:e.format,code:"invalid_type",input:i,inst:n});if(!Number.isSafeInteger(i))return void(i>0?t.issues.push({input:i,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:o,continue:!e.abort}):t.issues.push({input:i,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:n,origin:o,continue:!e.abort}))}i<a&&t.issues.push({origin:"number",input:i,code:"too_small",minimum:a,inclusive:!0,inst:n,continue:!e.abort}),i>u&&t.issues.push({origin:"number",input:i,code:"too_big",maximum:u,inst:n})}}),Nn=z("$ZodCheckMaxSize",function(n,e){var t,r;Un.init(n,e),null!==(t=(r=n._zod.def).when)&&void 0!==t||(r.when=function(n){var e=n.value;return!Z(e)&&void 0!==e.size}),n._zod.onattach.push(function(n){var t,r=null!==(t=n._zod.bag.maximum)&&void 0!==t?t:Number.POSITIVE_INFINITY;e.maximum<r&&(n._zod.bag.maximum=e.maximum)}),n._zod.check=function(t){var r=t.value;r.size<=e.maximum||t.issues.push({origin:B(r),code:"too_big",maximum:e.maximum,input:r,inst:n,continue:!e.abort})}}),Mn=z("$ZodCheckMinSize",function(n,e){var t,r;Un.init(n,e),null!==(t=(r=n._zod.def).when)&&void 0!==t||(r.when=function(n){var e=n.value;return!Z(e)&&void 0!==e.size}),n._zod.onattach.push(function(n){var t,r=null!==(t=n._zod.bag.minimum)&&void 0!==t?t:Number.NEGATIVE_INFINITY;e.minimum>r&&(n._zod.bag.minimum=e.minimum)}),n._zod.check=function(t){var r=t.value;r.size>=e.minimum||t.issues.push({origin:B(r),code:"too_small",minimum:e.minimum,input:r,inst:n,continue:!e.abort})}}),Fn=z("$ZodCheckSizeEquals",function(n,e){var t,r;Un.init(n,e),null!==(t=(r=n._zod.def).when)&&void 0!==t||(r.when=function(n){var e=n.value;return!Z(e)&&void 0!==e.size}),n._zod.onattach.push(function(n){var t=n._zod.bag;t.minimum=e.size,t.maximum=e.size,t.size=e.size}),n._zod.check=function(t){var r=t.value,i=r.size;if(i!==e.size){var a=i>e.size;t.issues.push(o(o({origin:B(r)},a?{code:"too_big",maximum:e.size}:{code:"too_small",minimum:e.size}),{},{inclusive:!0,exact:!0,input:t.value,inst:n,continue:!e.abort}))}}}),Ln=z("$ZodCheckMaxLength",function(n,e){var t,r;Un.init(n,e),null!==(t=(r=n._zod.def).when)&&void 0!==t||(r.when=function(n){var e=n.value;return!Z(e)&&void 0!==e.length}),n._zod.onattach.push(function(n){var t,r=null!==(t=n._zod.bag.maximum)&&void 0!==t?t:Number.POSITIVE_INFINITY;e.maximum<r&&(n._zod.bag.maximum=e.maximum)}),n._zod.check=function(t){var r=t.value;if(!(r.length<=e.maximum)){var o=G(r);t.issues.push({origin:o,code:"too_big",maximum:e.maximum,inclusive:!0,input:r,inst:n,continue:!e.abort})}}}),Dn=z("$ZodCheckMinLength",function(n,e){var t,r;Un.init(n,e),null!==(t=(r=n._zod.def).when)&&void 0!==t||(r.when=function(n){var e=n.value;return!Z(e)&&void 0!==e.length}),n._zod.onattach.push(function(n){var t,r=null!==(t=n._zod.bag.minimum)&&void 0!==t?t:Number.NEGATIVE_INFINITY;e.minimum>r&&(n._zod.bag.minimum=e.minimum)}),n._zod.check=function(t){var r=t.value;if(!(r.length>=e.minimum)){var o=G(r);t.issues.push({origin:o,code:"too_small",minimum:e.minimum,inclusive:!0,input:r,inst:n,continue:!e.abort})}}}),Vn=z("$ZodCheckLengthEquals",function(n,e){var t,r;Un.init(n,e),null!==(t=(r=n._zod.def).when)&&void 0!==t||(r.when=function(n){var e=n.value;return!Z(e)&&void 0!==e.length}),n._zod.onattach.push(function(n){var t=n._zod.bag;t.minimum=e.length,t.maximum=e.length,t.length=e.length}),n._zod.check=function(t){var r=t.value,i=r.length;if(i!==e.length){var a=G(r),u=i>e.length;t.issues.push(o(o({origin:a},u?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length}),{},{inclusive:!0,exact:!0,input:t.value,inst:n,continue:!e.abort}))}}}),qn=z("$ZodCheckStringFormat",function(n,e){var t,r,i,a;Un.init(n,e),n._zod.onattach.push(function(n){var t,r=n._zod.bag;(r.format=e.format,e.pattern)&&(null!==(t=r.patterns)&&void 0!==t||(r.patterns=new Set),r.patterns.add(e.pattern))}),e.pattern?null!==(t=(i=n._zod).check)&&void 0!==t||(i.check=function(t){e.pattern.lastIndex=0,e.pattern.test(t.value)||t.issues.push(o(o({origin:"string",code:"invalid_format",format:e.format,input:t.value},e.pattern?{pattern:e.pattern.toString()}:{}),{},{inst:n,continue:!e.abort}))}):null!==(r=(a=n._zod).check)&&void 0!==r||(a.check=function(){})}),Wn=z("$ZodCheckRegex",function(n,e){qn.init(n,e),n._zod.check=function(t){e.pattern.lastIndex=0,e.pattern.test(t.value)||t.issues.push({origin:"string",code:"invalid_format",format:"regex",input:t.value,pattern:e.pattern.toString(),inst:n,continue:!e.abort})}}),Hn=z("$ZodCheckLowerCase",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=Cn),qn.init(n,e)}),Bn=z("$ZodCheckUpperCase",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=An),qn.init(n,e)}),Gn=z("$ZodCheckIncludes",function(n,e){Un.init(n,e);var t=M(e.includes),r=new RegExp("number"==typeof e.position?"^.{".concat(e.position,"}").concat(t):t);e.pattern=r,n._zod.onattach.push(function(n){var e,t=n._zod.bag;null!==(e=t.patterns)&&void 0!==e||(t.patterns=new Set),t.patterns.add(r)}),n._zod.check=function(t){t.value.includes(e.includes,e.position)||t.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:t.value,inst:n,continue:!e.abort})}}),Jn=z("$ZodCheckStartsWith",function(n,e){var t;Un.init(n,e);var r=new RegExp("^".concat(M(e.prefix),".*"));null!==(t=e.pattern)&&void 0!==t||(e.pattern=r),n._zod.onattach.push(function(n){var e,t=n._zod.bag;null!==(e=t.patterns)&&void 0!==e||(t.patterns=new Set),t.patterns.add(r)}),n._zod.check=function(t){t.value.startsWith(e.prefix)||t.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:t.value,inst:n,continue:!e.abort})}}),Kn=z("$ZodCheckEndsWith",function(n,e){var t;Un.init(n,e);var r=new RegExp(".*".concat(M(e.suffix),"$"));null!==(t=e.pattern)&&void 0!==t||(e.pattern=r),n._zod.onattach.push(function(n){var e,t=n._zod.bag;null!==(e=t.patterns)&&void 0!==e||(t.patterns=new Set),t.patterns.add(r)}),n._zod.check=function(t){t.value.endsWith(e.suffix)||t.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:t.value,inst:n,continue:!e.abort})}});function Yn(n,e,t){var r;n.issues.length&&(r=e.issues).push.apply(r,v(q(t,n.issues)))}var Xn=z("$ZodCheckProperty",function(n,e){Un.init(n,e),n._zod.check=function(n){var t=e.schema._zod.run({value:n.value[e.property],issues:[]},{});if(t instanceof Promise)return t.then(function(t){return Yn(t,n,e.property)});Yn(t,n,e.property)}}),Qn=z("$ZodCheckMimeType",function(n,e){Un.init(n,e);var t=new Set(e.mime);n._zod.onattach.push(function(n){n._zod.bag.mime=e.mime}),n._zod.check=function(r){t.has(r.value.type)||r.issues.push({code:"invalid_value",values:e.mime,input:r.value.type,inst:n})}}),ne=z("$ZodCheckOverwrite",function(n,e){Un.init(n,e),n._zod.check=function(n){n.value=e.tx(n.value)}}),ee=function(){return s(function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];l(this,n),this.content=[],this.indent=0,this&&(this.args=e)},[{key:"indented",value:function(n){this.indent+=1,n(this),this.indent-=1}},{key:"write",value:function(n){var e=this;if("function"==typeof n)return n(this,{execution:"sync"}),void n(this,{execution:"async"});var t,r=n.split("\n").filter(function(n){return n}),o=Math.min.apply(Math,v(r.map(function(n){return n.length-n.trimStart().length}))),i=r.map(function(n){return n.slice(o)}).map(function(n){return" ".repeat(2*e.indent)+n}),a=c(i);try{for(a.s();!(t=a.n()).done;){var u=t.value;this.content.push(u)}}catch(n){a.e(n)}finally{a.f()}}},{key:"compile",value:function(){var n,e=Function,t=null==this?void 0:this.args,r=null!==(n=null==this?void 0:this.content)&&void 0!==n?n:[""],o=v(r.map(function(n){return" ".concat(n)}));return m(e,v(t).concat([o.join("\n")]))}}])}(),te={major:4,minor:0,patch:0},re=z("$ZodType",function(n,e){var t,r;null!=n||(n={}),n._zod.def=e,n._zod.bag=n._zod.bag||{},n._zod.version=te;var o=v(null!==(t=n._zod.def.checks)&&void 0!==t?t:[]);n._zod.traits.has("$ZodCheck")&&o.unshift(n);var u,s=c(o);try{for(s.s();!(u=s.n()).done;){var l,d=u.value,p=c(d._zod.onattach);try{for(p.s();!(l=p.n()).done;){(0,l.value)(n)}}catch(n){p.e(n)}finally{p.f()}}}catch(n){s.e(n)}finally{s.f()}if(0===o.length){var f,h;null!==(f=(r=n._zod).deferred)&&void 0!==f||(r.deferred=[]),null===(h=n._zod.deferred)||void 0===h||h.push(function(){n._zod.run=n._zod.parse})}else{var m=function(n,e,t){var r,o,u=V(n),s=c(e);try{var l=function(){var e=o.value;if(e._zod.def.when){if(!e._zod.def.when(n))return 0}else if(u)return 0;var s=n.issues.length,c=e._zod.check(n);if(c instanceof Promise&&!1===(null==t?void 0:t.async))throw new x;if(r||c instanceof Promise)r=(null!=r?r:Promise.resolve()).then(i(a().m(function e(){return a().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,c;case 1:if(n.issues.length!==s){e.n=2;break}return e.a(2);case 2:u||(u=V(n,s));case 3:return e.a(2)}},e)})));else{if(n.issues.length===s)return 0;u||(u=V(n,s))}};for(s.s();!(o=s.n()).done;)l()}catch(n){s.e(n)}finally{s.f()}return r?r.then(function(){return n}):n};n._zod.run=function(e,t){var r=n._zod.parse(e,t);if(r instanceof Promise){if(!1===t.async)throw new x;return r.then(function(n){return m(n,o,t)})}return m(r,o,t)}}n["~standard"]={validate:function(e){try{var t,r=tn(n,e);return r.success?{value:r.data}:{issues:null===(t=r.error)||void 0===t?void 0:t.issues}}catch(t){return on(n,e).then(function(n){var e;return n.success?{value:n.data}:{issues:null===(e=n.error)||void 0===e?void 0:e.issues}})}},vendor:"zod",version:1}}),oe=z("$ZodString",function(n,e){var t,r,o,i,a,u,s;re.init(n,e),n._zod.pattern=null!==(t=v(null!==(r=null==n||null===(o=n._zod.bag)||void 0===o?void 0:o.patterns)&&void 0!==r?r:[]).pop())&&void 0!==t?t:(i=n._zod.bag,s=i?"[\\s\\S]{".concat(null!==(a=null==i?void 0:i.minimum)&&void 0!==a?a:0,",").concat(null!==(u=null==i?void 0:i.maximum)&&void 0!==u?u:"","}"):"[\\s\\S]*",new RegExp("^".concat(s,"$"))),n._zod.parse=function(t,r){if(e.coerce)try{t.value=String(t.value)}catch(r){}return"string"==typeof t.value||t.issues.push({expected:"string",code:"invalid_type",input:t.value,inst:n}),t}}),ie=z("$ZodStringFormat",function(n,e){qn.init(n,e),oe.init(n,e)}),ae=z("$ZodGUID",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=fn),ie.init(n,e)}),ue=z("$ZodUUID",function(n,e){var t;if(e.version){var r,o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(void 0===o)throw new Error('Invalid UUID version: "'.concat(e.version,'"'));null!==(r=e.pattern)&&void 0!==r||(e.pattern=hn(o))}else null!==(t=e.pattern)&&void 0!==t||(e.pattern=hn());ie.init(n,e)}),se=z("$ZodEmail",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=vn),ie.init(n,e)}),ce=z("$ZodURL",function(n,e){ie.init(n,e),n._zod.check=function(t){try{var r=t.value,o=new URL(r),i=o.href;return e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(o.hostname)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:bn.source,input:t.value,inst:n,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||t.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:t.value,inst:n,continue:!e.abort})),void(!r.endsWith("/")&&i.endsWith("/")?t.value=i.slice(0,-1):t.value=i)}catch(r){t.issues.push({code:"invalid_format",format:"url",input:t.value,inst:n,continue:!e.abort})}}}),le=z("$ZodEmoji",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ie.init(n,e)}),de=z("$ZodNanoID",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=dn),ie.init(n,e)}),pe=z("$ZodCUID",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=an),ie.init(n,e)}),fe=z("$ZodCUID2",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=un),ie.init(n,e)}),he=z("$ZodULID",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=sn),ie.init(n,e)}),ve=z("$ZodXID",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=cn),ie.init(n,e)}),me=z("$ZodKSUID",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=ln),ie.init(n,e)}),_e=z("$ZodISODateTime",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=function(n){var e=Tn({precision:n.precision}),t=["Z"];n.local&&t.push(""),n.offset&&t.push("([+-]\\d{2}:\\d{2})");var r="".concat(e,"(?:").concat(t.join("|"),")");return new RegExp("^".concat(xn,"T(?:").concat(r,")$"))}(e)),ie.init(n,e)}),ye=z("$ZodISODate",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=In),ie.init(n,e)}),ge=z("$ZodISOTime",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=new RegExp("^".concat(Tn(e),"$"))),ie.init(n,e)}),we=z("$ZodISODuration",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=pn),ie.init(n,e)}),ke=z("$ZodIPv4",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=mn),ie.init(n,e),n._zod.onattach.push(function(n){n._zod.bag.format="ipv4"})}),be=z("$ZodIPv6",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=_n),ie.init(n,e),n._zod.onattach.push(function(n){n._zod.bag.format="ipv6"}),n._zod.check=function(t){try{new URL("http://[".concat(t.value,"]"))}catch(r){t.issues.push({code:"invalid_format",format:"ipv6",input:t.value,inst:n,continue:!e.abort})}}}),ze=z("$ZodCIDRv4",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=yn),ie.init(n,e)}),xe=z("$ZodCIDRv6",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=gn),ie.init(n,e),n._zod.check=function(t){var r=t.value.split("/"),o=h(r,2),i=o[0],a=o[1];try{if(!a)throw new Error;var u=Number(a);if("".concat(u)!==a)throw new Error;if(u<0||u>128)throw new Error;new URL("http://[".concat(i,"]"))}catch(r){t.issues.push({code:"invalid_format",format:"cidrv6",input:t.value,inst:n,continue:!e.abort})}}});function Ie(n){if(""===n)return!0;if(n.length%4!=0)return!1;try{return atob(n),!0}catch(n){return!1}}var Te=z("$ZodBase64",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=wn),ie.init(n,e),n._zod.onattach.push(function(n){n._zod.bag.contentEncoding="base64"}),n._zod.check=function(t){Ie(t.value)||t.issues.push({code:"invalid_format",format:"base64",input:t.value,inst:n,continue:!e.abort})}});var Ee=z("$ZodBase64URL",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=kn),ie.init(n,e),n._zod.onattach.push(function(n){n._zod.bag.contentEncoding="base64url"}),n._zod.check=function(t){(function(n){if(!kn.test(n))return!1;var e=n.replace(/[-_]/g,function(n){return"-"===n?"+":"/"});return Ie(e.padEnd(4*Math.ceil(e.length/4),"="))})(t.value)||t.issues.push({code:"invalid_format",format:"base64url",input:t.value,inst:n,continue:!e.abort})}}),Pe=z("$ZodE164",function(n,e){var t;null!==(t=e.pattern)&&void 0!==t||(e.pattern=zn),ie.init(n,e)});var Ze=z("$ZodJWT",function(n,e){ie.init(n,e),n._zod.check=function(t){(function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;try{var t=n.split(".");if(3!==t.length)return!1;var r=h(t,1)[0];if(!r)return!1;var o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==(null==o?void 0:o.typ)||!o.alg||e&&(!("alg"in o)||o.alg!==e))}catch(n){return!1}})(t.value,e.alg)||t.issues.push({code:"invalid_format",format:"jwt",input:t.value,inst:n,continue:!e.abort})}}),Ce=z("$ZodNumber",function(n,e){var t;re.init(n,e),n._zod.pattern=null!==(t=n._zod.bag.pattern)&&void 0!==t?t:Pn,n._zod.parse=function(t,r){if(e.coerce)try{t.value=Number(t.value)}catch(n){}var i=t.value;if("number"==typeof i&&!Number.isNaN(i)&&Number.isFinite(i))return t;var a="number"==typeof i?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return t.issues.push(o({expected:"number",code:"invalid_type",input:i,inst:n},a?{received:a}:{})),t}}),Ae=z("$ZodNumber",function(n,e){jn.init(n,e),Ce.init(n,e)}),Ue=z("$ZodBoolean",function(n,e){re.init(n,e),n._zod.pattern=Zn,n._zod.parse=function(t,r){if(e.coerce)try{t.value=Boolean(t.value)}catch(n){}var o=t.value;return"boolean"==typeof o||t.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:n}),t}}),Re=z("$ZodAny",function(n,e){re.init(n,e),n._zod.parse=function(n){return n}}),Se=z("$ZodUnknown",function(n,e){re.init(n,e),n._zod.parse=function(n){return n}}),Oe=z("$ZodNever",function(n,e){re.init(n,e),n._zod.parse=function(e,t){return e.issues.push({expected:"never",code:"invalid_type",input:e.value,inst:n}),e}});function $e(n,e,t){var r;n.issues.length&&(r=e.issues).push.apply(r,v(q(t,n.issues)));e.value[t]=n.value}var je=z("$ZodArray",function(n,e){re.init(n,e),n._zod.parse=function(t,r){var o=t.value;if(!Array.isArray(o))return t.issues.push({expected:"array",code:"invalid_type",input:o,inst:n}),t;t.value=Array(o.length);for(var i=[],a=function(n){var a=o[n],u=e.element._zod.run({value:a,issues:[]},r);u instanceof Promise?i.push(u.then(function(e){return $e(e,t,n)})):$e(u,t,n)},u=0;u<o.length;u++)a(u);return i.length?Promise.all(i).then(function(){return t}):t}});function Ne(n,e,t){var r;n.issues.length&&(r=e.issues).push.apply(r,v(q(t,n.issues)));e.value[t]=n.value}function Me(n,e,t,r){var o;n.issues.length?void 0===r[t]?e.value[t]=t in r?void 0:n.value:(o=e.issues).push.apply(o,v(q(t,n.issues))):void 0===n.value?t in r&&(e.value[t]=void 0):e.value[t]=n.value}var Fe=z("$ZodObject",function(n,e){re.init(n,e);var t=P(function(){for(var n=Object.keys(e.shape),t=0,r=n;t<r.length;t++){var o=r[t];if(!(e.shape[o]instanceof re))throw new Error('Invalid element at key "'.concat(o,'": expected a Zod schema'))}var i,a=(i=e.shape,Object.keys(i).filter(function(n){return"optional"===i[n]._zod.optin&&"optional"===i[n]._zod.optout}));return{shape:e.shape,keys:n,keySet:new Set(n),numKeys:n.length,optionalKeys:new Set(a)}});A(n._zod,"propValues",function(){var n=e.shape,t={};for(var r in n){var o=n[r]._zod;if(o.values){var i;null!==(i=t[r])&&void 0!==i||(t[r]=new Set);var a,u=c(o.values);try{for(u.s();!(a=u.n()).done;){var s=a.value;t[r].add(s)}}catch(n){u.e(n)}finally{u.f()}}}return t});var r,o,i=O,a=!I.jitless,u=a&&$.value,s=e.catchall;n._zod.parse=function(l,d){null!=o||(o=t.value);var p=l.value;if(!i(p))return l.issues.push({expected:"object",code:"invalid_type",input:p,inst:n}),l;var f=[];if(a&&u&&!1===(null==d?void 0:d.async)&&!0!==d.jitless)r||(r=function(n){var e=new ee(["shape","payload","ctx"]),r=t.value,o=function(n){var e=R(n);return"shape[".concat(e,"]._zod.run({ value: input[").concat(e,"], issues: [] }, ctx)")};e.write("const input = payload.value;");var i,a=Object.create(null),u=0,s=c(r.keys);try{for(s.s();!(i=s.n()).done;)a[i.value]="key_".concat(u++)}catch(n){s.e(n)}finally{s.f()}e.write("const newResult = {}");var l,d=c(r.keys);try{for(d.s();!(l=d.n()).done;){var p=l.value;if(r.optionalKeys.has(p)){var f=a[p];e.write("const ".concat(f," = ").concat(o(p),";"));var h=R(p);e.write("\n if (".concat(f,".issues.length) {\n if (input[").concat(h,"] === undefined) {\n if (").concat(h," in input) {\n newResult[").concat(h,"] = undefined;\n }\n } else {\n payload.issues = payload.issues.concat(\n ").concat(f,".issues.map((iss) => ({\n ...iss,\n path: iss.path ? [").concat(h,", ...iss.path] : [").concat(h,"],\n }))\n );\n }\n } else if (").concat(f,".value === undefined) {\n if (").concat(h," in input) newResult[").concat(h,"] = undefined;\n } else {\n newResult[").concat(h,"] = ").concat(f,".value;\n }\n "))}else{var v=a[p];e.write("const ".concat(v," = ").concat(o(p),";")),e.write("\n if (".concat(v,".issues.length) payload.issues = payload.issues.concat(").concat(v,".issues.map(iss => ({\n ...iss,\n path: iss.path ? [").concat(R(p),", ...iss.path] : [").concat(R(p),"]\n })));")),e.write("newResult[".concat(R(p),"] = ").concat(v,".value"))}}}catch(n){d.e(n)}finally{d.f()}e.write("payload.value = newResult;"),e.write("return payload;");var m=e.compile();return function(e,t){return m(n,e,t)}}(e.shape)),l=r(l,d);else{l.value={};var h,v=o.shape,m=c(o.keys);try{var _=function(){var n=h.value,e=v[n],t=e._zod.run({value:p[n],issues:[]},d),r="optional"===e._zod.optin&&"optional"===e._zod.optout;t instanceof Promise?f.push(t.then(function(e){return r?Me(e,l,n,p):Ne(e,l,n)})):r?Me(t,l,n,p):Ne(t,l,n)};for(m.s();!(h=m.n()).done;)_()}catch(n){m.e(n)}finally{m.f()}}if(!s)return f.length?Promise.all(f).then(function(){return l}):l;for(var y=[],g=o.keySet,w=s._zod,k=w.def.type,b=function(){var n=x[z];if(g.has(n))return 0;if("never"===k)return y.push(n),0;var e=w.run({value:p[n],issues:[]},d);e instanceof Promise?f.push(e.then(function(e){return Ne(e,l,n)})):Ne(e,l,n)},z=0,x=Object.keys(p);z<x.length;z++)b();return y.length&&l.issues.push({code:"unrecognized_keys",keys:y,input:p,inst:n}),f.length?Promise.all(f).then(function(){return l}):l}});function Le(n,e,t,r){var o,i=c(n);try{for(i.s();!(o=i.n()).done;){var a=o.value;if(0===a.issues.length)return e.value=a.value,e}}catch(n){i.e(n)}finally{i.f()}return e.issues.push({code:"invalid_union",input:e.value,inst:t,errors:n.map(function(n){return n.issues.map(function(n){return H(n,r,T())})})}),e}var De=z("$ZodUnion",function(n,e){re.init(n,e),A(n._zod,"optin",function(){return e.options.some(function(n){return"optional"===n._zod.optin})?"optional":void 0}),A(n._zod,"optout",function(){return e.options.some(function(n){return"optional"===n._zod.optout})?"optional":void 0}),A(n._zod,"values",function(){if(e.options.every(function(n){return n._zod.values}))return new Set(e.options.flatMap(function(n){return Array.from(n._zod.values)}))}),A(n._zod,"pattern",function(){if(e.options.every(function(n){return n._zod.pattern})){var n=e.options.map(function(n){return n._zod.pattern});return new RegExp("^(".concat(n.map(function(n){return C(n.source)}).join("|"),")$"))}}),n._zod.parse=function(t,r){var o,i=!1,a=[],u=c(e.options);try{for(u.s();!(o=u.n()).done;){var s=o.value._zod.run({value:t.value,issues:[]},r);if(s instanceof Promise)a.push(s),i=!0;else{if(0===s.issues.length)return s;a.push(s)}}}catch(n){u.e(n)}finally{u.f()}return i?Promise.all(a).then(function(e){return Le(e,t,n,r)}):Le(a,t,n,r)}}),Ve=z("$ZodDiscriminatedUnion",function(n,e){De.init(n,e);var t=n._zod.parse;A(n._zod,"propValues",function(){var n,t={},r=c(e.options);try{for(r.s();!(n=r.n()).done;){var o=n.value,i=o._zod.propValues;if(!i||0===Object.keys(i).length)throw new Error('Invalid discriminated union option at index "'.concat(e.options.indexOf(o),'"'));for(var a=0,u=Object.entries(i);a<u.length;a++){var s=h(u[a],2),l=s[0],d=s[1];t[l]||(t[l]=new Set);var p,f=c(d);try{for(f.s();!(p=f.n()).done;){var v=p.value;t[l].add(v)}}catch(n){f.e(n)}finally{f.f()}}}}catch(n){r.e(n)}finally{r.f()}return t});var r=P(function(){var n,t=e.options,r=new Map,o=c(t);try{for(o.s();!(n=o.n()).done;){var i=n.value,a=i._zod.propValues[e.discriminator];if(!a||0===a.size)throw new Error('Invalid discriminated union option at index "'.concat(e.options.indexOf(i),'"'));var u,s=c(a);try{for(s.s();!(u=s.n()).done;){var l=u.value;if(r.has(l))throw new Error('Duplicate discriminator value "'.concat(String(l),'"'));r.set(l,i)}}catch(n){s.e(n)}finally{s.f()}}}catch(n){o.e(n)}finally{o.f()}return r});n._zod.parse=function(o,i){var a=o.value;if(!O(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:n}),o;var u=r.value.get(null==a?void 0:a[e.discriminator]);return u?u._zod.run(o,i):e.unionFallback?t(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",input:a,path:[e.discriminator],inst:n}),o)}}),qe=z("$ZodIntersection",function(n,e){re.init(n,e),n._zod.parse=function(n,t){var r=n.value,o=e.left._zod.run({value:r,issues:[]},t),i=e.right._zod.run({value:r,issues:[]},t);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(function(e){var t=h(e,2),r=t[0],o=t[1];return He(n,r,o)}):He(n,o,i)}});function We(n,e){if(n===e)return{valid:!0,data:n};if(n instanceof Date&&e instanceof Date&&+n===+e)return{valid:!0,data:n};if(j(n)&&j(e)){var t,r=Object.keys(e),i=Object.keys(n).filter(function(n){return-1!==r.indexOf(n)}),a=o(o({},n),e),u=c(i);try{for(u.s();!(t=u.n()).done;){var s=t.value,l=We(n[s],e[s]);if(!l.valid)return{valid:!1,mergeErrorPath:[s].concat(v(l.mergeErrorPath))};a[s]=l.data}}catch(n){u.e(n)}finally{u.f()}return{valid:!0,data:a}}if(Array.isArray(n)&&Array.isArray(e)){if(n.length!==e.length)return{valid:!1,mergeErrorPath:[]};for(var d=[],p=0;p<n.length;p++){var f=We(n[p],e[p]);if(!f.valid)return{valid:!1,mergeErrorPath:[p].concat(v(f.mergeErrorPath))};d.push(f.data)}return{valid:!0,data:d}}return{valid:!1,mergeErrorPath:[]}}function He(n,e,t){var r,o;e.issues.length&&(r=n.issues).push.apply(r,v(e.issues));t.issues.length&&(o=n.issues).push.apply(o,v(t.issues));if(V(n))return n;var i=We(e.value,t.value);if(!i.valid)throw new Error("Unmergable intersection. Error path: "+"".concat(JSON.stringify(i.mergeErrorPath)));return n.value=i.data,n}var Be=z("$ZodRecord",function(n,e){re.init(n,e),n._zod.parse=function(t,r){var o=t.value;if(!j(o))return t.issues.push({expected:"record",code:"invalid_type",input:o,inst:n}),t;var i=[];if(e.keyType._zod.values){var a=e.keyType._zod.values;t.value={};var u,s,l=c(a);try{var d=function(){var n=u.value;if("string"==typeof n||"number"==typeof n||"symbol"===f(n)){var a=e.valueType._zod.run({value:o[n],issues:[]},r);if(a instanceof Promise)i.push(a.then(function(e){var r;e.issues.length&&(r=t.issues).push.apply(r,v(q(n,e.issues)));t.value[n]=e.value}));else{var s;if(a.issues.length)(s=t.issues).push.apply(s,v(q(n,a.issues)));t.value[n]=a.value}}};for(l.s();!(u=l.n()).done;)d()}catch(n){l.e(n)}finally{l.f()}for(var p in o)a.has(p)||(s=null!=s?s:[]).push(p);s&&s.length>0&&t.issues.push({code:"unrecognized_keys",input:o,inst:n,keys:s})}else{t.value={};var h,m=c(Reflect.ownKeys(o));try{var _=function(){var a=h.value;if("__proto__"===a)return 0;var u=e.keyType._zod.run({value:a,issues:[]},r);if(u instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(u.issues.length)return t.issues.push({origin:"record",code:"invalid_key",issues:u.issues.map(function(n){return H(n,r,T())}),input:a,path:[a],inst:n}),t.value[u.value]=u.value,0;var s=e.valueType._zod.run({value:o[a],issues:[]},r);if(s instanceof Promise)i.push(s.then(function(n){var e;n.issues.length&&(e=t.issues).push.apply(e,v(q(a,n.issues)));t.value[u.value]=n.value}));else{var c;if(s.issues.length)(c=t.issues).push.apply(c,v(q(a,s.issues)));t.value[u.value]=s.value}};for(m.s();!(h=m.n()).done;)_()}catch(n){m.e(n)}finally{m.f()}}return i.length?Promise.all(i).then(function(){return t}):t}}),Ge=z("$ZodEnum",function(n,e){re.init(n,e);var t,r,o=(t=e.entries,r=Object.values(t).filter(function(n){return"number"==typeof n}),Object.entries(t).filter(function(n){var e=h(n,2),t=e[0];return e[1],-1===r.indexOf(+t)}).map(function(n){var e=h(n,2);return e[0],e[1]}));n._zod.values=new Set(o),n._zod.pattern=new RegExp("^(".concat(o.filter(function(n){return N.has(f(n))}).map(function(n){return"string"==typeof n?M(n):n.toString()}).join("|"),")$")),n._zod.parse=function(e,t){var r=e.value;return n._zod.values.has(r)||e.issues.push({code:"invalid_value",values:o,input:r,inst:n}),e}}),Je=z("$ZodLiteral",function(n,e){re.init(n,e),n._zod.values=new Set(e.values),n._zod.pattern=new RegExp("^(".concat(e.values.map(function(n){return"string"==typeof n?M(n):n?n.toString():String(n)}).join("|"),")$")),n._zod.parse=function(t,r){var o=t.value;return n._zod.values.has(o)||t.issues.push({code:"invalid_value",values:e.values,input:o,inst:n}),t}}),Ke=z("$ZodTransform",function(n,e){re.init(n,e),n._zod.parse=function(n,t){var r=e.transform(n.value,n);if(t.async)return(r instanceof Promise?r:Promise.resolve(r)).then(function(e){return n.value=e,n});if(r instanceof Promise)throw new x;return n.value=r,n}}),Ye=z("$ZodOptional",function(n,e){re.init(n,e),n._zod.optin="optional",n._zod.optout="optional",A(n._zod,"values",function(){return e.innerType._zod.values?new Set([].concat(v(e.innerType._zod.values),[void 0])):void 0}),A(n._zod,"pattern",function(){var n=e.innerType._zod.pattern;return n?new RegExp("^(".concat(C(n.source),")?$")):void 0}),n._zod.parse=function(n,t){return"optional"===e.innerType._zod.optin?e.innerType._zod.run(n,t):void 0===n.value?n:e.innerType._zod.run(n,t)}}),Xe=z("$ZodNullable",function(n,e){re.init(n,e),A(n._zod,"optin",function(){return e.innerType._zod.optin}),A(n._zod,"optout",function(){return e.innerType._zod.optout}),A(n._zod,"pattern",function(){var n=e.innerType._zod.pattern;return n?new RegExp("^(".concat(C(n.source),"|null)$")):void 0}),A(n._zod,"values",function(){return e.innerType._zod.values?new Set([].concat(v(e.innerType._zod.values),[null])):void 0}),n._zod.parse=function(n,t){return null===n.value?n:e.innerType._zod.run(n,t)}}),Qe=z("$ZodDefault",function(n,e){re.init(n,e),n._zod.optin="optional",A(n._zod,"values",function(){return e.innerType._zod.values}),n._zod.parse=function(n,t){if(void 0===n.value)return n.value=e.defaultValue,n;var r=e.innerType._zod.run(n,t);return r instanceof Promise?r.then(function(n){return nt(n,e)}):nt(r,e)}});function nt(n,e){return void 0===n.value&&(n.value=e.defaultValue),n}var et=z("$ZodPrefault",function(n,e){re.init(n,e),n._zod.optin="optional",A(n._zod,"values",function(){return e.innerType._zod.values}),n._zod.parse=function(n,t){return void 0===n.value&&(n.value=e.defaultValue),e.innerType._zod.run(n,t)}}),tt=z("$ZodNonOptional",function(n,e){re.init(n,e),A(n._zod,"values",function(){var n=e.innerType._zod.values;return n?new Set(v(n).filter(function(n){return void 0!==n})):void 0}),n._zod.parse=function(t,r){var o=e.innerType._zod.run(t,r);return o instanceof Promise?o.then(function(e){return rt(e,n)}):rt(o,n)}});function rt(n,e){return n.issues.length||void 0!==n.value||n.issues.push({code:"invalid_type",expected:"nonoptional",input:n.value,inst:e}),n}var ot=z("$ZodCatch",function(n,e){re.init(n,e),n._zod.optin="optional",A(n._zod,"optout",function(){return e.innerType._zod.optout}),A(n._zod,"values",function(){return e.innerType._zod.values}),n._zod.parse=function(n,t){var r=e.innerType._zod.run(n,t);return r instanceof Promise?r.then(function(r){return n.value=r.value,r.issues.length&&(n.value=e.catchValue(o(o({},n),{},{error:{issues:r.issues.map(function(n){return H(n,t,T())})},input:n.value})),n.issues=[]),n}):(n.value=r.value,r.issues.length&&(n.value=e.catchValue(o(o({},n),{},{error:{issues:r.issues.map(function(n){return H(n,t,T())})},input:n.value})),n.issues=[]),n)}}),it=z("$ZodPipe",function(n,e){re.init(n,e),A(n._zod,"values",function(){return e.in._zod.values}),A(n._zod,"optin",function(){return e.in._zod.optin}),A(n._zod,"optout",function(){return e.out._zod.optout}),n._zod.parse=function(n,t){var r=e.in._zod.run(n,t);return r instanceof Promise?r.then(function(n){return at(n,e,t)}):at(r,e,t)}});function at(n,e,t){return V(n)?n:e.out._zod.run({value:n.value,issues:n.issues},t)}var ut=z("$ZodReadonly",function(n,e){re.init(n,e),A(n._zod,"propValues",function(){return e.innerType._zod.propValues}),A(n._zod,"values",function(){return e.innerType._zod.values}),A(n._zod,"optin",function(){return e.innerType._zod.optin}),A(n._zod,"optout",function(){return e.innerType._zod.optout}),n._zod.parse=function(n,t){var r=e.innerType._zod.run(n,t);return r instanceof Promise?r.then(st):st(r)}});function st(n){return n.value=Object.freeze(n.value),n}var ct=z("$ZodCustom",function(n,e){Un.init(n,e),re.init(n,e),n._zod.parse=function(n,e){return n},n._zod.check=function(t){var r=t.value,o=e.fn(r);if(o instanceof Promise)return o.then(function(e){return lt(e,t,r,n)});lt(o,t,r,n)}});function lt(n,e,t,r){if(!n){var o,i={code:"custom",input:t,inst:r,path:v(null!==(o=r._zod.def.path)&&void 0!==o?o:[]),continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),e.issues.push(J(i))}}var dt=function(){return s(function n(){l(this,n),this._map=new Map,this._idmap=new Map},[{key:"add",value:function(n){var e=arguments.length<=1?void 0:arguments[1];if(this._map.set(n,e),e&&"object"===f(e)&&"id"in e){if(this._idmap.has(e.id))throw new Error("ID ".concat(e.id," already exists in the registry"));this._idmap.set(e.id,n)}return this}},{key:"clear",value:function(){return this._map=new Map,this._idmap=new Map,this}},{key:"remove",value:function(n){var e=this._map.get(n);return e&&"object"===f(e)&&"id"in e&&this._idmap.delete(e.id),this._map.delete(n),this}},{key:"get",value:function(n){var e=n._zod.parent;if(e){var t,r=o({},null!==(t=this.get(e))&&void 0!==t?t:{});return delete r.id,o(o({},r),this._map.get(n))}return this._map.get(n)}},{key:"has",value:function(n){return this._map.has(n)}}])}();function pt(){return new dt}var ft=pt();function ht(n,e){return new n(o({type:"string",format:"guid",check:"string_format",abort:!1},L(e)))}function vt(n,e){return new n(o({type:"string",format:"url",check:"string_format",abort:!1},L(e)))}function mt(n,e){return new Sn(o(o({check:"less_than"},L(e)),{},{value:n,inclusive:!1}))}function _t(n,e){return new Sn(o(o({check:"less_than"},L(e)),{},{value:n,inclusive:!0}))}function yt(n,e){return new On(o(o({check:"greater_than"},L(e)),{},{value:n,inclusive:!1}))}function gt(n,e){return new On(o(o({check:"greater_than"},L(e)),{},{value:n,inclusive:!0}))}function wt(n,e){return new $n(o(o({check:"multiple_of"},L(e)),{},{value:n}))}function kt(n,e){return new Ln(o(o({check:"max_length"},L(e)),{},{maximum:n}))}function bt(n,e){return new Dn(o(o({check:"min_length"},L(e)),{},{minimum:n}))}function zt(n,e){return new Vn(o(o({check:"length_equals"},L(e)),{},{length:n}))}function xt(n,e){return new Wn(o(o({check:"string_format",format:"regex"},L(e)),{},{pattern:n}))}function It(n){return new Hn(o({check:"string_format",format:"lowercase"},L(n)))}function Tt(n){return new Bn(o({check:"string_format",format:"uppercase"},L(n)))}function Et(n,e){return new Gn(o(o({check:"string_format",format:"includes"},L(e)),{},{includes:n}))}function Pt(n,e){return new Jn(o(o({check:"string_format",format:"starts_with"},L(e)),{},{prefix:n}))}function Zt(n,e){return new Kn(o(o({check:"string_format",format:"ends_with"},L(e)),{},{suffix:n}))}function Ct(n){return new ne({check:"overwrite",tx:n})}function At(n){return Ct(function(e){return e.normalize(n)})}function Ut(){return Ct(function(n){return n.trim()})}function Rt(){return Ct(function(n){return n.toLowerCase()})}function St(){return Ct(function(n){return n.toUpperCase()})}var Ot=Object.freeze({__proto__:null,endsWith:Zt,gt:yt,gte:gt,includes:Et,length:zt,lowercase:It,lt:mt,lte:_t,maxLength:kt,maxSize:function(n,e){return new Nn(o(o({check:"max_size"},L(e)),{},{maximum:n}))},mime:function(n,e){return new Qn(o({check:"mime_type",mime:n},L(e)))},minLength:bt,minSize:function(n,e){return new Mn(o(o({check:"min_size"},L(e)),{},{minimum:n}))},multipleOf:wt,negative:function(n){return mt(0,n)},nonnegative:function(n){return gt(0,n)},nonpositive:function(n){return _t(0,n)},normalize:At,overwrite:Ct,positive:function(n){return yt(0,n)},property:function(n,e,t){return new Xn(o({check:"property",property:n,schema:e},L(t)))},regex:xt,size:function(n,e){return new Fn(o(o({check:"size_equals"},L(e)),{},{size:n}))},startsWith:Pt,toLowerCase:Rt,toUpperCase:St,trim:Ut,uppercase:Tt}),$t=z("ZodISODateTime",function(n,e){_e.init(n,e),Qt.init(n,e)});function jt(n){return function(n,e){return new n(o({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null},L(e)))}($t,n)}var Nt=z("ZodISODate",function(n,e){ye.init(n,e),Qt.init(n,e)});function Mt(n){return function(n,e){return new n(o({type:"string",format:"date",check:"string_format"},L(e)))}(Nt,n)}var Ft=z("ZodISOTime",function(n,e){ge.init(n,e),Qt.init(n,e)});function Lt(n){return function(n,e){return new n(o({type:"string",format:"time",check:"string_format",precision:null},L(e)))}(Ft,n)}var Dt=z("ZodISODuration",function(n,e){we.init(n,e),Qt.init(n,e)});function Vt(n){return function(n,e){return new n(o({type:"string",format:"duration",check:"string_format"},L(e)))}(Dt,n)}var qt=z("ZodError",function(n,e){Y.init(n,e),n.name="ZodError",Object.defineProperties(n,{format:{value:function(e){return function(n,e){var t=e||function(n){return n.message},r={_errors:[]},o=function(n){var e,i=c(n.issues);try{for(i.s();!(e=i.n()).done;){var a=e.value;if("invalid_union"===a.code&&a.errors.length)a.errors.map(function(n){return o({issues:n})});else if("invalid_key"===a.code)o({issues:a.issues});else if("invalid_element"===a.code)o({issues:a.issues});else if(0===a.path.length)r._errors.push(t(a));else for(var u=r,s=0;s<a.path.length;){var l=a.path[s];s===a.path.length-1?(u[l]=u[l]||{_errors:[]},u[l]._errors.push(t(a))):u[l]=u[l]||{_errors:[]},u=u[l],s++}}}catch(n){i.e(n)}finally{i.f()}};return o(n),r}(n,e)}},flatten:{value:function(e){return function(n){var e,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(n){return n.message},r={},o=[],i=c(n.issues);try{for(i.s();!(e=i.n()).done;){var a=e.value;a.path.length>0?(r[a.path[0]]=r[a.path[0]]||[],r[a.path[0]].push(t(a))):o.push(t(a))}}catch(n){i.e(n)}finally{i.f()}return{formErrors:o,fieldErrors:r}}(n,e)}},addIssue:{value:function(e){return n.issues.push(e)}},addIssues:{value:function(e){var t;return(t=n.issues).push.apply(t,v(e))}},isEmpty:{get:function(){return 0===n.issues.length}}})},{Parent:Error}),Wt=Q(qt),Ht=nn(qt),Bt=en(qt),Gt=rn(qt),Jt=z("ZodType",function(n,e){return re.init(n,e),n.def=e,Object.defineProperty(n,"_def",{value:e}),n.check=function(){for(var t,r=arguments.length,i=new Array(r),a=0;a<r;a++)i[a]=arguments[a];return n.clone(o(o({},e),{},{checks:[].concat(v(null!==(t=e.checks)&&void 0!==t?t:[]),v(i.map(function(n){return"function"==typeof n?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n})))}))},n.clone=function(e,t){return F(n,e,t)},n.brand=function(){return n},n.register=function(e,t){return e.add(n,t),n},n.parse=function(e,t){return Wt(n,e,t,{callee:n.parse})},n.safeParse=function(e,t){return Bt(n,e,t)},n.parseAsync=function(){var e=i(a().m(function e(t,r){return a().w(function(e){for(;;)if(0===e.n)return e.a(2,Ht(n,t,r,{callee:n.parseAsync}))},e)}));return function(n,t){return e.apply(this,arguments)}}(),n.safeParseAsync=function(){var e=i(a().m(function e(t,r){return a().w(function(e){for(;;)if(0===e.n)return e.a(2,Gt(n,t,r))},e)}));return function(n,t){return e.apply(this,arguments)}}(),n.spa=n.safeParseAsync,n.refine=function(e,t){return n.check(function(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(n,e,t){return new n(o({type:"custom",check:"custom",fn:e},L(t)))}(io,n,e)}(e,t))},n.superRefine=function(e){return n.check((t=e,r=function(n){var e=new Un({check:"custom"});return e._zod.check=n,e}(function(n){return n.addIssue=function(e){if("string"==typeof e)n.issues.push(J(e,n.value,r._zod.def));else{var t,o,i,a,u=e;u.fatal&&(u.continue=!1),null!==(t=u.code)&&void 0!==t||(u.code="custom"),null!==(o=u.input)&&void 0!==o||(u.input=n.value),null!==(i=u.inst)&&void 0!==i||(u.inst=r),null!==(a=u.continue)&&void 0!==a||(u.continue=!r._zod.def.abort),n.issues.push(J(u))}},t(n.value,n)})));var t,r},n.overwrite=function(e){return n.check(Ct(e))},n.optional=function(){return Jr(n)},n.nullable=function(){return Yr(n)},n.nullish=function(){return Jr(Yr(n))},n.nonoptional=function(e){return function(n,e){return new no(o({type:"nonoptional",innerType:n},L(e)))}(n,e)},n.array=function(){return Ar(n)},n.or=function(e){return $r([n,e])},n.and=function(e){return Mr(n,e)},n.transform=function(e){return ro(n,Br(e))},n.default=function(e){return t=e,new Xr({type:"default",innerType:n,get defaultValue(){return"function"==typeof t?t():t}});var t},n.prefault=function(e){return t=e,new Qr({type:"prefault",innerType:n,get defaultValue(){return"function"==typeof t?t():t}});var t},n.catch=function(e){return new eo({type:"catch",innerType:n,catchValue:"function"==typeof(t=e)?t:function(){return t}});var t},n.pipe=function(e){return ro(n,e)},n.readonly=function(){return new oo({type:"readonly",innerType:n})},n.describe=function(e){var t=n.clone();return ft.add(t,{description:e}),t},Object.defineProperty(n,"description",{get:function(){var e;return null===(e=ft.get(n))||void 0===e?void 0:e.description},configurable:!0}),n.meta=function(){if(0===arguments.length)return ft.get(n);var e=n.clone();return ft.add(e,arguments.length<=0?void 0:arguments[0]),e},n.isOptional=function(){return n.safeParse(void 0).success},n.isNullable=function(){return n.safeParse(null).success},n}),Kt=z("_ZodString",function(n,e){var t,r,o;oe.init(n,e),Jt.init(n,e);var i=n._zod.bag;n.format=null!==(t=i.format)&&void 0!==t?t:null,n.minLength=null!==(r=i.minimum)&&void 0!==r?r:null,n.maxLength=null!==(o=i.maximum)&&void 0!==o?o:null,n.regex=function(){return n.check(xt.apply(Ot,arguments))},n.includes=function(){return n.check(Et.apply(Ot,arguments))},n.startsWith=function(){return n.check(Pt.apply(Ot,arguments))},n.endsWith=function(){return n.check(Zt.apply(Ot,arguments))},n.min=function(){return n.check(bt.apply(Ot,arguments))},n.max=function(){return n.check(kt.apply(Ot,arguments))},n.length=function(){return n.check(zt.apply(Ot,arguments))},n.nonempty=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.check(bt.apply(Ot,[1].concat(t)))},n.lowercase=function(e){return n.check(It(e))},n.uppercase=function(e){return n.check(Tt(e))},n.trim=function(){return n.check(Ut())},n.normalize=function(){return n.check(At.apply(Ot,arguments))},n.toLowerCase=function(){return n.check(Rt())},n.toUpperCase=function(){return n.check(St())}}),Yt=z("ZodString",function(n,e){oe.init(n,e),Kt.init(n,e),n.email=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"email",check:"string_format",abort:!1},L(e)))}(nr,e))},n.url=function(e){return n.check(vt(rr,e))},n.jwt=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"jwt",check:"string_format",abort:!1},L(e)))}(yr,e))},n.emoji=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"emoji",check:"string_format",abort:!1},L(e)))}(or,e))},n.guid=function(e){return n.check(ht(er,e))},n.uuid=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"uuid",check:"string_format",abort:!1},L(e)))}(tr,e))},n.uuidv4=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4"},L(e)))}(tr,e))},n.uuidv6=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6"},L(e)))}(tr,e))},n.uuidv7=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7"},L(e)))}(tr,e))},n.nanoid=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"nanoid",check:"string_format",abort:!1},L(e)))}(ir,e))},n.guid=function(e){return n.check(ht(er,e))},n.cuid=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"cuid",check:"string_format",abort:!1},L(e)))}(ar,e))},n.cuid2=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"cuid2",check:"string_format",abort:!1},L(e)))}(ur,e))},n.ulid=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"ulid",check:"string_format",abort:!1},L(e)))}(sr,e))},n.base64=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"base64",check:"string_format",abort:!1},L(e)))}(vr,e))},n.base64url=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"base64url",check:"string_format",abort:!1},L(e)))}(mr,e))},n.xid=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"xid",check:"string_format",abort:!1},L(e)))}(cr,e))},n.ksuid=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"ksuid",check:"string_format",abort:!1},L(e)))}(lr,e))},n.ipv4=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"ipv4",check:"string_format",abort:!1},L(e)))}(dr,e))},n.ipv6=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"ipv6",check:"string_format",abort:!1},L(e)))}(pr,e))},n.cidrv4=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"cidrv4",check:"string_format",abort:!1},L(e)))}(fr,e))},n.cidrv6=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"cidrv6",check:"string_format",abort:!1},L(e)))}(hr,e))},n.e164=function(e){return n.check(function(n,e){return new n(o({type:"string",format:"e164",check:"string_format",abort:!1},L(e)))}(_r,e))},n.datetime=function(e){return n.check(jt(e))},n.date=function(e){return n.check(Mt(e))},n.time=function(e){return n.check(Lt(e))},n.duration=function(e){return n.check(Vt(e))}});function Xt(n){return function(n,e){return new n(o({type:"string"},L(e)))}(Yt,n)}var Qt=z("ZodStringFormat",function(n,e){ie.init(n,e),Kt.init(n,e)}),nr=z("ZodEmail",function(n,e){se.init(n,e),Qt.init(n,e)}),er=z("ZodGUID",function(n,e){ae.init(n,e),Qt.init(n,e)}),tr=z("ZodUUID",function(n,e){ue.init(n,e),Qt.init(n,e)}),rr=z("ZodURL",function(n,e){ce.init(n,e),Qt.init(n,e)});var or=z("ZodEmoji",function(n,e){le.init(n,e),Qt.init(n,e)}),ir=z("ZodNanoID",function(n,e){de.init(n,e),Qt.init(n,e)}),ar=z("ZodCUID",function(n,e){pe.init(n,e),Qt.init(n,e)}),ur=z("ZodCUID2",function(n,e){fe.init(n,e),Qt.init(n,e)}),sr=z("ZodULID",function(n,e){he.init(n,e),Qt.init(n,e)}),cr=z("ZodXID",function(n,e){ve.init(n,e),Qt.init(n,e)}),lr=z("ZodKSUID",function(n,e){me.init(n,e),Qt.init(n,e)}),dr=z("ZodIPv4",function(n,e){ke.init(n,e),Qt.init(n,e)}),pr=z("ZodIPv6",function(n,e){be.init(n,e),Qt.init(n,e)}),fr=z("ZodCIDRv4",function(n,e){ze.init(n,e),Qt.init(n,e)}),hr=z("ZodCIDRv6",function(n,e){xe.init(n,e),Qt.init(n,e)}),vr=z("ZodBase64",function(n,e){Te.init(n,e),Qt.init(n,e)}),mr=z("ZodBase64URL",function(n,e){Ee.init(n,e),Qt.init(n,e)}),_r=z("ZodE164",function(n,e){Pe.init(n,e),Qt.init(n,e)}),yr=z("ZodJWT",function(n,e){Ze.init(n,e),Qt.init(n,e)}),gr=z("ZodNumber",function(n,e){var t,r,o,i,a,u,s,c,l;Ce.init(n,e),Jt.init(n,e),n.gt=function(e,t){return n.check(yt(e,t))},n.gte=function(e,t){return n.check(gt(e,t))},n.min=function(e,t){return n.check(gt(e,t))},n.lt=function(e,t){return n.check(mt(e,t))},n.lte=function(e,t){return n.check(_t(e,t))},n.max=function(e,t){return n.check(_t(e,t))},n.int=function(e){return n.check(br(e))},n.safe=function(e){return n.check(br(e))},n.positive=function(e){return n.check(yt(0,e))},n.nonnegative=function(e){return n.check(gt(0,e))},n.negative=function(e){return n.check(mt(0,e))},n.nonpositive=function(e){return n.check(_t(0,e))},n.multipleOf=function(e,t){return n.check(wt(e,t))},n.step=function(e,t){return n.check(wt(e,t))},n.finite=function(){return n};var d=n._zod.bag;n.minValue=null!==(t=Math.max(null!==(r=d.minimum)&&void 0!==r?r:Number.NEGATIVE_INFINITY,null!==(o=d.exclusiveMinimum)&&void 0!==o?o:Number.NEGATIVE_INFINITY))&&void 0!==t?t:null,n.maxValue=null!==(i=Math.min(null!==(a=d.maximum)&&void 0!==a?a:Number.POSITIVE_INFINITY,null!==(u=d.exclusiveMaximum)&&void 0!==u?u:Number.POSITIVE_INFINITY))&&void 0!==i?i:null,n.isInt=(null!==(s=d.format)&&void 0!==s?s:"").includes("int")||Number.isSafeInteger(null!==(c=d.multipleOf)&&void 0!==c?c:.5),n.isFinite=!0,n.format=null!==(l=d.format)&&void 0!==l?l:null});function wr(n){return function(n,e){return new n(o({type:"number",checks:[]},L(e)))}(gr,n)}var kr=z("ZodNumberFormat",function(n,e){Ae.init(n,e),gr.init(n,e)});function br(n){return function(n,e){return new n(o({type:"number",check:"number_format",abort:!1,format:"safeint"},L(e)))}(kr,n)}var zr=z("ZodBoolean",function(n,e){Ue.init(n,e),Jt.init(n,e)});function xr(n){return function(n,e){return new n(o({type:"boolean"},L(e)))}(zr,n)}var Ir=z("ZodAny",function(n,e){Re.init(n,e),Jt.init(n,e)});var Tr=z("ZodUnknown",function(n,e){Se.init(n,e),Jt.init(n,e)});function Er(){return new Tr({type:"unknown"})}var Pr=z("ZodNever",function(n,e){Oe.init(n,e),Jt.init(n,e)});function Zr(n){return function(n,e){return new n(o({type:"never"},L(e)))}(Pr,n)}var Cr=z("ZodArray",function(n,e){je.init(n,e),Jt.init(n,e),n.element=e.element,n.min=function(e,t){return n.check(bt(e,t))},n.nonempty=function(e){return n.check(bt(1,e))},n.max=function(e,t){return n.check(kt(e,t))},n.length=function(e,t){return n.check(zt(e,t))},n.unwrap=function(){return n.element}});function Ar(n,e){return function(n,e,t){return new n(o({type:"array",element:e},L(t)))}(Cr,n,e)}var Ur=z("ZodObject",function(n,e){Fe.init(n,e),Jt.init(n,e),A(n,"shape",function(){return e.shape}),n.keyof=function(){return Vr(Object.keys(n._zod.def.shape))},n.catchall=function(e){return n.clone(o(o({},n._zod.def),{},{catchall:e}))},n.passthrough=function(){return n.clone(o(o({},n._zod.def),{},{catchall:Er()}))},n.loose=function(){return n.clone(o(o({},n._zod.def),{},{catchall:Er()}))},n.strict=function(){return n.clone(o(o({},n._zod.def),{},{catchall:Zr()}))},n.strip=function(){return n.clone(o(o({},n._zod.def),{},{catchall:void 0}))},n.extend=function(e){return function(n,e){if(!j(e))throw new Error("Invalid input to extend: expected a plain object");var t=o(o({},n._zod.def),{},{get shape(){var t=o(o({},n._zod.def.shape),e);return U(this,"shape",t),t},checks:[]});return F(n,t)}(n,e)},n.merge=function(e){return r=e,F(t=n,o(o({},t._zod.def),{},{get shape(){var n=o(o({},t._zod.def.shape),r._zod.def.shape);return U(this,"shape",n),n},catchall:r._zod.def.catchall,checks:[]}));var t,r},n.pick=function(e){return function(n,e){var t={},r=n._zod.def;for(var i in e){if(!(i in r.shape))throw new Error('Unrecognized key: "'.concat(i,'"'));e[i]&&(t[i]=r.shape[i])}return F(n,o(o({},n._zod.def),{},{shape:t,checks:[]}))}(n,e)},n.omit=function(e){return function(n,e){var t=o({},n._zod.def.shape),r=n._zod.def;for(var i in e){if(!(i in r.shape))throw new Error('Unrecognized key: "'.concat(i,'"'));e[i]&&delete t[i]}return F(n,o(o({},n._zod.def),{},{shape:t,checks:[]}))}(n,e)},n.partial=function(){return function(n,e,t){var r=e._zod.def.shape,i=o({},r);if(t)for(var a in t){if(!(a in r))throw new Error('Unrecognized key: "'.concat(a,'"'));t[a]&&(i[a]=n?new n({type:"optional",innerType:r[a]}):r[a])}else for(var u in r)i[u]=n?new n({type:"optional",innerType:r[u]}):r[u];return F(e,o(o({},e._zod.def),{},{shape:i,checks:[]}))}(Gr,n,arguments.length<=0?void 0:arguments[0])},n.required=function(){return function(n,e,t){var r=e._zod.def.shape,i=o({},r);if(t)for(var a in t){if(!(a in i))throw new Error('Unrecognized key: "'.concat(a,'"'));t[a]&&(i[a]=new n({type:"nonoptional",innerType:r[a]}))}else for(var u in r)i[u]=new n({type:"nonoptional",innerType:r[u]});return F(e,o(o({},e._zod.def),{},{shape:i,checks:[]}))}(no,n,arguments.length<=0?void 0:arguments[0])}});function Rr(n,e){var t=o({type:"object",get shape(){return U(this,"shape",o({},n)),this.shape}},L(e));return new Ur(t)}function Sr(n,e){return new Ur(o({type:"object",get shape(){return U(this,"shape",o({},n)),this.shape},catchall:Er()},L(e)))}var Or=z("ZodUnion",function(n,e){De.init(n,e),Jt.init(n,e),n.options=e.options});function $r(n,e){return new Or(o({type:"union",options:n},L(e)))}var jr=z("ZodDiscriminatedUnion",function(n,e){Or.init(n,e),Ve.init(n,e)});var Nr=z("ZodIntersection",function(n,e){qe.init(n,e),Jt.init(n,e)});function Mr(n,e){return new Nr({type:"intersection",left:n,right:e})}var Fr=z("ZodRecord",function(n,e){Be.init(n,e),Jt.init(n,e),n.keyType=e.keyType,n.valueType=e.valueType});function Lr(n,e,t){return new Fr(o({type:"record",keyType:n,valueType:e},L(t)))}var Dr=z("ZodEnum",function(n,e){Ge.init(n,e),Jt.init(n,e),n.enum=e.entries,n.options=Object.values(e.entries);var t=new Set(Object.keys(e.entries));n.extract=function(n,r){var i,a={},u=c(n);try{for(u.s();!(i=u.n()).done;){var s=i.value;if(!t.has(s))throw new Error("Key ".concat(s," not found in enum"));a[s]=e.entries[s]}}catch(n){u.e(n)}finally{u.f()}return new Dr(o(o(o({},e),{},{checks:[]},L(r)),{},{entries:a}))},n.exclude=function(n,r){var i,a=o({},e.entries),u=c(n);try{for(u.s();!(i=u.n()).done;){var s=i.value;if(!t.has(s))throw new Error("Key ".concat(s," not found in enum"));delete a[s]}}catch(n){u.e(n)}finally{u.f()}return new Dr(o(o(o({},e),{},{checks:[]},L(r)),{},{entries:a}))}});function Vr(n,e){var t=Array.isArray(n)?Object.fromEntries(n.map(function(n){return[n,n]})):n;return new Dr(o({type:"enum",entries:t},L(e)))}var qr=z("ZodLiteral",function(n,e){Je.init(n,e),Jt.init(n,e),n.values=new Set(e.values),Object.defineProperty(n,"value",{get:function(){if(e.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return e.values[0]}})});function Wr(n,e){return new qr(o({type:"literal",values:Array.isArray(n)?n:[n]},L(e)))}var Hr=z("ZodTransform",function(n,e){Ke.init(n,e),Jt.init(n,e),n._zod.parse=function(t,r){t.addIssue=function(r){if("string"==typeof r)t.issues.push(J(r,t.value,e));else{var o,i,a,u,s=r;s.fatal&&(s.continue=!1),null!==(o=s.code)&&void 0!==o||(s.code="custom"),null!==(i=s.input)&&void 0!==i||(s.input=t.value),null!==(a=s.inst)&&void 0!==a||(s.inst=n),null!==(u=s.continue)&&void 0!==u||(s.continue=!0),t.issues.push(J(s))}};var o=e.transform(t.value,t);return o instanceof Promise?o.then(function(n){return t.value=n,t}):(t.value=o,t)}});function Br(n){return new Hr({type:"transform",transform:n})}var Gr=z("ZodOptional",function(n,e){Ye.init(n,e),Jt.init(n,e),n.unwrap=function(){return n._zod.def.innerType}});function Jr(n){return new Gr({type:"optional",innerType:n})}var Kr=z("ZodNullable",function(n,e){Xe.init(n,e),Jt.init(n,e),n.unwrap=function(){return n._zod.def.innerType}});function Yr(n){return new Kr({type:"nullable",innerType:n})}var Xr=z("ZodDefault",function(n,e){Qe.init(n,e),Jt.init(n,e),n.unwrap=function(){return n._zod.def.innerType},n.removeDefault=n.unwrap});var Qr=z("ZodPrefault",function(n,e){et.init(n,e),Jt.init(n,e),n.unwrap=function(){return n._zod.def.innerType}});var no=z("ZodNonOptional",function(n,e){tt.init(n,e),Jt.init(n,e),n.unwrap=function(){return n._zod.def.innerType}});var eo=z("ZodCatch",function(n,e){ot.init(n,e),Jt.init(n,e),n.unwrap=function(){return n._zod.def.innerType},n.removeCatch=n.unwrap});var to=z("ZodPipe",function(n,e){it.init(n,e),Jt.init(n,e),n.in=e.in,n.out=e.out});function ro(n,e){return new to({type:"pipe",in:n,out:e})}var oo=z("ZodReadonly",function(n,e){ut.init(n,e),Jt.init(n,e)});var io=z("ZodCustom",function(n,e){ct.init(n,e),Jt.init(n,e)});var ao,uo,so,co="custom",lo="2025-06-18",po="2.0",fo=function(n,e,t){var r,i=L(t);return null!==(r=i.abort)&&void 0!==r||(i.abort=!0),new n(o({type:"custom",check:"custom",fn:e},i))}(io,null!=(ao=function(n){return null!==n&&("object"===f(n)||"function"==typeof n)})?ao:function(){return!0},uo),ho=$r([Xt(),wr().int()]),vo=Xt(),mo=Sr({progressToken:ho.optional()}),_o=Sr({_meta:mo.optional()}),yo=Rr({method:Xt(),params:_o.optional()}),go=Sr({_meta:Lr(Xt(),Er()).optional()}),wo=Rr({method:Xt(),params:go.optional()}),ko=Sr({_meta:Lr(Xt(),Er()).optional()}),bo=$r([Xt(),wr().int()]),zo=Rr(o({jsonrpc:Wr(po),id:bo},yo.shape)).strict(),xo=function(n){return zo.safeParse(n).success},Io=Rr(o({jsonrpc:Wr(po)},wo.shape)).strict(),To=Rr({jsonrpc:Wr(po),id:bo,result:ko}).strict(),Eo=function(n){return To.safeParse(n).success};!function(n){n[n.ConnectionClosed=-32e3]="ConnectionClosed",n[n.RequestTimeout=-32001]="RequestTimeout",n[n.ParseError=-32700]="ParseError",n[n.InvalidRequest=-32600]="InvalidRequest",n[n.MethodNotFound=-32601]="MethodNotFound",n[n.InvalidParams=-32602]="InvalidParams",n[n.InternalError=-32603]="InternalError",n[n.UrlElicitationRequired=-32042]="UrlElicitationRequired"}(so||(so={}));var Po=Rr({jsonrpc:Wr(po),id:bo,error:Rr({code:wr().int(),message:Xt(),data:Jr(Er())})}).strict(),Zo=$r([zo,Io,To,Po]),Co=ko.strict(),Ao=go.extend({requestId:bo,reason:Xt().optional()}),Uo=wo.extend({method:Wr("notifications/cancelled"),params:Ao}),Ro=Rr({src:Xt(),mimeType:Xt().optional(),sizes:Ar(Xt()).optional()}),So=Rr({icons:Ar(Ro).optional()}),Oo=Rr({name:Xt(),title:Xt().optional()}),$o=Oo.extend(o(o(o({},Oo.shape),So.shape),{},{version:Xt(),websiteUrl:Xt().optional()})),jo=Mr(Rr({applyDefaults:xr().optional()}),Lr(Xt(),Er())),No=function(n,e){return ro(Br(n),e)}(function(n){return n&&"object"===f(n)&&!Array.isArray(n)&&0===Object.keys(n).length?{form:{}}:n},Mr(Rr({form:jo.optional(),url:fo.optional()}),Lr(Xt(),Er()).optional())),Mo=Rr({experimental:Lr(Xt(),fo).optional(),sampling:Rr({context:fo.optional(),tools:fo.optional()}).optional(),elicitation:No.optional(),roots:Rr({listChanged:xr().optional()}).optional()}),Fo=_o.extend({protocolVersion:Xt(),capabilities:Mo,clientInfo:$o}),Lo=yo.extend({method:Wr("initialize"),params:Fo}),Do=Rr({experimental:Lr(Xt(),fo).optional(),logging:fo.optional(),completions:fo.optional(),prompts:Jr(Rr({listChanged:Jr(xr())})),resources:Rr({subscribe:xr().optional(),listChanged:xr().optional()}).optional(),tools:Rr({listChanged:xr().optional()}).optional()}),Vo=ko.extend({protocolVersion:Xt(),capabilities:Do,serverInfo:$o,instructions:Xt().optional()}),qo=wo.extend({method:Wr("notifications/initialized")}),Wo=function(n){return qo.safeParse(n).success},Ho=yo.extend({method:Wr("ping")}),Bo=Rr({progress:wr(),total:Jr(wr()),message:Jr(Xt())}),Go=Rr(o(o(o({},go.shape),Bo.shape),{},{progressToken:ho})),Jo=wo.extend({method:Wr("notifications/progress"),params:Go}),Ko=_o.extend({cursor:vo.optional()}),Yo=yo.extend({params:Ko.optional()}),Xo=ko.extend({nextCursor:Jr(vo)}),Qo=Rr({uri:Xt(),mimeType:Jr(Xt()),_meta:Lr(Xt(),Er()).optional()}),ni=Qo.extend({text:Xt()}),ei=Xt().refine(function(n){try{return atob(n),!0}catch(n){return!1}},{message:"Invalid Base64 string"}),ti=Qo.extend({blob:ei}),ri=Rr(o(o(o({},Oo.shape),So.shape),{},{uri:Xt(),description:Jr(Xt()),mimeType:Jr(Xt()),_meta:Jr(Sr({}))})),oi=Rr(o(o(o({},Oo.shape),So.shape),{},{uriTemplate:Xt(),description:Jr(Xt()),mimeType:Jr(Xt()),_meta:Jr(Sr({}))})),ii=Yo.extend({method:Wr("resources/list")}),ai=Xo.extend({resources:Ar(ri)}),ui=Yo.extend({method:Wr("resources/templates/list")}),si=Xo.extend({resourceTemplates:Ar(oi)}),ci=_o.extend({uri:Xt()}),li=ci,di=yo.extend({method:Wr("resources/read"),params:li}),pi=ko.extend({contents:Ar($r([ni,ti]))}),fi=wo.extend({method:Wr("notifications/resources/list_changed")}),hi=ci,vi=yo.extend({method:Wr("resources/subscribe"),params:hi}),mi=ci,_i=yo.extend({method:Wr("resources/unsubscribe"),params:mi}),yi=go.extend({uri:Xt()}),gi=wo.extend({method:Wr("notifications/resources/updated"),params:yi}),wi=Rr({name:Xt(),description:Jr(Xt()),required:Jr(xr())}),ki=Rr(o(o(o({},Oo.shape),So.shape),{},{description:Jr(Xt()),arguments:Jr(Ar(wi)),_meta:Jr(Sr({}))})),bi=Yo.extend({method:Wr("prompts/list")}),zi=Xo.extend({prompts:Ar(ki)}),xi=_o.extend({name:Xt(),arguments:Lr(Xt(),Xt()).optional()}),Ii=yo.extend({method:Wr("prompts/get"),params:xi}),Ti=Rr({type:Wr("text"),text:Xt(),_meta:Lr(Xt(),Er()).optional()}),Ei=Rr({type:Wr("image"),data:ei,mimeType:Xt(),_meta:Lr(Xt(),Er()).optional()}),Pi=Rr({type:Wr("audio"),data:ei,mimeType:Xt(),_meta:Lr(Xt(),Er()).optional()}),Zi=Rr({type:Wr("tool_use"),name:Xt(),id:Xt(),input:Rr({}).passthrough(),_meta:Jr(Rr({}).passthrough())}).passthrough(),Ci=Rr({type:Wr("resource"),resource:$r([ni,ti]),_meta:Lr(Xt(),Er()).optional()}),Ai=$r([Ti,Ei,Pi,ri.extend({type:Wr("resource_link")}),Ci]),Ui=Rr({role:Vr(["user","assistant"]),content:Ai}),Ri=ko.extend({description:Jr(Xt()),messages:Ar(Ui)}),Si=wo.extend({method:Wr("notifications/prompts/list_changed")}),Oi=Rr({title:Xt().optional(),readOnlyHint:xr().optional(),destructiveHint:xr().optional(),idempotentHint:xr().optional(),openWorldHint:xr().optional()}),$i=Rr(o(o(o({},Oo.shape),So.shape),{},{description:Xt().optional(),inputSchema:Rr({type:Wr("object"),properties:Lr(Xt(),fo).optional(),required:Ar(Xt()).optional()}).catchall(Er()),outputSchema:Rr({type:Wr("object"),properties:Lr(Xt(),fo).optional(),required:Ar(Xt()).optional()}).catchall(Er()).optional(),annotations:Jr(Oi),_meta:Lr(Xt(),Er()).optional()})),ji=Yo.extend({method:Wr("tools/list")}),Ni=Xo.extend({tools:Ar($i)}),Mi=ko.extend({content:Ar(Ai).default([]),structuredContent:Lr(Xt(),Er()).optional(),isError:Jr(xr())});Mi.or(ko.extend({toolResult:Er()}));var Fi,Li=_o.extend({name:Xt(),arguments:Jr(Lr(Xt(),Er()))}),Di=yo.extend({method:Wr("tools/call"),params:Li}),Vi=wo.extend({method:Wr("notifications/tools/list_changed")}),qi=Vr(["debug","info","notice","warning","error","critical","alert","emergency"]),Wi=_o.extend({level:qi}),Hi=yo.extend({method:Wr("logging/setLevel"),params:Wi}),Bi=go.extend({level:qi,logger:Xt().optional(),data:Er()}),Gi=wo.extend({method:Wr("notifications/message"),params:Bi}),Ji=Rr({name:Xt().optional()}),Ki=Rr({hints:Jr(Ar(Ji)),costPriority:Jr(wr().min(0).max(1)),speedPriority:Jr(wr().min(0).max(1)),intelligencePriority:Jr(wr().min(0).max(1))}),Yi=Rr({mode:Jr(Vr(["auto","required","none"]))}),Xi=Rr({type:Wr("tool_result"),toolUseId:Xt().describe("The unique identifier for the corresponding tool call."),content:Ar(Ai).default([]),structuredContent:Rr({}).passthrough().optional(),isError:Jr(xr()),_meta:Jr(Rr({}).passthrough())}).passthrough(),Qi=new jr(o({type:"union",options:[Ti,Ei,Pi,Zi,Xi],discriminator:"type"},L(Fi))),na=Rr({role:Vr(["user","assistant"]),content:$r([Qi,Ar(Qi)]),_meta:Jr(Rr({}).passthrough())}).passthrough(),ea=_o.extend({messages:Ar(na),modelPreferences:Ki.optional(),systemPrompt:Xt().optional(),includeContext:Vr(["none","thisServer","allServers"]).optional(),temperature:wr().optional(),maxTokens:wr().int(),stopSequences:Ar(Xt()).optional(),metadata:fo.optional(),tools:Jr(Ar($i)),toolChoice:Jr(Yi)}),ta=yo.extend({method:Wr("sampling/createMessage"),params:ea}),ra=ko.extend({model:Xt(),stopReason:Jr(Vr(["endTurn","stopSequence","maxTokens","toolUse"]).or(Xt())),role:Vr(["user","assistant"]),content:$r([Qi,Ar(Qi)])}),oa=Rr({type:Wr("boolean"),title:Xt().optional(),description:Xt().optional(),default:xr().optional()}),ia=Rr({type:Wr("string"),title:Xt().optional(),description:Xt().optional(),minLength:wr().optional(),maxLength:wr().optional(),format:Vr(["email","uri","date","date-time"]).optional(),default:Xt().optional()}),aa=Rr({type:Vr(["number","integer"]),title:Xt().optional(),description:Xt().optional(),minimum:wr().optional(),maximum:wr().optional(),default:wr().optional()}),ua=Rr({type:Wr("string"),title:Xt().optional(),description:Xt().optional(),enum:Ar(Xt()),default:Xt().optional()}),sa=Rr({type:Wr("string"),title:Xt().optional(),description:Xt().optional(),oneOf:Ar(Rr({const:Xt(),title:Xt()})),default:Xt().optional()}),ca=Rr({type:Wr("string"),title:Xt().optional(),description:Xt().optional(),enum:Ar(Xt()),enumNames:Ar(Xt()).optional(),default:Xt().optional()}),la=$r([ua,sa]),da=$r([Rr({type:Wr("array"),title:Xt().optional(),description:Xt().optional(),minItems:wr().optional(),maxItems:wr().optional(),items:Rr({type:Wr("string"),enum:Ar(Xt())}),default:Ar(Xt()).optional()}),Rr({type:Wr("array"),title:Xt().optional(),description:Xt().optional(),minItems:wr().optional(),maxItems:wr().optional(),items:Rr({anyOf:Ar(Rr({const:Xt(),title:Xt()}))}),default:Ar(Xt()).optional()})]),pa=$r([ca,la,da]),fa=$r([pa,oa,ia,aa]),ha=$r([_o.extend({mode:Wr("form").optional(),message:Xt(),requestedSchema:Rr({type:Wr("object"),properties:Lr(Xt(),fa),required:Ar(Xt()).optional()})}),_o.extend({mode:Wr("url"),message:Xt(),elicitationId:Xt(),url:Xt().url()})]),va=yo.extend({method:Wr("elicitation/create"),params:ha}),ma=go.extend({elicitationId:Xt()}),_a=wo.extend({method:Wr("notifications/elicitation/complete"),params:ma}),ya=ko.extend({action:Vr(["accept","decline","cancel"]),content:Lr(Xt(),$r([Xt(),wr(),xr(),Ar(Xt())])).optional()}),ga=Rr({type:Wr("ref/resource"),uri:Xt()}),wa=Rr({type:Wr("ref/prompt"),name:Xt()}),ka=_o.extend({ref:$r([wa,ga]),argument:Rr({name:Xt(),value:Xt()}),context:Rr({arguments:Lr(Xt(),Xt()).optional()}).optional()}),ba=yo.extend({method:Wr("completion/complete"),params:ka}),za=ko.extend({completion:Sr({values:Ar(Xt()).max(100),total:Jr(wr().int()),hasMore:Jr(xr())})}),xa=Rr({uri:Xt().startsWith("file://"),name:Xt().optional(),_meta:Lr(Xt(),Er()).optional()}),Ia=yo.extend({method:Wr("roots/list")}),Ta=ko.extend({roots:Ar(xa)}),Ea=wo.extend({method:Wr("notifications/roots/list_changed")});$r([Ho,Lo,ba,Hi,Ii,bi,ii,ui,di,vi,_i,Di,ji]),$r([Uo,Jo,qo,Ea]),$r([Co,ra,ya,Ta]),$r([Ho,ta,va,Ia]),$r([Uo,Jo,Gi,gi,fi,Vi,Si,_a]),$r([Co,Vo,za,Ri,zi,ai,si,pi,Mi,Ni]);var Pa,Za=function(n){return vt(rr,n)}().superRefine(function(n,e){if(!URL.canParse(n))return e.addIssue({code:co,message:"URL must be parseable",fatal:!0}),b}).refine(function(n){var e=new URL(n);return"javascript:"!==e.protocol&&"data:"!==e.protocol&&"vbscript:"!==e.protocol},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),Ca=Sr({resource:Xt().url(),authorization_servers:Ar(Za).optional(),jwks_uri:Xt().url().optional(),scopes_supported:Ar(Xt()).optional(),bearer_methods_supported:Ar(Xt()).optional(),resource_signing_alg_values_supported:Ar(Xt()).optional(),resource_name:Xt().optional(),resource_documentation:Xt().optional(),resource_policy_uri:Xt().url().optional(),resource_tos_uri:Xt().url().optional(),tls_client_certificate_bound_access_tokens:xr().optional(),authorization_details_types_supported:Ar(Xt()).optional(),dpop_signing_alg_values_supported:Ar(Xt()).optional(),dpop_bound_access_tokens_required:xr().optional()}),Aa=Sr({issuer:Xt(),authorization_endpoint:Za,token_endpoint:Za,registration_endpoint:Za.optional(),scopes_supported:Ar(Xt()).optional(),response_types_supported:Ar(Xt()),response_modes_supported:Ar(Xt()).optional(),grant_types_supported:Ar(Xt()).optional(),token_endpoint_auth_methods_supported:Ar(Xt()).optional(),token_endpoint_auth_signing_alg_values_supported:Ar(Xt()).optional(),service_documentation:Za.optional(),revocation_endpoint:Za.optional(),revocation_endpoint_auth_methods_supported:Ar(Xt()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Ar(Xt()).optional(),introspection_endpoint:Xt().optional(),introspection_endpoint_auth_methods_supported:Ar(Xt()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Ar(Xt()).optional(),code_challenge_methods_supported:Ar(Xt()).optional(),client_id_metadata_document_supported:xr().optional()}),Ua=Sr({issuer:Xt(),authorization_endpoint:Za,token_endpoint:Za,userinfo_endpoint:Za.optional(),jwks_uri:Za,registration_endpoint:Za.optional(),scopes_supported:Ar(Xt()).optional(),response_types_supported:Ar(Xt()),response_modes_supported:Ar(Xt()).optional(),grant_types_supported:Ar(Xt()).optional(),acr_values_supported:Ar(Xt()).optional(),subject_types_supported:Ar(Xt()),id_token_signing_alg_values_supported:Ar(Xt()),id_token_encryption_alg_values_supported:Ar(Xt()).optional(),id_token_encryption_enc_values_supported:Ar(Xt()).optional(),userinfo_signing_alg_values_supported:Ar(Xt()).optional(),userinfo_encryption_alg_values_supported:Ar(Xt()).optional(),userinfo_encryption_enc_values_supported:Ar(Xt()).optional(),request_object_signing_alg_values_supported:Ar(Xt()).optional(),request_object_encryption_alg_values_supported:Ar(Xt()).optional(),request_object_encryption_enc_values_supported:Ar(Xt()).optional(),token_endpoint_auth_methods_supported:Ar(Xt()).optional(),token_endpoint_auth_signing_alg_values_supported:Ar(Xt()).optional(),display_values_supported:Ar(Xt()).optional(),claim_types_supported:Ar(Xt()).optional(),claims_supported:Ar(Xt()).optional(),service_documentation:Xt().optional(),claims_locales_supported:Ar(Xt()).optional(),ui_locales_supported:Ar(Xt()).optional(),claims_parameter_supported:xr().optional(),request_parameter_supported:xr().optional(),request_uri_parameter_supported:xr().optional(),require_request_uri_registration:xr().optional(),op_policy_uri:Za.optional(),op_tos_uri:Za.optional(),client_id_metadata_document_supported:xr().optional()}),Ra=Rr(o(o({},Ua.shape),Aa.pick({code_challenge_methods_supported:!0}).shape)),Sa=Rr({access_token:Xt(),id_token:Xt().optional(),token_type:Xt(),expires_in:wr().optional(),scope:Xt().optional(),refresh_token:Xt().optional()}).strip(),Oa=Rr({error:Xt(),error_description:Xt().optional(),error_uri:Xt().optional()}),$a=Za.optional().or(Wr("").transform(function(){})),ja=Rr({redirect_uris:Ar(Za),token_endpoint_auth_method:Xt().optional(),grant_types:Ar(Xt()).optional(),response_types:Ar(Xt()).optional(),client_name:Xt().optional(),client_uri:Za.optional(),logo_uri:$a,scope:Xt().optional(),contacts:Ar(Xt()).optional(),tos_uri:$a,policy_uri:Xt().optional(),jwks_uri:Za.optional(),jwks:new Ir({type:"any"}).optional(),software_id:Xt().optional(),software_version:Xt().optional(),software_statement:Xt().optional()}).strip(),Na=Rr({client_id:Xt(),client_secret:Xt().optional(),client_id_issued_at:wr().optional(),client_secret_expires_at:wr().optional()}).strip(),Ma=ja.merge(Na);function Fa(n){var e="string"==typeof n?new URL(n):new URL(n.href);return e.hash="",e}function La(n){var e=n.requestedResource,t=n.configuredResource,r="string"==typeof e?new URL(e):new URL(e.href),o="string"==typeof t?new URL(t):new URL(t.href);if(r.origin!==o.origin)return!1;if(r.pathname.length<o.pathname.length)return!1;var i=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",a=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return i.startsWith(a)}Rr({error:Xt(),error_description:Xt().optional()}).strip(),Rr({token:Xt(),token_type_hint:Xt().optional()}).strip();var Da=function(n){function e(n,t){var r;return l(this,e),(r=d(this,e,[n])).errorUri=t,r.name=r.constructor.name,r}return u(e,n),s(e,[{key:"toResponseObject",value:function(){var n={error:this.errorCode,error_description:this.message};return this.errorUri&&(n.error_uri=this.errorUri),n}},{key:"errorCode",get:function(){return this.constructor.errorCode}}])}(p(Error)),Va=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();Va.errorCode="invalid_request";var qa=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();qa.errorCode="invalid_client";var Wa=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();Wa.errorCode="invalid_grant";var Ha=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();Ha.errorCode="unauthorized_client";var Ba=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();Ba.errorCode="unsupported_grant_type";var Ga=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();Ga.errorCode="invalid_scope";var Ja=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();Ja.errorCode="access_denied";var Ka=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();Ka.errorCode="server_error";var Ya=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();Ya.errorCode="temporarily_unavailable";var Xa=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();Xa.errorCode="unsupported_response_type";var Qa=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();Qa.errorCode="unsupported_token_type";var nu=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();nu.errorCode="invalid_token";var eu=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();eu.errorCode="method_not_allowed";var tu=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();tu.errorCode="too_many_requests";var ru=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();ru.errorCode="invalid_client_metadata";var ou=function(){function n(){return l(this,n),d(this,n,arguments)}return u(n,Da),s(n)}();ou.errorCode="insufficient_scope";var iu=(_(_(_(_(_(_(_(_(_(_(Pa={},Va.errorCode,Va),qa.errorCode,qa),Wa.errorCode,Wa),Ha.errorCode,Ha),Ba.errorCode,Ba),Ga.errorCode,Ga),Ja.errorCode,Ja),Ka.errorCode,Ka),Ya.errorCode,Ya),Xa.errorCode,Xa),_(_(_(_(_(_(Pa,Qa.errorCode,Qa),nu.errorCode,nu),eu.errorCode,eu),tu.errorCode,tu),ru.errorCode,ru),ou.errorCode,ou)),au=function(n){function e(n){return l(this,e),d(this,e,[null!=n?n:"Unauthorized"])}return u(e,n),s(e)}(p(Error));var uu="code",su="S256";function cu(n,e){var t,r=void 0!==n.client_secret;return 0===e.length?r?"client_secret_post":"none":"token_endpoint_auth_method"in n&&n.token_endpoint_auth_method&&(t=n.token_endpoint_auth_method,["client_secret_basic","client_secret_post","none"].includes(t))&&e.includes(n.token_endpoint_auth_method)?n.token_endpoint_auth_method:r&&e.includes("client_secret_basic")?"client_secret_basic":r&&e.includes("client_secret_post")?"client_secret_post":e.includes("none")?"none":r?"client_secret_post":"none"}function lu(n,e,t,r){var o=e.client_id,i=e.client_secret;switch(n){case"client_secret_basic":return void function(n,e,t){if(!e)throw new Error("client_secret_basic authentication requires a client_secret");var r=btoa("".concat(n,":").concat(e));t.set("Authorization","Basic ".concat(r))}(o,i,t);case"client_secret_post":return void function(n,e,t){t.set("client_id",n),e&&t.set("client_secret",e)}(o,i,r);case"none":return void function(n,e){e.set("client_id",n)}(o,r);default:throw new Error("Unsupported client authentication method: ".concat(n))}}function du(n){return pu.apply(this,arguments)}function pu(){return(pu=i(a().m(function n(e){var t,r,o,i,u,s,c,l,d,p;return a().w(function(n){for(;;)switch(n.p=n.n){case 0:if(t=e instanceof Response?e.status:void 0,!(e instanceof Response)){n.n=2;break}return n.n=1,e.text();case 1:d=n.v,n.n=3;break;case 2:d=e;case 3:return r=d,n.p=4,o=Oa.parse(JSON.parse(r)),i=o.error,u=o.error_description,s=o.error_uri,c=iu[i]||Ka,n.a(2,new c(u||"",s));case 5:return n.p=5,p=n.v,l="".concat(t?"HTTP ".concat(t,": "):"","Invalid OAuth error response: ").concat(p,". Raw body: ").concat(r),n.a(2,new Ka(l))}},n,null,[[4,5]])}))).apply(this,arguments)}function fu(n,e){return hu.apply(this,arguments)}function hu(){return hu=i(a().m(function n(e,t){var r,o,i;return a().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,n.n=1,vu(e,t);case 1:case 4:case 7:return n.a(2,n.v);case 2:if(n.p=2,!((i=n.v)instanceof qa||i instanceof Ha)){n.n=5;break}return n.n=3,null===(r=e.invalidateCredentials)||void 0===r?void 0:r.call(e,"all");case 3:return n.n=4,vu(e,t);case 5:if(!(i instanceof Wa)){n.n=8;break}return n.n=6,null===(o=e.invalidateCredentials)||void 0===o?void 0:o.call(e,"tokens");case 6:return n.n=7,vu(e,t);case 8:throw i;case 9:return n.a(2)}},n,null,[[0,2]])})),hu.apply(this,arguments)}function vu(n,e){return mu.apply(this,arguments)}function mu(){return(mu=i(a().m(function n(e,t){var r,o,i,u,s,c,l,d,p,f,h,v,m,_,y,g,w,k,b,z,x,I,T,E,P;return a().w(function(n){for(;;)switch(n.p=n.n){case 0:return r=t.serverUrl,o=t.authorizationCode,i=t.scope,u=t.resourceMetadataUrl,s=t.fetchFn,n.p=1,n.n=2,bu(r,{resourceMetadataUrl:u},s);case 2:(d=n.v).authorization_servers&&d.authorization_servers.length>0&&(p=d.authorization_servers[0]),n.n=4;break;case 3:n.p=3,n.v;case 4:return p||(p=new URL("/",r)),n.n=5,yu(r,e,d);case 5:return f=n.v,n.n=6,Ru(p,{fetchFn:s});case 6:return h=n.v,n.n=7,Promise.resolve(e.clientInformation());case 7:if(v=n.v){n.n=15;break}if(void 0===o){n.n=8;break}throw new Error("Existing OAuth client information is required when exchanging an authorization code");case 8:if(m=!0===(null==h?void 0:h.client_id_metadata_document_supported),!(_=e.clientMetadataUrl)||_u(_)){n.n=9;break}throw new ru("clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ".concat(_));case 9:if(!(m&&_)){n.n=11;break}return v={client_id:_},n.n=10,null===(c=e.saveClientInformation)||void 0===c?void 0:c.call(e,v);case 10:n.n=15;break;case 11:if(e.saveClientInformation){n.n=12;break}throw new Error("OAuth client information must be saveable for dynamic registration");case 12:return n.n=13,Lu(p,{metadata:h,clientMetadata:e.clientMetadata,fetchFn:s});case 13:return y=n.v,n.n=14,e.saveClientInformation(y);case 14:v=y;case 15:if(void 0===o){n.n=19;break}return n.n=16,e.codeVerifier();case 16:return g=n.v,n.n=17,ju(p,{metadata:h,clientInformation:v,authorizationCode:o,codeVerifier:g,redirectUri:e.redirectUrl,resource:f,addClientAuthentication:e.addClientAuthentication,fetchFn:s});case 17:return w=n.v,n.n=18,e.saveTokens(w);case 18:return n.a(2,"AUTHORIZED");case 19:return n.n=20,e.tokens();case 20:if(!(null==(k=n.v)?void 0:k.refresh_token)){n.n=26;break}return n.p=21,n.n=22,Mu(p,{metadata:h,clientInformation:v,refreshToken:k.refresh_token,resource:f,addClientAuthentication:e.addClientAuthentication,fetchFn:s});case 22:return b=n.v,n.n=23,e.saveTokens(b);case 23:return n.a(2,"AUTHORIZED");case 24:if(n.p=24,(E=n.v)instanceof Da&&!(E instanceof Ka)){n.n=25;break}n.n=26;break;case 25:throw E;case 26:if(!e.state){n.n=28;break}return n.n=27,e.state();case 27:P=n.v,n.n=29;break;case 28:P=void 0;case 29:return z=P,n.n=30,Ou(p,{metadata:h,clientInformation:v,state:z,redirectUrl:e.redirectUrl,scope:i||(null===(l=null==d?void 0:d.scopes_supported)||void 0===l?void 0:l.join(" "))||e.clientMetadata.scope,resource:f});case 30:return x=n.v,I=x.authorizationUrl,T=x.codeVerifier,n.n=31,e.saveCodeVerifier(T);case 31:return n.n=32,e.redirectToAuthorization(I);case 32:return n.a(2,"REDIRECT")}},n,null,[[21,24],[1,3]])}))).apply(this,arguments)}function _u(n){if(!n)return!1;try{var e=new URL(n);return"https:"===e.protocol&&"/"!==e.pathname}catch(n){return!1}}function yu(n,e,t){return gu.apply(this,arguments)}function gu(){return(gu=i(a().m(function n(e,t,r){var o;return a().w(function(n){for(;;)switch(n.n){case 0:if(o=Fa(e),!t.validateResourceURL){n.n=2;break}return n.n=1,t.validateResourceURL(o,null==r?void 0:r.resource);case 1:return n.a(2,n.v);case 2:if(r){n.n=3;break}return n.a(2,void 0);case 3:if(La({requestedResource:o,configuredResource:r.resource})){n.n=4;break}throw new Error("Protected resource ".concat(r.resource," does not match expected ").concat(o," (or origin)"));case 4:return n.a(2,new URL(r.resource))}},n)}))).apply(this,arguments)}function wu(n){var e=n.headers.get("WWW-Authenticate");if(!e)return{};var t=e.split(" "),r=h(t,2),o=r[0],i=r[1];if("bearer"!==o.toLowerCase()||!i)return{};var a,u=ku(n,"resource_metadata")||void 0;if(u)try{a=new URL(u)}catch(n){}return{resourceMetadataUrl:a,scope:ku(n,"scope")||void 0,error:ku(n,"error")||void 0}}function ku(n,e){var t=n.headers.get("WWW-Authenticate");if(!t)return null;var r=new RegExp("".concat(e,'=(?:"([^"]+)"|([^\\s,]+))')),o=t.match(r);return o?o[1]||o[2]:null}function bu(n,e){return zu.apply(this,arguments)}function zu(){return zu=i(a().m(function n(e,t){var r,o,i,u=arguments;return a().w(function(n){for(;;)switch(n.n){case 0:return r=u.length>2&&void 0!==u[2]?u[2]:fetch,n.n=1,Cu(e,"oauth-protected-resource",r,{protocolVersion:null==t?void 0:t.protocolVersion,metadataUrl:null==t?void 0:t.resourceMetadataUrl});case 1:if((o=n.v)&&404!==o.status){n.n=2;break}throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");case 2:if(o.ok){n.n=3;break}throw new Error("HTTP ".concat(o.status," trying to load well-known OAuth protected resource metadata."));case 3:return i=Ca,n.n=4,o.json();case 4:return n.a(2,i.parse.call(i,n.v))}},n)})),zu.apply(this,arguments)}function xu(n,e){return Iu.apply(this,arguments)}function Iu(){return Iu=i(a().m(function n(e,t){var r,o,i=arguments;return a().w(function(n){for(;;)switch(n.p=n.n){case 0:return r=i.length>2&&void 0!==i[2]?i[2]:fetch,n.p=1,n.n=2,r(e,{headers:t});case 2:return n.a(2,n.v);case 3:if(n.p=3,!((o=n.v)instanceof TypeError)){n.n=5;break}if(!t){n.n=4;break}return n.a(2,xu(e,void 0,r));case 4:return n.a(2,void 0);case 5:throw o;case 6:return n.a(2)}},n,null,[[1,3]])})),Iu.apply(this,arguments)}function Tu(n){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.endsWith("/")&&(e=e.slice(0,-1)),t.prependPathname?"".concat(e,"/.well-known/").concat(n):"/.well-known/".concat(n).concat(e)}function Eu(n,e){return Pu.apply(this,arguments)}function Pu(){return Pu=i(a().m(function n(e,t){var r,o,i=arguments;return a().w(function(n){for(;;)switch(n.n){case 0:return r=i.length>2&&void 0!==i[2]?i[2]:fetch,o={"MCP-Protocol-Version":t},n.n=1,xu(e,o,r);case 1:return n.a(2,n.v)}},n)})),Pu.apply(this,arguments)}function Zu(n,e){return!n||n.status>=400&&n.status<500&&"/"!==e}function Cu(n,e,t,r){return Au.apply(this,arguments)}function Au(){return Au=i(a().m(function n(e,t,r,o){var i,u,s,c,l,d,p,f;return a().w(function(n){for(;;)switch(n.n){case 0:return s=new URL(e),c=null!==(i=null==o?void 0:o.protocolVersion)&&void 0!==i?i:lo,(null==o?void 0:o.metadataUrl)?l=new URL(o.metadataUrl):(d=Tu(t,s.pathname),(l=new URL(d,null!==(u=null==o?void 0:o.metadataServerUrl)&&void 0!==u?u:s)).search=s.search),n.n=1,Eu(l,c,r);case 1:if(p=n.v,(null==o?void 0:o.metadataUrl)||!Zu(p,s.pathname)){n.n=3;break}return f=new URL("/.well-known/".concat(t),s),n.n=2,Eu(f,c,r);case 2:p=n.v;case 3:return n.a(2,p)}},n)})),Au.apply(this,arguments)}function Uu(n){var e="string"==typeof n?new URL(n):n,t=[];if(!("/"!==e.pathname))return t.push({url:new URL("/.well-known/oauth-authorization-server",e.origin),type:"oauth"}),t.push({url:new URL("/.well-known/openid-configuration",e.origin),type:"oidc"}),t;var r=e.pathname;return r.endsWith("/")&&(r=r.slice(0,-1)),t.push({url:new URL("/.well-known/oauth-authorization-server".concat(r),e.origin),type:"oauth"}),t.push({url:new URL("/.well-known/openid-configuration".concat(r),e.origin),type:"oidc"}),t.push({url:new URL("".concat(r,"/.well-known/openid-configuration"),e.origin),type:"oidc"}),t}function Ru(n){return Su.apply(this,arguments)}function Su(){return Su=i(a().m(function n(e){var t,r,o,i,u,s,l,d,p,f,h,v,m,_,y,g=arguments;return a().w(function(n){for(;;)switch(n.p=n.n){case 0:r=(t=g.length>1&&void 0!==g[1]?g[1]:{}).fetchFn,o=void 0===r?fetch:r,i=t.protocolVersion,u={"MCP-Protocol-Version":void 0===i?lo:i,Accept:"application/json"},s=Uu(e),l=c(s),n.p=1,l.s();case 2:if((d=l.n()).done){n.n=11;break}return p=d.value,f=p.url,h=p.type,n.n=3,xu(f,u,o);case 3:if(v=n.v){n.n=4;break}return n.a(3,10);case 4:if(v.ok){n.n=6;break}if(!(v.status>=400&&v.status<500)){n.n=5;break}return n.a(3,10);case 5:throw new Error("HTTP ".concat(v.status," trying to load ").concat("oauth"===h?"OAuth":"OpenID provider"," metadata from ").concat(f));case 6:if("oauth"!==h){n.n=8;break}return m=Aa,n.n=7,v.json();case 7:return n.a(2,m.parse.call(m,n.v));case 8:return _=Ra,n.n=9,v.json();case 9:return n.a(2,_.parse.call(_,n.v));case 10:n.n=2;break;case 11:n.n=13;break;case 12:n.p=12,y=n.v,l.e(y);case 13:return n.p=13,l.f(),n.f(13);case 14:return n.a(2,void 0)}},n,null,[[1,12,13,14]])})),Su.apply(this,arguments)}function Ou(n,e){return $u.apply(this,arguments)}function $u(){return($u=i(a().m(function n(e,t){var r,o,i,u,s,c,l,d,p,f;return a().w(function(n){for(;;)switch(n.n){case 0:if(r=t.metadata,o=t.clientInformation,i=t.redirectUrl,u=t.scope,s=t.state,c=t.resource,!r){n.n=3;break}if(l=new URL(r.authorization_endpoint),r.response_types_supported.includes(uu)){n.n=1;break}throw new Error("Incompatible auth server: does not support response type ".concat(uu));case 1:if(!r.code_challenge_methods_supported||r.code_challenge_methods_supported.includes(su)){n.n=2;break}throw new Error("Incompatible auth server: does not support code challenge method ".concat(su));case 2:n.n=4;break;case 3:l=new URL("/authorize",e);case 4:return n.n=5,y();case 5:return d=n.v,p=d.code_verifier,f=d.code_challenge,l.searchParams.set("response_type",uu),l.searchParams.set("client_id",o.client_id),l.searchParams.set("code_challenge",f),l.searchParams.set("code_challenge_method",su),l.searchParams.set("redirect_uri",String(i)),s&&l.searchParams.set("state",s),u&&l.searchParams.set("scope",u),(null==u?void 0:u.includes("offline_access"))&&l.searchParams.append("prompt","consent"),c&&l.searchParams.set("resource",c.href),n.a(2,{authorizationUrl:l,codeVerifier:p})}},n)}))).apply(this,arguments)}function ju(n,e){return Nu.apply(this,arguments)}function Nu(){return Nu=i(a().m(function n(e,t){var r,o,i,u,s,c,l,d,p,f,h,v,m,_,y,g;return a().w(function(n){for(;;)switch(n.n){case 0:if(r=t.metadata,o=t.clientInformation,i=t.authorizationCode,u=t.codeVerifier,s=t.redirectUri,c=t.resource,l=t.addClientAuthentication,d=t.fetchFn,f="authorization_code",h=(null==r?void 0:r.token_endpoint)?new URL(r.token_endpoint):new URL("/token",e),!(null==r?void 0:r.grant_types_supported)||r.grant_types_supported.includes(f)){n.n=1;break}throw new Error("Incompatible auth server: does not support grant type ".concat(f));case 1:return v=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),m=new URLSearchParams({grant_type:f,code:i,code_verifier:u,redirect_uri:String(s)}),l?l(v,m,e,r):(_=null!==(p=null==r?void 0:r.token_endpoint_auth_methods_supported)&&void 0!==p?p:[],lu(cu(o,_),o,v,m)),c&&m.set("resource",c.href),n.n=2,(null!=d?d:fetch)(h,{method:"POST",headers:v,body:m});case 2:if((y=n.v).ok){n.n=4;break}return n.n=3,du(y);case 3:throw n.v;case 4:return g=Sa,n.n=5,y.json();case 5:return n.a(2,g.parse.call(g,n.v))}},n)})),Nu.apply(this,arguments)}function Mu(n,e){return Fu.apply(this,arguments)}function Fu(){return Fu=i(a().m(function n(e,t){var r,i,u,s,c,l,d,p,f,h,v,m,_,y,g,w;return a().w(function(n){for(;;)switch(n.n){case 0:if(r=t.metadata,i=t.clientInformation,u=t.refreshToken,s=t.resource,c=t.addClientAuthentication,l=t.fetchFn,p="refresh_token",!r){n.n=2;break}if(f=new URL(r.token_endpoint),!r.grant_types_supported||r.grant_types_supported.includes(p)){n.n=1;break}throw new Error("Incompatible auth server: does not support grant type ".concat(p));case 1:n.n=3;break;case 2:f=new URL("/token",e);case 3:return h=new Headers({"Content-Type":"application/x-www-form-urlencoded"}),v=new URLSearchParams({grant_type:p,refresh_token:u}),c?c(h,v,e,r):(m=null!==(d=null==r?void 0:r.token_endpoint_auth_methods_supported)&&void 0!==d?d:[],lu(cu(i,m),i,h,v)),s&&v.set("resource",s.href),n.n=4,(null!=l?l:fetch)(f,{method:"POST",headers:h,body:v});case 4:if((_=n.v).ok){n.n=6;break}return n.n=5,du(_);case 5:throw n.v;case 6:return y=Sa,g=o,w={refresh_token:u},n.n=7,_.json();case 7:return n.a(2,y.parse.call(y,g(w,n.v)))}},n)})),Fu.apply(this,arguments)}function Lu(n,e){return Du.apply(this,arguments)}function Du(){return(Du=i(a().m(function n(e,t){var r,o,i,u,s,c;return a().w(function(n){for(;;)switch(n.n){case 0:if(r=t.metadata,o=t.clientMetadata,i=t.fetchFn,!r){n.n=2;break}if(r.registration_endpoint){n.n=1;break}throw new Error("Incompatible auth server: does not support dynamic client registration");case 1:u=new URL(r.registration_endpoint),n.n=3;break;case 2:u=new URL("/register",e);case 3:return n.n=4,(null!=i?i:fetch)(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});case 4:if((s=n.v).ok){n.n=6;break}return n.n=5,du(s);case 5:throw n.v;case 6:return c=Ma,n.n=7,s.json();case 7:return n.a(2,c.parse.call(c,n.v))}},n)}))).apply(this,arguments)}var Vu=function(n){function e(n,t){var r;return l(this,e),(r=d(this,e,[n])).name="ParseError",r.type=t.type,r.field=t.field,r.value=t.value,r.line=t.line,r}return u(e,n),s(e)}(p(Error));function qu(n){}function Wu(n){if("function"==typeof n)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");var e,t=n.onEvent,r=void 0===t?qu:t,o=n.onError,i=void 0===o?qu:o,a=n.onRetry,u=void 0===a?qu:a,s=n.onComment,l="",d=!0,p="",f="";function v(n){if(""===n)return p.length>0&&r({id:e,event:f||void 0,data:p.endsWith("\n")?p.slice(0,-1):p}),e=void 0,p="",void(f="");if(n.startsWith(":"))s&&s(n.slice(n.startsWith(": ")?2:1));else{var t=n.indexOf(":");if(-1===t)m(n,"",n);else{var o=n.slice(0,t),i=" "===n[t+1]?2:1;m(o,n.slice(t+i),n)}}}function m(n,t,r){switch(n){case"event":f=t;break;case"data":p="".concat(p).concat(t,"\n");break;case"id":e=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?u(parseInt(t,10)):i(new Vu('Invalid `retry` value: "'.concat(t,'"'),{type:"invalid-retry",value:t,line:r}));break;default:i(new Vu('Unknown field "'.concat(n.length>20?"".concat(n.slice(0,20),"…"):n,'"'),{type:"unknown-field",field:n,value:t,line:r}))}}return{feed:function(n){var e,t=d?n.replace(/^\xEF\xBB\xBF/,""):n,r=function(n){for(var e=[],t="",r=0;r<n.length;){var o=n.indexOf("\r",r),i=n.indexOf("\n",r),a=-1;if(-1!==o&&-1!==i?a=Math.min(o,i):-1!==o?a=o===n.length-1?-1:o:-1!==i&&(a=i),-1===a){t=n.slice(r);break}var u=n.slice(r,a);e.push(u),"\r"===n[(r=a+1)-1]&&"\n"===n[r]&&r++}return[e,t]}("".concat(l).concat(t)),o=h(r,2),i=o[0],a=o[1],u=c(i);try{for(u.s();!(e=u.n()).done;){v(e.value)}}catch(n){u.e(n)}finally{u.f()}l=a,d=!1},reset:function(){l&&(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).consume&&v(l),d=!0,e=void 0,p="",f="",l=""}}}var Hu=function(n){function e(){var n,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.onError,o=t.onRetry,i=t.onComment;return l(this,e),d(this,e,[{start:function(e){n=Wu({onEvent:function(n){e.enqueue(n)},onError:function(n){"terminate"===r?e.error(n):"function"==typeof r&&r(n)},onRetry:o,onComment:i})},transform:function(e){n.feed(e)}}])}return u(e,n),s(e)}(p(TransformStream)),Bu={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},Gu=function(n){function e(n,t){var r;return l(this,e),(r=d(this,e,["Streamable HTTP error: ".concat(t)])).code=n,r}return u(e,n),s(e)}(p(Error)),Ju=function(){return s(function n(e,t){var r;l(this,n),this._hasCompletedAuthFlow=!1,this._url=e,this._resourceMetadataUrl=void 0,this._scope=void 0,this._requestInit=null==t?void 0:t.requestInit,this._authProvider=null==t?void 0:t.authProvider,this._fetch=null==t?void 0:t.fetch,this._fetchWithInit=function(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:fetch,e=arguments.length>1?arguments[1]:void 0;return e?function(){var t=i(a().m(function t(r,i){var u;return a().w(function(t){for(;;)if(0===t.n)return u=o(o(o({},e),i),{},{headers:(null==i?void 0:i.headers)?o(o({},k(e.headers)),k(i.headers)):e.headers}),t.a(2,n(r,u))},t)}));return function(n,e){return t.apply(this,arguments)}}():n}(null==t?void 0:t.fetch,null==t?void 0:t.requestInit),this._sessionId=null==t?void 0:t.sessionId,this._reconnectionOptions=null!==(r=null==t?void 0:t.reconnectionOptions)&&void 0!==r?r:Bu},[{key:"_authThenStart",value:(h=i(a().m(function n(){var e,t,r;return a().w(function(n){for(;;)switch(n.p=n.n){case 0:if(this._authProvider){n.n=1;break}throw new au("No auth provider");case 1:return n.p=1,n.n=2,fu(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit});case 2:t=n.v,n.n=4;break;case 3:throw n.p=3,r=n.v,null===(e=this.onerror)||void 0===e||e.call(this,r),r;case 4:if("AUTHORIZED"===t){n.n=5;break}throw new au;case 5:return n.n=6,this._startOrAuthSse({resumptionToken:void 0});case 6:return n.a(2,n.v)}},n,this,[[1,3]])})),function(){return h.apply(this,arguments)})},{key:"_commonHeaders",value:(f=i(a().m(function n(){var e,t,r,i;return a().w(function(n){for(;;)switch(n.n){case 0:if(t={},!this._authProvider){n.n=2;break}return n.n=1,this._authProvider.tokens();case 1:(r=n.v)&&(t.Authorization="Bearer ".concat(r.access_token));case 2:return this._sessionId&&(t["mcp-session-id"]=this._sessionId),this._protocolVersion&&(t["mcp-protocol-version"]=this._protocolVersion),i=k(null===(e=this._requestInit)||void 0===e?void 0:e.headers),n.a(2,new Headers(o(o({},t),i)))}},n,this)})),function(){return f.apply(this,arguments)})},{key:"_startOrAuthSse",value:(p=i(a().m(function n(e){var t,r,o,i,u,s,c;return a().w(function(n){for(;;)switch(n.p=n.n){case 0:return i=e.resumptionToken,n.p=1,n.n=2,this._commonHeaders();case 2:return(u=n.v).set("Accept","text/event-stream"),i&&u.set("last-event-id",i),n.n=3,(null!==(t=this._fetch)&&void 0!==t?t:fetch)(this._url,{method:"GET",headers:u,signal:null===(r=this._abortController)||void 0===r?void 0:r.signal});case 3:if((s=n.v).ok){n.n=7;break}if(401!==s.status||!this._authProvider){n.n=5;break}return n.n=4,this._authThenStart();case 4:return n.a(2,n.v);case 5:if(405!==s.status){n.n=6;break}return n.a(2);case 6:throw new Gu(s.status,"Failed to open SSE stream: ".concat(s.statusText));case 7:this._handleSseStream(s.body,e,!0),n.n=9;break;case 8:throw n.p=8,c=n.v,null===(o=this.onerror)||void 0===o||o.call(this,c),c;case 9:return n.a(2)}},n,this,[[1,8]])})),function(n){return p.apply(this,arguments)})},{key:"_getNextReconnectionDelay",value:function(n){if(void 0!==this._serverRetryMs)return this._serverRetryMs;var e=this._reconnectionOptions.initialReconnectionDelay,t=this._reconnectionOptions.reconnectionDelayGrowFactor,r=this._reconnectionOptions.maxReconnectionDelay;return Math.min(e*Math.pow(t,n),r)}},{key:"_scheduleReconnection",value:function(n){var e,t=this,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=this._reconnectionOptions.maxRetries;if(o>0&&r>=o)null===(e=this.onerror)||void 0===e||e.call(this,new Error("Maximum reconnection attempts (".concat(o,") exceeded.")));else{var i=this._getNextReconnectionDelay(r);setTimeout(function(){t._startOrAuthSse(n).catch(function(e){var o;null===(o=t.onerror)||void 0===o||o.call(t,new Error("Failed to reconnect SSE stream: ".concat(e instanceof Error?e.message:String(e)))),t._scheduleReconnection(n,r+1)})},i)}}},{key:"_handleSseStream",value:function(n,e,t){var r=this;if(n){var o,u=e.onresumptiontoken,s=e.replayMessageId,c=!1,l=function(){var e=i(a().m(function e(){var i,l,d,p,f,h,v,m,_;return a().w(function(e){for(;;)switch(e.p=e.n){case 0:e.p=0,f=n.pipeThrough(new TextDecoderStream).pipeThrough(new Hu({onRetry:function(n){r._serverRetryMs=n}})).getReader();case 1:return e.n=2,f.read();case 2:if(h=e.v,v=h.value,!h.done){e.n=3;break}return e.a(3,4);case 3:if(v.id&&(o=v.id,c=!0,null==u||u(v.id)),!v.event||"message"===v.event)try{m=Zo.parse(JSON.parse(v.data)),void 0!==s&&Eo(m)&&(m.id=s),null===(i=r.onmessage)||void 0===i||i.call(r,m)}catch(n){null===(l=r.onerror)||void 0===l||l.call(r,n)}e.n=1;break;case 4:(t||c)&&r._abortController&&!r._abortController.signal.aborted&&r._scheduleReconnection({resumptionToken:o,onresumptiontoken:u,replayMessageId:s},0),e.n=6;break;case 5:if(e.p=5,_=e.v,null===(d=r.onerror)||void 0===d||d.call(r,new Error("SSE stream disconnected: ".concat(_))),(t||c)&&r._abortController&&!r._abortController.signal.aborted)try{r._scheduleReconnection({resumptionToken:o,onresumptiontoken:u,replayMessageId:s},0)}catch(n){null===(p=r.onerror)||void 0===p||p.call(r,new Error("Failed to reconnect: ".concat(n instanceof Error?n.message:String(n))))}case 6:return e.a(2)}},e,null,[[0,5]])}));return function(){return e.apply(this,arguments)}}();l()}}},{key:"start",value:(d=i(a().m(function n(){return a().w(function(n){for(;;)switch(n.n){case 0:if(!this._abortController){n.n=1;break}throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");case 1:this._abortController=new AbortController;case 2:return n.a(2)}},n,this)})),function(){return d.apply(this,arguments)})},{key:"finishAuth",value:(u=i(a().m(function n(e){return a().w(function(n){for(;;)switch(n.n){case 0:if(this._authProvider){n.n=1;break}throw new au("No auth provider");case 1:return n.n=2,fu(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit});case 2:if("AUTHORIZED"===n.v){n.n=3;break}throw new au("Failed to authorize");case 3:return n.a(2)}},n,this)})),function(n){return u.apply(this,arguments)})},{key:"close",value:(r=i(a().m(function n(){var e,t;return a().w(function(n){for(;;)switch(n.n){case 0:null===(e=this._abortController)||void 0===e||e.abort(),null===(t=this.onclose)||void 0===t||t.call(this);case 1:return n.a(2)}},n,this)})),function(){return r.apply(this,arguments)})},{key:"send",value:(t=i(a().m(function n(e,t){var r,i,u,s,l,d,p,f,h,v,m,_,y,g,w,k,b,z,x,I,T,E,P,Z,C,A,U,R,S=this;return a().w(function(n){for(;;)switch(n.p=n.n){case 0:if(n.p=0,d=(l=t||{}).resumptionToken,p=l.onresumptiontoken,!d){n.n=1;break}return this._startOrAuthSse({resumptionToken:d,replayMessageId:xo(e)?e.id:void 0}).catch(function(n){var e;return null===(e=S.onerror)||void 0===e?void 0:e.call(S,n)}),n.a(2);case 1:return n.n=2,this._commonHeaders();case 2:return(f=n.v).set("content-type","application/json"),f.set("accept","application/json, text/event-stream"),h=o(o({},this._requestInit),{},{method:"POST",headers:f,body:JSON.stringify(e),signal:null===(r=this._abortController)||void 0===r?void 0:r.signal}),n.n=3,(null!==(i=this._fetch)&&void 0!==i?i:fetch)(this._url,h);case 3:if(v=n.v,(m=v.headers.get("mcp-session-id"))&&(this._sessionId=m),v.ok){n.n=13;break}if(401!==v.status||!this._authProvider){n.n=7;break}if(!this._hasCompletedAuthFlow){n.n=4;break}throw new Gu(401,"Server returned 401 after successful authentication");case 4:return _=wu(v),y=_.resourceMetadataUrl,g=_.scope,this._resourceMetadataUrl=y,this._scope=g,n.n=5,fu(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetchWithInit});case 5:if("AUTHORIZED"===n.v){n.n=6;break}throw new au;case 6:return this._hasCompletedAuthFlow=!0,n.a(2,this.send(e));case 7:if(403!==v.status||!this._authProvider){n.n=11;break}if(w=wu(v),k=w.resourceMetadataUrl,b=w.scope,"insufficient_scope"!==w.error){n.n=11;break}if(z=v.headers.get("WWW-Authenticate"),this._lastUpscopingHeader!==z){n.n=8;break}throw new Gu(403,"Server returned 403 after trying upscoping");case 8:return b&&(this._scope=b),k&&(this._resourceMetadataUrl=k),this._lastUpscopingHeader=null!=z?z:void 0,n.n=9,fu(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl,scope:this._scope,fetchFn:this._fetch});case 9:if("AUTHORIZED"===n.v){n.n=10;break}throw new au;case 10:return n.a(2,this.send(e));case 11:return n.n=12,v.text().catch(function(){return null});case 12:throw x=n.v,new Error("Error POSTing to endpoint (HTTP ".concat(v.status,"): ").concat(x));case 13:if(this._hasCompletedAuthFlow=!1,this._lastUpscopingHeader=void 0,202!==v.status){n.n=14;break}return Wo(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch(function(n){var e;return null===(e=S.onerror)||void 0===e?void 0:e.call(S,n)}),n.a(2);case 14:if(I=Array.isArray(e)?e:[e],T=I.filter(function(n){return"method"in n&&"id"in n&&void 0!==n.id}).length>0,E=v.headers.get("content-type"),!T){n.n=18;break}if(!(null==E?void 0:E.includes("text/event-stream"))){n.n=15;break}this._handleSseStream(v.body,{onresumptiontoken:p},!1),n.n=18;break;case 15:if(!(null==E?void 0:E.includes("application/json"))){n.n=17;break}return n.n=16,v.json();case 16:P=n.v,Z=Array.isArray(P)?P.map(function(n){return Zo.parse(n)}):[Zo.parse(P)],C=c(Z);try{for(C.s();!(A=C.n()).done;)U=A.value,null===(u=this.onmessage)||void 0===u||u.call(this,U)}catch(n){C.e(n)}finally{C.f()}n.n=18;break;case 17:throw new Gu(-1,"Unexpected content type: ".concat(E));case 18:n.n=20;break;case 19:throw n.p=19,R=n.v,null===(s=this.onerror)||void 0===s||s.call(this,R),R;case 20:return n.a(2)}},n,this,[[0,19]])})),function(n,e){return t.apply(this,arguments)})},{key:"sessionId",get:function(){return this._sessionId}},{key:"terminateSession",value:(e=i(a().m(function n(){var e,t,r,i,u,s,c;return a().w(function(n){for(;;)switch(n.p=n.n){case 0:if(this._sessionId){n.n=1;break}return n.a(2);case 1:return n.p=1,n.n=2,this._commonHeaders();case 2:return i=n.v,u=o(o({},this._requestInit),{},{method:"DELETE",headers:i,signal:null===(e=this._abortController)||void 0===e?void 0:e.signal}),n.n=3,(null!==(t=this._fetch)&&void 0!==t?t:fetch)(this._url,u);case 3:if((s=n.v).ok||405===s.status){n.n=4;break}throw new Gu(s.status,"Failed to terminate session: ".concat(s.statusText));case 4:this._sessionId=void 0,n.n=6;break;case 5:throw n.p=5,c=n.v,null===(r=this.onerror)||void 0===r||r.call(this,c),c;case 6:return n.a(2)}},n,this,[[1,5]])})),function(){return e.apply(this,arguments)})},{key:"setProtocolVersion",value:function(n){this._protocolVersion=n}},{key:"protocolVersion",get:function(){return this._protocolVersion}},{key:"resumeStream",value:(n=i(a().m(function n(e,t){return a().w(function(n){for(;;)switch(n.n){case 0:return n.n=1,this._startOrAuthSse({resumptionToken:e,onresumptiontoken:null==t?void 0:t.onresumptiontoken});case 1:return n.a(2)}},n,this)})),function(e,t){return n.apply(this,arguments)})}]);var n,e,t,r,u,d,p,f,h}();let Ku,Yu,Xu;async function Qu(n,o,i,a,u){try{if(!Ku){const e=new Ju(new URL(n||"http://localhost:3000/mcp"));Ku=await r({transport:e})}if(!Yu)switch(o){case"openai":const n=w({apiKey:a});Yu=n(i);break;case"anthropic":const e=g({apiKey:a});Yu=e(i);break;default:throw new Error("Invalid AI provider")}Xu||(Xu=await Ku.tools());return(await e({model:Yu,tools:Xu,stopWhen:t(5),messages:[{role:"user",content:[{type:"text",text:u}]}]})).textStream}catch(n){throw console.error(n),n}}class ns{constructor(n){this.config=n,this.corsHeaders=n.corsHeaders||{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"Content-Type","Access-Control-Allow-Methods":"POST, OPTIONS"}}static defaultConfig(){return{mcpUrl:n.MCP_URL||"",aiProvider:n.AI_PROVIDER||"",aiModel:n.AI_MODEL||"",aiToken:n.AI_TOKEN||""}}static New(n){const e=new ns(n);return n=>e.handle(n)}async handle(e){if("OPTIONS"===e.method)return new Response("",{status:200,headers:this.corsHeaders});if("POST"!==e.method)return this.error(405,"Method not allowed");try{const t=(await e.json()).prompt;if(!t)return this.error(400,"Missing prompt");const r=[this.config.mcpUrl||n.MCP_URL||"",this.config.aiProvider||n.AI_PROVIDER||"",this.config.aiModel||n.AI_MODEL||"",this.config.aiToken||n.AI_TOKEN||"",t],o=await Qu(r[0],r[1],r[2],r[3],r[4]),i=new TextEncoder,a=new ReadableStream({async start(n){try{for await(const e of o)n.enqueue(i.encode(e));n.close()}catch(e){n.error(e)}}});return new Response(a,{headers:{...this.corsHeaders,"Content-Type":"text/plain; charset=utf-8","Transfer-Encoding":"chunked"}})}catch(n){const e=n;return console.error("Catch error:",e),this.error(500,e.message)}}error(n,e){return console.error("Error:",{status:n,message:e}),new Response(JSON.stringify({error:e}),{status:n,headers:{...this.corsHeaders,"Content-Type":"application/json"}})}}function es(n){if(n instanceof Request){return ns.New({...ns.defaultConfig()})(n)}return ns.New(n)}export{Qu as askPrompt,es as handler};
2
2
  //# sourceMappingURL=index.js.map