mboaai-sdk 1.0.14 → 1.0.16

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 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("mcp-client"),require("pkce-challenge")):"function"==typeof define&&define.amd?define(["exports","mcp-client","pkce-challenge"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MboaAI={},e.MCPClient,e.pkceChallenge)}(this,(function(e,t,s){"use strict";var a,n;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const s of e)t[s]=s;return t},e.getValidEnumValues=t=>{const s=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),a={};for(const e of s)a[e]=t[e];return e.objectValues(a)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.push(s);return t},e.find=(e,t)=>{for(const s of e)if(t(s))return s},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(a||(a={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(n||(n={}));const r=a.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),i=e=>{switch(typeof e){case"undefined":return r.undefined;case"string":return r.string;case"number":return Number.isNaN(e)?r.nan:r.number;case"boolean":return r.boolean;case"function":return r.function;case"bigint":return r.bigint;case"symbol":return r.symbol;case"object":return Array.isArray(e)?r.array:null===e?r.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?r.promise:"undefined"!=typeof Map&&e instanceof Map?r.map:"undefined"!=typeof Set&&e instanceof Set?r.set:"undefined"!=typeof Date&&e instanceof Date?r.date:r.object;default:return r.unknown}},o=a.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class d extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},s={_errors:[]},a=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(a);else if("invalid_return_type"===n.code)a(n.returnTypeError);else if("invalid_arguments"===n.code)a(n.argumentsError);else if(0===n.path.length)s._errors.push(t(n));else{let e=s,a=0;for(;a<n.path.length;){const s=n.path[a];a===n.path.length-1?(e[s]=e[s]||{_errors:[]},e[s]._errors.push(t(n))):e[s]=e[s]||{_errors:[]},e=e[s],a++}}};return a(this),s}static assert(e){if(!(e instanceof d))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,a.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},s=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):s.push(e(a));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}d.create=e=>new d(e);const c=(e,t)=>{let s;switch(e.code){case o.invalid_type:s=e.received===r.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case o.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(e.expected,a.jsonStringifyReplacer)}`;break;case o.unrecognized_keys:s=`Unrecognized key(s) in object: ${a.joinValues(e.keys,", ")}`;break;case o.invalid_union:s="Invalid input";break;case o.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${a.joinValues(e.options)}`;break;case o.invalid_enum_value:s=`Invalid enum value. Expected ${a.joinValues(e.options)}, received '${e.received}'`;break;case o.invalid_arguments:s="Invalid function arguments";break;case o.invalid_return_type:s="Invalid function return type";break;case o.invalid_date:s="Invalid date";break;case o.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(s=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(s=`${s} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?s=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?s=`Invalid input: must end with "${e.validation.endsWith}"`:a.assertNever(e.validation):s="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case o.too_small:s="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case o.too_big:s="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case o.custom:s="Invalid input";break;case o.invalid_intersection_types:s="Intersection results could not be merged";break;case o.not_multiple_of:s=`Number must be a multiple of ${e.multipleOf}`;break;case o.not_finite:s="Number must be finite";break;default:s=t.defaultError,a.assertNever(e)}return{message:s}};let u=c;function l(e,t){const s=u,a=(e=>{const{data:t,path:s,errorMaps:a,issueData:n}=e,r=[...s,...n.path||[]],i={...n,path:r};if(void 0!==n.message)return{...n,path:r,message:n.message};let o="";const d=a.filter((e=>!!e)).slice().reverse();for(const e of d)o=e(i,{data:t,defaultError:o}).message;return{...n,path:r,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,s,s===c?void 0:c].filter((e=>!!e))});e.common.issues.push(a)}class h{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const a of t){if("aborted"===a.status)return p;"dirty"===a.status&&e.dirty(),s.push(a.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const e of t){const t=await e.key,a=await e.value;s.push({key:t,value:a})}return h.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const a of t){const{key:t,value:n}=a;if("aborted"===t.status)return p;if("aborted"===n.status)return p;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!a.alwaysSet||(s[t.value]=n.value)}return{status:e.value,value:s}}}const p=Object.freeze({status:"aborted"}),m=e=>({status:"dirty",value:e}),f=e=>({status:"valid",value:e}),_=e=>"aborted"===e.status,g=e=>"dirty"===e.status,y=e=>"valid"===e.status,v=e=>"undefined"!=typeof Promise&&e instanceof Promise;var x;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(x||(x={}));class k{constructor(e,t,s,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const w=(e,t)=>{if(y(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new d(e.common.issues);return this._error=t,this._error}}};function b(e){if(!e)return{};const{errorMap:t,invalid_type_error:s,required_error:a,description:n}=e;if(t&&(s||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{const{message:r}=e;return"invalid_enum_value"===t.code?{message:r??n.defaultError}:void 0===n.data?{message:r??a??n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:r??s??n.defaultError}},description:n}}class T{get description(){return this._def.description}_getType(e){return i(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new h,ctx:{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(v(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){const s={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)},a=this._parseSync({data:e,path:s.path,parent:s});return w(s,a)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)};if(!this["~standard"].async)try{const s=this._parseSync({data:e,path:[],parent:t});return y(s)?{value:s.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((e=>y(e)?{value:e.value}:{issues:t.common.issues}))}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)},a=this._parse({data:e,path:s.path,parent:s}),n=await(v(a)?a:Promise.resolve(a));return w(s,n)}refine(e,t){const s=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const n=e(t),r=()=>a.addIssue({code:o.custom,...s(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then((e=>!!e||(r(),!1))):!!n||(r(),!1)}))}refinement(e,t){return this._refinement(((s,a)=>!!e(s)||(a.addIssue("function"==typeof t?t(s,a):t),!1)))}_refinement(e){return new be({schema:this,typeName:je.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Te.create(this,this._def)}nullable(){return Ce.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return re.create(this)}promise(){return we.create(this,this._def)}or(e){return de.create([this,e],this._def)}and(e){return he.create(this,e,this._def)}transform(e){return new be({...b(this._def),schema:this,typeName:je.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Oe({...b(this._def),innerType:this,defaultValue:t,typeName:je.ZodDefault})}brand(){return new Ze({typeName:je.ZodBranded,type:this,...b(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Se({...b(this._def),innerType:this,catchValue:t,typeName:je.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Ie.create(this,e)}readonly(){return Ee.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const C=/^c[^\s-]{8,}$/i,O=/^[0-9a-z]+$/,S=/^[0-9A-HJKMNP-TV-Z]{26}$/i,A=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Z=/^[a-z0-9_-]{21}$/i,I=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,E=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,j=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let P;const R=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,N=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,$=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,M=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,U=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,z=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,L="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",F=new RegExp(`^${L}$`);function D(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function V(e){let t=`${L}T${D(e)}`;const s=[];return s.push(e.local?"Z?":"Z"),e.offset&&s.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${s.join("|")})`,new RegExp(`^${t}$`)}function q(e,t){if(!I.test(e))return!1;try{const[s]=e.split("."),a=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),n=JSON.parse(atob(a));return"object"==typeof n&&null!==n&&((!("typ"in n)||"JWT"===n?.typ)&&(!!n.alg&&(!t||n.alg===t)))}catch{return!1}}function K(e,t){return!("v4"!==t&&t||!N.test(e))||!("v6"!==t&&t||!M.test(e))}class W extends T{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==r.string){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.string,received:t.parsedType}),p}const t=new h;let s;for(const r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:o.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("max"===r.kind)e.data.length>r.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:o.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("length"===r.kind){const a=e.data.length>r.value,n=e.data.length<r.value;(a||n)&&(s=this._getOrReturnCtx(e,s),a?l(s,{code:o.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):n&&l(s,{code:o.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if("email"===r.kind)j.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"email",code:o.invalid_string,message:r.message}),t.dirty());else if("emoji"===r.kind)P||(P=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),P.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"emoji",code:o.invalid_string,message:r.message}),t.dirty());else if("uuid"===r.kind)A.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"uuid",code:o.invalid_string,message:r.message}),t.dirty());else if("nanoid"===r.kind)Z.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"nanoid",code:o.invalid_string,message:r.message}),t.dirty());else if("cuid"===r.kind)C.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid",code:o.invalid_string,message:r.message}),t.dirty());else if("cuid2"===r.kind)O.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cuid2",code:o.invalid_string,message:r.message}),t.dirty());else if("ulid"===r.kind)S.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"ulid",code:o.invalid_string,message:r.message}),t.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),l(s,{validation:"url",code:o.invalid_string,message:r.message}),t.dirty()}else if("regex"===r.kind){r.regex.lastIndex=0;r.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"regex",code:o.invalid_string,message:r.message}),t.dirty())}else if("trim"===r.kind)e.data=e.data.trim();else if("includes"===r.kind)e.data.includes(r.value,r.position)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty());else if("toLowerCase"===r.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===r.kind)e.data=e.data.toUpperCase();else if("startsWith"===r.kind)e.data.startsWith(r.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty());else if("endsWith"===r.kind)e.data.endsWith(r.value)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty());else if("datetime"===r.kind){V(r).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:"datetime",message:r.message}),t.dirty())}else if("date"===r.kind){F.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:"date",message:r.message}),t.dirty())}else if("time"===r.kind){new RegExp(`^${D(r)}$`).test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{code:o.invalid_string,validation:"time",message:r.message}),t.dirty())}else"duration"===r.kind?E.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"duration",code:o.invalid_string,message:r.message}),t.dirty()):"ip"===r.kind?(n=e.data,("v4"!==(i=r.version)&&i||!R.test(n))&&("v6"!==i&&i||!$.test(n))&&(s=this._getOrReturnCtx(e,s),l(s,{validation:"ip",code:o.invalid_string,message:r.message}),t.dirty())):"jwt"===r.kind?q(e.data,r.alg)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"jwt",code:o.invalid_string,message:r.message}),t.dirty()):"cidr"===r.kind?K(e.data,r.version)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"cidr",code:o.invalid_string,message:r.message}),t.dirty()):"base64"===r.kind?U.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64",code:o.invalid_string,message:r.message}),t.dirty()):"base64url"===r.kind?z.test(e.data)||(s=this._getOrReturnCtx(e,s),l(s,{validation:"base64url",code:o.invalid_string,message:r.message}),t.dirty()):a.assertNever(r);var n,i;return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement((t=>e.test(t)),{validation:t,code:o.invalid_string,...x.errToObj(s)})}_addCheck(e){return new W({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...x.errToObj(e)})}url(e){return this._addCheck({kind:"url",...x.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...x.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...x.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...x.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...x.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...x.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...x.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...x.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...x.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...x.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...x.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...x.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...x.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,...x.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...x.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...x.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...x.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...x.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...x.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...x.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...x.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...x.errToObj(t)})}nonempty(e){return this.min(1,x.errToObj(e))}trim(){return new W({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new W({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isCIDR(){return!!this._def.checks.find((e=>"cidr"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get isBase64url(){return!!this._def.checks.find((e=>"base64url"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function H(e,t){const s=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,n=s>a?s:a;return Number.parseInt(e.toFixed(n).replace(".",""))%Number.parseInt(t.toFixed(n).replace(".",""))/10**n}W.create=e=>new W({checks:[],typeName:je.ZodString,coerce:e?.coerce??!1,...b(e)});class B extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==r.number){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.number,received:t.parsedType}),p}let t;const s=new h;for(const n of this._def.checks)if("int"===n.kind)a.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),l(t,{code:o.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty());else if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty())}else"multipleOf"===n.kind?0!==H(e.data,n.value)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):"finite"===n.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),l(t,{code:o.not_finite,message:n.message}),s.dirty()):a.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,s,a){return new B({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:x.toString(a)}]})}_addCheck(e){return new B({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:x.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:x.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:x.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:x.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&a.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if("finite"===s.kind||"int"===s.kind||"multipleOf"===s.kind)return!0;"min"===s.kind?(null===t||s.value>t)&&(t=s.value):"max"===s.kind&&(null===e||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}B.create=e=>new B({checks:[],typeName:je.ZodNumber,coerce:e?.coerce||!1,...b(e)});class J extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==r.bigint)return this._getInvalidInput(e);let t;const s=new h;for(const n of this._def.checks)if("min"===n.kind){(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty())}else if("max"===n.kind){(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty())}else"multipleOf"===n.kind?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),l(t,{code:o.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):a.assertNever(n);return{status:s.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.bigint,received:t.parsedType}),p}gte(e,t){return this.setLimit("min",e,!0,x.toString(t))}gt(e,t){return this.setLimit("min",e,!1,x.toString(t))}lte(e,t){return this.setLimit("max",e,!0,x.toString(t))}lt(e,t){return this.setLimit("max",e,!1,x.toString(t))}setLimit(e,t,s,a){return new J({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:x.toString(a)}]})}_addCheck(e){return new J({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:x.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:x.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:x.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:x.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:x.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}J.create=e=>new J({checks:[],typeName:je.ZodBigInt,coerce:e?.coerce??!1,...b(e)});class G extends T{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==r.boolean){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.boolean,received:t.parsedType}),p}return f(e.data)}}G.create=e=>new G({typeName:je.ZodBoolean,coerce:e?.coerce||!1,...b(e)});class Y extends T{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==r.date){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.date,received:t.parsedType}),p}if(Number.isNaN(e.data.getTime())){return l(this._getOrReturnCtx(e),{code:o.invalid_date}),p}const t=new h;let s;for(const n of this._def.checks)"min"===n.kind?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:o.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):"max"===n.kind?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),l(s,{code:o.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):a.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Y({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:x.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:x.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Y.create=e=>new Y({checks:[],coerce:e?.coerce||!1,typeName:je.ZodDate,...b(e)});class X extends T{_parse(e){if(this._getType(e)!==r.symbol){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.symbol,received:t.parsedType}),p}return f(e.data)}}X.create=e=>new X({typeName:je.ZodSymbol,...b(e)});class Q extends T{_parse(e){if(this._getType(e)!==r.undefined){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.undefined,received:t.parsedType}),p}return f(e.data)}}Q.create=e=>new Q({typeName:je.ZodUndefined,...b(e)});class ee extends T{_parse(e){if(this._getType(e)!==r.null){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.null,received:t.parsedType}),p}return f(e.data)}}ee.create=e=>new ee({typeName:je.ZodNull,...b(e)});class te extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return f(e.data)}}te.create=e=>new te({typeName:je.ZodAny,...b(e)});class se extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return f(e.data)}}se.create=e=>new se({typeName:je.ZodUnknown,...b(e)});class ae extends T{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.never,received:t.parsedType}),p}}ae.create=e=>new ae({typeName:je.ZodNever,...b(e)});class ne extends T{_parse(e){if(this._getType(e)!==r.undefined){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.void,received:t.parsedType}),p}return f(e.data)}}ne.create=e=>new ne({typeName:je.ZodVoid,...b(e)});class re extends T{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),a=this._def;if(t.parsedType!==r.array)return l(t,{code:o.invalid_type,expected:r.array,received:t.parsedType}),p;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,n=t.data.length<a.exactLength.value;(e||n)&&(l(t,{code:e?o.too_big:o.too_small,minimum:n?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),s.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(l(t,{code:o.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),s.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(l(t,{code:o.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map(((e,s)=>a.type._parseAsync(new k(t,e,t.path,s))))).then((e=>h.mergeArray(s,e)));const n=[...t.data].map(((e,s)=>a.type._parseSync(new k(t,e,t.path,s))));return h.mergeArray(s,n)}get element(){return this._def.type}min(e,t){return new re({...this._def,minLength:{value:e,message:x.toString(t)}})}max(e,t){return new re({...this._def,maxLength:{value:e,message:x.toString(t)}})}length(e,t){return new re({...this._def,exactLength:{value:e,message:x.toString(t)}})}nonempty(e){return this.min(1,e)}}function ie(e){if(e instanceof oe){const t={};for(const s in e.shape){const a=e.shape[s];t[s]=Te.create(ie(a))}return new oe({...e._def,shape:()=>t})}return e instanceof re?new re({...e._def,type:ie(e.element)}):e instanceof Te?Te.create(ie(e.unwrap())):e instanceof Ce?Ce.create(ie(e.unwrap())):e instanceof pe?pe.create(e.items.map((e=>ie(e)))):e}re.create=(e,t)=>new re({type:e,minLength:null,maxLength:null,exactLength:null,typeName:je.ZodArray,...b(t)});class oe extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=a.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==r.object){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.object,received:t.parsedType}),p}const{status:t,ctx:s}=this._processInputParams(e),{shape:a,keys:n}=this._getCached(),i=[];if(!(this._def.catchall instanceof ae&&"strip"===this._def.unknownKeys))for(const e in s.data)n.includes(e)||i.push(e);const d=[];for(const e of n){const t=a[e],n=s.data[e];d.push({key:{status:"valid",value:e},value:t._parse(new k(s,n,s.path,e)),alwaysSet:e in s.data})}if(this._def.catchall instanceof ae){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of i)d.push({key:{status:"valid",value:e},value:{status:"valid",value:s.data[e]}});else if("strict"===e)i.length>0&&(l(s,{code:o.unrecognized_keys,keys:i}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of i){const a=s.data[t];d.push({key:{status:"valid",value:t},value:e._parse(new k(s,a,s.path,t)),alwaysSet:t in s.data})}}return s.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of d){const s=await t.key,a=await t.value;e.push({key:s,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>h.mergeObjectSync(t,e))):h.mergeObjectSync(t,d)}get shape(){return this._def.shape()}strict(e){return x.errToObj,new oe({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,s)=>{const a=this._def.errorMap?.(t,s).message??s.defaultError;return"unrecognized_keys"===t.code?{message:x.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new oe({...this._def,unknownKeys:"strip"})}passthrough(){return new oe({...this._def,unknownKeys:"passthrough"})}extend(e){return new oe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new oe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:je.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new oe({...this._def,catchall:e})}pick(e){const t={};for(const s of a.objectKeys(e))e[s]&&this.shape[s]&&(t[s]=this.shape[s]);return new oe({...this._def,shape:()=>t})}omit(e){const t={};for(const s of a.objectKeys(this.shape))e[s]||(t[s]=this.shape[s]);return new oe({...this._def,shape:()=>t})}deepPartial(){return ie(this)}partial(e){const t={};for(const s of a.objectKeys(this.shape)){const a=this.shape[s];e&&!e[s]?t[s]=a:t[s]=a.optional()}return new oe({...this._def,shape:()=>t})}required(e){const t={};for(const s of a.objectKeys(this.shape))if(e&&!e[s])t[s]=this.shape[s];else{let e=this.shape[s];for(;e instanceof Te;)e=e._def.innerType;t[s]=e}return new oe({...this._def,shape:()=>t})}keyof(){return ve(a.objectKeys(this.shape))}}oe.create=(e,t)=>new oe({shape:()=>e,unknownKeys:"strip",catchall:ae.create(),typeName:je.ZodObject,...b(t)}),oe.strictCreate=(e,t)=>new oe({shape:()=>e,unknownKeys:"strict",catchall:ae.create(),typeName:je.ZodObject,...b(t)}),oe.lazycreate=(e,t)=>new oe({shape:e,unknownKeys:"strip",catchall:ae.create(),typeName:je.ZodObject,...b(t)});class de extends T{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;if(t.common.async)return Promise.all(s.map((async e=>{const s={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:s}),ctx:s}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const s of e)if("dirty"===s.result.status)return t.common.issues.push(...s.ctx.common.issues),s.result;const s=e.map((e=>new d(e.ctx.common.issues)));return l(t,{code:o.invalid_union,unionErrors:s}),p}));{let e;const a=[];for(const n of s){const s={...t,common:{...t.common,issues:[]},parent:null},r=n._parseSync({data:t.data,path:t.path,parent:s});if("valid"===r.status)return r;"dirty"!==r.status||e||(e={result:r,ctx:s}),s.common.issues.length&&a.push(s.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=a.map((e=>new d(e)));return l(t,{code:o.invalid_union,unionErrors:n}),p}}get options(){return this._def.options}}de.create=(e,t)=>new de({options:e,typeName:je.ZodUnion,...b(t)});const ce=e=>e instanceof ge?ce(e.schema):e instanceof be?ce(e.innerType()):e instanceof ye?[e.value]:e instanceof xe?e.options:e instanceof ke?a.objectValues(e.enum):e instanceof Oe?ce(e._def.innerType):e instanceof Q?[void 0]:e instanceof ee?[null]:e instanceof Te?[void 0,...ce(e.unwrap())]:e instanceof Ce?[null,...ce(e.unwrap())]:e instanceof Ze||e instanceof Ee?ce(e.unwrap()):e instanceof Se?ce(e._def.innerType):[];class ue extends T{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.object)return l(t,{code:o.invalid_type,expected:r.object,received:t.parsedType}),p;const s=this.discriminator,a=t.data[s],n=this.optionsMap.get(a);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{code:o.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),p)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const a=new Map;for(const s of t){const t=ce(s.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(a.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);a.set(n,s)}}return new ue({typeName:je.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...b(s)})}}function le(e,t){const s=i(e),n=i(t);if(e===t)return{valid:!0,data:e};if(s===r.object&&n===r.object){const s=a.objectKeys(t),n=a.objectKeys(e).filter((e=>-1!==s.indexOf(e))),r={...e,...t};for(const s of n){const a=le(e[s],t[s]);if(!a.valid)return{valid:!1};r[s]=a.data}return{valid:!0,data:r}}if(s===r.array&&n===r.array){if(e.length!==t.length)return{valid:!1};const s=[];for(let a=0;a<e.length;a++){const n=le(e[a],t[a]);if(!n.valid)return{valid:!1};s.push(n.data)}return{valid:!0,data:s}}return s===r.date&&n===r.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}class he extends T{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),a=(e,a)=>{if(_(e)||_(a))return p;const n=le(e.value,a.value);return n.valid?((g(e)||g(a))&&t.dirty(),{status:t.value,value:n.data}):(l(s,{code:o.invalid_intersection_types}),p)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then((([e,t])=>a(e,t))):a(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}he.create=(e,t,s)=>new he({left:e,right:t,typeName:je.ZodIntersection,...b(s)});class pe extends T{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==r.array)return l(s,{code:o.invalid_type,expected:r.array,received:s.parsedType}),p;if(s.data.length<this._def.items.length)return l(s,{code:o.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),p;!this._def.rest&&s.data.length>this._def.items.length&&(l(s,{code:o.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...s.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new k(s,e,s.path,t)):null})).filter((e=>!!e));return s.common.async?Promise.all(a).then((e=>h.mergeArray(t,e))):h.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new pe({...this._def,rest:e})}}pe.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new pe({items:e,typeName:je.ZodTuple,rest:null,...b(t)})};class me extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==r.object)return l(s,{code:o.invalid_type,expected:r.object,received:s.parsedType}),p;const a=[],n=this._def.keyType,i=this._def.valueType;for(const e in s.data)a.push({key:n._parse(new k(s,e,s.path,e)),value:i._parse(new k(s,s.data[e],s.path,e)),alwaysSet:e in s.data});return s.common.async?h.mergeObjectAsync(t,a):h.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,s){return new me(t instanceof T?{keyType:e,valueType:t,typeName:je.ZodRecord,...b(s)}:{keyType:W.create(),valueType:e,typeName:je.ZodRecord,...b(t)})}}class fe extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==r.map)return l(s,{code:o.invalid_type,expected:r.map,received:s.parsedType}),p;const a=this._def.keyType,n=this._def.valueType,i=[...s.data.entries()].map((([e,t],r)=>({key:a._parse(new k(s,e,s.path,[r,"key"])),value:n._parse(new k(s,t,s.path,[r,"value"]))})));if(s.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const s of i){const a=await s.key,n=await s.value;if("aborted"===a.status||"aborted"===n.status)return p;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const s of i){const a=s.key,n=s.value;if("aborted"===a.status||"aborted"===n.status)return p;"dirty"!==a.status&&"dirty"!==n.status||t.dirty(),e.set(a.value,n.value)}return{status:t.value,value:e}}}}fe.create=(e,t,s)=>new fe({valueType:t,keyType:e,typeName:je.ZodMap,...b(s)});class _e extends T{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==r.set)return l(s,{code:o.invalid_type,expected:r.set,received:s.parsedType}),p;const a=this._def;null!==a.minSize&&s.data.size<a.minSize.value&&(l(s,{code:o.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&s.data.size>a.maxSize.value&&(l(s,{code:o.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const n=this._def.valueType;function i(e){const s=new Set;for(const a of e){if("aborted"===a.status)return p;"dirty"===a.status&&t.dirty(),s.add(a.value)}return{status:t.value,value:s}}const d=[...s.data.values()].map(((e,t)=>n._parse(new k(s,e,s.path,t))));return s.common.async?Promise.all(d).then((e=>i(e))):i(d)}min(e,t){return new _e({...this._def,minSize:{value:e,message:x.toString(t)}})}max(e,t){return new _e({...this._def,maxSize:{value:e,message:x.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}_e.create=(e,t)=>new _e({valueType:e,minSize:null,maxSize:null,typeName:je.ZodSet,...b(t)});class ge extends T{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ge.create=(e,t)=>new ge({getter:e,typeName:je.ZodLazy,...b(t)});class ye extends T{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:o.invalid_literal,expected:this._def.value}),p}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ve(e,t){return new xe({values:e,typeName:je.ZodEnum,...b(t)})}ye.create=(e,t)=>new ye({value:e,typeName:je.ZodLiteral,...b(t)});class xe extends T{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{expected:a.joinValues(s),received:t.parsedType,code:o.invalid_type}),p}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),s=this._def.values;return l(t,{received:t.data,code:o.invalid_enum_value,options:s}),p}return f(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return xe.create(e,{...this._def,...t})}exclude(e,t=this._def){return xe.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}xe.create=ve;class ke extends T{_parse(e){const t=a.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==r.string&&s.parsedType!==r.number){const e=a.objectValues(t);return l(s,{expected:a.joinValues(e),received:s.parsedType,code:o.invalid_type}),p}if(this._cache||(this._cache=new Set(a.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=a.objectValues(t);return l(s,{received:s.data,code:o.invalid_enum_value,options:e}),p}return f(e.data)}get enum(){return this._def.values}}ke.create=(e,t)=>new ke({values:e,typeName:je.ZodNativeEnum,...b(t)});class we extends T{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==r.promise&&!1===t.common.async)return l(t,{code:o.invalid_type,expected:r.promise,received:t.parsedType}),p;const s=t.parsedType===r.promise?t.data:Promise.resolve(t.data);return f(s.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}we.create=(e,t)=>new we({type:e,typeName:je.ZodPromise,...b(t)});class be extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===je.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,r={addIssue:e=>{l(s,e),e.fatal?t.abort():t.dirty()},get path(){return s.path}};if(r.addIssue=r.addIssue.bind(r),"preprocess"===n.type){const e=n.transform(s.data,r);if(s.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return p;const a=await this._def.schema._parseAsync({data:e,path:s.path,parent:s});return"aborted"===a.status?p:"dirty"===a.status||"dirty"===t.value?m(a.value):a}));{if("aborted"===t.value)return p;const a=this._def.schema._parseSync({data:e,path:s.path,parent:s});return"aborted"===a.status?p:"dirty"===a.status||"dirty"===t.value?m(a.value):a}}if("refinement"===n.type){const e=e=>{const t=n.refinement(e,r);if(s.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===s.common.async){const a=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===a.status?p:("dirty"===a.status&&t.dirty(),e(a.value),{status:t.value,value:a.value})}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((s=>"aborted"===s.status?p:("dirty"===s.status&&t.dirty(),e(s.value).then((()=>({status:t.value,value:s.value}))))))}if("transform"===n.type){if(!1===s.common.async){const e=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!y(e))return p;const a=n.transform(e.value,r);if(a instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then((e=>y(e)?Promise.resolve(n.transform(e.value,r)).then((e=>({status:t.value,value:e}))):p))}a.assertNever(n)}}be.create=(e,t,s)=>new be({schema:e,typeName:je.ZodEffects,effect:t,...b(s)}),be.createWithPreprocess=(e,t,s)=>new be({schema:t,effect:{type:"preprocess",transform:e},typeName:je.ZodEffects,...b(s)});class Te extends T{_parse(e){return this._getType(e)===r.undefined?f(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Te.create=(e,t)=>new Te({innerType:e,typeName:je.ZodOptional,...b(t)});class Ce extends T{_parse(e){return this._getType(e)===r.null?f(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ce.create=(e,t)=>new Ce({innerType:e,typeName:je.ZodNullable,...b(t)});class Oe extends T{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===r.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Oe.create=(e,t)=>new Oe({innerType:e,typeName:je.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...b(t)});class Se extends T{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return v(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new d(s.common.issues)},input:s.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new d(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Se.create=(e,t)=>new Se({innerType:e,typeName:je.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...b(t)});class Ae extends T{_parse(e){if(this._getType(e)!==r.nan){const t=this._getOrReturnCtx(e);return l(t,{code:o.invalid_type,expected:r.nan,received:t.parsedType}),p}return{status:"valid",value:e.data}}}Ae.create=e=>new Ae({typeName:je.ZodNaN,...b(e)});class Ze extends T{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Ie extends T{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?p:"dirty"===e.status?(t.dirty(),m(e.value)):this._def.out._parseAsync({data:e.value,path:s.path,parent:s})})()}{const e=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return"aborted"===e.status?p:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:s.path,parent:s})}}static create(e,t){return new Ie({in:e,out:t,typeName:je.ZodPipeline})}}class Ee extends T{_parse(e){const t=this._def.innerType._parse(e),s=e=>(y(e)&&(e.value=Object.freeze(e.value)),e);return v(t)?t.then((e=>s(e))):s(t)}unwrap(){return this._def.innerType}}var je;Ee.create=(e,t)=>new Ee({innerType:e,typeName:je.ZodReadonly,...b(t)}),function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(je||(je={}));const Pe=W.create,Re=B.create,Ne=G.create,$e=te.create,Me=se.create;ae.create;const Ue=re.create,ze=oe.create,Le=de.create,Fe=ue.create;he.create,pe.create;const De=me.create,Ve=ye.create,qe=xe.create;we.create;const Ke=Te.create;Ce.create;const We="2025-03-26",He="2.0",Be=Le([Pe(),Re().int()]),Je=Pe(),Ge=ze({progressToken:Ke(Be)}).passthrough(),Ye=ze({_meta:Ke(Ge)}).passthrough(),Xe=ze({method:Pe(),params:Ke(Ye)}),Qe=ze({_meta:Ke(ze({}).passthrough())}).passthrough(),et=ze({method:Pe(),params:Ke(Qe)}),tt=ze({_meta:Ke(ze({}).passthrough())}).passthrough(),st=Le([Pe(),Re().int()]),at=ze({jsonrpc:Ve(He),id:st}).merge(Xe).strict(),nt=ze({jsonrpc:Ve(He)}).merge(et).strict(),rt=ze({jsonrpc:Ve(He),id:st,result:tt}).strict();var it;!function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError"}(it||(it={}));const ot=ze({jsonrpc:Ve(He),id:st,error:ze({code:Re().int(),message:Pe(),data:Ke(Me())})}).strict(),dt=Le([at,nt,rt,ot]),ct=tt.strict(),ut=et.extend({method:Ve("notifications/cancelled"),params:Qe.extend({requestId:st,reason:Pe().optional()})}),lt=ze({name:Pe(),version:Pe()}).passthrough(),ht=ze({experimental:Ke(ze({}).passthrough()),sampling:Ke(ze({}).passthrough()),roots:Ke(ze({listChanged:Ke(Ne())}).passthrough())}).passthrough(),pt=Xe.extend({method:Ve("initialize"),params:Ye.extend({protocolVersion:Pe(),capabilities:ht,clientInfo:lt})}),mt=ze({experimental:Ke(ze({}).passthrough()),logging:Ke(ze({}).passthrough()),completions:Ke(ze({}).passthrough()),prompts:Ke(ze({listChanged:Ke(Ne())}).passthrough()),resources:Ke(ze({subscribe:Ke(Ne()),listChanged:Ke(Ne())}).passthrough()),tools:Ke(ze({listChanged:Ke(Ne())}).passthrough())}).passthrough(),ft=tt.extend({protocolVersion:Pe(),capabilities:mt,serverInfo:lt,instructions:Ke(Pe())}),_t=et.extend({method:Ve("notifications/initialized")}),gt=Xe.extend({method:Ve("ping")}),yt=ze({progress:Re(),total:Ke(Re()),message:Ke(Pe())}).passthrough(),vt=et.extend({method:Ve("notifications/progress"),params:Qe.merge(yt).extend({progressToken:Be})}),xt=Xe.extend({params:Ye.extend({cursor:Ke(Je)}).optional()}),kt=tt.extend({nextCursor:Ke(Je)}),wt=ze({uri:Pe(),mimeType:Ke(Pe())}).passthrough(),bt=wt.extend({text:Pe()}),Tt=wt.extend({blob:Pe().base64()}),Ct=ze({uri:Pe(),name:Pe(),description:Ke(Pe()),mimeType:Ke(Pe())}).passthrough(),Ot=ze({uriTemplate:Pe(),name:Pe(),description:Ke(Pe()),mimeType:Ke(Pe())}).passthrough(),St=xt.extend({method:Ve("resources/list")}),At=kt.extend({resources:Ue(Ct)}),Zt=xt.extend({method:Ve("resources/templates/list")}),It=kt.extend({resourceTemplates:Ue(Ot)}),Et=Xe.extend({method:Ve("resources/read"),params:Ye.extend({uri:Pe()})}),jt=tt.extend({contents:Ue(Le([bt,Tt]))}),Pt=et.extend({method:Ve("notifications/resources/list_changed")}),Rt=Xe.extend({method:Ve("resources/subscribe"),params:Ye.extend({uri:Pe()})}),Nt=Xe.extend({method:Ve("resources/unsubscribe"),params:Ye.extend({uri:Pe()})}),$t=et.extend({method:Ve("notifications/resources/updated"),params:Qe.extend({uri:Pe()})}),Mt=ze({name:Pe(),description:Ke(Pe()),required:Ke(Ne())}).passthrough(),Ut=ze({name:Pe(),description:Ke(Pe()),arguments:Ke(Ue(Mt))}).passthrough(),zt=xt.extend({method:Ve("prompts/list")}),Lt=kt.extend({prompts:Ue(Ut)}),Ft=Xe.extend({method:Ve("prompts/get"),params:Ye.extend({name:Pe(),arguments:Ke(De(Pe()))})}),Dt=ze({type:Ve("text"),text:Pe()}).passthrough(),Vt=ze({type:Ve("image"),data:Pe().base64(),mimeType:Pe()}).passthrough(),qt=ze({type:Ve("audio"),data:Pe().base64(),mimeType:Pe()}).passthrough(),Kt=ze({type:Ve("resource"),resource:Le([bt,Tt])}).passthrough(),Wt=ze({role:qe(["user","assistant"]),content:Le([Dt,Vt,qt,Kt])}).passthrough(),Ht=tt.extend({description:Ke(Pe()),messages:Ue(Wt)}),Bt=et.extend({method:Ve("notifications/prompts/list_changed")}),Jt=ze({title:Ke(Pe()),readOnlyHint:Ke(Ne()),destructiveHint:Ke(Ne()),idempotentHint:Ke(Ne()),openWorldHint:Ke(Ne())}).passthrough(),Gt=ze({name:Pe(),description:Ke(Pe()),inputSchema:ze({type:Ve("object"),properties:Ke(ze({}).passthrough()),required:Ke(Ue(Pe()))}).passthrough(),outputSchema:Ke(ze({type:Ve("object"),properties:Ke(ze({}).passthrough()),required:Ke(Ue(Pe()))}).passthrough()),annotations:Ke(Jt)}).passthrough(),Yt=xt.extend({method:Ve("tools/list")}),Xt=kt.extend({tools:Ue(Gt)}),Qt=tt.extend({content:Ue(Le([Dt,Vt,qt,Kt])).default([]),structuredContent:ze({}).passthrough().optional(),isError:Ke(Ne())});Qt.or(tt.extend({toolResult:Me()}));const es=Xe.extend({method:Ve("tools/call"),params:Ye.extend({name:Pe(),arguments:Ke(De(Me()))})}),ts=et.extend({method:Ve("notifications/tools/list_changed")}),ss=qe(["debug","info","notice","warning","error","critical","alert","emergency"]),as=Xe.extend({method:Ve("logging/setLevel"),params:Ye.extend({level:ss})}),ns=et.extend({method:Ve("notifications/message"),params:Qe.extend({level:ss,logger:Ke(Pe()),data:Me()})}),rs=ze({name:Pe().optional()}).passthrough(),is=ze({hints:Ke(Ue(rs)),costPriority:Ke(Re().min(0).max(1)),speedPriority:Ke(Re().min(0).max(1)),intelligencePriority:Ke(Re().min(0).max(1))}).passthrough(),os=ze({role:qe(["user","assistant"]),content:Le([Dt,Vt,qt])}).passthrough(),ds=Xe.extend({method:Ve("sampling/createMessage"),params:Ye.extend({messages:Ue(os),systemPrompt:Ke(Pe()),includeContext:Ke(qe(["none","thisServer","allServers"])),temperature:Ke(Re()),maxTokens:Re().int(),stopSequences:Ke(Ue(Pe())),metadata:Ke(ze({}).passthrough()),modelPreferences:Ke(is)})}),cs=tt.extend({model:Pe(),stopReason:Ke(qe(["endTurn","stopSequence","maxTokens"]).or(Pe())),role:qe(["user","assistant"]),content:Fe("type",[Dt,Vt,qt])}),us=ze({type:Ve("ref/resource"),uri:Pe()}).passthrough(),ls=ze({type:Ve("ref/prompt"),name:Pe()}).passthrough(),hs=Xe.extend({method:Ve("completion/complete"),params:Ye.extend({ref:Le([ls,us]),argument:ze({name:Pe(),value:Pe()}).passthrough()})}),ps=tt.extend({completion:ze({values:Ue(Pe()).max(100),total:Ke(Re().int()),hasMore:Ke(Ne())}).passthrough()}),ms=ze({uri:Pe().startsWith("file://"),name:Ke(Pe())}).passthrough(),fs=Xe.extend({method:Ve("roots/list")}),_s=tt.extend({roots:Ue(ms)}),gs=et.extend({method:Ve("notifications/roots/list_changed")});Le([gt,pt,hs,as,Ft,zt,St,Zt,Et,Rt,Nt,es,Yt]),Le([ut,vt,_t,gs]),Le([ct,cs,_s]),Le([gt,ds,fs]),Le([ut,vt,ns,$t,Pt,ts,Bt]),Le([ct,ft,ps,Ht,Lt,At,It,jt,Qt,Xt]);const ys=ze({resource:Pe().url(),authorization_servers:Ue(Pe().url()).optional(),jwks_uri:Pe().url().optional(),scopes_supported:Ue(Pe()).optional(),bearer_methods_supported:Ue(Pe()).optional(),resource_signing_alg_values_supported:Ue(Pe()).optional(),resource_name:Pe().optional(),resource_documentation:Pe().optional(),resource_policy_uri:Pe().url().optional(),resource_tos_uri:Pe().url().optional(),tls_client_certificate_bound_access_tokens:Ne().optional(),authorization_details_types_supported:Ue(Pe()).optional(),dpop_signing_alg_values_supported:Ue(Pe()).optional(),dpop_bound_access_tokens_required:Ne().optional()}).passthrough(),vs=ze({issuer:Pe(),authorization_endpoint:Pe(),token_endpoint:Pe(),registration_endpoint:Pe().optional(),scopes_supported:Ue(Pe()).optional(),response_types_supported:Ue(Pe()),response_modes_supported:Ue(Pe()).optional(),grant_types_supported:Ue(Pe()).optional(),token_endpoint_auth_methods_supported:Ue(Pe()).optional(),token_endpoint_auth_signing_alg_values_supported:Ue(Pe()).optional(),service_documentation:Pe().optional(),revocation_endpoint:Pe().optional(),revocation_endpoint_auth_methods_supported:Ue(Pe()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Ue(Pe()).optional(),introspection_endpoint:Pe().optional(),introspection_endpoint_auth_methods_supported:Ue(Pe()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Ue(Pe()).optional(),code_challenge_methods_supported:Ue(Pe()).optional()}).passthrough(),xs=ze({access_token:Pe(),token_type:Pe(),expires_in:Re().optional(),scope:Pe().optional(),refresh_token:Pe().optional()}).strip();ze({error:Pe(),error_description:Pe().optional(),error_uri:Pe().optional()});const ks=ze({redirect_uris:Ue(Pe()).refine((e=>e.every((e=>URL.canParse(e)))),{message:"redirect_uris must contain valid URLs"}),token_endpoint_auth_method:Pe().optional(),grant_types:Ue(Pe()).optional(),response_types:Ue(Pe()).optional(),client_name:Pe().optional(),client_uri:Pe().optional(),logo_uri:Pe().optional(),scope:Pe().optional(),contacts:Ue(Pe()).optional(),tos_uri:Pe().optional(),policy_uri:Pe().optional(),jwks_uri:Pe().optional(),jwks:$e().optional(),software_id:Pe().optional(),software_version:Pe().optional()}).strip(),ws=ze({client_id:Pe(),client_secret:Pe().optional(),client_id_issued_at:Re().optional(),client_secret_expires_at:Re().optional()}).strip(),bs=ks.merge(ws);ze({error:Pe(),error_description:Pe().optional()}).strip(),ze({token:Pe(),token_type_hint:Pe().optional()}).strip();class Ts extends Error{constructor(e){super(null!=e?e:"Unauthorized")}}async function Cs(e,{serverUrl:t,authorizationCode:a,scope:n,resourceMetadataUrl:r}){let i=t;try{const e=await async function(e,t){var s;let a,n;a=new URL("/.well-known/oauth-protected-resource",e);try{n=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(s=null==t?void 0:t.protocolVersion)&&void 0!==s?s:We}})}catch(e){if(!(e instanceof TypeError))throw e;n=await fetch(a)}if(404===n.status)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!n.ok)throw new Error(`HTTP ${n.status} trying to load well-known OAuth protected resource metadata.`);return ys.parse(await n.json())}(r||t);e.authorization_servers&&e.authorization_servers.length>0&&(i=e.authorization_servers[0])}catch(e){console.warn("Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server",e)}const o=await async function(e,t){var s;const a=new URL("/.well-known/oauth-authorization-server",e);let n;try{n=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(s=null==t?void 0:t.protocolVersion)&&void 0!==s?s:We}})}catch(e){if(!(e instanceof TypeError))throw e;n=await fetch(a)}if(404===n.status)return;if(!n.ok)throw new Error(`HTTP ${n.status} trying to load well-known OAuth metadata`);return vs.parse(await n.json())}(i);let d=await Promise.resolve(e.clientInformation());if(!d){if(void 0!==a)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const t=await async function(e,{metadata:t,clientMetadata:s}){let a;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");a=new URL(t.registration_endpoint)}else a=new URL("/register",e);const n=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!n.ok)throw new Error(`Dynamic client registration failed: HTTP ${n.status}`);return bs.parse(await n.json())}(i,{metadata:o,clientMetadata:e.clientMetadata});await e.saveClientInformation(t),d=t}if(void 0!==a){const t=await e.codeVerifier(),s=await async function(e,{metadata:t,clientInformation:s,authorizationCode:a,codeVerifier:n,redirectUri:r}){const i="authorization_code";let o;if(t){if(o=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(i))throw new Error(`Incompatible auth server: does not support grant type ${i}`)}else o=new URL("/token",e);const d=new URLSearchParams({grant_type:i,client_id:s.client_id,code:a,code_verifier:n,redirect_uri:String(r)});s.client_secret&&d.set("client_secret",s.client_secret);const c=await fetch(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:d});if(!c.ok)throw new Error(`Token exchange failed: HTTP ${c.status}`);return xs.parse(await c.json())}(i,{metadata:o,clientInformation:d,authorizationCode:a,codeVerifier:t,redirectUri:e.redirectUrl});return await e.saveTokens(s),"AUTHORIZED"}const c=await e.tokens();if(null==c?void 0:c.refresh_token)try{const t=await async function(e,{metadata:t,clientInformation:s,refreshToken:a}){const n="refresh_token";let r;if(t){if(r=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(n))throw new Error(`Incompatible auth server: does not support grant type ${n}`)}else r=new URL("/token",e);const i=new URLSearchParams({grant_type:n,client_id:s.client_id,refresh_token:a});s.client_secret&&i.set("client_secret",s.client_secret);const o=await fetch(r,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i});if(!o.ok)throw new Error(`Token refresh failed: HTTP ${o.status}`);return xs.parse({refresh_token:a,...await o.json()})}(i,{metadata:o,clientInformation:d,refreshToken:c.refresh_token});return await e.saveTokens(t),"AUTHORIZED"}catch(e){console.error("Could not refresh OAuth tokens:",e)}const u=e.state?await e.state():void 0,{authorizationUrl:l,codeVerifier:h}=await async function(e,{metadata:t,clientInformation:a,redirectUrl:n,scope:r,state:i}){const o="code",d="S256";let c;if(t){if(c=new URL(t.authorization_endpoint),!t.response_types_supported.includes(o))throw new Error(`Incompatible auth server: does not support response type ${o}`);if(!t.code_challenge_methods_supported||!t.code_challenge_methods_supported.includes(d))throw new Error(`Incompatible auth server: does not support code challenge method ${d}`)}else c=new URL("/authorize",e);const u=await s(),l=u.code_verifier,h=u.code_challenge;c.searchParams.set("response_type",o),c.searchParams.set("client_id",a.client_id),c.searchParams.set("code_challenge",h),c.searchParams.set("code_challenge_method",d),c.searchParams.set("redirect_uri",String(n)),i&&c.searchParams.set("state",i);r&&c.searchParams.set("scope",r);return{authorizationUrl:c,codeVerifier:l}}(i,{metadata:o,clientInformation:d,state:u,redirectUrl:e.redirectUrl,scope:n||e.clientMetadata.scope});return await e.saveCodeVerifier(h),await e.redirectToAuthorization(l),"REDIRECT"}class Os extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function Ss(e){}function As(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Ss,onError:s=Ss,onRetry:a=Ss,onComment:n}=e;let r,i="",o=!0,d="",c="";function u(e){if(""===e)return d.length>0&&t({id:r,event:c||void 0,data:d.endsWith("\n")?d.slice(0,-1):d}),r=void 0,d="",void(c="");if(e.startsWith(":"))return void(n&&n(e.slice(e.startsWith(": ")?2:1)));const s=e.indexOf(":");if(-1===s)l(e,"",e);else{const t=e.slice(0,s),a=" "===e[s+1]?2:1;l(t,e.slice(s+a),e)}}function l(e,t,n){switch(e){case"event":c=t;break;case"data":d=`${d}${t}\n`;break;case"id":r=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?a(parseInt(t,10)):s(new Os(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:n}));break;default:s(new Os(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:"unknown-field",field:e,value:t,line:n}))}}return{feed:function(e){const t=o?e.replace(/^\xEF\xBB\xBF/,""):e,[s,a]=function(e){const t=[];let s="",a=0;for(;a<e.length;){const n=e.indexOf("\r",a),r=e.indexOf("\n",a);let i=-1;if(-1!==n&&-1!==r?i=Math.min(n,r):-1!==n?i=n:-1!==r&&(i=r),-1===i){s=e.slice(a);break}{const s=e.slice(a,i);t.push(s),a=i+1,"\r"===e[a-1]&&"\n"===e[a]&&a++}}return[t,s]}(`${i}${t}`);for(const e of s)u(e);i=a,o=!1},reset:function(e={}){i&&e.consume&&u(i),o=!0,r=void 0,d="",c="",i=""}}}class Zs extends TransformStream{constructor({onError:e,onRetry:t,onComment:s}={}){let a;super({start(n){a=As({onEvent:e=>{n.enqueue(e)},onError(t){"terminate"===e?n.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:s})},transform(e){a.feed(e)}})}}const Is={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class Es extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class js{constructor(e,t){var s;this._url=e,this._resourceMetadataUrl=void 0,this._requestInit=null==t?void 0:t.requestInit,this._authProvider=null==t?void 0:t.authProvider,this._sessionId=null==t?void 0:t.sessionId,this._reconnectionOptions=null!==(s=null==t?void 0:t.reconnectionOptions)&&void 0!==s?s:Is}async _authThenStart(){var e;if(!this._authProvider)throw new Ts("No auth provider");let t;try{t=await Cs(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl})}catch(t){throw null===(e=this.onerror)||void 0===e||e.call(this,t),t}if("AUTHORIZED"!==t)throw new Ts;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var e;const t={};if(this._authProvider){const e=await this._authProvider.tokens();e&&(t.Authorization=`Bearer ${e.access_token}`)}return this._sessionId&&(t["mcp-session-id"]=this._sessionId),new Headers({...t,...null===(e=this._requestInit)||void 0===e?void 0:e.headers})}async _startOrAuthSse(e){var t,s;const{resumptionToken:a}=e;try{const s=await this._commonHeaders();s.set("Accept","text/event-stream"),a&&s.set("last-event-id",a);const n=await fetch(this._url,{method:"GET",headers:s,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal});if(!n.ok){if(401===n.status&&this._authProvider)return await this._authThenStart();if(405===n.status)return;throw new Es(n.status,`Failed to open SSE stream: ${n.statusText}`)}this._handleSseStream(n.body,e)}catch(e){throw null===(s=this.onerror)||void 0===s||s.call(this,e),e}}_getNextReconnectionDelay(e){const t=this._reconnectionOptions.initialReconnectionDelay,s=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(s,e),a)}_scheduleReconnection(e,t=0){var s;const a=this._reconnectionOptions.maxRetries;if(a>0&&t>=a)return void(null===(s=this.onerror)||void 0===s||s.call(this,new Error(`Maximum reconnection attempts (${a}) exceeded.`)));const n=this._getNextReconnectionDelay(t);setTimeout((()=>{this._startOrAuthSse(e).catch((s=>{var a;null===(a=this.onerror)||void 0===a||a.call(this,new Error(`Failed to reconnect SSE stream: ${s instanceof Error?s.message:String(s)}`)),this._scheduleReconnection(e,t+1)}))}),n)}_handleSseStream(e,t){if(!e)return;const{onresumptiontoken:s,replayMessageId:a}=t;let n;(async()=>{var t,r,i,o,d;try{const i=e.pipeThrough(new TextDecoderStream).pipeThrough(new Zs).getReader();for(;;){const{value:e,done:o}=await i.read();if(o)break;if(e.id&&(n=e.id,null==s||s(e.id)),!e.event||"message"===e.event)try{const s=dt.parse(JSON.parse(e.data));void 0!==a&&(d=s,rt.safeParse(d).success)&&(s.id=a),null===(t=this.onmessage)||void 0===t||t.call(this,s)}catch(e){null===(r=this.onerror)||void 0===r||r.call(this,e)}}}catch(e){if(null===(i=this.onerror)||void 0===i||i.call(this,new Error(`SSE stream disconnected: ${e}`)),this._abortController&&!this._abortController.signal.aborted&&void 0!==n)try{this._scheduleReconnection({resumptionToken:n,onresumptiontoken:s,replayMessageId:a},0)}catch(e){null===(o=this.onerror)||void 0===o||o.call(this,new Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Ts("No auth provider");if("AUTHORIZED"!==await Cs(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl}))throw new Ts("Failed to authorize")}async close(){var e,t;null===(e=this._abortController)||void 0===e||e.abort(),null===(t=this.onclose)||void 0===t||t.call(this)}async send(e,t){var s,a,n,r;try{const{resumptionToken:n,onresumptiontoken:i}=t||{};if(n)return void this._startOrAuthSse({resumptionToken:n,replayMessageId:(r=e,at.safeParse(r).success?e.id:void 0)}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)}));const o=await this._commonHeaders();o.set("content-type","application/json"),o.set("accept","application/json, text/event-stream");const d={...this._requestInit,method:"POST",headers:o,body:JSON.stringify(e),signal:null===(s=this._abortController)||void 0===s?void 0:s.signal},c=await fetch(this._url,d),u=c.headers.get("mcp-session-id");if(u&&(this._sessionId=u),!c.ok){if(401===c.status&&this._authProvider){this._resourceMetadataUrl=function(e){const t=e.headers.get("WWW-Authenticate");if(!t)return;const[s,a]=t.split(" ");if("bearer"!==s.toLowerCase()||!a)return void console.log("Invalid WWW-Authenticate header format, expected 'Bearer'");const n=/resource_metadata="([^"]*)"/.exec(t);if(n)try{return new URL(n[1])}catch(e){return void console.log("Invalid resource metadata url: ",n[1])}}(c);if("AUTHORIZED"!==await Cs(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl}))throw new Ts;return this.send(e)}const t=await c.text().catch((()=>null));throw new Error(`Error POSTing to endpoint (HTTP ${c.status}): ${t}`)}if(202===c.status)return void((e=>_t.safeParse(e).success)(e)&&this._startOrAuthSse({resumptionToken:void 0}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)})));const l=(Array.isArray(e)?e:[e]).filter((e=>"method"in e&&"id"in e&&void 0!==e.id)).length>0,h=c.headers.get("content-type");if(l)if(null==h?void 0:h.includes("text/event-stream"))this._handleSseStream(c.body,{onresumptiontoken:i});else{if(!(null==h?void 0:h.includes("application/json")))throw new Es(-1,`Unexpected content type: ${h}`);{const e=await c.json(),t=Array.isArray(e)?e.map((e=>dt.parse(e))):[dt.parse(e)];for(const e of t)null===(a=this.onmessage)||void 0===a||a.call(this,e)}}}catch(e){throw null===(n=this.onerror)||void 0===n||n.call(this,e),e}}get sessionId(){return this._sessionId}async terminateSession(){var e,t;if(this._sessionId)try{const t=await this._commonHeaders(),s={...this._requestInit,method:"DELETE",headers:t,signal:null===(e=this._abortController)||void 0===e?void 0:e.signal},a=await fetch(this._url,s);if(!a.ok&&405!==a.status)throw new Es(a.status,`Failed to terminate session: ${a.statusText}`);this._sessionId=void 0}catch(e){throw null===(t=this.onerror)||void 0===t||t.call(this,e),e}}}class Ps{static async init(e){if(!(null==e?void 0:e.apiKey))throw new Error("MboaAI-SDK: apiKey is required");if(Ps.ready)return;const{apiKey:s,mcpUrl:a="https://api.filparty.com:8001/mcp",name:n="MboaAI-SDK",version:r="1.0.0",defaultType:i="standard"}=e;Ps.client=new t.MCPClient({name:n,version:r}),await Ps.client.connect(new js(new URL(a),{requestInit:{headers:{"x-api-key":s}}})),Ps.apiKey=s,Ps.defaultType=i,Ps.ready=!0}static async translate(e,t,s){var a,n,r;if(!Ps.ready)throw new Error("MboaAI-SDK: call init() first");const i=`Translate "${e}" into ${t} for ${null!=s?s:Ps.defaultType}`;try{const t=await Ps.client.callTool({name:"run_translate",arguments:{message:i,api_key:Ps.apiKey}}),s=String(null!==(r=null===(n=null===(a=null==t?void 0:t.content)||void 0===a?void 0:a[0])||void 0===n?void 0:n.text)&&void 0!==r?r:"");if((e=>{const t=e.trim().charAt(0);return"{"===t||"["===t})(s))try{const t=JSON.parse(s);return t.reply||t.text||e}catch(e){}return s||e}catch(t){return console.error("[MboaAI-SDK] translate error → returning source",t),e}}}Ps.ready=!1,Ps.defaultType="standard",Ps.apiKey="","undefined"!=typeof window&&(window.MboaAI=window.MboaAI||{},window.MboaAI.T=Ps),e.T=Ps,e.default=Ps,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("pkce-challenge")):"function"==typeof define&&define.amd?define(["exports","pkce-challenge"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MboaAI={},e.pkceChallenge)}(this,(function(e,t){"use strict";var r,a;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const r of e)t[r]=r;return t},e.getValidEnumValues=t=>{const r=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),a={};for(const e of r)a[e]=t[e];return e.objectValues(a)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},e.find=(e,t)=>{for(const r of e)if(t(r))return r},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(r||(r={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(a||(a={}));const s=r.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),i=e=>{switch(typeof e){case"undefined":return s.undefined;case"string":return s.string;case"number":return Number.isNaN(e)?s.nan:s.number;case"boolean":return s.boolean;case"function":return s.function;case"bigint":return s.bigint;case"symbol":return s.symbol;case"object":return Array.isArray(e)?s.array:null===e?s.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?s.promise:"undefined"!=typeof Map&&e instanceof Map?s.map:"undefined"!=typeof Set&&e instanceof Set?s.set:"undefined"!=typeof Date&&e instanceof Date?s.date:s.object;default:return s.unknown}},o=r.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class n extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){const t=e||function(e){return e.message},r={_errors:[]},a=e=>{for(const s of e.issues)if("invalid_union"===s.code)s.unionErrors.map(a);else if("invalid_return_type"===s.code)a(s.returnTypeError);else if("invalid_arguments"===s.code)a(s.argumentsError);else if(0===s.path.length)r._errors.push(t(s));else{let e=r,a=0;for(;a<s.path.length;){const r=s.path[a];a===s.path.length-1?(e[r]=e[r]||{_errors:[]},e[r]._errors.push(t(s))):e[r]=e[r]||{_errors:[]},e=e[r],a++}}};return a(this),r}static assert(e){if(!(e instanceof n))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,r.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},r=[];for(const a of this.issues)a.path.length>0?(t[a.path[0]]=t[a.path[0]]||[],t[a.path[0]].push(e(a))):r.push(e(a));return{formErrors:r,fieldErrors:t}}get formErrors(){return this.flatten()}}n.create=e=>new n(e);const l=(e,t)=>{let a;switch(e.code){case o.invalid_type:a=e.received===s.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case o.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,r.jsonStringifyReplacer)}`;break;case o.unrecognized_keys:a=`Unrecognized key(s) in object: ${r.joinValues(e.keys,", ")}`;break;case o.invalid_union:a="Invalid input";break;case o.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${r.joinValues(e.options)}`;break;case o.invalid_enum_value:a=`Invalid enum value. Expected ${r.joinValues(e.options)}, received '${e.received}'`;break;case o.invalid_arguments:a="Invalid function arguments";break;case o.invalid_return_type:a="Invalid function return type";break;case o.invalid_date:a="Invalid date";break;case o.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:r.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case o.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case o.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case o.custom:a="Invalid input";break;case o.invalid_intersection_types:a="Intersection results could not be merged";break;case o.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case o.not_finite:a="Number must be finite";break;default:a=t.defaultError,r.assertNever(e)}return{message:a}};let c=l;function d(e,t){const r=c,a=(e=>{const{data:t,path:r,errorMaps:a,issueData:s}=e,i=[...r,...s.path||[]],o={...s,path:i};if(void 0!==s.message)return{...s,path:i,message:s.message};let n="";const l=a.filter((e=>!!e)).slice().reverse();for(const e of l)n=e(o,{data:t,defaultError:n}).message;return{...s,path:i,message:n}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===l?void 0:l].filter((e=>!!e))});e.common.issues.push(a)}class u{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const r=[];for(const a of t){if("aborted"===a.status)return h;"dirty"===a.status&&e.dirty(),r.push(a.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,t){const r=[];for(const e of t){const t=await e.key,a=await e.value;r.push({key:t,value:a})}return u.mergeObjectSync(e,r)}static mergeObjectSync(e,t){const r={};for(const a of t){const{key:t,value:s}=a;if("aborted"===t.status)return h;if("aborted"===s.status)return h;"dirty"===t.status&&e.dirty(),"dirty"===s.status&&e.dirty(),"__proto__"===t.value||void 0===s.value&&!a.alwaysSet||(r[t.value]=s.value)}return{status:e.value,value:r}}}const h=Object.freeze({status:"aborted"}),p=e=>({status:"dirty",value:e}),m=e=>({status:"valid",value:e}),f=e=>"aborted"===e.status,v=e=>"dirty"===e.status,y=e=>"valid"===e.status,g=e=>"undefined"!=typeof Promise&&e instanceof Promise;var _;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(_||(_={}));class w{constructor(e,t,r,a){this._cachedPath=[],this.parent=e,this.data=t,this._path=r,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const b=(e,t)=>{if(y(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new n(e.common.issues);return this._error=t,this._error}}};function P(e){if(!e)return{};const{errorMap:t,invalid_type_error:r,required_error:a,description:s}=e;if(t&&(r||a))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:s};return{errorMap:(t,s)=>{const{message:i}=e;return"invalid_enum_value"===t.code?{message:i??s.defaultError}:void 0===s.data?{message:i??a??s.defaultError}:"invalid_type"!==t.code?{message:s.defaultError}:{message:i??r??s.defaultError}},description:s}}class E{get description(){return this._def.description}_getType(e){return i(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new u,ctx:{common:e.parent.common,data:e.data,parsedType:i(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(g(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}safeParse(e,t){const r={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)},a=this._parseSync({data:e,path:r.path,parent:r});return b(r,a)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:t});return y(r)?{value:r.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((e=>y(e)?{value:e.value}:{issues:t.common.issues}))}async parseAsync(e,t){const r=await this.safeParseAsync(e,t);if(r.success)return r.data;throw r.error}async safeParseAsync(e,t){const r={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:i(e)},a=this._parse({data:e,path:r.path,parent:r}),s=await(g(a)?a:Promise.resolve(a));return b(r,s)}refine(e,t){const r=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,a)=>{const s=e(t),i=()=>a.addIssue({code:o.custom,...r(t)});return"undefined"!=typeof Promise&&s instanceof Promise?s.then((e=>!!e||(i(),!1))):!!s||(i(),!1)}))}refinement(e,t){return this._refinement(((r,a)=>!!e(r)||(a.addIssue("function"==typeof t?t(r,a):t),!1)))}_refinement(e){return new Pe({schema:this,typeName:Ie.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:e=>this["~validate"](e)}}optional(){return Ee.create(this,this._def)}nullable(){return xe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return be.create(this,this._def)}or(e){return ne.create([this,e],this._def)}and(e){return ue.create(this,e,this._def)}transform(e){return new Pe({...P(this._def),schema:this,typeName:Ie.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new ke({...P(this._def),innerType:this,defaultValue:t,typeName:Ie.ZodDefault})}brand(){return new Oe({typeName:Ie.ZodBranded,type:this,...P(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Se({...P(this._def),innerType:this,catchValue:t,typeName:Ie.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return Te.create(this,e)}readonly(){return $e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const x=/^c[^\s-]{8,}$/i,k=/^[0-9a-z]+$/,S=/^[0-9A-HJKMNP-TV-Z]{26}$/i,R=/^[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,O=/^[a-z0-9_-]{21}$/i,T=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,$=/^[-+]?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)?)??$/,I=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let C;const j=/^(?:(?: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])$/,F=/^(?:(?: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])$/,A=/^(([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]))$/,D=/^(([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])$/,N=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,q=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,L="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",z=new RegExp(`^${L}$`);function Z(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function M(e){let t=`${L}T${Z(e)}`;const r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function U(e,t){if(!T.test(e))return!1;try{const[r]=e.split("."),a=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),s=JSON.parse(atob(a));return"object"==typeof s&&null!==s&&((!("typ"in s)||"JWT"===s?.typ)&&(!!s.alg&&(!t||s.alg===t)))}catch{return!1}}function V(e,t){return!("v4"!==t&&t||!F.test(e))||!("v6"!==t&&t||!D.test(e))}class H extends E{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==s.string){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.string,received:t.parsedType}),h}const t=new u;let a;for(const s of this._def.checks)if("min"===s.kind)e.data.length<s.value&&(a=this._getOrReturnCtx(e,a),d(a,{code:o.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if("max"===s.kind)e.data.length>s.value&&(a=this._getOrReturnCtx(e,a),d(a,{code:o.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if("length"===s.kind){const r=e.data.length>s.value,i=e.data.length<s.value;(r||i)&&(a=this._getOrReturnCtx(e,a),r?d(a,{code:o.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&d(a,{code:o.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if("email"===s.kind)I.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"email",code:o.invalid_string,message:s.message}),t.dirty());else if("emoji"===s.kind)C||(C=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),C.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"emoji",code:o.invalid_string,message:s.message}),t.dirty());else if("uuid"===s.kind)R.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"uuid",code:o.invalid_string,message:s.message}),t.dirty());else if("nanoid"===s.kind)O.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"nanoid",code:o.invalid_string,message:s.message}),t.dirty());else if("cuid"===s.kind)x.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"cuid",code:o.invalid_string,message:s.message}),t.dirty());else if("cuid2"===s.kind)k.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"cuid2",code:o.invalid_string,message:s.message}),t.dirty());else if("ulid"===s.kind)S.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"ulid",code:o.invalid_string,message:s.message}),t.dirty());else if("url"===s.kind)try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),d(a,{validation:"url",code:o.invalid_string,message:s.message}),t.dirty()}else if("regex"===s.kind){s.regex.lastIndex=0;s.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"regex",code:o.invalid_string,message:s.message}),t.dirty())}else if("trim"===s.kind)e.data=e.data.trim();else if("includes"===s.kind)e.data.includes(s.value,s.position)||(a=this._getOrReturnCtx(e,a),d(a,{code:o.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty());else if("toLowerCase"===s.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===s.kind)e.data=e.data.toUpperCase();else if("startsWith"===s.kind)e.data.startsWith(s.value)||(a=this._getOrReturnCtx(e,a),d(a,{code:o.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty());else if("endsWith"===s.kind)e.data.endsWith(s.value)||(a=this._getOrReturnCtx(e,a),d(a,{code:o.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty());else if("datetime"===s.kind){M(s).test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{code:o.invalid_string,validation:"datetime",message:s.message}),t.dirty())}else if("date"===s.kind){z.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{code:o.invalid_string,validation:"date",message:s.message}),t.dirty())}else if("time"===s.kind){new RegExp(`^${Z(s)}$`).test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{code:o.invalid_string,validation:"time",message:s.message}),t.dirty())}else"duration"===s.kind?$.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"duration",code:o.invalid_string,message:s.message}),t.dirty()):"ip"===s.kind?(i=e.data,("v4"!==(n=s.version)&&n||!j.test(i))&&("v6"!==n&&n||!A.test(i))&&(a=this._getOrReturnCtx(e,a),d(a,{validation:"ip",code:o.invalid_string,message:s.message}),t.dirty())):"jwt"===s.kind?U(e.data,s.alg)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"jwt",code:o.invalid_string,message:s.message}),t.dirty()):"cidr"===s.kind?V(e.data,s.version)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"cidr",code:o.invalid_string,message:s.message}),t.dirty()):"base64"===s.kind?N.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"base64",code:o.invalid_string,message:s.message}),t.dirty()):"base64url"===s.kind?q.test(e.data)||(a=this._getOrReturnCtx(e,a),d(a,{validation:"base64url",code:o.invalid_string,message:s.message}),t.dirty()):r.assertNever(s);var i,n;return{status:t.value,value:e.data}}_regex(e,t,r){return this.refinement((t=>e.test(t)),{validation:t,code:o.invalid_string,..._.errToObj(r)})}_addCheck(e){return new H({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",..._.errToObj(e)})}url(e){return this._addCheck({kind:"url",..._.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",..._.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",..._.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",..._.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",..._.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",..._.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",..._.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",..._.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",..._.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",..._.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",..._.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",..._.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,..._.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===e?.precision?null:e?.precision,..._.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",..._.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,..._.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,..._.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,..._.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,..._.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,..._.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,..._.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,..._.errToObj(t)})}nonempty(e){return this.min(1,_.errToObj(e))}trim(){return new H({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new H({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new H({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isCIDR(){return!!this._def.checks.find((e=>"cidr"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get isBase64url(){return!!this._def.checks.find((e=>"base64url"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function Q(e,t){const r=(e.toString().split(".")[1]||"").length,a=(t.toString().split(".")[1]||"").length,s=r>a?r:a;return Number.parseInt(e.toFixed(s).replace(".",""))%Number.parseInt(t.toFixed(s).replace(".",""))/10**s}H.create=e=>new H({checks:[],typeName:Ie.ZodString,coerce:e?.coerce??!1,...P(e)});class K extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==s.number){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.number,received:t.parsedType}),h}let t;const a=new u;for(const s of this._def.checks)if("int"===s.kind)r.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),d(t,{code:o.invalid_type,expected:"integer",received:"float",message:s.message}),a.dirty());else if("min"===s.kind){(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),d(t,{code:o.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty())}else if("max"===s.kind){(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),d(t,{code:o.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),a.dirty())}else"multipleOf"===s.kind?0!==Q(e.data,s.value)&&(t=this._getOrReturnCtx(e,t),d(t,{code:o.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):"finite"===s.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),d(t,{code:o.not_finite,message:s.message}),a.dirty()):r.assertNever(s);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,r,a){return new K({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:_.toString(a)}]})}_addCheck(e){return new K({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:_.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:_.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:_.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:_.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&r.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const r of this._def.checks){if("finite"===r.kind||"int"===r.kind||"multipleOf"===r.kind)return!0;"min"===r.kind?(null===t||r.value>t)&&(t=r.value):"max"===r.kind&&(null===e||r.value<e)&&(e=r.value)}return Number.isFinite(t)&&Number.isFinite(e)}}K.create=e=>new K({checks:[],typeName:Ie.ZodNumber,coerce:e?.coerce||!1,...P(e)});class B extends E{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==s.bigint)return this._getInvalidInput(e);let t;const a=new u;for(const s of this._def.checks)if("min"===s.kind){(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),d(t,{code:o.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty())}else if("max"===s.kind){(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),d(t,{code:o.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),a.dirty())}else"multipleOf"===s.kind?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),d(t,{code:o.not_multiple_of,multipleOf:s.value,message:s.message}),a.dirty()):r.assertNever(s);return{status:a.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.bigint,received:t.parsedType}),h}gte(e,t){return this.setLimit("min",e,!0,_.toString(t))}gt(e,t){return this.setLimit("min",e,!1,_.toString(t))}lte(e,t){return this.setLimit("max",e,!0,_.toString(t))}lt(e,t){return this.setLimit("max",e,!1,_.toString(t))}setLimit(e,t,r,a){return new B({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:r,message:_.toString(a)}]})}_addCheck(e){return new B({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:_.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:_.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:_.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:_.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:_.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}B.create=e=>new B({checks:[],typeName:Ie.ZodBigInt,coerce:e?.coerce??!1,...P(e)});class W extends E{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==s.boolean){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.boolean,received:t.parsedType}),h}return m(e.data)}}W.create=e=>new W({typeName:Ie.ZodBoolean,coerce:e?.coerce||!1,...P(e)});class J extends E{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==s.date){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.date,received:t.parsedType}),h}if(Number.isNaN(e.data.getTime())){return d(this._getOrReturnCtx(e),{code:o.invalid_date}),h}const t=new u;let a;for(const s of this._def.checks)"min"===s.kind?e.data.getTime()<s.value&&(a=this._getOrReturnCtx(e,a),d(a,{code:o.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):"max"===s.kind?e.data.getTime()>s.value&&(a=this._getOrReturnCtx(e,a),d(a,{code:o.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):r.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new J({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:_.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:_.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}J.create=e=>new J({checks:[],coerce:e?.coerce||!1,typeName:Ie.ZodDate,...P(e)});class G extends E{_parse(e){if(this._getType(e)!==s.symbol){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.symbol,received:t.parsedType}),h}return m(e.data)}}G.create=e=>new G({typeName:Ie.ZodSymbol,...P(e)});class Y extends E{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.undefined,received:t.parsedType}),h}return m(e.data)}}Y.create=e=>new Y({typeName:Ie.ZodUndefined,...P(e)});class X extends E{_parse(e){if(this._getType(e)!==s.null){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.null,received:t.parsedType}),h}return m(e.data)}}X.create=e=>new X({typeName:Ie.ZodNull,...P(e)});class ee extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return m(e.data)}}ee.create=e=>new ee({typeName:Ie.ZodAny,...P(e)});class te extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return m(e.data)}}te.create=e=>new te({typeName:Ie.ZodUnknown,...P(e)});class re extends E{_parse(e){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.never,received:t.parsedType}),h}}re.create=e=>new re({typeName:Ie.ZodNever,...P(e)});class ae extends E{_parse(e){if(this._getType(e)!==s.undefined){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.void,received:t.parsedType}),h}return m(e.data)}}ae.create=e=>new ae({typeName:Ie.ZodVoid,...P(e)});class se extends E{_parse(e){const{ctx:t,status:r}=this._processInputParams(e),a=this._def;if(t.parsedType!==s.array)return d(t,{code:o.invalid_type,expected:s.array,received:t.parsedType}),h;if(null!==a.exactLength){const e=t.data.length>a.exactLength.value,s=t.data.length<a.exactLength.value;(e||s)&&(d(t,{code:e?o.too_big:o.too_small,minimum:s?a.exactLength.value:void 0,maximum:e?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),r.dirty())}if(null!==a.minLength&&t.data.length<a.minLength.value&&(d(t,{code:o.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),r.dirty()),null!==a.maxLength&&t.data.length>a.maxLength.value&&(d(t,{code:o.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),r.dirty()),t.common.async)return Promise.all([...t.data].map(((e,r)=>a.type._parseAsync(new w(t,e,t.path,r))))).then((e=>u.mergeArray(r,e)));const i=[...t.data].map(((e,r)=>a.type._parseSync(new w(t,e,t.path,r))));return u.mergeArray(r,i)}get element(){return this._def.type}min(e,t){return new se({...this._def,minLength:{value:e,message:_.toString(t)}})}max(e,t){return new se({...this._def,maxLength:{value:e,message:_.toString(t)}})}length(e,t){return new se({...this._def,exactLength:{value:e,message:_.toString(t)}})}nonempty(e){return this.min(1,e)}}function ie(e){if(e instanceof oe){const t={};for(const r in e.shape){const a=e.shape[r];t[r]=Ee.create(ie(a))}return new oe({...e._def,shape:()=>t})}return e instanceof se?new se({...e._def,type:ie(e.element)}):e instanceof Ee?Ee.create(ie(e.unwrap())):e instanceof xe?xe.create(ie(e.unwrap())):e instanceof he?he.create(e.items.map((e=>ie(e)))):e}se.create=(e,t)=>new se({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Ie.ZodArray,...P(t)});class oe extends E{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=r.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==s.object){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.object,received:t.parsedType}),h}const{status:t,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),n=[];if(!(this._def.catchall instanceof re&&"strip"===this._def.unknownKeys))for(const e in r.data)i.includes(e)||n.push(e);const l=[];for(const e of i){const t=a[e],s=r.data[e];l.push({key:{status:"valid",value:e},value:t._parse(new w(r,s,r.path,e)),alwaysSet:e in r.data})}if(this._def.catchall instanceof re){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of n)l.push({key:{status:"valid",value:e},value:{status:"valid",value:r.data[e]}});else if("strict"===e)n.length>0&&(d(r,{code:o.unrecognized_keys,keys:n}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of n){const a=r.data[t];l.push({key:{status:"valid",value:t},value:e._parse(new w(r,a,r.path,t)),alwaysSet:t in r.data})}}return r.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of l){const r=await t.key,a=await t.value;e.push({key:r,value:a,alwaysSet:t.alwaysSet})}return e})).then((e=>u.mergeObjectSync(t,e))):u.mergeObjectSync(t,l)}get shape(){return this._def.shape()}strict(e){return _.errToObj,new oe({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,r)=>{const a=this._def.errorMap?.(t,r).message??r.defaultError;return"unrecognized_keys"===t.code?{message:_.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new oe({...this._def,unknownKeys:"strip"})}passthrough(){return new oe({...this._def,unknownKeys:"passthrough"})}extend(e){return new oe({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new oe({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ie.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new oe({...this._def,catchall:e})}pick(e){const t={};for(const a of r.objectKeys(e))e[a]&&this.shape[a]&&(t[a]=this.shape[a]);return new oe({...this._def,shape:()=>t})}omit(e){const t={};for(const a of r.objectKeys(this.shape))e[a]||(t[a]=this.shape[a]);return new oe({...this._def,shape:()=>t})}deepPartial(){return ie(this)}partial(e){const t={};for(const a of r.objectKeys(this.shape)){const r=this.shape[a];e&&!e[a]?t[a]=r:t[a]=r.optional()}return new oe({...this._def,shape:()=>t})}required(e){const t={};for(const a of r.objectKeys(this.shape))if(e&&!e[a])t[a]=this.shape[a];else{let e=this.shape[a];for(;e instanceof Ee;)e=e._def.innerType;t[a]=e}return new oe({...this._def,shape:()=>t})}keyof(){return ge(r.objectKeys(this.shape))}}oe.create=(e,t)=>new oe({shape:()=>e,unknownKeys:"strip",catchall:re.create(),typeName:Ie.ZodObject,...P(t)}),oe.strictCreate=(e,t)=>new oe({shape:()=>e,unknownKeys:"strict",catchall:re.create(),typeName:Ie.ZodObject,...P(t)}),oe.lazycreate=(e,t)=>new oe({shape:e,unknownKeys:"strip",catchall:re.create(),typeName:Ie.ZodObject,...P(t)});class ne extends E{_parse(e){const{ctx:t}=this._processInputParams(e),r=this._def.options;if(t.common.async)return Promise.all(r.map((async e=>{const r={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:r}),ctx:r}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const r of e)if("dirty"===r.result.status)return t.common.issues.push(...r.ctx.common.issues),r.result;const r=e.map((e=>new n(e.ctx.common.issues)));return d(t,{code:o.invalid_union,unionErrors:r}),h}));{let e;const a=[];for(const s of r){const r={...t,common:{...t.common,issues:[]},parent:null},i=s._parseSync({data:t.data,path:t.path,parent:r});if("valid"===i.status)return i;"dirty"!==i.status||e||(e={result:i,ctx:r}),r.common.issues.length&&a.push(r.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const s=a.map((e=>new n(e)));return d(t,{code:o.invalid_union,unionErrors:s}),h}}get options(){return this._def.options}}ne.create=(e,t)=>new ne({options:e,typeName:Ie.ZodUnion,...P(t)});const le=e=>e instanceof ve?le(e.schema):e instanceof Pe?le(e.innerType()):e instanceof ye?[e.value]:e instanceof _e?e.options:e instanceof we?r.objectValues(e.enum):e instanceof ke?le(e._def.innerType):e instanceof Y?[void 0]:e instanceof X?[null]:e instanceof Ee?[void 0,...le(e.unwrap())]:e instanceof xe?[null,...le(e.unwrap())]:e instanceof Oe||e instanceof $e?le(e.unwrap()):e instanceof Se?le(e._def.innerType):[];class ce extends E{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.object)return d(t,{code:o.invalid_type,expected:s.object,received:t.parsedType}),h;const r=this.discriminator,a=t.data[r],i=this.optionsMap.get(a);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(d(t,{code:o.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),h)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,r){const a=new Map;for(const r of t){const t=le(r.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const s of t){if(a.has(s))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(s)}`);a.set(s,r)}}return new ce({typeName:Ie.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:a,...P(r)})}}function de(e,t){const a=i(e),o=i(t);if(e===t)return{valid:!0,data:e};if(a===s.object&&o===s.object){const a=r.objectKeys(t),s=r.objectKeys(e).filter((e=>-1!==a.indexOf(e))),i={...e,...t};for(const r of s){const a=de(e[r],t[r]);if(!a.valid)return{valid:!1};i[r]=a.data}return{valid:!0,data:i}}if(a===s.array&&o===s.array){if(e.length!==t.length)return{valid:!1};const r=[];for(let a=0;a<e.length;a++){const s=de(e[a],t[a]);if(!s.valid)return{valid:!1};r.push(s.data)}return{valid:!0,data:r}}return a===s.date&&o===s.date&&+e===+t?{valid:!0,data:e}:{valid:!1}}class ue extends E{_parse(e){const{status:t,ctx:r}=this._processInputParams(e),a=(e,a)=>{if(f(e)||f(a))return h;const s=de(e.value,a.value);return s.valid?((v(e)||v(a))&&t.dirty(),{status:t.value,value:s.data}):(d(r,{code:o.invalid_intersection_types}),h)};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((([e,t])=>a(e,t))):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}))}}ue.create=(e,t,r)=>new ue({left:e,right:t,typeName:Ie.ZodIntersection,...P(r)});class he extends E{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==s.array)return d(r,{code:o.invalid_type,expected:s.array,received:r.parsedType}),h;if(r.data.length<this._def.items.length)return d(r,{code:o.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),h;!this._def.rest&&r.data.length>this._def.items.length&&(d(r,{code:o.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const a=[...r.data].map(((e,t)=>{const a=this._def.items[t]||this._def.rest;return a?a._parse(new w(r,e,r.path,t)):null})).filter((e=>!!e));return r.common.async?Promise.all(a).then((e=>u.mergeArray(t,e))):u.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new he({...this._def,rest:e})}}he.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new he({items:e,typeName:Ie.ZodTuple,rest:null,...P(t)})};class pe extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==s.object)return d(r,{code:o.invalid_type,expected:s.object,received:r.parsedType}),h;const a=[],i=this._def.keyType,n=this._def.valueType;for(const e in r.data)a.push({key:i._parse(new w(r,e,r.path,e)),value:n._parse(new w(r,r.data[e],r.path,e)),alwaysSet:e in r.data});return r.common.async?u.mergeObjectAsync(t,a):u.mergeObjectSync(t,a)}get element(){return this._def.valueType}static create(e,t,r){return new pe(t instanceof E?{keyType:e,valueType:t,typeName:Ie.ZodRecord,...P(r)}:{keyType:H.create(),valueType:e,typeName:Ie.ZodRecord,...P(t)})}}class me extends E{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==s.map)return d(r,{code:o.invalid_type,expected:s.map,received:r.parsedType}),h;const a=this._def.keyType,i=this._def.valueType,n=[...r.data.entries()].map((([e,t],s)=>({key:a._parse(new w(r,e,r.path,[s,"key"])),value:i._parse(new w(r,t,r.path,[s,"value"]))})));if(r.common.async){const e=new Map;return Promise.resolve().then((async()=>{for(const r of n){const a=await r.key,s=await r.value;if("aborted"===a.status||"aborted"===s.status)return h;"dirty"!==a.status&&"dirty"!==s.status||t.dirty(),e.set(a.value,s.value)}return{status:t.value,value:e}}))}{const e=new Map;for(const r of n){const a=r.key,s=r.value;if("aborted"===a.status||"aborted"===s.status)return h;"dirty"!==a.status&&"dirty"!==s.status||t.dirty(),e.set(a.value,s.value)}return{status:t.value,value:e}}}}me.create=(e,t,r)=>new me({valueType:t,keyType:e,typeName:Ie.ZodMap,...P(r)});class fe extends E{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.parsedType!==s.set)return d(r,{code:o.invalid_type,expected:s.set,received:r.parsedType}),h;const a=this._def;null!==a.minSize&&r.data.size<a.minSize.value&&(d(r,{code:o.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),t.dirty()),null!==a.maxSize&&r.data.size>a.maxSize.value&&(d(r,{code:o.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),t.dirty());const i=this._def.valueType;function n(e){const r=new Set;for(const a of e){if("aborted"===a.status)return h;"dirty"===a.status&&t.dirty(),r.add(a.value)}return{status:t.value,value:r}}const l=[...r.data.values()].map(((e,t)=>i._parse(new w(r,e,r.path,t))));return r.common.async?Promise.all(l).then((e=>n(e))):n(l)}min(e,t){return new fe({...this._def,minSize:{value:e,message:_.toString(t)}})}max(e,t){return new fe({...this._def,maxSize:{value:e,message:_.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}fe.create=(e,t)=>new fe({valueType:e,minSize:null,maxSize:null,typeName:Ie.ZodSet,...P(t)});class ve extends E{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ve.create=(e,t)=>new ve({getter:e,typeName:Ie.ZodLazy,...P(t)});class ye extends E{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return d(t,{received:t.data,code:o.invalid_literal,expected:this._def.value}),h}return{status:"valid",value:e.data}}get value(){return this._def.value}}function ge(e,t){return new _e({values:e,typeName:Ie.ZodEnum,...P(t)})}ye.create=(e,t)=>new ye({value:e,typeName:Ie.ZodLiteral,...P(t)});class _e extends E{_parse(e){if("string"!=typeof e.data){const t=this._getOrReturnCtx(e),a=this._def.values;return d(t,{expected:r.joinValues(a),received:t.parsedType,code:o.invalid_type}),h}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const t=this._getOrReturnCtx(e),r=this._def.values;return d(t,{received:t.data,code:o.invalid_enum_value,options:r}),h}return m(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return _e.create(e,{...this._def,...t})}exclude(e,t=this._def){return _e.create(this.options.filter((t=>!e.includes(t))),{...this._def,...t})}}_e.create=ge;class we extends E{_parse(e){const t=r.getValidEnumValues(this._def.values),a=this._getOrReturnCtx(e);if(a.parsedType!==s.string&&a.parsedType!==s.number){const e=r.objectValues(t);return d(a,{expected:r.joinValues(e),received:a.parsedType,code:o.invalid_type}),h}if(this._cache||(this._cache=new Set(r.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const e=r.objectValues(t);return d(a,{received:a.data,code:o.invalid_enum_value,options:e}),h}return m(e.data)}get enum(){return this._def.values}}we.create=(e,t)=>new we({values:e,typeName:Ie.ZodNativeEnum,...P(t)});class be extends E{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==s.promise&&!1===t.common.async)return d(t,{code:o.invalid_type,expected:s.promise,received:t.parsedType}),h;const r=t.parsedType===s.promise?t.data:Promise.resolve(t.data);return m(r.then((e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap}))))}}be.create=(e,t)=>new be({type:e,typeName:Ie.ZodPromise,...P(t)});class Pe extends E{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ie.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:a}=this._processInputParams(e),s=this._def.effect||null,i={addIssue:e=>{d(a,e),e.fatal?t.abort():t.dirty()},get path(){return a.path}};if(i.addIssue=i.addIssue.bind(i),"preprocess"===s.type){const e=s.transform(a.data,i);if(a.common.async)return Promise.resolve(e).then((async e=>{if("aborted"===t.value)return h;const r=await this._def.schema._parseAsync({data:e,path:a.path,parent:a});return"aborted"===r.status?h:"dirty"===r.status||"dirty"===t.value?p(r.value):r}));{if("aborted"===t.value)return h;const r=this._def.schema._parseSync({data:e,path:a.path,parent:a});return"aborted"===r.status?h:"dirty"===r.status||"dirty"===t.value?p(r.value):r}}if("refinement"===s.type){const e=e=>{const t=s.refinement(e,i);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){const r=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===r.status?h:("dirty"===r.status&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((r=>"aborted"===r.status?h:("dirty"===r.status&&t.dirty(),e(r.value).then((()=>({status:t.value,value:r.value}))))))}if("transform"===s.type){if(!1===a.common.async){const e=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!y(e))return h;const r=s.transform(e.value,i);if(r instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:r}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((e=>y(e)?Promise.resolve(s.transform(e.value,i)).then((e=>({status:t.value,value:e}))):h))}r.assertNever(s)}}Pe.create=(e,t,r)=>new Pe({schema:e,typeName:Ie.ZodEffects,effect:t,...P(r)}),Pe.createWithPreprocess=(e,t,r)=>new Pe({schema:t,effect:{type:"preprocess",transform:e},typeName:Ie.ZodEffects,...P(r)});class Ee extends E{_parse(e){return this._getType(e)===s.undefined?m(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Ee.create=(e,t)=>new Ee({innerType:e,typeName:Ie.ZodOptional,...P(t)});class xe extends E{_parse(e){return this._getType(e)===s.null?m(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xe.create=(e,t)=>new xe({innerType:e,typeName:Ie.ZodNullable,...P(t)});class ke extends E{_parse(e){const{ctx:t}=this._processInputParams(e);let r=t.data;return t.parsedType===s.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ke.create=(e,t)=>new ke({innerType:e,typeName:Ie.ZodDefault,defaultValue:"function"==typeof t.default?t.default:()=>t.default,...P(t)});class Se extends E{_parse(e){const{ctx:t}=this._processInputParams(e),r={...t,common:{...t.common,issues:[]}},a=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return g(a)?a.then((e=>({status:"valid",value:"valid"===e.status?e.value:this._def.catchValue({get error(){return new n(r.common.issues)},input:r.data})}))):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new n(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}Se.create=(e,t)=>new Se({innerType:e,typeName:Ie.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:()=>t.catch,...P(t)});class Re extends E{_parse(e){if(this._getType(e)!==s.nan){const t=this._getOrReturnCtx(e);return d(t,{code:o.invalid_type,expected:s.nan,received:t.parsedType}),h}return{status:"valid",value:e.data}}}Re.create=e=>new Re({typeName:Ie.ZodNaN,...P(e)});class Oe extends E{_parse(e){const{ctx:t}=this._processInputParams(e),r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}unwrap(){return this._def.type}}class Te extends E{_parse(e){const{status:t,ctx:r}=this._processInputParams(e);if(r.common.async){return(async()=>{const e=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?h:"dirty"===e.status?(t.dirty(),p(e.value)):this._def.out._parseAsync({data:e.value,path:r.path,parent:r})})()}{const e=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return"aborted"===e.status?h:"dirty"===e.status?(t.dirty(),{status:"dirty",value:e.value}):this._def.out._parseSync({data:e.value,path:r.path,parent:r})}}static create(e,t){return new Te({in:e,out:t,typeName:Ie.ZodPipeline})}}class $e extends E{_parse(e){const t=this._def.innerType._parse(e),r=e=>(y(e)&&(e.value=Object.freeze(e.value)),e);return g(t)?t.then((e=>r(e))):r(t)}unwrap(){return this._def.innerType}}var Ie;$e.create=(e,t)=>new $e({innerType:e,typeName:Ie.ZodReadonly,...P(t)}),function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(Ie||(Ie={}));const Ce=H.create,je=K.create,Fe=W.create,Ae=ee.create,De=te.create;re.create;const Ne=se.create,qe=oe.create,Le=ne.create,ze=ce.create;ue.create,he.create;const Ze=pe.create,Me=ye.create,Ue=_e.create;be.create;const Ve=Ee.create;xe.create;const He="2025-03-26",Qe=[He,"2024-11-05","2024-10-07"],Ke="2.0",Be=Le([Ce(),je().int()]),We=Ce(),Je=qe({progressToken:Ve(Be)}).passthrough(),Ge=qe({_meta:Ve(Je)}).passthrough(),Ye=qe({method:Ce(),params:Ve(Ge)}),Xe=qe({_meta:Ve(qe({}).passthrough())}).passthrough(),et=qe({method:Ce(),params:Ve(Xe)}),tt=qe({_meta:Ve(qe({}).passthrough())}).passthrough(),rt=Le([Ce(),je().int()]),at=qe({jsonrpc:Me(Ke),id:rt}).merge(Ye).strict(),st=e=>at.safeParse(e).success,it=qe({jsonrpc:Me(Ke)}).merge(et).strict(),ot=qe({jsonrpc:Me(Ke),id:rt,result:tt}).strict(),nt=e=>ot.safeParse(e).success;var lt;!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"}(lt||(lt={}));const ct=qe({jsonrpc:Me(Ke),id:rt,error:qe({code:je().int(),message:Ce(),data:Ve(De())})}).strict(),dt=Le([at,it,ot,ct]),ut=tt.strict(),ht=et.extend({method:Me("notifications/cancelled"),params:Xe.extend({requestId:rt,reason:Ce().optional()})}),pt=qe({name:Ce(),version:Ce()}).passthrough(),mt=qe({experimental:Ve(qe({}).passthrough()),sampling:Ve(qe({}).passthrough()),roots:Ve(qe({listChanged:Ve(Fe())}).passthrough())}).passthrough(),ft=Ye.extend({method:Me("initialize"),params:Ge.extend({protocolVersion:Ce(),capabilities:mt,clientInfo:pt})}),vt=qe({experimental:Ve(qe({}).passthrough()),logging:Ve(qe({}).passthrough()),completions:Ve(qe({}).passthrough()),prompts:Ve(qe({listChanged:Ve(Fe())}).passthrough()),resources:Ve(qe({subscribe:Ve(Fe()),listChanged:Ve(Fe())}).passthrough()),tools:Ve(qe({listChanged:Ve(Fe())}).passthrough())}).passthrough(),yt=tt.extend({protocolVersion:Ce(),capabilities:vt,serverInfo:pt,instructions:Ve(Ce())}),gt=et.extend({method:Me("notifications/initialized")}),_t=Ye.extend({method:Me("ping")}),wt=qe({progress:je(),total:Ve(je()),message:Ve(Ce())}).passthrough(),bt=et.extend({method:Me("notifications/progress"),params:Xe.merge(wt).extend({progressToken:Be})}),Pt=Ye.extend({params:Ge.extend({cursor:Ve(We)}).optional()}),Et=tt.extend({nextCursor:Ve(We)}),xt=qe({uri:Ce(),mimeType:Ve(Ce())}).passthrough(),kt=xt.extend({text:Ce()}),St=xt.extend({blob:Ce().base64()}),Rt=qe({uri:Ce(),name:Ce(),description:Ve(Ce()),mimeType:Ve(Ce())}).passthrough(),Ot=qe({uriTemplate:Ce(),name:Ce(),description:Ve(Ce()),mimeType:Ve(Ce())}).passthrough(),Tt=Pt.extend({method:Me("resources/list")}),$t=Et.extend({resources:Ne(Rt)}),It=Pt.extend({method:Me("resources/templates/list")}),Ct=Et.extend({resourceTemplates:Ne(Ot)}),jt=Ye.extend({method:Me("resources/read"),params:Ge.extend({uri:Ce()})}),Ft=tt.extend({contents:Ne(Le([kt,St]))}),At=et.extend({method:Me("notifications/resources/list_changed")}),Dt=Ye.extend({method:Me("resources/subscribe"),params:Ge.extend({uri:Ce()})}),Nt=Ye.extend({method:Me("resources/unsubscribe"),params:Ge.extend({uri:Ce()})}),qt=et.extend({method:Me("notifications/resources/updated"),params:Xe.extend({uri:Ce()})}),Lt=qe({name:Ce(),description:Ve(Ce()),required:Ve(Fe())}).passthrough(),zt=qe({name:Ce(),description:Ve(Ce()),arguments:Ve(Ne(Lt))}).passthrough(),Zt=Pt.extend({method:Me("prompts/list")}),Mt=Et.extend({prompts:Ne(zt)}),Ut=Ye.extend({method:Me("prompts/get"),params:Ge.extend({name:Ce(),arguments:Ve(Ze(Ce()))})}),Vt=qe({type:Me("text"),text:Ce()}).passthrough(),Ht=qe({type:Me("image"),data:Ce().base64(),mimeType:Ce()}).passthrough(),Qt=qe({type:Me("audio"),data:Ce().base64(),mimeType:Ce()}).passthrough(),Kt=qe({type:Me("resource"),resource:Le([kt,St])}).passthrough(),Bt=qe({role:Ue(["user","assistant"]),content:Le([Vt,Ht,Qt,Kt])}).passthrough(),Wt=tt.extend({description:Ve(Ce()),messages:Ne(Bt)}),Jt=et.extend({method:Me("notifications/prompts/list_changed")}),Gt=qe({title:Ve(Ce()),readOnlyHint:Ve(Fe()),destructiveHint:Ve(Fe()),idempotentHint:Ve(Fe()),openWorldHint:Ve(Fe())}).passthrough(),Yt=qe({name:Ce(),description:Ve(Ce()),inputSchema:qe({type:Me("object"),properties:Ve(qe({}).passthrough()),required:Ve(Ne(Ce()))}).passthrough(),outputSchema:Ve(qe({type:Me("object"),properties:Ve(qe({}).passthrough()),required:Ve(Ne(Ce()))}).passthrough()),annotations:Ve(Gt)}).passthrough(),Xt=Pt.extend({method:Me("tools/list")}),er=Et.extend({tools:Ne(Yt)}),tr=tt.extend({content:Ne(Le([Vt,Ht,Qt,Kt])).default([]),structuredContent:qe({}).passthrough().optional(),isError:Ve(Fe())});tr.or(tt.extend({toolResult:De()}));const rr=Ye.extend({method:Me("tools/call"),params:Ge.extend({name:Ce(),arguments:Ve(Ze(De()))})}),ar=et.extend({method:Me("notifications/tools/list_changed")}),sr=Ue(["debug","info","notice","warning","error","critical","alert","emergency"]),ir=Ye.extend({method:Me("logging/setLevel"),params:Ge.extend({level:sr})}),or=et.extend({method:Me("notifications/message"),params:Xe.extend({level:sr,logger:Ve(Ce()),data:De()})}),nr=qe({name:Ce().optional()}).passthrough(),lr=qe({hints:Ve(Ne(nr)),costPriority:Ve(je().min(0).max(1)),speedPriority:Ve(je().min(0).max(1)),intelligencePriority:Ve(je().min(0).max(1))}).passthrough(),cr=qe({role:Ue(["user","assistant"]),content:Le([Vt,Ht,Qt])}).passthrough(),dr=Ye.extend({method:Me("sampling/createMessage"),params:Ge.extend({messages:Ne(cr),systemPrompt:Ve(Ce()),includeContext:Ve(Ue(["none","thisServer","allServers"])),temperature:Ve(je()),maxTokens:je().int(),stopSequences:Ve(Ne(Ce())),metadata:Ve(qe({}).passthrough()),modelPreferences:Ve(lr)})}),ur=tt.extend({model:Ce(),stopReason:Ve(Ue(["endTurn","stopSequence","maxTokens"]).or(Ce())),role:Ue(["user","assistant"]),content:ze("type",[Vt,Ht,Qt])}),hr=qe({type:Me("ref/resource"),uri:Ce()}).passthrough(),pr=qe({type:Me("ref/prompt"),name:Ce()}).passthrough(),mr=Ye.extend({method:Me("completion/complete"),params:Ge.extend({ref:Le([pr,hr]),argument:qe({name:Ce(),value:Ce()}).passthrough()})}),fr=tt.extend({completion:qe({values:Ne(Ce()).max(100),total:Ve(je().int()),hasMore:Ve(Fe())}).passthrough()}),vr=qe({uri:Ce().startsWith("file://"),name:Ve(Ce())}).passthrough(),yr=Ye.extend({method:Me("roots/list")}),gr=tt.extend({roots:Ne(vr)}),_r=et.extend({method:Me("notifications/roots/list_changed")});Le([_t,ft,mr,ir,Ut,Zt,Tt,It,jt,Dt,Nt,rr,Xt]),Le([ht,bt,gt,_r]),Le([ut,ur,gr]),Le([_t,dr,yr]),Le([ht,bt,or,qt,At,ar,Jt]),Le([ut,yt,fr,Wt,Mt,$t,Ct,Ft,tr,er]);class wr extends Error{constructor(e,t,r){super(`MCP error ${e}: ${t}`),this.code=e,this.data=r,this.name="McpError"}}class br{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this.setNotificationHandler(ht,(e=>{const t=this._requestHandlerAbortControllers.get(e.params.requestId);null==t||t.abort(e.params.reason)})),this.setNotificationHandler(bt,(e=>{this._onprogress(e)})),this.setRequestHandler(_t,(e=>({})))}_setupTimeout(e,t,r,a,s=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(a,t),startTime:Date.now(),timeout:t,maxTotalTimeout:r,resetTimeoutOnProgress:s,onTimeout:a})}_resetTimeout(e){const t=this._timeoutInfo.get(e);if(!t)return!1;const r=Date.now()-t.startTime;if(t.maxTotalTimeout&&r>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new wr(lt.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:r});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){const t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=e=>{this._onerror(e)},this._transport.onmessage=(e,t)=>{var r;nt(e)||(r=e,ct.safeParse(r).success)?this._onresponse(e):st(e)?this._onrequest(e,t):(e=>it.safeParse(e).success)(e)?this._onnotification(e):this._onerror(new Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){var e;const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,null===(e=this.onclose)||void 0===e||e.call(this);const r=new wr(lt.ConnectionClosed,"Connection closed");for(const e of t.values())e(r)}_onerror(e){var t;null===(t=this.onerror)||void 0===t||t.call(this,e)}_onnotification(e){var t;const r=null!==(t=this._notificationHandlers.get(e.method))&&void 0!==t?t:this.fallbackNotificationHandler;void 0!==r&&Promise.resolve().then((()=>r(e))).catch((e=>this._onerror(new Error(`Uncaught error in notification handler: ${e}`))))}_onrequest(e,t){var r,a,s,i;const o=null!==(r=this._requestHandlers.get(e.method))&&void 0!==r?r:this.fallbackRequestHandler;if(void 0===o)return void(null===(a=this._transport)||void 0===a||a.send({jsonrpc:"2.0",id:e.id,error:{code:lt.MethodNotFound,message:"Method not found"}}).catch((e=>this._onerror(new Error(`Failed to send an error response: ${e}`)))));const n=new AbortController;this._requestHandlerAbortControllers.set(e.id,n);const l={signal:n.signal,sessionId:null===(s=this._transport)||void 0===s?void 0:s.sessionId,_meta:null===(i=e.params)||void 0===i?void 0:i._meta,sendNotification:t=>this.notification(t,{relatedRequestId:e.id}),sendRequest:(t,r,a)=>this.request(t,r,{...a,relatedRequestId:e.id}),authInfo:null==t?void 0:t.authInfo,requestId:e.id};Promise.resolve().then((()=>o(e,l))).then((t=>{var r;if(!n.signal.aborted)return null===(r=this._transport)||void 0===r?void 0:r.send({result:t,jsonrpc:"2.0",id:e.id})}),(t=>{var r,a;if(!n.signal.aborted)return null===(r=this._transport)||void 0===r?void 0:r.send({jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:lt.InternalError,message:null!==(a=t.message)&&void 0!==a?a:"Internal error"}})})).catch((e=>this._onerror(new Error(`Failed to send response: ${e}`)))).finally((()=>{this._requestHandlerAbortControllers.delete(e.id)}))}_onprogress(e){const{progressToken:t,...r}=e.params,a=Number(t),s=this._progressHandlers.get(a);if(!s)return void this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));const i=this._responseHandlers.get(a),o=this._timeoutInfo.get(a);if(o&&i&&o.resetTimeoutOnProgress)try{this._resetTimeout(a)}catch(e){return void i(e)}s(r)}_onresponse(e){const t=Number(e.id),r=this._responseHandlers.get(t);if(void 0!==r)if(this._responseHandlers.delete(t),this._progressHandlers.delete(t),this._cleanupTimeout(t),nt(e))r(e);else{r(new wr(e.error.code,e.error.message,e.error.data))}else this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`))}get transport(){return this._transport}async close(){var e;await(null===(e=this._transport)||void 0===e?void 0:e.close())}request(e,t,r){const{relatedRequestId:a,resumptionToken:s,onresumptiontoken:i}=null!=r?r:{};return new Promise(((o,n)=>{var l,c,d,u,h,p;if(!this._transport)return void n(new Error("Not connected"));!0===(null===(l=this._options)||void 0===l?void 0:l.enforceStrictCapabilities)&&this.assertCapabilityForMethod(e.method),null===(c=null==r?void 0:r.signal)||void 0===c||c.throwIfAborted();const m=this._requestMessageId++,f={...e,jsonrpc:"2.0",id:m};(null==r?void 0:r.onprogress)&&(this._progressHandlers.set(m,r.onprogress),f.params={...e.params,_meta:{...(null===(d=e.params)||void 0===d?void 0:d._meta)||{},progressToken:m}});const v=e=>{var t;this._responseHandlers.delete(m),this._progressHandlers.delete(m),this._cleanupTimeout(m),null===(t=this._transport)||void 0===t||t.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:m,reason:String(e)}},{relatedRequestId:a,resumptionToken:s,onresumptiontoken:i}).catch((e=>this._onerror(new Error(`Failed to send cancellation: ${e}`)))),n(e)};this._responseHandlers.set(m,(e=>{var a;if(!(null===(a=null==r?void 0:r.signal)||void 0===a?void 0:a.aborted)){if(e instanceof Error)return n(e);try{const r=t.parse(e.result);o(r)}catch(e){n(e)}}})),null===(u=null==r?void 0:r.signal)||void 0===u||u.addEventListener("abort",(()=>{var e;v(null===(e=null==r?void 0:r.signal)||void 0===e?void 0:e.reason)}));const y=null!==(h=null==r?void 0:r.timeout)&&void 0!==h?h:6e4;this._setupTimeout(m,y,null==r?void 0:r.maxTotalTimeout,(()=>v(new wr(lt.RequestTimeout,"Request timed out",{timeout:y}))),null!==(p=null==r?void 0:r.resetTimeoutOnProgress)&&void 0!==p&&p),this._transport.send(f,{relatedRequestId:a,resumptionToken:s,onresumptiontoken:i}).catch((e=>{this._cleanupTimeout(m),n(e)}))}))}async notification(e,t){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);const r={...e,jsonrpc:"2.0"};await this._transport.send(r,t)}setRequestHandler(e,t){const r=e.shape.method.value;this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,((r,a)=>Promise.resolve(t(e.parse(r),a))))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){this._notificationHandlers.set(e.shape.method.value,(r=>Promise.resolve(t(e.parse(r)))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function Pr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Er={exports:{}};
2
+ /** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */!function(e,t){!function(e){function t(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];if(t.length>1){t[0]=t[0].slice(0,-1);for(var a=t.length-1,s=1;s<a;++s)t[s]=t[s].slice(1,-1);return t[a]=t[a].slice(1),t.join("")}return t[0]}function r(e){return"(?:"+e+")"}function a(e){return void 0===e?"undefined":null===e?"null":Object.prototype.toString.call(e).split(" ").pop().split("]").shift().toLowerCase()}function s(e){return e.toUpperCase()}function i(e){return null!=e?e instanceof Array?e:"number"!=typeof e.length||e.split||e.setInterval||e.call?[e]:Array.prototype.slice.call(e):[]}function o(e,t){var r=e;if(t)for(var a in t)r[a]=t[a];return r}function n(e){var a="[A-Za-z]",s="[0-9]",i=t(s,"[A-Fa-f]"),o=r(r("%[EFef]"+i+"%"+i+i+"%"+i+i)+"|"+r("%[89A-Fa-f]"+i+"%"+i+i)+"|"+r("%"+i+i)),n="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",l=t("[\\:\\/\\?\\#\\[\\]\\@]",n),c=e?"[\\uE000-\\uF8FF]":"[]",d=t(a,s,"[\\-\\.\\_\\~]",e?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]");r(a+t(a,s,"[\\+\\-\\.]")+"*"),r(r(o+"|"+t(d,n,"[\\:]"))+"*");var u=r(r("25[0-5]")+"|"+r("2[0-4]"+s)+"|"+r("1"+s+s)+"|"+r("0?[1-9]"+s)+"|0?0?"+s),h=r(u+"\\."+u+"\\."+u+"\\."+u),p=r(i+"{1,4}"),m=r(r(p+"\\:"+p)+"|"+h),f=r(r(p+"\\:")+"{6}"+m),v=r("\\:\\:"+r(p+"\\:")+"{5}"+m),y=r(r(p)+"?\\:\\:"+r(p+"\\:")+"{4}"+m),g=r(r(r(p+"\\:")+"{0,1}"+p)+"?\\:\\:"+r(p+"\\:")+"{3}"+m),_=r(r(r(p+"\\:")+"{0,2}"+p)+"?\\:\\:"+r(p+"\\:")+"{2}"+m),w=r(r(r(p+"\\:")+"{0,3}"+p)+"?\\:\\:"+p+"\\:"+m),b=r(r(r(p+"\\:")+"{0,4}"+p)+"?\\:\\:"+m),P=r(r(r(p+"\\:")+"{0,5}"+p)+"?\\:\\:"+p),E=r(r(r(p+"\\:")+"{0,6}"+p)+"?\\:\\:"),x=r([f,v,y,g,_,w,b,P,E].join("|")),k=r(r(d+"|"+o)+"+");r("[vV]"+i+"+\\."+t(d,n,"[\\:]")+"+"),r(r(o+"|"+t(d,n))+"*");var S=r(o+"|"+t(d,n,"[\\:\\@]"));return r(r(o+"|"+t(d,n,"[\\@]"))+"+"),r(r(S+"|"+t("[\\/\\?]",c))+"*"),{NOT_SCHEME:new RegExp(t("[^]",a,s,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(t("[^\\%\\:]",d,n),"g"),NOT_HOST:new RegExp(t("[^\\%\\[\\]\\:]",d,n),"g"),NOT_PATH:new RegExp(t("[^\\%\\/\\:\\@]",d,n),"g"),NOT_PATH_NOSCHEME:new RegExp(t("[^\\%\\/\\@]",d,n),"g"),NOT_QUERY:new RegExp(t("[^\\%]",d,n,"[\\:\\@\\/\\?]",c),"g"),NOT_FRAGMENT:new RegExp(t("[^\\%]",d,n,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(t("[^]",d,n),"g"),UNRESERVED:new RegExp(d,"g"),OTHER_CHARS:new RegExp(t("[^\\%]",d,l),"g"),PCT_ENCODED:new RegExp(o,"g"),IPV4ADDRESS:new RegExp("^("+h+")$"),IPV6ADDRESS:new RegExp("^\\[?("+x+")"+r(r("\\%25|\\%(?!"+i+"{2})")+"("+k+")")+"?\\]?$")}}var l=n(!1),c=n(!0),d=function(){function e(e,t){var r=[],a=!0,s=!1,i=void 0;try{for(var o,n=e[Symbol.iterator]();!(a=(o=n.next()).done)&&(r.push(o.value),!t||r.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{!a&&n.return&&n.return()}finally{if(s)throw i}}return r}return function(t,r){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,r);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),u=function(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)},h=2147483647,p=36,m=1,f=26,v=38,y=700,g=72,_=128,w="-",b=/^xn--/,P=/[^\0-\x7E]/,E=/[\x2E\u3002\uFF0E\uFF61]/g,x={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},k=p-m,S=Math.floor,R=String.fromCharCode;function O(e){throw new RangeError(x[e])}function T(e,t){for(var r=[],a=e.length;a--;)r[a]=t(e[a]);return r}function $(e,t){var r=e.split("@"),a="";return r.length>1&&(a=r[0]+"@",e=r[1]),a+T((e=e.replace(E,".")).split("."),t).join(".")}function I(e){for(var t=[],r=0,a=e.length;r<a;){var s=e.charCodeAt(r++);if(s>=55296&&s<=56319&&r<a){var i=e.charCodeAt(r++);56320==(64512&i)?t.push(((1023&s)<<10)+(1023&i)+65536):(t.push(s),r--)}else t.push(s)}return t}var C=function(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:p},j=function(e,t){return e+22+75*(e<26)-((0!=t)<<5)},F=function(e,t,r){var a=0;for(e=r?S(e/y):e>>1,e+=S(e/t);e>k*f>>1;a+=p)e=S(e/k);return S(a+(k+1)*e/(e+v))},A=function(e){var t=[],r=e.length,a=0,s=_,i=g,o=e.lastIndexOf(w);o<0&&(o=0);for(var n=0;n<o;++n)e.charCodeAt(n)>=128&&O("not-basic"),t.push(e.charCodeAt(n));for(var l=o>0?o+1:0;l<r;){for(var c=a,d=1,u=p;;u+=p){l>=r&&O("invalid-input");var v=C(e.charCodeAt(l++));(v>=p||v>S((h-a)/d))&&O("overflow"),a+=v*d;var y=u<=i?m:u>=i+f?f:u-i;if(v<y)break;var b=p-y;d>S(h/b)&&O("overflow"),d*=b}var P=t.length+1;i=F(a-c,P,0==c),S(a/P)>h-s&&O("overflow"),s+=S(a/P),a%=P,t.splice(a++,0,s)}return String.fromCodePoint.apply(String,t)},D=function(e){var t=[],r=(e=I(e)).length,a=_,s=0,i=g,o=!0,n=!1,l=void 0;try{for(var c,d=e[Symbol.iterator]();!(o=(c=d.next()).done);o=!0){var u=c.value;u<128&&t.push(R(u))}}catch(e){n=!0,l=e}finally{try{!o&&d.return&&d.return()}finally{if(n)throw l}}var v=t.length,y=v;for(v&&t.push(w);y<r;){var b=h,P=!0,E=!1,x=void 0;try{for(var k,T=e[Symbol.iterator]();!(P=(k=T.next()).done);P=!0){var $=k.value;$>=a&&$<b&&(b=$)}}catch(e){E=!0,x=e}finally{try{!P&&T.return&&T.return()}finally{if(E)throw x}}var C=y+1;b-a>S((h-s)/C)&&O("overflow"),s+=(b-a)*C,a=b;var A=!0,D=!1,N=void 0;try{for(var q,L=e[Symbol.iterator]();!(A=(q=L.next()).done);A=!0){var z=q.value;if(z<a&&++s>h&&O("overflow"),z==a){for(var Z=s,M=p;;M+=p){var U=M<=i?m:M>=i+f?f:M-i;if(Z<U)break;var V=Z-U,H=p-U;t.push(R(j(U+V%H,0))),Z=S(V/H)}t.push(R(j(Z,0))),i=F(s,C,y==v),s=0,++y}}}catch(e){D=!0,N=e}finally{try{!A&&L.return&&L.return()}finally{if(D)throw N}}++s,++a}return t.join("")},N=function(e){return $(e,(function(e){return b.test(e)?A(e.slice(4).toLowerCase()):e}))},q=function(e){return $(e,(function(e){return P.test(e)?"xn--"+D(e):e}))},L={version:"2.1.0",ucs2:{decode:I,encode:function(e){return String.fromCodePoint.apply(String,u(e))}},decode:A,encode:D,toASCII:q,toUnicode:N},z={};function Z(e){var t=e.charCodeAt(0);return t<16?"%0"+t.toString(16).toUpperCase():t<128?"%"+t.toString(16).toUpperCase():t<2048?"%"+(t>>6|192).toString(16).toUpperCase()+"%"+(63&t|128).toString(16).toUpperCase():"%"+(t>>12|224).toString(16).toUpperCase()+"%"+(t>>6&63|128).toString(16).toUpperCase()+"%"+(63&t|128).toString(16).toUpperCase()}function M(e){for(var t="",r=0,a=e.length;r<a;){var s=parseInt(e.substr(r+1,2),16);if(s<128)t+=String.fromCharCode(s),r+=3;else if(s>=194&&s<224){if(a-r>=6){var i=parseInt(e.substr(r+4,2),16);t+=String.fromCharCode((31&s)<<6|63&i)}else t+=e.substr(r,6);r+=6}else if(s>=224){if(a-r>=9){var o=parseInt(e.substr(r+4,2),16),n=parseInt(e.substr(r+7,2),16);t+=String.fromCharCode((15&s)<<12|(63&o)<<6|63&n)}else t+=e.substr(r,9);r+=9}else t+=e.substr(r,3),r+=3}return t}function U(e,t){function r(e){var r=M(e);return r.match(t.UNRESERVED)?r:e}return e.scheme&&(e.scheme=String(e.scheme).replace(t.PCT_ENCODED,r).toLowerCase().replace(t.NOT_SCHEME,"")),void 0!==e.userinfo&&(e.userinfo=String(e.userinfo).replace(t.PCT_ENCODED,r).replace(t.NOT_USERINFO,Z).replace(t.PCT_ENCODED,s)),void 0!==e.host&&(e.host=String(e.host).replace(t.PCT_ENCODED,r).toLowerCase().replace(t.NOT_HOST,Z).replace(t.PCT_ENCODED,s)),void 0!==e.path&&(e.path=String(e.path).replace(t.PCT_ENCODED,r).replace(e.scheme?t.NOT_PATH:t.NOT_PATH_NOSCHEME,Z).replace(t.PCT_ENCODED,s)),void 0!==e.query&&(e.query=String(e.query).replace(t.PCT_ENCODED,r).replace(t.NOT_QUERY,Z).replace(t.PCT_ENCODED,s)),void 0!==e.fragment&&(e.fragment=String(e.fragment).replace(t.PCT_ENCODED,r).replace(t.NOT_FRAGMENT,Z).replace(t.PCT_ENCODED,s)),e}function V(e){return e.replace(/^0*(.*)/,"$1")||"0"}function H(e,t){var r=e.match(t.IPV4ADDRESS)||[],a=d(r,2)[1];return a?a.split(".").map(V).join("."):e}function Q(e,t){var r=e.match(t.IPV6ADDRESS)||[],a=d(r,3),s=a[1],i=a[2];if(s){for(var o=s.toLowerCase().split("::").reverse(),n=d(o,2),l=n[0],c=n[1],u=c?c.split(":").map(V):[],h=l.split(":").map(V),p=t.IPV4ADDRESS.test(h[h.length-1]),m=p?7:8,f=h.length-m,v=Array(m),y=0;y<m;++y)v[y]=u[y]||h[f+y]||"";p&&(v[m-1]=H(v[m-1],t));var g=v.reduce((function(e,t,r){if(!t||"0"===t){var a=e[e.length-1];a&&a.index+a.length===r?a.length++:e.push({index:r,length:1})}return e}),[]).sort((function(e,t){return t.length-e.length}))[0],_=void 0;if(g&&g.length>1){var w=v.slice(0,g.index),b=v.slice(g.index+g.length);_=w.join(":")+"::"+b.join(":")}else _=v.join(":");return i&&(_+="%"+i),_}return e}var K=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,B=void 0==="".match(/(){0}/)[1];function W(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={},a=!1!==t.iri?c:l;"suffix"===t.reference&&(e=(t.scheme?t.scheme+":":"")+"//"+e);var s=e.match(K);if(s){B?(r.scheme=s[1],r.userinfo=s[3],r.host=s[4],r.port=parseInt(s[5],10),r.path=s[6]||"",r.query=s[7],r.fragment=s[8],isNaN(r.port)&&(r.port=s[5])):(r.scheme=s[1]||void 0,r.userinfo=-1!==e.indexOf("@")?s[3]:void 0,r.host=-1!==e.indexOf("//")?s[4]:void 0,r.port=parseInt(s[5],10),r.path=s[6]||"",r.query=-1!==e.indexOf("?")?s[7]:void 0,r.fragment=-1!==e.indexOf("#")?s[8]:void 0,isNaN(r.port)&&(r.port=e.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?s[4]:void 0)),r.host&&(r.host=Q(H(r.host,a),a)),void 0!==r.scheme||void 0!==r.userinfo||void 0!==r.host||void 0!==r.port||r.path||void 0!==r.query?void 0===r.scheme?r.reference="relative":void 0===r.fragment?r.reference="absolute":r.reference="uri":r.reference="same-document",t.reference&&"suffix"!==t.reference&&t.reference!==r.reference&&(r.error=r.error||"URI is not a "+t.reference+" reference.");var i=z[(t.scheme||r.scheme||"").toLowerCase()];if(t.unicodeSupport||i&&i.unicodeSupport)U(r,a);else{if(r.host&&(t.domainHost||i&&i.domainHost))try{r.host=L.toASCII(r.host.replace(a.PCT_ENCODED,M).toLowerCase())}catch(e){r.error=r.error||"Host's domain name can not be converted to ASCII via punycode: "+e}U(r,l)}i&&i.parse&&i.parse(r,t)}else r.error=r.error||"URI can not be parsed.";return r}function J(e,t){var r=!1!==t.iri?c:l,a=[];return void 0!==e.userinfo&&(a.push(e.userinfo),a.push("@")),void 0!==e.host&&a.push(Q(H(String(e.host),r),r).replace(r.IPV6ADDRESS,(function(e,t,r){return"["+t+(r?"%25"+r:"")+"]"}))),"number"!=typeof e.port&&"string"!=typeof e.port||(a.push(":"),a.push(String(e.port))),a.length?a.join(""):void 0}var G=/^\.\.?\//,Y=/^\/\.(\/|$)/,X=/^\/\.\.(\/|$)/,ee=/^\/?(?:.|\n)*?(?=\/|$)/;function te(e){for(var t=[];e.length;)if(e.match(G))e=e.replace(G,"");else if(e.match(Y))e=e.replace(Y,"/");else if(e.match(X))e=e.replace(X,"/"),t.pop();else if("."===e||".."===e)e="";else{var r=e.match(ee);if(!r)throw new Error("Unexpected dot segment condition");var a=r[0];e=e.slice(a.length),t.push(a)}return t.join("")}function re(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.iri?c:l,a=[],s=z[(t.scheme||e.scheme||"").toLowerCase()];if(s&&s.serialize&&s.serialize(e,t),e.host)if(r.IPV6ADDRESS.test(e.host));else if(t.domainHost||s&&s.domainHost)try{e.host=t.iri?L.toUnicode(e.host):L.toASCII(e.host.replace(r.PCT_ENCODED,M).toLowerCase())}catch(r){e.error=e.error||"Host's domain name can not be converted to "+(t.iri?"Unicode":"ASCII")+" via punycode: "+r}U(e,r),"suffix"!==t.reference&&e.scheme&&(a.push(e.scheme),a.push(":"));var i=J(e,t);if(void 0!==i&&("suffix"!==t.reference&&a.push("//"),a.push(i),e.path&&"/"!==e.path.charAt(0)&&a.push("/")),void 0!==e.path){var o=e.path;t.absolutePath||s&&s.absolutePath||(o=te(o)),void 0===i&&(o=o.replace(/^\/\//,"/%2F")),a.push(o)}return void 0!==e.query&&(a.push("?"),a.push(e.query)),void 0!==e.fragment&&(a.push("#"),a.push(e.fragment)),a.join("")}function ae(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a={};return arguments[3]||(e=W(re(e,r),r),t=W(re(t,r),r)),!(r=r||{}).tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=te(t.path||""),a.query=t.query):(void 0!==t.userinfo||void 0!==t.host||void 0!==t.port?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=te(t.path||""),a.query=t.query):(t.path?("/"===t.path.charAt(0)?a.path=te(t.path):(void 0===e.userinfo&&void 0===e.host&&void 0===e.port||e.path?e.path?a.path=e.path.slice(0,e.path.lastIndexOf("/")+1)+t.path:a.path=t.path:a.path="/"+t.path,a.path=te(a.path)),a.query=t.query):(a.path=e.path,void 0!==t.query?a.query=t.query:a.query=e.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function se(e,t,r){var a=o({scheme:"null"},r);return re(ae(W(e,a),W(t,a),a,!0),a)}function ie(e,t){return"string"==typeof e?e=re(W(e,t),t):"object"===a(e)&&(e=W(re(e,t),t)),e}function oe(e,t,r){return"string"==typeof e?e=re(W(e,r),r):"object"===a(e)&&(e=re(e,r)),"string"==typeof t?t=re(W(t,r),r):"object"===a(t)&&(t=re(t,r)),e===t}function ne(e,t){return e&&e.toString().replace(t&&t.iri?c.ESCAPE:l.ESCAPE,Z)}function le(e,t){return e&&e.toString().replace(t&&t.iri?c.PCT_ENCODED:l.PCT_ENCODED,M)}var ce={scheme:"http",domainHost:!0,parse:function(e,t){return e.host||(e.error=e.error||"HTTP URIs must have a host."),e},serialize:function(e,t){var r="https"===String(e.scheme).toLowerCase();return e.port!==(r?443:80)&&""!==e.port||(e.port=void 0),e.path||(e.path="/"),e}},de={scheme:"https",domainHost:ce.domainHost,parse:ce.parse,serialize:ce.serialize};function ue(e){return"boolean"==typeof e.secure?e.secure:"wss"===String(e.scheme).toLowerCase()}var he={scheme:"ws",domainHost:!0,parse:function(e,t){var r=e;return r.secure=ue(r),r.resourceName=(r.path||"/")+(r.query?"?"+r.query:""),r.path=void 0,r.query=void 0,r},serialize:function(e,t){if(e.port!==(ue(e)?443:80)&&""!==e.port||(e.port=void 0),"boolean"==typeof e.secure&&(e.scheme=e.secure?"wss":"ws",e.secure=void 0),e.resourceName){var r=e.resourceName.split("?"),a=d(r,2),s=a[0],i=a[1];e.path=s&&"/"!==s?s:void 0,e.query=i,e.resourceName=void 0}return e.fragment=void 0,e}},pe={scheme:"wss",domainHost:he.domainHost,parse:he.parse,serialize:he.serialize},me={},fe="[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]",ve="[0-9A-Fa-f]",ye=r(r("%[EFef]"+ve+"%"+ve+ve+"%"+ve+ve)+"|"+r("%[89A-Fa-f]"+ve+"%"+ve+ve)+"|"+r("%"+ve+ve)),ge="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",_e=t("[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",'[\\"\\\\]'),we="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",be=new RegExp(fe,"g"),Pe=new RegExp(ye,"g"),Ee=new RegExp(t("[^]",ge,"[\\.]",'[\\"]',_e),"g"),xe=new RegExp(t("[^]",fe,we),"g"),ke=xe;function Se(e){var t=M(e);return t.match(be)?t:e}var Re={scheme:"mailto",parse:function(e,t){var r=e,a=r.to=r.path?r.path.split(","):[];if(r.path=void 0,r.query){for(var s=!1,i={},o=r.query.split("&"),n=0,l=o.length;n<l;++n){var c=o[n].split("=");switch(c[0]){case"to":for(var d=c[1].split(","),u=0,h=d.length;u<h;++u)a.push(d[u]);break;case"subject":r.subject=le(c[1],t);break;case"body":r.body=le(c[1],t);break;default:s=!0,i[le(c[0],t)]=le(c[1],t)}}s&&(r.headers=i)}r.query=void 0;for(var p=0,m=a.length;p<m;++p){var f=a[p].split("@");if(f[0]=le(f[0]),t.unicodeSupport)f[1]=le(f[1],t).toLowerCase();else try{f[1]=L.toASCII(le(f[1],t).toLowerCase())}catch(e){r.error=r.error||"Email address's domain name can not be converted to ASCII via punycode: "+e}a[p]=f.join("@")}return r},serialize:function(e,t){var r=e,a=i(e.to);if(a){for(var o=0,n=a.length;o<n;++o){var l=String(a[o]),c=l.lastIndexOf("@"),d=l.slice(0,c).replace(Pe,Se).replace(Pe,s).replace(Ee,Z),u=l.slice(c+1);try{u=t.iri?L.toUnicode(u):L.toASCII(le(u,t).toLowerCase())}catch(e){r.error=r.error||"Email address's domain name can not be converted to "+(t.iri?"Unicode":"ASCII")+" via punycode: "+e}a[o]=d+"@"+u}r.path=a.join(",")}var h=e.headers=e.headers||{};e.subject&&(h.subject=e.subject),e.body&&(h.body=e.body);var p=[];for(var m in h)h[m]!==me[m]&&p.push(m.replace(Pe,Se).replace(Pe,s).replace(xe,Z)+"="+h[m].replace(Pe,Se).replace(Pe,s).replace(ke,Z));return p.length&&(r.query=p.join("&")),r}},Oe=/^([^\:]+)\:(.*)/,Te={scheme:"urn",parse:function(e,t){var r=e.path&&e.path.match(Oe),a=e;if(r){var s=t.scheme||a.scheme||"urn",i=r[1].toLowerCase(),o=r[2],n=s+":"+(t.nid||i),l=z[n];a.nid=i,a.nss=o,a.path=void 0,l&&(a=l.parse(a,t))}else a.error=a.error||"URN can not be parsed.";return a},serialize:function(e,t){var r=t.scheme||e.scheme||"urn",a=e.nid,s=r+":"+(t.nid||a),i=z[s];i&&(e=i.serialize(e,t));var o=e,n=e.nss;return o.path=(a||t.nid)+":"+n,o}},$e=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,Ie={scheme:"urn:uuid",parse:function(e,t){var r=e;return r.uuid=r.nss,r.nss=void 0,t.tolerant||r.uuid&&r.uuid.match($e)||(r.error=r.error||"UUID is not valid."),r},serialize:function(e,t){var r=e;return r.nss=(e.uuid||"").toLowerCase(),r}};z[ce.scheme]=ce,z[de.scheme]=de,z[he.scheme]=he,z[pe.scheme]=pe,z[Re.scheme]=Re,z[Te.scheme]=Te,z[Ie.scheme]=Ie,e.SCHEMES=z,e.pctEncChar=Z,e.pctDecChars=M,e.parse=W,e.removeDotSegments=te,e.serialize=re,e.resolveComponents=ae,e.resolve=se,e.normalize=ie,e.equal=oe,e.escapeComponent=ne,e.unescapeComponent=le,Object.defineProperty(e,"__esModule",{value:!0})}(t)}(0,Er.exports);var xr=Er.exports,kr=function e(t,r){if(t===r)return!0;if(t&&r&&"object"==typeof t&&"object"==typeof r){if(t.constructor!==r.constructor)return!1;var a,s,i;if(Array.isArray(t)){if((a=t.length)!=r.length)return!1;for(s=a;0!==s--;)if(!e(t[s],r[s]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if((a=(i=Object.keys(t)).length)!==Object.keys(r).length)return!1;for(s=a;0!==s--;)if(!Object.prototype.hasOwnProperty.call(r,i[s]))return!1;for(s=a;0!==s--;){var o=i[s];if(!e(t[o],r[o]))return!1}return!0}return t!=t&&r!=r},Sr={copy:function(e,t){for(var r in t=t||{},e)t[r]=e[r];return t},checkDataType:Rr,checkDataTypes:function(e,t,r){if(1===e.length)return Rr(e[0],t,r,!0);var a="",s=Tr(e);for(var i in s.array&&s.object&&(a=s.null?"(":"(!"+t+" || ",a+="typeof "+t+' !== "object")',delete s.null,delete s.array,delete s.object),s.number&&delete s.integer,s)a+=(a?" && ":"")+Rr(i,t,r,!0);return a},coerceToTypes:function(e,t){if(Array.isArray(t)){for(var r=[],a=0;a<t.length;a++){var s=t[a];(Or[s]||"array"===e&&"array"===s)&&(r[r.length]=s)}if(r.length)return r}else{if(Or[t])return[t];if("array"===e&&"array"===t)return["array"]}},toHash:Tr,getProperty:Cr,escapeQuotes:jr,equal:kr,ucs2length:function(e){for(var t,r=0,a=e.length,s=0;s<a;)r++,(t=e.charCodeAt(s++))>=55296&&t<=56319&&s<a&&56320==(64512&(t=e.charCodeAt(s)))&&s++;return r},varOccurences:function(e,t){t+="[^0-9]";var r=e.match(new RegExp(t,"g"));return r?r.length:0},varReplace:function(e,t,r){return t+="([^0-9])",r=r.replace(/\$/g,"$$$$"),e.replace(new RegExp(t,"g"),r+"$1")},schemaHasRules:function(e,t){if("boolean"==typeof e)return!e;for(var r in e)if(t[r])return!0},schemaHasRulesExcept:function(e,t,r){if("boolean"==typeof e)return!e&&"not"!=r;for(var a in e)if(a!=r&&t[a])return!0},schemaUnknownRules:function(e,t){if("boolean"==typeof e)return;for(var r in e)if(!t[r])return r},toQuotedString:Fr,getPathExpr:function(e,t,r,a){return Nr(e,r?"'/' + "+t+(a?"":".replace(/~/g, '~0').replace(/\\//g, '~1')"):a?"'[' + "+t+" + ']'":"'[\\'' + "+t+" + '\\']'")},getPath:function(e,t,r){var a=Fr(r?"/"+qr(t):Cr(t));return Nr(e,a)},getData:function(e,t,r){var a,s,i,o;if(""===e)return"rootData";if("/"==e[0]){if(!Ar.test(e))throw new Error("Invalid JSON-pointer: "+e);s=e,i="rootData"}else{if(!(o=e.match(Dr)))throw new Error("Invalid JSON-pointer: "+e);if(a=+o[1],"#"==(s=o[2])){if(a>=t)throw new Error("Cannot access property/index "+a+" levels up, current level is "+t);return r[t-a]}if(a>t)throw new Error("Cannot access data "+a+" levels up, current level is "+t);if(i="data"+(t-a||""),!s)return i}for(var n=i,l=s.split("/"),c=0;c<l.length;c++){var d=l[c];d&&(n+=" && "+(i+=Cr(Lr(d))))}return n},unescapeFragment:function(e){return Lr(decodeURIComponent(e))},unescapeJsonPointer:Lr,escapeFragment:function(e){return encodeURIComponent(qr(e))},escapeJsonPointer:qr};function Rr(e,t,r,a){var s=a?" !== ":" === ",i=a?" || ":" && ",o=a?"!":"",n=a?"":"!";switch(e){case"null":return t+s+"null";case"array":return o+"Array.isArray("+t+")";case"object":return"("+o+t+i+"typeof "+t+s+'"object"'+i+n+"Array.isArray("+t+"))";case"integer":return"(typeof "+t+s+'"number"'+i+n+"("+t+" % 1)"+i+t+s+t+(r?i+o+"isFinite("+t+")":"")+")";case"number":return"(typeof "+t+s+'"'+e+'"'+(r?i+o+"isFinite("+t+")":"")+")";default:return"typeof "+t+s+'"'+e+'"'}}var Or=Tr(["string","number","integer","boolean","null"]);function Tr(e){for(var t={},r=0;r<e.length;r++)t[e[r]]=!0;return t}var $r=/^[a-z$_][a-z$_0-9]*$/i,Ir=/'|\\/g;function Cr(e){return"number"==typeof e?"["+e+"]":$r.test(e)?"."+e:"['"+jr(e)+"']"}function jr(e){return e.replace(Ir,"\\$&").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\f/g,"\\f").replace(/\t/g,"\\t")}function Fr(e){return"'"+jr(e)+"'"}var Ar=/^\/(?:[^~]|~0|~1)*$/,Dr=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function Nr(e,t){return'""'==e?t:(e+" + "+t).replace(/([^\\])' \+ '/g,"$1")}function qr(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Lr(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}var zr=Sr,Zr=function(e){zr.copy(e,this)};var Mr={exports:{}},Ur=Mr.exports=function(e,t,r){"function"==typeof t&&(r=t,t={}),Vr(t,"function"==typeof(r=t.cb||r)?r:r.pre||function(){},r.post||function(){},e,"",e)};function Vr(e,t,r,a,s,i,o,n,l,c){if(a&&"object"==typeof a&&!Array.isArray(a)){for(var d in t(a,s,i,o,n,l,c),a){var u=a[d];if(Array.isArray(u)){if(d in Ur.arrayKeywords)for(var h=0;h<u.length;h++)Vr(e,t,r,u[h],s+"/"+d+"/"+h,i,s,d,a,h)}else if(d in Ur.propsKeywords){if(u&&"object"==typeof u)for(var p in u)Vr(e,t,r,u[p],s+"/"+d+"/"+p.replace(/~/g,"~0").replace(/\//g,"~1"),i,s,d,a,p)}else(d in Ur.keywords||e.allKeys&&!(d in Ur.skipKeywords))&&Vr(e,t,r,u,s+"/"+d,i,s,d,a)}r(a,s,i,o,n,l,c)}}Ur.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0},Ur.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},Ur.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},Ur.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};var Hr=Mr.exports,Qr=xr,Kr=kr,Br=Sr,Wr=Zr,Jr=Hr,Gr=Yr;function Yr(e,t,r){var a=this._refs[r];if("string"==typeof a){if(!this._refs[a])return Yr.call(this,e,t,a);a=this._refs[a]}if((a=a||this._schemas[r])instanceof Wr)return sa(a.schema,this._opts.inlineRefs)?a.schema:a.validate||this._compile(a);var s,i,o,n=Xr.call(this,t,r);return n&&(s=n.schema,t=n.root,o=n.baseId),s instanceof Wr?i=s.validate||e.call(this,s.schema,t,void 0,o):void 0!==s&&(i=sa(s,this._opts.inlineRefs)?s:e.call(this,s,t,void 0,o)),i}function Xr(e,t){var r=Qr.parse(t),a=la(r),s=na(this._getId(e.schema));if(0===Object.keys(e.schema).length||a!==s){var i=da(a),o=this._refs[i];if("string"==typeof o)return ea.call(this,e,o,r);if(o instanceof Wr)o.validate||this._compile(o),e=o;else{if(!((o=this._schemas[i])instanceof Wr))return;if(o.validate||this._compile(o),i==da(t))return{schema:o,root:e,baseId:s};e=o}if(!e.schema)return;s=na(this._getId(e.schema))}return ra.call(this,r,s,e.schema,e)}function ea(e,t,r){var a=Xr.call(this,e,t);if(a){var s=a.schema,i=a.baseId;e=a.root;var o=this._getId(s);return o&&(i=ua(i,o)),ra.call(this,r,i,s,e)}}Yr.normalizeId=da,Yr.fullPath=na,Yr.url=ua,Yr.ids=function(e){var t=da(this._getId(e)),r={"":t},a={"":na(t,!1)},s={},i=this;return Jr(e,{allKeys:!0},(function(e,t,o,n,l,c,d){if(""!==t){var u=i._getId(e),h=r[n],p=a[n]+"/"+l;if(void 0!==d&&(p+="/"+("number"==typeof d?d:Br.escapeFragment(d))),"string"==typeof u){u=h=da(h?Qr.resolve(h,u):u);var m=i._refs[u];if("string"==typeof m&&(m=i._refs[m]),m&&m.schema){if(!Kr(e,m.schema))throw new Error('id "'+u+'" resolves to more than one schema')}else if(u!=da(p))if("#"==u[0]){if(s[u]&&!Kr(e,s[u]))throw new Error('id "'+u+'" resolves to more than one schema');s[u]=e}else i._refs[u]=p}r[t]=h,a[t]=p}})),s},Yr.inlineRef=sa,Yr.schema=Xr;var ta=Br.toHash(["properties","patternProperties","enum","dependencies","definitions"]);function ra(e,t,r,a){if(e.fragment=e.fragment||"","/"==e.fragment.slice(0,1)){for(var s=e.fragment.split("/"),i=1;i<s.length;i++){var o=s[i];if(o){if(void 0===(r=r[o=Br.unescapeFragment(o)]))break;var n;if(!ta[o]&&((n=this._getId(r))&&(t=ua(t,n)),r.$ref)){var l=ua(t,r.$ref),c=Xr.call(this,a,l);c&&(r=c.schema,a=c.root,t=c.baseId)}}}return void 0!==r&&r!==a.schema?{schema:r,root:a,baseId:t}:void 0}}var aa=Br.toHash(["type","format","pattern","maxLength","minLength","maxProperties","minProperties","maxItems","minItems","maximum","minimum","uniqueItems","multipleOf","required","enum"]);function sa(e,t){return!1!==t&&(void 0===t||!0===t?ia(e):t?oa(e)<=t:void 0)}function ia(e){var t;if(Array.isArray(e)){for(var r=0;r<e.length;r++)if("object"==typeof(t=e[r])&&!ia(t))return!1}else for(var a in e){if("$ref"==a)return!1;if("object"==typeof(t=e[a])&&!ia(t))return!1}return!0}function oa(e){var t,r=0;if(Array.isArray(e)){for(var a=0;a<e.length;a++)if("object"==typeof(t=e[a])&&(r+=oa(t)),r==1/0)return 1/0}else for(var s in e){if("$ref"==s)return 1/0;if(aa[s])r++;else if("object"==typeof(t=e[s])&&(r+=oa(t)+1),r==1/0)return 1/0}return r}function na(e,t){return!1!==t&&(e=da(e)),la(Qr.parse(e))}function la(e){return Qr.serialize(e).split("#")[0]+"#"}var ca=/#\/?$/;function da(e){return e?e.replace(ca,""):""}function ua(e,t){return t=da(t),Qr.resolve(e,t)}var ha=Gr,pa={Validation:fa((function(e){this.message="validation failed",this.errors=e,this.ajv=this.validation=!0})),MissingRef:fa(ma)};function ma(e,t,r){this.message=r||ma.message(e,t),this.missingRef=ha.url(e,t),this.missingSchema=ha.normalizeId(ha.fullPath(this.missingRef))}function fa(e){return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}ma.message=function(e,t){return"can't resolve reference "+t+" from id "+e};var va=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r,a="boolean"==typeof t.cycles&&t.cycles,s=t.cmp&&(r=t.cmp,function(e){return function(t,a){var s={key:t,value:e[t]},i={key:a,value:e[a]};return r(s,i)}}),i=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var r,o;if(Array.isArray(t)){for(o="[",r=0;r<t.length;r++)r&&(o+=","),o+=e(t[r])||"null";return o+"]"}if(null===t)return"null";if(-1!==i.indexOf(t)){if(a)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var n=i.push(t)-1,l=Object.keys(t).sort(s&&s(t));for(o="",r=0;r<l.length;r++){var c=l[r],d=e(t[c]);d&&(o&&(o+=","),o+=JSON.stringify(c)+":"+d)}return i.splice(n,1),"{"+o+"}"}}(e)},ya=function(e,t,r){var a="",s=!0===e.schema.$async,i=e.util.schemaHasRulesExcept(e.schema,e.RULES.all,"$ref"),o=e.self._getId(e.schema);if(e.opts.strictKeywords){var n=e.util.schemaUnknownRules(e.schema,e.RULES.keywords);if(n){var l="unknown keyword: "+n;if("log"!==e.opts.strictKeywords)throw new Error(l);e.logger.warn(l)}}if(e.isTop&&(a+=" var validate = ",s&&(e.async=!0,a+="async "),a+="function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; ",o&&(e.opts.sourceCode||e.opts.processCode)&&(a+=" /*# sourceURL="+o+" */ ")),"boolean"==typeof e.schema||!i&&!e.schema.$ref){t="false schema";var c=e.level,d=e.dataLevel,u=e.schema[t],h=e.schemaPath+e.util.getProperty(t),p=e.errSchemaPath+"/"+t,m=!e.opts.allErrors,f="data"+(d||""),v="valid"+c;if(!1===e.schema){e.isTop?m=!0:a+=" var "+v+" = false; ",(J=J||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'false schema' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: 'boolean schema is false' "),e.opts.verbose&&(a+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+f+" "),a+=" } "):a+=" {} ";var y=a;a=J.pop(),!e.compositeRule&&m?e.async?a+=" throw new ValidationError(["+y+"]); ":a+=" validate.errors = ["+y+"]; return false; ":a+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else e.isTop?a+=s?" return data; ":" validate.errors = null; return true; ":a+=" var "+v+" = true; ";return e.isTop&&(a+=" }; return validate; "),a}if(e.isTop){var g=e.isTop;c=e.level=0,d=e.dataLevel=0,f="data";if(e.rootId=e.resolve.fullPath(e.self._getId(e.root.schema)),e.baseId=e.baseId||e.rootId,delete e.isTop,e.dataPathArr=[""],void 0!==e.schema.default&&e.opts.useDefaults&&e.opts.strictDefaults){var _="default is ignored in the schema root";if("log"!==e.opts.strictDefaults)throw new Error(_);e.logger.warn(_)}a+=" var vErrors = null; ",a+=" var errors = 0; ",a+=" if (rootData === undefined) rootData = data; "}else{c=e.level,f="data"+((d=e.dataLevel)||"");if(o&&(e.baseId=e.resolve.url(e.baseId,o)),s&&!e.async)throw new Error("async schema in sync schema");a+=" var errs_"+c+" = errors;"}v="valid"+c,m=!e.opts.allErrors;var w="",b="",P=e.schema.type,E=Array.isArray(P);if(P&&e.opts.nullable&&!0===e.schema.nullable&&(E?-1==P.indexOf("null")&&(P=P.concat("null")):"null"!=P&&(P=[P,"null"],E=!0)),E&&1==P.length&&(P=P[0],E=!1),e.schema.$ref&&i){if("fail"==e.opts.extendRefs)throw new Error('$ref: validation keywords used in schema at path "'+e.errSchemaPath+'" (see option extendRefs)');!0!==e.opts.extendRefs&&(i=!1,e.logger.warn('$ref: keywords ignored in schema at path "'+e.errSchemaPath+'"'))}if(e.schema.$comment&&e.opts.$comment&&(a+=" "+e.RULES.all.$comment.code(e,"$comment")),P){if(e.opts.coerceTypes)var x=e.util.coerceToTypes(e.opts.coerceTypes,P);var k=e.RULES.types[P];if(x||E||!0===k||k&&!G(k)){h=e.schemaPath+".type",p=e.errSchemaPath+"/type",h=e.schemaPath+".type",p=e.errSchemaPath+"/type";var S=E?"checkDataTypes":"checkDataType";if(a+=" if ("+e.util[S](P,f,e.opts.strictNumbers,!0)+") { ",x){var R="dataType"+c,O="coerced"+c;a+=" var "+R+" = typeof "+f+"; var "+O+" = undefined; ","array"==e.opts.coerceTypes&&(a+=" if ("+R+" == 'object' && Array.isArray("+f+") && "+f+".length == 1) { "+f+" = "+f+"[0]; "+R+" = typeof "+f+"; if ("+e.util.checkDataType(e.schema.type,f,e.opts.strictNumbers)+") "+O+" = "+f+"; } "),a+=" if ("+O+" !== undefined) ; ";var T=x;if(T)for(var $,I=-1,C=T.length-1;I<C;)"string"==($=T[I+=1])?a+=" else if ("+R+" == 'number' || "+R+" == 'boolean') "+O+" = '' + "+f+"; else if ("+f+" === null) "+O+" = ''; ":"number"==$||"integer"==$?(a+=" else if ("+R+" == 'boolean' || "+f+" === null || ("+R+" == 'string' && "+f+" && "+f+" == +"+f+" ","integer"==$&&(a+=" && !("+f+" % 1)"),a+=")) "+O+" = +"+f+"; "):"boolean"==$?a+=" else if ("+f+" === 'false' || "+f+" === 0 || "+f+" === null) "+O+" = false; else if ("+f+" === 'true' || "+f+" === 1) "+O+" = true; ":"null"==$?a+=" else if ("+f+" === '' || "+f+" === 0 || "+f+" === false) "+O+" = null; ":"array"==e.opts.coerceTypes&&"array"==$&&(a+=" else if ("+R+" == 'string' || "+R+" == 'number' || "+R+" == 'boolean' || "+f+" == null) "+O+" = ["+f+"]; ");a+=" else { ",(J=J||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'type' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: { type: '",a+=E?""+P.join(","):""+P,a+="' } ",!1!==e.opts.messages&&(a+=" , message: 'should be ",a+=E?""+P.join(","):""+P,a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+h+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+f+" "),a+=" } "):a+=" {} ";y=a;a=J.pop(),!e.compositeRule&&m?e.async?a+=" throw new ValidationError(["+y+"]); ":a+=" validate.errors = ["+y+"]; return false; ":a+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } if ("+O+" !== undefined) { ";var j=d?"data"+(d-1||""):"parentData";a+=" "+f+" = "+O+"; ",d||(a+="if ("+j+" !== undefined)"),a+=" "+j+"["+(d?e.dataPathArr[d]:"parentDataProperty")+"] = "+O+"; } "}else{(J=J||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'type' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: { type: '",a+=E?""+P.join(","):""+P,a+="' } ",!1!==e.opts.messages&&(a+=" , message: 'should be ",a+=E?""+P.join(","):""+P,a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+h+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+f+" "),a+=" } "):a+=" {} ";y=a;a=J.pop(),!e.compositeRule&&m?e.async?a+=" throw new ValidationError(["+y+"]); ":a+=" validate.errors = ["+y+"]; return false; ":a+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}a+=" } "}}if(e.schema.$ref&&!i)a+=" "+e.RULES.all.$ref.code(e,"$ref")+" ",m&&(a+=" } if (errors === ",a+=g?"0":"errs_"+c,a+=") { ",b+="}");else{var F=e.RULES;if(F)for(var A=-1,D=F.length-1;A<D;)if(G(k=F[A+=1])){if(k.type&&(a+=" if ("+e.util.checkDataType(k.type,f,e.opts.strictNumbers)+") { "),e.opts.useDefaults)if("object"==k.type&&e.schema.properties){u=e.schema.properties;var N=Object.keys(u);if(N)for(var q,L=-1,z=N.length-1;L<z;){if(void 0!==(U=u[q=N[L+=1]]).default){var Z=f+e.util.getProperty(q);if(e.compositeRule){if(e.opts.strictDefaults){_="default is ignored for: "+Z;if("log"!==e.opts.strictDefaults)throw new Error(_);e.logger.warn(_)}}else a+=" if ("+Z+" === undefined ","empty"==e.opts.useDefaults&&(a+=" || "+Z+" === null || "+Z+" === '' "),a+=" ) "+Z+" = ","shared"==e.opts.useDefaults?a+=" "+e.useDefault(U.default)+" ":a+=" "+JSON.stringify(U.default)+" ",a+="; "}}}else if("array"==k.type&&Array.isArray(e.schema.items)){var M=e.schema.items;if(M){I=-1;for(var U,V=M.length-1;I<V;)if(void 0!==(U=M[I+=1]).default){Z=f+"["+I+"]";if(e.compositeRule){if(e.opts.strictDefaults){_="default is ignored for: "+Z;if("log"!==e.opts.strictDefaults)throw new Error(_);e.logger.warn(_)}}else a+=" if ("+Z+" === undefined ","empty"==e.opts.useDefaults&&(a+=" || "+Z+" === null || "+Z+" === '' "),a+=" ) "+Z+" = ","shared"==e.opts.useDefaults?a+=" "+e.useDefault(U.default)+" ":a+=" "+JSON.stringify(U.default)+" ",a+="; "}}}var H=k.rules;if(H)for(var Q,K=-1,B=H.length-1;K<B;)if(Y(Q=H[K+=1])){var W=Q.code(e,Q.keyword,k.type);W&&(a+=" "+W+" ",m&&(w+="}"))}if(m&&(a+=" "+w+" ",w=""),k.type&&(a+=" } ",P&&P===k.type&&!x)){a+=" else { ";var J;h=e.schemaPath+".type",p=e.errSchemaPath+"/type";(J=J||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'type' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(p)+" , params: { type: '",a+=E?""+P.join(","):""+P,a+="' } ",!1!==e.opts.messages&&(a+=" , message: 'should be ",a+=E?""+P.join(","):""+P,a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+h+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+f+" "),a+=" } "):a+=" {} ";y=a;a=J.pop(),!e.compositeRule&&m?e.async?a+=" throw new ValidationError(["+y+"]); ":a+=" validate.errors = ["+y+"]; return false; ":a+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } "}m&&(a+=" if (errors === ",a+=g?"0":"errs_"+c,a+=") { ",b+="}")}}function G(e){for(var t=e.rules,r=0;r<t.length;r++)if(Y(t[r]))return!0}function Y(t){return void 0!==e.schema[t.keyword]||t.implements&&function(t){for(var r=t.implements,a=0;a<r.length;a++)if(void 0!==e.schema[r[a]])return!0}(t)}return m&&(a+=" "+b+" "),g?(s?(a+=" if (errors === 0) return data; ",a+=" else throw new ValidationError(vErrors); "):(a+=" validate.errors = vErrors; ",a+=" return errors === 0; "),a+=" }; return validate;"):a+=" var "+v+" = errors === errs_"+c+";",a},ga=Gr,_a=Sr,wa=pa,ba=va,Pa=ya,Ea=_a.ucs2length,xa=kr,ka=wa.Validation,Sa=function e(t,r,a,s){var i=this,o=this._opts,n=[void 0],l={},c=[],d={},u=[],h={},p=[];r=r||{schema:t,refVal:n,refs:l};var m=Ra.call(this,t,r,s),f=this._compilations[m.index];if(m.compiling)return f.callValidate=function e(){var t=f.validate,r=t.apply(this,arguments);return e.errors=t.errors,r};var v=this._formats,y=this.RULES;try{var g=w(t,r,a,s);f.validate=g;var _=f.callValidate;return _&&(_.schema=g.schema,_.errors=null,_.refs=g.refs,_.refVal=g.refVal,_.root=g.root,_.$async=g.$async,o.sourceCode&&(_.source=g.source)),g}finally{Oa.call(this,t,r,s)}function w(t,a,s,d){var h=!a||a&&a.schema==t;if(a.schema!=r.schema)return e.call(i,t,a,s,d);var m,f=!0===t.$async,g=Pa({isTop:!0,schema:t,isRoot:h,baseId:d,root:a,schemaPath:"",errSchemaPath:"#",errorPath:'""',MissingRefError:wa.MissingRef,RULES:y,validate:Pa,util:_a,resolve:ga,resolveRef:b,usePattern:x,useDefault:k,useCustomRule:S,opts:o,formats:v,logger:i.logger,self:i});g=Fa(n,Ca)+Fa(c,$a)+Fa(u,Ia)+Fa(p,ja)+g,o.processCode&&(g=o.processCode(g,t));try{m=new Function("self","RULES","formats","root","refVal","defaults","customRules","equal","ucs2length","ValidationError",g)(i,y,v,r,n,u,p,xa,Ea,ka),n[0]=m}catch(e){throw i.logger.error("Error compiling schema, function code:",g),e}return m.schema=t,m.errors=null,m.refs=l,m.refVal=n,m.root=h?m:a,f&&(m.$async=!0),!0===o.sourceCode&&(m.source={code:g,patterns:c,defaults:u}),m}function b(t,s,c){s=ga.url(t,s);var d,u,h=l[s];if(void 0!==h)return E(d=n[h],u="refVal["+h+"]");if(!c&&r.refs){var p=r.refs[s];if(void 0!==p)return E(d=r.refVal[p],u=P(s,d))}u=P(s);var m=ga.call(i,w,r,s);if(void 0===m){var f=a&&a[s];f&&(m=ga.inlineRef(f,o.inlineRefs)?f:e.call(i,f,r,a,t))}if(void 0!==m)return function(e,t){var r=l[e];n[r]=t}(s,m),E(m,u);!function(e){delete l[e]}(s)}function P(e,t){var r=n.length;return n[r]=t,l[e]=r,"refVal"+r}function E(e,t){return"object"==typeof e||"boolean"==typeof e?{code:t,schema:e,inline:!0}:{code:t,$async:e&&!!e.$async}}function x(e){var t=d[e];return void 0===t&&(t=d[e]=c.length,c[t]=e),"pattern"+t}function k(e){switch(typeof e){case"boolean":case"number":return""+e;case"string":return _a.toQuotedString(e);case"object":if(null===e)return"null";var t=ba(e),r=h[t];return void 0===r&&(r=h[t]=u.length,u[r]=e),"default"+r}}function S(e,t,r,a){if(!1!==i._opts.validateSchema){var s=e.definition.dependencies;if(s&&!s.every((function(e){return Object.prototype.hasOwnProperty.call(r,e)})))throw new Error("parent schema must have all required keywords: "+s.join(","));var n=e.definition.validateSchema;if(n)if(!n(t)){var l="keyword schema is invalid: "+i.errorsText(n.errors);if("log"!=i._opts.validateSchema)throw new Error(l);i.logger.error(l)}}var c,d=e.definition.compile,u=e.definition.inline,h=e.definition.macro;if(d)c=d.call(i,t,r,a);else if(h)c=h.call(i,t,r,a),!1!==o.validateSchema&&i.validateSchema(c,!0);else if(u)c=u.call(i,a,e.keyword,t,r);else if(!(c=e.definition.validate))return;if(void 0===c)throw new Error('custom keyword "'+e.keyword+'"failed to compile');var m=p.length;return p[m]=c,{code:"customRule"+m,validate:c}}};function Ra(e,t,r){var a=Ta.call(this,e,t,r);return a>=0?{index:a,compiling:!0}:(a=this._compilations.length,this._compilations[a]={schema:e,root:t,baseId:r},{index:a,compiling:!1})}function Oa(e,t,r){var a=Ta.call(this,e,t,r);a>=0&&this._compilations.splice(a,1)}function Ta(e,t,r){for(var a=0;a<this._compilations.length;a++){var s=this._compilations[a];if(s.schema==e&&s.root==t&&s.baseId==r)return a}return-1}function $a(e,t){return"var pattern"+e+" = new RegExp("+_a.toQuotedString(t[e])+");"}function Ia(e){return"var default"+e+" = defaults["+e+"];"}function Ca(e,t){return void 0===t[e]?"":"var refVal"+e+" = refVal["+e+"];"}function ja(e){return"var customRule"+e+" = customRules["+e+"];"}function Fa(e,t){if(!e.length)return"";for(var r="",a=0;a<e.length;a++)r+=t(a,e);return r}var Aa={exports:{}},Da=Aa.exports=function(){this._cache={}};Da.prototype.put=function(e,t){this._cache[e]=t},Da.prototype.get=function(e){return this._cache[e]},Da.prototype.del=function(e){delete this._cache[e]},Da.prototype.clear=function(){this._cache={}};var Na=Aa.exports,qa=Sr,La=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,za=[0,31,28,31,30,31,30,31,31,30,31,30,31],Za=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,Ma=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,Ua=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,Va=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,Ha=/^(?:(?:http[s\u017F]?|ftp):\/\/)(?:(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+(?::(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?@)?(?:(?!10(?:\.[0-9]{1,3}){3})(?!127(?:\.[0-9]{1,3}){3})(?!169\.254(?:\.[0-9]{1,3}){2})(?!192\.168(?:\.[0-9]{1,3}){2})(?!172\.(?:1[6-9]|2[0-9]|3[01])(?:\.[0-9]{1,3}){2})(?:[1-9][0-9]?|1[0-9][0-9]|2[01][0-9]|22[0-3])(?:\.(?:1?[0-9]{1,2}|2[0-4][0-9]|25[0-5])){2}(?:\.(?:[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]))|(?:(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)(?:\.(?:(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+-)*(?:[0-9a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])+)*(?:\.(?:(?:[a-z\xA1-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]){2,})))(?::[0-9]{2,5})?(?:\/(?:[\0-\x08\x0E-\x1F!-\x9F\xA1-\u167F\u1681-\u1FFF\u200B-\u2027\u202A-\u202E\u2030-\u205E\u2060-\u2FFF\u3001-\uD7FF\uE000-\uFEFE\uFF00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])*)?$/i,Qa=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,Ka=/^(?:\/(?:[^~/]|~0|~1)*)*$/,Ba=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,Wa=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,Ja=Ga;function Ga(e){return e="full"==e?"full":"fast",qa.copy(Ga[e])}function Ya(e){var t=e.match(La);if(!t)return!1;var r=+t[1],a=+t[2],s=+t[3];return a>=1&&a<=12&&s>=1&&s<=(2==a&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(r)?29:za[a])}function Xa(e,t){var r=e.match(Za);if(!r)return!1;var a=r[1],s=r[2],i=r[3],o=r[5];return(a<=23&&s<=59&&i<=59||23==a&&59==s&&60==i)&&(!t||o)}Ga.fast={date:/^\d\d\d\d-[0-1]\d-[0-3]\d$/,time:/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,"date-time":/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,uri:/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/)?[^\s]*$/i,"uri-reference":/^(?:(?:[a-z][a-z0-9+\-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,"uri-template":Va,url:Ha,email:/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i,hostname:Ma,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:as,uuid:Qa,"json-pointer":Ka,"json-pointer-uri-fragment":Ba,"relative-json-pointer":Wa},Ga.full={date:Ya,time:Xa,"date-time":function(e){var t=e.split(es);return 2==t.length&&Ya(t[0])&&Xa(t[1],!0)},uri:function(e){return ts.test(e)&&Ua.test(e)},"uri-reference":/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,"uri-template":Va,url:Ha,email:/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,hostname:Ma,ipv4:/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,ipv6:/^\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(?:\.(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(?:%.+)?\s*$/i,regex:as,uuid:Qa,"json-pointer":Ka,"json-pointer-uri-fragment":Ba,"relative-json-pointer":Wa};var es=/t|\s/i;var ts=/\/|:/;var rs=/[^\\]\\Z/;function as(e){if(rs.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}}var ss=function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n;var p="maximum"==t,m=p?"exclusiveMaximum":"exclusiveMinimum",f=e.schema[m],v=e.opts.$data&&f&&f.$data,y=p?"<":">",g=p?">":"<",_=void 0;if(!h&&"number"!=typeof n&&void 0!==n)throw new Error(t+" must be number");if(!v&&void 0!==f&&"number"!=typeof f&&"boolean"!=typeof f)throw new Error(m+" must be number or boolean");if(v){var w=e.util.getData(f.$data,o,e.dataPathArr),b="exclusive"+i,P="exclType"+i,E="exclIsNumber"+i,x="' + "+(R="op"+i)+" + '";s+=" var schemaExcl"+i+" = "+w+"; ",s+=" var "+b+"; var "+P+" = typeof "+(w="schemaExcl"+i)+"; if ("+P+" != 'boolean' && "+P+" != 'undefined' && "+P+" != 'number') { ";var k;_=m;(k=k||[]).push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(_||"_exclusiveLimit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: {} ",!1!==e.opts.messages&&(s+=" , message: '"+m+" should be boolean' "),e.opts.verbose&&(s+=" , schema: validate.schema"+l+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var S=s;s=k.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } else if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" "+P+" == 'number' ? ( ("+b+" = "+a+" === undefined || "+w+" "+y+"= "+a+") ? "+u+" "+g+"= "+w+" : "+u+" "+g+" "+a+" ) : ( ("+b+" = "+w+" === true) ? "+u+" "+g+"= "+a+" : "+u+" "+g+" "+a+" ) || "+u+" !== "+u+") { var op"+i+" = "+b+" ? '"+y+"' : '"+y+"='; ",void 0===n&&(_=m,c=e.errSchemaPath+"/"+m,a=w,h=v)}else{x=y;if((E="number"==typeof f)&&h){var R="'"+x+"'";s+=" if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" ( "+a+" === undefined || "+f+" "+y+"= "+a+" ? "+u+" "+g+"= "+f+" : "+u+" "+g+" "+a+" ) || "+u+" !== "+u+") { "}else{E&&void 0===n?(b=!0,_=m,c=e.errSchemaPath+"/"+m,a=f,g+="="):(E&&(a=Math[p?"min":"max"](f,n)),f===(!E||a)?(b=!0,_=m,c=e.errSchemaPath+"/"+m,g+="="):(b=!1,x+="="));R="'"+x+"'";s+=" if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" "+u+" "+g+" "+a+" || "+u+" !== "+u+") { "}}_=_||t,(k=k||[]).push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(_||"_limit")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { comparison: "+R+", limit: "+a+", exclusive: "+b+" } ",!1!==e.opts.messages&&(s+=" , message: 'should be "+x+" ",s+=h?"' + "+a:a+"'"),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";S=s;return s=k.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+S+"]); ":s+=" validate.errors = ["+S+"]; return false; ":s+=" var err = "+S+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",d&&(s+=" else { "),s},is=function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;if(h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,!h&&"number"!=typeof n)throw new Error(t+" must be number");s+="if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" "+u+".length "+("maxItems"==t?">":"<")+" "+a+") { ";var p=t,m=m||[];m.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(p||"_limitItems")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { limit: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT have ",s+="maxItems"==t?"more":"fewer",s+=" than ",s+=h?"' + "+a+" + '":""+n,s+=" items' "),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var f=s;return s=m.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+f+"]); ":s+=" validate.errors = ["+f+"]; return false; ":s+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",d&&(s+=" else { "),s},os=function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;if(h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,!h&&"number"!=typeof n)throw new Error(t+" must be number");var p="maxLength"==t?">":"<";s+="if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),!1===e.opts.unicode?s+=" "+u+".length ":s+=" ucs2length("+u+") ",s+=" "+p+" "+a+") { ";var m=t,f=f||[];f.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(m||"_limitLength")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { limit: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT be ",s+="maxLength"==t?"longer":"shorter",s+=" than ",s+=h?"' + "+a+" + '":""+n,s+=" characters' "),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var v=s;return s=f.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+v+"]); ":s+=" validate.errors = ["+v+"]; return false; ":s+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",d&&(s+=" else { "),s},ns=function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;if(h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,!h&&"number"!=typeof n)throw new Error(t+" must be number");s+="if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'number') || "),s+=" Object.keys("+u+").length "+("maxProperties"==t?">":"<")+" "+a+") { ";var p=t,m=m||[];m.push(s),s="",!1!==e.createErrors?(s+=" { keyword: '"+(p||"_limitProperties")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { limit: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT have ",s+="maxProperties"==t?"more":"fewer",s+=" than ",s+=h?"' + "+a+" + '":""+n,s+=" properties' "),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var f=s;return s=m.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+f+"]); ":s+=" validate.errors = ["+f+"]; return false; ":s+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",d&&(s+=" else { "),s},ls={$ref:function(e,t,r){var a,s,i=" ",o=e.level,n=e.dataLevel,l=e.schema[t],c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(n||""),h="valid"+o;if("#"==l||"#/"==l)e.isRoot?(a=e.async,s="validate"):(a=!0===e.root.schema.$async,s="root.refVal[0]");else{var p=e.resolveRef(e.baseId,l,e.isRoot);if(void 0===p){var m=e.MissingRefError.message(e.baseId,l);if("fail"==e.opts.missingRefs){e.logger.error(m),(g=g||[]).push(i),i="",!1!==e.createErrors?(i+=" { keyword: '$ref' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { ref: '"+e.util.escapeQuotes(l)+"' } ",!1!==e.opts.messages&&(i+=" , message: 'can\\'t resolve reference "+e.util.escapeQuotes(l)+"' "),e.opts.verbose&&(i+=" , schema: "+e.util.toQuotedString(l)+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),i+=" } "):i+=" {} ";var f=i;i=g.pop(),!e.compositeRule&&d?e.async?i+=" throw new ValidationError(["+f+"]); ":i+=" validate.errors = ["+f+"]; return false; ":i+=" var err = "+f+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",d&&(i+=" if (false) { ")}else{if("ignore"!=e.opts.missingRefs)throw new e.MissingRefError(e.baseId,l,m);e.logger.warn(m),d&&(i+=" if (true) { ")}}else if(p.inline){var v=e.util.copy(e);v.level++;var y="valid"+v.level;v.schema=p.schema,v.schemaPath="",v.errSchemaPath=l,i+=" "+e.validate(v).replace(/validate\.schema/g,p.code)+" ",d&&(i+=" if ("+y+") { ")}else a=!0===p.$async||e.async&&!1!==p.$async,s=p.code}if(s){var g;(g=g||[]).push(i),i="",e.opts.passContext?i+=" "+s+".call(this, ":i+=" "+s+"( ",i+=" "+u+", (dataPath || '')",'""'!=e.errorPath&&(i+=" + "+e.errorPath);var _=i+=" , "+(n?"data"+(n-1||""):"parentData")+" , "+(n?e.dataPathArr[n]:"parentDataProperty")+", rootData) ";if(i=g.pop(),a){if(!e.async)throw new Error("async schema referenced by sync schema");d&&(i+=" var "+h+"; "),i+=" try { await "+_+"; ",d&&(i+=" "+h+" = true; "),i+=" } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; ",d&&(i+=" "+h+" = false; "),i+=" } ",d&&(i+=" if ("+h+") { ")}else i+=" if (!"+_+") { if (vErrors === null) vErrors = "+s+".errors; else vErrors = vErrors.concat("+s+".errors); errors = vErrors.length; } ",d&&(i+=" else { ")}return i},allOf:function(e,t,r){var a=" ",s=e.schema[t],i=e.schemaPath+e.util.getProperty(t),o=e.errSchemaPath+"/"+t,n=!e.opts.allErrors,l=e.util.copy(e),c="";l.level++;var d="valid"+l.level,u=l.baseId,h=!0,p=s;if(p)for(var m,f=-1,v=p.length-1;f<v;)m=p[f+=1],(e.opts.strictKeywords?"object"==typeof m&&Object.keys(m).length>0||!1===m:e.util.schemaHasRules(m,e.RULES.all))&&(h=!1,l.schema=m,l.schemaPath=i+"["+f+"]",l.errSchemaPath=o+"/"+f,a+=" "+e.validate(l)+" ",l.baseId=u,n&&(a+=" if ("+d+") { ",c+="}"));return n&&(a+=h?" if (true) { ":" "+c.slice(0,-1)+" "),a},anyOf:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h="errs__"+s,p=e.util.copy(e),m="";p.level++;var f="valid"+p.level,v=o.every((function(t){return e.opts.strictKeywords?"object"==typeof t&&Object.keys(t).length>0||!1===t:e.util.schemaHasRules(t,e.RULES.all)}));if(v){var y=p.baseId;a+=" var "+h+" = errors; var "+u+" = false; ";var g=e.compositeRule;e.compositeRule=p.compositeRule=!0;var _=o;if(_)for(var w,b=-1,P=_.length-1;b<P;)w=_[b+=1],p.schema=w,p.schemaPath=n+"["+b+"]",p.errSchemaPath=l+"/"+b,a+=" "+e.validate(p)+" ",p.baseId=y,a+=" "+u+" = "+u+" || "+f+"; if (!"+u+") { ",m+="}";e.compositeRule=p.compositeRule=g,a+=" "+m+" if (!"+u+") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'anyOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: 'should match some schema in anyOf' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?a+=" throw new ValidationError(vErrors); ":a+=" validate.errors = vErrors; return false; "),a+=" } else { errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } ",e.opts.allErrors&&(a+=" } ")}else c&&(a+=" if (true) { ");return a},$comment:function(e,t,r){var a=" ",s=e.schema[t],i=e.errSchemaPath+"/"+t;e.opts.allErrors;var o=e.util.toQuotedString(s);return!0===e.opts.$comment?a+=" console.log("+o+");":"function"==typeof e.opts.$comment&&(a+=" self._opts.$comment("+o+", "+e.util.toQuotedString(i)+", validate.root.schema);"),a},const:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h=e.opts.$data&&o&&o.$data;h&&(a+=" var schema"+s+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; "),h||(a+=" var schema"+s+" = validate.schema"+n+";"),a+="var "+u+" = equal("+d+", schema"+s+"); if (!"+u+") { ";var p=p||[];p.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'const' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { allowedValue: schema"+s+" } ",!1!==e.opts.messages&&(a+=" , message: 'should be equal to constant' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var m=a;return a=p.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+m+"]); ":a+=" validate.errors = ["+m+"]; return false; ":a+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" }",c&&(a+=" else { "),a},contains:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h="errs__"+s,p=e.util.copy(e);p.level++;var m="valid"+p.level,f="i"+s,v=p.dataLevel=e.dataLevel+1,y="data"+v,g=e.baseId,_=e.opts.strictKeywords?"object"==typeof o&&Object.keys(o).length>0||!1===o:e.util.schemaHasRules(o,e.RULES.all);if(a+="var "+h+" = errors;var "+u+";",_){var w=e.compositeRule;e.compositeRule=p.compositeRule=!0,p.schema=o,p.schemaPath=n,p.errSchemaPath=l,a+=" var "+m+" = false; for (var "+f+" = 0; "+f+" < "+d+".length; "+f+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,f,e.opts.jsonPointers,!0);var b=d+"["+f+"]";p.dataPathArr[v]=f;var P=e.validate(p);p.baseId=g,e.util.varOccurences(P,y)<2?a+=" "+e.util.varReplace(P,y,b)+" ":a+=" var "+y+" = "+b+"; "+P+" ",a+=" if ("+m+") break; } ",e.compositeRule=p.compositeRule=w,a+=" if (!"+m+") {"}else a+=" if ("+d+".length == 0) {";var E=E||[];E.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'contains' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: 'should contain a valid item' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var x=a;return a=E.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+x+"]); ":a+=" validate.errors = ["+x+"]; return false; ":a+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } else { ",_&&(a+=" errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } "),e.opts.allErrors&&(a+=" } "),a},dependencies:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="errs__"+s,h=e.util.copy(e),p="";h.level++;var m="valid"+h.level,f={},v={},y=e.opts.ownProperties;for(b in o)if("__proto__"!=b){var g=o[b],_=Array.isArray(g)?v:f;_[b]=g}a+="var "+u+" = errors;";var w=e.errorPath;for(var b in a+="var missing"+s+";",v)if((_=v[b]).length){if(a+=" if ( "+d+e.util.getProperty(b)+" !== undefined ",y&&(a+=" && Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(b)+"') "),c){a+=" && ( ";var P=_;if(P)for(var E=-1,x=P.length-1;E<x;){$=P[E+=1],E&&(a+=" || "),a+=" ( ( "+(F=d+(j=e.util.getProperty($)))+" === undefined ",y&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes($)+"') "),a+=") && (missing"+s+" = "+e.util.toQuotedString(e.opts.jsonPointers?$:j)+") ) "}a+=")) { ";var k="missing"+s,S="' + "+k+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(w,k,!0):w+" + "+k);var R=R||[];R.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { property: '"+e.util.escapeQuotes(b)+"', missingProperty: '"+S+"', depsCount: "+_.length+", deps: '"+e.util.escapeQuotes(1==_.length?_[0]:_.join(", "))+"' } ",!1!==e.opts.messages&&(a+=" , message: 'should have ",1==_.length?a+="property "+e.util.escapeQuotes(_[0]):a+="properties "+e.util.escapeQuotes(_.join(", ")),a+=" when property "+e.util.escapeQuotes(b)+" is present' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var O=a;a=R.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+O+"]); ":a+=" validate.errors = ["+O+"]; return false; ":a+=" var err = "+O+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; "}else{a+=" ) { ";var T=_;if(T)for(var $,I=-1,C=T.length-1;I<C;){$=T[I+=1];var j=e.util.getProperty($),F=(S=e.util.escapeQuotes($),d+j);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(w,$,e.opts.jsonPointers)),a+=" if ( "+F+" === undefined ",y&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes($)+"') "),a+=") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'dependencies' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { property: '"+e.util.escapeQuotes(b)+"', missingProperty: '"+S+"', depsCount: "+_.length+", deps: '"+e.util.escapeQuotes(1==_.length?_[0]:_.join(", "))+"' } ",!1!==e.opts.messages&&(a+=" , message: 'should have ",1==_.length?a+="property "+e.util.escapeQuotes(_[0]):a+="properties "+e.util.escapeQuotes(_.join(", ")),a+=" when property "+e.util.escapeQuotes(b)+" is present' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}a+=" } ",c&&(p+="}",a+=" else { ")}e.errorPath=w;var A=h.baseId;for(var b in f){g=f[b];(e.opts.strictKeywords?"object"==typeof g&&Object.keys(g).length>0||!1===g:e.util.schemaHasRules(g,e.RULES.all))&&(a+=" "+m+" = true; if ( "+d+e.util.getProperty(b)+" !== undefined ",y&&(a+=" && Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(b)+"') "),a+=") { ",h.schema=g,h.schemaPath=n+e.util.getProperty(b),h.errSchemaPath=l+"/"+e.util.escapeFragment(b),a+=" "+e.validate(h)+" ",h.baseId=A,a+=" } ",c&&(a+=" if ("+m+") { ",p+="}"))}return c&&(a+=" "+p+" if ("+u+" == errors) {"),a},enum:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h=e.opts.$data&&o&&o.$data;h&&(a+=" var schema"+s+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ");var p="i"+s,m="schema"+s;h||(a+=" var "+m+" = validate.schema"+n+";"),a+="var "+u+";",h&&(a+=" if (schema"+s+" === undefined) "+u+" = true; else if (!Array.isArray(schema"+s+")) "+u+" = false; else {"),a+=u+" = false;for (var "+p+"=0; "+p+"<"+m+".length; "+p+"++) if (equal("+d+", "+m+"["+p+"])) { "+u+" = true; break; }",h&&(a+=" } "),a+=" if (!"+u+") { ";var f=f||[];f.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'enum' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { allowedValues: schema"+s+" } ",!1!==e.opts.messages&&(a+=" , message: 'should be equal to one of the allowed values' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var v=a;return a=f.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+v+"]); ":a+=" validate.errors = ["+v+"]; return false; ":a+=" var err = "+v+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" }",c&&(a+=" else { "),a},format:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||"");if(!1===e.opts.format)return c&&(a+=" if (true) { "),a;var u,h=e.opts.$data&&o&&o.$data;h?(a+=" var schema"+s+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ",u="schema"+s):u=o;var p=e.opts.unknownFormats,m=Array.isArray(p);if(h){a+=" var "+(f="format"+s)+" = formats["+u+"]; var "+(v="isObject"+s)+" = typeof "+f+" == 'object' && !("+f+" instanceof RegExp) && "+f+".validate; var "+(y="formatType"+s)+" = "+v+" && "+f+".type || 'string'; if ("+v+") { ",e.async&&(a+=" var async"+s+" = "+f+".async; "),a+=" "+f+" = "+f+".validate; } if ( ",h&&(a+=" ("+u+" !== undefined && typeof "+u+" != 'string') || "),a+=" (","ignore"!=p&&(a+=" ("+u+" && !"+f+" ",m&&(a+=" && self._opts.unknownFormats.indexOf("+u+") == -1 "),a+=") || "),a+=" ("+f+" && "+y+" == '"+r+"' && !(typeof "+f+" == 'function' ? ",e.async?a+=" (async"+s+" ? await "+f+"("+d+") : "+f+"("+d+")) ":a+=" "+f+"("+d+") ",a+=" : "+f+".test("+d+"))))) {"}else{var f;if(!(f=e.formats[o])){if("ignore"==p)return e.logger.warn('unknown format "'+o+'" ignored in schema at path "'+e.errSchemaPath+'"'),c&&(a+=" if (true) { "),a;if(m&&p.indexOf(o)>=0)return c&&(a+=" if (true) { "),a;throw new Error('unknown format "'+o+'" is used in schema at path "'+e.errSchemaPath+'"')}var v,y=(v="object"==typeof f&&!(f instanceof RegExp)&&f.validate)&&f.type||"string";if(v){var g=!0===f.async;f=f.validate}if(y!=r)return c&&(a+=" if (true) { "),a;if(g){if(!e.async)throw new Error("async format in sync schema");a+=" if (!(await "+(_="formats"+e.util.getProperty(o)+".validate")+"("+d+"))) { "}else{a+=" if (! ";var _="formats"+e.util.getProperty(o);v&&(_+=".validate"),a+="function"==typeof f?" "+_+"("+d+") ":" "+_+".test("+d+") ",a+=") { "}}var w=w||[];w.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'format' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { format: ",a+=h?""+u:""+e.util.toQuotedString(o),a+=" } ",!1!==e.opts.messages&&(a+=" , message: 'should match format \"",a+=h?"' + "+u+" + '":""+e.util.escapeQuotes(o),a+="\"' "),e.opts.verbose&&(a+=" , schema: ",a+=h?"validate.schema"+n:""+e.util.toQuotedString(o),a+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var b=a;return a=w.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+b+"]); ":a+=" validate.errors = ["+b+"]; return false; ":a+=" var err = "+b+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } ",c&&(a+=" else { "),a},if:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h="errs__"+s,p=e.util.copy(e);p.level++;var m="valid"+p.level,f=e.schema.then,v=e.schema.else,y=void 0!==f&&(e.opts.strictKeywords?"object"==typeof f&&Object.keys(f).length>0||!1===f:e.util.schemaHasRules(f,e.RULES.all)),g=void 0!==v&&(e.opts.strictKeywords?"object"==typeof v&&Object.keys(v).length>0||!1===v:e.util.schemaHasRules(v,e.RULES.all)),_=p.baseId;if(y||g){var w;p.createErrors=!1,p.schema=o,p.schemaPath=n,p.errSchemaPath=l,a+=" var "+h+" = errors; var "+u+" = true; ";var b=e.compositeRule;e.compositeRule=p.compositeRule=!0,a+=" "+e.validate(p)+" ",p.baseId=_,p.createErrors=!0,a+=" errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; } ",e.compositeRule=p.compositeRule=b,y?(a+=" if ("+m+") { ",p.schema=e.schema.then,p.schemaPath=e.schemaPath+".then",p.errSchemaPath=e.errSchemaPath+"/then",a+=" "+e.validate(p)+" ",p.baseId=_,a+=" "+u+" = "+m+"; ",y&&g?a+=" var "+(w="ifClause"+s)+" = 'then'; ":w="'then'",a+=" } ",g&&(a+=" else { ")):a+=" if (!"+m+") { ",g&&(p.schema=e.schema.else,p.schemaPath=e.schemaPath+".else",p.errSchemaPath=e.errSchemaPath+"/else",a+=" "+e.validate(p)+" ",p.baseId=_,a+=" "+u+" = "+m+"; ",y&&g?a+=" var "+(w="ifClause"+s)+" = 'else'; ":w="'else'",a+=" } "),a+=" if (!"+u+") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'if' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { failingKeyword: "+w+" } ",!1!==e.opts.messages&&(a+=" , message: 'should match \"' + "+w+" + '\" schema' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?a+=" throw new ValidationError(vErrors); ":a+=" validate.errors = vErrors; return false; "),a+=" } ",c&&(a+=" else { ")}else c&&(a+=" if (true) { ");return a},items:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h="errs__"+s,p=e.util.copy(e),m="";p.level++;var f="valid"+p.level,v="i"+s,y=p.dataLevel=e.dataLevel+1,g="data"+y,_=e.baseId;if(a+="var "+h+" = errors;var "+u+";",Array.isArray(o)){var w=e.schema.additionalItems;if(!1===w){a+=" "+u+" = "+d+".length <= "+o.length+"; ";var b=l;l=e.errSchemaPath+"/additionalItems",a+=" if (!"+u+") { ";var P=P||[];P.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'additionalItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { limit: "+o.length+" } ",!1!==e.opts.messages&&(a+=" , message: 'should NOT have more than "+o.length+" items' "),e.opts.verbose&&(a+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var E=a;a=P.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+E+"]); ":a+=" validate.errors = ["+E+"]; return false; ":a+=" var err = "+E+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } ",l=b,c&&(m+="}",a+=" else { ")}var x=o;if(x)for(var k,S=-1,R=x.length-1;S<R;)if(k=x[S+=1],e.opts.strictKeywords?"object"==typeof k&&Object.keys(k).length>0||!1===k:e.util.schemaHasRules(k,e.RULES.all)){a+=" "+f+" = true; if ("+d+".length > "+S+") { ";var O=d+"["+S+"]";p.schema=k,p.schemaPath=n+"["+S+"]",p.errSchemaPath=l+"/"+S,p.errorPath=e.util.getPathExpr(e.errorPath,S,e.opts.jsonPointers,!0),p.dataPathArr[y]=S;var T=e.validate(p);p.baseId=_,e.util.varOccurences(T,g)<2?a+=" "+e.util.varReplace(T,g,O)+" ":a+=" var "+g+" = "+O+"; "+T+" ",a+=" } ",c&&(a+=" if ("+f+") { ",m+="}")}if("object"==typeof w&&(e.opts.strictKeywords?"object"==typeof w&&Object.keys(w).length>0||!1===w:e.util.schemaHasRules(w,e.RULES.all))){p.schema=w,p.schemaPath=e.schemaPath+".additionalItems",p.errSchemaPath=e.errSchemaPath+"/additionalItems",a+=" "+f+" = true; if ("+d+".length > "+o.length+") { for (var "+v+" = "+o.length+"; "+v+" < "+d+".length; "+v+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers,!0);O=d+"["+v+"]";p.dataPathArr[y]=v;T=e.validate(p);p.baseId=_,e.util.varOccurences(T,g)<2?a+=" "+e.util.varReplace(T,g,O)+" ":a+=" var "+g+" = "+O+"; "+T+" ",c&&(a+=" if (!"+f+") break; "),a+=" } } ",c&&(a+=" if ("+f+") { ",m+="}")}}else if(e.opts.strictKeywords?"object"==typeof o&&Object.keys(o).length>0||!1===o:e.util.schemaHasRules(o,e.RULES.all)){p.schema=o,p.schemaPath=n,p.errSchemaPath=l,a+=" for (var "+v+" = 0; "+v+" < "+d+".length; "+v+"++) { ",p.errorPath=e.util.getPathExpr(e.errorPath,v,e.opts.jsonPointers,!0);O=d+"["+v+"]";p.dataPathArr[y]=v;T=e.validate(p);p.baseId=_,e.util.varOccurences(T,g)<2?a+=" "+e.util.varReplace(T,g,O)+" ":a+=" var "+g+" = "+O+"; "+T+" ",c&&(a+=" if (!"+f+") break; "),a+=" }"}return c&&(a+=" "+m+" if ("+h+" == errors) {"),a},maximum:ss,minimum:ss,maxItems:is,minItems:is,maxLength:os,minLength:os,maxProperties:ns,minProperties:ns,multipleOf:function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;if(h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,!h&&"number"!=typeof n)throw new Error(t+" must be number");s+="var division"+i+";if (",h&&(s+=" "+a+" !== undefined && ( typeof "+a+" != 'number' || "),s+=" (division"+i+" = "+u+" / "+a+", ",e.opts.multipleOfPrecision?s+=" Math.abs(Math.round(division"+i+") - division"+i+") > 1e-"+e.opts.multipleOfPrecision+" ":s+=" division"+i+" !== parseInt(division"+i+") ",s+=" ) ",h&&(s+=" ) "),s+=" ) { ";var p=p||[];p.push(s),s="",!1!==e.createErrors?(s+=" { keyword: 'multipleOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { multipleOf: "+a+" } ",!1!==e.opts.messages&&(s+=" , message: 'should be multiple of ",s+=h?"' + "+a:a+"'"),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var m=s;return s=p.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+m+"]); ":s+=" validate.errors = ["+m+"]; return false; ":s+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",d&&(s+=" else { "),s},not:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="errs__"+s,h=e.util.copy(e);h.level++;var p="valid"+h.level;if(e.opts.strictKeywords?"object"==typeof o&&Object.keys(o).length>0||!1===o:e.util.schemaHasRules(o,e.RULES.all)){h.schema=o,h.schemaPath=n,h.errSchemaPath=l,a+=" var "+u+" = errors; ";var m,f=e.compositeRule;e.compositeRule=h.compositeRule=!0,h.createErrors=!1,h.opts.allErrors&&(m=h.opts.allErrors,h.opts.allErrors=!1),a+=" "+e.validate(h)+" ",h.createErrors=!0,m&&(h.opts.allErrors=m),e.compositeRule=h.compositeRule=f,a+=" if ("+p+") { ";var v=v||[];v.push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: 'should NOT be valid' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var y=a;a=v.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+y+"]); ":a+=" validate.errors = ["+y+"]; return false; ":a+=" var err = "+y+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } else { errors = "+u+"; if (vErrors !== null) { if ("+u+") vErrors.length = "+u+"; else vErrors = null; } ",e.opts.allErrors&&(a+=" } ")}else a+=" var err = ",!1!==e.createErrors?(a+=" { keyword: 'not' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: {} ",!1!==e.opts.messages&&(a+=" , message: 'should NOT be valid' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",c&&(a+=" if (false) { ");return a},oneOf:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h="errs__"+s,p=e.util.copy(e),m="";p.level++;var f="valid"+p.level,v=p.baseId,y="prevValid"+s,g="passingSchemas"+s;a+="var "+h+" = errors , "+y+" = false , "+u+" = false , "+g+" = null; ";var _=e.compositeRule;e.compositeRule=p.compositeRule=!0;var w=o;if(w)for(var b,P=-1,E=w.length-1;P<E;)b=w[P+=1],(e.opts.strictKeywords?"object"==typeof b&&Object.keys(b).length>0||!1===b:e.util.schemaHasRules(b,e.RULES.all))?(p.schema=b,p.schemaPath=n+"["+P+"]",p.errSchemaPath=l+"/"+P,a+=" "+e.validate(p)+" ",p.baseId=v):a+=" var "+f+" = true; ",P&&(a+=" if ("+f+" && "+y+") { "+u+" = false; "+g+" = ["+g+", "+P+"]; } else { ",m+="}"),a+=" if ("+f+") { "+u+" = "+y+" = true; "+g+" = "+P+"; }";return e.compositeRule=p.compositeRule=_,a+=m+"if (!"+u+") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'oneOf' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { passingSchemas: "+g+" } ",!1!==e.opts.messages&&(a+=" , message: 'should match exactly one schema in oneOf' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?a+=" throw new ValidationError(vErrors); ":a+=" validate.errors = vErrors; return false; "),a+="} else { errors = "+h+"; if (vErrors !== null) { if ("+h+") vErrors.length = "+h+"; else vErrors = null; }",e.opts.allErrors&&(a+=" } "),a},pattern:function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h=e.opts.$data&&n&&n.$data;h?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,s+="if ( ",h&&(s+=" ("+a+" !== undefined && typeof "+a+" != 'string') || "),s+=" !"+(h?"(new RegExp("+a+"))":e.usePattern(n))+".test("+u+") ) { ";var p=p||[];p.push(s),s="",!1!==e.createErrors?(s+=" { keyword: 'pattern' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { pattern: ",s+=h?""+a:""+e.util.toQuotedString(n),s+=" } ",!1!==e.opts.messages&&(s+=" , message: 'should match pattern \"",s+=h?"' + "+a+" + '":""+e.util.escapeQuotes(n),s+="\"' "),e.opts.verbose&&(s+=" , schema: ",s+=h?"validate.schema"+l:""+e.util.toQuotedString(n),s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var m=s;return s=p.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+m+"]); ":s+=" validate.errors = ["+m+"]; return false; ":s+=" var err = "+m+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+="} ",d&&(s+=" else { "),s},properties:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="errs__"+s,h=e.util.copy(e),p="";h.level++;var m="valid"+h.level,f="key"+s,v="idx"+s,y=h.dataLevel=e.dataLevel+1,g="data"+y,_="dataProperties"+s,w=Object.keys(o||{}).filter(j),b=e.schema.patternProperties||{},P=Object.keys(b).filter(j),E=e.schema.additionalProperties,x=w.length||P.length,k=!1===E,S="object"==typeof E&&Object.keys(E).length,R=e.opts.removeAdditional,O=k||S||R,T=e.opts.ownProperties,$=e.baseId,I=e.schema.required;if(I&&(!e.opts.$data||!I.$data)&&I.length<e.opts.loopRequired)var C=e.util.toHash(I);function j(e){return"__proto__"!==e}if(a+="var "+u+" = errors;var "+m+" = true;",T&&(a+=" var "+_+" = undefined;"),O){if(a+=T?" "+_+" = "+_+" || Object.keys("+d+"); for (var "+v+"=0; "+v+"<"+_+".length; "+v+"++) { var "+f+" = "+_+"["+v+"]; ":" for (var "+f+" in "+d+") { ",x){if(a+=" var isAdditional"+s+" = !(false ",w.length)if(w.length>8)a+=" || validate.schema"+n+".hasOwnProperty("+f+") ";else{var F=w;if(F)for(var A=-1,D=F.length-1;A<D;)W=F[A+=1],a+=" || "+f+" == "+e.util.toQuotedString(W)+" "}if(P.length){var N=P;if(N)for(var q=-1,L=N.length-1;q<L;)ie=N[q+=1],a+=" || "+e.usePattern(ie)+".test("+f+") "}a+=" ); if (isAdditional"+s+") { "}if("all"==R)a+=" delete "+d+"["+f+"]; ";else{var z=e.errorPath,Z="' + "+f+" + '";if(e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(e.errorPath,f,e.opts.jsonPointers)),k)if(R)a+=" delete "+d+"["+f+"]; ";else{a+=" "+m+" = false; ";var M=l;l=e.errSchemaPath+"/additionalProperties",(re=re||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'additionalProperties' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { additionalProperty: '"+Z+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is an invalid additional property":a+="should NOT have additional properties",a+="' "),e.opts.verbose&&(a+=" , schema: false , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var U=a;a=re.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+U+"]); ":a+=" validate.errors = ["+U+"]; return false; ":a+=" var err = "+U+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",l=M,c&&(a+=" break; ")}else if(S)if("failing"==R){a+=" var "+u+" = errors; ";var V=e.compositeRule;e.compositeRule=h.compositeRule=!0,h.schema=E,h.schemaPath=e.schemaPath+".additionalProperties",h.errSchemaPath=e.errSchemaPath+"/additionalProperties",h.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,f,e.opts.jsonPointers);var H=d+"["+f+"]";h.dataPathArr[y]=f;var Q=e.validate(h);h.baseId=$,e.util.varOccurences(Q,g)<2?a+=" "+e.util.varReplace(Q,g,H)+" ":a+=" var "+g+" = "+H+"; "+Q+" ",a+=" if (!"+m+") { errors = "+u+"; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete "+d+"["+f+"]; } ",e.compositeRule=h.compositeRule=V}else{h.schema=E,h.schemaPath=e.schemaPath+".additionalProperties",h.errSchemaPath=e.errSchemaPath+"/additionalProperties",h.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,f,e.opts.jsonPointers);H=d+"["+f+"]";h.dataPathArr[y]=f;Q=e.validate(h);h.baseId=$,e.util.varOccurences(Q,g)<2?a+=" "+e.util.varReplace(Q,g,H)+" ":a+=" var "+g+" = "+H+"; "+Q+" ",c&&(a+=" if (!"+m+") break; ")}e.errorPath=z}x&&(a+=" } "),a+=" } ",c&&(a+=" if ("+m+") { ",p+="}")}var K=e.opts.useDefaults&&!e.compositeRule;if(w.length){var B=w;if(B)for(var W,J=-1,G=B.length-1;J<G;){var Y=o[W=B[J+=1]];if(e.opts.strictKeywords?"object"==typeof Y&&Object.keys(Y).length>0||!1===Y:e.util.schemaHasRules(Y,e.RULES.all)){var X=e.util.getProperty(W),ee=(H=d+X,K&&void 0!==Y.default);h.schema=Y,h.schemaPath=n+X,h.errSchemaPath=l+"/"+e.util.escapeFragment(W),h.errorPath=e.util.getPath(e.errorPath,W,e.opts.jsonPointers),h.dataPathArr[y]=e.util.toQuotedString(W);Q=e.validate(h);if(h.baseId=$,e.util.varOccurences(Q,g)<2){Q=e.util.varReplace(Q,g,H);var te=H}else{te=g;a+=" var "+g+" = "+H+"; "}if(ee)a+=" "+Q+" ";else{if(C&&C[W]){a+=" if ( "+te+" === undefined ",T&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(W)+"') "),a+=") { "+m+" = false; ";z=e.errorPath,M=l;var re,ae=e.util.escapeQuotes(W);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(z,W,e.opts.jsonPointers)),l=e.errSchemaPath+"/required",(re=re||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+ae+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+ae+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";U=a;a=re.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+U+"]); ":a+=" validate.errors = ["+U+"]; return false; ":a+=" var err = "+U+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",l=M,e.errorPath=z,a+=" } else { "}else c?(a+=" if ( "+te+" === undefined ",T&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(W)+"') "),a+=") { "+m+" = true; } else { "):(a+=" if ("+te+" !== undefined ",T&&(a+=" && Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(W)+"') "),a+=" ) { ");a+=" "+Q+" } "}}c&&(a+=" if ("+m+") { ",p+="}")}}if(P.length){var se=P;if(se)for(var ie,oe=-1,ne=se.length-1;oe<ne;){Y=b[ie=se[oe+=1]];if(e.opts.strictKeywords?"object"==typeof Y&&Object.keys(Y).length>0||!1===Y:e.util.schemaHasRules(Y,e.RULES.all)){h.schema=Y,h.schemaPath=e.schemaPath+".patternProperties"+e.util.getProperty(ie),h.errSchemaPath=e.errSchemaPath+"/patternProperties/"+e.util.escapeFragment(ie),a+=T?" "+_+" = "+_+" || Object.keys("+d+"); for (var "+v+"=0; "+v+"<"+_+".length; "+v+"++) { var "+f+" = "+_+"["+v+"]; ":" for (var "+f+" in "+d+") { ",a+=" if ("+e.usePattern(ie)+".test("+f+")) { ",h.errorPath=e.util.getPathExpr(e.errorPath,f,e.opts.jsonPointers);H=d+"["+f+"]";h.dataPathArr[y]=f;Q=e.validate(h);h.baseId=$,e.util.varOccurences(Q,g)<2?a+=" "+e.util.varReplace(Q,g,H)+" ":a+=" var "+g+" = "+H+"; "+Q+" ",c&&(a+=" if (!"+m+") break; "),a+=" } ",c&&(a+=" else "+m+" = true; "),a+=" } ",c&&(a+=" if ("+m+") { ",p+="}")}}}return c&&(a+=" "+p+" if ("+u+" == errors) {"),a},propertyNames:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="errs__"+s,h=e.util.copy(e);h.level++;var p="valid"+h.level;if(a+="var "+u+" = errors;",e.opts.strictKeywords?"object"==typeof o&&Object.keys(o).length>0||!1===o:e.util.schemaHasRules(o,e.RULES.all)){h.schema=o,h.schemaPath=n,h.errSchemaPath=l;var m="key"+s,f="idx"+s,v="i"+s,y="' + "+m+" + '",g="data"+(h.dataLevel=e.dataLevel+1),_="dataProperties"+s,w=e.opts.ownProperties,b=e.baseId;w&&(a+=" var "+_+" = undefined; "),a+=w?" "+_+" = "+_+" || Object.keys("+d+"); for (var "+f+"=0; "+f+"<"+_+".length; "+f+"++) { var "+m+" = "+_+"["+f+"]; ":" for (var "+m+" in "+d+") { ",a+=" var startErrs"+s+" = errors; ";var P=m,E=e.compositeRule;e.compositeRule=h.compositeRule=!0;var x=e.validate(h);h.baseId=b,e.util.varOccurences(x,g)<2?a+=" "+e.util.varReplace(x,g,P)+" ":a+=" var "+g+" = "+P+"; "+x+" ",e.compositeRule=h.compositeRule=E,a+=" if (!"+p+") { for (var "+v+"=startErrs"+s+"; "+v+"<errors; "+v+"++) { vErrors["+v+"].propertyName = "+m+"; } var err = ",!1!==e.createErrors?(a+=" { keyword: 'propertyNames' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { propertyName: '"+y+"' } ",!1!==e.opts.messages&&(a+=" , message: 'property name \\'"+y+"\\' is invalid' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&c&&(e.async?a+=" throw new ValidationError(vErrors); ":a+=" validate.errors = vErrors; return false; "),c&&(a+=" break; "),a+=" } }"}return c&&(a+=" if ("+u+" == errors) {"),a},required:function(e,t,r){var a=" ",s=e.level,i=e.dataLevel,o=e.schema[t],n=e.schemaPath+e.util.getProperty(t),l=e.errSchemaPath+"/"+t,c=!e.opts.allErrors,d="data"+(i||""),u="valid"+s,h=e.opts.$data&&o&&o.$data;h&&(a+=" var schema"+s+" = "+e.util.getData(o.$data,i,e.dataPathArr)+"; ");var p="schema"+s;if(!h)if(o.length<e.opts.loopRequired&&e.schema.properties&&Object.keys(e.schema.properties).length){var m=[],f=o;if(f)for(var v,y=-1,g=f.length-1;y<g;){v=f[y+=1];var _=e.schema.properties[v];_&&(e.opts.strictKeywords?"object"==typeof _&&Object.keys(_).length>0||!1===_:e.util.schemaHasRules(_,e.RULES.all))||(m[m.length]=v)}}else m=o;if(h||m.length){var w=e.errorPath,b=h||m.length>=e.opts.loopRequired,P=e.opts.ownProperties;if(c)if(a+=" var missing"+s+"; ",b){h||(a+=" var "+p+" = validate.schema"+n+"; ");var E="' + "+(T="schema"+s+"["+(S="i"+s)+"]")+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(w,T,e.opts.jsonPointers)),a+=" var "+u+" = true; ",h&&(a+=" if (schema"+s+" === undefined) "+u+" = true; else if (!Array.isArray(schema"+s+")) "+u+" = false; else {"),a+=" for (var "+S+" = 0; "+S+" < "+p+".length; "+S+"++) { "+u+" = "+d+"["+p+"["+S+"]] !== undefined ",P&&(a+=" && Object.prototype.hasOwnProperty.call("+d+", "+p+"["+S+"]) "),a+="; if (!"+u+") break; } ",h&&(a+=" } "),a+=" if (!"+u+") { ",(O=O||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+E+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+E+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";var x=a;a=O.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+x+"]); ":a+=" validate.errors = ["+x+"]; return false; ":a+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } else { "}else{a+=" if ( ";var k=m;if(k)for(var S=-1,R=k.length-1;S<R;){I=k[S+=1],S&&(a+=" || "),a+=" ( ( "+(A=d+(F=e.util.getProperty(I)))+" === undefined ",P&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(I)+"') "),a+=") && (missing"+s+" = "+e.util.toQuotedString(e.opts.jsonPointers?I:F)+") ) "}a+=") { ";var O;E="' + "+(T="missing"+s)+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(w,T,!0):w+" + "+T),(O=O||[]).push(a),a="",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+E+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+E+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ";x=a;a=O.pop(),!e.compositeRule&&c?e.async?a+=" throw new ValidationError(["+x+"]); ":a+=" validate.errors = ["+x+"]; return false; ":a+=" var err = "+x+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",a+=" } else { "}else if(b){h||(a+=" var "+p+" = validate.schema"+n+"; ");var T;E="' + "+(T="schema"+s+"["+(S="i"+s)+"]")+" + '";e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(w,T,e.opts.jsonPointers)),h&&(a+=" if ("+p+" && !Array.isArray("+p+")) { var err = ",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+E+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+E+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if ("+p+" !== undefined) { "),a+=" for (var "+S+" = 0; "+S+" < "+p+".length; "+S+"++) { if ("+d+"["+p+"["+S+"]] === undefined ",P&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", "+p+"["+S+"]) "),a+=") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+E+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+E+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } ",h&&(a+=" } ")}else{var $=m;if($)for(var I,C=-1,j=$.length-1;C<j;){I=$[C+=1];var F=e.util.getProperty(I),A=(E=e.util.escapeQuotes(I),d+F);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(w,I,e.opts.jsonPointers)),a+=" if ( "+A+" === undefined ",P&&(a+=" || ! Object.prototype.hasOwnProperty.call("+d+", '"+e.util.escapeQuotes(I)+"') "),a+=") { var err = ",!1!==e.createErrors?(a+=" { keyword: 'required' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(l)+" , params: { missingProperty: '"+E+"' } ",!1!==e.opts.messages&&(a+=" , message: '",e.opts._errorDataPathProperty?a+="is a required property":a+="should have required property \\'"+E+"\\'",a+="' "),e.opts.verbose&&(a+=" , schema: validate.schema"+n+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+d+" "),a+=" } "):a+=" {} ",a+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } "}}e.errorPath=w}else c&&(a+=" if (true) {");return a},uniqueItems:function(e,t,r){var a,s=" ",i=e.level,o=e.dataLevel,n=e.schema[t],l=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+"/"+t,d=!e.opts.allErrors,u="data"+(o||""),h="valid"+i,p=e.opts.$data&&n&&n.$data;if(p?(s+=" var schema"+i+" = "+e.util.getData(n.$data,o,e.dataPathArr)+"; ",a="schema"+i):a=n,(n||p)&&!1!==e.opts.uniqueItems){p&&(s+=" var "+h+"; if ("+a+" === false || "+a+" === undefined) "+h+" = true; else if (typeof "+a+" != 'boolean') "+h+" = false; else { "),s+=" var i = "+u+".length , "+h+" = true , j; if (i > 1) { ";var m=e.schema.items&&e.schema.items.type,f=Array.isArray(m);if(!m||"object"==m||"array"==m||f&&(m.indexOf("object")>=0||m.indexOf("array")>=0))s+=" outer: for (;i--;) { for (j = i; j--;) { if (equal("+u+"[i], "+u+"[j])) { "+h+" = false; break outer; } } } ";else{s+=" var itemIndices = {}, item; for (;i--;) { var item = "+u+"[i]; ";var v="checkDataType"+(f?"s":"");s+=" if ("+e.util[v](m,"item",e.opts.strictNumbers,!0)+") continue; ",f&&(s+=" if (typeof item == 'string') item = '\"' + item; "),s+=" if (typeof itemIndices[item] == 'number') { "+h+" = false; j = itemIndices[item]; break; } itemIndices[item] = i; } "}s+=" } ",p&&(s+=" } "),s+=" if (!"+h+") { ";var y=y||[];y.push(s),s="",!1!==e.createErrors?(s+=" { keyword: 'uniqueItems' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(c)+" , params: { i: i, j: j } ",!1!==e.opts.messages&&(s+=" , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' "),e.opts.verbose&&(s+=" , schema: ",s+=p?"validate.schema"+l:""+n,s+=" , parentSchema: validate.schema"+e.schemaPath+" , data: "+u+" "),s+=" } "):s+=" {} ";var g=s;s=y.pop(),!e.compositeRule&&d?e.async?s+=" throw new ValidationError(["+g+"]); ":s+=" validate.errors = ["+g+"]; return false; ":s+=" var err = "+g+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",s+=" } ",d&&(s+=" else { ")}else d&&(s+=" if (true) { ");return s},validate:ya},cs=ls,ds=Sr.toHash,us=["multipleOf","maximum","exclusiveMaximum","minimum","exclusiveMinimum","maxLength","minLength","pattern","additionalItems","maxItems","minItems","uniqueItems","maxProperties","minProperties","required","additionalProperties","enum","format","const"],hs=pa.MissingRef,ps=function e(t,r,a){var s=this;if("function"!=typeof this._opts.loadSchema)throw new Error("options.loadSchema should be a function");"function"==typeof r&&(a=r,r=void 0);var i=o(t).then((function(){var e=s._addSchema(t,void 0,r);return e.validate||n(e)}));a&&i.then((function(e){a(null,e)}),a);return i;function o(t){var r=t.$schema;return r&&!s.getSchema(r)?e.call(s,{$ref:r},!0):Promise.resolve()}function n(e){try{return s._compile(e)}catch(t){if(t instanceof hs)return function(t){var a=t.missingSchema;if(c(a))throw new Error("Schema "+a+" is loaded but "+t.missingRef+" cannot be resolved");var i=s._loadingSchemas[a];i||(i=s._loadingSchemas[a]=s._opts.loadSchema(a)).then(l,l);return i.then((function(e){if(!c(a))return o(e).then((function(){c(a)||s.addSchema(e,a,void 0,r)}))})).then((function(){return n(e)}));function l(){delete s._loadingSchemas[a]}function c(e){return s._refs[e]||s._schemas[e]}}(t);throw t}}};var ms={$schema:"http://json-schema.org/draft-07/schema#",$id:"http://json-schema.org/draft-07/schema#",title:"Core schema meta-schema",definitions:{schemaArray:{type:"array",minItems:1,items:{$ref:"#"}},nonNegativeInteger:{type:"integer",minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:"#/definitions/nonNegativeInteger"},{default:0}]},simpleTypes:{enum:["array","boolean","integer","null","number","object","string"]},stringArray:{type:"array",items:{type:"string"},uniqueItems:!0,default:[]}},type:["object","boolean"],properties:{$id:{type:"string",format:"uri-reference"},$schema:{type:"string",format:"uri"},$ref:{type:"string",format:"uri-reference"},$comment:{type:"string"},title:{type:"string"},description:{type:"string"},default:!0,readOnly:{type:"boolean",default:!1},examples:{type:"array",items:!0},multipleOf:{type:"number",exclusiveMinimum:0},maximum:{type:"number"},exclusiveMaximum:{type:"number"},minimum:{type:"number"},exclusiveMinimum:{type:"number"},maxLength:{$ref:"#/definitions/nonNegativeInteger"},minLength:{$ref:"#/definitions/nonNegativeIntegerDefault0"},pattern:{type:"string",format:"regex"},additionalItems:{$ref:"#"},items:{anyOf:[{$ref:"#"},{$ref:"#/definitions/schemaArray"}],default:!0},maxItems:{$ref:"#/definitions/nonNegativeInteger"},minItems:{$ref:"#/definitions/nonNegativeIntegerDefault0"},uniqueItems:{type:"boolean",default:!1},contains:{$ref:"#"},maxProperties:{$ref:"#/definitions/nonNegativeInteger"},minProperties:{$ref:"#/definitions/nonNegativeIntegerDefault0"},required:{$ref:"#/definitions/stringArray"},additionalProperties:{$ref:"#"},definitions:{type:"object",additionalProperties:{$ref:"#"},default:{}},properties:{type:"object",additionalProperties:{$ref:"#"},default:{}},patternProperties:{type:"object",additionalProperties:{$ref:"#"},propertyNames:{format:"regex"},default:{}},dependencies:{type:"object",additionalProperties:{anyOf:[{$ref:"#"},{$ref:"#/definitions/stringArray"}]}},propertyNames:{$ref:"#"},const:!0,enum:{type:"array",items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:"#/definitions/simpleTypes"},{type:"array",items:{$ref:"#/definitions/simpleTypes"},minItems:1,uniqueItems:!0}]},format:{type:"string"},contentMediaType:{type:"string"},contentEncoding:{type:"string"},if:{$ref:"#"},then:{$ref:"#"},else:{$ref:"#"},allOf:{$ref:"#/definitions/schemaArray"},anyOf:{$ref:"#/definitions/schemaArray"},oneOf:{$ref:"#/definitions/schemaArray"},not:{$ref:"#"}},default:!0},fs=ms,vs={$id:"https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js",definitions:{simpleTypes:fs.definitions.simpleTypes},type:"object",dependencies:{schema:["validate"],$data:["validate"],statements:["inline"],valid:{not:{required:["macro"]}}},properties:{type:fs.properties.type,schema:{type:"boolean"},statements:{type:"boolean"},dependencies:{type:"array",items:{type:"string"}},metaSchema:{type:"object"},modifying:{type:"boolean"},valid:{type:"boolean"},$data:{type:"boolean"},async:{type:"boolean"},errors:{anyOf:[{type:"boolean"},{const:"full"}]}}},ys=/^[a-z_$][a-z0-9_$-]*$/i,gs=function(e,t,r){var a,s,i=" ",o=e.level,n=e.dataLevel,l=e.schema[t],c=e.schemaPath+e.util.getProperty(t),d=e.errSchemaPath+"/"+t,u=!e.opts.allErrors,h="data"+(n||""),p="valid"+o,m="errs__"+o,f=e.opts.$data&&l&&l.$data;f?(i+=" var schema"+o+" = "+e.util.getData(l.$data,n,e.dataPathArr)+"; ",s="schema"+o):s=l;var v,y,g,_,w,b=this,P="definition"+o,E=b.definition,x="";if(f&&E.$data){w="keywordValidate"+o;var k=E.validateSchema;i+=" var "+P+" = RULES.custom['"+t+"'].definition; var "+w+" = "+P+".validate;"}else{if(!(_=e.useCustomRule(b,l,e.schema,e)))return;s="validate.schema"+c,w=_.code,v=E.compile,y=E.inline,g=E.macro}var S=w+".errors",R="i"+o,O="ruleErr"+o,T=E.async;if(T&&!e.async)throw new Error("async keyword in sync schema");if(y||g||(i+=S+" = null;"),i+="var "+m+" = errors;var "+p+";",f&&E.$data&&(x+="}",i+=" if ("+s+" === undefined) { "+p+" = true; } else { ",k&&(x+="}",i+=" "+p+" = "+P+".validateSchema("+s+"); if ("+p+") { ")),y)E.statements?i+=" "+_.validate+" ":i+=" "+p+" = "+_.validate+"; ";else if(g){var $=e.util.copy(e);x="";$.level++;var I="valid"+$.level;$.schema=_.validate,$.schemaPath="";var C=e.compositeRule;e.compositeRule=$.compositeRule=!0;var j=e.validate($).replace(/validate\.schema/g,w);e.compositeRule=$.compositeRule=C,i+=" "+j}else{(N=N||[]).push(i),i="",i+=" "+w+".call( ",e.opts.passContext?i+="this":i+="self",v||!1===E.schema?i+=" , "+h+" ":i+=" , "+s+" , "+h+" , validate.schema"+e.schemaPath+" ",i+=" , (dataPath || '')",'""'!=e.errorPath&&(i+=" + "+e.errorPath);var F=n?"data"+(n-1||""):"parentData",A=n?e.dataPathArr[n]:"parentDataProperty",D=i+=" , "+F+" , "+A+" , rootData ) ";i=N.pop(),!1===E.errors?(i+=" "+p+" = ",T&&(i+="await "),i+=D+"; "):i+=T?" var "+(S="customErrors"+o)+" = null; try { "+p+" = await "+D+"; } catch (e) { "+p+" = false; if (e instanceof ValidationError) "+S+" = e.errors; else throw e; } ":" "+S+" = null; "+p+" = "+D+"; "}if(E.modifying&&(i+=" if ("+F+") "+h+" = "+F+"["+A+"];"),i+=""+x,E.valid)u&&(i+=" if (true) { ");else{var N;i+=" if ( ",void 0===E.valid?(i+=" !",i+=g?""+I:""+p):i+=" "+!E.valid+" ",i+=") { ",a=b.keyword,(N=N||[]).push(i),i="",(N=N||[]).push(i),i="",!1!==e.createErrors?(i+=" { keyword: '"+(a||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { keyword: '"+b.keyword+"' } ",!1!==e.opts.messages&&(i+=" , message: 'should pass \""+b.keyword+"\" keyword validation' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ";var q=i;i=N.pop(),!e.compositeRule&&u?e.async?i+=" throw new ValidationError(["+q+"]); ":i+=" validate.errors = ["+q+"]; return false; ":i+=" var err = "+q+"; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ";var L=i;i=N.pop(),y?E.errors?"full"!=E.errors&&(i+=" for (var "+R+"="+m+"; "+R+"<errors; "+R+"++) { var "+O+" = vErrors["+R+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+O+".schemaPath === undefined) { "+O+'.schemaPath = "'+d+'"; } ',e.opts.verbose&&(i+=" "+O+".schema = "+s+"; "+O+".data = "+h+"; "),i+=" } "):!1===E.errors?i+=" "+L+" ":(i+=" if ("+m+" == errors) { "+L+" } else { for (var "+R+"="+m+"; "+R+"<errors; "+R+"++) { var "+O+" = vErrors["+R+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; if ("+O+".schemaPath === undefined) { "+O+'.schemaPath = "'+d+'"; } ',e.opts.verbose&&(i+=" "+O+".schema = "+s+"; "+O+".data = "+h+"; "),i+=" } } "):g?(i+=" var err = ",!1!==e.createErrors?(i+=" { keyword: '"+(a||"custom")+"' , dataPath: (dataPath || '') + "+e.errorPath+" , schemaPath: "+e.util.toQuotedString(d)+" , params: { keyword: '"+b.keyword+"' } ",!1!==e.opts.messages&&(i+=" , message: 'should pass \""+b.keyword+"\" keyword validation' "),e.opts.verbose&&(i+=" , schema: validate.schema"+c+" , parentSchema: validate.schema"+e.schemaPath+" , data: "+h+" "),i+=" } "):i+=" {} ",i+="; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; ",!e.compositeRule&&u&&(e.async?i+=" throw new ValidationError(vErrors); ":i+=" validate.errors = vErrors; return false; ")):!1===E.errors?i+=" "+L+" ":(i+=" if (Array.isArray("+S+")) { if (vErrors === null) vErrors = "+S+"; else vErrors = vErrors.concat("+S+"); errors = vErrors.length; for (var "+R+"="+m+"; "+R+"<errors; "+R+"++) { var "+O+" = vErrors["+R+"]; if ("+O+".dataPath === undefined) "+O+".dataPath = (dataPath || '') + "+e.errorPath+"; "+O+'.schemaPath = "'+d+'"; ',e.opts.verbose&&(i+=" "+O+".schema = "+s+"; "+O+".data = "+h+"; "),i+=" } } else { "+L+" } "),i+=" } ",u&&(i+=" else { ")}return i},_s=vs,ws={add:function(e,t){var r=this.RULES;if(r.keywords[e])throw new Error("Keyword "+e+" is already defined");if(!ys.test(e))throw new Error("Keyword "+e+" is not a valid identifier");if(t){this.validateKeyword(t,!0);var a=t.type;if(Array.isArray(a))for(var s=0;s<a.length;s++)o(e,a[s],t);else o(e,a,t);var i=t.metaSchema;i&&(t.$data&&this._opts.$data&&(i={anyOf:[i,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]}),t.validateSchema=this.compile(i,!0))}function o(e,t,a){for(var s,i=0;i<r.length;i++){var o=r[i];if(o.type==t){s=o;break}}s||(s={type:t,rules:[]},r.push(s));var n={keyword:e,definition:a,custom:!0,code:gs,implements:a.implements};s.rules.push(n),r.custom[e]=n}return r.keywords[e]=r.all[e]=!0,this},get:function(e){var t=this.RULES.custom[e];return t?t.definition:this.RULES.keywords[e]||!1},remove:function(e){var t=this.RULES;delete t.keywords[e],delete t.all[e],delete t.custom[e];for(var r=0;r<t.length;r++)for(var a=t[r].rules,s=0;s<a.length;s++)if(a[s].keyword==e){a.splice(s,1);break}return this},validate:function e(t,r){e.errors=null;var a=this._validateKeyword=this._validateKeyword||this.compile(_s,!0);if(a(t))return!0;if(e.errors=a.errors,r)throw new Error("custom keyword definition is invalid: "+this.errorsText(a.errors));return!1}};var bs={$schema:"http://json-schema.org/draft-07/schema#",$id:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#",description:"Meta-schema for $data reference (JSON Schema extension proposal)",type:"object",required:["$data"],properties:{$data:{type:"string",anyOf:[{format:"relative-json-pointer"},{format:"json-pointer"}]}},additionalProperties:!1},Ps=Sa,Es=Gr,xs=Na,ks=Zr,Ss=va,Rs=Ja,Os=function(){var e=[{type:"number",rules:[{maximum:["exclusiveMaximum"]},{minimum:["exclusiveMinimum"]},"multipleOf","format"]},{type:"string",rules:["maxLength","minLength","pattern","format"]},{type:"array",rules:["maxItems","minItems","items","contains","uniqueItems"]},{type:"object",rules:["maxProperties","minProperties","required","dependencies","propertyNames",{properties:["additionalProperties","patternProperties"]}]},{rules:["$ref","const","enum","not","anyOf","oneOf","allOf","if"]}],t=["type","$comment"];return e.all=ds(t),e.types=ds(["number","integer","string","array","object","boolean","null"]),e.forEach((function(r){r.rules=r.rules.map((function(r){var a;if("object"==typeof r){var s=Object.keys(r)[0];a=r[s],r=s,a.forEach((function(r){t.push(r),e.all[r]=!0}))}return t.push(r),e.all[r]={keyword:r,code:cs[r],implements:a}})),e.all.$comment={keyword:"$comment",code:cs.$comment},r.type&&(e.types[r.type]=r)})),e.keywords=ds(t.concat(["$schema","$id","id","$data","$async","title","description","default","definitions","examples","readOnly","writeOnly","contentMediaType","contentEncoding","additionalItems","then","else"])),e.custom={},e},Ts=function(e,t){for(var r=0;r<t.length;r++){e=JSON.parse(JSON.stringify(e));var a,s=t[r].split("/"),i=e;for(a=1;a<s.length;a++)i=i[s[a]];for(a=0;a<us.length;a++){var o=us[a],n=i[o];n&&(i[o]={anyOf:[n,{$ref:"https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"}]})}}return e},$s=Sr,Is=Ns;Ns.prototype.validate=function(e,t){var r;if("string"==typeof e){if(!(r=this.getSchema(e)))throw new Error('no schema with key or ref "'+e+'"')}else{var a=this._addSchema(e);r=a.validate||this._compile(a)}var s=r(t);!0!==r.$async&&(this.errors=r.errors);return s},Ns.prototype.compile=function(e,t){var r=this._addSchema(e,void 0,t);return r.validate||this._compile(r)},Ns.prototype.addSchema=function(e,t,r,a){if(Array.isArray(e)){for(var s=0;s<e.length;s++)this.addSchema(e[s],void 0,r,a);return this}var i=this._getId(e);if(void 0!==i&&"string"!=typeof i)throw new Error("schema id must be string");return Us(this,t=Es.normalizeId(t||i)),this._schemas[t]=this._addSchema(e,r,a,!0),this},Ns.prototype.addMetaSchema=function(e,t,r){return this.addSchema(e,t,r,!0),this},Ns.prototype.validateSchema=function(e,t){var r=e.$schema;if(void 0!==r&&"string"!=typeof r)throw new Error("$schema must be a string");if(r=r||this._opts.defaultMeta||function(e){var t=e._opts.meta;return e._opts.defaultMeta="object"==typeof t?e._getId(t)||t:e.getSchema(Fs)?Fs:void 0,e._opts.defaultMeta}(this),!r)return this.logger.warn("meta-schema not available"),this.errors=null,!0;var a=this.validate(r,e);if(!a&&t){var s="schema is invalid: "+this.errorsText();if("log"!=this._opts.validateSchema)throw new Error(s);this.logger.error(s)}return a},Ns.prototype.getSchema=function(e){var t=qs(this,e);switch(typeof t){case"object":return t.validate||this._compile(t);case"string":return this.getSchema(t);case"undefined":return function(e,t){var r=Es.schema.call(e,{schema:{}},t);if(r){var a=r.schema,s=r.root,i=r.baseId,o=Ps.call(e,a,s,void 0,i);return e._fragments[t]=new ks({ref:t,fragment:!0,schema:a,root:s,baseId:i,validate:o}),o}}(this,e)}},Ns.prototype.removeSchema=function(e){if(e instanceof RegExp)return Ls(this,this._schemas,e),Ls(this,this._refs,e),this;switch(typeof e){case"undefined":return Ls(this,this._schemas),Ls(this,this._refs),this._cache.clear(),this;case"string":var t=qs(this,e);return t&&this._cache.del(t.cacheKey),delete this._schemas[e],delete this._refs[e],this;case"object":var r=this._opts.serialize,a=r?r(e):e;this._cache.del(a);var s=this._getId(e);s&&(s=Es.normalizeId(s),delete this._schemas[s],delete this._refs[s])}return this},Ns.prototype.addFormat=function(e,t){"string"==typeof t&&(t=new RegExp(t));return this._formats[e]=t,this},Ns.prototype.errorsText=function(e,t){if(!(e=e||this.errors))return"No errors";for(var r=void 0===(t=t||{}).separator?", ":t.separator,a=void 0===t.dataVar?"data":t.dataVar,s="",i=0;i<e.length;i++){var o=e[i];o&&(s+=a+o.dataPath+" "+o.message+r)}return s.slice(0,-r.length)},Ns.prototype._addSchema=function(e,t,r,a){if("object"!=typeof e&&"boolean"!=typeof e)throw new Error("schema should be object or boolean");var s=this._opts.serialize,i=s?s(e):e,o=this._cache.get(i);if(o)return o;a=a||!1!==this._opts.addUsedSchema;var n=Es.normalizeId(this._getId(e));n&&a&&Us(this,n);var l,c=!1!==this._opts.validateSchema&&!t;c&&!(l=n&&n==Es.normalizeId(e.$schema))&&this.validateSchema(e,!0);var d=Es.ids.call(this,e),u=new ks({id:n,schema:e,localRefs:d,cacheKey:i,meta:r});"#"!=n[0]&&a&&(this._refs[n]=u);this._cache.put(i,u),c&&l&&this.validateSchema(e,!0);return u},Ns.prototype._compile=function(e,t){if(e.compiling)return e.validate=s,s.schema=e.schema,s.errors=null,s.root=t||s,!0===e.schema.$async&&(s.$async=!0),s;var r,a;e.compiling=!0,e.meta&&(r=this._opts,this._opts=this._metaOpts);try{a=Ps.call(this,e.schema,t,e.localRefs)}catch(t){throw delete e.validate,t}finally{e.compiling=!1,e.meta&&(this._opts=r)}return e.validate=a,e.refs=a.refs,e.refVal=a.refVal,e.root=a.root,a;function s(){var t=e.validate,r=t.apply(this,arguments);return s.errors=t.errors,r}},Ns.prototype.compileAsync=ps;var Cs=ws;Ns.prototype.addKeyword=Cs.add,Ns.prototype.getKeyword=Cs.get,Ns.prototype.removeKeyword=Cs.remove,Ns.prototype.validateKeyword=Cs.validate;var js=pa;Ns.ValidationError=js.Validation,Ns.MissingRefError=js.MissingRef,Ns.$dataMetaSchema=Ts;var Fs="http://json-schema.org/draft-07/schema",As=["removeAdditional","useDefaults","coerceTypes","strictDefaults"],Ds=["/properties"];function Ns(e){if(!(this instanceof Ns))return new Ns(e);e=this._opts=$s.copy(e)||{},function(e){var t=e._opts.logger;if(!1===t)e.logger={log:Vs,warn:Vs,error:Vs};else{if(void 0===t&&(t=console),!("object"==typeof t&&t.log&&t.warn&&t.error))throw new Error("logger must implement log, warn and error methods");e.logger=t}}(this),this._schemas={},this._refs={},this._fragments={},this._formats=Rs(e.format),this._cache=e.cache||new xs,this._loadingSchemas={},this._compilations=[],this.RULES=Os(),this._getId=function(e){switch(e.schemaId){case"auto":return Ms;case"id":return zs;default:return Zs}}(e),e.loopRequired=e.loopRequired||1/0,"property"==e.errorDataPath&&(e._errorDataPathProperty=!0),void 0===e.serialize&&(e.serialize=Ss),this._metaOpts=function(e){for(var t=$s.copy(e._opts),r=0;r<As.length;r++)delete t[As[r]];return t}(this),e.formats&&function(e){for(var t in e._opts.formats){var r=e._opts.formats[t];e.addFormat(t,r)}}(this),e.keywords&&function(e){for(var t in e._opts.keywords){var r=e._opts.keywords[t];e.addKeyword(t,r)}}(this),function(e){var t;e._opts.$data&&(t=bs,e.addMetaSchema(t,t.$id,!0));if(!1===e._opts.meta)return;var r=ms;e._opts.$data&&(r=Ts(r,Ds));e.addMetaSchema(r,Fs,!0),e._refs["http://json-schema.org/schema"]=Fs}(this),"object"==typeof e.meta&&this.addMetaSchema(e.meta),e.nullable&&this.addKeyword("nullable",{metaSchema:{type:"boolean"}}),function(e){var t=e._opts.schemas;if(!t)return;if(Array.isArray(t))e.addSchema(t);else for(var r in t)e.addSchema(t[r],r)}(this)}function qs(e,t){return t=Es.normalizeId(t),e._schemas[t]||e._refs[t]||e._fragments[t]}function Ls(e,t,r){for(var a in t){var s=t[a];s.meta||r&&!r.test(a)||(e._cache.del(s.cacheKey),delete t[a])}}function zs(e){return e.$id&&this.logger.warn("schema $id ignored",e.$id),e.id}function Zs(e){return e.id&&this.logger.warn("schema id ignored",e.id),e.$id}function Ms(e){if(e.$id&&e.id&&e.$id!=e.id)throw new Error("schema $id is different from id");return e.$id||e.id}function Us(e,t){if(e._schemas[t]||e._refs[t])throw new Error('schema with key or id "'+t+'" already exists')}function Vs(){}var Hs=Pr(Is);class Qs extends br{constructor(e,t){var r;super(t),this._clientInfo=e,this._cachedToolOutputValidators=new Map,this._capabilities=null!==(r=null==t?void 0:t.capabilities)&&void 0!==r?r:{},this._ajv=new Hs}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");var t,r;this._capabilities=(t=this._capabilities,r=e,Object.entries(r).reduce(((e,[t,r])=>(e[t]=r&&"object"==typeof r&&e[t]?{...e[t],...r}:r,e)),{...t}))}assertCapability(e,t){var r;if(!(null===(r=this._serverCapabilities)||void 0===r?void 0:r[e]))throw new Error(`Server does not support ${e} (required for ${t})`)}async connect(e,t){if(await super.connect(e),void 0===e.sessionId)try{const e=await this.request({method:"initialize",params:{protocolVersion:He,capabilities:this._capabilities,clientInfo:this._clientInfo}},yt,t);if(void 0===e)throw new Error(`Server sent invalid initialize result: ${e}`);if(!Qe.includes(e.protocolVersion))throw new Error(`Server's protocol version is not supported: ${e.protocolVersion}`);this._serverCapabilities=e.capabilities,this._serverVersion=e.serverInfo,this._instructions=e.instructions,await this.notification({method:"notifications/initialized"})}catch(e){throw this.close(),e}}getServerCapabilities(){return this._serverCapabilities}getServerVersion(){return this._serverVersion}getInstructions(){return this._instructions}assertCapabilityForMethod(e){var t,r,a,s,i;switch(e){case"logging/setLevel":if(!(null===(t=this._serverCapabilities)||void 0===t?void 0:t.logging))throw new Error(`Server does not support logging (required for ${e})`);break;case"prompts/get":case"prompts/list":if(!(null===(r=this._serverCapabilities)||void 0===r?void 0:r.prompts))throw new Error(`Server does not support prompts (required for ${e})`);break;case"resources/list":case"resources/templates/list":case"resources/read":case"resources/subscribe":case"resources/unsubscribe":if(!(null===(a=this._serverCapabilities)||void 0===a?void 0:a.resources))throw new Error(`Server does not support resources (required for ${e})`);if("resources/subscribe"===e&&!this._serverCapabilities.resources.subscribe)throw new Error(`Server does not support resource subscriptions (required for ${e})`);break;case"tools/call":case"tools/list":if(!(null===(s=this._serverCapabilities)||void 0===s?void 0:s.tools))throw new Error(`Server does not support tools (required for ${e})`);break;case"completion/complete":if(!(null===(i=this._serverCapabilities)||void 0===i?void 0:i.completions))throw new Error(`Server does not support completions (required for ${e})`)}}assertNotificationCapability(e){var t;if("notifications/roots/list_changed"===e)if(!(null===(t=this._capabilities.roots)||void 0===t?void 0:t.listChanged))throw new Error(`Client does not support roots list changed notifications (required for ${e})`)}assertRequestHandlerCapability(e){switch(e){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Client does not support sampling capability (required for ${e})`);break;case"roots/list":if(!this._capabilities.roots)throw new Error(`Client does not support roots capability (required for ${e})`)}}async ping(e){return this.request({method:"ping"},ut,e)}async complete(e,t){return this.request({method:"completion/complete",params:e},fr,t)}async setLoggingLevel(e,t){return this.request({method:"logging/setLevel",params:{level:e}},ut,t)}async getPrompt(e,t){return this.request({method:"prompts/get",params:e},Wt,t)}async listPrompts(e,t){return this.request({method:"prompts/list",params:e},Mt,t)}async listResources(e,t){return this.request({method:"resources/list",params:e},$t,t)}async listResourceTemplates(e,t){return this.request({method:"resources/templates/list",params:e},Ct,t)}async readResource(e,t){return this.request({method:"resources/read",params:e},Ft,t)}async subscribeResource(e,t){return this.request({method:"resources/subscribe",params:e},ut,t)}async unsubscribeResource(e,t){return this.request({method:"resources/unsubscribe",params:e},ut,t)}async callTool(e,t=tr,r){const a=await this.request({method:"tools/call",params:e},t,r),s=this.getToolOutputValidator(e.name);if(s){if(!a.structuredContent&&!a.isError)throw new wr(lt.InvalidRequest,`Tool ${e.name} has an output schema but did not return structured content`);if(a.structuredContent)try{if(!s(a.structuredContent))throw new wr(lt.InvalidParams,`Structured content does not match the tool's output schema: ${this._ajv.errorsText(s.errors)}`)}catch(e){if(e instanceof wr)throw e;throw new wr(lt.InvalidParams,`Failed to validate structured content: ${e instanceof Error?e.message:String(e)}`)}}return a}cacheToolOutputSchemas(e){this._cachedToolOutputValidators.clear();for(const t of e)if(t.outputSchema)try{const e=this._ajv.compile(t.outputSchema);this._cachedToolOutputValidators.set(t.name,e)}catch(e){console.warn(`Failed to compile output schema for tool ${t.name}: ${e}`)}}getToolOutputValidator(e){return this._cachedToolOutputValidators.get(e)}async listTools(e,t){const r=await this.request({method:"tools/list",params:e},er,t);return this.cacheToolOutputSchemas(r.tools),r}async sendRootsListChanged(){return this.notification({method:"notifications/roots/list_changed"})}}const Ks=qe({resource:Ce().url(),authorization_servers:Ne(Ce().url()).optional(),jwks_uri:Ce().url().optional(),scopes_supported:Ne(Ce()).optional(),bearer_methods_supported:Ne(Ce()).optional(),resource_signing_alg_values_supported:Ne(Ce()).optional(),resource_name:Ce().optional(),resource_documentation:Ce().optional(),resource_policy_uri:Ce().url().optional(),resource_tos_uri:Ce().url().optional(),tls_client_certificate_bound_access_tokens:Fe().optional(),authorization_details_types_supported:Ne(Ce()).optional(),dpop_signing_alg_values_supported:Ne(Ce()).optional(),dpop_bound_access_tokens_required:Fe().optional()}).passthrough(),Bs=qe({issuer:Ce(),authorization_endpoint:Ce(),token_endpoint:Ce(),registration_endpoint:Ce().optional(),scopes_supported:Ne(Ce()).optional(),response_types_supported:Ne(Ce()),response_modes_supported:Ne(Ce()).optional(),grant_types_supported:Ne(Ce()).optional(),token_endpoint_auth_methods_supported:Ne(Ce()).optional(),token_endpoint_auth_signing_alg_values_supported:Ne(Ce()).optional(),service_documentation:Ce().optional(),revocation_endpoint:Ce().optional(),revocation_endpoint_auth_methods_supported:Ne(Ce()).optional(),revocation_endpoint_auth_signing_alg_values_supported:Ne(Ce()).optional(),introspection_endpoint:Ce().optional(),introspection_endpoint_auth_methods_supported:Ne(Ce()).optional(),introspection_endpoint_auth_signing_alg_values_supported:Ne(Ce()).optional(),code_challenge_methods_supported:Ne(Ce()).optional()}).passthrough(),Ws=qe({access_token:Ce(),token_type:Ce(),expires_in:je().optional(),scope:Ce().optional(),refresh_token:Ce().optional()}).strip();qe({error:Ce(),error_description:Ce().optional(),error_uri:Ce().optional()});const Js=qe({redirect_uris:Ne(Ce()).refine((e=>e.every((e=>URL.canParse(e)))),{message:"redirect_uris must contain valid URLs"}),token_endpoint_auth_method:Ce().optional(),grant_types:Ne(Ce()).optional(),response_types:Ne(Ce()).optional(),client_name:Ce().optional(),client_uri:Ce().optional(),logo_uri:Ce().optional(),scope:Ce().optional(),contacts:Ne(Ce()).optional(),tos_uri:Ce().optional(),policy_uri:Ce().optional(),jwks_uri:Ce().optional(),jwks:Ae().optional(),software_id:Ce().optional(),software_version:Ce().optional()}).strip(),Gs=qe({client_id:Ce(),client_secret:Ce().optional(),client_id_issued_at:je().optional(),client_secret_expires_at:je().optional()}).strip(),Ys=Js.merge(Gs);qe({error:Ce(),error_description:Ce().optional()}).strip(),qe({token:Ce(),token_type_hint:Ce().optional()}).strip();class Xs extends Error{constructor(e){super(null!=e?e:"Unauthorized")}}async function ei(e,{serverUrl:r,authorizationCode:a,scope:s,resourceMetadataUrl:i}){let o=r;try{const e=await async function(e,t){var r;let a,s;a=new URL("/.well-known/oauth-protected-resource",e);try{s=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(r=null==t?void 0:t.protocolVersion)&&void 0!==r?r:He}})}catch(e){if(!(e instanceof TypeError))throw e;s=await fetch(a)}if(404===s.status)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!s.ok)throw new Error(`HTTP ${s.status} trying to load well-known OAuth protected resource metadata.`);return Ks.parse(await s.json())}(i||r);e.authorization_servers&&e.authorization_servers.length>0&&(o=e.authorization_servers[0])}catch(e){console.warn("Could not load OAuth Protected Resource metadata, falling back to /.well-known/oauth-authorization-server",e)}const n=await async function(e,t){var r;const a=new URL("/.well-known/oauth-authorization-server",e);let s;try{s=await fetch(a,{headers:{"MCP-Protocol-Version":null!==(r=null==t?void 0:t.protocolVersion)&&void 0!==r?r:He}})}catch(e){if(!(e instanceof TypeError))throw e;s=await fetch(a)}if(404===s.status)return;if(!s.ok)throw new Error(`HTTP ${s.status} trying to load well-known OAuth metadata`);return Bs.parse(await s.json())}(o);let l=await Promise.resolve(e.clientInformation());if(!l){if(void 0!==a)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const t=await async function(e,{metadata:t,clientMetadata:r}){let a;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");a=new URL(t.registration_endpoint)}else a=new URL("/register",e);const s=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!s.ok)throw new Error(`Dynamic client registration failed: HTTP ${s.status}`);return Ys.parse(await s.json())}(o,{metadata:n,clientMetadata:e.clientMetadata});await e.saveClientInformation(t),l=t}if(void 0!==a){const t=await e.codeVerifier(),r=await async function(e,{metadata:t,clientInformation:r,authorizationCode:a,codeVerifier:s,redirectUri:i}){const o="authorization_code";let n;if(t){if(n=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(o))throw new Error(`Incompatible auth server: does not support grant type ${o}`)}else n=new URL("/token",e);const l=new URLSearchParams({grant_type:o,client_id:r.client_id,code:a,code_verifier:s,redirect_uri:String(i)});r.client_secret&&l.set("client_secret",r.client_secret);const c=await fetch(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:l});if(!c.ok)throw new Error(`Token exchange failed: HTTP ${c.status}`);return Ws.parse(await c.json())}(o,{metadata:n,clientInformation:l,authorizationCode:a,codeVerifier:t,redirectUri:e.redirectUrl});return await e.saveTokens(r),"AUTHORIZED"}const c=await e.tokens();if(null==c?void 0:c.refresh_token)try{const t=await async function(e,{metadata:t,clientInformation:r,refreshToken:a}){const s="refresh_token";let i;if(t){if(i=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(s))throw new Error(`Incompatible auth server: does not support grant type ${s}`)}else i=new URL("/token",e);const o=new URLSearchParams({grant_type:s,client_id:r.client_id,refresh_token:a});r.client_secret&&o.set("client_secret",r.client_secret);const n=await fetch(i,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o});if(!n.ok)throw new Error(`Token refresh failed: HTTP ${n.status}`);return Ws.parse({refresh_token:a,...await n.json()})}(o,{metadata:n,clientInformation:l,refreshToken:c.refresh_token});return await e.saveTokens(t),"AUTHORIZED"}catch(e){console.error("Could not refresh OAuth tokens:",e)}const d=e.state?await e.state():void 0,{authorizationUrl:u,codeVerifier:h}=await async function(e,{metadata:r,clientInformation:a,redirectUrl:s,scope:i,state:o}){const n="code",l="S256";let c;if(r){if(c=new URL(r.authorization_endpoint),!r.response_types_supported.includes(n))throw new Error(`Incompatible auth server: does not support response type ${n}`);if(!r.code_challenge_methods_supported||!r.code_challenge_methods_supported.includes(l))throw new Error(`Incompatible auth server: does not support code challenge method ${l}`)}else c=new URL("/authorize",e);const d=await t(),u=d.code_verifier,h=d.code_challenge;c.searchParams.set("response_type",n),c.searchParams.set("client_id",a.client_id),c.searchParams.set("code_challenge",h),c.searchParams.set("code_challenge_method",l),c.searchParams.set("redirect_uri",String(s)),o&&c.searchParams.set("state",o);i&&c.searchParams.set("scope",i);return{authorizationUrl:c,codeVerifier:u}}(o,{metadata:n,clientInformation:l,state:d,redirectUrl:e.redirectUrl,scope:s||e.clientMetadata.scope});return await e.saveCodeVerifier(h),await e.redirectToAuthorization(u),"REDIRECT"}class ti extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}}function ri(e){}function ai(e){if("function"==typeof e)throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=ri,onError:r=ri,onRetry:a=ri,onComment:s}=e;let i,o="",n=!0,l="",c="";function d(e){if(""===e)return l.length>0&&t({id:i,event:c||void 0,data:l.endsWith("\n")?l.slice(0,-1):l}),i=void 0,l="",void(c="");if(e.startsWith(":"))return void(s&&s(e.slice(e.startsWith(": ")?2:1)));const r=e.indexOf(":");if(-1===r)u(e,"",e);else{const t=e.slice(0,r),a=" "===e[r+1]?2:1;u(t,e.slice(r+a),e)}}function u(e,t,s){switch(e){case"event":c=t;break;case"data":l=`${l}${t}\n`;break;case"id":i=t.includes("\0")?void 0:t;break;case"retry":/^\d+$/.test(t)?a(parseInt(t,10)):r(new ti(`Invalid \`retry\` value: "${t}"`,{type:"invalid-retry",value:t,line:s}));break;default:r(new ti(`Unknown field "${e.length>20?`${e.slice(0,20)}…`:e}"`,{type:"unknown-field",field:e,value:t,line:s}))}}return{feed:function(e){const t=n?e.replace(/^\xEF\xBB\xBF/,""):e,[r,a]=function(e){const t=[];let r="",a=0;for(;a<e.length;){const s=e.indexOf("\r",a),i=e.indexOf("\n",a);let o=-1;if(-1!==s&&-1!==i?o=Math.min(s,i):-1!==s?o=s:-1!==i&&(o=i),-1===o){r=e.slice(a);break}{const r=e.slice(a,o);t.push(r),a=o+1,"\r"===e[a-1]&&"\n"===e[a]&&a++}}return[t,r]}(`${o}${t}`);for(const e of r)d(e);o=a,n=!1},reset:function(e={}){o&&e.consume&&d(o),n=!0,i=void 0,l="",c="",o=""}}}class si extends TransformStream{constructor({onError:e,onRetry:t,onComment:r}={}){let a;super({start(s){a=ai({onEvent:e=>{s.enqueue(e)},onError(t){"terminate"===e?s.error(t):"function"==typeof e&&e(t)},onRetry:t,onComment:r})},transform(e){a.feed(e)}})}}const ii={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2};class oi extends Error{constructor(e,t){super(`Streamable HTTP error: ${t}`),this.code=e}}class ni{constructor(e,t){var r;this._url=e,this._resourceMetadataUrl=void 0,this._requestInit=null==t?void 0:t.requestInit,this._authProvider=null==t?void 0:t.authProvider,this._sessionId=null==t?void 0:t.sessionId,this._reconnectionOptions=null!==(r=null==t?void 0:t.reconnectionOptions)&&void 0!==r?r:ii}async _authThenStart(){var e;if(!this._authProvider)throw new Xs("No auth provider");let t;try{t=await ei(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl})}catch(t){throw null===(e=this.onerror)||void 0===e||e.call(this,t),t}if("AUTHORIZED"!==t)throw new Xs;return await this._startOrAuthSse({resumptionToken:void 0})}async _commonHeaders(){var e;const t={};if(this._authProvider){const e=await this._authProvider.tokens();e&&(t.Authorization=`Bearer ${e.access_token}`)}return this._sessionId&&(t["mcp-session-id"]=this._sessionId),new Headers({...t,...null===(e=this._requestInit)||void 0===e?void 0:e.headers})}async _startOrAuthSse(e){var t,r;const{resumptionToken:a}=e;try{const r=await this._commonHeaders();r.set("Accept","text/event-stream"),a&&r.set("last-event-id",a);const s=await fetch(this._url,{method:"GET",headers:r,signal:null===(t=this._abortController)||void 0===t?void 0:t.signal});if(!s.ok){if(401===s.status&&this._authProvider)return await this._authThenStart();if(405===s.status)return;throw new oi(s.status,`Failed to open SSE stream: ${s.statusText}`)}this._handleSseStream(s.body,e)}catch(e){throw null===(r=this.onerror)||void 0===r||r.call(this,e),e}}_getNextReconnectionDelay(e){const t=this._reconnectionOptions.initialReconnectionDelay,r=this._reconnectionOptions.reconnectionDelayGrowFactor,a=this._reconnectionOptions.maxReconnectionDelay;return Math.min(t*Math.pow(r,e),a)}_scheduleReconnection(e,t=0){var r;const a=this._reconnectionOptions.maxRetries;if(a>0&&t>=a)return void(null===(r=this.onerror)||void 0===r||r.call(this,new Error(`Maximum reconnection attempts (${a}) exceeded.`)));const s=this._getNextReconnectionDelay(t);setTimeout((()=>{this._startOrAuthSse(e).catch((r=>{var a;null===(a=this.onerror)||void 0===a||a.call(this,new Error(`Failed to reconnect SSE stream: ${r instanceof Error?r.message:String(r)}`)),this._scheduleReconnection(e,t+1)}))}),s)}_handleSseStream(e,t){if(!e)return;const{onresumptiontoken:r,replayMessageId:a}=t;let s;(async()=>{var t,i,o,n;try{const o=e.pipeThrough(new TextDecoderStream).pipeThrough(new si).getReader();for(;;){const{value:e,done:n}=await o.read();if(n)break;if(e.id&&(s=e.id,null==r||r(e.id)),!e.event||"message"===e.event)try{const r=dt.parse(JSON.parse(e.data));void 0!==a&&nt(r)&&(r.id=a),null===(t=this.onmessage)||void 0===t||t.call(this,r)}catch(e){null===(i=this.onerror)||void 0===i||i.call(this,e)}}}catch(e){if(null===(o=this.onerror)||void 0===o||o.call(this,new Error(`SSE stream disconnected: ${e}`)),this._abortController&&!this._abortController.signal.aborted&&void 0!==s)try{this._scheduleReconnection({resumptionToken:s,onresumptiontoken:r,replayMessageId:a},0)}catch(e){null===(n=this.onerror)||void 0===n||n.call(this,new Error(`Failed to reconnect: ${e instanceof Error?e.message:String(e)}`))}}})()}async start(){if(this._abortController)throw new Error("StreamableHTTPClientTransport already started! If using Client class, note that connect() calls start() automatically.");this._abortController=new AbortController}async finishAuth(e){if(!this._authProvider)throw new Xs("No auth provider");if("AUTHORIZED"!==await ei(this._authProvider,{serverUrl:this._url,authorizationCode:e,resourceMetadataUrl:this._resourceMetadataUrl}))throw new Xs("Failed to authorize")}async close(){var e,t;null===(e=this._abortController)||void 0===e||e.abort(),null===(t=this.onclose)||void 0===t||t.call(this)}async send(e,t){var r,a,s,i;try{const{resumptionToken:s,onresumptiontoken:o}=t||{};if(s)return void this._startOrAuthSse({resumptionToken:s,replayMessageId:st(e)?e.id:void 0}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)}));const n=await this._commonHeaders();n.set("content-type","application/json"),n.set("accept","application/json, text/event-stream");const l={...this._requestInit,method:"POST",headers:n,body:JSON.stringify(e),signal:null===(r=this._abortController)||void 0===r?void 0:r.signal},c=await fetch(this._url,l),d=c.headers.get("mcp-session-id");if(d&&(this._sessionId=d),!c.ok){if(401===c.status&&this._authProvider){this._resourceMetadataUrl=function(e){const t=e.headers.get("WWW-Authenticate");if(!t)return;const[r,a]=t.split(" ");if("bearer"!==r.toLowerCase()||!a)return void console.log("Invalid WWW-Authenticate header format, expected 'Bearer'");const s=/resource_metadata="([^"]*)"/.exec(t);if(s)try{return new URL(s[1])}catch(e){return void console.log("Invalid resource metadata url: ",s[1])}}(c);if("AUTHORIZED"!==await ei(this._authProvider,{serverUrl:this._url,resourceMetadataUrl:this._resourceMetadataUrl}))throw new Xs;return this.send(e)}const t=await c.text().catch((()=>null));throw new Error(`Error POSTing to endpoint (HTTP ${c.status}): ${t}`)}if(202===c.status)return i=e,void(gt.safeParse(i).success&&this._startOrAuthSse({resumptionToken:void 0}).catch((e=>{var t;return null===(t=this.onerror)||void 0===t?void 0:t.call(this,e)})));const u=(Array.isArray(e)?e:[e]).filter((e=>"method"in e&&"id"in e&&void 0!==e.id)).length>0,h=c.headers.get("content-type");if(u)if(null==h?void 0:h.includes("text/event-stream"))this._handleSseStream(c.body,{onresumptiontoken:o});else{if(!(null==h?void 0:h.includes("application/json")))throw new oi(-1,`Unexpected content type: ${h}`);{const e=await c.json(),t=Array.isArray(e)?e.map((e=>dt.parse(e))):[dt.parse(e)];for(const e of t)null===(a=this.onmessage)||void 0===a||a.call(this,e)}}}catch(e){throw null===(s=this.onerror)||void 0===s||s.call(this,e),e}}get sessionId(){return this._sessionId}async terminateSession(){var e,t;if(this._sessionId)try{const t=await this._commonHeaders(),r={...this._requestInit,method:"DELETE",headers:t,signal:null===(e=this._abortController)||void 0===e?void 0:e.signal},a=await fetch(this._url,r);if(!a.ok&&405!==a.status)throw new oi(a.status,`Failed to terminate session: ${a.statusText}`);this._sessionId=void 0}catch(e){throw null===(t=this.onerror)||void 0===t||t.call(this,e),e}}}class li{static async init(e){if(!(null==e?void 0:e.apiKey))throw new Error("MboaAI-SDK: apiKey is required");if(li.ready)return;const{apiKey:t,mcpUrl:r="https://api.filparty.com:8001/mcp",name:a="MboaAI-SDK",version:s="1.0.0",defaultType:i="standard"}=e,o=new ni(new URL(r),{requestInit:{headers:{"x-api-key":t}}}),n=new Qs({name:a,version:s});await n.connect(o),li.client=n,li.apiKey=t,li.defaultType=i,li.ready=!0}static async translate(e,t,r){var a,s;if(!li.ready)throw new Error("MboaAI-SDK: call init() first");const i=`Translate "${e}" into ${t} for ${null!=r?r:li.defaultType}`;try{const t=await li.client.callTool({name:"run_translate",arguments:{message:i,api_key:li.apiKey}}),r=null==t?void 0:t.content,o=String(null!==(s=null===(a=null==r?void 0:r[0])||void 0===a?void 0:a.text)&&void 0!==s?s:"");if((e=>{const t=e.trim().charAt(0);return"{"===t||"["===t})(o))try{const t=JSON.parse(o);return t.reply||t.text||e}catch(e){}return o||e}catch(t){return console.error("[MboaAI-SDK] translate error → returning source",t),e}}}li.ready=!1,li.defaultType="standard",li.apiKey="","undefined"!=typeof window&&(window.MboaAI=window.MboaAI||{},window.MboaAI.T=li),e.T=li,e.default=li,Object.defineProperty(e,"__esModule",{value:!0})}));