@mcp-b/global 1.1.3-beta.0 → 1.1.3-beta.2

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,8 +1,8 @@
1
- var WebMCP=(function(e){var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=(e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),u;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(u||={});var d;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(d||={});let f=u.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),p=e=>{switch(typeof e){case`undefined`:return f.undefined;case`string`:return f.string;case`number`:return Number.isNaN(e)?f.nan:f.number;case`boolean`:return f.boolean;case`function`:return f.function;case`bigint`:return f.bigint;case`symbol`:return f.symbol;case`object`:return Array.isArray(e)?f.array:e===null?f.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?f.promise:typeof Map<`u`&&e instanceof Map?f.map:typeof Set<`u`&&e instanceof Set?f.set:typeof Date<`u`&&e instanceof Date?f.date:f.object;default:return f.unknown}},m=u.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`]);var h=class e 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]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,u.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};h.create=e=>new h(e);var g=(e,t)=>{let n;switch(e.code){case m.invalid_type:n=e.received===f.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,u.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${u.joinValues(e.keys,`, `)}`;break;case m.invalid_union:n=`Invalid input`;break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${u.joinValues(e.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${u.joinValues(e.options)}, received '${e.received}'`;break;case m.invalid_arguments:n=`Invalid function arguments`;break;case m.invalid_return_type:n=`Invalid function return type`;break;case m.invalid_date:n=`Invalid date`;break;case m.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:u.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case m.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`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 m.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case m.custom:n=`Invalid input`;break;case m.invalid_intersection_types:n=`Intersection results could not be merged`;break;case m.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case m.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,u.assertNever(e)}return{message:n}};let _=g;function v(){return _}let y=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function b(e,t){let n=v(),r=y({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===g?void 0:g].filter(e=>!!e)});e.common.issues.push(r)}var x=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return S;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return S;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};let S=Object.freeze({status:`aborted`}),C=e=>({status:`dirty`,value:e}),w=e=>({status:`valid`,value:e}),T=e=>e.status===`aborted`,E=e=>e.status===`dirty`,D=e=>e.status===`valid`,O=e=>typeof Promise<`u`&&e instanceof Promise;var k;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(k||={});var A=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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}};let j=(e,t)=>{if(D(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new h(e.common.issues),this._error}}};function M(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var N=class{get description(){return this._def.description}_getType(e){return p(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:p(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new x,ctx:{common:e.parent.common,data:e.data,parsedType:p(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(O(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p(e)};return j(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return D(n)?{value:n.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=>D(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p(e)},r=this._parse({data:e,path:n.path,parent:n});return j(n,await(O(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:m.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Ge({schema:this,typeName:W.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 Ke.create(this,this._def)}nullable(){return qe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ee.create(this)}promise(){return We.create(this,this._def)}or(e){return ke.create([this,e],this._def)}and(e){return Ne.create(this,e,this._def)}transform(e){return new Ge({...M(this._def),schema:this,typeName:W.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Je({...M(this._def),innerType:this,defaultValue:t,typeName:W.ZodDefault})}brand(){return new Ze({typeName:W.ZodBranded,type:this,...M(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Ye({...M(this._def),innerType:this,catchValue:t,typeName:W.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Qe.create(this,e)}readonly(){return $e.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let P=/^c[^\s-]{8,}$/i,F=/^[0-9a-z]+$/,ee=/^[0-9A-HJKMNP-TV-Z]{26}$/i,I=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,L=/^[a-z0-9_-]{21}$/i,R=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,z=/^[-+]?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)?)??$/,te=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ne,re=/^(?:(?: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])$/,ie=/^(?:(?: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])$/,B=/^(([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]))$/,ae=/^(([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])$/,oe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,V=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,H=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,se=RegExp(`^${H}$`);function ce(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function le(e){return RegExp(`^${ce(e)}$`)}function ue(e){let t=`${H}T${ce(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function U(e,t){return!!((t===`v4`||!t)&&re.test(e)||(t===`v6`||!t)&&B.test(e))}function de(e,t){if(!R.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function fe(e,t){return!!((t===`v4`||!t)&&ie.test(e)||(t===`v6`||!t)&&ae.test(e))}var pe=class e extends N{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.string,received:t.parsedType}),S}let t=new x,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),b(n,{code:m.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),b(n,{code:m.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?b(n,{code:m.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&b(n,{code:m.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)te.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`email`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)ne||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),ne.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`emoji`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)I.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`uuid`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)L.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`nanoid`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)P.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`cuid`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)F.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`cuid2`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)ee.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`ulid`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),b(n,{validation:`url`,code:m.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`regex`,code:m.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),b(n,{code:m.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),b(n,{code:m.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),b(n,{code:m.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?ue(r).test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{code:m.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?se.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{code:m.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?le(r).test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{code:m.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?z.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`duration`,code:m.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?U(e.data,r.version)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`ip`,code:m.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?de(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`jwt`,code:m.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?fe(e.data,r.version)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`cidr`,code:m.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?oe.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`base64`,code:m.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?V.test(e.data)||(n=this._getOrReturnCtx(e,n),b(n,{validation:`base64url`,code:m.invalid_string,message:r.message}),t.dirty()):u.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:m.invalid_string,...k.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...k.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...k.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...k.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...k.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...k.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...k.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...k.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...k.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...k.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...k.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...k.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...k.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...k.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...k.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...k.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...k.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...k.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...k.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...k.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...k.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...k.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...k.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...k.errToObj(t)})}nonempty(e){return this.min(1,k.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};pe.create=e=>new pe({checks:[],typeName:W.ZodString,coerce:e?.coerce??!1,...M(e)});function me(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var he=class e extends N{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.number,received:t.parsedType}),S}let t,n=new x;for(let r of this._def.checks)r.kind===`int`?u.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),b(t,{code:m.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:m.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:m.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?me(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),b(t,{code:m.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),b(t,{code:m.not_finite,message:r.message}),n.dirty()):u.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,k.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,k.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,k.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,k.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:k.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:k.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:k.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:k.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:k.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:k.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&u.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};he.create=e=>new he({checks:[],typeName:W.ZodNumber,coerce:e?.coerce||!1,...M(e)});var ge=class e extends N{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)!==f.bigint)return this._getInvalidInput(e);let t,n=new x;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:m.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),b(t,{code:m.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),b(t,{code:m.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):u.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.bigint,received:t.parsedType}),S}gte(e,t){return this.setLimit(`min`,e,!0,k.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,k.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,k.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,k.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:k.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:k.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:k.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:k.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:k.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:k.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};ge.create=e=>new ge({checks:[],typeName:W.ZodBigInt,coerce:e?.coerce??!1,...M(e)});var _e=class extends N{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.boolean,received:t.parsedType}),S}return w(e.data)}};_e.create=e=>new _e({typeName:W.ZodBoolean,coerce:e?.coerce||!1,...M(e)});var ve=class e extends N{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.date,received:t.parsedType}),S}if(Number.isNaN(e.data.getTime()))return b(this._getOrReturnCtx(e),{code:m.invalid_date}),S;let t=new x,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),b(n,{code:m.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),b(n,{code:m.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):u.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:k.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:k.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};ve.create=e=>new ve({checks:[],coerce:e?.coerce||!1,typeName:W.ZodDate,...M(e)});var ye=class extends N{_parse(e){if(this._getType(e)!==f.symbol){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.symbol,received:t.parsedType}),S}return w(e.data)}};ye.create=e=>new ye({typeName:W.ZodSymbol,...M(e)});var be=class extends N{_parse(e){if(this._getType(e)!==f.undefined){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.undefined,received:t.parsedType}),S}return w(e.data)}};be.create=e=>new be({typeName:W.ZodUndefined,...M(e)});var xe=class extends N{_parse(e){if(this._getType(e)!==f.null){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.null,received:t.parsedType}),S}return w(e.data)}};xe.create=e=>new xe({typeName:W.ZodNull,...M(e)});var Se=class extends N{constructor(){super(...arguments),this._any=!0}_parse(e){return w(e.data)}};Se.create=e=>new Se({typeName:W.ZodAny,...M(e)});var Ce=class extends N{constructor(){super(...arguments),this._unknown=!0}_parse(e){return w(e.data)}};Ce.create=e=>new Ce({typeName:W.ZodUnknown,...M(e)});var we=class extends N{_parse(e){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.never,received:t.parsedType}),S}};we.create=e=>new we({typeName:W.ZodNever,...M(e)});var Te=class extends N{_parse(e){if(this._getType(e)!==f.undefined){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.void,received:t.parsedType}),S}return w(e.data)}};Te.create=e=>new Te({typeName:W.ZodVoid,...M(e)});var Ee=class e extends N{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==f.array)return b(t,{code:m.invalid_type,expected:f.array,received:t.parsedType}),S;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(b(t,{code:e?m.too_big:m.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(b(t,{code:m.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(b(t,{code:m.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new A(t,e,t.path,n)))).then(e=>x.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new A(t,e,t.path,n)));return x.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:k.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:k.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:k.toString(n)}})}nonempty(e){return this.min(1,e)}};Ee.create=(e,t)=>new Ee({type:e,minLength:null,maxLength:null,exactLength:null,typeName:W.ZodArray,...M(t)});function De(e){if(e instanceof Oe){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Ke.create(De(r))}return new Oe({...e._def,shape:()=>t})}else if(e instanceof Ee)return new Ee({...e._def,type:De(e.element)});else if(e instanceof Ke)return Ke.create(De(e.unwrap()));else if(e instanceof qe)return qe.create(De(e.unwrap()));else if(e instanceof Pe)return Pe.create(e.items.map(e=>De(e)));else return e}var Oe=class e extends N{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:u.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==f.object){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.object,received:t.parsedType}),S}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof we&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new A(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof we){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(b(n,{code:m.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new A(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>x.mergeObjectSync(t,e)):x.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return k.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:k.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:W.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of u.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of u.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return De(this)}partial(t){let n={};for(let e of u.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of u.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ke;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Ve(u.objectKeys(this.shape))}};Oe.create=(e,t)=>new Oe({shape:()=>e,unknownKeys:`strip`,catchall:we.create(),typeName:W.ZodObject,...M(t)}),Oe.strictCreate=(e,t)=>new Oe({shape:()=>e,unknownKeys:`strict`,catchall:we.create(),typeName:W.ZodObject,...M(t)}),Oe.lazycreate=(e,t)=>new Oe({shape:e,unknownKeys:`strip`,catchall:we.create(),typeName:W.ZodObject,...M(t)});var ke=class extends N{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new h(e.ctx.common.issues));return b(t,{code:m.invalid_union,unionErrors:n}),S}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new h(e));return b(t,{code:m.invalid_union,unionErrors:i}),S}}get options(){return this._def.options}};ke.create=(e,t)=>new ke({options:e,typeName:W.ZodUnion,...M(t)});let Ae=e=>e instanceof ze?Ae(e.schema):e instanceof Ge?Ae(e.innerType()):e instanceof Be?[e.value]:e instanceof He?e.options:e instanceof Ue?u.objectValues(e.enum):e instanceof Je?Ae(e._def.innerType):e instanceof be?[void 0]:e instanceof xe?[null]:e instanceof Ke?[void 0,...Ae(e.unwrap())]:e instanceof qe?[null,...Ae(e.unwrap())]:e instanceof Ze||e instanceof $e?Ae(e.unwrap()):e instanceof Ye?Ae(e._def.innerType):[];var je=class e extends N{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return b(t,{code:m.invalid_type,expected:f.object,received:t.parsedType}),S;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);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}):(b(t,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),S)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Ae(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:W.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...M(r)})}};function Me(e,t){let n=p(e),r=p(t);if(e===t)return{valid:!0,data:e};if(n===f.object&&r===f.object){let n=u.objectKeys(t),r=u.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Me(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===f.array&&r===f.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Me(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===f.date&&r===f.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Ne=class extends N{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(T(e)||T(r))return S;let i=Me(e.value,r.value);return i.valid?((E(e)||E(r))&&t.dirty(),{status:t.value,value:i.data}):(b(n,{code:m.invalid_intersection_types}),S)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Ne.create=(e,t,n)=>new Ne({left:e,right:t,typeName:W.ZodIntersection,...M(n)});var Pe=class e extends N{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return b(n,{code:m.invalid_type,expected:f.array,received:n.parsedType}),S;if(n.data.length<this._def.items.length)return b(n,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),S;!this._def.rest&&n.data.length>this._def.items.length&&(b(n,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new A(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>x.mergeArray(t,e)):x.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Pe.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Pe({items:e,typeName:W.ZodTuple,rest:null,...M(t)})};var Fe=class e extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return b(n,{code:m.invalid_type,expected:f.object,received:n.parsedType}),S;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new A(n,e,n.path,e)),value:a._parse(new A(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?x.mergeObjectAsync(t,r):x.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof N?new e({keyType:t,valueType:n,typeName:W.ZodRecord,...M(r)}):new e({keyType:pe.create(),valueType:t,typeName:W.ZodRecord,...M(n)})}},Ie=class extends N{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return b(n,{code:m.invalid_type,expected:f.map,received:n.parsedType}),S;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new A(n,e,n.path,[a,`key`])),value:i._parse(new A(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return S;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return S;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Ie.create=(e,t,n)=>new Ie({valueType:t,keyType:e,typeName:W.ZodMap,...M(n)});var Le=class e extends N{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return b(n,{code:m.invalid_type,expected:f.set,received:n.parsedType}),S;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(b(n,{code:m.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(b(n,{code:m.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return S;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new A(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:k.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:k.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Le.create=(e,t)=>new Le({valueType:e,minSize:null,maxSize:null,typeName:W.ZodSet,...M(t)});var Re=class e extends N{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return b(t,{code:m.invalid_type,expected:f.function,received:t.parsedType}),S;function n(e,n){return y({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,v(),g].filter(e=>!!e),issueData:{code:m.invalid_arguments,argumentsError:n}})}function r(e,n){return y({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,v(),g].filter(e=>!!e),issueData:{code:m.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof We){let e=this;return w(async function(...t){let o=new h([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return w(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new h([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new h([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Pe.create(t).rest(Ce.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Pe.create([]).rest(Ce.create()),returns:n||Ce.create(),typeName:W.ZodFunction,...M(r)})}},ze=class extends N{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ze.create=(e,t)=>new ze({getter:e,typeName:W.ZodLazy,...M(t)});var Be=class extends N{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return b(t,{received:t.data,code:m.invalid_literal,expected:this._def.value}),S}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Be.create=(e,t)=>new Be({value:e,typeName:W.ZodLiteral,...M(t)});function Ve(e,t){return new He({values:e,typeName:W.ZodEnum,...M(t)})}var He=class e extends N{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return b(t,{expected:u.joinValues(n),received:t.parsedType,code:m.invalid_type}),S}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return b(t,{received:t.data,code:m.invalid_enum_value,options:n}),S}return w(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};He.create=Ve;var Ue=class extends N{_parse(e){let t=u.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let e=u.objectValues(t);return b(n,{expected:u.joinValues(e),received:n.parsedType,code:m.invalid_type}),S}if(this._cache||=new Set(u.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=u.objectValues(t);return b(n,{received:n.data,code:m.invalid_enum_value,options:e}),S}return w(e.data)}get enum(){return this._def.values}};Ue.create=(e,t)=>new Ue({values:e,typeName:W.ZodNativeEnum,...M(t)});var We=class extends N{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==f.promise&&t.common.async===!1?(b(t,{code:m.invalid_type,expected:f.promise,received:t.parsedType}),S):w((t.parsedType===f.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};We.create=(e,t)=>new We({type:e,typeName:W.ZodPromise,...M(t)});var Ge=class extends N{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===W.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{b(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return S;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?S:r.status===`dirty`||t.value===`dirty`?C(r.value):r});{if(t.value===`aborted`)return S;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?S:r.status===`dirty`||t.value===`dirty`?C(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?S:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?S:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!D(e))return S;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>D(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):S);u.assertNever(r)}};Ge.create=(e,t,n)=>new Ge({schema:e,typeName:W.ZodEffects,effect:t,...M(n)}),Ge.createWithPreprocess=(e,t,n)=>new Ge({schema:t,effect:{type:`preprocess`,transform:e},typeName:W.ZodEffects,...M(n)});var Ke=class extends N{_parse(e){return this._getType(e)===f.undefined?w(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ke.create=(e,t)=>new Ke({innerType:e,typeName:W.ZodOptional,...M(t)});var qe=class extends N{_parse(e){return this._getType(e)===f.null?w(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};qe.create=(e,t)=>new qe({innerType:e,typeName:W.ZodNullable,...M(t)});var Je=class extends N{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Je.create=(e,t)=>new Je({innerType:e,typeName:W.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...M(t)});var Ye=class extends N{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return O(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new h(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new h(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Ye.create=(e,t)=>new Ye({innerType:e,typeName:W.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...M(t)});var Xe=class extends N{_parse(e){if(this._getType(e)!==f.nan){let t=this._getOrReturnCtx(e);return b(t,{code:m.invalid_type,expected:f.nan,received:t.parsedType}),S}return{status:`valid`,value:e.data}}};Xe.create=e=>new Xe({typeName:W.ZodNaN,...M(e)});var Ze=class extends N{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Qe=class e extends N{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?S:e.status===`dirty`?(t.dirty(),C(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?S:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:W.ZodPipeline})}},$e=class extends N{_parse(e){let t=this._def.innerType._parse(e),n=e=>(D(e)&&(e.value=Object.freeze(e.value)),e);return O(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};$e.create=(e,t)=>new $e({innerType:e,typeName:W.ZodReadonly,...M(t)}),Oe.lazycreate;var W;(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`})(W||={});let G=pe.create,K=he.create;Xe.create,ge.create;let q=_e.create;ve.create,ye.create,be.create;let et=xe.create,tt=Se.create,nt=Ce.create,rt=we.create;Te.create;let J=Ee.create,Y=Oe.create;Oe.strictCreate;let X=ke.create,it=je.create,at=Ne.create,ot=Pe.create,st=Fe.create;Ie.create,Le.create,Re.create,ze.create;let Z=Be.create,ct=He.create;Ue.create,We.create,Ge.create;let Q=Ke.create;qe.create,Ge.createWithPreprocess,Qe.create;let lt=X([G(),K().int()]),ut=G(),dt=Y({_meta:Q(Y({progressToken:Q(lt)}).passthrough())}).passthrough(),ft=Y({method:G(),params:Q(dt)}),pt=Y({_meta:Q(Y({}).passthrough())}).passthrough(),mt=Y({method:G(),params:Q(pt)}),ht=Y({_meta:Q(Y({}).passthrough())}).passthrough(),gt=X([G(),K().int()]),_t=Y({jsonrpc:Z(`2.0`),id:gt}).merge(ft).strict(),vt=Y({jsonrpc:Z(`2.0`)}).merge(mt).strict(),yt=Y({jsonrpc:Z(`2.0`),id:gt,result:ht}).strict();var bt;(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`})(bt||={});let xt=X([_t,vt,yt,Y({jsonrpc:Z(`2.0`),id:gt,error:Y({code:K().int(),message:G(),data:Q(nt())})}).strict()]),St=ht.strict(),Ct=mt.extend({method:Z(`notifications/cancelled`),params:pt.extend({requestId:gt,reason:G().optional()})}),wt=Y({name:G(),title:Q(G())}).passthrough(),Tt=wt.extend({version:G()}),Et=Y({experimental:Q(Y({}).passthrough()),sampling:Q(Y({}).passthrough()),elicitation:Q(Y({}).passthrough()),roots:Q(Y({listChanged:Q(q())}).passthrough())}).passthrough(),Dt=ft.extend({method:Z(`initialize`),params:dt.extend({protocolVersion:G(),capabilities:Et,clientInfo:Tt})}),Ot=Y({experimental:Q(Y({}).passthrough()),logging:Q(Y({}).passthrough()),completions:Q(Y({}).passthrough()),prompts:Q(Y({listChanged:Q(q())}).passthrough()),resources:Q(Y({subscribe:Q(q()),listChanged:Q(q())}).passthrough()),tools:Q(Y({listChanged:Q(q())}).passthrough())}).passthrough(),kt=ht.extend({protocolVersion:G(),capabilities:Ot,serverInfo:Tt,instructions:Q(G())}),At=mt.extend({method:Z(`notifications/initialized`)}),jt=ft.extend({method:Z(`ping`)}),Mt=Y({progress:K(),total:Q(K()),message:Q(G())}).passthrough(),Nt=mt.extend({method:Z(`notifications/progress`),params:pt.merge(Mt).extend({progressToken:lt})}),Pt=ft.extend({params:dt.extend({cursor:Q(ut)}).optional()}),Ft=ht.extend({nextCursor:Q(ut)}),It=Y({uri:G(),mimeType:Q(G()),_meta:Q(Y({}).passthrough())}).passthrough(),Lt=It.extend({text:G()}),Rt=G().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),zt=It.extend({blob:Rt}),Bt=wt.extend({uri:G(),description:Q(G()),mimeType:Q(G()),_meta:Q(Y({}).passthrough())}),Vt=wt.extend({uriTemplate:G(),description:Q(G()),mimeType:Q(G()),_meta:Q(Y({}).passthrough())}),Ht=Pt.extend({method:Z(`resources/list`)}),Ut=Ft.extend({resources:J(Bt)}),Wt=Pt.extend({method:Z(`resources/templates/list`)}),Gt=Ft.extend({resourceTemplates:J(Vt)}),Kt=ft.extend({method:Z(`resources/read`),params:dt.extend({uri:G()})}),qt=ht.extend({contents:J(X([Lt,zt]))}),Jt=mt.extend({method:Z(`notifications/resources/list_changed`)}),Yt=ft.extend({method:Z(`resources/subscribe`),params:dt.extend({uri:G()})}),Xt=ft.extend({method:Z(`resources/unsubscribe`),params:dt.extend({uri:G()})}),Zt=mt.extend({method:Z(`notifications/resources/updated`),params:pt.extend({uri:G()})}),Qt=Y({name:G(),description:Q(G()),required:Q(q())}).passthrough(),$t=wt.extend({description:Q(G()),arguments:Q(J(Qt)),_meta:Q(Y({}).passthrough())}),en=Pt.extend({method:Z(`prompts/list`)}),tn=Ft.extend({prompts:J($t)}),nn=ft.extend({method:Z(`prompts/get`),params:dt.extend({name:G(),arguments:Q(st(G()))})}),rn=Y({type:Z(`text`),text:G(),_meta:Q(Y({}).passthrough())}).passthrough(),an=Y({type:Z(`image`),data:Rt,mimeType:G(),_meta:Q(Y({}).passthrough())}).passthrough(),on=Y({type:Z(`audio`),data:Rt,mimeType:G(),_meta:Q(Y({}).passthrough())}).passthrough(),sn=Y({type:Z(`resource`),resource:X([Lt,zt]),_meta:Q(Y({}).passthrough())}).passthrough(),cn=X([rn,an,on,Bt.extend({type:Z(`resource_link`)}),sn]),ln=Y({role:ct([`user`,`assistant`]),content:cn}).passthrough(),un=ht.extend({description:Q(G()),messages:J(ln)}),dn=mt.extend({method:Z(`notifications/prompts/list_changed`)}),fn=Y({title:Q(G()),readOnlyHint:Q(q()),destructiveHint:Q(q()),idempotentHint:Q(q()),openWorldHint:Q(q())}).passthrough(),pn=wt.extend({description:Q(G()),inputSchema:Y({type:Z(`object`),properties:Q(Y({}).passthrough()),required:Q(J(G()))}).passthrough(),outputSchema:Q(Y({type:Z(`object`),properties:Q(Y({}).passthrough()),required:Q(J(G()))}).passthrough()),annotations:Q(fn),_meta:Q(Y({}).passthrough())}),mn=Pt.extend({method:Z(`tools/list`)}),hn=Ft.extend({tools:J(pn)}),gn=ht.extend({content:J(cn).default([]),structuredContent:Y({}).passthrough().optional(),isError:Q(q())});gn.or(ht.extend({toolResult:nt()}));let _n=ft.extend({method:Z(`tools/call`),params:dt.extend({name:G(),arguments:Q(st(nt()))})}),vn=mt.extend({method:Z(`notifications/tools/list_changed`)}),yn=ct([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),bn=ft.extend({method:Z(`logging/setLevel`),params:dt.extend({level:yn})}),xn=mt.extend({method:Z(`notifications/message`),params:pt.extend({level:yn,logger:Q(G()),data:nt()})}),Sn=Y({hints:Q(J(Y({name:G().optional()}).passthrough())),costPriority:Q(K().min(0).max(1)),speedPriority:Q(K().min(0).max(1)),intelligencePriority:Q(K().min(0).max(1))}).passthrough(),Cn=Y({role:ct([`user`,`assistant`]),content:X([rn,an,on])}).passthrough(),wn=ft.extend({method:Z(`sampling/createMessage`),params:dt.extend({messages:J(Cn),systemPrompt:Q(G()),includeContext:Q(ct([`none`,`thisServer`,`allServers`])),temperature:Q(K()),maxTokens:K().int(),stopSequences:Q(J(G())),metadata:Q(Y({}).passthrough()),modelPreferences:Q(Sn)})}),Tn=ht.extend({model:G(),stopReason:Q(ct([`endTurn`,`stopSequence`,`maxTokens`]).or(G())),role:ct([`user`,`assistant`]),content:it(`type`,[rn,an,on])}),En=X([Y({type:Z(`boolean`),title:Q(G()),description:Q(G()),default:Q(q())}).passthrough(),Y({type:Z(`string`),title:Q(G()),description:Q(G()),minLength:Q(K()),maxLength:Q(K()),format:Q(ct([`email`,`uri`,`date`,`date-time`]))}).passthrough(),Y({type:ct([`number`,`integer`]),title:Q(G()),description:Q(G()),minimum:Q(K()),maximum:Q(K())}).passthrough(),Y({type:Z(`string`),title:Q(G()),description:Q(G()),enum:J(G()),enumNames:Q(J(G()))}).passthrough()]),Dn=ft.extend({method:Z(`elicitation/create`),params:dt.extend({message:G(),requestedSchema:Y({type:Z(`object`),properties:st(G(),En),required:Q(J(G()))}).passthrough()})}),On=ht.extend({action:ct([`accept`,`decline`,`cancel`]),content:Q(st(G(),nt()))}),kn=Y({type:Z(`ref/resource`),uri:G()}).passthrough(),An=Y({type:Z(`ref/prompt`),name:G()}).passthrough(),jn=ft.extend({method:Z(`completion/complete`),params:dt.extend({ref:X([An,kn]),argument:Y({name:G(),value:G()}).passthrough(),context:Q(Y({arguments:Q(st(G(),G()))}))})}),Mn=ht.extend({completion:Y({values:J(G()).max(100),total:Q(K().int()),hasMore:Q(q())}).passthrough()}),Nn=Y({uri:G().startsWith(`file://`),name:Q(G()),_meta:Q(Y({}).passthrough())}).passthrough(),Pn=ft.extend({method:Z(`roots/list`)}),Fn=ht.extend({roots:J(Nn)}),In=mt.extend({method:Z(`notifications/roots/list_changed`)});X([jt,Dt,jn,bn,nn,en,Ht,Wt,Kt,Yt,Xt,_n,mn]),X([Ct,Nt,At,In]),X([St,Tn,On,Fn]),X([jt,wn,Dn,Pn]),X([Ct,Nt,xn,Zt,Jt,vn,dn]),X([St,kt,Mn,un,tn,Ut,Gt,qt,gn,hn]),function(e){return e.START=`start`,e.STARTED=`started`,e.STOP=`stop`,e.STOPPED=`stopped`,e.PING=`ping`,e.PONG=`pong`,e.ERROR=`error`,e.LIST_TOOLS=`list_tools`,e.CALL_TOOL=`call_tool`,e.TOOL_LIST_UPDATED=`tool_list_updated`,e.TOOL_LIST_UPDATED_ACK=`tool_list_updated_ack`,e.PROCESS_DATA=`process_data`,e.SERVER_STARTED=`server_started`,e.SERVER_STOPPED=`server_stopped`,e.ERROR_FROM_NATIVE_HOST=`error_from_native_host`,e.CONNECT_NATIVE=`connectNative`,e.PING_NATIVE=`ping_native`,e.DISCONNECT_NATIVE=`disconnect_native`,e}({}),{NAME:`com.chromemcp.nativehost`,DEFAULT_PORT:12306}.NAME;var Ln=class{_started=!1;_allowedOrigins;_channelId;_messageHandler;_clientOrigin;_serverReadyTimeout;_serverReadyRetryMs;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins||e.allowedOrigins.length===0)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=e.allowedOrigins,this._channelId=e.channelId||`mcp-iframe`,this._serverReadyRetryMs=e.serverReadyRetryMs??250}async start(){if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(!this._allowedOrigins.includes(e.origin)&&!this._allowedOrigins.includes(`*`)||e.data?.channel!==this._channelId||e.data?.type!==`mcp`||e.data?.direction!==`client-to-server`)return;this._clientOrigin=e.origin;let t=e.data.payload;if(typeof t==`string`&&t===`mcp-check-ready`){this.broadcastServerReady();return}try{let e=xt.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,this.broadcastServerReady()}broadcastServerReady(){window.parent&&window.parent!==window?(window.parent.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},`*`),this.clearServerReadyRetry()):this.scheduleServerReadyRetry()}scheduleServerReadyRetry(){this._serverReadyTimeout||=setTimeout(()=>{this._serverReadyTimeout=void 0,this._started&&this.broadcastServerReady()},this._serverReadyRetryMs)}clearServerReadyRetry(){this._serverReadyTimeout&&=(clearTimeout(this._serverReadyTimeout),void 0)}async send(e){if(!this._started)throw Error(`Transport not started`);if(!this._clientOrigin){console.warn(`[IframeChildTransport] No client connected, message not sent`);return}window.parent&&window.parent!==window?window.parent.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:e},this._clientOrigin):console.warn(`[IframeChildTransport] Not running in an iframe, message not sent`)}async close(){this._messageHandler&&window.removeEventListener(`message`,this._messageHandler),this._started=!1,this._clientOrigin&&window.parent&&window.parent!==window&&window.parent.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-stopped`},`*`),this.clearServerReadyRetry(),this.onclose?.()}},Rn=class{_started=!1;_allowedOrigins;_channelId;_messageHandler;_clientOrigin;onclose;onerror;onmessage;constructor(e){if(!e.allowedOrigins||e.allowedOrigins.length===0)throw Error(`At least one allowed origin must be specified`);this._allowedOrigins=e.allowedOrigins,this._channelId=e.channelId||`mcp-default`}async start(){if(this._started)throw Error(`Transport already started`);this._messageHandler=e=>{if(!this._allowedOrigins.includes(e.origin)&&!this._allowedOrigins.includes(`*`)||e.data?.channel!==this._channelId||e.data?.type!==`mcp`||e.data?.direction!==`client-to-server`)return;this._clientOrigin=e.origin;let t=e.data.payload;if(typeof t==`string`&&t===`mcp-check-ready`){window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},this._clientOrigin);return}try{let e=xt.parse(t);this.onmessage?.(e)}catch(e){this.onerror?.(Error(`Invalid message: ${e instanceof Error?e.message:String(e)}`))}},window.addEventListener(`message`,this._messageHandler),this._started=!0,window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-ready`},`*`)}async send(e){if(!this._started)throw Error(`Transport not started`);let t=this._clientOrigin||`*`;this._clientOrigin||console.debug(`[TabServerTransport] Sending to unknown client origin (backwards compatibility mode)`),window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:e},t)}async close(){this._messageHandler&&window.removeEventListener(`message`,this._messageHandler),this._started=!1,window.postMessage({channel:this._channelId,type:`mcp`,direction:`server-to-client`,payload:`mcp-server-stopped`},`*`),this.onclose?.()}};let zn=`2025-06-18`,Bn=[zn,`2025-03-26`,`2024-11-05`,`2024-10-07`],Vn=X([G(),K().int()]),Hn=G(),Un=Y({_meta:Q(Y({progressToken:Q(Vn)}).passthrough())}).passthrough(),Wn=Y({method:G(),params:Q(Un)}),Gn=Y({_meta:Q(Y({}).passthrough())}).passthrough(),Kn=Y({method:G(),params:Q(Gn)}),qn=Y({_meta:Q(Y({}).passthrough())}).passthrough(),Jn=X([G(),K().int()]),Yn=Y({jsonrpc:Z(`2.0`),id:Jn}).merge(Wn).strict(),Xn=e=>Yn.safeParse(e).success,Zn=Y({jsonrpc:Z(`2.0`)}).merge(Kn).strict(),Qn=e=>Zn.safeParse(e).success,$n=Y({jsonrpc:Z(`2.0`),id:Jn,result:qn}).strict(),er=e=>$n.safeParse(e).success;var tr;(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`})(tr||={});let nr=Y({jsonrpc:Z(`2.0`),id:Jn,error:Y({code:K().int(),message:G(),data:Q(nt())})}).strict(),rr=e=>nr.safeParse(e).success;X([Yn,Zn,$n,nr]);let ir=qn.strict(),ar=Kn.extend({method:Z(`notifications/cancelled`),params:Gn.extend({requestId:Jn,reason:G().optional()})}),or=Y({name:G(),title:Q(G())}).passthrough(),sr=or.extend({version:G()}),cr=Y({experimental:Q(Y({}).passthrough()),sampling:Q(Y({}).passthrough()),elicitation:Q(Y({}).passthrough()),roots:Q(Y({listChanged:Q(q())}).passthrough())}).passthrough(),lr=Wn.extend({method:Z(`initialize`),params:Un.extend({protocolVersion:G(),capabilities:cr,clientInfo:sr})}),ur=Y({experimental:Q(Y({}).passthrough()),logging:Q(Y({}).passthrough()),completions:Q(Y({}).passthrough()),prompts:Q(Y({listChanged:Q(q())}).passthrough()),resources:Q(Y({subscribe:Q(q()),listChanged:Q(q())}).passthrough()),tools:Q(Y({listChanged:Q(q())}).passthrough())}).passthrough(),dr=qn.extend({protocolVersion:G(),capabilities:ur,serverInfo:sr,instructions:Q(G())}),fr=Kn.extend({method:Z(`notifications/initialized`)}),pr=Wn.extend({method:Z(`ping`)}),mr=Y({progress:K(),total:Q(K()),message:Q(G())}).passthrough(),hr=Kn.extend({method:Z(`notifications/progress`),params:Gn.merge(mr).extend({progressToken:Vn})}),gr=Wn.extend({params:Un.extend({cursor:Q(Hn)}).optional()}),_r=qn.extend({nextCursor:Q(Hn)}),vr=Y({uri:G(),mimeType:Q(G()),_meta:Q(Y({}).passthrough())}).passthrough(),yr=vr.extend({text:G()}),br=vr.extend({blob:G().base64()}),xr=or.extend({uri:G(),description:Q(G()),mimeType:Q(G()),_meta:Q(Y({}).passthrough())}),Sr=or.extend({uriTemplate:G(),description:Q(G()),mimeType:Q(G()),_meta:Q(Y({}).passthrough())}),Cr=gr.extend({method:Z(`resources/list`)}),wr=_r.extend({resources:J(xr)}),Tr=gr.extend({method:Z(`resources/templates/list`)}),Er=_r.extend({resourceTemplates:J(Sr)}),Dr=Wn.extend({method:Z(`resources/read`),params:Un.extend({uri:G()})}),Or=qn.extend({contents:J(X([yr,br]))}),kr=Kn.extend({method:Z(`notifications/resources/list_changed`)}),Ar=Wn.extend({method:Z(`resources/subscribe`),params:Un.extend({uri:G()})}),jr=Wn.extend({method:Z(`resources/unsubscribe`),params:Un.extend({uri:G()})}),Mr=Kn.extend({method:Z(`notifications/resources/updated`),params:Gn.extend({uri:G()})}),Nr=Y({name:G(),description:Q(G()),required:Q(q())}).passthrough(),Pr=or.extend({description:Q(G()),arguments:Q(J(Nr)),_meta:Q(Y({}).passthrough())}),Fr=gr.extend({method:Z(`prompts/list`)}),Ir=_r.extend({prompts:J(Pr)}),Lr=Wn.extend({method:Z(`prompts/get`),params:Un.extend({name:G(),arguments:Q(st(G()))})}),Rr=Y({type:Z(`text`),text:G(),_meta:Q(Y({}).passthrough())}).passthrough(),zr=Y({type:Z(`image`),data:G().base64(),mimeType:G(),_meta:Q(Y({}).passthrough())}).passthrough(),Br=Y({type:Z(`audio`),data:G().base64(),mimeType:G(),_meta:Q(Y({}).passthrough())}).passthrough(),Vr=Y({type:Z(`resource`),resource:X([yr,br]),_meta:Q(Y({}).passthrough())}).passthrough(),Hr=X([Rr,zr,Br,xr.extend({type:Z(`resource_link`)}),Vr]),Ur=Y({role:ct([`user`,`assistant`]),content:Hr}).passthrough(),Wr=qn.extend({description:Q(G()),messages:J(Ur)}),Gr=Kn.extend({method:Z(`notifications/prompts/list_changed`)}),Kr=Y({title:Q(G()),readOnlyHint:Q(q()),destructiveHint:Q(q()),idempotentHint:Q(q()),openWorldHint:Q(q())}).passthrough(),qr=or.extend({description:Q(G()),inputSchema:Y({type:Z(`object`),properties:Q(Y({}).passthrough()),required:Q(J(G()))}).passthrough(),outputSchema:Q(Y({type:Z(`object`),properties:Q(Y({}).passthrough()),required:Q(J(G()))}).passthrough()),annotations:Q(Kr),_meta:Q(Y({}).passthrough())}),Jr=gr.extend({method:Z(`tools/list`)}),Yr=_r.extend({tools:J(qr)}),Xr=qn.extend({content:J(Hr).default([]),structuredContent:Y({}).passthrough().optional(),isError:Q(q())});Xr.or(qn.extend({toolResult:nt()}));let Zr=Wn.extend({method:Z(`tools/call`),params:Un.extend({name:G(),arguments:Q(st(nt()))})}),Qr=Kn.extend({method:Z(`notifications/tools/list_changed`)}),$r=ct([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),ei=Wn.extend({method:Z(`logging/setLevel`),params:Un.extend({level:$r})}),ti=Kn.extend({method:Z(`notifications/message`),params:Gn.extend({level:$r,logger:Q(G()),data:nt()})}),ni=Y({hints:Q(J(Y({name:G().optional()}).passthrough())),costPriority:Q(K().min(0).max(1)),speedPriority:Q(K().min(0).max(1)),intelligencePriority:Q(K().min(0).max(1))}).passthrough(),ri=Y({role:ct([`user`,`assistant`]),content:X([Rr,zr,Br])}).passthrough(),ii=Wn.extend({method:Z(`sampling/createMessage`),params:Un.extend({messages:J(ri),systemPrompt:Q(G()),includeContext:Q(ct([`none`,`thisServer`,`allServers`])),temperature:Q(K()),maxTokens:K().int(),stopSequences:Q(J(G())),metadata:Q(Y({}).passthrough()),modelPreferences:Q(ni)})}),ai=qn.extend({model:G(),stopReason:Q(ct([`endTurn`,`stopSequence`,`maxTokens`]).or(G())),role:ct([`user`,`assistant`]),content:it(`type`,[Rr,zr,Br])}),oi=X([Y({type:Z(`boolean`),title:Q(G()),description:Q(G()),default:Q(q())}).passthrough(),Y({type:Z(`string`),title:Q(G()),description:Q(G()),minLength:Q(K()),maxLength:Q(K()),format:Q(ct([`email`,`uri`,`date`,`date-time`]))}).passthrough(),Y({type:ct([`number`,`integer`]),title:Q(G()),description:Q(G()),minimum:Q(K()),maximum:Q(K())}).passthrough(),Y({type:Z(`string`),title:Q(G()),description:Q(G()),enum:J(G()),enumNames:Q(J(G()))}).passthrough()]),si=Wn.extend({method:Z(`elicitation/create`),params:Un.extend({message:G(),requestedSchema:Y({type:Z(`object`),properties:st(G(),oi),required:Q(J(G()))}).passthrough()})}),ci=qn.extend({action:ct([`accept`,`decline`,`cancel`]),content:Q(st(G(),nt()))}),li=Y({type:Z(`ref/resource`),uri:G()}).passthrough(),ui=Y({type:Z(`ref/prompt`),name:G()}).passthrough(),di=Wn.extend({method:Z(`completion/complete`),params:Un.extend({ref:X([ui,li]),argument:Y({name:G(),value:G()}).passthrough(),context:Q(Y({arguments:Q(st(G(),G()))}))})}),fi=qn.extend({completion:Y({values:J(G()).max(100),total:Q(K().int()),hasMore:Q(q())}).passthrough()}),pi=Y({uri:G().startsWith(`file://`),name:Q(G()),_meta:Q(Y({}).passthrough())}).passthrough(),mi=Wn.extend({method:Z(`roots/list`)}),hi=qn.extend({roots:J(pi)}),gi=Kn.extend({method:Z(`notifications/roots/list_changed`)});X([pr,lr,di,ei,Lr,Fr,Cr,Tr,Dr,Ar,jr,Zr,Jr]),X([ar,hr,fr,gi]),X([ir,ai,ci,hi]),X([pr,ii,si,mi]),X([ar,hr,ti,Mr,kr,Qr,Gr]),X([ir,dr,fi,Wr,Ir,wr,Er,Or,Xr,Yr]);var _i=class extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}},vi=class{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(ar,e=>{this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}),this.setNotificationHandler(hr,e=>{this._onprogress(e)}),this.setRequestHandler(pr,e=>({}))}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),new _i(tr.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),er(e)||rr(e)?this._onresponse(e):Xn(e)?this._onrequest(e,t):Qn(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){var e;let t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,(e=this.onclose)==null||e.call(this);let n=new _i(tr.ConnectionClosed,`Connection closed`);for(let e of t.values())e(n)}_onerror(e){var t;(t=this.onerror)==null||t.call(this,e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){var n;let r=this._requestHandlers.get(e.method)??this.fallbackRequestHandler;if(r===void 0){(n=this._transport)==null||n.send({jsonrpc:`2.0`,id:e.id,error:{code:tr.MethodNotFound,message:`Method not found`}}).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let i=new AbortController;this._requestHandlerAbortControllers.set(e.id,i);let a={signal:i.signal,sessionId:this._transport?.sessionId,_meta:e.params?._meta,sendNotification:t=>this.notification(t,{relatedRequestId:e.id}),sendRequest:(t,n,r)=>this.request(t,n,{...r,relatedRequestId:e.id}),authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo};Promise.resolve().then(()=>r(e,a)).then(t=>{if(!i.signal.aborted)return this._transport?.send({result:t,jsonrpc:`2.0`,id:e.id})},t=>{if(!i.signal.aborted)return this._transport?.send({jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:tr.InternalError,message:t.message??`Internal error`}})}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._responseHandlers.get(t);if(n===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._progressHandlers.delete(t),this._cleanupTimeout(t),er(e)?n(e):n(new _i(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}=n??{};return new Promise((o,s)=>{var c,l;if(!this._transport){s(Error(`Not connected`));return}this._options?.enforceStrictCapabilities===!0&&this.assertCapabilityForMethod(e.method),(c=n?.signal)==null||c.throwIfAborted();let u=this._requestMessageId++,d={...e,jsonrpc:`2.0`,id:u};n?.onprogress&&(this._progressHandlers.set(u,n.onprogress),d.params={...e.params,_meta:{...e.params?._meta||{},progressToken:u}});let f=e=>{var t;this._responseHandlers.delete(u),this._progressHandlers.delete(u),this._cleanupTimeout(u),(t=this._transport)==null||t.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:u,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),s(e)};this._responseHandlers.set(u,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return s(e);try{o(t.parse(e.result))}catch(e){s(e)}}}),(l=n?.signal)==null||l.addEventListener(`abort`,()=>{f(n?.signal?.reason)});let p=n?.timeout??6e4;this._setupTimeout(u,p,n?.maxTotalTimeout,()=>f(new _i(tr.RequestTimeout,`Request timed out`,{timeout:p})),n?.resetTimeoutOnProgress??!1),this._transport.send(d,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(u),s(e)})})}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n={...e,jsonrpc:`2.0`};await this._transport.send(n,t)}setRequestHandler(e,t){let n=e.shape.method.value;this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>Promise.resolve(t(e.parse(n),r)))}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){this._notificationHandlers.set(e.shape.method.value,n=>Promise.resolve(t(e.parse(n))))}removeNotificationHandler(e){this._notificationHandlers.delete(e)}};function yi(e,t){return Object.entries(t).reduce((e,[t,n])=>(n&&typeof n==`object`?e[t]=e[t]?{...e[t],...n}:n:e[t]=n,e),{...e})}var bi=s(((e,t)=>{
2
- /** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
3
- (function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):r(n.URI=n.URI||{})})(e,(function(e){function t(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];if(t.length>1){t[0]=t[0].slice(0,-1);for(var r=t.length-1,i=1;i<r;++i)t[i]=t[i].slice(1,-1);return t[r]=t[r].slice(1),t.join(``)}else return t[0]}function n(e){return`(?:`+e+`)`}function r(e){return e===void 0?`undefined`:e===null?`null`:Object.prototype.toString.call(e).split(` `).pop().split(`]`).shift().toLowerCase()}function i(e){return e.toUpperCase()}function a(e){return e==null?[]:e instanceof Array?e:typeof e.length!=`number`||e.split||e.setInterval||e.call?[e]:Array.prototype.slice.call(e)}function o(e,t){var n=e;if(t)for(var r in t)n[r]=t[r];return n}function s(e){var r=`[A-Za-z]`,i=`[0-9]`,a=t(i,`[A-Fa-f]`),o=n(n(`%[EFef]`+a+`%`+a+a+`%`+a+a)+`|`+n(`%[89A-Fa-f]`+a+`%`+a+a)+`|`+n(`%`+a+a)),s=`[\\:\\/\\?\\#\\[\\]\\@]`,c=`[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]`,l=t(s,c),u=e?`[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]`:`[]`,d=e?`[\\uE000-\\uF8FF]`:`[]`,f=t(r,i,`[\\-\\.\\_\\~]`,u),p=n(r+t(r,i,`[\\+\\-\\.]`)+`*`),m=n(n(o+`|`+t(f,c,`[\\:]`))+`*`);n(n(`25[0-5]`)+`|`+n(`2[0-4]`+i)+`|`+n(`1`+i+i)+`|`+n(`[1-9]`+i)+`|`+i);var h=n(n(`25[0-5]`)+`|`+n(`2[0-4]`+i)+`|`+n(`1`+i+i)+`|`+n(`0?[1-9]`+i)+`|0?0?`+i),g=n(h+`\\.`+h+`\\.`+h+`\\.`+h),_=n(a+`{1,4}`),v=n(n(_+`\\:`+_)+`|`+g),y=n([n(n(_+`\\:`)+`{6}`+v),n(`\\:\\:`+n(_+`\\:`)+`{5}`+v),n(n(_)+`?\\:\\:`+n(_+`\\:`)+`{4}`+v),n(n(n(_+`\\:`)+`{0,1}`+_)+`?\\:\\:`+n(_+`\\:`)+`{3}`+v),n(n(n(_+`\\:`)+`{0,2}`+_)+`?\\:\\:`+n(_+`\\:`)+`{2}`+v),n(n(n(_+`\\:`)+`{0,3}`+_)+`?\\:\\:`+_+`\\:`+v),n(n(n(_+`\\:`)+`{0,4}`+_)+`?\\:\\:`+v),n(n(n(_+`\\:`)+`{0,5}`+_)+`?\\:\\:`+_),n(n(n(_+`\\:`)+`{0,6}`+_)+`?\\:\\:`)].join(`|`)),b=n(n(f+`|`+o)+`+`);n(y+`\\%25`+b);var x=n(y+n(`\\%25|\\%(?!`+a+`{2})`)+b),S=n(`[vV]`+a+`+\\.`+t(f,c,`[\\:]`)+`+`),C=n(`\\[`+n(x+`|`+y+`|`+S)+`\\]`),w=n(n(o+`|`+t(f,c))+`*`),T=n(C+`|`+g+`(?!`+w+`)|`+w),E=n(i+`*`),D=n(n(m+`@`)+`?`+T+n(`\\:`+E)+`?`),O=n(o+`|`+t(f,c,`[\\:\\@]`)),k=n(O+`*`),A=n(O+`+`),j=n(n(o+`|`+t(f,c,`[\\@]`))+`+`),M=n(n(`\\/`+k)+`*`),N=n(`\\/`+n(A+M)+`?`),P=n(j+M),F=n(A+M),ee=`(?!`+O+`)`;n(M+`|`+N+`|`+P+`|`+F+`|`+ee);var I=n(n(O+`|`+t(`[\\/\\?]`,d))+`*`),L=n(n(O+`|[\\/\\?]`)+`*`),R=n(n(`\\/\\/`+D+M)+`|`+N+`|`+F+`|`+ee),z=n(p+`\\:`+R+n(`\\?`+I)+`?`+n(`\\#`+L)+`?`),te=n(n(n(`\\/\\/`+D+M)+`|`+N+`|`+P+`|`+ee)+n(`\\?`+I)+`?`+n(`\\#`+L)+`?`);return n(z+`|`+te),n(p+`\\:`+R+n(`\\?`+I)+`?`),``+p+n(n(`\\/\\/(`+n(`(`+m+`)@`)+`?(`+T+`)`+n(`\\:(`+E+`)`)+`?)`)+`?(`+M+`|`+N+`|`+F+`|`+ee+`)`)+n(`\\?(`+I+`)`)+n(`\\#(`+L+`)`),``+n(n(`\\/\\/(`+n(`(`+m+`)@`)+`?(`+T+`)`+n(`\\:(`+E+`)`)+`?)`)+`?(`+M+`|`+N+`|`+P+`|`+ee+`)`)+n(`\\?(`+I+`)`)+n(`\\#(`+L+`)`),``+p+n(n(`\\/\\/(`+n(`(`+m+`)@`)+`?(`+T+`)`+n(`\\:(`+E+`)`)+`?)`)+`?(`+M+`|`+N+`|`+F+`|`+ee+`)`)+n(`\\?(`+I+`)`),``+n(`\\#(`+L+`)`),``+n(`(`+m+`)@`)+T+n(`\\:(`+E+`)`),{NOT_SCHEME:new RegExp(t(`[^]`,r,i,`[\\+\\-\\.]`),`g`),NOT_USERINFO:new RegExp(t(`[^\\%\\:]`,f,c),`g`),NOT_HOST:new RegExp(t(`[^\\%\\[\\]\\:]`,f,c),`g`),NOT_PATH:new RegExp(t(`[^\\%\\/\\:\\@]`,f,c),`g`),NOT_PATH_NOSCHEME:new RegExp(t(`[^\\%\\/\\@]`,f,c),`g`),NOT_QUERY:new RegExp(t(`[^\\%]`,f,c,`[\\:\\@\\/\\?]`,d),`g`),NOT_FRAGMENT:new RegExp(t(`[^\\%]`,f,c,`[\\:\\@\\/\\?]`),`g`),ESCAPE:new RegExp(t(`[^]`,f,c),`g`),UNRESERVED:new RegExp(f,`g`),OTHER_CHARS:new RegExp(t(`[^\\%]`,f,l),`g`),PCT_ENCODED:new RegExp(o,`g`),IPV4ADDRESS:RegExp(`^(`+g+`)$`),IPV6ADDRESS:RegExp(`^\\[?(`+y+`)`+n(n(`\\%25|\\%(?!`+a+`{2})`)+`(`+b+`)`)+`?\\]?$`)}}var c=s(!1),l=s(!0),u=function(){function e(e,t){var n=[],r=!0,i=!1,a=void 0;try{for(var o=e[Symbol.iterator](),s;!(r=(s=o.next()).done)&&(n.push(s.value),!(t&&n.length===t));r=!0);}catch(e){i=!0,a=e}finally{try{!r&&o.return&&o.return()}finally{if(i)throw a}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw TypeError(`Invalid attempt to destructure non-iterable instance`)}}(),d=function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}else return Array.from(e)},f=2147483647,p=36,m=1,h=26,g=38,_=700,v=72,y=128,b=`-`,x=/^xn--/,S=/[^\0-\x7E]/,C=/[\x2E\u3002\uFF0E\uFF61]/g,w={overflow:`Overflow: input needs wider integers to process`,"not-basic":`Illegal input >= 0x80 (not a basic code point)`,"invalid-input":`Invalid input`},T=p-m,E=Math.floor,D=String.fromCharCode;function O(e){throw RangeError(w[e])}function k(e,t){for(var n=[],r=e.length;r--;)n[r]=t(e[r]);return n}function A(e,t){var n=e.split(`@`),r=``;n.length>1&&(r=n[0]+`@`,e=n[1]),e=e.replace(C,`.`);var i=k(e.split(`.`),t).join(`.`);return r+i}function j(e){for(var t=[],n=0,r=e.length;n<r;){var i=e.charCodeAt(n++);if(i>=55296&&i<=56319&&n<r){var a=e.charCodeAt(n++);(a&64512)==56320?t.push(((i&1023)<<10)+(a&1023)+65536):(t.push(i),n--)}else t.push(i)}return t}var M=function(e){return String.fromCodePoint.apply(String,d(e))},N=function(e){return e-48<10?e-22:e-65<26?e-65:e-97<26?e-97:p},P=function(e,t){return e+22+75*(e<26)-((t!=0)<<5)},F=function(e,t,n){var r=0;for(e=n?E(e/_):e>>1,e+=E(e/t);e>T*h>>1;r+=p)e=E(e/T);return E(r+(T+1)*e/(e+g))},ee=function(e){var t=[],n=e.length,r=0,i=y,a=v,o=e.lastIndexOf(b);o<0&&(o=0);for(var s=0;s<o;++s)e.charCodeAt(s)>=128&&O(`not-basic`),t.push(e.charCodeAt(s));for(var c=o>0?o+1:0;c<n;){for(var l=r,u=1,d=p;;d+=p){c>=n&&O(`invalid-input`);var g=N(e.charCodeAt(c++));(g>=p||g>E((f-r)/u))&&O(`overflow`),r+=g*u;var _=d<=a?m:d>=a+h?h:d-a;if(g<_)break;var x=p-_;u>E(f/x)&&O(`overflow`),u*=x}var S=t.length+1;a=F(r-l,S,l==0),E(r/S)>f-i&&O(`overflow`),i+=E(r/S),r%=S,t.splice(r++,0,i)}return String.fromCodePoint.apply(String,t)},I=function(e){var t=[];e=j(e);var n=e.length,r=y,i=0,a=v,o=!0,s=!1,c=void 0;try{for(var l=e[Symbol.iterator](),u;!(o=(u=l.next()).done);o=!0){var d=u.value;d<128&&t.push(D(d))}}catch(e){s=!0,c=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw c}}var g=t.length,_=g;for(g&&t.push(b);_<n;){var x=f,S=!0,C=!1,w=void 0;try{for(var T=e[Symbol.iterator](),k;!(S=(k=T.next()).done);S=!0){var A=k.value;A>=r&&A<x&&(x=A)}}catch(e){C=!0,w=e}finally{try{!S&&T.return&&T.return()}finally{if(C)throw w}}var M=_+1;x-r>E((f-i)/M)&&O(`overflow`),i+=(x-r)*M,r=x;var N=!0,ee=!1,I=void 0;try{for(var L=e[Symbol.iterator](),R;!(N=(R=L.next()).done);N=!0){var z=R.value;if(z<r&&++i>f&&O(`overflow`),z==r){for(var te=i,ne=p;;ne+=p){var re=ne<=a?m:ne>=a+h?h:ne-a;if(te<re)break;var ie=te-re,B=p-re;t.push(D(P(re+ie%B,0))),te=E(ie/B)}t.push(D(P(te,0))),a=F(i,M,_==g),i=0,++_}}}catch(e){ee=!0,I=e}finally{try{!N&&L.return&&L.return()}finally{if(ee)throw I}}++i,++r}return t.join(``)},L={version:`2.1.0`,ucs2:{decode:j,encode:M},decode:ee,encode:I,toASCII:function(e){return A(e,function(e){return S.test(e)?`xn--`+I(e):e})},toUnicode:function(e){return A(e,function(e){return x.test(e)?ee(e.slice(4).toLowerCase()):e})}},R={};function z(e){var t=e.charCodeAt(0),n=void 0;return n=t<16?`%0`+t.toString(16).toUpperCase():t<128?`%`+t.toString(16).toUpperCase():t<2048?`%`+(t>>6|192).toString(16).toUpperCase()+`%`+(t&63|128).toString(16).toUpperCase():`%`+(t>>12|224).toString(16).toUpperCase()+`%`+(t>>6&63|128).toString(16).toUpperCase()+`%`+(t&63|128).toString(16).toUpperCase(),n}function te(e){for(var t=``,n=0,r=e.length;n<r;){var i=parseInt(e.substr(n+1,2),16);if(i<128)t+=String.fromCharCode(i),n+=3;else if(i>=194&&i<224){if(r-n>=6){var a=parseInt(e.substr(n+4,2),16);t+=String.fromCharCode((i&31)<<6|a&63)}else t+=e.substr(n,6);n+=6}else if(i>=224){if(r-n>=9){var o=parseInt(e.substr(n+4,2),16),s=parseInt(e.substr(n+7,2),16);t+=String.fromCharCode((i&15)<<12|(o&63)<<6|s&63)}else t+=e.substr(n,9);n+=9}else t+=e.substr(n,3),n+=3}return t}function ne(e,t){function n(e){var n=te(e);return n.match(t.UNRESERVED)?n:e}return e.scheme&&=String(e.scheme).replace(t.PCT_ENCODED,n).toLowerCase().replace(t.NOT_SCHEME,``),e.userinfo!==void 0&&(e.userinfo=String(e.userinfo).replace(t.PCT_ENCODED,n).replace(t.NOT_USERINFO,z).replace(t.PCT_ENCODED,i)),e.host!==void 0&&(e.host=String(e.host).replace(t.PCT_ENCODED,n).toLowerCase().replace(t.NOT_HOST,z).replace(t.PCT_ENCODED,i)),e.path!==void 0&&(e.path=String(e.path).replace(t.PCT_ENCODED,n).replace(e.scheme?t.NOT_PATH:t.NOT_PATH_NOSCHEME,z).replace(t.PCT_ENCODED,i)),e.query!==void 0&&(e.query=String(e.query).replace(t.PCT_ENCODED,n).replace(t.NOT_QUERY,z).replace(t.PCT_ENCODED,i)),e.fragment!==void 0&&(e.fragment=String(e.fragment).replace(t.PCT_ENCODED,n).replace(t.NOT_FRAGMENT,z).replace(t.PCT_ENCODED,i)),e}function re(e){return e.replace(/^0*(.*)/,`$1`)||`0`}function ie(e,t){var n=u(e.match(t.IPV4ADDRESS)||[],2)[1];return n?n.split(`.`).map(re).join(`.`):e}function B(e,t){var n=u(e.match(t.IPV6ADDRESS)||[],3),r=n[1],i=n[2];if(r){for(var a=u(r.toLowerCase().split(`::`).reverse(),2),o=a[0],s=a[1],c=s?s.split(`:`).map(re):[],l=o.split(`:`).map(re),d=t.IPV4ADDRESS.test(l[l.length-1]),f=d?7:8,p=l.length-f,m=Array(f),h=0;h<f;++h)m[h]=c[h]||l[p+h]||``;d&&(m[f-1]=ie(m[f-1],t));var g=m.reduce(function(e,t,n){if(!t||t===`0`){var r=e[e.length-1];r&&r.index+r.length===n?r.length++:e.push({index:n,length:1})}return e},[]).sort(function(e,t){return t.length-e.length})[0],_=void 0;if(g&&g.length>1){var v=m.slice(0,g.index),y=m.slice(g.index+g.length);_=v.join(`:`)+`::`+y.join(`:`)}else _=m.join(`:`);return i&&(_+=`%`+i),_}else return e}var ae=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,oe=``.match(/(){0}/)[1]===void 0;function V(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n={},r=t.iri===!1?c:l;t.reference===`suffix`&&(e=(t.scheme?t.scheme+`:`:``)+`//`+e);var i=e.match(ae);if(i){oe?(n.scheme=i[1],n.userinfo=i[3],n.host=i[4],n.port=parseInt(i[5],10),n.path=i[6]||``,n.query=i[7],n.fragment=i[8],isNaN(n.port)&&(n.port=i[5])):(n.scheme=i[1]||void 0,n.userinfo=e.indexOf(`@`)===-1?void 0:i[3],n.host=e.indexOf(`//`)===-1?void 0:i[4],n.port=parseInt(i[5],10),n.path=i[6]||``,n.query=e.indexOf(`?`)===-1?void 0:i[7],n.fragment=e.indexOf(`#`)===-1?void 0:i[8],isNaN(n.port)&&(n.port=e.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?i[4]:void 0)),n.host&&=B(ie(n.host,r),r),n.scheme===void 0&&n.userinfo===void 0&&n.host===void 0&&n.port===void 0&&!n.path&&n.query===void 0?n.reference=`same-document`:n.scheme===void 0?n.reference=`relative`:n.fragment===void 0?n.reference=`absolute`:n.reference=`uri`,t.reference&&t.reference!==`suffix`&&t.reference!==n.reference&&(n.error=n.error||`URI is not a `+t.reference+` reference.`);var a=R[(t.scheme||n.scheme||``).toLowerCase()];if(!t.unicodeSupport&&(!a||!a.unicodeSupport)){if(n.host&&(t.domainHost||a&&a.domainHost))try{n.host=L.toASCII(n.host.replace(r.PCT_ENCODED,te).toLowerCase())}catch(e){n.error=n.error||`Host's domain name can not be converted to ASCII via punycode: `+e}ne(n,c)}else ne(n,r);a&&a.parse&&a.parse(n,t)}else n.error=n.error||`URI can not be parsed.`;return n}function H(e,t){var n=t.iri===!1?c:l,r=[];return e.userinfo!==void 0&&(r.push(e.userinfo),r.push(`@`)),e.host!==void 0&&r.push(B(ie(String(e.host),n),n).replace(n.IPV6ADDRESS,function(e,t,n){return`[`+t+(n?`%25`+n:``)+`]`})),(typeof e.port==`number`||typeof e.port==`string`)&&(r.push(`:`),r.push(String(e.port))),r.length?r.join(``):void 0}var se=/^\.\.?\//,ce=/^\/\.(\/|$)/,le=/^\/\.\.(\/|$)/,ue=/^\/?(?:.|\n)*?(?=\/|$)/;function U(e){for(var t=[];e.length;)if(e.match(se))e=e.replace(se,``);else if(e.match(ce))e=e.replace(ce,`/`);else if(e.match(le))e=e.replace(le,`/`),t.pop();else if(e===`.`||e===`..`)e=``;else{var n=e.match(ue);if(n){var r=n[0];e=e.slice(r.length),t.push(r)}else throw Error(`Unexpected dot segment condition`)}return t.join(``)}function de(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.iri?l:c,r=[],i=R[(t.scheme||e.scheme||``).toLowerCase()];if(i&&i.serialize&&i.serialize(e,t),e.host&&!n.IPV6ADDRESS.test(e.host)&&(t.domainHost||i&&i.domainHost))try{e.host=t.iri?L.toUnicode(e.host):L.toASCII(e.host.replace(n.PCT_ENCODED,te).toLowerCase())}catch(n){e.error=e.error||`Host's domain name can not be converted to `+(t.iri?`Unicode`:`ASCII`)+` via punycode: `+n}ne(e,n),t.reference!==`suffix`&&e.scheme&&(r.push(e.scheme),r.push(`:`));var a=H(e,t);if(a!==void 0&&(t.reference!==`suffix`&&r.push(`//`),r.push(a),e.path&&e.path.charAt(0)!==`/`&&r.push(`/`)),e.path!==void 0){var o=e.path;!t.absolutePath&&(!i||!i.absolutePath)&&(o=U(o)),a===void 0&&(o=o.replace(/^\/\//,`/%2F`)),r.push(o)}return e.query!==void 0&&(r.push(`?`),r.push(e.query)),e.fragment!==void 0&&(r.push(`#`),r.push(e.fragment)),r.join(``)}function fe(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments[3],i={};return r||(e=V(de(e,n),n),t=V(de(t,n),n)),n||={},!n.tolerant&&t.scheme?(i.scheme=t.scheme,i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=U(t.path||``),i.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(i.userinfo=t.userinfo,i.host=t.host,i.port=t.port,i.path=U(t.path||``),i.query=t.query):(t.path?(t.path.charAt(0)===`/`?i.path=U(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?i.path=`/`+t.path:e.path?i.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:i.path=t.path,i.path=U(i.path)),i.query=t.query):(i.path=e.path,t.query===void 0?i.query=e.query:i.query=t.query),i.userinfo=e.userinfo,i.host=e.host,i.port=e.port),i.scheme=e.scheme),i.fragment=t.fragment,i}function pe(e,t,n){var r=o({scheme:`null`},n);return de(fe(V(e,r),V(t,r),r,!0),r)}function me(e,t){return typeof e==`string`?e=de(V(e,t),t):r(e)===`object`&&(e=V(de(e,t),t)),e}function he(e,t,n){return typeof e==`string`?e=de(V(e,n),n):r(e)===`object`&&(e=de(e,n)),typeof t==`string`?t=de(V(t,n),n):r(t)===`object`&&(t=de(t,n)),e===t}function ge(e,t){return e&&e.toString().replace(!t||!t.iri?c.ESCAPE:l.ESCAPE,z)}function _e(e,t){return e&&e.toString().replace(!t||!t.iri?c.PCT_ENCODED:l.PCT_ENCODED,te)}var ve={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 n=String(e.scheme).toLowerCase()===`https`;return(e.port===(n?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}},ye={scheme:`https`,domainHost:ve.domainHost,parse:ve.parse,serialize:ve.serialize};function be(e){return typeof e.secure==`boolean`?e.secure:String(e.scheme).toLowerCase()===`wss`}var xe={scheme:`ws`,domainHost:!0,parse:function(e,t){var n=e;return n.secure=be(n),n.resourceName=(n.path||`/`)+(n.query?`?`+n.query:``),n.path=void 0,n.query=void 0,n},serialize:function(e,t){if((e.port===(be(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){var n=u(e.resourceName.split(`?`),2),r=n[0],i=n[1];e.path=r&&r!==`/`?r:void 0,e.query=i,e.resourceName=void 0}return e.fragment=void 0,e}},Se={scheme:`wss`,domainHost:xe.domainHost,parse:xe.parse,serialize:xe.serialize},Ce={},we=`[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]`,Te=`[0-9A-Fa-f]`,Ee=n(n(`%[EFef]`+Te+`%`+Te+Te+`%`+Te+Te)+`|`+n(`%[89A-Fa-f]`+Te+`%`+Te+Te)+`|`+n(`%`+Te+Te)),De="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Oe=t(`[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]`,`[\\"\\\\]`),ke=`[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]`,Ae=new RegExp(we,`g`),je=new RegExp(Ee,`g`),Me=new RegExp(t(`[^]`,De,`[\\.]`,`[\\"]`,Oe),`g`),Ne=new RegExp(t(`[^]`,we,ke),`g`),Pe=Ne;function Fe(e){var t=te(e);return t.match(Ae)?t:e}var Ie={scheme:`mailto`,parse:function(e,t){var n=e,r=n.to=n.path?n.path.split(`,`):[];if(n.path=void 0,n.query){for(var i=!1,a={},o=n.query.split(`&`),s=0,c=o.length;s<c;++s){var l=o[s].split(`=`);switch(l[0]){case`to`:for(var u=l[1].split(`,`),d=0,f=u.length;d<f;++d)r.push(u[d]);break;case`subject`:n.subject=_e(l[1],t);break;case`body`:n.body=_e(l[1],t);break;default:i=!0,a[_e(l[0],t)]=_e(l[1],t);break}}i&&(n.headers=a)}n.query=void 0;for(var p=0,m=r.length;p<m;++p){var h=r[p].split(`@`);if(h[0]=_e(h[0]),t.unicodeSupport)h[1]=_e(h[1],t).toLowerCase();else try{h[1]=L.toASCII(_e(h[1],t).toLowerCase())}catch(e){n.error=n.error||`Email address's domain name can not be converted to ASCII via punycode: `+e}r[p]=h.join(`@`)}return n},serialize:function(e,t){var n=e,r=a(e.to);if(r){for(var o=0,s=r.length;o<s;++o){var c=String(r[o]),l=c.lastIndexOf(`@`),u=c.slice(0,l).replace(je,Fe).replace(je,i).replace(Me,z),d=c.slice(l+1);try{d=t.iri?L.toUnicode(d):L.toASCII(_e(d,t).toLowerCase())}catch(e){n.error=n.error||`Email address's domain name can not be converted to `+(t.iri?`Unicode`:`ASCII`)+` via punycode: `+e}r[o]=u+`@`+d}n.path=r.join(`,`)}var f=e.headers=e.headers||{};e.subject&&(f.subject=e.subject),e.body&&(f.body=e.body);var p=[];for(var m in f)f[m]!==Ce[m]&&p.push(m.replace(je,Fe).replace(je,i).replace(Ne,z)+`=`+f[m].replace(je,Fe).replace(je,i).replace(Pe,z));return p.length&&(n.query=p.join(`&`)),n}},Le=/^([^\:]+)\:(.*)/,Re={scheme:`urn`,parse:function(e,t){var n=e.path&&e.path.match(Le),r=e;if(n){var i=t.scheme||r.scheme||`urn`,a=n[1].toLowerCase(),o=n[2],s=R[i+`:`+(t.nid||a)];r.nid=a,r.nss=o,r.path=void 0,s&&(r=s.parse(r,t))}else r.error=r.error||`URN can not be parsed.`;return r},serialize:function(e,t){var n=t.scheme||e.scheme||`urn`,r=e.nid,i=R[n+`:`+(t.nid||r)];i&&(e=i.serialize(e,t));var a=e,o=e.nss;return a.path=(r||t.nid)+`:`+o,a}},ze=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/,Be={scheme:`urn:uuid`,parse:function(e,t){var n=e;return n.uuid=n.nss,n.nss=void 0,!t.tolerant&&(!n.uuid||!n.uuid.match(ze))&&(n.error=n.error||`UUID is not valid.`),n},serialize:function(e,t){var n=e;return n.nss=(e.uuid||``).toLowerCase(),n}};R[ve.scheme]=ve,R[ye.scheme]=ye,R[xe.scheme]=xe,R[Se.scheme]=Se,R[Ie.scheme]=Ie,R[Re.scheme]=Re,R[Be.scheme]=Be,e.SCHEMES=R,e.pctEncChar=z,e.pctDecChars=te,e.parse=V,e.removeDotSegments=U,e.serialize=de,e.resolveComponents=fe,e.resolve=pe,e.normalize=me,e.equal=he,e.escapeComponent=ge,e.unescapeComponent=_e,Object.defineProperty(e,`__esModule`,{value:!0})}))})),xi=s(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),Si=s(((e,t)=>{t.exports=function(e){for(var t=0,n=e.length,r=0,i;r<n;)t++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<n&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return t}})),Ci=s(((e,t)=>{t.exports={copy:n,checkDataType:r,checkDataTypes:i,coerceToTypes:o,toHash:s,getProperty:u,escapeQuotes:d,equal:xi(),ucs2length:Si(),varOccurences:f,varReplace:p,schemaHasRules:m,schemaHasRulesExcept:h,schemaUnknownRules:g,toQuotedString:_,getPathExpr:v,getPath:y,getData:S,unescapeFragment:w,unescapeJsonPointer:D,escapeFragment:T,escapeJsonPointer:E};function n(e,t){for(var n in t||={},e)t[n]=e[n];return t}function r(e,t,n,r){var i=r?` !== `:` === `,a=r?` || `:` && `,o=r?`!`:``,s=r?``:`!`;switch(e){case`null`:return t+i+`null`;case`array`:return o+`Array.isArray(`+t+`)`;case`object`:return`(`+o+t+a+`typeof `+t+i+`"object"`+a+s+`Array.isArray(`+t+`))`;case`integer`:return`(typeof `+t+i+`"number"`+a+s+`(`+t+` % 1)`+a+t+i+t+(n?a+o+`isFinite(`+t+`)`:``)+`)`;case`number`:return`(typeof `+t+i+`"`+e+`"`+(n?a+o+`isFinite(`+t+`)`:``)+`)`;default:return`typeof `+t+i+`"`+e+`"`}}function i(e,t,n){switch(e.length){case 1:return r(e[0],t,n,!0);default:var i=``,a=s(e);for(var o in a.array&&a.object&&(i=a.null?`(`:`(!`+t+` || `,i+=`typeof `+t+` !== "object")`,delete a.null,delete a.array,delete a.object),a.number&&delete a.integer,a)i+=(i?` && `:``)+r(o,t,n,!0);return i}}var a=s([`string`,`number`,`integer`,`boolean`,`null`]);function o(e,t){if(Array.isArray(t)){for(var n=[],r=0;r<t.length;r++){var i=t[r];(a[i]||e===`array`&&i===`array`)&&(n[n.length]=i)}if(n.length)return n}else if(a[t])return[t];else if(e===`array`&&t===`array`)return[`array`]}function s(e){for(var t={},n=0;n<e.length;n++)t[e[n]]=!0;return t}var c=/^[a-z$_][a-z$_0-9]*$/i,l=/'|\\/g;function u(e){return typeof e==`number`?`[`+e+`]`:c.test(e)?`.`+e:`['`+d(e)+`']`}function d(e){return e.replace(l,`\\$&`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/\f/g,`\\f`).replace(/\t/g,`\\t`)}function f(e,t){t+=`[^0-9]`;var n=e.match(new RegExp(t,`g`));return n?n.length:0}function p(e,t,n){return t+=`([^0-9])`,n=n.replace(/\$/g,`$$$$`),e.replace(new RegExp(t,`g`),n+`$1`)}function m(e,t){if(typeof e==`boolean`)return!e;for(var n in e)if(t[n])return!0}function h(e,t,n){if(typeof e==`boolean`)return!e&&n!=`not`;for(var r in e)if(r!=n&&t[r])return!0}function g(e,t){if(typeof e!=`boolean`){for(var n in e)if(!t[n])return n}}function _(e){return`'`+d(e)+`'`}function v(e,t,n,r){return C(e,n?`'/' + `+t+(r?``:`.replace(/~/g, '~0').replace(/\\//g, '~1')`):r?`'[' + `+t+` + ']'`:`'[\\'' + `+t+` + '\\']'`)}function y(e,t,n){return C(e,_(n?`/`+E(t):u(t)))}var b=/^\/(?:[^~]|~0|~1)*$/,x=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function S(e,t,n){var r,i,a,o;if(e===``)return`rootData`;if(e[0]==`/`){if(!b.test(e))throw Error(`Invalid JSON-pointer: `+e);i=e,a=`rootData`}else{if(o=e.match(x),!o)throw Error(`Invalid JSON-pointer: `+e);if(r=+o[1],i=o[2],i==`#`){if(r>=t)throw Error(`Cannot access property/index `+r+` levels up, current level is `+t);return n[t-r]}if(r>t)throw Error(`Cannot access data `+r+` levels up, current level is `+t);if(a=`data`+(t-r||``),!i)return a}for(var s=a,c=i.split(`/`),l=0;l<c.length;l++){var d=c[l];d&&(a+=u(D(d)),s+=` && `+a)}return s}function C(e,t){return e==`""`?t:(e+` + `+t).replace(/([^\\])' \+ '/g,`$1`)}function w(e){return D(decodeURIComponent(e))}function T(e){return encodeURIComponent(E(e))}function E(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function D(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}})),wi=s(((e,t)=>{var n=Ci();t.exports=r;function r(e){n.copy(e,this)}})),Ti=s(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.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};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),Ei=s(((e,t)=>{var n=bi(),r=xi(),i=Ci(),a=wi(),o=Ti();t.exports=s,s.normalizeId=y,s.fullPath=g,s.url=b,s.ids=x,s.inlineRef=p,s.schema=c;function s(e,t,n){var r=this._refs[n];if(typeof r==`string`)if(this._refs[r])r=this._refs[r];else return s.call(this,e,t,r);if(r||=this._schemas[n],r instanceof a)return p(r.schema,this._opts.inlineRefs)?r.schema:r.validate||this._compile(r);var i=c.call(this,t,n),o,l,u;return i&&(o=i.schema,t=i.root,u=i.baseId),o instanceof a?l=o.validate||e.call(this,o.schema,t,void 0,u):o!==void 0&&(l=p(o,this._opts.inlineRefs)?o:e.call(this,o,t,void 0,u)),l}function c(e,t){var r=n.parse(t),i=_(r),o=g(this._getId(e.schema));if(Object.keys(e.schema).length===0||i!==o){var s=y(i),c=this._refs[s];if(typeof c==`string`)return l.call(this,e,c,r);if(c instanceof a)c.validate||this._compile(c),e=c;else if(c=this._schemas[s],c instanceof a){if(c.validate||this._compile(c),s==y(t))return{schema:c,root:e,baseId:o};e=c}else return;if(!e.schema)return;o=g(this._getId(e.schema))}return d.call(this,r,o,e.schema,e)}function l(e,t,n){var r=c.call(this,e,t);if(r){var i=r.schema,a=r.baseId;e=r.root;var o=this._getId(i);return o&&(a=b(a,o)),d.call(this,n,a,i,e)}}var u=i.toHash([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function d(e,t,n,r){if(e.fragment=e.fragment||``,e.fragment.slice(0,1)==`/`){for(var a=e.fragment.split(`/`),o=1;o<a.length;o++){var s=a[o];if(s){if(s=i.unescapeFragment(s),n=n[s],n===void 0)break;var l;if(!u[s]&&(l=this._getId(n),l&&(t=b(t,l)),n.$ref)){var d=b(t,n.$ref),f=c.call(this,r,d);f&&(n=f.schema,r=f.root,t=f.baseId)}}}if(n!==void 0&&n!==r.schema)return{schema:n,root:r,baseId:t}}}var f=i.toHash([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`]);function p(e,t){if(t===!1)return!1;if(t===void 0||t===!0)return m(e);if(t)return h(e)<=t}function m(e){var t;if(Array.isArray(e)){for(var n=0;n<e.length;n++)if(t=e[n],typeof t==`object`&&!m(t))return!1}else for(var r in e)if(r==`$ref`||(t=e[r],typeof t==`object`&&!m(t)))return!1;return!0}function h(e){var t=0,n;if(Array.isArray(e)){for(var r=0;r<e.length;r++)if(n=e[r],typeof n==`object`&&(t+=h(n)),t==1/0)return 1/0}else for(var i in e){if(i==`$ref`)return 1/0;if(f[i])t++;else if(n=e[i],typeof n==`object`&&(t+=h(n)+1),t==1/0)return 1/0}return t}function g(e,t){return t!==!1&&(e=y(e)),_(n.parse(e))}function _(e){return n.serialize(e).split(`#`)[0]+`#`}var v=/#\/?$/;function y(e){return e?e.replace(v,``):``}function b(e,t){return t=y(t),n.resolve(e,t)}function x(e){var t=y(this._getId(e)),a={"":t},s={"":g(t,!1)},c={},l=this;return o(e,{allKeys:!0},function(e,t,o,u,d,f,p){if(t!==``){var m=l._getId(e),h=a[u],g=s[u]+`/`+d;if(p!==void 0&&(g+=`/`+(typeof p==`number`?p:i.escapeFragment(p))),typeof m==`string`){m=h=y(h?n.resolve(h,m):m);var _=l._refs[m];if(typeof _==`string`&&(_=l._refs[_]),_&&_.schema){if(!r(e,_.schema))throw Error(`id "`+m+`" resolves to more than one schema`)}else if(m!=y(g))if(m[0]==`#`){if(c[m]&&!r(e,c[m]))throw Error(`id "`+m+`" resolves to more than one schema`);c[m]=e}else l._refs[m]=g}a[t]=h,s[t]=g}}),c}})),Di=s(((e,t)=>{var n=Ei();t.exports={Validation:a(r),MissingRef:a(i)};function r(e){this.message=`validation failed`,this.errors=e,this.ajv=this.validation=!0}i.message=function(e,t){return`can't resolve reference `+t+` from id `+e};function i(e,t,r){this.message=r||i.message(e,t),this.missingRef=n.url(e,t),this.missingSchema=n.normalizeId(n.fullPath(this.missingRef))}function a(e){return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}})),Oi=s(((e,t)=>{t.exports=function(e,t){t||={},typeof t==`function`&&(t={cmp:t});var n=typeof t.cycles==`boolean`?t.cycles:!1,r=t.cmp&&(function(e){return function(t){return function(n,r){return e({key:n,value:t[n]},{key:r,value:t[r]})}}})(t.cmp),i=[];return(function e(t){if(t&&t.toJSON&&typeof t.toJSON==`function`&&(t=t.toJSON()),t!==void 0){if(typeof t==`number`)return isFinite(t)?``+t:`null`;if(typeof t!=`object`)return JSON.stringify(t);var a,o;if(Array.isArray(t)){for(o=`[`,a=0;a<t.length;a++)a&&(o+=`,`),o+=e(t[a])||`null`;return o+`]`}if(t===null)return`null`;if(i.indexOf(t)!==-1){if(n)return JSON.stringify(`__cycle__`);throw TypeError(`Converting circular structure to JSON`)}var s=i.push(t)-1,c=Object.keys(t).sort(r&&r(t));for(o=``,a=0;a<c.length;a++){var l=c[a],u=e(t[l]);u&&(o&&(o+=`,`),o+=JSON.stringify(l)+`:`+u)}return i.splice(s,1),`{`+o+`}`}})(e)}})),ki=s(((e,t)=>{t.exports=function(e,t,n){var r=``,i=e.schema.$async===!0,a=e.util.schemaHasRulesExcept(e.schema,e.RULES.all,`$ref`),o=e.self._getId(e.schema);if(e.opts.strictKeywords){var s=e.util.schemaUnknownRules(e.schema,e.RULES.keywords);if(s){var c=`unknown keyword: `+s;if(e.opts.strictKeywords===`log`)e.logger.warn(c);else throw Error(c)}}if(e.isTop&&(r+=` var validate = `,i&&(e.async=!0,r+=`async `),r+=`function(data, dataPath, parentData, parentDataProperty, rootData) { 'use strict'; `,o&&(e.opts.sourceCode||e.opts.processCode)&&(r+=` `+(`/*# sourceURL=`+o+` */`)+` `)),typeof e.schema==`boolean`||!(a||e.schema.$ref)){var t=`false schema`,l=e.level,u=e.dataLevel,d=e.schema[t],f=e.schemaPath+e.util.getProperty(t),p=e.errSchemaPath+`/`+t,m=!e.opts.allErrors,h,g=`data`+(u||``),_=`valid`+l;if(e.schema===!1){e.isTop?m=!0:r+=` var `+_+` = false; `;var v=v||[];v.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(h||`false schema`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(p)+` , params: {} `,e.opts.messages!==!1&&(r+=` , message: 'boolean schema is false' `),e.opts.verbose&&(r+=` , schema: false , parentSchema: validate.schema`+e.schemaPath+` , data: `+g+` `),r+=` } `);var y=r;r=v.pop(),!e.compositeRule&&m?e.async?r+=` throw new ValidationError([`+y+`]); `:r+=` validate.errors = [`+y+`]; return false; `:r+=` var err = `+y+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `}else e.isTop?i?r+=` return data; `:r+=` validate.errors = null; return true; `:r+=` var `+_+` = true; `;return e.isTop&&(r+=` }; return validate; `),r}if(e.isTop){var b=e.isTop,l=e.level=0,u=e.dataLevel=0,g=`data`;if(e.rootId=e.resolve.fullPath(e.self._getId(e.root.schema)),e.baseId=e.baseId||e.rootId,delete e.isTop,e.dataPathArr=[``],e.schema.default!==void 0&&e.opts.useDefaults&&e.opts.strictDefaults){var x=`default is ignored in the schema root`;if(e.opts.strictDefaults===`log`)e.logger.warn(x);else throw Error(x)}r+=` var vErrors = null; `,r+=` var errors = 0; `,r+=` if (rootData === undefined) rootData = data; `}else{var l=e.level,u=e.dataLevel,g=`data`+(u||``);if(o&&(e.baseId=e.resolve.url(e.baseId,o)),i&&!e.async)throw Error(`async schema in sync schema`);r+=` var errs_`+l+` = errors;`}var _=`valid`+l,m=!e.opts.allErrors,S=``,C=``,h,w=e.schema.type,T=Array.isArray(w);if(w&&e.opts.nullable&&e.schema.nullable===!0&&(T?w.indexOf(`null`)==-1&&(w=w.concat(`null`)):w!=`null`&&(w=[w,`null`],T=!0)),T&&w.length==1&&(w=w[0],T=!1),e.schema.$ref&&a){if(e.opts.extendRefs==`fail`)throw Error(`$ref: validation keywords used in schema at path "`+e.errSchemaPath+`" (see option extendRefs)`);e.opts.extendRefs!==!0&&(a=!1,e.logger.warn(`$ref: keywords ignored in schema at path "`+e.errSchemaPath+`"`))}if(e.schema.$comment&&e.opts.$comment&&(r+=` `+e.RULES.all.$comment.code(e,`$comment`)),w){if(e.opts.coerceTypes)var E=e.util.coerceToTypes(e.opts.coerceTypes,w);var D=e.RULES.types[w];if(E||T||D===!0||D&&!ue(D)){var f=e.schemaPath+`.type`,p=e.errSchemaPath+`/type`,f=e.schemaPath+`.type`,p=e.errSchemaPath+`/type`,O=T?`checkDataTypes`:`checkDataType`;if(r+=` if (`+e.util[O](w,g,e.opts.strictNumbers,!0)+`) { `,E){var k=`dataType`+l,A=`coerced`+l;r+=` var `+k+` = typeof `+g+`; var `+A+` = undefined; `,e.opts.coerceTypes==`array`&&(r+=` if (`+k+` == 'object' && Array.isArray(`+g+`) && `+g+`.length == 1) { `+g+` = `+g+`[0]; `+k+` = typeof `+g+`; if (`+e.util.checkDataType(e.schema.type,g,e.opts.strictNumbers)+`) `+A+` = `+g+`; } `),r+=` if (`+A+` !== undefined) ; `;var j=E;if(j)for(var M,N=-1,P=j.length-1;N<P;)M=j[N+=1],M==`string`?r+=` else if (`+k+` == 'number' || `+k+` == 'boolean') `+A+` = '' + `+g+`; else if (`+g+` === null) `+A+` = ''; `:M==`number`||M==`integer`?(r+=` else if (`+k+` == 'boolean' || `+g+` === null || (`+k+` == 'string' && `+g+` && `+g+` == +`+g+` `,M==`integer`&&(r+=` && !(`+g+` % 1)`),r+=`)) `+A+` = +`+g+`; `):M==`boolean`?r+=` else if (`+g+` === 'false' || `+g+` === 0 || `+g+` === null) `+A+` = false; else if (`+g+` === 'true' || `+g+` === 1) `+A+` = true; `:M==`null`?r+=` else if (`+g+` === '' || `+g+` === 0 || `+g+` === false) `+A+` = null; `:e.opts.coerceTypes==`array`&&M==`array`&&(r+=` else if (`+k+` == 'string' || `+k+` == 'number' || `+k+` == 'boolean' || `+g+` == null) `+A+` = [`+g+`]; `);r+=` else { `;var v=v||[];v.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(h||`type`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(p)+` , params: { type: '`,T?r+=``+w.join(`,`):r+=``+w,r+=`' } `,e.opts.messages!==!1&&(r+=` , message: 'should be `,T?r+=``+w.join(`,`):r+=``+w,r+=`' `),e.opts.verbose&&(r+=` , schema: validate.schema`+f+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+g+` `),r+=` } `);var y=r;r=v.pop(),!e.compositeRule&&m?e.async?r+=` throw new ValidationError([`+y+`]); `:r+=` validate.errors = [`+y+`]; return false; `:r+=` var err = `+y+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } if (`+A+` !== undefined) { `;var F=u?`data`+(u-1||``):`parentData`,ee=u?e.dataPathArr[u]:`parentDataProperty`;r+=` `+g+` = `+A+`; `,u||(r+=`if (`+F+` !== undefined)`),r+=` `+F+`[`+ee+`] = `+A+`; } `}else{var v=v||[];v.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(h||`type`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(p)+` , params: { type: '`,T?r+=``+w.join(`,`):r+=``+w,r+=`' } `,e.opts.messages!==!1&&(r+=` , message: 'should be `,T?r+=``+w.join(`,`):r+=``+w,r+=`' `),e.opts.verbose&&(r+=` , schema: validate.schema`+f+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+g+` `),r+=` } `);var y=r;r=v.pop(),!e.compositeRule&&m?e.async?r+=` throw new ValidationError([`+y+`]); `:r+=` validate.errors = [`+y+`]; return false; `:r+=` var err = `+y+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `}r+=` } `}}if(e.schema.$ref&&!a)r+=` `+e.RULES.all.$ref.code(e,`$ref`)+` `,m&&(r+=` } if (errors === `,b?r+=`0`:r+=`errs_`+l,r+=`) { `,C+=`}`);else{var I=e.RULES;if(I){for(var D,L=-1,R=I.length-1;L<R;)if(D=I[L+=1],ue(D)){if(D.type&&(r+=` if (`+e.util.checkDataType(D.type,g,e.opts.strictNumbers)+`) { `),e.opts.useDefaults){if(D.type==`object`&&e.schema.properties){var d=e.schema.properties,z=Object.keys(d);if(z)for(var te,ne=-1,re=z.length-1;ne<re;){te=z[ne+=1];var ie=d[te];if(ie.default!==void 0){var B=g+e.util.getProperty(te);if(e.compositeRule){if(e.opts.strictDefaults){var x=`default is ignored for: `+B;if(e.opts.strictDefaults===`log`)e.logger.warn(x);else throw Error(x)}}else r+=` if (`+B+` === undefined `,e.opts.useDefaults==`empty`&&(r+=` || `+B+` === null || `+B+` === '' `),r+=` ) `+B+` = `,e.opts.useDefaults==`shared`?r+=` `+e.useDefault(ie.default)+` `:r+=` `+JSON.stringify(ie.default)+` `,r+=`; `}}}else if(D.type==`array`&&Array.isArray(e.schema.items)){var ae=e.schema.items;if(ae){for(var ie,N=-1,oe=ae.length-1;N<oe;)if(ie=ae[N+=1],ie.default!==void 0){var B=g+`[`+N+`]`;if(e.compositeRule){if(e.opts.strictDefaults){var x=`default is ignored for: `+B;if(e.opts.strictDefaults===`log`)e.logger.warn(x);else throw Error(x)}}else r+=` if (`+B+` === undefined `,e.opts.useDefaults==`empty`&&(r+=` || `+B+` === null || `+B+` === '' `),r+=` ) `+B+` = `,e.opts.useDefaults==`shared`?r+=` `+e.useDefault(ie.default)+` `:r+=` `+JSON.stringify(ie.default)+` `,r+=`; `}}}}var V=D.rules;if(V){for(var H,se=-1,ce=V.length-1;se<ce;)if(H=V[se+=1],U(H)){var le=H.code(e,H.keyword,D.type);le&&(r+=` `+le+` `,m&&(S+=`}`))}}if(m&&(r+=` `+S+` `,S=``),D.type&&(r+=` } `,w&&w===D.type&&!E)){r+=` else { `;var f=e.schemaPath+`.type`,p=e.errSchemaPath+`/type`,v=v||[];v.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(h||`type`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(p)+` , params: { type: '`,T?r+=``+w.join(`,`):r+=``+w,r+=`' } `,e.opts.messages!==!1&&(r+=` , message: 'should be `,T?r+=``+w.join(`,`):r+=``+w,r+=`' `),e.opts.verbose&&(r+=` , schema: validate.schema`+f+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+g+` `),r+=` } `);var y=r;r=v.pop(),!e.compositeRule&&m?e.async?r+=` throw new ValidationError([`+y+`]); `:r+=` validate.errors = [`+y+`]; return false; `:r+=` var err = `+y+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } `}m&&(r+=` if (errors === `,b?r+=`0`:r+=`errs_`+l,r+=`) { `,C+=`}`)}}}m&&(r+=` `+C+` `),b?(i?(r+=` if (errors === 0) return data; `,r+=` else throw new ValidationError(vErrors); `):(r+=` validate.errors = vErrors; `,r+=` return errors === 0; `),r+=` }; return validate;`):r+=` var `+_+` = errors === errs_`+l+`;`;function ue(e){for(var t=e.rules,n=0;n<t.length;n++)if(U(t[n]))return!0}function U(t){return e.schema[t.keyword]!==void 0||t.implements&&de(t)}function de(t){for(var n=t.implements,r=0;r<n.length;r++)if(e.schema[n[r]]!==void 0)return!0}return r}})),Ai=s(((e,t)=>{var n=Ei(),r=Ci(),i=Di(),a=Oi(),o=ki(),s=r.ucs2length,c=xi(),l=i.Validation;t.exports=u;function u(e,t,p,y){var b=this,x=this._opts,S=[void 0],C={},w=[],T={},E=[],D={},O=[];t||={schema:e,refVal:S,refs:C};var k=d.call(this,e,t,y),A=this._compilations[k.index];if(k.compiling)return A.callValidate=F;var j=this._formats,M=this.RULES;try{var N=ee(e,t,p,y);A.validate=N;var P=A.callValidate;return P&&(P.schema=N.schema,P.errors=null,P.refs=N.refs,P.refVal=N.refVal,P.root=N.root,P.$async=N.$async,x.sourceCode&&(P.source=N.source)),N}finally{f.call(this,e,t,y)}function F(){var e=A.validate,t=e.apply(this,arguments);return F.errors=e.errors,t}function ee(e,a,d,f){var p=!a||a&&a.schema==e;if(a.schema!=t.schema)return u.call(b,e,a,d,f);var y=e.$async===!0,T=o({isTop:!0,schema:e,isRoot:p,baseId:f,root:a,schemaPath:``,errSchemaPath:`#`,errorPath:`""`,MissingRefError:i.MissingRef,RULES:M,validate:o,util:r,resolve:n,resolveRef:I,usePattern:ne,useDefault:re,useCustomRule:ie,opts:x,formats:j,logger:b.logger,self:b});T=v(S,g)+v(w,m)+v(E,h)+v(O,_)+T,x.processCode&&(T=x.processCode(T,e));var D;try{D=Function(`self`,`RULES`,`formats`,`root`,`refVal`,`defaults`,`customRules`,`equal`,`ucs2length`,`ValidationError`,T)(b,M,j,t,S,E,O,c,s,l),S[0]=D}catch(e){throw b.logger.error(`Error compiling schema, function code:`,T),e}return D.schema=e,D.errors=null,D.refs=C,D.refVal=S,D.root=p?D:a,y&&(D.$async=!0),x.sourceCode===!0&&(D.source={code:T,patterns:w,defaults:E}),D}function I(e,r,i){r=n.url(e,r);var a=C[r],o,s;if(a!==void 0)return o=S[a],s=`refVal[`+a+`]`,te(o,s);if(!i&&t.refs){var c=t.refs[r];if(c!==void 0)return o=t.refVal[c],s=L(r,o),te(o,s)}s=L(r);var l=n.call(b,ee,t,r);if(l===void 0){var d=p&&p[r];d&&(l=n.inlineRef(d,x.inlineRefs)?d:u.call(b,d,t,p,e))}if(l===void 0)R(r);else return z(r,l),te(l,s)}function L(e,t){var n=S.length;return S[n]=t,C[e]=n,`refVal`+n}function R(e){delete C[e]}function z(e,t){var n=C[e];S[n]=t}function te(e,t){return typeof e==`object`||typeof e==`boolean`?{code:t,schema:e,inline:!0}:{code:t,$async:e&&!!e.$async}}function ne(e){var t=T[e];return t===void 0&&(t=T[e]=w.length,w[t]=e),`pattern`+t}function re(e){switch(typeof e){case`boolean`:case`number`:return``+e;case`string`:return r.toQuotedString(e);case`object`:if(e===null)return`null`;var t=a(e),n=D[t];return n===void 0&&(n=D[t]=E.length,E[n]=e),`default`+n}}function ie(e,t,n,r){if(b._opts.validateSchema!==!1){var i=e.definition.dependencies;if(i&&!i.every(function(e){return Object.prototype.hasOwnProperty.call(n,e)}))throw Error(`parent schema must have all required keywords: `+i.join(`,`));var a=e.definition.validateSchema;if(a&&!a(t)){var o=`keyword schema is invalid: `+b.errorsText(a.errors);if(b._opts.validateSchema==`log`)b.logger.error(o);else throw Error(o)}}var s=e.definition.compile,c=e.definition.inline,l=e.definition.macro,u;if(s)u=s.call(b,t,n,r);else if(l)u=l.call(b,t,n,r),x.validateSchema!==!1&&b.validateSchema(u,!0);else if(c)u=c.call(b,r,e.keyword,t,n);else if(u=e.definition.validate,!u)return;if(u===void 0)throw Error(`custom keyword "`+e.keyword+`"failed to compile`);var d=O.length;return O[d]=u,{code:`customRule`+d,validate:u}}}function d(e,t,n){var r=p.call(this,e,t,n);return r>=0?{index:r,compiling:!0}:(r=this._compilations.length,this._compilations[r]={schema:e,root:t,baseId:n},{index:r,compiling:!1})}function f(e,t,n){var r=p.call(this,e,t,n);r>=0&&this._compilations.splice(r,1)}function p(e,t,n){for(var r=0;r<this._compilations.length;r++){var i=this._compilations[r];if(i.schema==e&&i.root==t&&i.baseId==n)return r}return-1}function m(e,t){return`var pattern`+e+` = new RegExp(`+r.toQuotedString(t[e])+`);`}function h(e){return`var default`+e+` = defaults[`+e+`];`}function g(e,t){return t[e]===void 0?``:`var refVal`+e+` = refVal[`+e+`];`}function _(e){return`var customRule`+e+` = customRules[`+e+`];`}function v(e,t){if(!e.length)return``;for(var n=``,r=0;r<e.length;r++)n+=t(r,e);return n}})),ji=s(((e,t)=>{var n=t.exports=function(){this._cache={}};n.prototype.put=function(e,t){this._cache[e]=t},n.prototype.get=function(e){return this._cache[e]},n.prototype.del=function(e){delete this._cache[e]},n.prototype.clear=function(){this._cache={}}})),Mi=s(((e,t)=>{var n=Ci(),r=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,i=[0,31,28,31,30,31,30,31,31,30,31,30,31],a=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,o=/^(?=.{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,s=/^(?:[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,c=/^(?:[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,l=/^(?:(?:[^\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,u=/^(?:(?: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,d=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,f=/^(?:\/(?:[^~/]|~0|~1)*)*$/,p=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,m=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/;t.exports=h;function h(e){return e=e==`full`?`full`:`fast`,n.copy(h[e])}h.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":l,url:u,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:o,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:w,uuid:d,"json-pointer":f,"json-pointer-uri-fragment":p,"relative-json-pointer":m},h.full={date:_,time:v,"date-time":b,uri:S,"uri-reference":c,"uri-template":l,url:u,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:o,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:w,uuid:d,"json-pointer":f,"json-pointer-uri-fragment":p,"relative-json-pointer":m};function g(e){return e%4==0&&(e%100!=0||e%400==0)}function _(e){var t=e.match(r);if(!t)return!1;var n=+t[1],a=+t[2],o=+t[3];return a>=1&&a<=12&&o>=1&&o<=(a==2&&g(n)?29:i[a])}function v(e,t){var n=e.match(a);if(!n)return!1;var r=n[1],i=n[2],o=n[3],s=n[5];return(r<=23&&i<=59&&o<=59||r==23&&i==59&&o==60)&&(!t||s)}var y=/t|\s/i;function b(e){var t=e.split(y);return t.length==2&&_(t[0])&&v(t[1],!0)}var x=/\/|:/;function S(e){return x.test(e)&&s.test(e)}var C=/[^\\]\\Z/;function w(e){if(C.test(e))return!1;try{return new RegExp(e),!0}catch{return!1}}})),Ni=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.errSchemaPath+`/`+t,c=!e.opts.allErrors,l=`data`+(a||``),u=`valid`+i,d,f;if(o==`#`||o==`#/`)e.isRoot?(d=e.async,f=`validate`):(d=e.root.schema.$async===!0,f=`root.refVal[0]`);else{var p=e.resolveRef(e.baseId,o,e.isRoot);if(p===void 0){var m=e.MissingRefError.message(e.baseId,o);if(e.opts.missingRefs==`fail`){e.logger.error(m);var h=h||[];h.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '$ref' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(s)+` , params: { ref: '`+e.util.escapeQuotes(o)+`' } `,e.opts.messages!==!1&&(r+=` , message: 'can\\'t resolve reference `+e.util.escapeQuotes(o)+`' `),e.opts.verbose&&(r+=` , schema: `+e.util.toQuotedString(o)+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+l+` `),r+=` } `);var g=r;r=h.pop(),!e.compositeRule&&c?e.async?r+=` throw new ValidationError([`+g+`]); `:r+=` validate.errors = [`+g+`]; return false; `:r+=` var err = `+g+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,c&&(r+=` if (false) { `)}else if(e.opts.missingRefs==`ignore`)e.logger.warn(m),c&&(r+=` if (true) { `);else throw new e.MissingRefError(e.baseId,o,m)}else if(p.inline){var _=e.util.copy(e);_.level++;var v=`valid`+_.level;_.schema=p.schema,_.schemaPath=``,_.errSchemaPath=o;var y=e.validate(_).replace(/validate\.schema/g,p.code);r+=` `+y+` `,c&&(r+=` if (`+v+`) { `)}else d=p.$async===!0||e.async&&p.$async!==!1,f=p.code}if(f){var h=h||[];h.push(r),r=``,e.opts.passContext?r+=` `+f+`.call(this, `:r+=` `+f+`( `,r+=` `+l+`, (dataPath || '')`,e.errorPath!=`""`&&(r+=` + `+e.errorPath);var b=a?`data`+(a-1||``):`parentData`,x=a?e.dataPathArr[a]:`parentDataProperty`;r+=` , `+b+` , `+x+`, rootData) `;var S=r;if(r=h.pop(),d){if(!e.async)throw Error(`async schema referenced by sync schema`);c&&(r+=` var `+u+`; `),r+=` try { await `+S+`; `,c&&(r+=` `+u+` = true; `),r+=` } catch (e) { if (!(e instanceof ValidationError)) throw e; if (vErrors === null) vErrors = e.errors; else vErrors = vErrors.concat(e.errors); errors = vErrors.length; `,c&&(r+=` `+u+` = false; `),r+=` } `,c&&(r+=` if (`+u+`) { `)}else r+=` if (!`+S+`) { if (vErrors === null) vErrors = `+f+`.errors; else vErrors = vErrors.concat(`+f+`.errors); errors = vErrors.length; } `,c&&(r+=` else { `)}return r}})),Pi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.schema[t],a=e.schemaPath+e.util.getProperty(t),o=e.errSchemaPath+`/`+t,s=!e.opts.allErrors,c=e.util.copy(e),l=``;c.level++;var u=`valid`+c.level,d=c.baseId,f=!0,p=i;if(p)for(var m,h=-1,g=p.length-1;h<g;)m=p[h+=1],(e.opts.strictKeywords?typeof m==`object`&&Object.keys(m).length>0||m===!1:e.util.schemaHasRules(m,e.RULES.all))&&(f=!1,c.schema=m,c.schemaPath=a+`[`+h+`]`,c.errSchemaPath=o+`/`+h,r+=` `+e.validate(c)+` `,c.baseId=d,s&&(r+=` if (`+u+`) { `,l+=`}`));return s&&(f?r+=` if (true) { `:r+=` `+l.slice(0,-1)+` `),r}})),Fi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`valid`+i,f=`errs__`+i,p=e.util.copy(e),m=``;p.level++;var h=`valid`+p.level;if(o.every(function(t){return e.opts.strictKeywords?typeof t==`object`&&Object.keys(t).length>0||t===!1:e.util.schemaHasRules(t,e.RULES.all)})){var g=p.baseId;r+=` var `+f+` = errors; var `+d+` = false; `;var _=e.compositeRule;e.compositeRule=p.compositeRule=!0;var v=o;if(v)for(var y,b=-1,x=v.length-1;b<x;)y=v[b+=1],p.schema=y,p.schemaPath=s+`[`+b+`]`,p.errSchemaPath=c+`/`+b,r+=` `+e.validate(p)+` `,p.baseId=g,r+=` `+d+` = `+d+` || `+h+`; if (!`+d+`) { `,m+=`}`;e.compositeRule=p.compositeRule=_,r+=` `+m+` if (!`+d+`) { var err = `,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'anyOf' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: {} `,e.opts.messages!==!1&&(r+=` , message: 'should match some schema in anyOf' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `),r+=`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,!e.compositeRule&&l&&(e.async?r+=` throw new ValidationError(vErrors); `:r+=` validate.errors = vErrors; return false; `),r+=` } else { errors = `+f+`; if (vErrors !== null) { if (`+f+`) vErrors.length = `+f+`; else vErrors = null; } `,e.opts.allErrors&&(r+=` } `)}else l&&(r+=` if (true) { `);return r}})),Ii=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.schema[t],a=e.errSchemaPath+`/`+t;e.opts.allErrors;var o=e.util.toQuotedString(i);return e.opts.$comment===!0?r+=` console.log(`+o+`);`:typeof e.opts.$comment==`function`&&(r+=` self._opts.$comment(`+o+`, `+e.util.toQuotedString(a)+`, validate.root.schema);`),r}})),Li=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`valid`+i,f=e.opts.$data&&o&&o.$data;f&&(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,``+i),f||(r+=` var schema`+i+` = validate.schema`+s+`;`),r+=`var `+d+` = equal(`+u+`, schema`+i+`); if (!`+d+`) { `;var p=p||[];p.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'const' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { allowedValue: schema`+i+` } `,e.opts.messages!==!1&&(r+=` , message: 'should be equal to constant' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var m=r;return r=p.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+m+`]); `:r+=` validate.errors = [`+m+`]; return false; `:r+=` var err = `+m+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` }`,l&&(r+=` else { `),r}})),Ri=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`valid`+i,f=`errs__`+i,p=e.util.copy(e),m=``;p.level++;var h=`valid`+p.level,g=`i`+i,_=p.dataLevel=e.dataLevel+1,v=`data`+_,y=e.baseId,b=e.opts.strictKeywords?typeof o==`object`&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all);if(r+=`var `+f+` = errors;var `+d+`;`,b){var x=e.compositeRule;e.compositeRule=p.compositeRule=!0,p.schema=o,p.schemaPath=s,p.errSchemaPath=c,r+=` var `+h+` = false; for (var `+g+` = 0; `+g+` < `+u+`.length; `+g+`++) { `,p.errorPath=e.util.getPathExpr(e.errorPath,g,e.opts.jsonPointers,!0);var S=u+`[`+g+`]`;p.dataPathArr[_]=g;var C=e.validate(p);p.baseId=y,e.util.varOccurences(C,v)<2?r+=` `+e.util.varReplace(C,v,S)+` `:r+=` var `+v+` = `+S+`; `+C+` `,r+=` if (`+h+`) break; } `,e.compositeRule=p.compositeRule=x,r+=` `+m+` if (!`+h+`) {`}else r+=` if (`+u+`.length == 0) {`;var w=w||[];w.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'contains' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: {} `,e.opts.messages!==!1&&(r+=` , message: 'should contain a valid item' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var T=r;return r=w.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+T+`]); `:r+=` validate.errors = [`+T+`]; return false; `:r+=` var err = `+T+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } else { `,b&&(r+=` errors = `+f+`; if (vErrors !== null) { if (`+f+`) vErrors.length = `+f+`; else vErrors = null; } `),e.opts.allErrors&&(r+=` } `),r}})),zi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`errs__`+i,f=e.util.copy(e),p=``;f.level++;var m=`valid`+f.level,h={},g={},_=e.opts.ownProperties;for(x in o)if(x!=`__proto__`){var v=o[x],y=Array.isArray(v)?g:h;y[x]=v}r+=`var `+d+` = errors;`;var b=e.errorPath;for(var x in r+=`var missing`+i+`;`,g)if(y=g[x],y.length){if(r+=` if ( `+u+e.util.getProperty(x)+` !== undefined `,_&&(r+=` && Object.prototype.hasOwnProperty.call(`+u+`, '`+e.util.escapeQuotes(x)+`') `),l){r+=` && ( `;var S=y;if(S)for(var C,w=-1,T=S.length-1;w<T;){C=S[w+=1],w&&(r+=` || `);var E=e.util.getProperty(C),D=u+E;r+=` ( ( `+D+` === undefined `,_&&(r+=` || ! Object.prototype.hasOwnProperty.call(`+u+`, '`+e.util.escapeQuotes(C)+`') `),r+=`) && (missing`+i+` = `+e.util.toQuotedString(e.opts.jsonPointers?C:E)+`) ) `}r+=`)) { `;var O=`missing`+i,k=`' + `+O+` + '`;e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(b,O,!0):b+` + `+O);var A=A||[];A.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'dependencies' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { property: '`+e.util.escapeQuotes(x)+`', missingProperty: '`+k+`', depsCount: `+y.length+`, deps: '`+e.util.escapeQuotes(y.length==1?y[0]:y.join(`, `))+`' } `,e.opts.messages!==!1&&(r+=` , message: 'should have `,y.length==1?r+=`property `+e.util.escapeQuotes(y[0]):r+=`properties `+e.util.escapeQuotes(y.join(`, `)),r+=` when property `+e.util.escapeQuotes(x)+` is present' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var j=r;r=A.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+j+`]); `:r+=` validate.errors = [`+j+`]; return false; `:r+=` var err = `+j+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `}else{r+=` ) { `;var M=y;if(M)for(var C,N=-1,P=M.length-1;N<P;){C=M[N+=1];var E=e.util.getProperty(C),k=e.util.escapeQuotes(C),D=u+E;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(b,C,e.opts.jsonPointers)),r+=` if ( `+D+` === undefined `,_&&(r+=` || ! Object.prototype.hasOwnProperty.call(`+u+`, '`+e.util.escapeQuotes(C)+`') `),r+=`) { var err = `,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'dependencies' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { property: '`+e.util.escapeQuotes(x)+`', missingProperty: '`+k+`', depsCount: `+y.length+`, deps: '`+e.util.escapeQuotes(y.length==1?y[0]:y.join(`, `))+`' } `,e.opts.messages!==!1&&(r+=` , message: 'should have `,y.length==1?r+=`property `+e.util.escapeQuotes(y[0]):r+=`properties `+e.util.escapeQuotes(y.join(`, `)),r+=` when property `+e.util.escapeQuotes(x)+` is present' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `),r+=`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } `}}r+=` } `,l&&(p+=`}`,r+=` else { `)}e.errorPath=b;var F=f.baseId;for(var x in h){var v=h[x];(e.opts.strictKeywords?typeof v==`object`&&Object.keys(v).length>0||v===!1:e.util.schemaHasRules(v,e.RULES.all))&&(r+=` `+m+` = true; if ( `+u+e.util.getProperty(x)+` !== undefined `,_&&(r+=` && Object.prototype.hasOwnProperty.call(`+u+`, '`+e.util.escapeQuotes(x)+`') `),r+=`) { `,f.schema=v,f.schemaPath=s+e.util.getProperty(x),f.errSchemaPath=c+`/`+e.util.escapeFragment(x),r+=` `+e.validate(f)+` `,f.baseId=F,r+=` } `,l&&(r+=` if (`+m+`) { `,p+=`}`))}return l&&(r+=` `+p+` if (`+d+` == errors) {`),r}})),Bi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`valid`+i,f=e.opts.$data&&o&&o.$data;f&&(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,``+i);var p=`i`+i,m=`schema`+i;f||(r+=` var `+m+` = validate.schema`+s+`;`),r+=`var `+d+`;`,f&&(r+=` if (schema`+i+` === undefined) `+d+` = true; else if (!Array.isArray(schema`+i+`)) `+d+` = false; else {`),r+=``+d+` = false;for (var `+p+`=0; `+p+`<`+m+`.length; `+p+`++) if (equal(`+u+`, `+m+`[`+p+`])) { `+d+` = true; break; }`,f&&(r+=` } `),r+=` if (!`+d+`) { `;var h=h||[];h.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'enum' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { allowedValues: schema`+i+` } `,e.opts.messages!==!1&&(r+=` , message: 'should be equal to one of the allowed values' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var g=r;return r=h.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+g+`]); `:r+=` validate.errors = [`+g+`]; return false; `:r+=` var err = `+g+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` }`,l&&(r+=` else { `),r}})),Vi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``);if(e.opts.format===!1)return l&&(r+=` if (true) { `),r;var d=e.opts.$data&&o&&o.$data,f;d?(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,f=`schema`+i):f=o;var p=e.opts.unknownFormats,m=Array.isArray(p);if(d){var h=`format`+i,g=`isObject`+i,_=`formatType`+i;r+=` var `+h+` = formats[`+f+`]; var `+g+` = typeof `+h+` == 'object' && !(`+h+` instanceof RegExp) && `+h+`.validate; var `+_+` = `+g+` && `+h+`.type || 'string'; if (`+g+`) { `,e.async&&(r+=` var async`+i+` = `+h+`.async; `),r+=` `+h+` = `+h+`.validate; } if ( `,d&&(r+=` (`+f+` !== undefined && typeof `+f+` != 'string') || `),r+=` (`,p!=`ignore`&&(r+=` (`+f+` && !`+h+` `,m&&(r+=` && self._opts.unknownFormats.indexOf(`+f+`) == -1 `),r+=`) || `),r+=` (`+h+` && `+_+` == '`+n+`' && !(typeof `+h+` == 'function' ? `,e.async?r+=` (async`+i+` ? await `+h+`(`+u+`) : `+h+`(`+u+`)) `:r+=` `+h+`(`+u+`) `,r+=` : `+h+`.test(`+u+`))))) {`}else{var h=e.formats[o];if(!h){if(p==`ignore`)return e.logger.warn(`unknown format "`+o+`" ignored in schema at path "`+e.errSchemaPath+`"`),l&&(r+=` if (true) { `),r;if(m&&p.indexOf(o)>=0)return l&&(r+=` if (true) { `),r;throw Error(`unknown format "`+o+`" is used in schema at path "`+e.errSchemaPath+`"`)}var g=typeof h==`object`&&!(h instanceof RegExp)&&h.validate,_=g&&h.type||`string`;if(g){var v=h.async===!0;h=h.validate}if(_!=n)return l&&(r+=` if (true) { `),r;if(v){if(!e.async)throw Error(`async format in sync schema`);var y=`formats`+e.util.getProperty(o)+`.validate`;r+=` if (!(await `+y+`(`+u+`))) { `}else{r+=` if (! `;var y=`formats`+e.util.getProperty(o);g&&(y+=`.validate`),typeof h==`function`?r+=` `+y+`(`+u+`) `:r+=` `+y+`.test(`+u+`) `,r+=`) { `}}var b=b||[];b.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'format' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { format: `,d?r+=``+f:r+=``+e.util.toQuotedString(o),r+=` } `,e.opts.messages!==!1&&(r+=` , message: 'should match format "`,d?r+=`' + `+f+` + '`:r+=``+e.util.escapeQuotes(o),r+=`"' `),e.opts.verbose&&(r+=` , schema: `,d?r+=`validate.schema`+s:r+=``+e.util.toQuotedString(o),r+=` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var x=r;return r=b.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+x+`]); `:r+=` validate.errors = [`+x+`]; return false; `:r+=` var err = `+x+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } `,l&&(r+=` else { `),r}})),Hi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`valid`+i,f=`errs__`+i,p=e.util.copy(e);p.level++;var m=`valid`+p.level,h=e.schema.then,g=e.schema.else,_=h!==void 0&&(e.opts.strictKeywords?typeof h==`object`&&Object.keys(h).length>0||h===!1:e.util.schemaHasRules(h,e.RULES.all)),v=g!==void 0&&(e.opts.strictKeywords?typeof g==`object`&&Object.keys(g).length>0||g===!1:e.util.schemaHasRules(g,e.RULES.all)),y=p.baseId;if(_||v){var b;p.createErrors=!1,p.schema=o,p.schemaPath=s,p.errSchemaPath=c,r+=` var `+f+` = errors; var `+d+` = true; `;var x=e.compositeRule;e.compositeRule=p.compositeRule=!0,r+=` `+e.validate(p)+` `,p.baseId=y,p.createErrors=!0,r+=` errors = `+f+`; if (vErrors !== null) { if (`+f+`) vErrors.length = `+f+`; else vErrors = null; } `,e.compositeRule=p.compositeRule=x,_?(r+=` if (`+m+`) { `,p.schema=e.schema.then,p.schemaPath=e.schemaPath+`.then`,p.errSchemaPath=e.errSchemaPath+`/then`,r+=` `+e.validate(p)+` `,p.baseId=y,r+=` `+d+` = `+m+`; `,_&&v?(b=`ifClause`+i,r+=` var `+b+` = 'then'; `):b=`'then'`,r+=` } `,v&&(r+=` else { `)):r+=` if (!`+m+`) { `,v&&(p.schema=e.schema.else,p.schemaPath=e.schemaPath+`.else`,p.errSchemaPath=e.errSchemaPath+`/else`,r+=` `+e.validate(p)+` `,p.baseId=y,r+=` `+d+` = `+m+`; `,_&&v?(b=`ifClause`+i,r+=` var `+b+` = 'else'; `):b=`'else'`,r+=` } `),r+=` if (!`+d+`) { var err = `,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'if' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { failingKeyword: `+b+` } `,e.opts.messages!==!1&&(r+=` , message: 'should match "' + `+b+` + '" schema' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `),r+=`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,!e.compositeRule&&l&&(e.async?r+=` throw new ValidationError(vErrors); `:r+=` validate.errors = vErrors; return false; `),r+=` } `,l&&(r+=` else { `)}else l&&(r+=` if (true) { `);return r}})),Ui=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`valid`+i,f=`errs__`+i,p=e.util.copy(e),m=``;p.level++;var h=`valid`+p.level,g=`i`+i,_=p.dataLevel=e.dataLevel+1,v=`data`+_,y=e.baseId;if(r+=`var `+f+` = errors;var `+d+`;`,Array.isArray(o)){var b=e.schema.additionalItems;if(b===!1){r+=` `+d+` = `+u+`.length <= `+o.length+`; `;var x=c;c=e.errSchemaPath+`/additionalItems`,r+=` if (!`+d+`) { `;var S=S||[];S.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'additionalItems' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { limit: `+o.length+` } `,e.opts.messages!==!1&&(r+=` , message: 'should NOT have more than `+o.length+` items' `),e.opts.verbose&&(r+=` , schema: false , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var C=r;r=S.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+C+`]); `:r+=` validate.errors = [`+C+`]; return false; `:r+=` var err = `+C+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } `,c=x,l&&(m+=`}`,r+=` else { `)}var w=o;if(w){for(var T,E=-1,D=w.length-1;E<D;)if(T=w[E+=1],e.opts.strictKeywords?typeof T==`object`&&Object.keys(T).length>0||T===!1:e.util.schemaHasRules(T,e.RULES.all)){r+=` `+h+` = true; if (`+u+`.length > `+E+`) { `;var O=u+`[`+E+`]`;p.schema=T,p.schemaPath=s+`[`+E+`]`,p.errSchemaPath=c+`/`+E,p.errorPath=e.util.getPathExpr(e.errorPath,E,e.opts.jsonPointers,!0),p.dataPathArr[_]=E;var k=e.validate(p);p.baseId=y,e.util.varOccurences(k,v)<2?r+=` `+e.util.varReplace(k,v,O)+` `:r+=` var `+v+` = `+O+`; `+k+` `,r+=` } `,l&&(r+=` if (`+h+`) { `,m+=`}`)}}if(typeof b==`object`&&(e.opts.strictKeywords?typeof b==`object`&&Object.keys(b).length>0||b===!1:e.util.schemaHasRules(b,e.RULES.all))){p.schema=b,p.schemaPath=e.schemaPath+`.additionalItems`,p.errSchemaPath=e.errSchemaPath+`/additionalItems`,r+=` `+h+` = true; if (`+u+`.length > `+o.length+`) { for (var `+g+` = `+o.length+`; `+g+` < `+u+`.length; `+g+`++) { `,p.errorPath=e.util.getPathExpr(e.errorPath,g,e.opts.jsonPointers,!0);var O=u+`[`+g+`]`;p.dataPathArr[_]=g;var k=e.validate(p);p.baseId=y,e.util.varOccurences(k,v)<2?r+=` `+e.util.varReplace(k,v,O)+` `:r+=` var `+v+` = `+O+`; `+k+` `,l&&(r+=` if (!`+h+`) break; `),r+=` } } `,l&&(r+=` if (`+h+`) { `,m+=`}`)}}else if(e.opts.strictKeywords?typeof o==`object`&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all)){p.schema=o,p.schemaPath=s,p.errSchemaPath=c,r+=` for (var `+g+` = 0; `+g+` < `+u+`.length; `+g+`++) { `,p.errorPath=e.util.getPathExpr(e.errorPath,g,e.opts.jsonPointers,!0);var O=u+`[`+g+`]`;p.dataPathArr[_]=g;var k=e.validate(p);p.baseId=y,e.util.varOccurences(k,v)<2?r+=` `+e.util.varReplace(k,v,O)+` `:r+=` var `+v+` = `+O+`; `+k+` `,l&&(r+=` if (!`+h+`) break; `),r+=` }`}return l&&(r+=` `+m+` if (`+f+` == errors) {`),r}})),Wi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u,d=`data`+(a||``),f=e.opts.$data&&o&&o.$data,p;f?(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,p=`schema`+i):p=o;var m=t==`maximum`,h=m?`exclusiveMaximum`:`exclusiveMinimum`,g=e.schema[h],_=e.opts.$data&&g&&g.$data,v=m?`<`:`>`,y=m?`>`:`<`,u=void 0;if(!(f||typeof o==`number`||o===void 0))throw Error(t+` must be number`);if(!(_||g===void 0||typeof g==`number`||typeof g==`boolean`))throw Error(h+` must be number or boolean`);if(_){var b=e.util.getData(g.$data,a,e.dataPathArr),x=`exclusive`+i,S=`exclType`+i,C=`exclIsNumber`+i,w=`op`+i,T=`' + `+w+` + '`;r+=` var schemaExcl`+i+` = `+b+`; `,b=`schemaExcl`+i,r+=` var `+x+`; var `+S+` = typeof `+b+`; if (`+S+` != 'boolean' && `+S+` != 'undefined' && `+S+` != 'number') { `;var u=h,E=E||[];E.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(u||`_exclusiveLimit`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: {} `,e.opts.messages!==!1&&(r+=` , message: '`+h+` should be boolean' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+d+` `),r+=` } `);var D=r;r=E.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+D+`]); `:r+=` validate.errors = [`+D+`]; return false; `:r+=` var err = `+D+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } else if ( `,f&&(r+=` (`+p+` !== undefined && typeof `+p+` != 'number') || `),r+=` `+S+` == 'number' ? ( (`+x+` = `+p+` === undefined || `+b+` `+v+`= `+p+`) ? `+d+` `+y+`= `+b+` : `+d+` `+y+` `+p+` ) : ( (`+x+` = `+b+` === true) ? `+d+` `+y+`= `+p+` : `+d+` `+y+` `+p+` ) || `+d+` !== `+d+`) { var op`+i+` = `+x+` ? '`+v+`' : '`+v+`='; `,o===void 0&&(u=h,c=e.errSchemaPath+`/`+h,p=b,f=_)}else{var C=typeof g==`number`,T=v;if(C&&f){var w=`'`+T+`'`;r+=` if ( `,f&&(r+=` (`+p+` !== undefined && typeof `+p+` != 'number') || `),r+=` ( `+p+` === undefined || `+g+` `+v+`= `+p+` ? `+d+` `+y+`= `+g+` : `+d+` `+y+` `+p+` ) || `+d+` !== `+d+`) { `}else{C&&o===void 0?(x=!0,u=h,c=e.errSchemaPath+`/`+h,p=g,y+=`=`):(C&&(p=Math[m?`min`:`max`](g,o)),g===(C?p:!0)?(x=!0,u=h,c=e.errSchemaPath+`/`+h,y+=`=`):(x=!1,T+=`=`));var w=`'`+T+`'`;r+=` if ( `,f&&(r+=` (`+p+` !== undefined && typeof `+p+` != 'number') || `),r+=` `+d+` `+y+` `+p+` || `+d+` !== `+d+`) { `}}u||=t;var E=E||[];E.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(u||`_limit`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { comparison: `+w+`, limit: `+p+`, exclusive: `+x+` } `,e.opts.messages!==!1&&(r+=` , message: 'should be `+T+` `,f?r+=`' + `+p:r+=``+p+`'`),e.opts.verbose&&(r+=` , schema: `,f?r+=`validate.schema`+s:r+=``+o,r+=` , parentSchema: validate.schema`+e.schemaPath+` , data: `+d+` `),r+=` } `);var D=r;return r=E.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+D+`]); `:r+=` validate.errors = [`+D+`]; return false; `:r+=` var err = `+D+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } `,l&&(r+=` else { `),r}})),Gi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u,d=`data`+(a||``),f=e.opts.$data&&o&&o.$data,p;if(f?(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,p=`schema`+i):p=o,!(f||typeof o==`number`))throw Error(t+` must be number`);var m=t==`maxItems`?`>`:`<`;r+=`if ( `,f&&(r+=` (`+p+` !== undefined && typeof `+p+` != 'number') || `),r+=` `+d+`.length `+m+` `+p+`) { `;var u=t,h=h||[];h.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(u||`_limitItems`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { limit: `+p+` } `,e.opts.messages!==!1&&(r+=` , message: 'should NOT have `,t==`maxItems`?r+=`more`:r+=`fewer`,r+=` than `,f?r+=`' + `+p+` + '`:r+=``+o,r+=` items' `),e.opts.verbose&&(r+=` , schema: `,f?r+=`validate.schema`+s:r+=``+o,r+=` , parentSchema: validate.schema`+e.schemaPath+` , data: `+d+` `),r+=` } `);var g=r;return r=h.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+g+`]); `:r+=` validate.errors = [`+g+`]; return false; `:r+=` var err = `+g+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=`} `,l&&(r+=` else { `),r}})),Ki=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u,d=`data`+(a||``),f=e.opts.$data&&o&&o.$data,p;if(f?(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,p=`schema`+i):p=o,!(f||typeof o==`number`))throw Error(t+` must be number`);var m=t==`maxLength`?`>`:`<`;r+=`if ( `,f&&(r+=` (`+p+` !== undefined && typeof `+p+` != 'number') || `),e.opts.unicode===!1?r+=` `+d+`.length `:r+=` ucs2length(`+d+`) `,r+=` `+m+` `+p+`) { `;var u=t,h=h||[];h.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(u||`_limitLength`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { limit: `+p+` } `,e.opts.messages!==!1&&(r+=` , message: 'should NOT be `,t==`maxLength`?r+=`longer`:r+=`shorter`,r+=` than `,f?r+=`' + `+p+` + '`:r+=``+o,r+=` characters' `),e.opts.verbose&&(r+=` , schema: `,f?r+=`validate.schema`+s:r+=``+o,r+=` , parentSchema: validate.schema`+e.schemaPath+` , data: `+d+` `),r+=` } `);var g=r;return r=h.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+g+`]); `:r+=` validate.errors = [`+g+`]; return false; `:r+=` var err = `+g+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=`} `,l&&(r+=` else { `),r}})),qi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u,d=`data`+(a||``),f=e.opts.$data&&o&&o.$data,p;if(f?(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,p=`schema`+i):p=o,!(f||typeof o==`number`))throw Error(t+` must be number`);var m=t==`maxProperties`?`>`:`<`;r+=`if ( `,f&&(r+=` (`+p+` !== undefined && typeof `+p+` != 'number') || `),r+=` Object.keys(`+d+`).length `+m+` `+p+`) { `;var u=t,h=h||[];h.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(u||`_limitProperties`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { limit: `+p+` } `,e.opts.messages!==!1&&(r+=` , message: 'should NOT have `,t==`maxProperties`?r+=`more`:r+=`fewer`,r+=` than `,f?r+=`' + `+p+` + '`:r+=``+o,r+=` properties' `),e.opts.verbose&&(r+=` , schema: `,f?r+=`validate.schema`+s:r+=``+o,r+=` , parentSchema: validate.schema`+e.schemaPath+` , data: `+d+` `),r+=` } `);var g=r;return r=h.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+g+`]); `:r+=` validate.errors = [`+g+`]; return false; `:r+=` var err = `+g+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=`} `,l&&(r+=` else { `),r}})),Ji=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=e.opts.$data&&o&&o.$data,f;if(d?(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,f=`schema`+i):f=o,!(d||typeof o==`number`))throw Error(t+` must be number`);r+=`var division`+i+`;if (`,d&&(r+=` `+f+` !== undefined && ( typeof `+f+` != 'number' || `),r+=` (division`+i+` = `+u+` / `+f+`, `,e.opts.multipleOfPrecision?r+=` Math.abs(Math.round(division`+i+`) - division`+i+`) > 1e-`+e.opts.multipleOfPrecision+` `:r+=` division`+i+` !== parseInt(division`+i+`) `,r+=` ) `,d&&(r+=` ) `),r+=` ) { `;var p=p||[];p.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'multipleOf' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { multipleOf: `+f+` } `,e.opts.messages!==!1&&(r+=` , message: 'should be multiple of `,d?r+=`' + `+f:r+=``+f+`'`),e.opts.verbose&&(r+=` , schema: `,d?r+=`validate.schema`+s:r+=``+o,r+=` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var m=r;return r=p.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+m+`]); `:r+=` validate.errors = [`+m+`]; return false; `:r+=` var err = `+m+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=`} `,l&&(r+=` else { `),r}})),Yi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`errs__`+i,f=e.util.copy(e);f.level++;var p=`valid`+f.level;if(e.opts.strictKeywords?typeof o==`object`&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all)){f.schema=o,f.schemaPath=s,f.errSchemaPath=c,r+=` var `+d+` = errors; `;var m=e.compositeRule;e.compositeRule=f.compositeRule=!0,f.createErrors=!1;var h;f.opts.allErrors&&(h=f.opts.allErrors,f.opts.allErrors=!1),r+=` `+e.validate(f)+` `,f.createErrors=!0,h&&(f.opts.allErrors=h),e.compositeRule=f.compositeRule=m,r+=` if (`+p+`) { `;var g=g||[];g.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'not' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: {} `,e.opts.messages!==!1&&(r+=` , message: 'should NOT be valid' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var _=r;r=g.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+_+`]); `:r+=` validate.errors = [`+_+`]; return false; `:r+=` var err = `+_+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } else { errors = `+d+`; if (vErrors !== null) { if (`+d+`) vErrors.length = `+d+`; else vErrors = null; } `,e.opts.allErrors&&(r+=` } `)}else r+=` var err = `,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'not' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: {} `,e.opts.messages!==!1&&(r+=` , message: 'should NOT be valid' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `),r+=`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,l&&(r+=` if (false) { `);return r}})),Xi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`valid`+i,f=`errs__`+i,p=e.util.copy(e),m=``;p.level++;var h=`valid`+p.level,g=p.baseId,_=`prevValid`+i,v=`passingSchemas`+i;r+=`var `+f+` = errors , `+_+` = false , `+d+` = false , `+v+` = null; `;var y=e.compositeRule;e.compositeRule=p.compositeRule=!0;var b=o;if(b)for(var x,S=-1,C=b.length-1;S<C;)x=b[S+=1],(e.opts.strictKeywords?typeof x==`object`&&Object.keys(x).length>0||x===!1:e.util.schemaHasRules(x,e.RULES.all))?(p.schema=x,p.schemaPath=s+`[`+S+`]`,p.errSchemaPath=c+`/`+S,r+=` `+e.validate(p)+` `,p.baseId=g):r+=` var `+h+` = true; `,S&&(r+=` if (`+h+` && `+_+`) { `+d+` = false; `+v+` = [`+v+`, `+S+`]; } else { `,m+=`}`),r+=` if (`+h+`) { `+d+` = `+_+` = true; `+v+` = `+S+`; }`;return e.compositeRule=p.compositeRule=y,r+=``+m+`if (!`+d+`) { var err = `,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'oneOf' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { passingSchemas: `+v+` } `,e.opts.messages!==!1&&(r+=` , message: 'should match exactly one schema in oneOf' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `),r+=`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,!e.compositeRule&&l&&(e.async?r+=` throw new ValidationError(vErrors); `:r+=` validate.errors = vErrors; return false; `),r+=`} else { errors = `+f+`; if (vErrors !== null) { if (`+f+`) vErrors.length = `+f+`; else vErrors = null; }`,e.opts.allErrors&&(r+=` } `),r}})),Zi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=e.opts.$data&&o&&o.$data,f;d?(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,f=`schema`+i):f=o;var p=d?`(new RegExp(`+f+`))`:e.usePattern(o);r+=`if ( `,d&&(r+=` (`+f+` !== undefined && typeof `+f+` != 'string') || `),r+=` !`+p+`.test(`+u+`) ) { `;var m=m||[];m.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'pattern' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { pattern: `,d?r+=``+f:r+=``+e.util.toQuotedString(o),r+=` } `,e.opts.messages!==!1&&(r+=` , message: 'should match pattern "`,d?r+=`' + `+f+` + '`:r+=``+e.util.escapeQuotes(o),r+=`"' `),e.opts.verbose&&(r+=` , schema: `,d?r+=`validate.schema`+s:r+=``+e.util.toQuotedString(o),r+=` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var h=r;return r=m.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+h+`]); `:r+=` validate.errors = [`+h+`]; return false; `:r+=` var err = `+h+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=`} `,l&&(r+=` else { `),r}})),Qi=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`errs__`+i,f=e.util.copy(e),p=``;f.level++;var m=`valid`+f.level,h=`key`+i,g=`idx`+i,_=f.dataLevel=e.dataLevel+1,v=`data`+_,y=`dataProperties`+i,b=Object.keys(o||{}).filter(N),x=e.schema.patternProperties||{},S=Object.keys(x).filter(N),C=e.schema.additionalProperties,w=b.length||S.length,T=C===!1,E=typeof C==`object`&&Object.keys(C).length,D=e.opts.removeAdditional,O=T||E||D,k=e.opts.ownProperties,A=e.baseId,j=e.schema.required;if(j&&!(e.opts.$data&&j.$data)&&j.length<e.opts.loopRequired)var M=e.util.toHash(j);function N(e){return e!==`__proto__`}if(r+=`var `+d+` = errors;var `+m+` = true;`,k&&(r+=` var `+y+` = undefined;`),O){if(k?r+=` `+y+` = `+y+` || Object.keys(`+u+`); for (var `+g+`=0; `+g+`<`+y+`.length; `+g+`++) { var `+h+` = `+y+`[`+g+`]; `:r+=` for (var `+h+` in `+u+`) { `,w){if(r+=` var isAdditional`+i+` = !(false `,b.length)if(b.length>8)r+=` || validate.schema`+s+`.hasOwnProperty(`+h+`) `;else{var P=b;if(P)for(var F,ee=-1,I=P.length-1;ee<I;)F=P[ee+=1],r+=` || `+h+` == `+e.util.toQuotedString(F)+` `}if(S.length){var L=S;if(L)for(var R,z=-1,te=L.length-1;z<te;)R=L[z+=1],r+=` || `+e.usePattern(R)+`.test(`+h+`) `}r+=` ); if (isAdditional`+i+`) { `}if(D==`all`)r+=` delete `+u+`[`+h+`]; `;else{var ne=e.errorPath,re=`' + `+h+` + '`;if(e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(e.errorPath,h,e.opts.jsonPointers)),T)if(D)r+=` delete `+u+`[`+h+`]; `;else{r+=` `+m+` = false; `;var ie=c;c=e.errSchemaPath+`/additionalProperties`;var B=B||[];B.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'additionalProperties' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { additionalProperty: '`+re+`' } `,e.opts.messages!==!1&&(r+=` , message: '`,e.opts._errorDataPathProperty?r+=`is an invalid additional property`:r+=`should NOT have additional properties`,r+=`' `),e.opts.verbose&&(r+=` , schema: false , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var ae=r;r=B.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+ae+`]); `:r+=` validate.errors = [`+ae+`]; return false; `:r+=` var err = `+ae+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,c=ie,l&&(r+=` break; `)}else if(E)if(D==`failing`){r+=` var `+d+` = errors; `;var oe=e.compositeRule;e.compositeRule=f.compositeRule=!0,f.schema=C,f.schemaPath=e.schemaPath+`.additionalProperties`,f.errSchemaPath=e.errSchemaPath+`/additionalProperties`,f.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,h,e.opts.jsonPointers);var V=u+`[`+h+`]`;f.dataPathArr[_]=h;var H=e.validate(f);f.baseId=A,e.util.varOccurences(H,v)<2?r+=` `+e.util.varReplace(H,v,V)+` `:r+=` var `+v+` = `+V+`; `+H+` `,r+=` if (!`+m+`) { errors = `+d+`; if (validate.errors !== null) { if (errors) validate.errors.length = errors; else validate.errors = null; } delete `+u+`[`+h+`]; } `,e.compositeRule=f.compositeRule=oe}else{f.schema=C,f.schemaPath=e.schemaPath+`.additionalProperties`,f.errSchemaPath=e.errSchemaPath+`/additionalProperties`,f.errorPath=e.opts._errorDataPathProperty?e.errorPath:e.util.getPathExpr(e.errorPath,h,e.opts.jsonPointers);var V=u+`[`+h+`]`;f.dataPathArr[_]=h;var H=e.validate(f);f.baseId=A,e.util.varOccurences(H,v)<2?r+=` `+e.util.varReplace(H,v,V)+` `:r+=` var `+v+` = `+V+`; `+H+` `,l&&(r+=` if (!`+m+`) break; `)}e.errorPath=ne}w&&(r+=` } `),r+=` } `,l&&(r+=` if (`+m+`) { `,p+=`}`)}var se=e.opts.useDefaults&&!e.compositeRule;if(b.length){var ce=b;if(ce)for(var F,le=-1,ue=ce.length-1;le<ue;){F=ce[le+=1];var U=o[F];if(e.opts.strictKeywords?typeof U==`object`&&Object.keys(U).length>0||U===!1:e.util.schemaHasRules(U,e.RULES.all)){var de=e.util.getProperty(F),V=u+de,fe=se&&U.default!==void 0;f.schema=U,f.schemaPath=s+de,f.errSchemaPath=c+`/`+e.util.escapeFragment(F),f.errorPath=e.util.getPath(e.errorPath,F,e.opts.jsonPointers),f.dataPathArr[_]=e.util.toQuotedString(F);var H=e.validate(f);if(f.baseId=A,e.util.varOccurences(H,v)<2){H=e.util.varReplace(H,v,V);var pe=V}else{var pe=v;r+=` var `+v+` = `+V+`; `}if(fe)r+=` `+H+` `;else{if(M&&M[F]){r+=` if ( `+pe+` === undefined `,k&&(r+=` || ! Object.prototype.hasOwnProperty.call(`+u+`, '`+e.util.escapeQuotes(F)+`') `),r+=`) { `+m+` = false; `;var ne=e.errorPath,ie=c,me=e.util.escapeQuotes(F);e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(ne,F,e.opts.jsonPointers)),c=e.errSchemaPath+`/required`;var B=B||[];B.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'required' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { missingProperty: '`+me+`' } `,e.opts.messages!==!1&&(r+=` , message: '`,e.opts._errorDataPathProperty?r+=`is a required property`:r+=`should have required property \\'`+me+`\\'`,r+=`' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var ae=r;r=B.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+ae+`]); `:r+=` validate.errors = [`+ae+`]; return false; `:r+=` var err = `+ae+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,c=ie,e.errorPath=ne,r+=` } else { `}else l?(r+=` if ( `+pe+` === undefined `,k&&(r+=` || ! Object.prototype.hasOwnProperty.call(`+u+`, '`+e.util.escapeQuotes(F)+`') `),r+=`) { `+m+` = true; } else { `):(r+=` if (`+pe+` !== undefined `,k&&(r+=` && Object.prototype.hasOwnProperty.call(`+u+`, '`+e.util.escapeQuotes(F)+`') `),r+=` ) { `);r+=` `+H+` } `}}l&&(r+=` if (`+m+`) { `,p+=`}`)}}if(S.length){var he=S;if(he)for(var R,ge=-1,_e=he.length-1;ge<_e;){R=he[ge+=1];var U=x[R];if(e.opts.strictKeywords?typeof U==`object`&&Object.keys(U).length>0||U===!1:e.util.schemaHasRules(U,e.RULES.all)){f.schema=U,f.schemaPath=e.schemaPath+`.patternProperties`+e.util.getProperty(R),f.errSchemaPath=e.errSchemaPath+`/patternProperties/`+e.util.escapeFragment(R),k?r+=` `+y+` = `+y+` || Object.keys(`+u+`); for (var `+g+`=0; `+g+`<`+y+`.length; `+g+`++) { var `+h+` = `+y+`[`+g+`]; `:r+=` for (var `+h+` in `+u+`) { `,r+=` if (`+e.usePattern(R)+`.test(`+h+`)) { `,f.errorPath=e.util.getPathExpr(e.errorPath,h,e.opts.jsonPointers);var V=u+`[`+h+`]`;f.dataPathArr[_]=h;var H=e.validate(f);f.baseId=A,e.util.varOccurences(H,v)<2?r+=` `+e.util.varReplace(H,v,V)+` `:r+=` var `+v+` = `+V+`; `+H+` `,l&&(r+=` if (!`+m+`) break; `),r+=` } `,l&&(r+=` else `+m+` = true; `),r+=` } `,l&&(r+=` if (`+m+`) { `,p+=`}`)}}}return l&&(r+=` `+p+` if (`+d+` == errors) {`),r}})),$i=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`errs__`+i,f=e.util.copy(e),p=``;f.level++;var m=`valid`+f.level;if(r+=`var `+d+` = errors;`,e.opts.strictKeywords?typeof o==`object`&&Object.keys(o).length>0||o===!1:e.util.schemaHasRules(o,e.RULES.all)){f.schema=o,f.schemaPath=s,f.errSchemaPath=c;var h=`key`+i,g=`idx`+i,_=`i`+i,v=`' + `+h+` + '`,y=`data`+(f.dataLevel=e.dataLevel+1),b=`dataProperties`+i,x=e.opts.ownProperties,S=e.baseId;x&&(r+=` var `+b+` = undefined; `),x?r+=` `+b+` = `+b+` || Object.keys(`+u+`); for (var `+g+`=0; `+g+`<`+b+`.length; `+g+`++) { var `+h+` = `+b+`[`+g+`]; `:r+=` for (var `+h+` in `+u+`) { `,r+=` var startErrs`+i+` = errors; `;var C=h,w=e.compositeRule;e.compositeRule=f.compositeRule=!0;var T=e.validate(f);f.baseId=S,e.util.varOccurences(T,y)<2?r+=` `+e.util.varReplace(T,y,C)+` `:r+=` var `+y+` = `+C+`; `+T+` `,e.compositeRule=f.compositeRule=w,r+=` if (!`+m+`) { for (var `+_+`=startErrs`+i+`; `+_+`<errors; `+_+`++) { vErrors[`+_+`].propertyName = `+h+`; } var err = `,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'propertyNames' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { propertyName: '`+v+`' } `,e.opts.messages!==!1&&(r+=` , message: 'property name \\'`+v+`\\' is invalid' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `),r+=`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,!e.compositeRule&&l&&(e.async?r+=` throw new ValidationError(vErrors); `:r+=` validate.errors = vErrors; return false; `),l&&(r+=` break; `),r+=` } }`}return l&&(r+=` `+p+` if (`+d+` == errors) {`),r}})),ea=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`valid`+i,f=e.opts.$data&&o&&o.$data;f&&(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,``+i);var p=`schema`+i;if(!f)if(o.length<e.opts.loopRequired&&e.schema.properties&&Object.keys(e.schema.properties).length){var m=[],h=o;if(h)for(var g,_=-1,v=h.length-1;_<v;){g=h[_+=1];var y=e.schema.properties[g];y&&(e.opts.strictKeywords?typeof y==`object`&&Object.keys(y).length>0||y===!1:e.util.schemaHasRules(y,e.RULES.all))||(m[m.length]=g)}}else var m=o;if(f||m.length){var b=e.errorPath,x=f||m.length>=e.opts.loopRequired,S=e.opts.ownProperties;if(l)if(r+=` var missing`+i+`; `,x){f||(r+=` var `+p+` = validate.schema`+s+`; `);var C=`i`+i,w=`schema`+i+`[`+C+`]`,T=`' + `+w+` + '`;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(b,w,e.opts.jsonPointers)),r+=` var `+d+` = true; `,f&&(r+=` if (schema`+i+` === undefined) `+d+` = true; else if (!Array.isArray(schema`+i+`)) `+d+` = false; else {`),r+=` for (var `+C+` = 0; `+C+` < `+p+`.length; `+C+`++) { `+d+` = `+u+`[`+p+`[`+C+`]] !== undefined `,S&&(r+=` && Object.prototype.hasOwnProperty.call(`+u+`, `+p+`[`+C+`]) `),r+=`; if (!`+d+`) break; } `,f&&(r+=` } `),r+=` if (!`+d+`) { `;var E=E||[];E.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'required' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { missingProperty: '`+T+`' } `,e.opts.messages!==!1&&(r+=` , message: '`,e.opts._errorDataPathProperty?r+=`is a required property`:r+=`should have required property \\'`+T+`\\'`,r+=`' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var D=r;r=E.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+D+`]); `:r+=` validate.errors = [`+D+`]; return false; `:r+=` var err = `+D+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } else { `}else{r+=` if ( `;var O=m;if(O)for(var k,C=-1,A=O.length-1;C<A;){k=O[C+=1],C&&(r+=` || `);var j=e.util.getProperty(k),M=u+j;r+=` ( ( `+M+` === undefined `,S&&(r+=` || ! Object.prototype.hasOwnProperty.call(`+u+`, '`+e.util.escapeQuotes(k)+`') `),r+=`) && (missing`+i+` = `+e.util.toQuotedString(e.opts.jsonPointers?k:j)+`) ) `}r+=`) { `;var w=`missing`+i,T=`' + `+w+` + '`;e.opts._errorDataPathProperty&&(e.errorPath=e.opts.jsonPointers?e.util.getPathExpr(b,w,!0):b+` + `+w);var E=E||[];E.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'required' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { missingProperty: '`+T+`' } `,e.opts.messages!==!1&&(r+=` , message: '`,e.opts._errorDataPathProperty?r+=`is a required property`:r+=`should have required property \\'`+T+`\\'`,r+=`' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var D=r;r=E.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+D+`]); `:r+=` validate.errors = [`+D+`]; return false; `:r+=` var err = `+D+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } else { `}else if(x){f||(r+=` var `+p+` = validate.schema`+s+`; `);var C=`i`+i,w=`schema`+i+`[`+C+`]`,T=`' + `+w+` + '`;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPathExpr(b,w,e.opts.jsonPointers)),f&&(r+=` if (`+p+` && !Array.isArray(`+p+`)) { var err = `,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'required' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { missingProperty: '`+T+`' } `,e.opts.messages!==!1&&(r+=` , message: '`,e.opts._errorDataPathProperty?r+=`is a required property`:r+=`should have required property \\'`+T+`\\'`,r+=`' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `),r+=`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } else if (`+p+` !== undefined) { `),r+=` for (var `+C+` = 0; `+C+` < `+p+`.length; `+C+`++) { if (`+u+`[`+p+`[`+C+`]] === undefined `,S&&(r+=` || ! Object.prototype.hasOwnProperty.call(`+u+`, `+p+`[`+C+`]) `),r+=`) { var err = `,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'required' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { missingProperty: '`+T+`' } `,e.opts.messages!==!1&&(r+=` , message: '`,e.opts._errorDataPathProperty?r+=`is a required property`:r+=`should have required property \\'`+T+`\\'`,r+=`' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `),r+=`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } } `,f&&(r+=` } `)}else{var N=m;if(N)for(var k,P=-1,F=N.length-1;P<F;){k=N[P+=1];var j=e.util.getProperty(k),T=e.util.escapeQuotes(k),M=u+j;e.opts._errorDataPathProperty&&(e.errorPath=e.util.getPath(b,k,e.opts.jsonPointers)),r+=` if ( `+M+` === undefined `,S&&(r+=` || ! Object.prototype.hasOwnProperty.call(`+u+`, '`+e.util.escapeQuotes(k)+`') `),r+=`) { var err = `,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'required' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { missingProperty: '`+T+`' } `,e.opts.messages!==!1&&(r+=` , message: '`,e.opts._errorDataPathProperty?r+=`is a required property`:r+=`should have required property \\'`+T+`\\'`,r+=`' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `),r+=`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; } `}}e.errorPath=b}else l&&(r+=` if (true) {`);return r}})),ta=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u=`data`+(a||``),d=`valid`+i,f=e.opts.$data&&o&&o.$data,p;if(f?(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,p=`schema`+i):p=o,(o||f)&&e.opts.uniqueItems!==!1){f&&(r+=` var `+d+`; if (`+p+` === false || `+p+` === undefined) `+d+` = true; else if (typeof `+p+` != 'boolean') `+d+` = false; else { `),r+=` var i = `+u+`.length , `+d+` = true , j; if (i > 1) { `;var m=e.schema.items&&e.schema.items.type,h=Array.isArray(m);if(!m||m==`object`||m==`array`||h&&(m.indexOf(`object`)>=0||m.indexOf(`array`)>=0))r+=` outer: for (;i--;) { for (j = i; j--;) { if (equal(`+u+`[i], `+u+`[j])) { `+d+` = false; break outer; } } } `;else{r+=` var itemIndices = {}, item; for (;i--;) { var item = `+u+`[i]; `;var g=`checkDataType`+(h?`s`:``);r+=` if (`+e.util[g](m,`item`,e.opts.strictNumbers,!0)+`) continue; `,h&&(r+=` if (typeof item == 'string') item = '"' + item; `),r+=` if (typeof itemIndices[item] == 'number') { `+d+` = false; j = itemIndices[item]; break; } itemIndices[item] = i; } `}r+=` } `,f&&(r+=` } `),r+=` if (!`+d+`) { `;var _=_||[];_.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: 'uniqueItems' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { i: i, j: j } `,e.opts.messages!==!1&&(r+=` , message: 'should NOT have duplicate items (items ## ' + j + ' and ' + i + ' are identical)' `),e.opts.verbose&&(r+=` , schema: `,f?r+=`validate.schema`+s:r+=``+o,r+=` , parentSchema: validate.schema`+e.schemaPath+` , data: `+u+` `),r+=` } `);var v=r;r=_.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+v+`]); `:r+=` validate.errors = [`+v+`]; return false; `:r+=` var err = `+v+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,r+=` } `,l&&(r+=` else { `)}else l&&(r+=` if (true) { `);return r}})),na=s(((e,t)=>{t.exports={$ref:Ni(),allOf:Pi(),anyOf:Fi(),$comment:Ii(),const:Li(),contains:Ri(),dependencies:zi(),enum:Bi(),format:Vi(),if:Hi(),items:Ui(),maximum:Wi(),minimum:Wi(),maxItems:Gi(),minItems:Gi(),maxLength:Ki(),minLength:Ki(),maxProperties:qi(),minProperties:qi(),multipleOf:Ji(),not:Yi(),oneOf:Xi(),pattern:Zi(),properties:Qi(),propertyNames:$i(),required:ea(),uniqueItems:ta(),validate:ki()}})),ra=s(((e,t)=>{var n=na(),r=Ci().toHash;t.exports=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=r(t),e.types=r([`number`,`integer`,`string`,`array`,`object`,`boolean`,`null`]),e.forEach(function(r){r.rules=r.rules.map(function(r){var i;if(typeof r==`object`){var a=Object.keys(r)[0];i=r[a],r=a,i.forEach(function(n){t.push(n),e.all[n]=!0})}return t.push(r),e.all[r]={keyword:r,code:n[r],implements:i}}),e.all.$comment={keyword:`$comment`,code:n.$comment},r.type&&(e.types[r.type]=r)}),e.keywords=r(t.concat([`$schema`,`$id`,`id`,`$data`,`$async`,`title`,`description`,`default`,`definitions`,`examples`,`readOnly`,`writeOnly`,`contentMediaType`,`contentEncoding`,`additionalItems`,`then`,`else`])),e.custom={},e}})),ia=s(((e,t)=>{var n=[`multipleOf`,`maximum`,`exclusiveMaximum`,`minimum`,`exclusiveMinimum`,`maxLength`,`minLength`,`pattern`,`additionalItems`,`maxItems`,`minItems`,`uniqueItems`,`maxProperties`,`minProperties`,`required`,`additionalProperties`,`enum`,`format`,`const`];t.exports=function(e,t){for(var r=0;r<t.length;r++){e=JSON.parse(JSON.stringify(e));var i=t[r].split(`/`),a=e,o;for(o=1;o<i.length;o++)a=a[i[o]];for(o=0;o<n.length;o++){var s=n[o],c=a[s];c&&(a[s]={anyOf:[c,{$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`}]})}}return e}})),aa=s(((e,t)=>{var n=Di().MissingRef;t.exports=r;function r(e,t,i){var a=this;if(typeof this._opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);typeof t==`function`&&(i=t,t=void 0);var o=s(e).then(function(){var n=a._addSchema(e,void 0,t);return n.validate||c(n)});return i&&o.then(function(e){i(null,e)},i),o;function s(e){var t=e.$schema;return t&&!a.getSchema(t)?r.call(a,{$ref:t},!0):Promise.resolve()}function c(e){try{return a._compile(e)}catch(e){if(e instanceof n)return r(e);throw e}function r(n){var r=n.missingSchema;if(l(r))throw Error(`Schema `+r+` is loaded but `+n.missingRef+` cannot be resolved`);var i=a._loadingSchemas[r];return i||(i=a._loadingSchemas[r]=a._opts.loadSchema(r),i.then(o,o)),i.then(function(e){if(!l(r))return s(e).then(function(){l(r)||a.addSchema(e,r,void 0,t)})}).then(function(){return c(e)});function o(){delete a._loadingSchemas[r]}function l(e){return a._refs[e]||a._schemas[e]}}}}})),oa=s(((e,t)=>{t.exports=function(e,t,n){var r=` `,i=e.level,a=e.dataLevel,o=e.schema[t],s=e.schemaPath+e.util.getProperty(t),c=e.errSchemaPath+`/`+t,l=!e.opts.allErrors,u,d=`data`+(a||``),f=`valid`+i,p=`errs__`+i,m=e.opts.$data&&o&&o.$data,h;m?(r+=` var schema`+i+` = `+e.util.getData(o.$data,a,e.dataPathArr)+`; `,h=`schema`+i):h=o;var g=this,_=`definition`+i,v=g.definition,y=``,b,x,S,C,w;if(m&&v.$data){w=`keywordValidate`+i;var T=v.validateSchema;r+=` var `+_+` = RULES.custom['`+t+`'].definition; var `+w+` = `+_+`.validate;`}else{if(C=e.useCustomRule(g,o,e.schema,e),!C)return;h=`validate.schema`+s,w=C.code,b=v.compile,x=v.inline,S=v.macro}var E=w+`.errors`,D=`i`+i,O=`ruleErr`+i,k=v.async;if(k&&!e.async)throw Error(`async keyword in sync schema`);if(x||S||(r+=``+E+` = null;`),r+=`var `+p+` = errors;var `+f+`;`,m&&v.$data&&(y+=`}`,r+=` if (`+h+` === undefined) { `+f+` = true; } else { `,T&&(y+=`}`,r+=` `+f+` = `+_+`.validateSchema(`+h+`); if (`+f+`) { `)),x)v.statements?r+=` `+C.validate+` `:r+=` `+f+` = `+C.validate+`; `;else if(S){var A=e.util.copy(e),y=``;A.level++;var j=`valid`+A.level;A.schema=C.validate,A.schemaPath=``;var M=e.compositeRule;e.compositeRule=A.compositeRule=!0;var N=e.validate(A).replace(/validate\.schema/g,w);e.compositeRule=A.compositeRule=M,r+=` `+N}else{var P=P||[];P.push(r),r=``,r+=` `+w+`.call( `,e.opts.passContext?r+=`this`:r+=`self`,b||v.schema===!1?r+=` , `+d+` `:r+=` , `+h+` , `+d+` , validate.schema`+e.schemaPath+` `,r+=` , (dataPath || '')`,e.errorPath!=`""`&&(r+=` + `+e.errorPath);var F=a?`data`+(a-1||``):`parentData`,ee=a?e.dataPathArr[a]:`parentDataProperty`;r+=` , `+F+` , `+ee+` , rootData ) `;var I=r;r=P.pop(),v.errors===!1?(r+=` `+f+` = `,k&&(r+=`await `),r+=``+I+`; `):k?(E=`customErrors`+i,r+=` var `+E+` = null; try { `+f+` = await `+I+`; } catch (e) { `+f+` = false; if (e instanceof ValidationError) `+E+` = e.errors; else throw e; } `):r+=` `+E+` = null; `+f+` = `+I+`; `}if(v.modifying&&(r+=` if (`+F+`) `+d+` = `+F+`[`+ee+`];`),r+=``+y,v.valid)l&&(r+=` if (true) { `);else{r+=` if ( `,v.valid===void 0?(r+=` !`,S?r+=``+j:r+=``+f):r+=` `+!v.valid+` `,r+=`) { `,u=g.keyword;var P=P||[];P.push(r),r=``;var P=P||[];P.push(r),r=``,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(u||`custom`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { keyword: '`+g.keyword+`' } `,e.opts.messages!==!1&&(r+=` , message: 'should pass "`+g.keyword+`" keyword validation' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+d+` `),r+=` } `);var L=r;r=P.pop(),!e.compositeRule&&l?e.async?r+=` throw new ValidationError([`+L+`]); `:r+=` validate.errors = [`+L+`]; return false; `:r+=` var err = `+L+`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `;var R=r;r=P.pop(),x?v.errors?v.errors!=`full`&&(r+=` for (var `+D+`=`+p+`; `+D+`<errors; `+D+`++) { var `+O+` = vErrors[`+D+`]; if (`+O+`.dataPath === undefined) `+O+`.dataPath = (dataPath || '') + `+e.errorPath+`; if (`+O+`.schemaPath === undefined) { `+O+`.schemaPath = "`+c+`"; } `,e.opts.verbose&&(r+=` `+O+`.schema = `+h+`; `+O+`.data = `+d+`; `),r+=` } `):v.errors===!1?r+=` `+R+` `:(r+=` if (`+p+` == errors) { `+R+` } else { for (var `+D+`=`+p+`; `+D+`<errors; `+D+`++) { var `+O+` = vErrors[`+D+`]; if (`+O+`.dataPath === undefined) `+O+`.dataPath = (dataPath || '') + `+e.errorPath+`; if (`+O+`.schemaPath === undefined) { `+O+`.schemaPath = "`+c+`"; } `,e.opts.verbose&&(r+=` `+O+`.schema = `+h+`; `+O+`.data = `+d+`; `),r+=` } } `):S?(r+=` var err = `,e.createErrors===!1?r+=` {} `:(r+=` { keyword: '`+(u||`custom`)+`' , dataPath: (dataPath || '') + `+e.errorPath+` , schemaPath: `+e.util.toQuotedString(c)+` , params: { keyword: '`+g.keyword+`' } `,e.opts.messages!==!1&&(r+=` , message: 'should pass "`+g.keyword+`" keyword validation' `),e.opts.verbose&&(r+=` , schema: validate.schema`+s+` , parentSchema: validate.schema`+e.schemaPath+` , data: `+d+` `),r+=` } `),r+=`; if (vErrors === null) vErrors = [err]; else vErrors.push(err); errors++; `,!e.compositeRule&&l&&(e.async?r+=` throw new ValidationError(vErrors); `:r+=` validate.errors = vErrors; return false; `)):v.errors===!1?r+=` `+R+` `:(r+=` if (Array.isArray(`+E+`)) { if (vErrors === null) vErrors = `+E+`; else vErrors = vErrors.concat(`+E+`); errors = vErrors.length; for (var `+D+`=`+p+`; `+D+`<errors; `+D+`++) { var `+O+` = vErrors[`+D+`]; if (`+O+`.dataPath === undefined) `+O+`.dataPath = (dataPath || '') + `+e.errorPath+`; `+O+`.schemaPath = "`+c+`"; `,e.opts.verbose&&(r+=` `+O+`.schema = `+h+`; `+O+`.data = `+d+`; `),r+=` } } else { `+R+` } `),r+=` } `,l&&(r+=` else { `)}return r}})),sa=s(((e,t)=>{t.exports={$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}})),ca=s(((e,t)=>{var n=sa();t.exports={$id:`https://github.com/ajv-validator/ajv/blob/master/lib/definition_schema.js`,definitions:{simpleTypes:n.definitions.simpleTypes},type:`object`,dependencies:{schema:[`validate`],$data:[`validate`],statements:[`inline`],valid:{not:{required:[`macro`]}}},properties:{type:n.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`}]}}}})),la=s(((e,t)=>{var n=/^[a-z_$][a-z0-9_$-]*$/i,r=oa(),i=ca();t.exports={add:a,get:o,remove:s,validate:c};function a(e,t){var i=this.RULES;if(i.keywords[e])throw Error(`Keyword `+e+` is already defined`);if(!n.test(e))throw Error(`Keyword `+e+` is not a valid identifier`);if(t){this.validateKeyword(t,!0);var a=t.type;if(Array.isArray(a))for(var o=0;o<a.length;o++)c(e,a[o],t);else c(e,a,t);var s=t.metaSchema;s&&(t.$data&&this._opts.$data&&(s={anyOf:[s,{$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`}]}),t.validateSchema=this.compile(s,!0))}i.keywords[e]=i.all[e]=!0;function c(e,t,n){for(var a,o=0;o<i.length;o++){var s=i[o];if(s.type==t){a=s;break}}a||(a={type:t,rules:[]},i.push(a));var c={keyword:e,definition:n,custom:!0,code:r,implements:n.implements};a.rules.push(c),i.custom[e]=c}return this}function o(e){var t=this.RULES.custom[e];return t?t.definition:this.RULES.keywords[e]||!1}function s(e){var t=this.RULES;delete t.keywords[e],delete t.all[e],delete t.custom[e];for(var n=0;n<t.length;n++)for(var r=t[n].rules,i=0;i<r.length;i++)if(r[i].keyword==e){r.splice(i,1);break}return this}function c(e,t){c.errors=null;var n=this._validateKeyword=this._validateKeyword||this.compile(i,!0);if(n(e))return!0;if(c.errors=n.errors,t)throw Error(`custom keyword definition is invalid: `+this.errorsText(n.errors));return!1}})),ua=s(((e,t)=>{t.exports={$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}})),da=l(s(((e,t)=>{var n=Ai(),r=Ei(),i=ji(),a=wi(),o=Oi(),s=Mi(),c=ra(),l=ia(),u=Ci();t.exports=g,g.prototype.validate=_,g.prototype.compile=v,g.prototype.addSchema=y,g.prototype.addMetaSchema=b,g.prototype.validateSchema=x,g.prototype.getSchema=C,g.prototype.removeSchema=E,g.prototype.addFormat=F,g.prototype.errorsText=P,g.prototype._addSchema=O,g.prototype._compile=k,g.prototype.compileAsync=aa();var d=la();g.prototype.addKeyword=d.add,g.prototype.getKeyword=d.get,g.prototype.removeKeyword=d.remove,g.prototype.validateKeyword=d.validate;var f=Di();g.ValidationError=f.Validation,g.MissingRefError=f.MissingRef,g.$dataMetaSchema=l;var p=`http://json-schema.org/draft-07/schema`,m=[`removeAdditional`,`useDefaults`,`coerceTypes`,`strictDefaults`],h=[`/properties`];function g(e){if(!(this instanceof g))return new g(e);e=this._opts=u.copy(e)||{},ne(this),this._schemas={},this._refs={},this._fragments={},this._formats=s(e.format),this._cache=e.cache||new i,this._loadingSchemas={},this._compilations=[],this.RULES=c(),this._getId=A(e),e.loopRequired=e.loopRequired||1/0,e.errorDataPath==`property`&&(e._errorDataPathProperty=!0),e.serialize===void 0&&(e.serialize=o),this._metaOpts=te(this),e.formats&&L(this),e.keywords&&R(this),ee(this),typeof e.meta==`object`&&this.addMetaSchema(e.meta),e.nullable&&this.addKeyword(`nullable`,{metaSchema:{type:`boolean`}}),I(this)}function _(e,t){var n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "`+e+`"`)}else{var r=this._addSchema(e);n=r.validate||this._compile(r)}var i=n(t);return n.$async!==!0&&(this.errors=n.errors),i}function v(e,t){var n=this._addSchema(e,void 0,t);return n.validate||this._compile(n)}function y(e,t,n,i){if(Array.isArray(e)){for(var a=0;a<e.length;a++)this.addSchema(e[a],void 0,n,i);return this}var o=this._getId(e);if(o!==void 0&&typeof o!=`string`)throw Error(`schema id must be string`);return t=r.normalizeId(t||o),z(this,t),this._schemas[t]=this._addSchema(e,n,i,!0),this}function b(e,t,n){return this.addSchema(e,t,n,!0),this}function x(e,t){var n=e.$schema;if(n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this._opts.defaultMeta||S(this),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;var r=this.validate(n,e);if(!r&&t){var i=`schema is invalid: `+this.errorsText();if(this._opts.validateSchema==`log`)this.logger.error(i);else throw Error(i)}return r}function S(e){var t=e._opts.meta;return e._opts.defaultMeta=typeof t==`object`?e._getId(t)||t:e.getSchema(p)?p:void 0,e._opts.defaultMeta}function C(e){var t=T(this,e);switch(typeof t){case`object`:return t.validate||this._compile(t);case`string`:return this.getSchema(t);case`undefined`:return w(this,e)}}function w(e,t){var i=r.schema.call(e,{schema:{}},t);if(i){var o=i.schema,s=i.root,c=i.baseId,l=n.call(e,o,s,void 0,c);return e._fragments[t]=new a({ref:t,fragment:!0,schema:o,root:s,baseId:c,validate:l}),l}}function T(e,t){return t=r.normalizeId(t),e._schemas[t]||e._refs[t]||e._fragments[t]}function E(e){if(e instanceof RegExp)return D(this,this._schemas,e),D(this,this._refs,e),this;switch(typeof e){case`undefined`:return D(this,this._schemas),D(this,this._refs),this._cache.clear(),this;case`string`:var t=T(this,e);return t&&this._cache.del(t.cacheKey),delete this._schemas[e],delete this._refs[e],this;case`object`:var n=this._opts.serialize,i=n?n(e):e;this._cache.del(i);var a=this._getId(e);a&&(a=r.normalizeId(a),delete this._schemas[a],delete this._refs[a])}return this}function D(e,t,n){for(var r in t){var i=t[r];!i.meta&&(!n||n.test(r))&&(e._cache.del(i.cacheKey),delete t[r])}}function O(e,t,n,i){if(typeof e!=`object`&&typeof e!=`boolean`)throw Error(`schema should be object or boolean`);var o=this._opts.serialize,s=o?o(e):e,c=this._cache.get(s);if(c)return c;i||=this._opts.addUsedSchema!==!1;var l=r.normalizeId(this._getId(e));l&&i&&z(this,l);var u=this._opts.validateSchema!==!1&&!t,d;u&&!(d=l&&l==r.normalizeId(e.$schema))&&this.validateSchema(e,!0);var f=new a({id:l,schema:e,localRefs:r.ids.call(this,e),cacheKey:s,meta:n});return l[0]!=`#`&&i&&(this._refs[l]=f),this._cache.put(s,f),u&&d&&this.validateSchema(e,!0),f}function k(e,t){if(e.compiling)return e.validate=a,a.schema=e.schema,a.errors=null,a.root=t||a,e.schema.$async===!0&&(a.$async=!0),a;e.compiling=!0;var r;e.meta&&(r=this._opts,this._opts=this._metaOpts);var i;try{i=n.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=i,e.refs=i.refs,e.refVal=i.refVal,e.root=i.root,i;function a(){var t=e.validate,n=t.apply(this,arguments);return a.errors=t.errors,n}}function A(e){switch(e.schemaId){case`auto`:return N;case`id`:return j;default:return M}}function j(e){return e.$id&&this.logger.warn(`schema $id ignored`,e.$id),e.id}function M(e){return e.id&&this.logger.warn(`schema id ignored`,e.id),e.$id}function N(e){if(e.$id&&e.id&&e.$id!=e.id)throw Error(`schema $id is different from id`);return e.$id||e.id}function P(e,t){if(e||=this.errors,!e)return`No errors`;t||={};for(var n=t.separator===void 0?`, `:t.separator,r=t.dataVar===void 0?`data`:t.dataVar,i=``,a=0;a<e.length;a++){var o=e[a];o&&(i+=r+o.dataPath+` `+o.message+n)}return i.slice(0,-n.length)}function F(e,t){return typeof t==`string`&&(t=new RegExp(t)),this._formats[e]=t,this}function ee(e){var t;if(e._opts.$data&&(t=ua(),e.addMetaSchema(t,t.$id,!0)),e._opts.meta!==!1){var n=sa();e._opts.$data&&(n=l(n,h)),e.addMetaSchema(n,p,!0),e._refs[`http://json-schema.org/schema`]=p}}function I(e){var t=e._opts.schemas;if(t)if(Array.isArray(t))e.addSchema(t);else for(var n in t)e.addSchema(t[n],n)}function L(e){for(var t in e._opts.formats){var n=e._opts.formats[t];e.addFormat(t,n)}}function R(e){for(var t in e._opts.keywords){var n=e._opts.keywords[t];e.addKeyword(t,n)}}function z(e,t){if(e._schemas[t]||e._refs[t])throw Error(`schema with key or id "`+t+`" already exists`)}function te(e){for(var t=u.copy(e._opts),n=0;n<m.length;n++)delete t[m[n]];return t}function ne(e){var t=e._opts.logger;if(t===!1)e.logger={log:re,warn:re,error:re};else{if(t===void 0&&(t=console),!(typeof t==`object`&&t.log&&t.warn&&t.error))throw Error(`logger must implement log, warn and error methods`);e.logger=t}}function re(){}}))(),1),fa=class extends vi{constructor(e,t){super(t),this._serverInfo=e,this._capabilities=t?.capabilities??{},this._instructions=t?.instructions,this.setRequestHandler(lr,e=>this._oninitialize(e)),this.setNotificationHandler(fr,()=>this.oninitialized?.call(this))}registerCapabilities(e){if(this.transport)throw Error(`Cannot register capabilities after connecting to transport`);this._capabilities=yi(this._capabilities,e)}assertCapabilityForMethod(e){switch(e){case`sampling/createMessage`:if(!this._clientCapabilities?.sampling)throw Error(`Client does not support sampling (required for ${e})`);break;case`elicitation/create`:if(!this._clientCapabilities?.elicitation)throw Error(`Client does not support elicitation (required for ${e})`);break;case`roots/list`:if(!this._clientCapabilities?.roots)throw Error(`Client does not support listing roots (required for ${e})`);break;case`ping`:break}}assertNotificationCapability(e){switch(e){case`notifications/message`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`notifications/resources/updated`:case`notifications/resources/list_changed`:if(!this._capabilities.resources)throw Error(`Server does not support notifying about resources (required for ${e})`);break;case`notifications/tools/list_changed`:if(!this._capabilities.tools)throw Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case`notifications/prompts/list_changed`:if(!this._capabilities.prompts)throw Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case`notifications/cancelled`:break;case`notifications/progress`:break}}assertRequestHandlerCapability(e){switch(e){case`sampling/createMessage`:if(!this._capabilities.sampling)throw Error(`Server does not support sampling (required for ${e})`);break;case`logging/setLevel`:if(!this._capabilities.logging)throw Error(`Server does not support logging (required for ${e})`);break;case`prompts/get`:case`prompts/list`:if(!this._capabilities.prompts)throw Error(`Server does not support prompts (required for ${e})`);break;case`resources/list`:case`resources/templates/list`:case`resources/read`:if(!this._capabilities.resources)throw Error(`Server does not support resources (required for ${e})`);break;case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Server does not support tools (required for ${e})`);break;case`ping`:case`initialize`:break}}async _oninitialize(e){let t=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:Bn.includes(t)?t:zn,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:`ping`},ir)}async createMessage(e,t){return this.request({method:`sampling/createMessage`,params:e},ai,t)}async elicitInput(e,t){let n=await this.request({method:`elicitation/create`,params:e},ci,t);if(n.action===`accept`&&n.content)try{let t=new da.default,r=t.compile(e.requestedSchema);if(!r(n.content))throw new _i(tr.InvalidParams,`Elicitation response content does not match requested schema: ${t.errorsText(r.errors)}`)}catch(e){throw e instanceof _i?e:new _i(tr.InternalError,`Error validating elicitation response: ${e}`)}return n}async listRoots(e,t){return this.request({method:`roots/list`,params:e},hi,t)}async sendLoggingMessage(e){return this.notification({method:`notifications/message`,params:e})}async sendResourceUpdated(e){return this.notification({method:`notifications/resources/updated`,params:e})}async sendResourceListChanged(){return this.notification({method:`notifications/resources/list_changed`})}async sendToolListChanged(){return this.notification({method:`notifications/tools/list_changed`})}async sendPromptListChanged(){return this.notification({method:`notifications/prompts/list_changed`})}},pa;(function(e){e.Completable=`McpCompletable`})(pa||={});var ma=class extends N{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}};ma.create=(e,t)=>new ma({type:e,typeName:pa.Completable,complete:t.complete,...ha(t)});function ha(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var ga=e=>[e.slice(0,e.length/2),e.slice(e.length/2)],_a=Symbol(`Original index`),va=e=>{let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`boolean`)t.push(r?{[_a]:n}:{[_a]:n,not:{}});else if(_a in r)return e;else t.push({...r,[_a]:n})}return t};function ya(e,t){if(e.allOf.length===0)return rt();if(e.allOf.length===1){let n=e.allOf[0];return Ha(n,{...t,path:[...t.path,`allOf`,n[_a]]})}let[n,r]=ga(va(e.allOf));return at(ya({allOf:n},t),ya({allOf:r},t))}var ba=(e,t)=>e.anyOf.length?e.anyOf.length===1?Ha(e.anyOf[0],{...t,path:[...t.path,`anyOf`,0]}):X(e.anyOf.map((e,n)=>Ha(e,{...t,path:[...t.path,`anyOf`,n]}))):tt();function $(e,t,n,r){let i=t[n];if(i!==void 0){let a=t.errorMessage?.[n];return r(e,i,a)}return e}var xa={an:{object:e=>e.type===`object`||!e.type&&(e.properties!==void 0||e.additionalProperties!==void 0||e.patternProperties!==void 0),array:e=>e.type===`array`,anyOf:e=>e.anyOf!==void 0,allOf:e=>e.allOf!==void 0,enum:e=>e.enum!==void 0},a:{nullable:e=>e.nullable===!0,multipleType:e=>Array.isArray(e.type),not:e=>e.not!==void 0,const:e=>e.const!==void 0,primitive:(e,t)=>e.type===t,conditional:e=>!!(`if`in e&&e.if&&`then`in e&&`else`in e&&e.then&&e.else),oneOf:e=>e.oneOf!==void 0}},Sa=(e,t)=>{if(xa.an.anyOf(e)){let n=new Set,r=[];e.anyOf.forEach(e=>{if(typeof e==`object`&&e.type&&n.add(typeof e.type==`string`?e.type:e.type[0]),typeof e==`object`&&e.items){let t=e.items;!Array.isArray(t)&&typeof t==`object`&&r.push(t)}});let i;r.length===1?i=r[0]:r.length>1&&(i={anyOf:r});let a={...n.size>0?{type:Array.from(n)}:{type:`array`},...i&&{items:i}};return[`default`,`description`,`examples`,`title`].forEach(t=>{let n=e[t];n!==void 0&&(a[t]=n)}),Ha(a,t)}if(Array.isArray(e.items))return ot(e.items.map((e,n)=>Ha(e,{...t,path:[...t.path,`items`,n]})));let n=e.items?J(Ha(e.items,{...t,path:[...t.path,`items`]})):J(tt());return n=$(n,e,`minItems`,(e,t,n)=>e.min(t,n)),n=$(n,e,`maxItems`,(e,t,n)=>e.max(t,n)),typeof e.min==`number`&&typeof e.minItems!=`number`&&(n=$(n,{...e,minItems:e.min},`minItems`,(e,t,n)=>e.min(t,n))),typeof e.max==`number`&&typeof e.maxItems!=`number`&&(n=$(n,{...e,maxItems:e.max},`maxItems`,(e,t,n)=>e.max(t,n))),n},Ca=e=>q(),wa=e=>Z(e.const),Ta=e=>tt(),Ea=e=>e.enum.length===0?rt():e.enum.length===1?Z(e.enum[0]):e.enum.every(e=>typeof e==`string`)?ct(e.enum):X(e.enum.map(e=>Z(e))),Da=(e,t)=>{let n=Ha(e.if,{...t,path:[...t.path,`if`]}),r=Ha(e.then,{...t,path:[...t.path,`then`]}),i=Ha(e.else,{...t,path:[...t.path,`else`]});return X([r,i]).superRefine((e,t)=>{let a=n.safeParse(e).success?r.safeParse(e):i.safeParse(e);a.success||a.error.errors.forEach(e=>t.addIssue(e))})},Oa=(e,t)=>X(e.type.map(n=>Ha({...e,type:n},t))),ka=(e,t)=>tt().refine(n=>!Ha(e.not,{...t,path:[...t.path,`not`]}).safeParse(n).success,`Invalid input: Should NOT be valid against schema`),Aa=e=>et(),ja=(e,...t)=>Object.keys(e).reduce((n,r)=>(t.includes(r)||(n[r]=e[r]),n),{}),Ma=(e,t)=>{let n=e.default===null,r=Ha(n?ja(ja(e,`nullable`),`default`):ja(e,`nullable`),t,!0).nullable();return n?r.default(null):r},Na=e=>{let t=K(),n=!1;return e.type===`integer`?(n=!0,t=$(t,e,`type`,(e,t,n)=>e.int(n))):e.format===`int64`&&(n=!0,t=$(t,e,`format`,(e,t,n)=>e.int(n))),t=$(t,e,`multipleOf`,(e,t,r)=>t===1?n?e:e.int(r):e.multipleOf(t,r)),typeof e.minimum==`number`?t=e.exclusiveMinimum===!0?$(t,e,`minimum`,(e,t,n)=>e.gt(t,n)):$(t,e,`minimum`,(e,t,n)=>e.gte(t,n)):typeof e.exclusiveMinimum==`number`&&(t=$(t,e,`exclusiveMinimum`,(e,t,n)=>e.gt(t,n))),typeof e.maximum==`number`?t=e.exclusiveMaximum===!0?$(t,e,`maximum`,(e,t,n)=>e.lt(t,n)):$(t,e,`maximum`,(e,t,n)=>e.lte(t,n)):typeof e.exclusiveMaximum==`number`&&(t=$(t,e,`exclusiveMaximum`,(e,t,n)=>e.lt(t,n))),typeof e.min==`number`&&typeof e.minimum!=`number`&&(t=$(t,{...e,minimum:e.min},`minimum`,(e,t,n)=>e.gte(t,n))),typeof e.max==`number`&&typeof e.maximum!=`number`&&(t=$(t,{...e,maximum:e.max},`maximum`,(e,t,n)=>e.lte(t,n))),t},Pa=(e,t)=>e.oneOf.length?e.oneOf.length===1?Ha(e.oneOf[0],{...t,path:[...t.path,`oneOf`,0]}):tt().superRefine((n,r)=>{let i=e.oneOf.map((e,n)=>Ha(e,{...t,path:[...t.path,`oneOf`,n]})),a=i.reduce((e,t)=>(t=>t.error?[...e,t.error]:e)(t.safeParse(n)),[]);i.length-a.length!==1&&r.addIssue({path:r.path,code:`invalid_union`,unionErrors:a,message:`Invalid input: Should pass single schema`})}):tt();function Fa(e,t){if(!e.properties)return Y({});let n=Object.keys(e.properties);if(n.length===0)return Y({});let r={};for(let i of n){let n=e.properties[i],a=Ha(n,{...t,path:[...t.path,`properties`,i]}),o=Array.isArray(e.required)?e.required.includes(i):!1;if(!o&&n&&typeof n==`object`&&`default`in n)if(n.default===null){let e=n.anyOf&&Array.isArray(n.anyOf)&&n.anyOf.some(e=>typeof e==`object`&&!!e&&e.type===`null`),t=n.oneOf&&Array.isArray(n.oneOf)&&n.oneOf.some(e=>typeof e==`object`&&!!e&&e.type===`null`),o=`nullable`in n&&n.nullable===!0;e||t||o?r[i]=a.optional().default(null):r[i]=a.nullable().optional().default(null)}else r[i]=a.optional().default(n.default);else r[i]=o?a:a.optional()}return Y(r)}function Ia(e,t){let n=Object.keys(e.patternProperties??{}).length>0,r=e.type===`object`?e:{...e,type:`object`},i=Fa(r,t),a=i,o=r.additionalProperties===void 0?void 0:Ha(r.additionalProperties,{...t,path:[...t.path,`additionalProperties`]}),s=r.additionalProperties===!0;if(r.patternProperties){let e=Object.fromEntries(Object.entries(r.patternProperties).map(([e,n])=>[e,Ha(n,{...t,path:[...t.path,`patternProperties`,e]})])),n=Object.values(e);a=i?o?i.catchall(X([...n,o])):Object.keys(e).length>1?i.catchall(X(n)):i.catchall(n[0]):o?st(X([...n,o])):n.length>1?st(X(n)):st(n[0]);let s=new Set(Object.keys(r.properties??{}));a=a.superRefine((t,n)=>{for(let i in t){let a=s.has(i);for(let o in r.patternProperties){let r=new RegExp(o);if(i.match(r)){a=!0;let r=e[o].safeParse(t[i]);r.success||n.addIssue({path:[...n.path,i],code:`custom`,message:`Invalid input: Key matching regex /${i}/ must match schema`,params:{issues:r.error.issues}})}}if(!a&&o){let e=o.safeParse(t[i]);e.success||n.addIssue({path:[...n.path,i],code:`custom`,message:`Invalid input: must match catchall schema`,params:{issues:e.error.issues}})}}})}let c;return c=i?n?a:o?o instanceof we?i.strict():s?i.passthrough():i.catchall(o):i.strict():n?a:o?o instanceof we?Y({}).strict():s?Y({}).passthrough():st(o):Y({}).passthrough(),xa.an.anyOf(e)&&(c=c.and(ba({...e,anyOf:e.anyOf.map(e=>typeof e==`object`&&!e.type&&(e.properties??e.additionalProperties??e.patternProperties)?{...e,type:`object`}:e)},t))),xa.a.oneOf(e)&&(c=c.and(Pa({...e,oneOf:e.oneOf.map(e=>typeof e==`object`&&!e.type&&(e.properties??e.additionalProperties??e.patternProperties)?{...e,type:`object`}:e)},t))),xa.an.allOf(e)&&(c=c.and(ya({...e,allOf:e.allOf.map(e=>typeof e==`object`&&!e.type&&(e.properties??e.additionalProperties??e.patternProperties)?{...e,type:`object`}:e)},t))),c}var La=e=>{let t=G();return t=$(t,e,`format`,(e,t,n)=>{switch(t){case`email`:return e.email(n);case`ip`:return e.ip(n);case`ipv4`:return e.ip({version:`v4`,message:n});case`ipv6`:return e.ip({version:`v6`,message:n});case`uri`:return e.url(n);case`uuid`:return e.uuid(n);case`date-time`:return e.datetime({offset:!0,message:n});case`time`:return e.time(n);case`date`:return e.date(n);case`binary`:return e.base64(n);case`duration`:return e.duration(n);default:return e}}),t=$(t,e,`contentEncoding`,(e,t,n)=>e.base64(n)),t=$(t,e,`pattern`,(e,t,n)=>e.regex(new RegExp(t),n)),t=$(t,e,`minLength`,(e,t,n)=>e.min(t,n)),t=$(t,e,`maxLength`,(e,t,n)=>e.max(t,n)),typeof e.min==`number`&&typeof e.minLength!=`number`&&(t=$(t,{...e,minLength:e.min},`minLength`,(e,t,n)=>e.min(t,n))),typeof e.max==`number`&&typeof e.maxLength!=`number`&&(t=$(t,{...e,maxLength:e.max},`maxLength`,(e,t,n)=>e.max(t,n))),t},Ra=(e,t)=>{let n=``;if(e.description?n=e.description:e.title&&(n=e.title),e.example!==void 0){let t=`Example: ${JSON.stringify(e.example)}`;n=n?`${n}
1
+ var WebMCP=(function(e,t,n){var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e},u=(e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e));t=u(t),n=u(n);var d;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(d||={});var ee;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(ee||={});let f=d.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),p=e=>{switch(typeof e){case`undefined`:return f.undefined;case`string`:return f.string;case`number`:return Number.isNaN(e)?f.nan:f.number;case`boolean`:return f.boolean;case`function`:return f.function;case`bigint`:return f.bigint;case`symbol`:return f.symbol;case`object`:return Array.isArray(e)?f.array:e===null?f.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?f.promise:typeof Map<`u`&&e instanceof Map?f.map:typeof Set<`u`&&e instanceof Set?f.set:typeof Date<`u`&&e instanceof Date?f.date:f.object;default:return f.unknown}},m=d.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`]);var h=class e 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]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,d.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};h.create=e=>new h(e);var g=(e,t)=>{let n;switch(e.code){case m.invalid_type:n=e.received===f.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case m.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,d.jsonStringifyReplacer)}`;break;case m.unrecognized_keys:n=`Unrecognized key(s) in object: ${d.joinValues(e.keys,`, `)}`;break;case m.invalid_union:n=`Invalid input`;break;case m.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${d.joinValues(e.options)}`;break;case m.invalid_enum_value:n=`Invalid enum value. Expected ${d.joinValues(e.options)}, received '${e.received}'`;break;case m.invalid_arguments:n=`Invalid function arguments`;break;case m.invalid_return_type:n=`Invalid function return type`;break;case m.invalid_date:n=`Invalid date`;break;case m.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:d.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case m.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`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 m.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case m.custom:n=`Invalid input`;break;case m.invalid_intersection_types:n=`Intersection results could not be merged`;break;case m.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case m.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,d.assertNever(e)}return{message:n}};let te=g;function ne(){return te}let re=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function _(e,t){let n=ne(),r=re({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===g?void 0:g].filter(e=>!!e)});e.common.issues.push(r)}var v=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return y;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return y;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};let y=Object.freeze({status:`aborted`}),ie=e=>({status:`dirty`,value:e}),b=e=>({status:`valid`,value:e}),ae=e=>e.status===`aborted`,oe=e=>e.status===`dirty`,x=e=>e.status===`valid`,se=e=>typeof Promise<`u`&&e instanceof Promise;var S;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(S||={});var C=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}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}};let ce=(e,t)=>{if(x(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new h(e.common.issues),this._error}}};function w(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var T=class{get description(){return this._def.description}_getType(e){return p(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:p(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new v,ctx:{common:e.parent.common,data:e.data,parsedType:p(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(se(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p(e)};return ce(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return x(n)?{value:n.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=>x(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:p(e)},r=this._parse({data:e,path:n.path,parent:n});return ce(n,await(se(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:m.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new I({schema:this,typeName:z.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 L.create(this,this._def)}nullable(){return R.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return O.create(this)}promise(){return F.create(this,this._def)}or(e){return Ue.create([this,e],this._def)}and(e){return M.create(this,e,this._def)}transform(e){return new I({...w(this._def),schema:this,typeName:z.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new et({...w(this._def),innerType:this,defaultValue:t,typeName:z.ZodDefault})}brand(){return new rt({typeName:z.ZodBranded,type:this,...w(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new tt({...w(this._def),innerType:this,catchValue:t,typeName:z.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return it.create(this,e)}readonly(){return at.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};let le=/^c[^\s-]{8,}$/i,ue=/^[0-9a-z]+$/,de=/^[0-9A-HJKMNP-TV-Z]{26}$/i,fe=/^[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,pe=/^[a-z0-9_-]{21}$/i,me=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,he=/^[-+]?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)?)??$/,ge=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,_e,ve=/^(?:(?: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])$/,ye=/^(?:(?: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])$/,be=/^(([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]))$/,xe=/^(([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])$/,Se=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ce=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,we=`((\\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])))`,Te=RegExp(`^${we}$`);function Ee(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function De(e){return RegExp(`^${Ee(e)}$`)}function Oe(e){let t=`${we}T${Ee(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function ke(e,t){return!!((t===`v4`||!t)&&ve.test(e)||(t===`v6`||!t)&&be.test(e))}function Ae(e,t){if(!me.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function je(e,t){return!!((t===`v4`||!t)&&ye.test(e)||(t===`v6`||!t)&&xe.test(e))}var Me=class e extends T{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.string,received:t.parsedType}),y}let t=new v,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),_(n,{code:m.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),_(n,{code:m.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?_(n,{code:m.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&_(n,{code:m.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)ge.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`email`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)_e||=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`),_e.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`emoji`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)fe.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`uuid`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)pe.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`nanoid`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)le.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`cuid`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)ue.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`cuid2`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)de.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`ulid`,code:m.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),_(n,{validation:`url`,code:m.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`regex`,code:m.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),_(n,{code:m.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),_(n,{code:m.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),_(n,{code:m.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Oe(r).test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{code:m.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Te.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{code:m.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?De(r).test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{code:m.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?he.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`duration`,code:m.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?ke(e.data,r.version)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`ip`,code:m.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Ae(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`jwt`,code:m.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?je(e.data,r.version)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`cidr`,code:m.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Se.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`base64`,code:m.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Ce.test(e.data)||(n=this._getOrReturnCtx(e,n),_(n,{validation:`base64url`,code:m.invalid_string,message:r.message}),t.dirty()):d.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:m.invalid_string,...S.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...S.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...S.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...S.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...S.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...S.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...S.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...S.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...S.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...S.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...S.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...S.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...S.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...S.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...S.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...S.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...S.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...S.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...S.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...S.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...S.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...S.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...S.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...S.errToObj(t)})}nonempty(e){return this.min(1,S.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Me.create=e=>new Me({checks:[],typeName:z.ZodString,coerce:e?.coerce??!1,...w(e)});function Ne(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Pe=class e extends T{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.number,received:t.parsedType}),y}let t,n=new v;for(let r of this._def.checks)r.kind===`int`?d.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),_(t,{code:m.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:m.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:m.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Ne(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),_(t,{code:m.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),_(t,{code:m.not_finite,message:r.message}),n.dirty()):d.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,S.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,S.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,S.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,S.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:S.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:S.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:S.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:S.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:S.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:S.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:S.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:S.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:S.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:S.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&d.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Pe.create=e=>new Pe({checks:[],typeName:z.ZodNumber,coerce:e?.coerce||!1,...w(e)});var Fe=class e 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)!==f.bigint)return this._getInvalidInput(e);let t,n=new v;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:m.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),_(t,{code:m.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),_(t,{code:m.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):d.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.bigint,received:t.parsedType}),y}gte(e,t){return this.setLimit(`min`,e,!0,S.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,S.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,S.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,S.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:S.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:S.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:S.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:S.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:S.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:S.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Fe.create=e=>new Fe({checks:[],typeName:z.ZodBigInt,coerce:e?.coerce??!1,...w(e)});var Ie=class extends T{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.boolean,received:t.parsedType}),y}return b(e.data)}};Ie.create=e=>new Ie({typeName:z.ZodBoolean,coerce:e?.coerce||!1,...w(e)});var Le=class e extends T{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.date,received:t.parsedType}),y}if(Number.isNaN(e.data.getTime()))return _(this._getOrReturnCtx(e),{code:m.invalid_date}),y;let t=new v,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),_(n,{code:m.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),_(n,{code:m.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):d.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:S.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:S.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Le.create=e=>new Le({checks:[],coerce:e?.coerce||!1,typeName:z.ZodDate,...w(e)});var Re=class extends T{_parse(e){if(this._getType(e)!==f.symbol){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.symbol,received:t.parsedType}),y}return b(e.data)}};Re.create=e=>new Re({typeName:z.ZodSymbol,...w(e)});var ze=class extends T{_parse(e){if(this._getType(e)!==f.undefined){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.undefined,received:t.parsedType}),y}return b(e.data)}};ze.create=e=>new ze({typeName:z.ZodUndefined,...w(e)});var Be=class extends T{_parse(e){if(this._getType(e)!==f.null){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.null,received:t.parsedType}),y}return b(e.data)}};Be.create=e=>new Be({typeName:z.ZodNull,...w(e)});var Ve=class extends T{constructor(){super(...arguments),this._any=!0}_parse(e){return b(e.data)}};Ve.create=e=>new Ve({typeName:z.ZodAny,...w(e)});var E=class extends T{constructor(){super(...arguments),this._unknown=!0}_parse(e){return b(e.data)}};E.create=e=>new E({typeName:z.ZodUnknown,...w(e)});var D=class extends T{_parse(e){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.never,received:t.parsedType}),y}};D.create=e=>new D({typeName:z.ZodNever,...w(e)});var He=class extends T{_parse(e){if(this._getType(e)!==f.undefined){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.void,received:t.parsedType}),y}return b(e.data)}};He.create=e=>new He({typeName:z.ZodVoid,...w(e)});var O=class e extends T{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==f.array)return _(t,{code:m.invalid_type,expected:f.array,received:t.parsedType}),y;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(_(t,{code:e?m.too_big:m.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(_(t,{code:m.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(_(t,{code:m.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new C(t,e,t.path,n)))).then(e=>v.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new C(t,e,t.path,n)));return v.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:S.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:S.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:S.toString(n)}})}nonempty(e){return this.min(1,e)}};O.create=(e,t)=>new O({type:e,minLength:null,maxLength:null,exactLength:null,typeName:z.ZodArray,...w(t)});function k(e){if(e instanceof A){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=L.create(k(r))}return new A({...e._def,shape:()=>t})}else if(e instanceof O)return new O({...e._def,type:k(e.element)});else if(e instanceof L)return L.create(k(e.unwrap()));else if(e instanceof R)return R.create(k(e.unwrap()));else if(e instanceof N)return N.create(e.items.map(e=>k(e)));else return e}var A=class e extends T{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:d.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==f.object){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.object,received:t.parsedType}),y}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof D&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new C(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof D){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(_(n,{code:m.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new C(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>v.mergeObjectSync(t,e)):v.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return S.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:S.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:z.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of d.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of d.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return k(this)}partial(t){let n={};for(let e of d.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of d.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof L;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Qe(d.objectKeys(this.shape))}};A.create=(e,t)=>new A({shape:()=>e,unknownKeys:`strip`,catchall:D.create(),typeName:z.ZodObject,...w(t)}),A.strictCreate=(e,t)=>new A({shape:()=>e,unknownKeys:`strict`,catchall:D.create(),typeName:z.ZodObject,...w(t)}),A.lazycreate=(e,t)=>new A({shape:e,unknownKeys:`strip`,catchall:D.create(),typeName:z.ZodObject,...w(t)});var Ue=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new h(e.ctx.common.issues));return _(t,{code:m.invalid_union,unionErrors:n}),y}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new h(e));return _(t,{code:m.invalid_union,unionErrors:i}),y}}get options(){return this._def.options}};Ue.create=(e,t)=>new Ue({options:e,typeName:z.ZodUnion,...w(t)});let j=e=>e instanceof Xe?j(e.schema):e instanceof I?j(e.innerType()):e instanceof Ze?[e.value]:e instanceof P?e.options:e instanceof $e?d.objectValues(e.enum):e instanceof et?j(e._def.innerType):e instanceof ze?[void 0]:e instanceof Be?[null]:e instanceof L?[void 0,...j(e.unwrap())]:e instanceof R?[null,...j(e.unwrap())]:e instanceof rt||e instanceof at?j(e.unwrap()):e instanceof tt?j(e._def.innerType):[];var We=class e extends T{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return _(t,{code:m.invalid_type,expected:f.object,received:t.parsedType}),y;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);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}):(_(t,{code:m.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),y)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=j(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:z.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...w(r)})}};function Ge(e,t){let n=p(e),r=p(t);if(e===t)return{valid:!0,data:e};if(n===f.object&&r===f.object){let n=d.objectKeys(t),r=d.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Ge(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===f.array&&r===f.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Ge(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===f.date&&r===f.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var M=class extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(ae(e)||ae(r))return y;let i=Ge(e.value,r.value);return i.valid?((oe(e)||oe(r))&&t.dirty(),{status:t.value,value:i.data}):(_(n,{code:m.invalid_intersection_types}),y)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};M.create=(e,t,n)=>new M({left:e,right:t,typeName:z.ZodIntersection,...w(n)});var N=class e extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return _(n,{code:m.invalid_type,expected:f.array,received:n.parsedType}),y;if(n.data.length<this._def.items.length)return _(n,{code:m.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),y;!this._def.rest&&n.data.length>this._def.items.length&&(_(n,{code:m.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new C(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>v.mergeArray(t,e)):v.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};N.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new N({items:e,typeName:z.ZodTuple,rest:null,...w(t)})};var Ke=class e extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return _(n,{code:m.invalid_type,expected:f.object,received:n.parsedType}),y;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new C(n,e,n.path,e)),value:a._parse(new C(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?v.mergeObjectAsync(t,r):v.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof T?new e({keyType:t,valueType:n,typeName:z.ZodRecord,...w(r)}):new e({keyType:Me.create(),valueType:t,typeName:z.ZodRecord,...w(n)})}},qe=class extends T{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return _(n,{code:m.invalid_type,expected:f.map,received:n.parsedType}),y;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new C(n,e,n.path,[a,`key`])),value:i._parse(new C(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return y;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return y;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};qe.create=(e,t,n)=>new qe({valueType:t,keyType:e,typeName:z.ZodMap,...w(n)});var Je=class e extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return _(n,{code:m.invalid_type,expected:f.set,received:n.parsedType}),y;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(_(n,{code:m.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(_(n,{code:m.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return y;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new C(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:S.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:S.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Je.create=(e,t)=>new Je({valueType:e,minSize:null,maxSize:null,typeName:z.ZodSet,...w(t)});var Ye=class e extends T{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return _(t,{code:m.invalid_type,expected:f.function,received:t.parsedType}),y;function n(e,n){return re({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ne(),g].filter(e=>!!e),issueData:{code:m.invalid_arguments,argumentsError:n}})}function r(e,n){return re({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ne(),g].filter(e=>!!e),issueData:{code:m.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof F){let e=this;return b(async function(...t){let o=new h([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return b(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new h([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new h([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:N.create(t).rest(E.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||N.create([]).rest(E.create()),returns:n||E.create(),typeName:z.ZodFunction,...w(r)})}},Xe=class extends T{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Xe.create=(e,t)=>new Xe({getter:e,typeName:z.ZodLazy,...w(t)});var Ze=class extends T{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return _(t,{received:t.data,code:m.invalid_literal,expected:this._def.value}),y}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Ze.create=(e,t)=>new Ze({value:e,typeName:z.ZodLiteral,...w(t)});function Qe(e,t){return new P({values:e,typeName:z.ZodEnum,...w(t)})}var P=class e extends T{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return _(t,{expected:d.joinValues(n),received:t.parsedType,code:m.invalid_type}),y}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return _(t,{received:t.data,code:m.invalid_enum_value,options:n}),y}return b(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};P.create=Qe;var $e=class extends T{_parse(e){let t=d.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let e=d.objectValues(t);return _(n,{expected:d.joinValues(e),received:n.parsedType,code:m.invalid_type}),y}if(this._cache||=new Set(d.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=d.objectValues(t);return _(n,{received:n.data,code:m.invalid_enum_value,options:e}),y}return b(e.data)}get enum(){return this._def.values}};$e.create=(e,t)=>new $e({values:e,typeName:z.ZodNativeEnum,...w(t)});var F=class extends T{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==f.promise&&t.common.async===!1?(_(t,{code:m.invalid_type,expected:f.promise,received:t.parsedType}),y):b((t.parsedType===f.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};F.create=(e,t)=>new F({type:e,typeName:z.ZodPromise,...w(t)});var I=class extends T{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{_(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return y;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?y:r.status===`dirty`||t.value===`dirty`?ie(r.value):r});{if(t.value===`aborted`)return y;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?y:r.status===`dirty`||t.value===`dirty`?ie(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?y:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?y:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!x(e))return y;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>x(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):y);d.assertNever(r)}};I.create=(e,t,n)=>new I({schema:e,typeName:z.ZodEffects,effect:t,...w(n)}),I.createWithPreprocess=(e,t,n)=>new I({schema:t,effect:{type:`preprocess`,transform:e},typeName:z.ZodEffects,...w(n)});var L=class extends T{_parse(e){return this._getType(e)===f.undefined?b(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};L.create=(e,t)=>new L({innerType:e,typeName:z.ZodOptional,...w(t)});var R=class extends T{_parse(e){return this._getType(e)===f.null?b(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};R.create=(e,t)=>new R({innerType:e,typeName:z.ZodNullable,...w(t)});var et=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};et.create=(e,t)=>new et({innerType:e,typeName:z.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...w(t)});var tt=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return se(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new h(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new h(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};tt.create=(e,t)=>new tt({innerType:e,typeName:z.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...w(t)});var nt=class extends T{_parse(e){if(this._getType(e)!==f.nan){let t=this._getOrReturnCtx(e);return _(t,{code:m.invalid_type,expected:f.nan,received:t.parsedType}),y}return{status:`valid`,value:e.data}}};nt.create=e=>new nt({typeName:z.ZodNaN,...w(e)});var rt=class extends T{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},it=class e extends T{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?y:e.status===`dirty`?(t.dirty(),ie(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?y:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:z.ZodPipeline})}},at=class extends T{_parse(e){let t=this._def.innerType._parse(e),n=e=>(x(e)&&(e.value=Object.freeze(e.value)),e);return se(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};at.create=(e,t)=>new at({innerType:e,typeName:z.ZodReadonly,...w(t)}),A.lazycreate;var z;(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`})(z||={});let ot=Me.create,st=Pe.create;nt.create,Fe.create;let ct=Ie.create;Le.create,Re.create,ze.create;let lt=Be.create,B=Ve.create;E.create;let ut=D.create;He.create;let dt=O.create,V=A.create;A.strictCreate;let H=Ue.create;We.create;let ft=M.create,pt=N.create,mt=Ke.create;qe.create,Je.create,Ye.create,Xe.create;let ht=Ze.create,gt=P.create;$e.create,F.create,I.create,L.create,R.create,I.createWithPreprocess,it.create;var _t=e=>[e.slice(0,e.length/2),e.slice(e.length/2)],U=Symbol(`Original index`),vt=e=>{let t=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`boolean`)t.push(r?{[U]:n}:{[U]:n,not:{}});else if(U in r)return e;else t.push({...r,[U]:n})}return t};function yt(e,t){if(e.allOf.length===0)return ut();if(e.allOf.length===1){let n=e.allOf[0];return K(n,{...t,path:[...t.path,`allOf`,n[U]]})}let[n,r]=_t(vt(e.allOf));return ft(yt({allOf:n},t),yt({allOf:r},t))}var bt=(e,t)=>e.anyOf.length?e.anyOf.length===1?K(e.anyOf[0],{...t,path:[...t.path,`anyOf`,0]}):H(e.anyOf.map((e,n)=>K(e,{...t,path:[...t.path,`anyOf`,n]}))):B();function W(e,t,n,r){let i=t[n];if(i!==void 0){let a=t.errorMessage?.[n];return r(e,i,a)}return e}var G={an:{object:e=>e.type===`object`||!e.type&&(e.properties!==void 0||e.additionalProperties!==void 0||e.patternProperties!==void 0),array:e=>e.type===`array`,anyOf:e=>e.anyOf!==void 0,allOf:e=>e.allOf!==void 0,enum:e=>e.enum!==void 0},a:{nullable:e=>e.nullable===!0,multipleType:e=>Array.isArray(e.type),not:e=>e.not!==void 0,const:e=>e.const!==void 0,primitive:(e,t)=>e.type===t,conditional:e=>!!(`if`in e&&e.if&&`then`in e&&`else`in e&&e.then&&e.else),oneOf:e=>e.oneOf!==void 0}},xt=(e,t)=>{if(G.an.anyOf(e)){let n=new Set,r=[];e.anyOf.forEach(e=>{if(typeof e==`object`&&e.type&&n.add(typeof e.type==`string`?e.type:e.type[0]),typeof e==`object`&&e.items){let t=e.items;!Array.isArray(t)&&typeof t==`object`&&r.push(t)}});let i;r.length===1?i=r[0]:r.length>1&&(i={anyOf:r});let a={...n.size>0?{type:Array.from(n)}:{type:`array`},...i&&{items:i}};return[`default`,`description`,`examples`,`title`].forEach(t=>{let n=e[t];n!==void 0&&(a[t]=n)}),K(a,t)}if(Array.isArray(e.items))return pt(e.items.map((e,n)=>K(e,{...t,path:[...t.path,`items`,n]})));let n=e.items?dt(K(e.items,{...t,path:[...t.path,`items`]})):dt(B());return n=W(n,e,`minItems`,(e,t,n)=>e.min(t,n)),n=W(n,e,`maxItems`,(e,t,n)=>e.max(t,n)),typeof e.min==`number`&&typeof e.minItems!=`number`&&(n=W(n,{...e,minItems:e.min},`minItems`,(e,t,n)=>e.min(t,n))),typeof e.max==`number`&&typeof e.maxItems!=`number`&&(n=W(n,{...e,maxItems:e.max},`maxItems`,(e,t,n)=>e.max(t,n))),n},St=e=>ct(),Ct=e=>ht(e.const),wt=e=>B(),Tt=e=>e.enum.length===0?ut():e.enum.length===1?ht(e.enum[0]):e.enum.every(e=>typeof e==`string`)?gt(e.enum):H(e.enum.map(e=>ht(e))),Et=(e,t)=>{let n=K(e.if,{...t,path:[...t.path,`if`]}),r=K(e.then,{...t,path:[...t.path,`then`]}),i=K(e.else,{...t,path:[...t.path,`else`]});return H([r,i]).superRefine((e,t)=>{let a=n.safeParse(e).success?r.safeParse(e):i.safeParse(e);a.success||a.error.errors.forEach(e=>t.addIssue(e))})},Dt=(e,t)=>H(e.type.map(n=>K({...e,type:n},t))),Ot=(e,t)=>B().refine(n=>!K(e.not,{...t,path:[...t.path,`not`]}).safeParse(n).success,`Invalid input: Should NOT be valid against schema`),kt=e=>lt(),At=(e,...t)=>Object.keys(e).reduce((n,r)=>(t.includes(r)||(n[r]=e[r]),n),{}),jt=(e,t)=>{let n=e.default===null,r=K(n?At(At(e,`nullable`),`default`):At(e,`nullable`),t,!0).nullable();return n?r.default(null):r},Mt=e=>{let t=st(),n=!1;return e.type===`integer`?(n=!0,t=W(t,e,`type`,(e,t,n)=>e.int(n))):e.format===`int64`&&(n=!0,t=W(t,e,`format`,(e,t,n)=>e.int(n))),t=W(t,e,`multipleOf`,(e,t,r)=>t===1?n?e:e.int(r):e.multipleOf(t,r)),typeof e.minimum==`number`?t=e.exclusiveMinimum===!0?W(t,e,`minimum`,(e,t,n)=>e.gt(t,n)):W(t,e,`minimum`,(e,t,n)=>e.gte(t,n)):typeof e.exclusiveMinimum==`number`&&(t=W(t,e,`exclusiveMinimum`,(e,t,n)=>e.gt(t,n))),typeof e.maximum==`number`?t=e.exclusiveMaximum===!0?W(t,e,`maximum`,(e,t,n)=>e.lt(t,n)):W(t,e,`maximum`,(e,t,n)=>e.lte(t,n)):typeof e.exclusiveMaximum==`number`&&(t=W(t,e,`exclusiveMaximum`,(e,t,n)=>e.lt(t,n))),typeof e.min==`number`&&typeof e.minimum!=`number`&&(t=W(t,{...e,minimum:e.min},`minimum`,(e,t,n)=>e.gte(t,n))),typeof e.max==`number`&&typeof e.maximum!=`number`&&(t=W(t,{...e,maximum:e.max},`maximum`,(e,t,n)=>e.lte(t,n))),t},Nt=(e,t)=>e.oneOf.length?e.oneOf.length===1?K(e.oneOf[0],{...t,path:[...t.path,`oneOf`,0]}):B().superRefine((n,r)=>{let i=e.oneOf.map((e,n)=>K(e,{...t,path:[...t.path,`oneOf`,n]})),a=i.reduce((e,t)=>(t=>t.error?[...e,t.error]:e)(t.safeParse(n)),[]);i.length-a.length!==1&&r.addIssue({path:r.path,code:`invalid_union`,unionErrors:a,message:`Invalid input: Should pass single schema`})}):B();function Pt(e,t){if(!e.properties)return V({});let n=Object.keys(e.properties);if(n.length===0)return V({});let r={};for(let i of n){let n=e.properties[i],a=K(n,{...t,path:[...t.path,`properties`,i]}),o=Array.isArray(e.required)?e.required.includes(i):!1;if(!o&&n&&typeof n==`object`&&`default`in n)if(n.default===null){let e=n.anyOf&&Array.isArray(n.anyOf)&&n.anyOf.some(e=>typeof e==`object`&&!!e&&e.type===`null`),t=n.oneOf&&Array.isArray(n.oneOf)&&n.oneOf.some(e=>typeof e==`object`&&!!e&&e.type===`null`),o=`nullable`in n&&n.nullable===!0;e||t||o?r[i]=a.optional().default(null):r[i]=a.nullable().optional().default(null)}else r[i]=a.optional().default(n.default);else r[i]=o?a:a.optional()}return V(r)}function Ft(e,t){let n=Object.keys(e.patternProperties??{}).length>0,r=e.type===`object`?e:{...e,type:`object`},i=Pt(r,t),a=i,o=r.additionalProperties===void 0?void 0:K(r.additionalProperties,{...t,path:[...t.path,`additionalProperties`]}),s=r.additionalProperties===!0;if(r.patternProperties){let e=Object.fromEntries(Object.entries(r.patternProperties).map(([e,n])=>[e,K(n,{...t,path:[...t.path,`patternProperties`,e]})])),n=Object.values(e);a=i?o?i.catchall(H([...n,o])):Object.keys(e).length>1?i.catchall(H(n)):i.catchall(n[0]):o?mt(H([...n,o])):n.length>1?mt(H(n)):mt(n[0]);let s=new Set(Object.keys(r.properties??{}));a=a.superRefine((t,n)=>{for(let i in t){let a=s.has(i);for(let o in r.patternProperties){let r=new RegExp(o);if(i.match(r)){a=!0;let r=e[o].safeParse(t[i]);r.success||n.addIssue({path:[...n.path,i],code:`custom`,message:`Invalid input: Key matching regex /${i}/ must match schema`,params:{issues:r.error.issues}})}}if(!a&&o){let e=o.safeParse(t[i]);e.success||n.addIssue({path:[...n.path,i],code:`custom`,message:`Invalid input: must match catchall schema`,params:{issues:e.error.issues}})}}})}let c;return c=i?n?a:o?o instanceof D?i.strict():s?i.passthrough():i.catchall(o):i.strict():n?a:o?o instanceof D?V({}).strict():s?V({}).passthrough():mt(o):V({}).passthrough(),G.an.anyOf(e)&&(c=c.and(bt({...e,anyOf:e.anyOf.map(e=>typeof e==`object`&&!e.type&&(e.properties??e.additionalProperties??e.patternProperties)?{...e,type:`object`}:e)},t))),G.a.oneOf(e)&&(c=c.and(Nt({...e,oneOf:e.oneOf.map(e=>typeof e==`object`&&!e.type&&(e.properties??e.additionalProperties??e.patternProperties)?{...e,type:`object`}:e)},t))),G.an.allOf(e)&&(c=c.and(yt({...e,allOf:e.allOf.map(e=>typeof e==`object`&&!e.type&&(e.properties??e.additionalProperties??e.patternProperties)?{...e,type:`object`}:e)},t))),c}var It=e=>{let t=ot();return t=W(t,e,`format`,(e,t,n)=>{switch(t){case`email`:return e.email(n);case`ip`:return e.ip(n);case`ipv4`:return e.ip({version:`v4`,message:n});case`ipv6`:return e.ip({version:`v6`,message:n});case`uri`:return e.url(n);case`uuid`:return e.uuid(n);case`date-time`:return e.datetime({offset:!0,message:n});case`time`:return e.time(n);case`date`:return e.date(n);case`binary`:return e.base64(n);case`duration`:return e.duration(n);default:return e}}),t=W(t,e,`contentEncoding`,(e,t,n)=>e.base64(n)),t=W(t,e,`pattern`,(e,t,n)=>e.regex(new RegExp(t),n)),t=W(t,e,`minLength`,(e,t,n)=>e.min(t,n)),t=W(t,e,`maxLength`,(e,t,n)=>e.max(t,n)),typeof e.min==`number`&&typeof e.minLength!=`number`&&(t=W(t,{...e,minLength:e.min},`minLength`,(e,t,n)=>e.min(t,n))),typeof e.max==`number`&&typeof e.maxLength!=`number`&&(t=W(t,{...e,maxLength:e.max},`maxLength`,(e,t,n)=>e.max(t,n))),t},Lt=(e,t)=>{let n=``;if(e.description?n=e.description:e.title&&(n=e.title),e.example!==void 0){let t=`Example: ${JSON.stringify(e.example)}`;n=n?`${n}
4
2
  ${t}`:t}else if(e.examples!==void 0&&Array.isArray(e.examples)){let t=e.examples;if(t&&t.length&&t.length>0){let e=t.length===1?`Example: ${JSON.stringify(t[0])}`:`Examples:
5
3
  ${t.map(e=>` ${JSON.stringify(e)}`).join(`
6
4
  `)}`;n=n?`${n}
7
- ${e}`:e}}return n&&(t=t.describe(n)),t},za=(e,t,n)=>{if(e.default!==void 0){if(e.default===null&&n?.path.some(e=>e===`anyOf`||e===`oneOf`)&&e.type&&e.type!==`null`&&!e.nullable)return t;t=t.default(e.default)}return t},Ba=(e,t)=>(e.readOnly&&(t=t.readonly()),t),Va=(e,t)=>xa.a.nullable(e)?Ma(e,t):xa.an.object(e)?Ia(e,t):xa.an.array(e)?Sa(e,t):xa.an.anyOf(e)?ba(e,t):xa.an.allOf(e)?ya(e,t):xa.a.oneOf(e)?Pa(e,t):xa.a.not(e)?ka(e,t):xa.an.enum(e)?Ea(e):xa.a.const(e)?wa(e):xa.a.multipleType(e)?Oa(e,t):xa.a.primitive(e,`string`)?La(e):xa.a.primitive(e,`number`)||xa.a.primitive(e,`integer`)?Na(e):xa.a.primitive(e,`boolean`)?Ca(e):xa.a.primitive(e,`null`)?Aa(e):xa.a.conditional(e)?Da(e,t):Ta(e),Ha=(e,t={seen:new Map,path:[]},n)=>{if(typeof e!=`object`)return e?tt():rt();if(t.parserOverride){let n=t.parserOverride(e,t);if(n instanceof N)return n}let r=t.seen.get(e);if(r){if(r.r!==void 0)return r.r;if(t.depth===void 0||r.n>=t.depth)return tt();r.n+=1}else r={r:void 0,n:0},t.seen.set(e,r);let i=Va(e,t);return n||(t.withoutDescribes||(i=Ra(e,i)),t.withoutDefaults||(i=za(e,i,t)),i=Ba(e,i)),r.r=i,i},Ua=(e,t={})=>Ha(e,{path:[],seen:new Map,...t});function Wa(e){if(typeof e!=`object`||!e||`type`in e&&typeof e.type==`string`)return!1;let t=Object.values(e);return t.length===0?!1:t.some(e=>e instanceof N)}function Ga(e){try{return Ua(e)}catch(e){return console.warn(`[Web Model Context] Failed to convert JSON Schema to Zod:`,e),Y({}).passthrough()}}function Ka(e){let t={},n=[];for(let[r,i]of Object.entries(e)){let e=i.description||void 0,a=`string`,o,s;if(i instanceof pe)a=`string`;else if(i instanceof he)a=`number`;else if(i instanceof _e)a=`boolean`;else if(i instanceof Ee){a=`array`;let e=i.element;s=e instanceof pe?{type:`string`}:e instanceof he?{type:`number`}:e instanceof _e?{type:`boolean`}:{type:`string`}}else if(i instanceof Oe)a=`object`;else if(i instanceof He){a=`string`;let e=i._def;e?.values&&(o=e.values)}let c={type:a};e&&(c.description=e),o&&(c.enum=o),s&&(c.items=s),t[r]=c,i.isOptional()||n.push(r)}return{type:`object`,properties:t,...n.length>0&&{required:n}}}function qa(e){if(Wa(e))return{jsonSchema:Ka(e),zodValidator:Y(e)};let t=e;return{jsonSchema:t,zodValidator:Ga(t)}}function Ja(e,t){let n=t.safeParse(e);return n.success?{success:!0,data:n.data}:{success:!1,error:`Validation failed:\n${n.error.errors.map(e=>` - ${e.path.join(`.`)||`root`}: ${e.message}`).join(`
8
- `)}`}}function Ya(){if(typeof window>`u`||typeof navigator>`u`)return{hasNativeContext:!1,hasNativeTesting:!1};let e=navigator.modelContext,t=navigator.modelContextTesting;return!e||!t||(t.constructor?.name||``).includes(`WebModelContext`)?{hasNativeContext:!1,hasNativeTesting:!1}:{hasNativeContext:!0,hasNativeTesting:!0}}var Xa=class{nativeContext;nativeTesting;bridge;syncInProgress=!1;constructor(e,t,n){this.bridge=e,this.nativeContext=t,this.nativeTesting=n,this.nativeTesting.registerToolsChangedCallback(()=>{console.log(`[Native Adapter] Tool change detected from native API`),this.syncToolsFromNative()}),this.syncToolsFromNative()}syncToolsFromNative(){if(!this.syncInProgress){this.syncInProgress=!0;try{let e=this.nativeTesting.listTools();console.log(`[Native Adapter] Syncing ${e.length} tools from native API`),this.bridge.tools.clear();for(let t of e)try{let e=JSON.parse(t.inputSchema),n={name:t.name,description:t.description,inputSchema:e,execute:async e=>{let n=await this.nativeTesting.executeTool(t.name,JSON.stringify(e));return this.convertToToolResponse(n)},inputValidator:Ga(e)};this.bridge.tools.set(t.name,n)}catch(e){console.error(`[Native Adapter] Failed to sync tool "${t.name}":`,e)}this.notifyMCPServers()}finally{this.syncInProgress=!1}}}convertToToolResponse(e){return typeof e==`string`?{content:[{type:`text`,text:e}]}:e==null?{content:[{type:`text`,text:``}]}:typeof e==`object`?{content:[{type:`text`,text:JSON.stringify(e,null,2)}],structuredContent:e}:{content:[{type:`text`,text:String(e)}]}}notifyMCPServers(){this.bridge.tabServer?.notification&&this.bridge.tabServer.notification({method:`notifications/tools/list_changed`,params:{}}),this.bridge.iframeServer?.notification&&this.bridge.iframeServer.notification({method:`notifications/tools/list_changed`,params:{}})}provideContext(e){console.log(`[Native Adapter] Delegating provideContext to native API`),this.nativeContext.provideContext(e)}registerTool(e){return console.log(`[Native Adapter] Delegating registerTool("${e.name}") to native API`),this.nativeContext.registerTool(e)}unregisterTool(e){console.log(`[Native Adapter] Delegating unregisterTool("${e}") to native API`),this.nativeContext.unregisterTool(e)}clearContext(){console.log(`[Native Adapter] Delegating clearContext to native API`),this.nativeContext.clearContext()}async executeTool(e,t){console.log(`[Native Adapter] Executing tool "${e}" via native API`);try{let n=await this.nativeTesting.executeTool(e,JSON.stringify(t));return this.convertToToolResponse(n)}catch(t){return console.error(`[Native Adapter] Error executing tool "${e}":`,t),{content:[{type:`text`,text:`Error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}listTools(){return Array.from(this.bridge.tools.values()).map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,...e.outputSchema&&{outputSchema:e.outputSchema},...e.annotations&&{annotations:e.annotations}}))}registerResource(e){return console.warn(`[Native Adapter] registerResource is not supported by native API`),{unregister:()=>{}}}unregisterResource(e){console.warn(`[Native Adapter] unregisterResource is not supported by native API`)}listResources(){return[]}listResourceTemplates(){return[]}async readResource(e){throw Error(`[Native Adapter] readResource is not supported by native API`)}registerPrompt(e){return console.warn(`[Native Adapter] registerPrompt is not supported by native API`),{unregister:()=>{}}}unregisterPrompt(e){console.warn(`[Native Adapter] unregisterPrompt is not supported by native API`)}listPrompts(){return[]}async getPrompt(e,t){throw Error(`[Native Adapter] getPrompt is not supported by native API`)}addEventListener(e,t,n){this.nativeContext.addEventListener(e,t,n)}removeEventListener(e,t,n){this.nativeContext.removeEventListener(e,t,n)}dispatchEvent(e){return this.nativeContext.dispatchEvent(e)}async createMessage(e){console.log(`[Native Adapter] Requesting sampling from client`);let t=this.bridge.tabServer.server;if(!t?.createMessage)throw Error(`Sampling is not supported: no connected client with sampling capability`);return t.createMessage(e)}async elicitInput(e){console.log(`[Native Adapter] Requesting elicitation from client`);let t=this.bridge.tabServer.server;if(!t?.elicitInput)throw Error(`Elicitation is not supported: no connected client with elicitation capability`);return t.elicitInput(e)}},Za=class extends Event{name;arguments;_response=null;_responded=!1;constructor(e,t){super(`toolcall`,{cancelable:!0}),this.name=e,this.arguments=t}respondWith(e){if(this._responded)throw Error(`Response already provided for this tool call`);this._response=e,this._responded=!0}getResponse(){return this._response}hasResponse(){return this._responded}},Qa=class{toolCallHistory=[];mockResponses=new Map;toolsChangedCallbacks=new Set;bridge;constructor(e){this.bridge=e}recordToolCall(e,t){this.toolCallHistory.push({toolName:e,arguments:t,timestamp:Date.now()})}hasMockResponse(e){return this.mockResponses.has(e)}getMockResponse(e){return this.mockResponses.get(e)}notifyToolsChanged(){for(let e of this.toolsChangedCallbacks)try{e()}catch(e){console.error(`[Model Context Testing] Error in tools changed callback:`,e)}}async executeTool(e,t){console.log(`[Model Context Testing] Executing tool: ${e}`);let n;try{n=JSON.parse(t)}catch(e){throw SyntaxError(`Invalid JSON input: ${e instanceof Error?e.message:String(e)}`)}if(!this.bridge.tools.get(e))throw Error(`Tool not found: ${e}`);let r=await this.bridge.modelContext.executeTool(e,n);if(!r.isError){if(r.structuredContent)return r.structuredContent;if(r.content&&r.content.length>0){let e=r.content[0];if(e&&e.type===`text`)return e.text}}}listTools(){return this.bridge.modelContext.listTools().map(e=>({name:e.name,description:e.description,inputSchema:JSON.stringify(e.inputSchema)}))}registerToolsChangedCallback(e){this.toolsChangedCallbacks.add(e),console.log(`[Model Context Testing] Tools changed callback registered`)}getToolCalls(){return[...this.toolCallHistory]}clearToolCalls(){this.toolCallHistory=[],console.log(`[Model Context Testing] Tool call history cleared`)}setMockToolResponse(e,t){this.mockResponses.set(e,t),console.log(`[Model Context Testing] Mock response set for tool: ${e}`)}clearMockToolResponse(e){this.mockResponses.delete(e),console.log(`[Model Context Testing] Mock response cleared for tool: ${e}`)}clearAllMockToolResponses(){this.mockResponses.clear(),console.log(`[Model Context Testing] All mock responses cleared`)}getRegisteredTools(){return this.bridge.modelContext.listTools()}reset(){this.clearToolCalls(),this.clearAllMockToolResponses(),console.log(`[Model Context Testing] Testing state reset`)}},$a=class{bridge;eventTarget;provideContextTools;dynamicTools;provideContextResources;dynamicResources;provideContextPrompts;dynamicPrompts;toolRegistrationTimestamps;resourceRegistrationTimestamps;promptRegistrationTimestamps;toolUnregisterFunctions;resourceUnregisterFunctions;promptUnregisterFunctions;testingAPI;constructor(e){this.bridge=e,this.eventTarget=new EventTarget,this.provideContextTools=new Map,this.dynamicTools=new Map,this.toolRegistrationTimestamps=new Map,this.toolUnregisterFunctions=new Map,this.provideContextResources=new Map,this.dynamicResources=new Map,this.resourceRegistrationTimestamps=new Map,this.resourceUnregisterFunctions=new Map,this.provideContextPrompts=new Map,this.dynamicPrompts=new Map,this.promptRegistrationTimestamps=new Map,this.promptUnregisterFunctions=new Map}setTestingAPI(e){this.testingAPI=e}addEventListener(e,t,n){this.eventTarget.addEventListener(e,t,n)}removeEventListener(e,t,n){this.eventTarget.removeEventListener(e,t,n)}dispatchEvent(e){return this.eventTarget.dispatchEvent(e)}provideContext(e){let t=e.tools?.length??0,n=e.resources?.length??0,r=e.prompts?.length??0;console.log(`[Web Model Context] provideContext: ${t} tools, ${n} resources, ${r} prompts`),this.provideContextTools.clear(),this.provideContextResources.clear(),this.provideContextPrompts.clear();for(let t of e.tools??[]){if(this.dynamicTools.has(t.name))throw Error(`[Web Model Context] Tool name collision: "${t.name}" is already registered via registerTool(). Please use a different name or unregister the dynamic tool first.`);let{jsonSchema:e,zodValidator:n}=qa(t.inputSchema),r=t.outputSchema?qa(t.outputSchema):null,i={name:t.name,description:t.description,inputSchema:e,...r&&{outputSchema:r.jsonSchema},...t.annotations&&{annotations:t.annotations},execute:t.execute,inputValidator:n,...r&&{outputValidator:r.zodValidator}};this.provideContextTools.set(t.name,i)}for(let t of e.resources??[]){if(this.dynamicResources.has(t.uri))throw Error(`[Web Model Context] Resource URI collision: "${t.uri}" is already registered via registerResource(). Please use a different URI or unregister the dynamic resource first.`);let e=this.validateResource(t);this.provideContextResources.set(t.uri,e)}for(let t of e.prompts??[]){if(this.dynamicPrompts.has(t.name))throw Error(`[Web Model Context] Prompt name collision: "${t.name}" is already registered via registerPrompt(). Please use a different name or unregister the dynamic prompt first.`);let e=this.validatePrompt(t);this.provideContextPrompts.set(t.name,e)}this.updateBridgeTools(),this.updateBridgeResources(),this.updateBridgePrompts(),this.notifyToolsListChanged(),this.notifyResourcesListChanged(),this.notifyPromptsListChanged()}validateResource(e){let t=/\{([^}]+)\}/g,n=[];for(let r of e.uri.matchAll(t)){let e=r[1];e&&n.push(e)}return{uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType,read:e.read,isTemplate:n.length>0,templateParams:n}}validatePrompt(e){let t,n;if(e.argsSchema){let r=qa(e.argsSchema);t=r.jsonSchema,n=r.zodValidator}return{name:e.name,description:e.description,argsSchema:t,get:e.get,argsValidator:n}}registerTool(e){console.log(`[Web Model Context] Registering tool dynamically: ${e.name}`);let t=Date.now(),n=this.toolRegistrationTimestamps.get(e.name);if(n&&t-n<50){console.warn(`[Web Model Context] Tool "${e.name}" registered multiple times within 50ms. This is likely due to React Strict Mode double-mounting. Ignoring duplicate registration.`);let t=this.toolUnregisterFunctions.get(e.name);if(t)return{unregister:t}}if(this.provideContextTools.has(e.name))throw Error(`[Web Model Context] Tool name collision: "${e.name}" is already registered via provideContext(). Please use a different name or update your provideContext() call.`);if(this.dynamicTools.has(e.name))throw Error(`[Web Model Context] Tool name collision: "${e.name}" is already registered via registerTool(). Please unregister it first or use a different name.`);let{jsonSchema:r,zodValidator:i}=qa(e.inputSchema),a=e.outputSchema?qa(e.outputSchema):null,o={name:e.name,description:e.description,inputSchema:r,...a&&{outputSchema:a.jsonSchema},...e.annotations&&{annotations:e.annotations},execute:e.execute,inputValidator:i,...a&&{outputValidator:a.zodValidator}};this.dynamicTools.set(e.name,o),this.toolRegistrationTimestamps.set(e.name,t),this.updateBridgeTools(),this.notifyToolsListChanged();let s=()=>{if(console.log(`[Web Model Context] Unregistering tool: ${e.name}`),this.provideContextTools.has(e.name))throw Error(`[Web Model Context] Cannot unregister tool "${e.name}": This tool was registered via provideContext(). Use provideContext() to update the base tool set.`);if(!this.dynamicTools.has(e.name)){console.warn(`[Web Model Context] Tool "${e.name}" is not registered, ignoring unregister call`);return}this.dynamicTools.delete(e.name),this.toolRegistrationTimestamps.delete(e.name),this.toolUnregisterFunctions.delete(e.name),this.updateBridgeTools(),this.notifyToolsListChanged()};return this.toolUnregisterFunctions.set(e.name,s),{unregister:s}}registerResource(e){console.log(`[Web Model Context] Registering resource dynamically: ${e.uri}`);let t=Date.now(),n=this.resourceRegistrationTimestamps.get(e.uri);if(n&&t-n<50){console.warn(`[Web Model Context] Resource "${e.uri}" registered multiple times within 50ms. This is likely due to React Strict Mode double-mounting. Ignoring duplicate registration.`);let t=this.resourceUnregisterFunctions.get(e.uri);if(t)return{unregister:t}}if(this.provideContextResources.has(e.uri))throw Error(`[Web Model Context] Resource URI collision: "${e.uri}" is already registered via provideContext(). Please use a different URI or update your provideContext() call.`);if(this.dynamicResources.has(e.uri))throw Error(`[Web Model Context] Resource URI collision: "${e.uri}" is already registered via registerResource(). Please unregister it first or use a different URI.`);let r=this.validateResource(e);this.dynamicResources.set(e.uri,r),this.resourceRegistrationTimestamps.set(e.uri,t),this.updateBridgeResources(),this.notifyResourcesListChanged();let i=()=>{if(console.log(`[Web Model Context] Unregistering resource: ${e.uri}`),this.provideContextResources.has(e.uri))throw Error(`[Web Model Context] Cannot unregister resource "${e.uri}": This resource was registered via provideContext(). Use provideContext() to update the base resource set.`);if(!this.dynamicResources.has(e.uri)){console.warn(`[Web Model Context] Resource "${e.uri}" is not registered, ignoring unregister call`);return}this.dynamicResources.delete(e.uri),this.resourceRegistrationTimestamps.delete(e.uri),this.resourceUnregisterFunctions.delete(e.uri),this.updateBridgeResources(),this.notifyResourcesListChanged()};return this.resourceUnregisterFunctions.set(e.uri,i),{unregister:i}}unregisterResource(e){console.log(`[Web Model Context] Unregistering resource: ${e}`);let t=this.provideContextResources.has(e),n=this.dynamicResources.has(e);if(!t&&!n){console.warn(`[Web Model Context] Resource "${e}" is not registered, ignoring unregister call`);return}t&&this.provideContextResources.delete(e),n&&(this.dynamicResources.delete(e),this.resourceRegistrationTimestamps.delete(e),this.resourceUnregisterFunctions.delete(e)),this.updateBridgeResources(),this.notifyResourcesListChanged()}listResources(){return Array.from(this.bridge.resources.values()).filter(e=>!e.isTemplate).map(e=>({uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType}))}listResourceTemplates(){return Array.from(this.bridge.resources.values()).filter(e=>e.isTemplate).map(e=>({uriTemplate:e.uri,name:e.name,...e.description!==void 0&&{description:e.description},...e.mimeType!==void 0&&{mimeType:e.mimeType}}))}registerPrompt(e){console.log(`[Web Model Context] Registering prompt dynamically: ${e.name}`);let t=Date.now(),n=this.promptRegistrationTimestamps.get(e.name);if(n&&t-n<50){console.warn(`[Web Model Context] Prompt "${e.name}" registered multiple times within 50ms. This is likely due to React Strict Mode double-mounting. Ignoring duplicate registration.`);let t=this.promptUnregisterFunctions.get(e.name);if(t)return{unregister:t}}if(this.provideContextPrompts.has(e.name))throw Error(`[Web Model Context] Prompt name collision: "${e.name}" is already registered via provideContext(). Please use a different name or update your provideContext() call.`);if(this.dynamicPrompts.has(e.name))throw Error(`[Web Model Context] Prompt name collision: "${e.name}" is already registered via registerPrompt(). Please unregister it first or use a different name.`);let r=this.validatePrompt(e);this.dynamicPrompts.set(e.name,r),this.promptRegistrationTimestamps.set(e.name,t),this.updateBridgePrompts(),this.notifyPromptsListChanged();let i=()=>{if(console.log(`[Web Model Context] Unregistering prompt: ${e.name}`),this.provideContextPrompts.has(e.name))throw Error(`[Web Model Context] Cannot unregister prompt "${e.name}": This prompt was registered via provideContext(). Use provideContext() to update the base prompt set.`);if(!this.dynamicPrompts.has(e.name)){console.warn(`[Web Model Context] Prompt "${e.name}" is not registered, ignoring unregister call`);return}this.dynamicPrompts.delete(e.name),this.promptRegistrationTimestamps.delete(e.name),this.promptUnregisterFunctions.delete(e.name),this.updateBridgePrompts(),this.notifyPromptsListChanged()};return this.promptUnregisterFunctions.set(e.name,i),{unregister:i}}unregisterPrompt(e){console.log(`[Web Model Context] Unregistering prompt: ${e}`);let t=this.provideContextPrompts.has(e),n=this.dynamicPrompts.has(e);if(!t&&!n){console.warn(`[Web Model Context] Prompt "${e}" is not registered, ignoring unregister call`);return}t&&this.provideContextPrompts.delete(e),n&&(this.dynamicPrompts.delete(e),this.promptRegistrationTimestamps.delete(e),this.promptUnregisterFunctions.delete(e)),this.updateBridgePrompts(),this.notifyPromptsListChanged()}listPrompts(){return Array.from(this.bridge.prompts.values()).map(e=>({name:e.name,description:e.description,arguments:e.argsSchema?.properties?Object.entries(e.argsSchema.properties).map(([t,n])=>({name:t,description:n.description,required:e.argsSchema?.required?.includes(t)??!1})):void 0}))}unregisterTool(e){console.log(`[Web Model Context] Unregistering tool: ${e}`);let t=this.provideContextTools.has(e),n=this.dynamicTools.has(e);if(!t&&!n){console.warn(`[Web Model Context] Tool "${e}" is not registered, ignoring unregister call`);return}t&&this.provideContextTools.delete(e),n&&(this.dynamicTools.delete(e),this.toolRegistrationTimestamps.delete(e),this.toolUnregisterFunctions.delete(e)),this.updateBridgeTools(),this.notifyToolsListChanged()}clearContext(){console.log(`[Web Model Context] Clearing all context (tools, resources, prompts)`),this.provideContextTools.clear(),this.dynamicTools.clear(),this.toolRegistrationTimestamps.clear(),this.toolUnregisterFunctions.clear(),this.provideContextResources.clear(),this.dynamicResources.clear(),this.resourceRegistrationTimestamps.clear(),this.resourceUnregisterFunctions.clear(),this.provideContextPrompts.clear(),this.dynamicPrompts.clear(),this.promptRegistrationTimestamps.clear(),this.promptUnregisterFunctions.clear(),this.updateBridgeTools(),this.updateBridgeResources(),this.updateBridgePrompts(),this.notifyToolsListChanged(),this.notifyResourcesListChanged(),this.notifyPromptsListChanged()}updateBridgeTools(){this.bridge.tools.clear();for(let[e,t]of this.provideContextTools)this.bridge.tools.set(e,t);for(let[e,t]of this.dynamicTools)this.bridge.tools.set(e,t);console.log(`[Web Model Context] Updated bridge with ${this.provideContextTools.size} base tools + ${this.dynamicTools.size} dynamic tools = ${this.bridge.tools.size} total`)}notifyToolsListChanged(){this.bridge.tabServer.notification&&this.bridge.tabServer.notification({method:`notifications/tools/list_changed`,params:{}}),this.bridge.iframeServer?.notification&&this.bridge.iframeServer.notification({method:`notifications/tools/list_changed`,params:{}}),this.testingAPI&&`notifyToolsChanged`in this.testingAPI&&this.testingAPI.notifyToolsChanged()}updateBridgeResources(){this.bridge.resources.clear();for(let[e,t]of this.provideContextResources)this.bridge.resources.set(e,t);for(let[e,t]of this.dynamicResources)this.bridge.resources.set(e,t);console.log(`[Web Model Context] Updated bridge with ${this.provideContextResources.size} base resources + ${this.dynamicResources.size} dynamic resources = ${this.bridge.resources.size} total`)}notifyResourcesListChanged(){this.bridge.tabServer.notification&&this.bridge.tabServer.notification({method:`notifications/resources/list_changed`,params:{}}),this.bridge.iframeServer?.notification&&this.bridge.iframeServer.notification({method:`notifications/resources/list_changed`,params:{}})}updateBridgePrompts(){this.bridge.prompts.clear();for(let[e,t]of this.provideContextPrompts)this.bridge.prompts.set(e,t);for(let[e,t]of this.dynamicPrompts)this.bridge.prompts.set(e,t);console.log(`[Web Model Context] Updated bridge with ${this.provideContextPrompts.size} base prompts + ${this.dynamicPrompts.size} dynamic prompts = ${this.bridge.prompts.size} total`)}notifyPromptsListChanged(){this.bridge.tabServer.notification&&this.bridge.tabServer.notification({method:`notifications/prompts/list_changed`,params:{}}),this.bridge.iframeServer?.notification&&this.bridge.iframeServer.notification({method:`notifications/prompts/list_changed`,params:{}})}async readResource(e){console.log(`[Web Model Context] Reading resource: ${e}`);let t=this.bridge.resources.get(e);if(t&&!t.isTemplate)try{let n=new URL(e);return await t.read(n)}catch(t){throw console.error(`[Web Model Context] Error reading resource ${e}:`,t),t}for(let t of this.bridge.resources.values()){if(!t.isTemplate)continue;let n=this.matchUriTemplate(t.uri,e);if(n)try{let r=new URL(e);return await t.read(r,n)}catch(t){throw console.error(`[Web Model Context] Error reading resource ${e}:`,t),t}}throw Error(`Resource not found: ${e}`)}matchUriTemplate(e,t){let n=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,e=>e===`{`||e===`}`?e:`\\${e}`);r=r.replace(/\{([^}]+)\}/g,(e,t)=>(n.push(t),`(.+)`));let i=RegExp(`^${r}$`),a=t.match(i);if(!a)return null;let o={};for(let e=0;e<n.length;e++){let t=n[e],r=a[e+1];t!==void 0&&r!==void 0&&(o[t]=r)}return o}async getPrompt(e,t){console.log(`[Web Model Context] Getting prompt: ${e}`);let n=this.bridge.prompts.get(e);if(!n)throw Error(`Prompt not found: ${e}`);if(n.argsValidator&&t){let r=Ja(t,n.argsValidator);if(!r.success)throw console.error(`[Web Model Context] Argument validation failed for prompt ${e}:`,r.error),Error(`Argument validation error for prompt "${e}":\n${r.error}`)}try{return await n.get(t??{})}catch(t){throw console.error(`[Web Model Context] Error getting prompt ${e}:`,t),t}}async executeTool(e,t){let n=this.bridge.tools.get(e);if(!n)throw Error(`Tool not found: ${e}`);console.log(`[Web Model Context] Validating input for tool: ${e}`);let r=Ja(t,n.inputValidator);if(!r.success)return console.error(`[Web Model Context] Input validation failed for ${e}:`,r.error),{content:[{type:`text`,text:`Input validation error for tool "${e}":\n${r.error}`}],isError:!0};let i=r.data;if(this.testingAPI&&this.testingAPI.recordToolCall(e,i),this.testingAPI?.hasMockResponse(e)){let t=this.testingAPI.getMockResponse(e);if(t)return console.log(`[Web Model Context] Returning mock response for tool: ${e}`),t}let a=new Za(e,i);if(this.dispatchEvent(a),a.defaultPrevented&&a.hasResponse()){let t=a.getResponse();if(t)return console.log(`[Web Model Context] Tool ${e} handled by event listener`),t}console.log(`[Web Model Context] Executing tool: ${e}`);try{let t=await n.execute(i);if(n.outputValidator&&t.structuredContent){let r=Ja(t.structuredContent,n.outputValidator);r.success||console.warn(`[Web Model Context] Output validation failed for ${e}:`,r.error)}return t}catch(t){return console.error(`[Web Model Context] Error executing tool ${e}:`,t),{content:[{type:`text`,text:`Error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}listTools(){return Array.from(this.bridge.tools.values()).map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,...e.outputSchema&&{outputSchema:e.outputSchema},...e.annotations&&{annotations:e.annotations}}))}async createMessage(e){console.log(`[Web Model Context] Requesting sampling from client`);let t=this.bridge.tabServer.server;if(!t?.createMessage)throw Error(`Sampling is not supported: no connected client with sampling capability`);return t.createMessage(e)}async elicitInput(e){console.log(`[Web Model Context] Requesting elicitation from client`);let t=this.bridge.tabServer.server;if(!t?.elicitInput)throw Error(`Elicitation is not supported: no connected client with elicitation capability`);return t.elicitInput(e)}};function eo(e){console.log(`[Web Model Context] Initializing MCP bridge`);let t=window.location.hostname||`localhost`,n=e?.transport,r=(e,t)=>{e.setRequestHandler(Jr,async()=>(console.log(`[MCP Bridge] Handling list_tools request`),{tools:t.modelContext.listTools()})),e.setRequestHandler(Zr,async e=>{console.log(`[MCP Bridge] Handling call_tool request: ${e.params.name}`);let n=e.params.name,r=e.params.arguments||{};try{let e=await t.modelContext.executeTool(n,r);return{content:e.content,isError:e.isError}}catch(e){throw console.error(`[MCP Bridge] Error calling tool ${n}:`,e),e}}),e.setRequestHandler(Cr,async()=>(console.log(`[MCP Bridge] Handling list_resources request`),{resources:t.modelContext.listResources()})),e.setRequestHandler(Dr,async e=>{console.log(`[MCP Bridge] Handling read_resource request: ${e.params.uri}`);try{return await t.modelContext.readResource(e.params.uri)}catch(t){throw console.error(`[MCP Bridge] Error reading resource ${e.params.uri}:`,t),t}}),e.setRequestHandler(Fr,async()=>(console.log(`[MCP Bridge] Handling list_prompts request`),{prompts:t.modelContext.listPrompts()})),e.setRequestHandler(Lr,async e=>{console.log(`[MCP Bridge] Handling get_prompt request: ${e.params.name}`);try{return await t.modelContext.getPrompt(e.params.name,e.params.arguments)}catch(t){throw console.error(`[MCP Bridge] Error getting prompt ${e.params.name}:`,t),t}})},i=n?.create?.();if(i){console.log(`[Web Model Context] Using custom transport`);let e=new fa({name:t,version:`1.0.0`},{capabilities:{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}}}),n={tabServer:e,tools:new Map,resources:new Map,prompts:new Map,modelContext:void 0,isInitialized:!0};return n.modelContext=new $a(n),r(e,n),e.connect(i),console.log(`[Web Model Context] MCP server connected with custom transport`),n}console.log(`[Web Model Context] Using dual-server mode`);let a=n?.tabServer!==!1,o=new fa({name:`${t}-tab`,version:`1.0.0`},{capabilities:{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}}}),s={tabServer:o,tools:new Map,resources:new Map,prompts:new Map,modelContext:void 0,isInitialized:!0};if(s.modelContext=new $a(s),r(o,s),a){let{allowedOrigins:e,...t}=typeof n?.tabServer==`object`?n.tabServer:{},r=new Rn({allowedOrigins:e??[`*`],...t});o.connect(r),console.log(`[Web Model Context] Tab server connected`)}let c=typeof window<`u`&&window.parent!==window,l=n?.iframeServer;if(l!==!1&&(l!==void 0||c)){console.log(`[Web Model Context] Enabling iframe server`);let e=new fa({name:`${t}-iframe`,version:`1.0.0`},{capabilities:{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}}});r(e,s);let{allowedOrigins:n,...i}=typeof l==`object`?l:{},a=new Ln({allowedOrigins:n??[`*`],...i});e.connect(a),s.iframeServer=e,console.log(`[Web Model Context] Iframe server connected`)}return s}function to(e){if(typeof window>`u`){console.warn(`[Web Model Context] Not in browser environment, skipping initialization`);return}let t=e??window.__webModelContextOptions,n=Ya();if(n.hasNativeContext&&n.hasNativeTesting){let e=window.navigator.modelContext,n=window.navigator.modelContextTesting;if(!e||!n){console.error(`[Web Model Context] Native API detection mismatch`);return}console.log(`✅ [Web Model Context] Native Chromium API detected`),console.log(` Using native implementation with MCP bridge synchronization`),console.log(` Native API will automatically collect tools from embedded iframes`);try{let r=eo(t);r.modelContext=new Xa(r,e,n),r.modelContextTesting=n,Object.defineProperty(window,`__mcpBridge`,{value:r,writable:!1,configurable:!0}),console.log(`✅ [Web Model Context] MCP bridge synced with native API`),console.log(` MCP clients will receive automatic tool updates from native registry`)}catch(e){throw console.error(`[Web Model Context] Failed to initialize native adapter:`,e),e}return}if(n.hasNativeContext&&!n.hasNativeTesting){console.warn(`[Web Model Context] Partial native API detected`),console.warn(` navigator.modelContext exists but navigator.modelContextTesting is missing`),console.warn(` Cannot sync with native API. Please enable experimental features:`),console.warn(` - Navigate to chrome://flags`),console.warn(` - Enable "Experimental Web Platform Features"`),console.warn(` - Or launch with: --enable-experimental-web-platform-features`),console.warn(` Skipping initialization to avoid conflicts`);return}if(window.navigator.modelContext){console.warn(`[Web Model Context] window.navigator.modelContext already exists, skipping initialization`);return}console.log(`[Web Model Context] Native API not detected, installing polyfill`);try{let e=eo(t);Object.defineProperty(window.navigator,`modelContext`,{value:e.modelContext,writable:!1,configurable:!1}),Object.defineProperty(window,`__mcpBridge`,{value:e,writable:!1,configurable:!0}),console.log(`✅ [Web Model Context] window.navigator.modelContext initialized successfully`),console.log(`[Model Context Testing] Installing polyfill`),console.log(` 💡 To use the native implementation in Chromium:`),console.log(` - Navigate to chrome://flags`),console.log(` - Enable "Experimental Web Platform Features"`),console.log(` - Or launch with: --enable-experimental-web-platform-features`);let n=new Qa(e);e.modelContextTesting=n,e.modelContext.setTestingAPI(n),Object.defineProperty(window.navigator,`modelContextTesting`,{value:n,writable:!1,configurable:!0}),console.log(`✅ [Model Context Testing] Polyfill installed at window.navigator.modelContextTesting`)}catch(e){throw console.error(`[Web Model Context] Failed to initialize:`,e),e}}function no(){if(!(typeof window>`u`)){if(window.__mcpBridge)try{window.__mcpBridge.tabServer.close(),window.__mcpBridge.iframeServer&&window.__mcpBridge.iframeServer.close()}catch(e){console.warn(`[Web Model Context] Error closing MCP servers:`,e)}delete window.navigator.modelContext,delete window.navigator.modelContextTesting,delete window.__mcpBridge,console.log(`[Web Model Context] Cleaned up`)}}function ro(e,t){return e?t?{...e,...t,tabServer:{...e.tabServer??{},...t.tabServer??{}}}:e:t}function io(e,t){return e?t?{...e,...t,transport:ro(e.transport??{},t.transport??{})}:e:t}function ao(e){if(!e||!e.dataset)return;let{dataset:t}=e;if(t.webmcpOptions)try{return JSON.parse(t.webmcpOptions)}catch(e){console.error(`[Web Model Context] Invalid JSON in data-webmcp-options:`,e);return}let n={},r=!1;t.webmcpAutoInitialize!==void 0&&(n.autoInitialize=t.webmcpAutoInitialize!==`false`,r=!0);let i={},a=!1;if(t.webmcpAllowedOrigins){let e=t.webmcpAllowedOrigins.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);e.length>0&&(i.allowedOrigins=e,r=!0,a=!0)}return t.webmcpChannelId&&(i.channelId=t.webmcpChannelId,r=!0,a=!0),a&&(n.transport={...n.transport??{},tabServer:{...n.transport?.tabServer??{},...i}}),r?n:void 0}if(typeof window<`u`&&typeof document<`u`){let e=window.__webModelContextOptions,t=document.currentScript,n=ao(t),r=io(e,n)??e??n;r&&(window.__webModelContextOptions=r);let i=r?.autoInitialize!==!1;try{i&&to(r)}catch(e){console.error(`[Web Model Context] Auto-initialization failed:`,e)}}return e.cleanupWebModelContext=no,e.initializeWebModelContext=to,e})({});
5
+ ${e}`:e}}return n&&(t=t.describe(n)),t},Rt=(e,t,n)=>{if(e.default!==void 0){if(e.default===null&&n?.path.some(e=>e===`anyOf`||e===`oneOf`)&&e.type&&e.type!==`null`&&!e.nullable)return t;t=t.default(e.default)}return t},zt=(e,t)=>(e.readOnly&&(t=t.readonly()),t),Bt=(e,t)=>G.a.nullable(e)?jt(e,t):G.an.object(e)?Ft(e,t):G.an.array(e)?xt(e,t):G.an.anyOf(e)?bt(e,t):G.an.allOf(e)?yt(e,t):G.a.oneOf(e)?Nt(e,t):G.a.not(e)?Ot(e,t):G.an.enum(e)?Tt(e):G.a.const(e)?Ct(e):G.a.multipleType(e)?Dt(e,t):G.a.primitive(e,`string`)?It(e):G.a.primitive(e,`number`)||G.a.primitive(e,`integer`)?Mt(e):G.a.primitive(e,`boolean`)?St(e):G.a.primitive(e,`null`)?kt(e):G.a.conditional(e)?Et(e,t):wt(e),K=(e,t={seen:new Map,path:[]},n)=>{if(typeof e!=`object`)return e?B():ut();if(t.parserOverride){let n=t.parserOverride(e,t);if(n instanceof T)return n}let r=t.seen.get(e);if(r){if(r.r!==void 0)return r.r;if(t.depth===void 0||r.n>=t.depth)return B();r.n+=1}else r={r:void 0,n:0},t.seen.set(e,r);let i=Bt(e,t);return n||(t.withoutDescribes||(i=Lt(e,i)),t.withoutDefaults||(i=Rt(e,i,t)),i=zt(e,i)),r.r=i,i},Vt=(e,t={})=>K(e,{path:[],seen:new Map,...t});let Ht=Symbol(`Let zodToJsonSchema decide on which parser to use`),Ut={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,target:`jsonSchema7`,strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`,openAiAnyTypeName:`OpenAiAnyType`},Wt=e=>typeof e==`string`?{...Ut,name:e}:{...Ut,...e},Gt=e=>{let t=Wt(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,flags:{hasReferencedOpenAiAnyType:!1},currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}};function Kt(e,t,n,r){r?.errorMessages&&n&&(e.errorMessage={...e.errorMessage,[t]:n})}function q(e,t,n,r,i){e[t]=n,Kt(e,t,r,i)}let qt=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function J(e){if(e.target!==`openAi`)return{};let t=[...e.basePath,e.definitionPath,e.openAiAnyTypeName];return e.flags.hasReferencedOpenAiAnyType=!0,{$ref:e.$refStrategy===`relative`?qt(t,e.currentPath):t.join(`/`)}}function Jt(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==z.ZodAny&&(n.items=Q(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&q(n,`minItems`,e.minLength.value,e.minLength.message,t),e.maxLength&&q(n,`maxItems`,e.maxLength.value,e.maxLength.message,t),e.exactLength&&(q(n,`minItems`,e.exactLength.value,e.exactLength.message,t),q(n,`maxItems`,e.exactLength.value,e.exactLength.message,t)),n}function Yt(e,t){let n={type:`integer`,format:`int64`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`min`:t.target===`jsonSchema7`?r.inclusive?q(n,`minimum`,r.value,r.message,t):q(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),q(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?q(n,`maximum`,r.value,r.message,t):q(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),q(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:q(n,`multipleOf`,r.value,r.message,t);break}return n}function Xt(){return{type:`boolean`}}function Zt(e,t){return Q(e.type._def,t)}let Qt=(e,t)=>Q(e.innerType._def,t);function $t(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map((n,r)=>$t(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return en(e,t)}}let en=(e,t)=>{let n={type:`integer`,format:`unix-time`};if(t.target===`openApi3`)return n;for(let r of e.checks)switch(r.kind){case`min`:q(n,`minimum`,r.value,r.message,t);break;case`max`:q(n,`maximum`,r.value,r.message,t);break}return n};function tn(e,t){return{...Q(e.innerType._def,t),default:e.defaultValue()}}function nn(e,t){return t.effectStrategy===`input`?Q(e.schema._def,t):J(t)}function rn(e){return{type:`string`,enum:Array.from(e.values)}}let an=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function on(e,t){let n=[Q(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),Q(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=t.target===`jsonSchema2019-09`?{unevaluatedProperties:!1}:void 0,i=[];return n.forEach(e=>{if(an(e))i.push(...e.allOf),e.unevaluatedProperties===void 0&&(r=void 0);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}else r=void 0;i.push(t)}}),i.length?{allOf:i,...r}:void 0}function sn(e,t){let n=typeof e.value;return n!==`bigint`&&n!==`number`&&n!==`boolean`&&n!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:t.target===`openApi3`?{type:n===`bigint`?`integer`:n,enum:[e.value]}:{type:n===`bigint`?`integer`:n,const:e.value}}let cn,Y={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(cn===void 0&&(cn=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),cn),uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function ln(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:q(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t);break;case`max`:q(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`email`:switch(t.emailStrategy){case`format:email`:X(n,`email`,r.message,t);break;case`format:idn-email`:X(n,`idn-email`,r.message,t);break;case`pattern:zod`:Z(n,Y.email,r.message,t);break}break;case`url`:X(n,`uri`,r.message,t);break;case`uuid`:X(n,`uuid`,r.message,t);break;case`regex`:Z(n,r.regex,r.message,t);break;case`cuid`:Z(n,Y.cuid,r.message,t);break;case`cuid2`:Z(n,Y.cuid2,r.message,t);break;case`startsWith`:Z(n,RegExp(`^${un(r.value,t)}`),r.message,t);break;case`endsWith`:Z(n,RegExp(`${un(r.value,t)}$`),r.message,t);break;case`datetime`:X(n,`date-time`,r.message,t);break;case`date`:X(n,`date`,r.message,t);break;case`time`:X(n,`time`,r.message,t);break;case`duration`:X(n,`duration`,r.message,t);break;case`length`:q(n,`minLength`,typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,r.message,t),q(n,`maxLength`,typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value,r.message,t);break;case`includes`:Z(n,RegExp(un(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&X(n,`ipv4`,r.message,t),r.version!==`v4`&&X(n,`ipv6`,r.message,t);break;case`base64url`:Z(n,Y.base64url,r.message,t);break;case`jwt`:Z(n,Y.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&Z(n,Y.ipv4Cidr,r.message,t),r.version!==`v4`&&Z(n,Y.ipv6Cidr,r.message,t);break;case`emoji`:Z(n,Y.emoji(),r.message,t);break;case`ulid`:Z(n,Y.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:X(n,`binary`,r.message,t);break;case`contentEncoding:base64`:q(n,`contentEncoding`,`base64`,r.message,t);break;case`pattern:zod`:Z(n,Y.base64,r.message,t);break}break;case`nanoid`:Z(n,Y.nanoid,r.message,t);case`toLowerCase`:case`toUpperCase`:case`trim`:break;default:(e=>{})(r)}return n}function un(e,t){return t.patternStrategy===`escape`?fn(e):e}let dn=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function fn(e){let t=``;for(let n=0;n<e.length;n++)dn.has(e[n])||(t+=`\\`),t+=e[n];return t}function X(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&r.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):q(e,`format`,t,n,r)}function Z(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&r.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,Object.keys(e.errorMessage).length===0&&delete e.errorMessage)),e.allOf.push({pattern:pn(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):q(e,`pattern`,pn(t,r),n,r)}function pn(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
6
+ ]))`;continue}else if(r[e]===`$`){i+=`($|(?=[\r
7
+ ]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r\n`:`[${r[e]}\r\n]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function mn(e,t){if(t.target===`openAi`&&console.warn(`Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.`),t.target===`openApi3`&&e.keyType?._def.typeName===z.ZodEnum)return{type:`object`,required:e.keyType._def.values,properties:e.keyType._def.values.reduce((n,r)=>({...n,[r]:Q(e.valueType._def,{...t,currentPath:[...t.currentPath,`properties`,r]})??J(t)}),{}),additionalProperties:t.rejectedAdditionalProperties};let n={type:`object`,additionalProperties:Q(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(t.target===`openApi3`)return n;if(e.keyType?._def.typeName===z.ZodString&&e.keyType._def.checks?.length){let{type:r,...i}=ln(e.keyType._def,t);return{...n,propertyNames:i}}else if(e.keyType?._def.typeName===z.ZodEnum)return{...n,propertyNames:{enum:e.keyType._def.values}};else if(e.keyType?._def.typeName===z.ZodBranded&&e.keyType._def.type._def.typeName===z.ZodString&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=Zt(e.keyType._def,t);return{...n,propertyNames:i}}return n}function hn(e,t){return t.mapStrategy===`record`?mn(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[Q(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||J(t),Q(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||J(t)],minItems:2,maxItems:2}}}function gn(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function _n(e){return e.target===`openAi`?void 0:{not:J({...e,currentPath:[...e.currentPath,`not`]})}}function vn(e){return e.target===`openApi3`?{enum:[`null`],nullable:!0}:{type:`null`}}let yn={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function bn(e,t){if(t.target===`openApi3`)return xn(e,t);let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in yn&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=yn[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}else if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];case`symbol`:case`undefined`:case`function`:default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return xn(e,t)}let xn=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>Q(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function Sn(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return t.target===`openApi3`?{type:yn[e.innerType._def.typeName],nullable:!0}:{type:[yn[e.innerType._def.typeName],`null`]};if(t.target===`openApi3`){let n=Q(e.innerType._def,{...t,currentPath:[...t.currentPath]});return n&&`$ref`in n?{allOf:[n],nullable:!0}:n&&{...n,nullable:!0}}let n=Q(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function Cn(e,t){let n={type:`number`};if(!e.checks)return n;for(let r of e.checks)switch(r.kind){case`int`:n.type=`integer`,Kt(n,`type`,r.message,t);break;case`min`:t.target===`jsonSchema7`?r.inclusive?q(n,`minimum`,r.value,r.message,t):q(n,`exclusiveMinimum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMinimum=!0),q(n,`minimum`,r.value,r.message,t));break;case`max`:t.target===`jsonSchema7`?r.inclusive?q(n,`maximum`,r.value,r.message,t):q(n,`exclusiveMaximum`,r.value,r.message,t):(r.inclusive||(n.exclusiveMaximum=!0),q(n,`maximum`,r.value,r.message,t));break;case`multipleOf`:q(n,`multipleOf`,r.value,r.message,t);break}return n}function wn(e,t){let n=t.target===`openAi`,r={type:`object`,properties:{}},i=[],a=e.shape();for(let e in a){let o=a[e];if(o===void 0||o._def===void 0)continue;let s=En(o);s&&n&&(o._def.typeName===`ZodOptional`&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),s=!1);let c=Q(o._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});c!==void 0&&(r.properties[e]=c,s||i.push(e))}i.length&&(r.required=i);let o=Tn(e,t);return o!==void 0&&(r.additionalProperties=o),r}function Tn(e,t){if(e.catchall._def.typeName!==`ZodNever`)return Q(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function En(e){try{return e.isOptional()}catch{return!0}}let Dn=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return Q(e.innerType._def,t);let n=Q(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:J(t)},n]}:J(t)},On=(e,t)=>{if(t.pipeStrategy===`input`)return Q(e.in._def,t);if(t.pipeStrategy===`output`)return Q(e.out._def,t);let n=Q(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,Q(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function kn(e,t){return Q(e.type._def,t)}function An(e,t){let n={type:`array`,uniqueItems:!0,items:Q(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&q(n,`minItems`,e.minSize.value,e.minSize.message,t),e.maxSize&&q(n,`maxItems`,e.maxSize.value,e.maxSize.message,t),n}function jn(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>Q(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:Q(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>Q(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function Mn(e){return{not:J(e)}}function Nn(e){return J(e)}let Pn=(e,t)=>Q(e.innerType._def,t),Fn=(e,t,n)=>{switch(t){case z.ZodString:return ln(e,n);case z.ZodNumber:return Cn(e,n);case z.ZodObject:return wn(e,n);case z.ZodBigInt:return Yt(e,n);case z.ZodBoolean:return Xt();case z.ZodDate:return $t(e,n);case z.ZodUndefined:return Mn(n);case z.ZodNull:return vn(n);case z.ZodArray:return Jt(e,n);case z.ZodUnion:case z.ZodDiscriminatedUnion:return bn(e,n);case z.ZodIntersection:return on(e,n);case z.ZodTuple:return jn(e,n);case z.ZodRecord:return mn(e,n);case z.ZodLiteral:return sn(e,n);case z.ZodEnum:return rn(e);case z.ZodNativeEnum:return gn(e);case z.ZodNullable:return Sn(e,n);case z.ZodOptional:return Dn(e,n);case z.ZodMap:return hn(e,n);case z.ZodSet:return An(e,n);case z.ZodLazy:return()=>e.getter()._def;case z.ZodPromise:return kn(e,n);case z.ZodNaN:case z.ZodNever:return _n(n);case z.ZodEffects:return nn(e,n);case z.ZodAny:return J(n);case z.ZodUnknown:return Nn(n);case z.ZodDefault:return tn(e,n);case z.ZodBranded:return Zt(e,n);case z.ZodReadonly:return Pn(e,n);case z.ZodCatch:return Qt(e,n);case z.ZodPipeline:return On(e,n);case z.ZodFunction:case z.ZodVoid:case z.ZodSymbol:return;default:return(e=>void 0)(t)}};function Q(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.(e,t,r,n);if(i!==Ht)return i}if(r&&!n){let e=In(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=Fn(e,e.typeName,t),o=typeof a==`function`?Q(a(),t):a;if(o&&Ln(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}let In=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:qt(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),J(t)):t.$refStrategy===`seen`?J(t):void 0}},Ln=(e,t,n)=>(e.description&&(n.description=e.description,t.markdownDescription&&(n.markdownDescription=e.description)),n),Rn=(e,t)=>{let n=Gt(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:Q(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??J(n)}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=Q(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??J(n),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o),n.flags.hasReferencedOpenAiAnyType&&(r||={},r[n.openAiAnyTypeName]||(r[n.openAiAnyTypeName]={type:[`string`,`number`,`integer`,`boolean`,`array`,`null`],items:{$ref:n.$refStrategy===`relative`?`1`:[...n.basePath,n.definitionPath,n.openAiAnyTypeName].join(`/`)}}));let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return n.target===`jsonSchema7`?s.$schema=`http://json-schema.org/draft-07/schema#`:(n.target===`jsonSchema2019-09`||n.target===`openAi`)&&(s.$schema=`https://json-schema.org/draft/2019-09/schema#`),n.target===`openAi`&&(`anyOf`in s||`oneOf`in s||`allOf`in s||`type`in s&&Array.isArray(s.type))&&console.warn(`Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.`),s};function zn(e){if(typeof e!=`object`||!e||`type`in e&&typeof e.type==`string`)return!1;let t=Object.values(e);return t.length===0?!1:t.some(e=>e instanceof T)}function Bn(e){try{return Vt(e)}catch(e){return console.warn(`[Web Model Context] Failed to convert JSON Schema to Zod:`,e),V({}).passthrough()}}function Vn(e){let{$schema:t,...n}=Rn(V(e),{$refStrategy:`none`,target:`jsonSchema7`});return n}function $(e){if(zn(e))return{jsonSchema:Vn(e),zodValidator:V(e)};let t=e;return{jsonSchema:t,zodValidator:Bn(t)}}function Hn(e,t){let n=t.safeParse(e);return n.success?{success:!0,data:n.data}:{success:!1,error:`Validation failed:\n${n.error.errors.map(e=>` - ${e.path.join(`.`)||`root`}: ${e.message}`).join(`
8
+ `)}`}}function Un(){if(typeof window>`u`||typeof navigator>`u`)return{hasNativeContext:!1,hasNativeTesting:!1};let e=navigator.modelContext,t=navigator.modelContextTesting;return!e||!t||(t.constructor?.name||``).includes(`WebModelContext`)?{hasNativeContext:!1,hasNativeTesting:!1}:{hasNativeContext:!0,hasNativeTesting:!0}}var Wn=class{nativeContext;nativeTesting;bridge;syncInProgress=!1;constructor(e,t,n){this.bridge=e,this.nativeContext=t,this.nativeTesting=n,this.nativeTesting.registerToolsChangedCallback(()=>{console.log(`[Native Adapter] Tool change detected from native API`),this.syncToolsFromNative()}),this.syncToolsFromNative()}syncToolsFromNative(){if(!this.syncInProgress){this.syncInProgress=!0;try{let e=this.nativeTesting.listTools();console.log(`[Native Adapter] Syncing ${e.length} tools from native API`),this.bridge.tools.clear();for(let t of e)try{let e=JSON.parse(t.inputSchema),n={name:t.name,description:t.description,inputSchema:e,execute:async e=>{let n=await this.nativeTesting.executeTool(t.name,JSON.stringify(e));return this.convertToToolResponse(n)},inputValidator:Bn(e)};this.bridge.tools.set(t.name,n)}catch(e){console.error(`[Native Adapter] Failed to sync tool "${t.name}":`,e)}this.notifyMCPServers()}finally{this.syncInProgress=!1}}}convertToToolResponse(e){return typeof e==`string`?{content:[{type:`text`,text:e}]}:e==null?{content:[{type:`text`,text:``}]}:typeof e==`object`?{content:[{type:`text`,text:JSON.stringify(e,null,2)}],structuredContent:e}:{content:[{type:`text`,text:String(e)}]}}notifyMCPServers(){this.bridge.tabServer?.notification&&this.bridge.tabServer.notification({method:`notifications/tools/list_changed`,params:{}}),this.bridge.iframeServer?.notification&&this.bridge.iframeServer.notification({method:`notifications/tools/list_changed`,params:{}})}provideContext(e){console.log(`[Native Adapter] Delegating provideContext to native API`),this.nativeContext.provideContext(e)}registerTool(e){return console.log(`[Native Adapter] Delegating registerTool("${e.name}") to native API`),this.nativeContext.registerTool(e)}unregisterTool(e){console.log(`[Native Adapter] Delegating unregisterTool("${e}") to native API`),this.nativeContext.unregisterTool(e)}clearContext(){console.log(`[Native Adapter] Delegating clearContext to native API`),this.nativeContext.clearContext()}async executeTool(e,t){console.log(`[Native Adapter] Executing tool "${e}" via native API`);try{let n=await this.nativeTesting.executeTool(e,JSON.stringify(t));return this.convertToToolResponse(n)}catch(t){return console.error(`[Native Adapter] Error executing tool "${e}":`,t),{content:[{type:`text`,text:`Error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}listTools(){return Array.from(this.bridge.tools.values()).map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,...e.outputSchema&&{outputSchema:e.outputSchema},...e.annotations&&{annotations:e.annotations}}))}registerResource(e){return console.warn(`[Native Adapter] registerResource is not supported by native API`),{unregister:()=>{}}}unregisterResource(e){console.warn(`[Native Adapter] unregisterResource is not supported by native API`)}listResources(){return[]}listResourceTemplates(){return[]}async readResource(e){throw Error(`[Native Adapter] readResource is not supported by native API`)}registerPrompt(e){return console.warn(`[Native Adapter] registerPrompt is not supported by native API`),{unregister:()=>{}}}unregisterPrompt(e){console.warn(`[Native Adapter] unregisterPrompt is not supported by native API`)}listPrompts(){return[]}async getPrompt(e,t){throw Error(`[Native Adapter] getPrompt is not supported by native API`)}addEventListener(e,t,n){this.nativeContext.addEventListener(e,t,n)}removeEventListener(e,t,n){this.nativeContext.removeEventListener(e,t,n)}dispatchEvent(e){return this.nativeContext.dispatchEvent(e)}async createMessage(e){console.log(`[Native Adapter] Requesting sampling from client`);let t=this.bridge.tabServer.server;if(!t?.createMessage)throw Error(`Sampling is not supported: no connected client with sampling capability`);return t.createMessage(e)}async elicitInput(e){console.log(`[Native Adapter] Requesting elicitation from client`);let t=this.bridge.tabServer.server;if(!t?.elicitInput)throw Error(`Elicitation is not supported: no connected client with elicitation capability`);return t.elicitInput(e)}},Gn=class extends Event{name;arguments;_response=null;_responded=!1;constructor(e,t){super(`toolcall`,{cancelable:!0}),this.name=e,this.arguments=t}respondWith(e){if(this._responded)throw Error(`Response already provided for this tool call`);this._response=e,this._responded=!0}getResponse(){return this._response}hasResponse(){return this._responded}},Kn=class{toolCallHistory=[];mockResponses=new Map;toolsChangedCallbacks=new Set;bridge;constructor(e){this.bridge=e}recordToolCall(e,t){this.toolCallHistory.push({toolName:e,arguments:t,timestamp:Date.now()})}hasMockResponse(e){return this.mockResponses.has(e)}getMockResponse(e){return this.mockResponses.get(e)}notifyToolsChanged(){for(let e of this.toolsChangedCallbacks)try{e()}catch(e){console.error(`[Model Context Testing] Error in tools changed callback:`,e)}}async executeTool(e,t){console.log(`[Model Context Testing] Executing tool: ${e}`);let n;try{n=JSON.parse(t)}catch(e){throw SyntaxError(`Invalid JSON input: ${e instanceof Error?e.message:String(e)}`)}if(!this.bridge.tools.get(e))throw Error(`Tool not found: ${e}`);let r=await this.bridge.modelContext.executeTool(e,n);if(!r.isError){if(r.structuredContent)return r.structuredContent;if(r.content&&r.content.length>0){let e=r.content[0];if(e&&e.type===`text`)return e.text}}}listTools(){return this.bridge.modelContext.listTools().map(e=>({name:e.name,description:e.description,inputSchema:JSON.stringify(e.inputSchema)}))}registerToolsChangedCallback(e){this.toolsChangedCallbacks.add(e),console.log(`[Model Context Testing] Tools changed callback registered`)}getToolCalls(){return[...this.toolCallHistory]}clearToolCalls(){this.toolCallHistory=[],console.log(`[Model Context Testing] Tool call history cleared`)}setMockToolResponse(e,t){this.mockResponses.set(e,t),console.log(`[Model Context Testing] Mock response set for tool: ${e}`)}clearMockToolResponse(e){this.mockResponses.delete(e),console.log(`[Model Context Testing] Mock response cleared for tool: ${e}`)}clearAllMockToolResponses(){this.mockResponses.clear(),console.log(`[Model Context Testing] All mock responses cleared`)}getRegisteredTools(){return this.bridge.modelContext.listTools()}reset(){this.clearToolCalls(),this.clearAllMockToolResponses(),console.log(`[Model Context Testing] Testing state reset`)}},qn=class{bridge;eventTarget;provideContextTools;dynamicTools;provideContextResources;dynamicResources;provideContextPrompts;dynamicPrompts;toolRegistrationTimestamps;resourceRegistrationTimestamps;promptRegistrationTimestamps;toolUnregisterFunctions;resourceUnregisterFunctions;promptUnregisterFunctions;testingAPI;constructor(e){this.bridge=e,this.eventTarget=new EventTarget,this.provideContextTools=new Map,this.dynamicTools=new Map,this.toolRegistrationTimestamps=new Map,this.toolUnregisterFunctions=new Map,this.provideContextResources=new Map,this.dynamicResources=new Map,this.resourceRegistrationTimestamps=new Map,this.resourceUnregisterFunctions=new Map,this.provideContextPrompts=new Map,this.dynamicPrompts=new Map,this.promptRegistrationTimestamps=new Map,this.promptUnregisterFunctions=new Map}setTestingAPI(e){this.testingAPI=e}addEventListener(e,t,n){this.eventTarget.addEventListener(e,t,n)}removeEventListener(e,t,n){this.eventTarget.removeEventListener(e,t,n)}dispatchEvent(e){return this.eventTarget.dispatchEvent(e)}provideContext(e){let t=e.tools?.length??0,n=e.resources?.length??0,r=e.prompts?.length??0;console.log(`[Web Model Context] provideContext: ${t} tools, ${n} resources, ${r} prompts`),this.provideContextTools.clear(),this.provideContextResources.clear(),this.provideContextPrompts.clear();for(let t of e.tools??[]){if(this.dynamicTools.has(t.name))throw Error(`[Web Model Context] Tool name collision: "${t.name}" is already registered via registerTool(). Please use a different name or unregister the dynamic tool first.`);let{jsonSchema:e,zodValidator:n}=$(t.inputSchema),r=t.outputSchema?$(t.outputSchema):null,i={name:t.name,description:t.description,inputSchema:e,...r&&{outputSchema:r.jsonSchema},...t.annotations&&{annotations:t.annotations},execute:t.execute,inputValidator:n,...r&&{outputValidator:r.zodValidator}};this.provideContextTools.set(t.name,i)}for(let t of e.resources??[]){if(this.dynamicResources.has(t.uri))throw Error(`[Web Model Context] Resource URI collision: "${t.uri}" is already registered via registerResource(). Please use a different URI or unregister the dynamic resource first.`);let e=this.validateResource(t);this.provideContextResources.set(t.uri,e)}for(let t of e.prompts??[]){if(this.dynamicPrompts.has(t.name))throw Error(`[Web Model Context] Prompt name collision: "${t.name}" is already registered via registerPrompt(). Please use a different name or unregister the dynamic prompt first.`);let e=this.validatePrompt(t);this.provideContextPrompts.set(t.name,e)}this.updateBridgeTools(),this.updateBridgeResources(),this.updateBridgePrompts(),this.notifyToolsListChanged(),this.notifyResourcesListChanged(),this.notifyPromptsListChanged()}validateResource(e){let t=/\{([^}]+)\}/g,n=[];for(let r of e.uri.matchAll(t)){let e=r[1];e&&n.push(e)}return{uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType,read:e.read,isTemplate:n.length>0,templateParams:n}}validatePrompt(e){let t,n;if(e.argsSchema){let r=$(e.argsSchema);t=r.jsonSchema,n=r.zodValidator}return{name:e.name,description:e.description,argsSchema:t,get:e.get,argsValidator:n}}registerTool(e){console.log(`[Web Model Context] Registering tool dynamically: ${e.name}`);let t=Date.now(),n=this.toolRegistrationTimestamps.get(e.name);if(n&&t-n<50){console.warn(`[Web Model Context] Tool "${e.name}" registered multiple times within 50ms. This is likely due to React Strict Mode double-mounting. Ignoring duplicate registration.`);let t=this.toolUnregisterFunctions.get(e.name);if(t)return{unregister:t}}if(this.provideContextTools.has(e.name))throw Error(`[Web Model Context] Tool name collision: "${e.name}" is already registered via provideContext(). Please use a different name or update your provideContext() call.`);if(this.dynamicTools.has(e.name))throw Error(`[Web Model Context] Tool name collision: "${e.name}" is already registered via registerTool(). Please unregister it first or use a different name.`);let{jsonSchema:r,zodValidator:i}=$(e.inputSchema),a=e.outputSchema?$(e.outputSchema):null,o={name:e.name,description:e.description,inputSchema:r,...a&&{outputSchema:a.jsonSchema},...e.annotations&&{annotations:e.annotations},execute:e.execute,inputValidator:i,...a&&{outputValidator:a.zodValidator}};this.dynamicTools.set(e.name,o),this.toolRegistrationTimestamps.set(e.name,t),this.updateBridgeTools(),this.notifyToolsListChanged();let s=()=>{if(console.log(`[Web Model Context] Unregistering tool: ${e.name}`),this.provideContextTools.has(e.name))throw Error(`[Web Model Context] Cannot unregister tool "${e.name}": This tool was registered via provideContext(). Use provideContext() to update the base tool set.`);if(!this.dynamicTools.has(e.name)){console.warn(`[Web Model Context] Tool "${e.name}" is not registered, ignoring unregister call`);return}this.dynamicTools.delete(e.name),this.toolRegistrationTimestamps.delete(e.name),this.toolUnregisterFunctions.delete(e.name),this.updateBridgeTools(),this.notifyToolsListChanged()};return this.toolUnregisterFunctions.set(e.name,s),{unregister:s}}registerResource(e){console.log(`[Web Model Context] Registering resource dynamically: ${e.uri}`);let t=Date.now(),n=this.resourceRegistrationTimestamps.get(e.uri);if(n&&t-n<50){console.warn(`[Web Model Context] Resource "${e.uri}" registered multiple times within 50ms. This is likely due to React Strict Mode double-mounting. Ignoring duplicate registration.`);let t=this.resourceUnregisterFunctions.get(e.uri);if(t)return{unregister:t}}if(this.provideContextResources.has(e.uri))throw Error(`[Web Model Context] Resource URI collision: "${e.uri}" is already registered via provideContext(). Please use a different URI or update your provideContext() call.`);if(this.dynamicResources.has(e.uri))throw Error(`[Web Model Context] Resource URI collision: "${e.uri}" is already registered via registerResource(). Please unregister it first or use a different URI.`);let r=this.validateResource(e);this.dynamicResources.set(e.uri,r),this.resourceRegistrationTimestamps.set(e.uri,t),this.updateBridgeResources(),this.notifyResourcesListChanged();let i=()=>{if(console.log(`[Web Model Context] Unregistering resource: ${e.uri}`),this.provideContextResources.has(e.uri))throw Error(`[Web Model Context] Cannot unregister resource "${e.uri}": This resource was registered via provideContext(). Use provideContext() to update the base resource set.`);if(!this.dynamicResources.has(e.uri)){console.warn(`[Web Model Context] Resource "${e.uri}" is not registered, ignoring unregister call`);return}this.dynamicResources.delete(e.uri),this.resourceRegistrationTimestamps.delete(e.uri),this.resourceUnregisterFunctions.delete(e.uri),this.updateBridgeResources(),this.notifyResourcesListChanged()};return this.resourceUnregisterFunctions.set(e.uri,i),{unregister:i}}unregisterResource(e){console.log(`[Web Model Context] Unregistering resource: ${e}`);let t=this.provideContextResources.has(e),n=this.dynamicResources.has(e);if(!t&&!n){console.warn(`[Web Model Context] Resource "${e}" is not registered, ignoring unregister call`);return}t&&this.provideContextResources.delete(e),n&&(this.dynamicResources.delete(e),this.resourceRegistrationTimestamps.delete(e),this.resourceUnregisterFunctions.delete(e)),this.updateBridgeResources(),this.notifyResourcesListChanged()}listResources(){return Array.from(this.bridge.resources.values()).filter(e=>!e.isTemplate).map(e=>({uri:e.uri,name:e.name,description:e.description,mimeType:e.mimeType}))}listResourceTemplates(){return Array.from(this.bridge.resources.values()).filter(e=>e.isTemplate).map(e=>({uriTemplate:e.uri,name:e.name,...e.description!==void 0&&{description:e.description},...e.mimeType!==void 0&&{mimeType:e.mimeType}}))}registerPrompt(e){console.log(`[Web Model Context] Registering prompt dynamically: ${e.name}`);let t=Date.now(),n=this.promptRegistrationTimestamps.get(e.name);if(n&&t-n<50){console.warn(`[Web Model Context] Prompt "${e.name}" registered multiple times within 50ms. This is likely due to React Strict Mode double-mounting. Ignoring duplicate registration.`);let t=this.promptUnregisterFunctions.get(e.name);if(t)return{unregister:t}}if(this.provideContextPrompts.has(e.name))throw Error(`[Web Model Context] Prompt name collision: "${e.name}" is already registered via provideContext(). Please use a different name or update your provideContext() call.`);if(this.dynamicPrompts.has(e.name))throw Error(`[Web Model Context] Prompt name collision: "${e.name}" is already registered via registerPrompt(). Please unregister it first or use a different name.`);let r=this.validatePrompt(e);this.dynamicPrompts.set(e.name,r),this.promptRegistrationTimestamps.set(e.name,t),this.updateBridgePrompts(),this.notifyPromptsListChanged();let i=()=>{if(console.log(`[Web Model Context] Unregistering prompt: ${e.name}`),this.provideContextPrompts.has(e.name))throw Error(`[Web Model Context] Cannot unregister prompt "${e.name}": This prompt was registered via provideContext(). Use provideContext() to update the base prompt set.`);if(!this.dynamicPrompts.has(e.name)){console.warn(`[Web Model Context] Prompt "${e.name}" is not registered, ignoring unregister call`);return}this.dynamicPrompts.delete(e.name),this.promptRegistrationTimestamps.delete(e.name),this.promptUnregisterFunctions.delete(e.name),this.updateBridgePrompts(),this.notifyPromptsListChanged()};return this.promptUnregisterFunctions.set(e.name,i),{unregister:i}}unregisterPrompt(e){console.log(`[Web Model Context] Unregistering prompt: ${e}`);let t=this.provideContextPrompts.has(e),n=this.dynamicPrompts.has(e);if(!t&&!n){console.warn(`[Web Model Context] Prompt "${e}" is not registered, ignoring unregister call`);return}t&&this.provideContextPrompts.delete(e),n&&(this.dynamicPrompts.delete(e),this.promptRegistrationTimestamps.delete(e),this.promptUnregisterFunctions.delete(e)),this.updateBridgePrompts(),this.notifyPromptsListChanged()}listPrompts(){return Array.from(this.bridge.prompts.values()).map(e=>({name:e.name,description:e.description,arguments:e.argsSchema?.properties?Object.entries(e.argsSchema.properties).map(([t,n])=>({name:t,description:n.description,required:e.argsSchema?.required?.includes(t)??!1})):void 0}))}unregisterTool(e){console.log(`[Web Model Context] Unregistering tool: ${e}`);let t=this.provideContextTools.has(e),n=this.dynamicTools.has(e);if(!t&&!n){console.warn(`[Web Model Context] Tool "${e}" is not registered, ignoring unregister call`);return}t&&this.provideContextTools.delete(e),n&&(this.dynamicTools.delete(e),this.toolRegistrationTimestamps.delete(e),this.toolUnregisterFunctions.delete(e)),this.updateBridgeTools(),this.notifyToolsListChanged()}clearContext(){console.log(`[Web Model Context] Clearing all context (tools, resources, prompts)`),this.provideContextTools.clear(),this.dynamicTools.clear(),this.toolRegistrationTimestamps.clear(),this.toolUnregisterFunctions.clear(),this.provideContextResources.clear(),this.dynamicResources.clear(),this.resourceRegistrationTimestamps.clear(),this.resourceUnregisterFunctions.clear(),this.provideContextPrompts.clear(),this.dynamicPrompts.clear(),this.promptRegistrationTimestamps.clear(),this.promptUnregisterFunctions.clear(),this.updateBridgeTools(),this.updateBridgeResources(),this.updateBridgePrompts(),this.notifyToolsListChanged(),this.notifyResourcesListChanged(),this.notifyPromptsListChanged()}updateBridgeTools(){this.bridge.tools.clear();for(let[e,t]of this.provideContextTools)this.bridge.tools.set(e,t);for(let[e,t]of this.dynamicTools)this.bridge.tools.set(e,t);console.log(`[Web Model Context] Updated bridge with ${this.provideContextTools.size} base tools + ${this.dynamicTools.size} dynamic tools = ${this.bridge.tools.size} total`)}notifyToolsListChanged(){this.bridge.tabServer.notification&&this.bridge.tabServer.notification({method:`notifications/tools/list_changed`,params:{}}),this.bridge.iframeServer?.notification&&this.bridge.iframeServer.notification({method:`notifications/tools/list_changed`,params:{}}),this.testingAPI&&`notifyToolsChanged`in this.testingAPI&&this.testingAPI.notifyToolsChanged()}updateBridgeResources(){this.bridge.resources.clear();for(let[e,t]of this.provideContextResources)this.bridge.resources.set(e,t);for(let[e,t]of this.dynamicResources)this.bridge.resources.set(e,t);console.log(`[Web Model Context] Updated bridge with ${this.provideContextResources.size} base resources + ${this.dynamicResources.size} dynamic resources = ${this.bridge.resources.size} total`)}notifyResourcesListChanged(){this.bridge.tabServer.notification&&this.bridge.tabServer.notification({method:`notifications/resources/list_changed`,params:{}}),this.bridge.iframeServer?.notification&&this.bridge.iframeServer.notification({method:`notifications/resources/list_changed`,params:{}})}updateBridgePrompts(){this.bridge.prompts.clear();for(let[e,t]of this.provideContextPrompts)this.bridge.prompts.set(e,t);for(let[e,t]of this.dynamicPrompts)this.bridge.prompts.set(e,t);console.log(`[Web Model Context] Updated bridge with ${this.provideContextPrompts.size} base prompts + ${this.dynamicPrompts.size} dynamic prompts = ${this.bridge.prompts.size} total`)}notifyPromptsListChanged(){this.bridge.tabServer.notification&&this.bridge.tabServer.notification({method:`notifications/prompts/list_changed`,params:{}}),this.bridge.iframeServer?.notification&&this.bridge.iframeServer.notification({method:`notifications/prompts/list_changed`,params:{}})}async readResource(e){console.log(`[Web Model Context] Reading resource: ${e}`);let t=this.bridge.resources.get(e);if(t&&!t.isTemplate)try{let n=new URL(e);return await t.read(n)}catch(t){throw console.error(`[Web Model Context] Error reading resource ${e}:`,t),t}for(let t of this.bridge.resources.values()){if(!t.isTemplate)continue;let n=this.matchUriTemplate(t.uri,e);if(n)try{let r=new URL(e);return await t.read(r,n)}catch(t){throw console.error(`[Web Model Context] Error reading resource ${e}:`,t),t}}throw Error(`Resource not found: ${e}`)}matchUriTemplate(e,t){let n=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,e=>e===`{`||e===`}`?e:`\\${e}`);r=r.replace(/\{([^}]+)\}/g,(e,t)=>(n.push(t),`(.+)`));let i=RegExp(`^${r}$`),a=t.match(i);if(!a)return null;let o={};for(let e=0;e<n.length;e++){let t=n[e],r=a[e+1];t!==void 0&&r!==void 0&&(o[t]=r)}return o}async getPrompt(e,t){console.log(`[Web Model Context] Getting prompt: ${e}`);let n=this.bridge.prompts.get(e);if(!n)throw Error(`Prompt not found: ${e}`);if(n.argsValidator&&t){let r=Hn(t,n.argsValidator);if(!r.success)throw console.error(`[Web Model Context] Argument validation failed for prompt ${e}:`,r.error),Error(`Argument validation error for prompt "${e}":\n${r.error}`)}try{return await n.get(t??{})}catch(t){throw console.error(`[Web Model Context] Error getting prompt ${e}:`,t),t}}async executeTool(e,t){let n=this.bridge.tools.get(e);if(!n)throw Error(`Tool not found: ${e}`);console.log(`[Web Model Context] Validating input for tool: ${e}`);let r=Hn(t,n.inputValidator);if(!r.success)return console.error(`[Web Model Context] Input validation failed for ${e}:`,r.error),{content:[{type:`text`,text:`Input validation error for tool "${e}":\n${r.error}`}],isError:!0};let i=r.data;if(this.testingAPI&&this.testingAPI.recordToolCall(e,i),this.testingAPI?.hasMockResponse(e)){let t=this.testingAPI.getMockResponse(e);if(t)return console.log(`[Web Model Context] Returning mock response for tool: ${e}`),t}let a=new Gn(e,i);if(this.dispatchEvent(a),a.defaultPrevented&&a.hasResponse()){let t=a.getResponse();if(t)return console.log(`[Web Model Context] Tool ${e} handled by event listener`),t}console.log(`[Web Model Context] Executing tool: ${e}`);try{let t=await n.execute(i);if(n.outputValidator&&t.structuredContent){let r=Hn(t.structuredContent,n.outputValidator);r.success||console.warn(`[Web Model Context] Output validation failed for ${e}:`,r.error)}return t}catch(t){return console.error(`[Web Model Context] Error executing tool ${e}:`,t),{content:[{type:`text`,text:`Error: ${t instanceof Error?t.message:String(t)}`}],isError:!0}}}listTools(){return Array.from(this.bridge.tools.values()).map(e=>({name:e.name,description:e.description,inputSchema:e.inputSchema,...e.outputSchema&&{outputSchema:e.outputSchema},...e.annotations&&{annotations:e.annotations}}))}async createMessage(e){console.log(`[Web Model Context] Requesting sampling from client`);let t=this.bridge.tabServer.server;if(!t?.createMessage)throw Error(`Sampling is not supported: no connected client with sampling capability`);return t.createMessage(e)}async elicitInput(e){console.log(`[Web Model Context] Requesting elicitation from client`);let t=this.bridge.tabServer.server;if(!t?.elicitInput)throw Error(`Elicitation is not supported: no connected client with elicitation capability`);return t.elicitInput(e)}};function Jn(e){console.log(`[Web Model Context] Initializing MCP bridge`);let r=window.location.hostname||`localhost`,i=e?.transport,a=(e,t)=>{e.setRequestHandler(n.ListToolsRequestSchema,async()=>(console.log(`[MCP Bridge] Handling list_tools request`),{tools:t.modelContext.listTools()})),e.setRequestHandler(n.CallToolRequestSchema,async e=>{console.log(`[MCP Bridge] Handling call_tool request: ${e.params.name}`);let n=e.params.name,r=e.params.arguments||{};try{let e=await t.modelContext.executeTool(n,r);return{content:e.content,isError:e.isError}}catch(e){throw console.error(`[MCP Bridge] Error calling tool ${n}:`,e),e}}),e.setRequestHandler(n.ListResourcesRequestSchema,async()=>(console.log(`[MCP Bridge] Handling list_resources request`),{resources:t.modelContext.listResources()})),e.setRequestHandler(n.ReadResourceRequestSchema,async e=>{console.log(`[MCP Bridge] Handling read_resource request: ${e.params.uri}`);try{return await t.modelContext.readResource(e.params.uri)}catch(t){throw console.error(`[MCP Bridge] Error reading resource ${e.params.uri}:`,t),t}}),e.setRequestHandler(n.ListPromptsRequestSchema,async()=>(console.log(`[MCP Bridge] Handling list_prompts request`),{prompts:t.modelContext.listPrompts()})),e.setRequestHandler(n.GetPromptRequestSchema,async e=>{console.log(`[MCP Bridge] Handling get_prompt request: ${e.params.name}`);try{return await t.modelContext.getPrompt(e.params.name,e.params.arguments)}catch(t){throw console.error(`[MCP Bridge] Error getting prompt ${e.params.name}:`,t),t}})},o=i?.create?.();if(o){console.log(`[Web Model Context] Using custom transport`);let e=new n.Server({name:r,version:`1.0.0`},{capabilities:{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}}}),t={tabServer:e,tools:new Map,resources:new Map,prompts:new Map,modelContext:void 0,isInitialized:!0};return t.modelContext=new qn(t),a(e,t),e.connect(o),console.log(`[Web Model Context] MCP server connected with custom transport`),t}console.log(`[Web Model Context] Using dual-server mode`);let s=i?.tabServer!==!1,c=new n.Server({name:`${r}-tab`,version:`1.0.0`},{capabilities:{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}}}),l={tabServer:c,tools:new Map,resources:new Map,prompts:new Map,modelContext:void 0,isInitialized:!0};if(l.modelContext=new qn(l),a(c,l),s){let{allowedOrigins:e,...n}=typeof i?.tabServer==`object`?i.tabServer:{},r=new t.TabServerTransport({allowedOrigins:e??[`*`],...n});c.connect(r),console.log(`[Web Model Context] Tab server connected`)}let u=typeof window<`u`&&window.parent!==window,d=i?.iframeServer;if(d!==!1&&(d!==void 0||u)){console.log(`[Web Model Context] Enabling iframe server`);let e=new n.Server({name:`${r}-iframe`,version:`1.0.0`},{capabilities:{tools:{listChanged:!0},resources:{listChanged:!0},prompts:{listChanged:!0}}});a(e,l);let{allowedOrigins:i,...o}=typeof d==`object`?d:{},s=new t.IframeChildTransport({allowedOrigins:i??[`*`],...o});e.connect(s),l.iframeServer=e,console.log(`[Web Model Context] Iframe server connected`)}return l}function Yn(e){if(typeof window>`u`){console.warn(`[Web Model Context] Not in browser environment, skipping initialization`);return}let t=e??window.__webModelContextOptions,n=Un();if(n.hasNativeContext&&n.hasNativeTesting){let e=window.navigator.modelContext,n=window.navigator.modelContextTesting;if(!e||!n){console.error(`[Web Model Context] Native API detection mismatch`);return}console.log(`✅ [Web Model Context] Native Chromium API detected`),console.log(` Using native implementation with MCP bridge synchronization`),console.log(` Native API will automatically collect tools from embedded iframes`);try{let r=Jn(t);r.modelContext=new Wn(r,e,n),r.modelContextTesting=n,Object.defineProperty(window,`__mcpBridge`,{value:r,writable:!1,configurable:!0}),console.log(`✅ [Web Model Context] MCP bridge synced with native API`),console.log(` MCP clients will receive automatic tool updates from native registry`)}catch(e){throw console.error(`[Web Model Context] Failed to initialize native adapter:`,e),e}return}if(n.hasNativeContext&&!n.hasNativeTesting){console.warn(`[Web Model Context] Partial native API detected`),console.warn(` navigator.modelContext exists but navigator.modelContextTesting is missing`),console.warn(` Cannot sync with native API. Please enable experimental features:`),console.warn(` - Navigate to chrome://flags`),console.warn(` - Enable "Experimental Web Platform Features"`),console.warn(` - Or launch with: --enable-experimental-web-platform-features`),console.warn(` Skipping initialization to avoid conflicts`);return}if(window.navigator.modelContext){console.warn(`[Web Model Context] window.navigator.modelContext already exists, skipping initialization`);return}console.log(`[Web Model Context] Native API not detected, installing polyfill`);try{let e=Jn(t);Object.defineProperty(window.navigator,`modelContext`,{value:e.modelContext,writable:!1,configurable:!1}),Object.defineProperty(window,`__mcpBridge`,{value:e,writable:!1,configurable:!0}),console.log(`✅ [Web Model Context] window.navigator.modelContext initialized successfully`),console.log(`[Model Context Testing] Installing polyfill`),console.log(` 💡 To use the native implementation in Chromium:`),console.log(` - Navigate to chrome://flags`),console.log(` - Enable "Experimental Web Platform Features"`),console.log(` - Or launch with: --enable-experimental-web-platform-features`);let n=new Kn(e);e.modelContextTesting=n,e.modelContext.setTestingAPI(n),Object.defineProperty(window.navigator,`modelContextTesting`,{value:n,writable:!1,configurable:!0}),console.log(`✅ [Model Context Testing] Polyfill installed at window.navigator.modelContextTesting`)}catch(e){throw console.error(`[Web Model Context] Failed to initialize:`,e),e}}function Xn(){if(!(typeof window>`u`)){if(window.__mcpBridge)try{window.__mcpBridge.tabServer.close(),window.__mcpBridge.iframeServer&&window.__mcpBridge.iframeServer.close()}catch(e){console.warn(`[Web Model Context] Error closing MCP servers:`,e)}delete window.navigator.modelContext,delete window.navigator.modelContextTesting,delete window.__mcpBridge,console.log(`[Web Model Context] Cleaned up`)}}function Zn(e,t){return e?t?{...e,...t,tabServer:{...e.tabServer??{},...t.tabServer??{}}}:e:t}function Qn(e,t){return e?t?{...e,...t,transport:Zn(e.transport??{},t.transport??{})}:e:t}function $n(e){if(!e||!e.dataset)return;let{dataset:t}=e;if(t.webmcpOptions)try{return JSON.parse(t.webmcpOptions)}catch(e){console.error(`[Web Model Context] Invalid JSON in data-webmcp-options:`,e);return}let n={},r=!1;t.webmcpAutoInitialize!==void 0&&(n.autoInitialize=t.webmcpAutoInitialize!==`false`,r=!0);let i={},a=!1;if(t.webmcpAllowedOrigins){let e=t.webmcpAllowedOrigins.split(`,`).map(e=>e.trim()).filter(e=>e.length>0);e.length>0&&(i.allowedOrigins=e,r=!0,a=!0)}return t.webmcpChannelId&&(i.channelId=t.webmcpChannelId,r=!0,a=!0),a&&(n.transport={...n.transport??{},tabServer:{...n.transport?.tabServer??{},...i}}),r?n:void 0}if(typeof window<`u`&&typeof document<`u`){let e=window.__webModelContextOptions,t=document.currentScript,n=$n(t),r=Qn(e,n)??e??n;r&&(window.__webModelContextOptions=r);let i=r?.autoInitialize!==!1;try{i&&Yn(r)}catch(e){console.error(`[Web Model Context] Auto-initialization failed:`,e)}}return e.cleanupWebModelContext=Xn,e.initializeWebModelContext=Yn,e.zodToJsonSchema=Vn,e})({},__mcp_b_transports,__mcp_b_webmcp_ts_sdk);