@iai-lib/any-chat-widget 0.1.0-alpha.60 → 0.1.0-alpha.62

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.
@@ -40,7 +40,7 @@
40
40
  * @license
41
41
  * Copyright 2021 Google LLC
42
42
  * SPDX-License-Identifier: BSD-3-Clause
43
- */function zA(t,e,r){return t?e(t):r==null?void 0:r(t)}var fr;(function(t){t.assertEqual=i=>i;function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(fr||(fr={}));var Dp;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Dp||(Dp={}));const vt=fr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ha=t=>{switch(typeof t){case"undefined":return vt.undefined;case"string":return vt.string;case"number":return isNaN(t)?vt.nan:vt.number;case"boolean":return vt.boolean;case"function":return vt.function;case"bigint":return vt.bigint;case"symbol":return vt.symbol;case"object":return Array.isArray(t)?vt.array:t===null?vt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?vt.promise:typeof Map<"u"&&t instanceof Map?vt.map:typeof Set<"u"&&t instanceof Set?vt.set:typeof Date<"u"&&t instanceof Date?vt.date:vt.object;default:return vt.unknown}},rt=fr.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"]),HA=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Hn extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}static assert(e){if(!(e instanceof Hn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,fr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Hn.create=t=>new Hn(t);const zo=(t,e)=>{let r;switch(t.code){case rt.invalid_type:t.received===vt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case rt.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,fr.jsonStringifyReplacer)}`;break;case rt.unrecognized_keys:r=`Unrecognized key(s) in object: ${fr.joinValues(t.keys,", ")}`;break;case rt.invalid_union:r="Invalid input";break;case rt.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${fr.joinValues(t.options)}`;break;case rt.invalid_enum_value:r=`Invalid enum value. Expected ${fr.joinValues(t.options)}, received '${t.received}'`;break;case rt.invalid_arguments:r="Invalid function arguments";break;case rt.invalid_return_type:r="Invalid function return type";break;case rt.invalid_date:r="Invalid date";break;case rt.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:fr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case rt.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case rt.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case rt.custom:r="Invalid input";break;case rt.invalid_intersection_types:r="Intersection results could not be merged";break;case rt.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case rt.not_finite:r="Number must be finite";break;default:r=e.defaultError,fr.assertNever(t)}return{message:r}};let Iw=zo;function qA(t){Iw=t}function Rd(){return Iw}const Ad=t=>{const{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],s={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(s,{data:e,defaultError:o}).message;return{...i,path:a,message:o}},VA=[];function dt(t,e){const r=Rd(),n=Ad({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===zo?void 0:zo].filter(i=>!!i)});t.common.issues.push(n)}class hn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const i of r){if(i.status==="aborted")return Ht;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const i of r){const a=await i.key,s=await i.value;n.push({key:a,value:s})}return hn.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const i of r){const{key:a,value:s}=i;if(a.status==="aborted"||s.status==="aborted")return Ht;a.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[a.value]=s.value)}return{status:e.value,value:n}}}const Ht=Object.freeze({status:"aborted"}),Ho=t=>({status:"dirty",value:t}),kn=t=>({status:"valid",value:t}),jp=t=>t.status==="aborted",Up=t=>t.status==="dirty",dl=t=>t.status==="valid",fl=t=>typeof Promise<"u"&&t instanceof Promise;function Od(t,e,r,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function xw(t,e,r,n,i){if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r}typeof SuppressedError=="function"&&SuppressedError;var Pt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Pt||(Pt={}));var hl,pl;class Ni{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Rw=(t,e)=>{if(dl(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new Hn(t.common.issues);return this._error=r,this._error}}};function tr(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,o)=>{var u,l;const{message:c}=t;return s.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:(u=c??n)!==null&&u!==void 0?u:o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:(l=c??r)!==null&&l!==void 0?l:o.defaultError}},description:i}}class sr{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)}get description(){return this._def.description}_getType(e){return Ha(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ha(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new hn,ctx:{common:e.parent.common,data:e.data,parsedType:Ha(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(fl(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const i={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ha(e)},a=this._parseSync({data:e,path:i.path,parent:i});return Rw(i,a)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ha(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(fl(i)?i:Promise.resolve(i));return Rw(n,a)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{const s=e(i),o=()=>a.addIssue({code:rt.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new mi({schema:this,typeName:Ut.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Di.create(this,this._def)}nullable(){return Za.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return gi.create(this,this._def)}promise(){return Zo.create(this,this._def)}or(e){return yl.create([this,e],this._def)}and(e){return bl.create(this,e,this._def)}transform(e){return new mi({...tr(this._def),schema:this,typeName:Ut.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new $l({...tr(this._def),innerType:this,defaultValue:r,typeName:Ut.ZodDefault})}brand(){return new zp({typeName:Ut.ZodBranded,type:this,...tr(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Tl({...tr(this._def),innerType:this,catchValue:r,typeName:Ut.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Cl.create(this,e)}readonly(){return El.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const WA=/^c[^\s-]{8,}$/i,ZA=/^[0-9a-z]+$/,GA=/^[0-9A-HJKMNP-TV-Z]{26}$/,KA=/^[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,YA=/^[a-z0-9_-]{21}$/i,JA=/^[-+]?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)?)??$/,QA=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,XA="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Fp;const e2=/^(?:(?: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])$/,t2=/^(([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})))$/,r2=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Aw="((\\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])))",n2=new RegExp(`^${Aw}$`);function Ow(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function i2(t){return new RegExp(`^${Ow(t)}$`)}function Pw(t){let e=`${Aw}T${Ow(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function a2(t,e){return!!((e==="v4"||!e)&&e2.test(t)||(e==="v6"||!e)&&t2.test(t))}class vi extends sr{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==vt.string){const a=this._getOrReturnCtx(e);return dt(a,{code:rt.invalid_type,expected:vt.string,received:a.parsedType}),Ht}const n=new hn;let i;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const s=e.data.length>a.value,o=e.data.length<a.value;(s||o)&&(i=this._getOrReturnCtx(e,i),s?dt(i,{code:rt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&dt(i,{code:rt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")QA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"email",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Fp||(Fp=new RegExp(XA,"u")),Fp.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"emoji",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")KA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"uuid",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")YA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"nanoid",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")WA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"cuid",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")ZA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"cuid2",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")GA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"ulid",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),dt(i,{validation:"url",code:rt.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"regex",code:rt.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Pw(a).test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?n2.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?i2(a).test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?JA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"duration",code:rt.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?a2(e.data,a.version)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"ip",code:rt.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?r2.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"base64",code:rt.invalid_string,message:a.message}),n.dirty()):fr.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:rt.invalid_string,...Pt.errToObj(n)})}_addCheck(e){return new vi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Pt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Pt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Pt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Pt.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Pt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Pt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Pt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Pt.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Pt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Pt.errToObj(e)})}datetime(e){var r,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Pt.errToObj(e==null?void 0: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:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Pt.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Pt.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Pt.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Pt.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Pt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Pt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Pt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Pt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Pt.errToObj(r)})}nonempty(e){return this.min(1,Pt.errToObj(e))}trim(){return new vi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new vi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new vi({...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 isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}vi.create=t=>{var e;return new vi({checks:[],typeName:Ut.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...tr(t)})};function s2(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),s=parseInt(e.toFixed(i).replace(".",""));return a%s/Math.pow(10,i)}class qa extends sr{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)!==vt.number){const a=this._getOrReturnCtx(e);return dt(a,{code:rt.invalid_type,expected:vt.number,received:a.parsedType}),Ht}let n;const i=new hn;for(const a of this._def.checks)a.kind==="int"?fr.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?s2(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.not_finite,message:a.message}),i.dirty()):fr.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Pt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Pt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Pt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Pt.toString(r))}setLimit(e,r,n,i){return new qa({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Pt.toString(i)}]})}_addCheck(e){return new qa({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Pt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Pt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Pt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Pt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Pt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Pt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Pt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Pt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Pt.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&fr.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}qa.create=t=>new qa({checks:[],typeName:Ut.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...tr(t)});class Va extends sr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==vt.bigint){const a=this._getOrReturnCtx(e);return dt(a,{code:rt.invalid_type,expected:vt.bigint,received:a.parsedType}),Ht}let n;const i=new hn;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):fr.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Pt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Pt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Pt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Pt.toString(r))}setLimit(e,r,n,i){return new Va({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Pt.toString(i)}]})}_addCheck(e){return new Va({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Pt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Pt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Pt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Pt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Pt.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Va.create=t=>{var e;return new Va({checks:[],typeName:Ut.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...tr(t)})};class vl extends sr{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==vt.boolean){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.boolean,received:n.parsedType}),Ht}return kn(e.data)}}vl.create=t=>new vl({typeName:Ut.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...tr(t)});class Ds extends sr{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==vt.date){const a=this._getOrReturnCtx(e);return dt(a,{code:rt.invalid_type,expected:vt.date,received:a.parsedType}),Ht}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return dt(a,{code:rt.invalid_date}),Ht}const n=new hn;let i;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):fr.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ds({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Pt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Pt.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Ds.create=t=>new Ds({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Ut.ZodDate,...tr(t)});class Pd extends sr{_parse(e){if(this._getType(e)!==vt.symbol){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.symbol,received:n.parsedType}),Ht}return kn(e.data)}}Pd.create=t=>new Pd({typeName:Ut.ZodSymbol,...tr(t)});class gl extends sr{_parse(e){if(this._getType(e)!==vt.undefined){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.undefined,received:n.parsedType}),Ht}return kn(e.data)}}gl.create=t=>new gl({typeName:Ut.ZodUndefined,...tr(t)});class ml extends sr{_parse(e){if(this._getType(e)!==vt.null){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.null,received:n.parsedType}),Ht}return kn(e.data)}}ml.create=t=>new ml({typeName:Ut.ZodNull,...tr(t)});class qo extends sr{constructor(){super(...arguments),this._any=!0}_parse(e){return kn(e.data)}}qo.create=t=>new qo({typeName:Ut.ZodAny,...tr(t)});class js extends sr{constructor(){super(...arguments),this._unknown=!0}_parse(e){return kn(e.data)}}js.create=t=>new js({typeName:Ut.ZodUnknown,...tr(t)});class la extends sr{_parse(e){const r=this._getOrReturnCtx(e);return dt(r,{code:rt.invalid_type,expected:vt.never,received:r.parsedType}),Ht}}la.create=t=>new la({typeName:Ut.ZodNever,...tr(t)});class Md extends sr{_parse(e){if(this._getType(e)!==vt.undefined){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.void,received:n.parsedType}),Ht}return kn(e.data)}}Md.create=t=>new Md({typeName:Ut.ZodVoid,...tr(t)});class gi extends sr{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==vt.array)return dt(r,{code:rt.invalid_type,expected:vt.array,received:r.parsedType}),Ht;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(s||o)&&(dt(r,{code:s?rt.too_big:rt.too_small,minimum:o?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(dt(r,{code:rt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(dt(r,{code:rt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>i.type._parseAsync(new Ni(r,s,r.path,o)))).then(s=>hn.mergeArray(n,s));const a=[...r.data].map((s,o)=>i.type._parseSync(new Ni(r,s,r.path,o)));return hn.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new gi({...this._def,minLength:{value:e,message:Pt.toString(r)}})}max(e,r){return new gi({...this._def,maxLength:{value:e,message:Pt.toString(r)}})}length(e,r){return new gi({...this._def,exactLength:{value:e,message:Pt.toString(r)}})}nonempty(e){return this.min(1,e)}}gi.create=(t,e)=>new gi({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Ut.ZodArray,...tr(e)});function Vo(t){if(t instanceof qr){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=Di.create(Vo(n))}return new qr({...t._def,shape:()=>e})}else return t instanceof gi?new gi({...t._def,type:Vo(t.element)}):t instanceof Di?Di.create(Vo(t.unwrap())):t instanceof Za?Za.create(Vo(t.unwrap())):t instanceof Li?Li.create(t.items.map(e=>Vo(e))):t}class qr extends sr{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=fr.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==vt.object){const l=this._getOrReturnCtx(e);return dt(l,{code:rt.invalid_type,expected:vt.object,received:l.parsedType}),Ht}const{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof la&&this._def.unknownKeys==="strip"))for(const l in i.data)s.includes(l)||o.push(l);const u=[];for(const l of s){const c=a[l],d=i.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new Ni(i,d,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof la){const l=this._def.unknownKeys;if(l==="passthrough")for(const c of o)u.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(l==="strict")o.length>0&&(dt(i,{code:rt.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const c of o){const d=i.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new Ni(i,d,i.path,c)),alwaysSet:c in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const l=[];for(const c of u){const d=await c.key,f=await c.value;l.push({key:d,value:f,alwaysSet:c.alwaysSet})}return l}).then(l=>hn.mergeObjectSync(n,l)):hn.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Pt.errToObj,new qr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,s,o;const u=(s=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&s!==void 0?s:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=Pt.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new qr({...this._def,unknownKeys:"strip"})}passthrough(){return new qr({...this._def,unknownKeys:"passthrough"})}extend(e){return new qr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new qr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ut.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new qr({...this._def,catchall:e})}pick(e){const r={};return fr.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new qr({...this._def,shape:()=>r})}omit(e){const r={};return fr.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new qr({...this._def,shape:()=>r})}deepPartial(){return Vo(this)}partial(e){const r={};return fr.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}),new qr({...this._def,shape:()=>r})}required(e){const r={};return fr.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Di;)a=a._def.innerType;r[n]=a}}),new qr({...this._def,shape:()=>r})}keyof(){return Mw(fr.objectKeys(this.shape))}}qr.create=(t,e)=>new qr({shape:()=>t,unknownKeys:"strip",catchall:la.create(),typeName:Ut.ZodObject,...tr(e)}),qr.strictCreate=(t,e)=>new qr({shape:()=>t,unknownKeys:"strict",catchall:la.create(),typeName:Ut.ZodObject,...tr(e)}),qr.lazycreate=(t,e)=>new qr({shape:t,unknownKeys:"strip",catchall:la.create(),typeName:Ut.ZodObject,...tr(e)});class yl extends sr{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(o=>new Hn(o.ctx.common.issues));return dt(r,{code:rt.invalid_union,unionErrors:s}),Ht}if(r.common.async)return Promise.all(n.map(async a=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let a;const s=[];for(const u of n){const l={...r,common:{...r.common,issues:[]},parent:null},c=u._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(u=>new Hn(u));return dt(r,{code:rt.invalid_union,unionErrors:o}),Ht}}get options(){return this._def.options}}yl.create=(t,e)=>new yl({options:t,typeName:Ut.ZodUnion,...tr(e)});const ca=t=>t instanceof _l?ca(t.schema):t instanceof mi?ca(t.innerType()):t instanceof kl?[t.value]:t instanceof Wa?t.options:t instanceof Sl?fr.objectValues(t.enum):t instanceof $l?ca(t._def.innerType):t instanceof gl?[void 0]:t instanceof ml?[null]:t instanceof Di?[void 0,...ca(t.unwrap())]:t instanceof Za?[null,...ca(t.unwrap())]:t instanceof zp||t instanceof El?ca(t.unwrap()):t instanceof Tl?ca(t._def.innerType):[];class Nd extends sr{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==vt.object)return dt(r,{code:rt.invalid_type,expected:vt.object,received:r.parsedType}),Ht;const n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(dt(r,{code:rt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Ht)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const a of r){const s=ca(a.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,a)}}return new Nd({typeName:Ut.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...tr(n)})}}function Bp(t,e){const r=Ha(t),n=Ha(e);if(t===e)return{valid:!0,data:t};if(r===vt.object&&n===vt.object){const i=fr.objectKeys(e),a=fr.objectKeys(t).filter(o=>i.indexOf(o)!==-1),s={...t,...e};for(const o of a){const u=Bp(t[o],e[o]);if(!u.valid)return{valid:!1};s[o]=u.data}return{valid:!0,data:s}}else if(r===vt.array&&n===vt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const s=t[a],o=e[a],u=Bp(s,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===vt.date&&n===vt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class bl extends sr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=(a,s)=>{if(jp(a)||jp(s))return Ht;const o=Bp(a.value,s.value);return o.valid?((Up(a)||Up(s))&&r.dirty(),{status:r.value,value:o.data}):(dt(n,{code:rt.invalid_intersection_types}),Ht)};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(([a,s])=>i(a,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}bl.create=(t,e,r)=>new bl({left:t,right:e,typeName:Ut.ZodIntersection,...tr(r)});class Li extends sr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==vt.array)return dt(n,{code:rt.invalid_type,expected:vt.array,received:n.parsedType}),Ht;if(n.data.length<this._def.items.length)return dt(n,{code:rt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ht;!this._def.rest&&n.data.length>this._def.items.length&&(dt(n,{code:rt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((s,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new Ni(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(a).then(s=>hn.mergeArray(r,s)):hn.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Li({...this._def,rest:e})}}Li.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Li({items:t,typeName:Ut.ZodTuple,rest:null,...tr(e)})};class wl extends sr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==vt.object)return dt(n,{code:rt.invalid_type,expected:vt.object,received:n.parsedType}),Ht;const i=[],a=this._def.keyType,s=this._def.valueType;for(const o in n.data)i.push({key:a._parse(new Ni(n,o,n.path,o)),value:s._parse(new Ni(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?hn.mergeObjectAsync(r,i):hn.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof sr?new wl({keyType:e,valueType:r,typeName:Ut.ZodRecord,...tr(n)}):new wl({keyType:vi.create(),valueType:e,typeName:Ut.ZodRecord,...tr(r)})}}class Ld extends sr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==vt.map)return dt(n,{code:rt.invalid_type,expected:vt.map,received:n.parsedType}),Ht;const i=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([o,u],l)=>({key:i._parse(new Ni(n,o,n.path,[l,"key"])),value:a._parse(new Ni(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of s){const l=await u.key,c=await u.value;if(l.status==="aborted"||c.status==="aborted")return Ht;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const u of s){const l=u.key,c=u.value;if(l.status==="aborted"||c.status==="aborted")return Ht;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}}Ld.create=(t,e,r)=>new Ld({valueType:e,keyType:t,typeName:Ut.ZodMap,...tr(r)});class Us extends sr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==vt.set)return dt(n,{code:rt.invalid_type,expected:vt.set,received:n.parsedType}),Ht;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(dt(n,{code:rt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(dt(n,{code:rt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const a=this._def.valueType;function s(u){const l=new Set;for(const c of u){if(c.status==="aborted")return Ht;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new Ni(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>s(u)):s(o)}min(e,r){return new Us({...this._def,minSize:{value:e,message:Pt.toString(r)}})}max(e,r){return new Us({...this._def,maxSize:{value:e,message:Pt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Us.create=(t,e)=>new Us({valueType:t,minSize:null,maxSize:null,typeName:Ut.ZodSet,...tr(e)});class Wo extends sr{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==vt.function)return dt(r,{code:rt.invalid_type,expected:vt.function,received:r.parsedType}),Ht;function n(o,u){return Ad({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rd(),zo].filter(l=>!!l),issueData:{code:rt.invalid_arguments,argumentsError:u}})}function i(o,u){return Ad({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rd(),zo].filter(l=>!!l),issueData:{code:rt.invalid_return_type,returnTypeError:u}})}const a={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Zo){const o=this;return kn(async function(...u){const l=new Hn([]),c=await o._def.args.parseAsync(u,a).catch(m=>{throw l.addIssue(n(u,m)),l}),d=await Reflect.apply(s,this,c);return await o._def.returns._def.type.parseAsync(d,a).catch(m=>{throw l.addIssue(i(d,m)),l})})}else{const o=this;return kn(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Hn([n(u,l.error)]);const c=Reflect.apply(s,this,l.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new Hn([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Wo({...this._def,args:Li.create(e).rest(js.create())})}returns(e){return new Wo({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Wo({args:e||Li.create([]).rest(js.create()),returns:r||js.create(),typeName:Ut.ZodFunction,...tr(n)})}}class _l extends sr{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}_l.create=(t,e)=>new _l({getter:t,typeName:Ut.ZodLazy,...tr(e)});class kl extends sr{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return dt(r,{received:r.data,code:rt.invalid_literal,expected:this._def.value}),Ht}return{status:"valid",value:e.data}}get value(){return this._def.value}}kl.create=(t,e)=>new kl({value:t,typeName:Ut.ZodLiteral,...tr(e)});function Mw(t,e){return new Wa({values:t,typeName:Ut.ZodEnum,...tr(e)})}class Wa extends sr{constructor(){super(...arguments),hl.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return dt(r,{expected:fr.joinValues(n),received:r.parsedType,code:rt.invalid_type}),Ht}if(Od(this,hl)||xw(this,hl,new Set(this._def.values)),!Od(this,hl).has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return dt(r,{received:r.data,code:rt.invalid_enum_value,options:n}),Ht}return kn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return Wa.create(e,{...this._def,...r})}exclude(e,r=this._def){return Wa.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}hl=new WeakMap,Wa.create=Mw;class Sl extends sr{constructor(){super(...arguments),pl.set(this,void 0)}_parse(e){const r=fr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==vt.string&&n.parsedType!==vt.number){const i=fr.objectValues(r);return dt(n,{expected:fr.joinValues(i),received:n.parsedType,code:rt.invalid_type}),Ht}if(Od(this,pl)||xw(this,pl,new Set(fr.getValidEnumValues(this._def.values))),!Od(this,pl).has(e.data)){const i=fr.objectValues(r);return dt(n,{received:n.data,code:rt.invalid_enum_value,options:i}),Ht}return kn(e.data)}get enum(){return this._def.values}}pl=new WeakMap,Sl.create=(t,e)=>new Sl({values:t,typeName:Ut.ZodNativeEnum,...tr(e)});class Zo extends sr{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==vt.promise&&r.common.async===!1)return dt(r,{code:rt.invalid_type,expected:vt.promise,received:r.parsedType}),Ht;const n=r.parsedType===vt.promise?r.data:Promise.resolve(r.data);return kn(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Zo.create=(t,e)=>new Zo({type:t,typeName:Ut.ZodPromise,...tr(e)});class mi extends sr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ut.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:s=>{dt(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const s=i.transform(n.data,a);if(n.common.async)return Promise.resolve(s).then(async o=>{if(r.value==="aborted")return Ht;const u=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return u.status==="aborted"?Ht:u.status==="dirty"||r.value==="dirty"?Ho(u.value):u});{if(r.value==="aborted")return Ht;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?Ht:o.status==="dirty"||r.value==="dirty"?Ho(o.value):o}}if(i.type==="refinement"){const s=o=>{const u=i.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Ht:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?Ht:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!dl(s))return s;const o=i.transform(s.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>dl(s)?Promise.resolve(i.transform(s.value,a)).then(o=>({status:r.value,value:o})):s);fr.assertNever(i)}}mi.create=(t,e,r)=>new mi({schema:t,typeName:Ut.ZodEffects,effect:e,...tr(r)}),mi.createWithPreprocess=(t,e,r)=>new mi({schema:e,effect:{type:"preprocess",transform:t},typeName:Ut.ZodEffects,...tr(r)});class Di extends sr{_parse(e){return this._getType(e)===vt.undefined?kn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Di.create=(t,e)=>new Di({innerType:t,typeName:Ut.ZodOptional,...tr(e)});class Za extends sr{_parse(e){return this._getType(e)===vt.null?kn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Za.create=(t,e)=>new Za({innerType:t,typeName:Ut.ZodNullable,...tr(e)});class $l extends sr{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===vt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}$l.create=(t,e)=>new $l({innerType:t,typeName:Ut.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...tr(e)});class Tl extends sr{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return fl(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Hn(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Hn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Tl.create=(t,e)=>new Tl({innerType:t,typeName:Ut.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...tr(e)});class Dd extends sr{_parse(e){if(this._getType(e)!==vt.nan){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.nan,received:n.parsedType}),Ht}return{status:"valid",value:e.data}}}Dd.create=t=>new Dd({typeName:Ut.ZodNaN,...tr(t)});const o2=Symbol("zod_brand");class zp extends sr{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Cl extends sr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Ht:a.status==="dirty"?(r.dirty(),Ho(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Ht:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new Cl({in:e,out:r,typeName:Ut.ZodPipeline})}}class El extends sr{_parse(e){const r=this._def.innerType._parse(e),n=i=>(dl(i)&&(i.value=Object.freeze(i.value)),i);return fl(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}}El.create=(t,e)=>new El({innerType:t,typeName:Ut.ZodReadonly,...tr(e)});function Nw(t,e={},r){return t?qo.create().superRefine((n,i)=>{var a,s;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(s=(a=o.fatal)!==null&&a!==void 0?a:r)!==null&&s!==void 0?s:!0,l=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...l,fatal:u})}}):qo.create()}const u2={object:qr.lazycreate};var Ut;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Ut||(Ut={}));const l2=(t,e={message:`Input not instance of ${t.name}`})=>Nw(r=>r instanceof t,e),Lw=vi.create,Dw=qa.create,c2=Dd.create,d2=Va.create,jw=vl.create,f2=Ds.create,h2=Pd.create,p2=gl.create,v2=ml.create,g2=qo.create,m2=js.create,y2=la.create,b2=Md.create,w2=gi.create,_2=qr.create,k2=qr.strictCreate,S2=yl.create,$2=Nd.create,T2=bl.create,C2=Li.create,E2=wl.create,I2=Ld.create,x2=Us.create,R2=Wo.create,A2=_l.create,O2=kl.create,P2=Wa.create,M2=Sl.create,N2=Zo.create,Uw=mi.create,L2=Di.create,D2=Za.create,j2=mi.createWithPreprocess,U2=Cl.create;var Il=Object.freeze({__proto__:null,defaultErrorMap:zo,setErrorMap:qA,getErrorMap:Rd,makeIssue:Ad,EMPTY_PATH:VA,addIssueToContext:dt,ParseStatus:hn,INVALID:Ht,DIRTY:Ho,OK:kn,isAborted:jp,isDirty:Up,isValid:dl,isAsync:fl,get util(){return fr},get objectUtil(){return Dp},ZodParsedType:vt,getParsedType:Ha,ZodType:sr,datetimeRegex:Pw,ZodString:vi,ZodNumber:qa,ZodBigInt:Va,ZodBoolean:vl,ZodDate:Ds,ZodSymbol:Pd,ZodUndefined:gl,ZodNull:ml,ZodAny:qo,ZodUnknown:js,ZodNever:la,ZodVoid:Md,ZodArray:gi,ZodObject:qr,ZodUnion:yl,ZodDiscriminatedUnion:Nd,ZodIntersection:bl,ZodTuple:Li,ZodRecord:wl,ZodMap:Ld,ZodSet:Us,ZodFunction:Wo,ZodLazy:_l,ZodLiteral:kl,ZodEnum:Wa,ZodNativeEnum:Sl,ZodPromise:Zo,ZodEffects:mi,ZodTransformer:mi,ZodOptional:Di,ZodNullable:Za,ZodDefault:$l,ZodCatch:Tl,ZodNaN:Dd,BRAND:o2,ZodBranded:zp,ZodPipeline:Cl,ZodReadonly:El,custom:Nw,Schema:sr,ZodSchema:sr,late:u2,get ZodFirstPartyTypeKind(){return Ut},coerce:{string:t=>vi.create({...t,coerce:!0}),number:t=>qa.create({...t,coerce:!0}),boolean:t=>vl.create({...t,coerce:!0}),bigint:t=>Va.create({...t,coerce:!0}),date:t=>Ds.create({...t,coerce:!0})},any:g2,array:w2,bigint:d2,boolean:jw,date:f2,discriminatedUnion:$2,effect:Uw,enum:P2,function:R2,instanceof:l2,intersection:T2,lazy:A2,literal:O2,map:I2,nan:c2,nativeEnum:M2,never:y2,null:v2,nullable:D2,number:Dw,object:_2,oboolean:()=>jw().optional(),onumber:()=>Dw().optional(),optional:L2,ostring:()=>Lw().optional(),pipeline:U2,preprocess:j2,promise:N2,record:E2,set:x2,strictObject:k2,string:Lw,symbol:h2,transformer:Uw,tuple:C2,undefined:p2,union:S2,unknown:m2,void:b2,NEVER:Ht,ZodIssueCode:rt,quotelessJson:HA,ZodError:Hn});const Fw=yA`*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: \"\"}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.static{position:static}.relative{position:relative}.my-4{margin-top:1rem;margin-bottom:1rem}.mb-4{margin-bottom:1rem}.mt-4{margin-top:1rem}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rounded{border-radius:.25rem}.border{border-width:1px}.border-red-400{--tw-border-opacity: 1;border-color:rgb(248 113 113 / var(--tw-border-opacity))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity))}.px-4{padding-left:1rem;padding-right:1rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity))}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}input{width:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-radius:.25rem;border-width:1px;padding:.5rem .75rem;line-height:1.25;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity));--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}label{margin-bottom:.5rem;display:block;font-size:.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.btn-primary{border-radius:.25rem;padding:.5rem 1rem;font-weight:700;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.btn-primary:hover{opacity:.95}.btn-primary:disabled{pointer-events:none;opacity:.5}.btn-primary{background-color:var(--iai-chat-i-button-bg);color:var(--iai-chat-i-button-fg)}.btn-secondary{padding:.5rem 1rem;font-weight:700;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.btn-secondary:hover{opacity:.95}.btn-secondary:disabled{pointer-events:none;opacity:.5}`;var sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function F2(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function B2(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}(function(){function t(M,V){var ie=M.split("."),Fe=ce;ie[0]in Fe||!Fe.execScript||Fe.execScript("var "+ie[0]);for(var lt;ie.length&&(lt=ie.shift());)ie.length||V===void 0?Fe=Fe[lt]?Fe[lt]:Fe[lt]={}:Fe[lt]=V}function e(M,V){function ie(){}ie.prototype=V.prototype,M.M=V.prototype,M.prototype=new ie,M.prototype.constructor=M,M.N=function(Fe,lt,yt){for(var Bt=Array(arguments.length-2),er=2;er<arguments.length;er++)Bt[er-2]=arguments[er];return V.prototype[lt].apply(Fe,Bt)}}function r(M,V){M!=null&&this.a.apply(this,arguments)}function n(M){M.b=""}function i(M,V){M.sort(V||a)}function a(M,V){return M>V?1:M<V?-1:0}function s(M){var V,ie=[],Fe=0;for(V in M)ie[Fe++]=M[V];return ie}function o(M,V){this.b=M,this.a={};for(var ie=0;ie<V.length;ie++){var Fe=V[ie];this.a[Fe.b]=Fe}}function u(M){return M=s(M.a),i(M,function(V,ie){return V.b-ie.b}),M}function l(M,V){switch(this.b=M,this.g=!!V.v,this.a=V.c,this.i=V.type,this.h=!1,this.a){case be:case ht:case Ve:case Kt:case Rt:case Ue:case Ge:this.h=!0}this.f=V.defaultValue}function c(){this.a={},this.f=this.j().a,this.b=this.g=null}function d(M,V){for(var ie=u(M.j()),Fe=0;Fe<ie.length;Fe++){var lt=ie[Fe],yt=lt.b;if(V.a[yt]!=null){M.b&&delete M.b[lt.b];var Bt=lt.a==11||lt.a==10;if(lt.g)for(var lt=f(V,yt)||[],er=0;er<lt.length;er++){var Ee=M,Ne=yt,pe=Bt?lt[er].clone():lt[er];Ee.a[Ne]||(Ee.a[Ne]=[]),Ee.a[Ne].push(pe),Ee.b&&delete Ee.b[Ne]}else lt=f(V,yt),Bt?(Bt=f(M,yt))?d(Bt,lt):N(M,yt,lt.clone()):N(M,yt,lt)}}}function f(M,V){var ie=M.a[V];if(ie==null)return null;if(M.g){if(!(V in M.b)){var Fe=M.g,lt=M.f[V];if(ie!=null)if(lt.g){for(var yt=[],Bt=0;Bt<ie.length;Bt++)yt[Bt]=Fe.b(lt,ie[Bt]);ie=yt}else ie=Fe.b(lt,ie);return M.b[V]=ie}return M.b[V]}return ie}function m(M,V,ie){var Fe=f(M,V);return M.f[V].g?Fe[ie||0]:Fe}function k(M,V){var ie;if(M.a[V]!=null)ie=m(M,V,void 0);else e:{if(ie=M.f[V],ie.f===void 0){var Fe=ie.i;if(Fe===Boolean)ie.f=!1;else if(Fe===Number)ie.f=0;else{if(Fe!==String){ie=new Fe;break e}ie.f=ie.h?"0":""}}ie=ie.f}return ie}function L(M,V){return M.f[V].g?M.a[V]!=null?M.a[V].length:0:M.a[V]!=null?1:0}function N(M,V,ie){M.a[V]=ie,M.b&&(M.b[V]=ie)}function z(M,V){var ie,Fe=[];for(ie in V)ie!=0&&Fe.push(new l(ie,V[ie]));return new o(M,Fe)}function re(){c.call(this)}function Me(){c.call(this)}function Oe(){c.call(this)}function Be(){}function Pe(){}function Ze(){}function Z(){this.a={}}function Ie(M){return M.length==0||Or.test(M)}function _e(M,V){if(V==null)return null;V=V.toUpperCase();var ie=M.a[V];if(ie==null){if(ie=ot[V],ie==null)return null;ie=new Ze().a(Oe.j(),ie),M.a[V]=ie}return ie}function se(M){return M=kt[M],M==null?"ZZ":M[0]}function Te(M){this.H=RegExp(" "),this.C="",this.m=new r,this.w="",this.i=new r,this.u=new r,this.l=!0,this.A=this.o=this.F=!1,this.G=Z.b(),this.s=0,this.b=new r,this.B=!1,this.h="",this.a=new r,this.f=[],this.D=M,this.J=this.g=te(this,this.D)}function te(M,V){var ie;if(V!=null&&isNaN(V)&&V.toUpperCase()in ot){if(ie=_e(M.G,V),ie==null)throw Error("Invalid region code: "+V);ie=k(ie,10)}else ie=0;return ie=_e(M.G,se(ie)),ie??jr}function oe(M){for(var V=M.f.length,ie=0;ie<V;++ie){var Fe=M.f[ie],lt=k(Fe,1);if(M.w==lt)return!1;var yt;yt=M;var Bt=Fe,er=k(Bt,1);if(er.indexOf("|")!=-1)yt=!1;else{er=er.replace(lr,"\\d"),er=er.replace(cr,"\\d"),n(yt.m);var Ee;Ee=yt;var Bt=k(Bt,2),Ne="999999999999999".match(er)[0];Ne.length<Ee.a.b.length?Ee="":(Ee=Ne.replace(new RegExp(er,"g"),Bt),Ee=Ee.replace(RegExp("9","g")," ")),0<Ee.length?(yt.m.a(Ee),yt=!0):yt=!1}if(yt)return M.w=lt,M.B=At.test(m(Fe,4)),M.s=0,!0}return M.l=!1}function q(M,V){for(var ie=[],Fe=V.length-3,lt=M.f.length,yt=0;yt<lt;++yt){var Bt=M.f[yt];L(Bt,3)==0?ie.push(M.f[yt]):(Bt=m(Bt,3,Math.min(Fe,L(Bt,3)-1)),V.search(Bt)==0&&ie.push(M.f[yt]))}M.f=ie}function ne(M,V){M.i.a(V);var ie=V;if(Xe.test(ie)||M.i.b.length==1&&mr.test(ie)){var Fe,ie=V;ie=="+"?(Fe=ie,M.u.a(ie)):(Fe=ar[ie],M.u.a(Fe),M.a.a(Fe)),V=Fe}else M.l=!1,M.F=!0;if(!M.l){if(!M.F){if(Ct(M)){if(tt(M))return Se(M)}else if(0<M.h.length&&(ie=M.a.toString(),n(M.a),M.a.a(M.h),M.a.a(ie),ie=M.b.toString(),Fe=ie.lastIndexOf(M.h),n(M.b),M.b.a(ie.substring(0,Fe))),M.h!=Qe(M))return M.b.a(" "),Se(M)}return M.i.toString()}switch(M.u.b.length){case 0:case 1:case 2:return M.i.toString();case 3:if(!Ct(M))return M.h=Qe(M),ke(M);M.A=!0;default:return M.A?(tt(M)&&(M.A=!1),M.b.toString()+M.a.toString()):0<M.f.length?(ie=De(M,V),Fe=H(M),0<Fe.length?Fe:(q(M,M.a.toString()),oe(M)?P(M):M.l?ye(M,ie):M.i.toString())):ke(M)}}function Se(M){return M.l=!0,M.A=!1,M.f=[],M.s=0,n(M.m),M.w="",ke(M)}function H(M){for(var V=M.a.toString(),ie=M.f.length,Fe=0;Fe<ie;++Fe){var lt=M.f[Fe],yt=k(lt,1);if(new RegExp("^(?:"+yt+")$").test(V))return M.B=At.test(m(lt,4)),V=V.replace(new RegExp(yt,"g"),m(lt,2)),ye(M,V)}return""}function ye(M,V){var ie=M.b.b.length;return M.B&&0<ie&&M.b.toString().charAt(ie-1)!=" "?M.b+" "+V:M.b+V}function ke(M){var V=M.a.toString();if(3<=V.length){for(var ie=M.o&&M.h.length==0&&0<L(M.g,20)?f(M.g,20)||[]:f(M.g,19)||[],Fe=ie.length,lt=0;lt<Fe;++lt){var yt=ie[lt];0<M.h.length&&Ie(k(yt,4))&&!m(yt,6)&&yt.a[5]==null||(M.h.length!=0||M.o||Ie(k(yt,4))||m(yt,6))&&Vt.test(k(yt,2))&&M.f.push(yt)}return q(M,V),V=H(M),0<V.length?V:oe(M)?P(M):M.i.toString()}return ye(M,V)}function P(M){var V=M.a.toString(),ie=V.length;if(0<ie){for(var Fe="",lt=0;lt<ie;lt++)Fe=De(M,V.charAt(lt));return M.l?ye(M,Fe):M.i.toString()}return M.b.toString()}function Qe(M){var V,ie=M.a.toString(),Fe=0;return m(M.g,10)!=1?V=!1:(V=M.a.toString(),V=V.charAt(0)=="1"&&V.charAt(1)!="0"&&V.charAt(1)!="1"),V?(Fe=1,M.b.a("1").a(" "),M.o=!0):M.g.a[15]!=null&&(V=new RegExp("^(?:"+m(M.g,15)+")"),V=ie.match(V),V!=null&&V[0]!=null&&0<V[0].length&&(M.o=!0,Fe=V[0].length,M.b.a(ie.substring(0,Fe)))),n(M.a),M.a.a(ie.substring(Fe)),ie.substring(0,Fe)}function Ct(M){var V=M.u.toString(),ie=new RegExp("^(?:\\+|"+m(M.g,11)+")"),ie=V.match(ie);return ie!=null&&ie[0]!=null&&0<ie[0].length&&(M.o=!0,ie=ie[0].length,n(M.a),M.a.a(V.substring(ie)),n(M.b),M.b.a(V.substring(0,ie)),V.charAt(0)!="+"&&M.b.a(" "),!0)}function tt(M){if(M.a.b.length==0)return!1;var V,ie=new r;e:{if(V=M.a.toString(),V.length!=0&&V.charAt(0)!="0"){for(var Fe,lt=V.length,yt=1;3>=yt&&yt<=lt;++yt)if(Fe=parseInt(V.substring(0,yt),10),Fe in kt){ie.a(V.substring(yt)),V=Fe;break e}}V=0}return V!=0&&(n(M.a),M.a.a(ie.toString()),ie=se(V),ie=="001"?M.g=_e(M.G,""+V):ie!=M.D&&(M.g=te(M,ie)),M.b.a(""+V).a(" "),M.h="",!0)}function De(M,V){var ie=M.m.toString();if(0<=ie.substring(M.s).search(M.H)){var Fe=ie.search(M.H),ie=ie.replace(M.H,V);return n(M.m),M.m.a(ie),M.s=Fe,ie.substring(0,M.s+1)}return M.f.length==1&&(M.l=!1),M.w="",M.i.toString()}var ce=this;r.prototype.b="",r.prototype.set=function(M){this.b=""+M},r.prototype.a=function(M,V,ie){if(this.b+=String(M),V!=null)for(var Fe=1;Fe<arguments.length;Fe++)this.b+=arguments[Fe];return this},r.prototype.toString=function(){return this.b};var Ge=1,Ue=2,be=3,ht=4,Ve=6,Kt=16,Rt=18;c.prototype.set=function(M,V){N(this,M.b,V)},c.prototype.clone=function(){var M=new this.constructor;return M!=this&&(M.a={},M.b&&(M.b={}),d(M,this)),M},e(re,c);var Q=null;e(Me,c);var je=null;e(Oe,c);var st=null;re.prototype.j=function(){var M=Q;return M||(Q=M=z(re,{0:{name:"NumberFormat",I:"i18n.phonenumbers.NumberFormat"},1:{name:"pattern",required:!0,c:9,type:String},2:{name:"format",required:!0,c:9,type:String},3:{name:"leading_digits_pattern",v:!0,c:9,type:String},4:{name:"national_prefix_formatting_rule",c:9,type:String},6:{name:"national_prefix_optional_when_formatting",c:8,defaultValue:!1,type:Boolean},5:{name:"domestic_carrier_code_formatting_rule",c:9,type:String}})),M},re.j=re.prototype.j,Me.prototype.j=function(){var M=je;return M||(je=M=z(Me,{0:{name:"PhoneNumberDesc",I:"i18n.phonenumbers.PhoneNumberDesc"},2:{name:"national_number_pattern",c:9,type:String},9:{name:"possible_length",v:!0,c:5,type:Number},10:{name:"possible_length_local_only",v:!0,c:5,type:Number},6:{name:"example_number",c:9,type:String}})),M},Me.j=Me.prototype.j,Oe.prototype.j=function(){var M=st;return M||(st=M=z(Oe,{0:{name:"PhoneMetadata",I:"i18n.phonenumbers.PhoneMetadata"},1:{name:"general_desc",c:11,type:Me},2:{name:"fixed_line",c:11,type:Me},3:{name:"mobile",c:11,type:Me},4:{name:"toll_free",c:11,type:Me},5:{name:"premium_rate",c:11,type:Me},6:{name:"shared_cost",c:11,type:Me},7:{name:"personal_number",c:11,type:Me},8:{name:"voip",c:11,type:Me},21:{name:"pager",c:11,type:Me},25:{name:"uan",c:11,type:Me},27:{name:"emergency",c:11,type:Me},28:{name:"voicemail",c:11,type:Me},29:{name:"short_code",c:11,type:Me},30:{name:"standard_rate",c:11,type:Me},31:{name:"carrier_specific",c:11,type:Me},33:{name:"sms_services",c:11,type:Me},24:{name:"no_international_dialling",c:11,type:Me},9:{name:"id",required:!0,c:9,type:String},10:{name:"country_code",c:5,type:Number},11:{name:"international_prefix",c:9,type:String},17:{name:"preferred_international_prefix",c:9,type:String},12:{name:"national_prefix",c:9,type:String},13:{name:"preferred_extn_prefix",c:9,type:String},15:{name:"national_prefix_for_parsing",c:9,type:String},16:{name:"national_prefix_transform_rule",c:9,type:String},18:{name:"same_mobile_and_fixed_line_pattern",c:8,defaultValue:!1,type:Boolean},19:{name:"number_format",v:!0,c:11,type:re},20:{name:"intl_number_format",v:!0,c:11,type:re},22:{name:"main_country_for_code",c:8,defaultValue:!1,type:Boolean},23:{name:"leading_digits",c:9,type:String},26:{name:"leading_zero_possible",c:8,defaultValue:!1,type:Boolean}})),M},Oe.j=Oe.prototype.j,Be.prototype.a=function(M){throw new M.b,Error("Unimplemented")},Be.prototype.b=function(M,V){if(M.a==11||M.a==10)return V instanceof c?V:this.a(M.i.prototype.j(),V);if(M.a==14){if(typeof V=="string"&&Re.test(V)){var ie=Number(V);if(0<ie)return ie}return V}if(!M.h)return V;if(ie=M.i,ie===String){if(typeof V=="number")return String(V)}else if(ie===Number&&typeof V=="string"&&(V==="Infinity"||V==="-Infinity"||V==="NaN"||Re.test(V)))return Number(V);return V};var Re=/^-?[0-9]+$/;e(Pe,Be),Pe.prototype.a=function(M,V){var ie=new M.b;return ie.g=this,ie.a=V,ie.b={},ie},e(Ze,Pe),Ze.prototype.b=function(M,V){return M.a==8?!!V:Be.prototype.b.apply(this,arguments)},Ze.prototype.a=function(M,V){return Ze.M.a.call(this,M,V)};var kt={1:"US AG AI AS BB BM BS CA DM DO GD GU JM KN KY LC MP MS PR SX TC TT VC VG VI".split(" ")},ot={AG:[null,[null,null,"(?:268|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"268(?:4(?:6[0-38]|84)|56[0-2])\\d{4}",null,null,null,"2684601234",null,null,null,[7]],[null,null,"268(?:464|7(?:1[3-9]|2\\d|3[246]|64|[78][0-689]))\\d{4}",null,null,null,"2684641234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"26848[01]\\d{4}",null,null,null,"2684801234",null,null,null,[7]],"AG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"26840[69]\\d{4}",null,null,null,"2684061234",null,null,null,[7]],null,"268",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],AI:[null,[null,null,"(?:264|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"2644(?:6[12]|9[78])\\d{4}",null,null,null,"2644612345",null,null,null,[7]],[null,null,"264(?:235|476|5(?:3[6-9]|8[1-4])|7(?:29|72))\\d{4}",null,null,null,"2642351234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"AI",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"264",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],AS:[null,[null,null,"(?:[58]\\d\\d|684|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"6846(?:22|33|44|55|77|88|9[19])\\d{4}",null,null,null,"6846221234",null,null,null,[7]],[null,null,"684(?:2(?:5[2468]|72)|7(?:3[13]|70))\\d{4}",null,null,null,"6847331234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"AS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"684",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BB:[null,[null,null,"(?:246|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"246(?:2(?:2[78]|7[0-4])|4(?:1[024-6]|2\\d|3[2-9])|5(?:20|[34]\\d|54|7[1-3])|6(?:2\\d|38)|7[35]7|9(?:1[89]|63))\\d{4}",null,null,null,"2464123456",null,null,null,[7]],[null,null,"246(?:2(?:[356]\\d|4[0-57-9]|8[0-79])|45\\d|69[5-7]|8(?:[2-5]\\d|83))\\d{4}",null,null,null,"2462501234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"(?:246976|900[2-9]\\d\\d)\\d{4}",null,null,null,"9002123456",null,null,null,[7]],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"24631\\d{5}",null,null,null,"2463101234",null,null,null,[7]],"BB",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"246",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"246(?:292|367|4(?:1[7-9]|3[01]|44|67)|7(?:36|53))\\d{4}",null,null,null,"2464301234",null,null,null,[7]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BM:[null,[null,null,"(?:441|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"441(?:2(?:02|23|[3479]\\d|61)|[46]\\d\\d|5(?:4\\d|60|89)|824)\\d{4}",null,null,null,"4412345678",null,null,null,[7]],[null,null,"441(?:[37]\\d|5[0-39])\\d{5}",null,null,null,"4413701234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"BM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"441",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BS:[null,[null,null,"(?:242|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"242(?:3(?:02|[236][1-9]|4[0-24-9]|5[0-68]|7[347]|8[0-4]|9[2-467])|461|502|6(?:0[1-4]|12|2[013]|[45]0|7[67]|8[78]|9[89])|7(?:02|88))\\d{4}",null,null,null,"2423456789",null,null,null,[7]],[null,null,"242(?:3(?:5[79]|7[56]|95)|4(?:[23][1-9]|4[1-35-9]|5[1-8]|6[2-8]|7\\d|81)|5(?:2[45]|3[35]|44|5[1-46-9]|65|77)|6[34]6|7(?:27|38)|8(?:0[1-9]|1[02-9]|2\\d|[89]9))\\d{4}",null,null,null,"2423591234",null,null,null,[7]],[null,null,"(?:242300|8(?:00|33|44|55|66|77|88)[2-9]\\d\\d)\\d{4}",null,null,null,"8002123456",null,null,null,[7]],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"BS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"242",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"242225[0-46-9]\\d{3}",null,null,null,"2422250123"],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],CA:[null,[null,null,"(?:[2-8]\\d|90)\\d{8}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",null,null,null,"5062345678",null,null,null,[7]],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",null,null,null,"5062345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"(?:5(?:00|2[12]|33|44|66|77|88)|622)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"600[2-9]\\d{6}",null,null,null,"6002012345"],"CA",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],DM:[null,[null,null,"(?:[58]\\d\\d|767|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"767(?:2(?:55|66)|4(?:2[01]|4[0-25-9])|50[0-4]|70[1-3])\\d{4}",null,null,null,"7674201234",null,null,null,[7]],[null,null,"767(?:2(?:[2-4689]5|7[5-7])|31[5-7]|61[1-7])\\d{4}",null,null,null,"7672251234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"DM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"767",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],DO:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"8(?:[04]9[2-9]\\d\\d|29(?:2(?:[0-59]\\d|6[04-9]|7[0-27]|8[0237-9])|3(?:[0-35-9]\\d|4[7-9])|[45]\\d\\d|6(?:[0-27-9]\\d|[3-5][1-9]|6[0135-8])|7(?:0[013-9]|[1-37]\\d|4[1-35689]|5[1-4689]|6[1-57-9]|8[1-79]|9[1-8])|8(?:0[146-9]|1[0-48]|[248]\\d|3[1-79]|5[01589]|6[013-68]|7[124-8]|9[0-8])|9(?:[0-24]\\d|3[02-46-9]|5[0-79]|60|7[0169]|8[57-9]|9[02-9])))\\d{4}",null,null,null,"8092345678",null,null,null,[7]],[null,null,"8[024]9[2-9]\\d{6}",null,null,null,"8092345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"DO",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"8[024]9",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],GD:[null,[null,null,"(?:473|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"473(?:2(?:3[0-2]|69)|3(?:2[89]|86)|4(?:[06]8|3[5-9]|4[0-49]|5[5-79]|73|90)|63[68]|7(?:58|84)|800|938)\\d{4}",null,null,null,"4732691234",null,null,null,[7]],[null,null,"473(?:4(?:0[2-79]|1[04-9]|2[0-5]|58)|5(?:2[01]|3[3-8])|901)\\d{4}",null,null,null,"4734031234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"GD",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"473",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],GU:[null,[null,null,"(?:[58]\\d\\d|671|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))\\d{4}",null,null,null,"6713001234",null,null,null,[7]],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))\\d{4}",null,null,null,"6713001234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"GU",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"671",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],JM:[null,[null,null,"(?:[58]\\d\\d|658|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:658[2-9]\\d\\d|876(?:5(?:0[12]|1[0-468]|2[35]|63)|6(?:0[1-3579]|1[0237-9]|[23]\\d|40|5[06]|6[2-589]|7[05]|8[04]|9[4-9])|7(?:0[2-689]|[1-6]\\d|8[056]|9[45])|9(?:0[1-8]|1[02378]|[2-8]\\d|9[2-468])))\\d{4}",null,null,null,"8765230123",null,null,null,[7]],[null,null,"876(?:(?:2[14-9]|[348]\\d)\\d|5(?:0[3-9]|[2-57-9]\\d|6[0-24-9])|7(?:0[07]|7\\d|8[1-47-9]|9[0-36-9])|9(?:[01]9|9[0579]))\\d{4}",null,null,null,"8762101234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"JM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"658|876",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],KN:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"869(?:2(?:29|36)|302|4(?:6[015-9]|70))\\d{4}",null,null,null,"8692361234",null,null,null,[7]],[null,null,"869(?:5(?:5[6-8]|6[5-7])|66\\d|76[02-7])\\d{4}",null,null,null,"8697652917",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"KN",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"869",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],KY:[null,[null,null,"(?:345|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"345(?:2(?:22|44)|444|6(?:23|38|40)|7(?:4[35-79]|6[6-9]|77)|8(?:00|1[45]|25|[48]8)|9(?:14|4[035-9]))\\d{4}",null,null,null,"3452221234",null,null,null,[7]],[null,null,"345(?:32[1-9]|5(?:1[67]|2[5-79]|4[6-9]|50|76)|649|9(?:1[67]|2[2-9]|3[689]))\\d{4}",null,null,null,"3453231234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"(?:345976|900[2-9]\\d\\d)\\d{4}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"KY",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"345849\\d{4}",null,null,null,"3458491234"],null,"345",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],LC:[null,[null,null,"(?:[58]\\d\\d|758|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"758(?:4(?:30|5\\d|6[2-9]|8[0-2])|57[0-2]|638)\\d{4}",null,null,null,"7584305678",null,null,null,[7]],[null,null,"758(?:28[4-7]|384|4(?:6[01]|8[4-9])|5(?:1[89]|20|84)|7(?:1[2-9]|2\\d|3[01]))\\d{4}",null,null,null,"7582845678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"LC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"758",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],MP:[null,[null,null,"(?:[58]\\d\\d|(?:67|90)0)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",null,null,null,"6702345678",null,null,null,[7]],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",null,null,null,"6702345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"MP",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"670",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],MS:[null,[null,null,"(?:(?:[58]\\d\\d|900)\\d\\d|66449)\\d{5}",null,null,null,null,null,null,[10],[7]],[null,null,"664491\\d{4}",null,null,null,"6644912345",null,null,null,[7]],[null,null,"66449[2-6]\\d{4}",null,null,null,"6644923456",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"MS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"664",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],PR:[null,[null,null,"(?:[589]\\d\\d|787)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:787|939)[2-9]\\d{6}",null,null,null,"7872345678",null,null,null,[7]],[null,null,"(?:787|939)[2-9]\\d{6}",null,null,null,"7872345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"PR",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"787|939",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],SX:[null,[null,null,"(?:(?:[58]\\d\\d|900)\\d|7215)\\d{6}",null,null,null,null,null,null,[10],[7]],[null,null,"7215(?:4[2-8]|8[239]|9[056])\\d{4}",null,null,null,"7215425678",null,null,null,[7]],[null,null,"7215(?:1[02]|2\\d|5[034679]|8[014-8])\\d{4}",null,null,null,"7215205678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"SX",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"721",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],TC:[null,[null,null,"(?:[58]\\d\\d|649|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"649(?:712|9(?:4\\d|50))\\d{4}",null,null,null,"6497121234",null,null,null,[7]],[null,null,"649(?:2(?:3[129]|4[1-7])|3(?:3[1-389]|4[1-8])|4[34][1-3])\\d{4}",null,null,null,"6492311234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"64971[01]\\d{4}",null,null,null,"6497101234",null,null,null,[7]],"TC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"649",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],TT:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"868(?:2(?:01|[23]\\d)|6(?:0[7-9]|1[02-8]|2[1-9]|[3-69]\\d|7[0-79])|82[124])\\d{4}",null,null,null,"8682211234",null,null,null,[7]],[null,null,"868(?:2(?:6[6-9]|[7-9]\\d)|[37](?:0[1-9]|1[02-9]|[2-9]\\d)|4[6-9]\\d|6(?:20|78|8\\d))\\d{4}",null,null,null,"8682911234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"TT",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"868",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,"868619\\d{4}",null,null,null,"8686191234",null,null,null,[7]]],US:[null,[null,null,"[2-9]\\d{9}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[017]|6[0-279]|78|8[0-2])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-28]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[0179]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}",null,null,null,"2015550123",null,null,null,[7]],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[017]|6[0-279]|78|8[0-2])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-28]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[0179]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}",null,null,null,"2015550123",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"US",1,"011","1",null,null,"1",null,null,1,[[null,"(\\d{3})(\\d{4})","$1-$2",["[2-9]"]],[null,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],null,null,1]],[[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[2-9]"]]],[null,null,null,null,null,null,null,null,null,[-1]],1,null,[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"710[2-9]\\d{6}",null,null,null,"7102123456"],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VC:[null,[null,null,"(?:[58]\\d\\d|784|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"784(?:266|3(?:6[6-9]|7\\d|8[0-24-6])|4(?:38|5[0-36-8]|8[0-8])|5(?:55|7[0-2]|93)|638|784)\\d{4}",null,null,null,"7842661234",null,null,null,[7]],[null,null,"784(?:4(?:3[0-5]|5[45]|89|9[0-8])|5(?:2[6-9]|3[0-4]))\\d{4}",null,null,null,"7844301234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"784",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VG:[null,[null,null,"(?:284|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"284(?:(?:229|774|8(?:52|6[459]))\\d|4(?:22\\d|9(?:[45]\\d|6[0-5])))\\d{3}",null,null,null,"2842291234",null,null,null,[7]],[null,null,"284(?:(?:3(?:0[0-3]|4[0-7]|68|9[34])|54[0-57])\\d|4(?:(?:4[0-6]|68)\\d|9(?:6[6-9]|9\\d)))\\d{3}",null,null,null,"2843001234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"284",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VI:[null,[null,null,"(?:(?:34|90)0|[58]\\d\\d)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"340(?:2(?:01|2[06-8]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-57-9]|27|7\\d)|884|998)\\d{4}",null,null,null,"3406421234",null,null,null,[7]],[null,null,"340(?:2(?:01|2[06-8]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-57-9]|27|7\\d)|884|998)\\d{4}",null,null,null,"3406421234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VI",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"340",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]]};Z.b=function(){return Z.a?Z.a:Z.a=new Z};var ar={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"},mr=RegExp("[++]+"),Xe=RegExp("([0-90-9٠-٩۰-۹])"),Or=/^\(?\$1\)?$/,jr=new Oe;N(jr,11,"NA");var lr=/\[([^\[\]])*\]/g,cr=/\d(?=[^,}][^,}])/g,Vt=RegExp("^[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~]*(\\$\\d[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~]*)+$"),At=/[- ]/;Te.prototype.K=function(){this.C="",n(this.i),n(this.u),n(this.m),this.s=0,this.w="",n(this.b),this.h="",n(this.a),this.l=!0,this.A=this.o=this.F=!1,this.f=[],this.B=!1,this.g!=this.J&&(this.g=te(this,this.D))},Te.prototype.L=function(M){return this.C=ne(this,M)},t("Cleave.AsYouTypeFormatter",Te),t("Cleave.AsYouTypeFormatter.prototype.inputDigit",Te.prototype.L),t("Cleave.AsYouTypeFormatter.prototype.clear",Te.prototype.K)}).call(typeof sn=="object"&&sn?sn:window);var z2=Object.defineProperty,H2=Object.getOwnPropertyDescriptor,jd=(t,e,r,n)=>{for(var i=n>1?void 0:n?H2(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&z2(e,r,i),i};const q2=Il.object({firstName:Il.string().min(1,{message:"First name is required"}),lastName:Il.string().min(1,{message:"Last name is required"}),email:Il.string().email({message:"Invalid email address"}),phone:Il.string().regex(/^(1-)?\d{3}-\d{3}-\d{4}$/,{message:"Invalid phone number"}).transform(t=>t.replace(/-/g,"").replace(/^1/,""))});let Go=class extends Bo{constructor(){super(...arguments),this.params={firstName:"",lastName:"",email:"",phone:""},this.errors=[]}firstUpdated(){this.phoneCleave=new gA(this.phoneInput,{phone:!0,phoneRegionCode:"US",delimiter:"-"})}submit(t){t.preventDefault();try{this.params=q2.parse(this.params)}catch(e){this.errors=e.errors;return}this.dispatchEvent(new CustomEvent("submit",{composed:!0,detail:this.params}))}cancel(){this.dispatchEvent(new CustomEvent("cancel"))}updateField(t,e){this.params={...this.params,[t]:e}}render(){return Id`
43
+ */function zA(t,e,r){return t?e(t):r==null?void 0:r(t)}var fr;(function(t){t.assertEqual=i=>i;function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(fr||(fr={}));var Dp;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Dp||(Dp={}));const vt=fr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Ha=t=>{switch(typeof t){case"undefined":return vt.undefined;case"string":return vt.string;case"number":return isNaN(t)?vt.nan:vt.number;case"boolean":return vt.boolean;case"function":return vt.function;case"bigint":return vt.bigint;case"symbol":return vt.symbol;case"object":return Array.isArray(t)?vt.array:t===null?vt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?vt.promise:typeof Map<"u"&&t instanceof Map?vt.map:typeof Set<"u"&&t instanceof Set?vt.set:typeof Date<"u"&&t instanceof Date?vt.date:vt.object;default:return vt.unknown}},rt=fr.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"]),HA=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class Hn extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}static assert(e){if(!(e instanceof Hn))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,fr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}Hn.create=t=>new Hn(t);const zo=(t,e)=>{let r;switch(t.code){case rt.invalid_type:t.received===vt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case rt.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,fr.jsonStringifyReplacer)}`;break;case rt.unrecognized_keys:r=`Unrecognized key(s) in object: ${fr.joinValues(t.keys,", ")}`;break;case rt.invalid_union:r="Invalid input";break;case rt.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${fr.joinValues(t.options)}`;break;case rt.invalid_enum_value:r=`Invalid enum value. Expected ${fr.joinValues(t.options)}, received '${t.received}'`;break;case rt.invalid_arguments:r="Invalid function arguments";break;case rt.invalid_return_type:r="Invalid function return type";break;case rt.invalid_date:r="Invalid date";break;case rt.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:fr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case rt.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case rt.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case rt.custom:r="Invalid input";break;case rt.invalid_intersection_types:r="Intersection results could not be merged";break;case rt.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case rt.not_finite:r="Number must be finite";break;default:r=e.defaultError,fr.assertNever(t)}return{message:r}};let Iw=zo;function qA(t){Iw=t}function Rd(){return Iw}const Ad=t=>{const{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],s={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(s,{data:e,defaultError:o}).message;return{...i,path:a,message:o}},VA=[];function dt(t,e){const r=Rd(),n=Ad({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===zo?void 0:zo].filter(i=>!!i)});t.common.issues.push(n)}class hn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const i of r){if(i.status==="aborted")return Ht;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const i of r){const a=await i.key,s=await i.value;n.push({key:a,value:s})}return hn.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const i of r){const{key:a,value:s}=i;if(a.status==="aborted"||s.status==="aborted")return Ht;a.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[a.value]=s.value)}return{status:e.value,value:n}}}const Ht=Object.freeze({status:"aborted"}),Ho=t=>({status:"dirty",value:t}),kn=t=>({status:"valid",value:t}),jp=t=>t.status==="aborted",Up=t=>t.status==="dirty",dl=t=>t.status==="valid",fl=t=>typeof Promise<"u"&&t instanceof Promise;function Od(t,e,r,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function xw(t,e,r,n,i){if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,r),r}typeof SuppressedError=="function"&&SuppressedError;var Pt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Pt||(Pt={}));var hl,pl;class Ni{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Rw=(t,e)=>{if(dl(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new Hn(t.common.issues);return this._error=r,this._error}}};function tr(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(s,o)=>{var u,l;const{message:c}=t;return s.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:(u=c??n)!==null&&u!==void 0?u:o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:(l=c??r)!==null&&l!==void 0?l:o.defaultError}},description:i}}class sr{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)}get description(){return this._def.description}_getType(e){return Ha(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Ha(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new hn,ctx:{common:e.parent.common,data:e.data,parsedType:Ha(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(fl(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const i={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ha(e)},a=this._parseSync({data:e,path:i.path,parent:i});return Rw(i,a)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Ha(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(fl(i)?i:Promise.resolve(i));return Rw(n,a)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{const s=e(i),o=()=>a.addIssue({code:rt.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new mi({schema:this,typeName:Ut.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Di.create(this,this._def)}nullable(){return Za.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return gi.create(this,this._def)}promise(){return Zo.create(this,this._def)}or(e){return yl.create([this,e],this._def)}and(e){return bl.create(this,e,this._def)}transform(e){return new mi({...tr(this._def),schema:this,typeName:Ut.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new $l({...tr(this._def),innerType:this,defaultValue:r,typeName:Ut.ZodDefault})}brand(){return new zp({typeName:Ut.ZodBranded,type:this,...tr(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Tl({...tr(this._def),innerType:this,catchValue:r,typeName:Ut.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return Cl.create(this,e)}readonly(){return El.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const WA=/^c[^\s-]{8,}$/i,ZA=/^[0-9a-z]+$/,GA=/^[0-9A-HJKMNP-TV-Z]{26}$/,KA=/^[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,YA=/^[a-z0-9_-]{21}$/i,JA=/^[-+]?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)?)??$/,QA=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,XA="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Fp;const e2=/^(?:(?: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])$/,t2=/^(([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})))$/,r2=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Aw="((\\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])))",n2=new RegExp(`^${Aw}$`);function Ow(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function i2(t){return new RegExp(`^${Ow(t)}$`)}function Pw(t){let e=`${Aw}T${Ow(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function a2(t,e){return!!((e==="v4"||!e)&&e2.test(t)||(e==="v6"||!e)&&t2.test(t))}class vi extends sr{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==vt.string){const a=this._getOrReturnCtx(e);return dt(a,{code:rt.invalid_type,expected:vt.string,received:a.parsedType}),Ht}const n=new hn;let i;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const s=e.data.length>a.value,o=e.data.length<a.value;(s||o)&&(i=this._getOrReturnCtx(e,i),s?dt(i,{code:rt.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&dt(i,{code:rt.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")QA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"email",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Fp||(Fp=new RegExp(XA,"u")),Fp.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"emoji",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")KA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"uuid",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")YA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"nanoid",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")WA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"cuid",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")ZA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"cuid2",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")GA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"ulid",code:rt.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),dt(i,{validation:"url",code:rt.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"regex",code:rt.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Pw(a).test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?n2.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?i2(a).test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?JA.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"duration",code:rt.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?a2(e.data,a.version)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"ip",code:rt.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?r2.test(e.data)||(i=this._getOrReturnCtx(e,i),dt(i,{validation:"base64",code:rt.invalid_string,message:a.message}),n.dirty()):fr.assertNever(a);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:rt.invalid_string,...Pt.errToObj(n)})}_addCheck(e){return new vi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Pt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Pt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Pt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Pt.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Pt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Pt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Pt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Pt.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Pt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Pt.errToObj(e)})}datetime(e){var r,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...Pt.errToObj(e==null?void 0: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:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...Pt.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...Pt.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Pt.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Pt.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Pt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Pt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Pt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Pt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Pt.errToObj(r)})}nonempty(e){return this.min(1,Pt.errToObj(e))}trim(){return new vi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new vi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new vi({...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 isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}vi.create=t=>{var e;return new vi({checks:[],typeName:Ut.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...tr(t)})};function s2(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),s=parseInt(e.toFixed(i).replace(".",""));return a%s/Math.pow(10,i)}class qa extends sr{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)!==vt.number){const a=this._getOrReturnCtx(e);return dt(a,{code:rt.invalid_type,expected:vt.number,received:a.parsedType}),Ht}let n;const i=new hn;for(const a of this._def.checks)a.kind==="int"?fr.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),i.dirty()):a.kind==="multipleOf"?s2(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.not_finite,message:a.message}),i.dirty()):fr.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Pt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Pt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Pt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Pt.toString(r))}setLimit(e,r,n,i){return new qa({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Pt.toString(i)}]})}_addCheck(e){return new qa({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Pt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Pt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Pt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Pt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Pt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Pt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Pt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Pt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Pt.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&fr.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}qa.create=t=>new qa({checks:[],typeName:Ut.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...tr(t)});class Va extends sr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==vt.bigint){const a=this._getOrReturnCtx(e);return dt(a,{code:rt.invalid_type,expected:vt.bigint,received:a.parsedType}),Ht}let n;const i=new hn;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),dt(n,{code:rt.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):fr.assertNever(a);return{status:i.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Pt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Pt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Pt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Pt.toString(r))}setLimit(e,r,n,i){return new Va({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Pt.toString(i)}]})}_addCheck(e){return new Va({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Pt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Pt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Pt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Pt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Pt.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}Va.create=t=>{var e;return new Va({checks:[],typeName:Ut.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...tr(t)})};class vl extends sr{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==vt.boolean){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.boolean,received:n.parsedType}),Ht}return kn(e.data)}}vl.create=t=>new vl({typeName:Ut.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...tr(t)});class Ds extends sr{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==vt.date){const a=this._getOrReturnCtx(e);return dt(a,{code:rt.invalid_type,expected:vt.date,received:a.parsedType}),Ht}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return dt(a,{code:rt.invalid_date}),Ht}const n=new hn;let i;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(i=this._getOrReturnCtx(e,i),dt(i,{code:rt.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):fr.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ds({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Pt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Pt.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Ds.create=t=>new Ds({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Ut.ZodDate,...tr(t)});class Pd extends sr{_parse(e){if(this._getType(e)!==vt.symbol){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.symbol,received:n.parsedType}),Ht}return kn(e.data)}}Pd.create=t=>new Pd({typeName:Ut.ZodSymbol,...tr(t)});class gl extends sr{_parse(e){if(this._getType(e)!==vt.undefined){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.undefined,received:n.parsedType}),Ht}return kn(e.data)}}gl.create=t=>new gl({typeName:Ut.ZodUndefined,...tr(t)});class ml extends sr{_parse(e){if(this._getType(e)!==vt.null){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.null,received:n.parsedType}),Ht}return kn(e.data)}}ml.create=t=>new ml({typeName:Ut.ZodNull,...tr(t)});class qo extends sr{constructor(){super(...arguments),this._any=!0}_parse(e){return kn(e.data)}}qo.create=t=>new qo({typeName:Ut.ZodAny,...tr(t)});class js extends sr{constructor(){super(...arguments),this._unknown=!0}_parse(e){return kn(e.data)}}js.create=t=>new js({typeName:Ut.ZodUnknown,...tr(t)});class la extends sr{_parse(e){const r=this._getOrReturnCtx(e);return dt(r,{code:rt.invalid_type,expected:vt.never,received:r.parsedType}),Ht}}la.create=t=>new la({typeName:Ut.ZodNever,...tr(t)});class Md extends sr{_parse(e){if(this._getType(e)!==vt.undefined){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.void,received:n.parsedType}),Ht}return kn(e.data)}}Md.create=t=>new Md({typeName:Ut.ZodVoid,...tr(t)});class gi extends sr{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==vt.array)return dt(r,{code:rt.invalid_type,expected:vt.array,received:r.parsedType}),Ht;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(s||o)&&(dt(r,{code:s?rt.too_big:rt.too_small,minimum:o?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(dt(r,{code:rt.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(dt(r,{code:rt.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>i.type._parseAsync(new Ni(r,s,r.path,o)))).then(s=>hn.mergeArray(n,s));const a=[...r.data].map((s,o)=>i.type._parseSync(new Ni(r,s,r.path,o)));return hn.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new gi({...this._def,minLength:{value:e,message:Pt.toString(r)}})}max(e,r){return new gi({...this._def,maxLength:{value:e,message:Pt.toString(r)}})}length(e,r){return new gi({...this._def,exactLength:{value:e,message:Pt.toString(r)}})}nonempty(e){return this.min(1,e)}}gi.create=(t,e)=>new gi({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Ut.ZodArray,...tr(e)});function Vo(t){if(t instanceof qr){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=Di.create(Vo(n))}return new qr({...t._def,shape:()=>e})}else return t instanceof gi?new gi({...t._def,type:Vo(t.element)}):t instanceof Di?Di.create(Vo(t.unwrap())):t instanceof Za?Za.create(Vo(t.unwrap())):t instanceof Li?Li.create(t.items.map(e=>Vo(e))):t}class qr extends sr{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=fr.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==vt.object){const l=this._getOrReturnCtx(e);return dt(l,{code:rt.invalid_type,expected:vt.object,received:l.parsedType}),Ht}const{status:n,ctx:i}=this._processInputParams(e),{shape:a,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof la&&this._def.unknownKeys==="strip"))for(const l in i.data)s.includes(l)||o.push(l);const u=[];for(const l of s){const c=a[l],d=i.data[l];u.push({key:{status:"valid",value:l},value:c._parse(new Ni(i,d,i.path,l)),alwaysSet:l in i.data})}if(this._def.catchall instanceof la){const l=this._def.unknownKeys;if(l==="passthrough")for(const c of o)u.push({key:{status:"valid",value:c},value:{status:"valid",value:i.data[c]}});else if(l==="strict")o.length>0&&(dt(i,{code:rt.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const c of o){const d=i.data[c];u.push({key:{status:"valid",value:c},value:l._parse(new Ni(i,d,i.path,c)),alwaysSet:c in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const l=[];for(const c of u){const d=await c.key,f=await c.value;l.push({key:d,value:f,alwaysSet:c.alwaysSet})}return l}).then(l=>hn.mergeObjectSync(n,l)):hn.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return Pt.errToObj,new qr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,s,o;const u=(s=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&s!==void 0?s:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=Pt.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new qr({...this._def,unknownKeys:"strip"})}passthrough(){return new qr({...this._def,unknownKeys:"passthrough"})}extend(e){return new qr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new qr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ut.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new qr({...this._def,catchall:e})}pick(e){const r={};return fr.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new qr({...this._def,shape:()=>r})}omit(e){const r={};return fr.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new qr({...this._def,shape:()=>r})}deepPartial(){return Vo(this)}partial(e){const r={};return fr.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}),new qr({...this._def,shape:()=>r})}required(e){const r={};return fr.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof Di;)a=a._def.innerType;r[n]=a}}),new qr({...this._def,shape:()=>r})}keyof(){return Mw(fr.objectKeys(this.shape))}}qr.create=(t,e)=>new qr({shape:()=>t,unknownKeys:"strip",catchall:la.create(),typeName:Ut.ZodObject,...tr(e)}),qr.strictCreate=(t,e)=>new qr({shape:()=>t,unknownKeys:"strict",catchall:la.create(),typeName:Ut.ZodObject,...tr(e)}),qr.lazycreate=(t,e)=>new qr({shape:t,unknownKeys:"strip",catchall:la.create(),typeName:Ut.ZodObject,...tr(e)});class yl extends sr{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(o=>new Hn(o.ctx.common.issues));return dt(r,{code:rt.invalid_union,unionErrors:s}),Ht}if(r.common.async)return Promise.all(n.map(async a=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let a;const s=[];for(const u of n){const l={...r,common:{...r.common,issues:[]},parent:null},c=u._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(u=>new Hn(u));return dt(r,{code:rt.invalid_union,unionErrors:o}),Ht}}get options(){return this._def.options}}yl.create=(t,e)=>new yl({options:t,typeName:Ut.ZodUnion,...tr(e)});const ca=t=>t instanceof _l?ca(t.schema):t instanceof mi?ca(t.innerType()):t instanceof kl?[t.value]:t instanceof Wa?t.options:t instanceof Sl?fr.objectValues(t.enum):t instanceof $l?ca(t._def.innerType):t instanceof gl?[void 0]:t instanceof ml?[null]:t instanceof Di?[void 0,...ca(t.unwrap())]:t instanceof Za?[null,...ca(t.unwrap())]:t instanceof zp||t instanceof El?ca(t.unwrap()):t instanceof Tl?ca(t._def.innerType):[];class Nd extends sr{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==vt.object)return dt(r,{code:rt.invalid_type,expected:vt.object,received:r.parsedType}),Ht;const n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(dt(r,{code:rt.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Ht)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const a of r){const s=ca(a.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,a)}}return new Nd({typeName:Ut.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...tr(n)})}}function Bp(t,e){const r=Ha(t),n=Ha(e);if(t===e)return{valid:!0,data:t};if(r===vt.object&&n===vt.object){const i=fr.objectKeys(e),a=fr.objectKeys(t).filter(o=>i.indexOf(o)!==-1),s={...t,...e};for(const o of a){const u=Bp(t[o],e[o]);if(!u.valid)return{valid:!1};s[o]=u.data}return{valid:!0,data:s}}else if(r===vt.array&&n===vt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const s=t[a],o=e[a],u=Bp(s,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===vt.date&&n===vt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class bl extends sr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=(a,s)=>{if(jp(a)||jp(s))return Ht;const o=Bp(a.value,s.value);return o.valid?((Up(a)||Up(s))&&r.dirty(),{status:r.value,value:o.data}):(dt(n,{code:rt.invalid_intersection_types}),Ht)};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(([a,s])=>i(a,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}bl.create=(t,e,r)=>new bl({left:t,right:e,typeName:Ut.ZodIntersection,...tr(r)});class Li extends sr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==vt.array)return dt(n,{code:rt.invalid_type,expected:vt.array,received:n.parsedType}),Ht;if(n.data.length<this._def.items.length)return dt(n,{code:rt.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Ht;!this._def.rest&&n.data.length>this._def.items.length&&(dt(n,{code:rt.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const a=[...n.data].map((s,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new Ni(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(a).then(s=>hn.mergeArray(r,s)):hn.mergeArray(r,a)}get items(){return this._def.items}rest(e){return new Li({...this._def,rest:e})}}Li.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Li({items:t,typeName:Ut.ZodTuple,rest:null,...tr(e)})};class wl extends sr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==vt.object)return dt(n,{code:rt.invalid_type,expected:vt.object,received:n.parsedType}),Ht;const i=[],a=this._def.keyType,s=this._def.valueType;for(const o in n.data)i.push({key:a._parse(new Ni(n,o,n.path,o)),value:s._parse(new Ni(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?hn.mergeObjectAsync(r,i):hn.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof sr?new wl({keyType:e,valueType:r,typeName:Ut.ZodRecord,...tr(n)}):new wl({keyType:vi.create(),valueType:e,typeName:Ut.ZodRecord,...tr(r)})}}class Ld extends sr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==vt.map)return dt(n,{code:rt.invalid_type,expected:vt.map,received:n.parsedType}),Ht;const i=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([o,u],l)=>({key:i._parse(new Ni(n,o,n.path,[l,"key"])),value:a._parse(new Ni(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of s){const l=await u.key,c=await u.value;if(l.status==="aborted"||c.status==="aborted")return Ht;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const u of s){const l=u.key,c=u.value;if(l.status==="aborted"||c.status==="aborted")return Ht;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}}Ld.create=(t,e,r)=>new Ld({valueType:e,keyType:t,typeName:Ut.ZodMap,...tr(r)});class Us extends sr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==vt.set)return dt(n,{code:rt.invalid_type,expected:vt.set,received:n.parsedType}),Ht;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(dt(n,{code:rt.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(dt(n,{code:rt.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const a=this._def.valueType;function s(u){const l=new Set;for(const c of u){if(c.status==="aborted")return Ht;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new Ni(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>s(u)):s(o)}min(e,r){return new Us({...this._def,minSize:{value:e,message:Pt.toString(r)}})}max(e,r){return new Us({...this._def,maxSize:{value:e,message:Pt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}Us.create=(t,e)=>new Us({valueType:t,minSize:null,maxSize:null,typeName:Ut.ZodSet,...tr(e)});class Wo extends sr{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==vt.function)return dt(r,{code:rt.invalid_type,expected:vt.function,received:r.parsedType}),Ht;function n(o,u){return Ad({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rd(),zo].filter(l=>!!l),issueData:{code:rt.invalid_arguments,argumentsError:u}})}function i(o,u){return Ad({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rd(),zo].filter(l=>!!l),issueData:{code:rt.invalid_return_type,returnTypeError:u}})}const a={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Zo){const o=this;return kn(async function(...u){const l=new Hn([]),c=await o._def.args.parseAsync(u,a).catch(m=>{throw l.addIssue(n(u,m)),l}),d=await Reflect.apply(s,this,c);return await o._def.returns._def.type.parseAsync(d,a).catch(m=>{throw l.addIssue(i(d,m)),l})})}else{const o=this;return kn(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new Hn([n(u,l.error)]);const c=Reflect.apply(s,this,l.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new Hn([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Wo({...this._def,args:Li.create(e).rest(js.create())})}returns(e){return new Wo({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Wo({args:e||Li.create([]).rest(js.create()),returns:r||js.create(),typeName:Ut.ZodFunction,...tr(n)})}}class _l extends sr{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}_l.create=(t,e)=>new _l({getter:t,typeName:Ut.ZodLazy,...tr(e)});class kl extends sr{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return dt(r,{received:r.data,code:rt.invalid_literal,expected:this._def.value}),Ht}return{status:"valid",value:e.data}}get value(){return this._def.value}}kl.create=(t,e)=>new kl({value:t,typeName:Ut.ZodLiteral,...tr(e)});function Mw(t,e){return new Wa({values:t,typeName:Ut.ZodEnum,...tr(e)})}class Wa extends sr{constructor(){super(...arguments),hl.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return dt(r,{expected:fr.joinValues(n),received:r.parsedType,code:rt.invalid_type}),Ht}if(Od(this,hl)||xw(this,hl,new Set(this._def.values)),!Od(this,hl).has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return dt(r,{received:r.data,code:rt.invalid_enum_value,options:n}),Ht}return kn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return Wa.create(e,{...this._def,...r})}exclude(e,r=this._def){return Wa.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}hl=new WeakMap,Wa.create=Mw;class Sl extends sr{constructor(){super(...arguments),pl.set(this,void 0)}_parse(e){const r=fr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==vt.string&&n.parsedType!==vt.number){const i=fr.objectValues(r);return dt(n,{expected:fr.joinValues(i),received:n.parsedType,code:rt.invalid_type}),Ht}if(Od(this,pl)||xw(this,pl,new Set(fr.getValidEnumValues(this._def.values))),!Od(this,pl).has(e.data)){const i=fr.objectValues(r);return dt(n,{received:n.data,code:rt.invalid_enum_value,options:i}),Ht}return kn(e.data)}get enum(){return this._def.values}}pl=new WeakMap,Sl.create=(t,e)=>new Sl({values:t,typeName:Ut.ZodNativeEnum,...tr(e)});class Zo extends sr{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==vt.promise&&r.common.async===!1)return dt(r,{code:rt.invalid_type,expected:vt.promise,received:r.parsedType}),Ht;const n=r.parsedType===vt.promise?r.data:Promise.resolve(r.data);return kn(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Zo.create=(t,e)=>new Zo({type:t,typeName:Ut.ZodPromise,...tr(e)});class mi extends sr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ut.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:s=>{dt(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const s=i.transform(n.data,a);if(n.common.async)return Promise.resolve(s).then(async o=>{if(r.value==="aborted")return Ht;const u=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return u.status==="aborted"?Ht:u.status==="dirty"||r.value==="dirty"?Ho(u.value):u});{if(r.value==="aborted")return Ht;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?Ht:o.status==="dirty"||r.value==="dirty"?Ho(o.value):o}}if(i.type==="refinement"){const s=o=>{const u=i.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Ht:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?Ht:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!dl(s))return s;const o=i.transform(s.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>dl(s)?Promise.resolve(i.transform(s.value,a)).then(o=>({status:r.value,value:o})):s);fr.assertNever(i)}}mi.create=(t,e,r)=>new mi({schema:t,typeName:Ut.ZodEffects,effect:e,...tr(r)}),mi.createWithPreprocess=(t,e,r)=>new mi({schema:e,effect:{type:"preprocess",transform:t},typeName:Ut.ZodEffects,...tr(r)});class Di extends sr{_parse(e){return this._getType(e)===vt.undefined?kn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Di.create=(t,e)=>new Di({innerType:t,typeName:Ut.ZodOptional,...tr(e)});class Za extends sr{_parse(e){return this._getType(e)===vt.null?kn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Za.create=(t,e)=>new Za({innerType:t,typeName:Ut.ZodNullable,...tr(e)});class $l extends sr{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===vt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}$l.create=(t,e)=>new $l({innerType:t,typeName:Ut.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...tr(e)});class Tl extends sr{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return fl(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Hn(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Hn(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Tl.create=(t,e)=>new Tl({innerType:t,typeName:Ut.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...tr(e)});class Dd extends sr{_parse(e){if(this._getType(e)!==vt.nan){const n=this._getOrReturnCtx(e);return dt(n,{code:rt.invalid_type,expected:vt.nan,received:n.parsedType}),Ht}return{status:"valid",value:e.data}}}Dd.create=t=>new Dd({typeName:Ut.ZodNaN,...tr(t)});const o2=Symbol("zod_brand");class zp extends sr{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class Cl extends sr{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?Ht:a.status==="dirty"?(r.dirty(),Ho(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Ht:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new Cl({in:e,out:r,typeName:Ut.ZodPipeline})}}class El extends sr{_parse(e){const r=this._def.innerType._parse(e),n=i=>(dl(i)&&(i.value=Object.freeze(i.value)),i);return fl(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}}El.create=(t,e)=>new El({innerType:t,typeName:Ut.ZodReadonly,...tr(e)});function Nw(t,e={},r){return t?qo.create().superRefine((n,i)=>{var a,s;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(s=(a=o.fatal)!==null&&a!==void 0?a:r)!==null&&s!==void 0?s:!0,l=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...l,fatal:u})}}):qo.create()}const u2={object:qr.lazycreate};var Ut;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Ut||(Ut={}));const l2=(t,e={message:`Input not instance of ${t.name}`})=>Nw(r=>r instanceof t,e),Lw=vi.create,Dw=qa.create,c2=Dd.create,d2=Va.create,jw=vl.create,f2=Ds.create,h2=Pd.create,p2=gl.create,v2=ml.create,g2=qo.create,m2=js.create,y2=la.create,b2=Md.create,w2=gi.create,_2=qr.create,k2=qr.strictCreate,S2=yl.create,$2=Nd.create,T2=bl.create,C2=Li.create,E2=wl.create,I2=Ld.create,x2=Us.create,R2=Wo.create,A2=_l.create,O2=kl.create,P2=Wa.create,M2=Sl.create,N2=Zo.create,Uw=mi.create,L2=Di.create,D2=Za.create,j2=mi.createWithPreprocess,U2=Cl.create;var Il=Object.freeze({__proto__:null,defaultErrorMap:zo,setErrorMap:qA,getErrorMap:Rd,makeIssue:Ad,EMPTY_PATH:VA,addIssueToContext:dt,ParseStatus:hn,INVALID:Ht,DIRTY:Ho,OK:kn,isAborted:jp,isDirty:Up,isValid:dl,isAsync:fl,get util(){return fr},get objectUtil(){return Dp},ZodParsedType:vt,getParsedType:Ha,ZodType:sr,datetimeRegex:Pw,ZodString:vi,ZodNumber:qa,ZodBigInt:Va,ZodBoolean:vl,ZodDate:Ds,ZodSymbol:Pd,ZodUndefined:gl,ZodNull:ml,ZodAny:qo,ZodUnknown:js,ZodNever:la,ZodVoid:Md,ZodArray:gi,ZodObject:qr,ZodUnion:yl,ZodDiscriminatedUnion:Nd,ZodIntersection:bl,ZodTuple:Li,ZodRecord:wl,ZodMap:Ld,ZodSet:Us,ZodFunction:Wo,ZodLazy:_l,ZodLiteral:kl,ZodEnum:Wa,ZodNativeEnum:Sl,ZodPromise:Zo,ZodEffects:mi,ZodTransformer:mi,ZodOptional:Di,ZodNullable:Za,ZodDefault:$l,ZodCatch:Tl,ZodNaN:Dd,BRAND:o2,ZodBranded:zp,ZodPipeline:Cl,ZodReadonly:El,custom:Nw,Schema:sr,ZodSchema:sr,late:u2,get ZodFirstPartyTypeKind(){return Ut},coerce:{string:t=>vi.create({...t,coerce:!0}),number:t=>qa.create({...t,coerce:!0}),boolean:t=>vl.create({...t,coerce:!0}),bigint:t=>Va.create({...t,coerce:!0}),date:t=>Ds.create({...t,coerce:!0})},any:g2,array:w2,bigint:d2,boolean:jw,date:f2,discriminatedUnion:$2,effect:Uw,enum:P2,function:R2,instanceof:l2,intersection:T2,lazy:A2,literal:O2,map:I2,nan:c2,nativeEnum:M2,never:y2,null:v2,nullable:D2,number:Dw,object:_2,oboolean:()=>jw().optional(),onumber:()=>Dw().optional(),optional:L2,ostring:()=>Lw().optional(),pipeline:U2,preprocess:j2,promise:N2,record:E2,set:x2,strictObject:k2,string:Lw,symbol:h2,transformer:Uw,tuple:C2,undefined:p2,union:S2,unknown:m2,void:b2,NEVER:Ht,ZodIssueCode:rt,quotelessJson:HA,ZodError:Hn});const Fw=yA`*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: \"\"}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,\"Apple Color Emoji\",\"Segoe UI Emoji\",Segoe UI Symbol,\"Noto Color Emoji\";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.static{position:static}.relative{position:relative}.my-4{margin-top:1rem;margin-bottom:1rem}.mb-4{margin-bottom:1rem}.mt-4{margin-top:1rem}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rounded{border-radius:.25rem}.border{border-width:1px}.border-red-400{--tw-border-opacity: 1;border-color:rgb(248 113 113 / var(--tw-border-opacity))}.bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity))}.px-4{padding-left:1rem;padding-right:1rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.text-red-700{--tw-text-opacity: 1;color:rgb(185 28 28 / var(--tw-text-opacity))}.shadow{--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}input{width:100%;-webkit-appearance:none;-moz-appearance:none;appearance:none;border-radius:.25rem;border-width:1px;padding:.5rem .75rem;line-height:1.25;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity));--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}label{margin-bottom:.5rem;display:block;font-size:.875rem;line-height:1.25rem;font-weight:700;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.btn-primary{border-radius:.25rem;padding:.5rem 1rem;font-weight:700;--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.btn-primary:hover{opacity:.95}.btn-primary:disabled{pointer-events:none;opacity:.5}.btn-primary{background-color:var(--iai-chat-i-button-bg);color:var(--iai-chat-i-button-fg)}.btn-secondary{padding:.5rem 1rem;font-weight:700;--tw-text-opacity: 1;color:rgb(55 65 81 / var(--tw-text-opacity))}.btn-secondary:hover{opacity:.95}.btn-secondary:disabled{pointer-events:none;opacity:.5}`;var sn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function F2(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function B2(t){if(t.__esModule)return t;var e=t.default;if(typeof e=="function"){var r=function n(){return this instanceof n?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}(function(){function t(M,V){var ie=M.split("."),Be=ce;ie[0]in Be||!Be.execScript||Be.execScript("var "+ie[0]);for(var lt;ie.length&&(lt=ie.shift());)ie.length||V===void 0?Be=Be[lt]?Be[lt]:Be[lt]={}:Be[lt]=V}function e(M,V){function ie(){}ie.prototype=V.prototype,M.M=V.prototype,M.prototype=new ie,M.prototype.constructor=M,M.N=function(Be,lt,yt){for(var Bt=Array(arguments.length-2),er=2;er<arguments.length;er++)Bt[er-2]=arguments[er];return V.prototype[lt].apply(Be,Bt)}}function r(M,V){M!=null&&this.a.apply(this,arguments)}function n(M){M.b=""}function i(M,V){M.sort(V||a)}function a(M,V){return M>V?1:M<V?-1:0}function s(M){var V,ie=[],Be=0;for(V in M)ie[Be++]=M[V];return ie}function o(M,V){this.b=M,this.a={};for(var ie=0;ie<V.length;ie++){var Be=V[ie];this.a[Be.b]=Be}}function u(M){return M=s(M.a),i(M,function(V,ie){return V.b-ie.b}),M}function l(M,V){switch(this.b=M,this.g=!!V.v,this.a=V.c,this.i=V.type,this.h=!1,this.a){case be:case ht:case Ve:case Kt:case Rt:case Ue:case Ge:this.h=!0}this.f=V.defaultValue}function c(){this.a={},this.f=this.j().a,this.b=this.g=null}function d(M,V){for(var ie=u(M.j()),Be=0;Be<ie.length;Be++){var lt=ie[Be],yt=lt.b;if(V.a[yt]!=null){M.b&&delete M.b[lt.b];var Bt=lt.a==11||lt.a==10;if(lt.g)for(var lt=f(V,yt)||[],er=0;er<lt.length;er++){var Ee=M,Ne=yt,pe=Bt?lt[er].clone():lt[er];Ee.a[Ne]||(Ee.a[Ne]=[]),Ee.a[Ne].push(pe),Ee.b&&delete Ee.b[Ne]}else lt=f(V,yt),Bt?(Bt=f(M,yt))?d(Bt,lt):N(M,yt,lt.clone()):N(M,yt,lt)}}}function f(M,V){var ie=M.a[V];if(ie==null)return null;if(M.g){if(!(V in M.b)){var Be=M.g,lt=M.f[V];if(ie!=null)if(lt.g){for(var yt=[],Bt=0;Bt<ie.length;Bt++)yt[Bt]=Be.b(lt,ie[Bt]);ie=yt}else ie=Be.b(lt,ie);return M.b[V]=ie}return M.b[V]}return ie}function m(M,V,ie){var Be=f(M,V);return M.f[V].g?Be[ie||0]:Be}function k(M,V){var ie;if(M.a[V]!=null)ie=m(M,V,void 0);else e:{if(ie=M.f[V],ie.f===void 0){var Be=ie.i;if(Be===Boolean)ie.f=!1;else if(Be===Number)ie.f=0;else{if(Be!==String){ie=new Be;break e}ie.f=ie.h?"0":""}}ie=ie.f}return ie}function L(M,V){return M.f[V].g?M.a[V]!=null?M.a[V].length:0:M.a[V]!=null?1:0}function N(M,V,ie){M.a[V]=ie,M.b&&(M.b[V]=ie)}function z(M,V){var ie,Be=[];for(ie in V)ie!=0&&Be.push(new l(ie,V[ie]));return new o(M,Be)}function re(){c.call(this)}function Me(){c.call(this)}function Oe(){c.call(this)}function Fe(){}function Pe(){}function Ze(){}function Z(){this.a={}}function Ie(M){return M.length==0||Or.test(M)}function _e(M,V){if(V==null)return null;V=V.toUpperCase();var ie=M.a[V];if(ie==null){if(ie=ot[V],ie==null)return null;ie=new Ze().a(Oe.j(),ie),M.a[V]=ie}return ie}function se(M){return M=kt[M],M==null?"ZZ":M[0]}function Te(M){this.H=RegExp(" "),this.C="",this.m=new r,this.w="",this.i=new r,this.u=new r,this.l=!0,this.A=this.o=this.F=!1,this.G=Z.b(),this.s=0,this.b=new r,this.B=!1,this.h="",this.a=new r,this.f=[],this.D=M,this.J=this.g=te(this,this.D)}function te(M,V){var ie;if(V!=null&&isNaN(V)&&V.toUpperCase()in ot){if(ie=_e(M.G,V),ie==null)throw Error("Invalid region code: "+V);ie=k(ie,10)}else ie=0;return ie=_e(M.G,se(ie)),ie??jr}function oe(M){for(var V=M.f.length,ie=0;ie<V;++ie){var Be=M.f[ie],lt=k(Be,1);if(M.w==lt)return!1;var yt;yt=M;var Bt=Be,er=k(Bt,1);if(er.indexOf("|")!=-1)yt=!1;else{er=er.replace(lr,"\\d"),er=er.replace(cr,"\\d"),n(yt.m);var Ee;Ee=yt;var Bt=k(Bt,2),Ne="999999999999999".match(er)[0];Ne.length<Ee.a.b.length?Ee="":(Ee=Ne.replace(new RegExp(er,"g"),Bt),Ee=Ee.replace(RegExp("9","g")," ")),0<Ee.length?(yt.m.a(Ee),yt=!0):yt=!1}if(yt)return M.w=lt,M.B=At.test(m(Be,4)),M.s=0,!0}return M.l=!1}function q(M,V){for(var ie=[],Be=V.length-3,lt=M.f.length,yt=0;yt<lt;++yt){var Bt=M.f[yt];L(Bt,3)==0?ie.push(M.f[yt]):(Bt=m(Bt,3,Math.min(Be,L(Bt,3)-1)),V.search(Bt)==0&&ie.push(M.f[yt]))}M.f=ie}function ne(M,V){M.i.a(V);var ie=V;if(Xe.test(ie)||M.i.b.length==1&&mr.test(ie)){var Be,ie=V;ie=="+"?(Be=ie,M.u.a(ie)):(Be=ar[ie],M.u.a(Be),M.a.a(Be)),V=Be}else M.l=!1,M.F=!0;if(!M.l){if(!M.F){if(Ct(M)){if(tt(M))return Se(M)}else if(0<M.h.length&&(ie=M.a.toString(),n(M.a),M.a.a(M.h),M.a.a(ie),ie=M.b.toString(),Be=ie.lastIndexOf(M.h),n(M.b),M.b.a(ie.substring(0,Be))),M.h!=Qe(M))return M.b.a(" "),Se(M)}return M.i.toString()}switch(M.u.b.length){case 0:case 1:case 2:return M.i.toString();case 3:if(!Ct(M))return M.h=Qe(M),ke(M);M.A=!0;default:return M.A?(tt(M)&&(M.A=!1),M.b.toString()+M.a.toString()):0<M.f.length?(ie=De(M,V),Be=H(M),0<Be.length?Be:(q(M,M.a.toString()),oe(M)?P(M):M.l?ye(M,ie):M.i.toString())):ke(M)}}function Se(M){return M.l=!0,M.A=!1,M.f=[],M.s=0,n(M.m),M.w="",ke(M)}function H(M){for(var V=M.a.toString(),ie=M.f.length,Be=0;Be<ie;++Be){var lt=M.f[Be],yt=k(lt,1);if(new RegExp("^(?:"+yt+")$").test(V))return M.B=At.test(m(lt,4)),V=V.replace(new RegExp(yt,"g"),m(lt,2)),ye(M,V)}return""}function ye(M,V){var ie=M.b.b.length;return M.B&&0<ie&&M.b.toString().charAt(ie-1)!=" "?M.b+" "+V:M.b+V}function ke(M){var V=M.a.toString();if(3<=V.length){for(var ie=M.o&&M.h.length==0&&0<L(M.g,20)?f(M.g,20)||[]:f(M.g,19)||[],Be=ie.length,lt=0;lt<Be;++lt){var yt=ie[lt];0<M.h.length&&Ie(k(yt,4))&&!m(yt,6)&&yt.a[5]==null||(M.h.length!=0||M.o||Ie(k(yt,4))||m(yt,6))&&Vt.test(k(yt,2))&&M.f.push(yt)}return q(M,V),V=H(M),0<V.length?V:oe(M)?P(M):M.i.toString()}return ye(M,V)}function P(M){var V=M.a.toString(),ie=V.length;if(0<ie){for(var Be="",lt=0;lt<ie;lt++)Be=De(M,V.charAt(lt));return M.l?ye(M,Be):M.i.toString()}return M.b.toString()}function Qe(M){var V,ie=M.a.toString(),Be=0;return m(M.g,10)!=1?V=!1:(V=M.a.toString(),V=V.charAt(0)=="1"&&V.charAt(1)!="0"&&V.charAt(1)!="1"),V?(Be=1,M.b.a("1").a(" "),M.o=!0):M.g.a[15]!=null&&(V=new RegExp("^(?:"+m(M.g,15)+")"),V=ie.match(V),V!=null&&V[0]!=null&&0<V[0].length&&(M.o=!0,Be=V[0].length,M.b.a(ie.substring(0,Be)))),n(M.a),M.a.a(ie.substring(Be)),ie.substring(0,Be)}function Ct(M){var V=M.u.toString(),ie=new RegExp("^(?:\\+|"+m(M.g,11)+")"),ie=V.match(ie);return ie!=null&&ie[0]!=null&&0<ie[0].length&&(M.o=!0,ie=ie[0].length,n(M.a),M.a.a(V.substring(ie)),n(M.b),M.b.a(V.substring(0,ie)),V.charAt(0)!="+"&&M.b.a(" "),!0)}function tt(M){if(M.a.b.length==0)return!1;var V,ie=new r;e:{if(V=M.a.toString(),V.length!=0&&V.charAt(0)!="0"){for(var Be,lt=V.length,yt=1;3>=yt&&yt<=lt;++yt)if(Be=parseInt(V.substring(0,yt),10),Be in kt){ie.a(V.substring(yt)),V=Be;break e}}V=0}return V!=0&&(n(M.a),M.a.a(ie.toString()),ie=se(V),ie=="001"?M.g=_e(M.G,""+V):ie!=M.D&&(M.g=te(M,ie)),M.b.a(""+V).a(" "),M.h="",!0)}function De(M,V){var ie=M.m.toString();if(0<=ie.substring(M.s).search(M.H)){var Be=ie.search(M.H),ie=ie.replace(M.H,V);return n(M.m),M.m.a(ie),M.s=Be,ie.substring(0,M.s+1)}return M.f.length==1&&(M.l=!1),M.w="",M.i.toString()}var ce=this;r.prototype.b="",r.prototype.set=function(M){this.b=""+M},r.prototype.a=function(M,V,ie){if(this.b+=String(M),V!=null)for(var Be=1;Be<arguments.length;Be++)this.b+=arguments[Be];return this},r.prototype.toString=function(){return this.b};var Ge=1,Ue=2,be=3,ht=4,Ve=6,Kt=16,Rt=18;c.prototype.set=function(M,V){N(this,M.b,V)},c.prototype.clone=function(){var M=new this.constructor;return M!=this&&(M.a={},M.b&&(M.b={}),d(M,this)),M},e(re,c);var Q=null;e(Me,c);var je=null;e(Oe,c);var st=null;re.prototype.j=function(){var M=Q;return M||(Q=M=z(re,{0:{name:"NumberFormat",I:"i18n.phonenumbers.NumberFormat"},1:{name:"pattern",required:!0,c:9,type:String},2:{name:"format",required:!0,c:9,type:String},3:{name:"leading_digits_pattern",v:!0,c:9,type:String},4:{name:"national_prefix_formatting_rule",c:9,type:String},6:{name:"national_prefix_optional_when_formatting",c:8,defaultValue:!1,type:Boolean},5:{name:"domestic_carrier_code_formatting_rule",c:9,type:String}})),M},re.j=re.prototype.j,Me.prototype.j=function(){var M=je;return M||(je=M=z(Me,{0:{name:"PhoneNumberDesc",I:"i18n.phonenumbers.PhoneNumberDesc"},2:{name:"national_number_pattern",c:9,type:String},9:{name:"possible_length",v:!0,c:5,type:Number},10:{name:"possible_length_local_only",v:!0,c:5,type:Number},6:{name:"example_number",c:9,type:String}})),M},Me.j=Me.prototype.j,Oe.prototype.j=function(){var M=st;return M||(st=M=z(Oe,{0:{name:"PhoneMetadata",I:"i18n.phonenumbers.PhoneMetadata"},1:{name:"general_desc",c:11,type:Me},2:{name:"fixed_line",c:11,type:Me},3:{name:"mobile",c:11,type:Me},4:{name:"toll_free",c:11,type:Me},5:{name:"premium_rate",c:11,type:Me},6:{name:"shared_cost",c:11,type:Me},7:{name:"personal_number",c:11,type:Me},8:{name:"voip",c:11,type:Me},21:{name:"pager",c:11,type:Me},25:{name:"uan",c:11,type:Me},27:{name:"emergency",c:11,type:Me},28:{name:"voicemail",c:11,type:Me},29:{name:"short_code",c:11,type:Me},30:{name:"standard_rate",c:11,type:Me},31:{name:"carrier_specific",c:11,type:Me},33:{name:"sms_services",c:11,type:Me},24:{name:"no_international_dialling",c:11,type:Me},9:{name:"id",required:!0,c:9,type:String},10:{name:"country_code",c:5,type:Number},11:{name:"international_prefix",c:9,type:String},17:{name:"preferred_international_prefix",c:9,type:String},12:{name:"national_prefix",c:9,type:String},13:{name:"preferred_extn_prefix",c:9,type:String},15:{name:"national_prefix_for_parsing",c:9,type:String},16:{name:"national_prefix_transform_rule",c:9,type:String},18:{name:"same_mobile_and_fixed_line_pattern",c:8,defaultValue:!1,type:Boolean},19:{name:"number_format",v:!0,c:11,type:re},20:{name:"intl_number_format",v:!0,c:11,type:re},22:{name:"main_country_for_code",c:8,defaultValue:!1,type:Boolean},23:{name:"leading_digits",c:9,type:String},26:{name:"leading_zero_possible",c:8,defaultValue:!1,type:Boolean}})),M},Oe.j=Oe.prototype.j,Fe.prototype.a=function(M){throw new M.b,Error("Unimplemented")},Fe.prototype.b=function(M,V){if(M.a==11||M.a==10)return V instanceof c?V:this.a(M.i.prototype.j(),V);if(M.a==14){if(typeof V=="string"&&Re.test(V)){var ie=Number(V);if(0<ie)return ie}return V}if(!M.h)return V;if(ie=M.i,ie===String){if(typeof V=="number")return String(V)}else if(ie===Number&&typeof V=="string"&&(V==="Infinity"||V==="-Infinity"||V==="NaN"||Re.test(V)))return Number(V);return V};var Re=/^-?[0-9]+$/;e(Pe,Fe),Pe.prototype.a=function(M,V){var ie=new M.b;return ie.g=this,ie.a=V,ie.b={},ie},e(Ze,Pe),Ze.prototype.b=function(M,V){return M.a==8?!!V:Fe.prototype.b.apply(this,arguments)},Ze.prototype.a=function(M,V){return Ze.M.a.call(this,M,V)};var kt={1:"US AG AI AS BB BM BS CA DM DO GD GU JM KN KY LC MP MS PR SX TC TT VC VG VI".split(" ")},ot={AG:[null,[null,null,"(?:268|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"268(?:4(?:6[0-38]|84)|56[0-2])\\d{4}",null,null,null,"2684601234",null,null,null,[7]],[null,null,"268(?:464|7(?:1[3-9]|2\\d|3[246]|64|[78][0-689]))\\d{4}",null,null,null,"2684641234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"26848[01]\\d{4}",null,null,null,"2684801234",null,null,null,[7]],"AG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"26840[69]\\d{4}",null,null,null,"2684061234",null,null,null,[7]],null,"268",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],AI:[null,[null,null,"(?:264|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"2644(?:6[12]|9[78])\\d{4}",null,null,null,"2644612345",null,null,null,[7]],[null,null,"264(?:235|476|5(?:3[6-9]|8[1-4])|7(?:29|72))\\d{4}",null,null,null,"2642351234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"AI",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"264",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],AS:[null,[null,null,"(?:[58]\\d\\d|684|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"6846(?:22|33|44|55|77|88|9[19])\\d{4}",null,null,null,"6846221234",null,null,null,[7]],[null,null,"684(?:2(?:5[2468]|72)|7(?:3[13]|70))\\d{4}",null,null,null,"6847331234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"AS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"684",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BB:[null,[null,null,"(?:246|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"246(?:2(?:2[78]|7[0-4])|4(?:1[024-6]|2\\d|3[2-9])|5(?:20|[34]\\d|54|7[1-3])|6(?:2\\d|38)|7[35]7|9(?:1[89]|63))\\d{4}",null,null,null,"2464123456",null,null,null,[7]],[null,null,"246(?:2(?:[356]\\d|4[0-57-9]|8[0-79])|45\\d|69[5-7]|8(?:[2-5]\\d|83))\\d{4}",null,null,null,"2462501234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"(?:246976|900[2-9]\\d\\d)\\d{4}",null,null,null,"9002123456",null,null,null,[7]],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"24631\\d{5}",null,null,null,"2463101234",null,null,null,[7]],"BB",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"246",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"246(?:292|367|4(?:1[7-9]|3[01]|44|67)|7(?:36|53))\\d{4}",null,null,null,"2464301234",null,null,null,[7]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BM:[null,[null,null,"(?:441|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"441(?:2(?:02|23|[3479]\\d|61)|[46]\\d\\d|5(?:4\\d|60|89)|824)\\d{4}",null,null,null,"4412345678",null,null,null,[7]],[null,null,"441(?:[37]\\d|5[0-39])\\d{5}",null,null,null,"4413701234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"BM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"441",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],BS:[null,[null,null,"(?:242|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"242(?:3(?:02|[236][1-9]|4[0-24-9]|5[0-68]|7[347]|8[0-4]|9[2-467])|461|502|6(?:0[1-4]|12|2[013]|[45]0|7[67]|8[78]|9[89])|7(?:02|88))\\d{4}",null,null,null,"2423456789",null,null,null,[7]],[null,null,"242(?:3(?:5[79]|7[56]|95)|4(?:[23][1-9]|4[1-35-9]|5[1-8]|6[2-8]|7\\d|81)|5(?:2[45]|3[35]|44|5[1-46-9]|65|77)|6[34]6|7(?:27|38)|8(?:0[1-9]|1[02-9]|2\\d|[89]9))\\d{4}",null,null,null,"2423591234",null,null,null,[7]],[null,null,"(?:242300|8(?:00|33|44|55|66|77|88)[2-9]\\d\\d)\\d{4}",null,null,null,"8002123456",null,null,null,[7]],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"BS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"242",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"242225[0-46-9]\\d{3}",null,null,null,"2422250123"],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],CA:[null,[null,null,"(?:[2-8]\\d|90)\\d{8}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",null,null,null,"5062345678",null,null,null,[7]],[null,null,"(?:2(?:04|[23]6|[48]9|50)|3(?:06|43|65)|4(?:03|1[68]|3[178]|50)|5(?:06|1[49]|48|79|8[17])|6(?:04|13|39|47)|7(?:0[59]|78|8[02])|8(?:[06]7|19|25|73)|90[25])[2-9]\\d{6}",null,null,null,"5062345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"(?:5(?:00|2[12]|33|44|66|77|88)|622)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"600[2-9]\\d{6}",null,null,null,"6002012345"],"CA",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],DM:[null,[null,null,"(?:[58]\\d\\d|767|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"767(?:2(?:55|66)|4(?:2[01]|4[0-25-9])|50[0-4]|70[1-3])\\d{4}",null,null,null,"7674201234",null,null,null,[7]],[null,null,"767(?:2(?:[2-4689]5|7[5-7])|31[5-7]|61[1-7])\\d{4}",null,null,null,"7672251234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"DM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"767",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],DO:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"8(?:[04]9[2-9]\\d\\d|29(?:2(?:[0-59]\\d|6[04-9]|7[0-27]|8[0237-9])|3(?:[0-35-9]\\d|4[7-9])|[45]\\d\\d|6(?:[0-27-9]\\d|[3-5][1-9]|6[0135-8])|7(?:0[013-9]|[1-37]\\d|4[1-35689]|5[1-4689]|6[1-57-9]|8[1-79]|9[1-8])|8(?:0[146-9]|1[0-48]|[248]\\d|3[1-79]|5[01589]|6[013-68]|7[124-8]|9[0-8])|9(?:[0-24]\\d|3[02-46-9]|5[0-79]|60|7[0169]|8[57-9]|9[02-9])))\\d{4}",null,null,null,"8092345678",null,null,null,[7]],[null,null,"8[024]9[2-9]\\d{6}",null,null,null,"8092345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"DO",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"8[024]9",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],GD:[null,[null,null,"(?:473|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"473(?:2(?:3[0-2]|69)|3(?:2[89]|86)|4(?:[06]8|3[5-9]|4[0-49]|5[5-79]|73|90)|63[68]|7(?:58|84)|800|938)\\d{4}",null,null,null,"4732691234",null,null,null,[7]],[null,null,"473(?:4(?:0[2-79]|1[04-9]|2[0-5]|58)|5(?:2[01]|3[3-8])|901)\\d{4}",null,null,null,"4734031234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"GD",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"473",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],GU:[null,[null,null,"(?:[58]\\d\\d|671|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))\\d{4}",null,null,null,"6713001234",null,null,null,[7]],[null,null,"671(?:3(?:00|3[39]|4[349]|55|6[26])|4(?:00|56|7[1-9]|8[0236-9])|5(?:55|6[2-5]|88)|6(?:3[2-578]|4[24-9]|5[34]|78|8[235-9])|7(?:[0479]7|2[0167]|3[45]|8[7-9])|8(?:[2-57-9]8|6[48])|9(?:2[29]|6[79]|7[1279]|8[7-9]|9[78]))\\d{4}",null,null,null,"6713001234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"GU",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"671",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],JM:[null,[null,null,"(?:[58]\\d\\d|658|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:658[2-9]\\d\\d|876(?:5(?:0[12]|1[0-468]|2[35]|63)|6(?:0[1-3579]|1[0237-9]|[23]\\d|40|5[06]|6[2-589]|7[05]|8[04]|9[4-9])|7(?:0[2-689]|[1-6]\\d|8[056]|9[45])|9(?:0[1-8]|1[02378]|[2-8]\\d|9[2-468])))\\d{4}",null,null,null,"8765230123",null,null,null,[7]],[null,null,"876(?:(?:2[14-9]|[348]\\d)\\d|5(?:0[3-9]|[2-57-9]\\d|6[0-24-9])|7(?:0[07]|7\\d|8[1-47-9]|9[0-36-9])|9(?:[01]9|9[0579]))\\d{4}",null,null,null,"8762101234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"JM",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"658|876",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],KN:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"869(?:2(?:29|36)|302|4(?:6[015-9]|70))\\d{4}",null,null,null,"8692361234",null,null,null,[7]],[null,null,"869(?:5(?:5[6-8]|6[5-7])|66\\d|76[02-7])\\d{4}",null,null,null,"8697652917",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"KN",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"869",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],KY:[null,[null,null,"(?:345|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"345(?:2(?:22|44)|444|6(?:23|38|40)|7(?:4[35-79]|6[6-9]|77)|8(?:00|1[45]|25|[48]8)|9(?:14|4[035-9]))\\d{4}",null,null,null,"3452221234",null,null,null,[7]],[null,null,"345(?:32[1-9]|5(?:1[67]|2[5-79]|4[6-9]|50|76)|649|9(?:1[67]|2[2-9]|3[689]))\\d{4}",null,null,null,"3453231234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"(?:345976|900[2-9]\\d\\d)\\d{4}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"KY",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,"345849\\d{4}",null,null,null,"3458491234"],null,"345",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],LC:[null,[null,null,"(?:[58]\\d\\d|758|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"758(?:4(?:30|5\\d|6[2-9]|8[0-2])|57[0-2]|638)\\d{4}",null,null,null,"7584305678",null,null,null,[7]],[null,null,"758(?:28[4-7]|384|4(?:6[01]|8[4-9])|5(?:1[89]|20|84)|7(?:1[2-9]|2\\d|3[01]))\\d{4}",null,null,null,"7582845678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"LC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"758",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],MP:[null,[null,null,"(?:[58]\\d\\d|(?:67|90)0)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",null,null,null,"6702345678",null,null,null,[7]],[null,null,"670(?:2(?:3[3-7]|56|8[5-8])|32[1-38]|4(?:33|8[348])|5(?:32|55|88)|6(?:64|70|82)|78[3589]|8[3-9]8|989)\\d{4}",null,null,null,"6702345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"MP",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"670",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],MS:[null,[null,null,"(?:(?:[58]\\d\\d|900)\\d\\d|66449)\\d{5}",null,null,null,null,null,null,[10],[7]],[null,null,"664491\\d{4}",null,null,null,"6644912345",null,null,null,[7]],[null,null,"66449[2-6]\\d{4}",null,null,null,"6644923456",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"MS",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"664",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],PR:[null,[null,null,"(?:[589]\\d\\d|787)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:787|939)[2-9]\\d{6}",null,null,null,"7872345678",null,null,null,[7]],[null,null,"(?:787|939)[2-9]\\d{6}",null,null,null,"7872345678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"PR",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"787|939",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],SX:[null,[null,null,"(?:(?:[58]\\d\\d|900)\\d|7215)\\d{6}",null,null,null,null,null,null,[10],[7]],[null,null,"7215(?:4[2-8]|8[239]|9[056])\\d{4}",null,null,null,"7215425678",null,null,null,[7]],[null,null,"7215(?:1[02]|2\\d|5[034679]|8[014-8])\\d{4}",null,null,null,"7215205678",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002123456"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002123456"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"SX",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"721",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],TC:[null,[null,null,"(?:[58]\\d\\d|649|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"649(?:712|9(?:4\\d|50))\\d{4}",null,null,null,"6497121234",null,null,null,[7]],[null,null,"649(?:2(?:3[129]|4[1-7])|3(?:3[1-389]|4[1-8])|4[34][1-3])\\d{4}",null,null,null,"6492311234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,"64971[01]\\d{4}",null,null,null,"6497101234",null,null,null,[7]],"TC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"649",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],TT:[null,[null,null,"(?:[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"868(?:2(?:01|[23]\\d)|6(?:0[7-9]|1[02-8]|2[1-9]|[3-69]\\d|7[0-79])|82[124])\\d{4}",null,null,null,"8682211234",null,null,null,[7]],[null,null,"868(?:2(?:6[6-9]|[7-9]\\d)|[37](?:0[1-9]|1[02-9]|[2-9]\\d)|4[6-9]\\d|6(?:20|78|8\\d))\\d{4}",null,null,null,"8682911234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"TT",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"868",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,"868619\\d{4}",null,null,null,"8686191234",null,null,null,[7]]],US:[null,[null,null,"[2-9]\\d{9}",null,null,null,null,null,null,[10],[7]],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[017]|6[0-279]|78|8[0-2])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-28]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[0179]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}",null,null,null,"2015550123",null,null,null,[7]],[null,null,"(?:2(?:0[1-35-9]|1[02-9]|2[03-589]|3[149]|4[08]|5[1-46]|6[0279]|7[0269]|8[13])|3(?:0[1-57-9]|1[02-9]|2[0135]|3[0-24679]|4[67]|5[12]|6[014]|8[056])|4(?:0[124-9]|1[02-579]|2[3-5]|3[0245]|4[0235]|58|6[39]|7[0589]|8[04])|5(?:0[1-57-9]|1[0235-8]|20|3[0149]|4[01]|5[19]|6[1-47]|7[013-5]|8[056])|6(?:0[1-35-9]|1[024-9]|2[03689]|[34][016]|5[017]|6[0-279]|78|8[0-2])|7(?:0[1-46-8]|1[2-9]|2[04-7]|3[1247]|4[037]|5[47]|6[02359]|7[02-59]|8[156])|8(?:0[1-68]|1[02-8]|2[08]|3[0-28]|4[3578]|5[046-9]|6[02-5]|7[028])|9(?:0[1346-9]|1[02-9]|2[0589]|3[0146-8]|4[0179]|5[12469]|7[0-389]|8[04-69]))[2-9]\\d{6}",null,null,null,"2015550123",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"US",1,"011","1",null,null,"1",null,null,1,[[null,"(\\d{3})(\\d{4})","$1-$2",["[2-9]"]],[null,"(\\d{3})(\\d{3})(\\d{4})","($1) $2-$3",["[2-9]"],null,null,1]],[[null,"(\\d{3})(\\d{3})(\\d{4})","$1-$2-$3",["[2-9]"]]],[null,null,null,null,null,null,null,null,null,[-1]],1,null,[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"710[2-9]\\d{6}",null,null,null,"7102123456"],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VC:[null,[null,null,"(?:[58]\\d\\d|784|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"784(?:266|3(?:6[6-9]|7\\d|8[0-24-6])|4(?:38|5[0-36-8]|8[0-8])|5(?:55|7[0-2]|93)|638|784)\\d{4}",null,null,null,"7842661234",null,null,null,[7]],[null,null,"784(?:4(?:3[0-5]|5[45]|89|9[0-8])|5(?:2[6-9]|3[0-4]))\\d{4}",null,null,null,"7844301234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VC",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"784",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VG:[null,[null,null,"(?:284|[58]\\d\\d|900)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"284(?:(?:229|774|8(?:52|6[459]))\\d|4(?:22\\d|9(?:[45]\\d|6[0-5])))\\d{3}",null,null,null,"2842291234",null,null,null,[7]],[null,null,"284(?:(?:3(?:0[0-3]|4[0-7]|68|9[34])|54[0-57])\\d|4(?:(?:4[0-6]|68)\\d|9(?:6[6-9]|9\\d)))\\d{3}",null,null,null,"2843001234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VG",1,"011","1",null,null,"1",null,null,null,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"284",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]],VI:[null,[null,null,"(?:(?:34|90)0|[58]\\d\\d)\\d{7}",null,null,null,null,null,null,[10],[7]],[null,null,"340(?:2(?:01|2[06-8]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-57-9]|27|7\\d)|884|998)\\d{4}",null,null,null,"3406421234",null,null,null,[7]],[null,null,"340(?:2(?:01|2[06-8]|44|77)|3(?:32|44)|4(?:22|7[34])|5(?:1[34]|55)|6(?:26|4[23]|77|9[023])|7(?:1[2-57-9]|27|7\\d)|884|998)\\d{4}",null,null,null,"3406421234",null,null,null,[7]],[null,null,"8(?:00|33|44|55|66|77|88)[2-9]\\d{6}",null,null,null,"8002345678"],[null,null,"900[2-9]\\d{6}",null,null,null,"9002345678"],[null,null,null,null,null,null,null,null,null,[-1]],[null,null,"5(?:00|2[12]|33|44|66|77|88)[2-9]\\d{6}",null,null,null,"5002345678"],[null,null,null,null,null,null,null,null,null,[-1]],"VI",1,"011","1",null,null,"1",null,null,1,null,null,[null,null,null,null,null,null,null,null,null,[-1]],null,"340",[null,null,null,null,null,null,null,null,null,[-1]],[null,null,null,null,null,null,null,null,null,[-1]],null,null,[null,null,null,null,null,null,null,null,null,[-1]]]};Z.b=function(){return Z.a?Z.a:Z.a=new Z};var ar={0:"0",1:"1",2:"2",3:"3",4:"4",5:"5",6:"6",7:"7",8:"8",9:"9","0":"0","1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9"},mr=RegExp("[++]+"),Xe=RegExp("([0-90-9٠-٩۰-۹])"),Or=/^\(?\$1\)?$/,jr=new Oe;N(jr,11,"NA");var lr=/\[([^\[\]])*\]/g,cr=/\d(?=[^,}][^,}])/g,Vt=RegExp("^[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~]*(\\$\\d[-x‐-―−ー--/  ­​⁠ ()()[].\\[\\]/~⁓∼~]*)+$"),At=/[- ]/;Te.prototype.K=function(){this.C="",n(this.i),n(this.u),n(this.m),this.s=0,this.w="",n(this.b),this.h="",n(this.a),this.l=!0,this.A=this.o=this.F=!1,this.f=[],this.B=!1,this.g!=this.J&&(this.g=te(this,this.D))},Te.prototype.L=function(M){return this.C=ne(this,M)},t("Cleave.AsYouTypeFormatter",Te),t("Cleave.AsYouTypeFormatter.prototype.inputDigit",Te.prototype.L),t("Cleave.AsYouTypeFormatter.prototype.clear",Te.prototype.K)}).call(typeof sn=="object"&&sn?sn:window);var z2=Object.defineProperty,H2=Object.getOwnPropertyDescriptor,jd=(t,e,r,n)=>{for(var i=n>1?void 0:n?H2(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&z2(e,r,i),i};const q2=Il.object({firstName:Il.string().min(1,{message:"First name is required"}),lastName:Il.string().min(1,{message:"Last name is required"}),email:Il.string().email({message:"Invalid email address"}),phone:Il.string().regex(/^(1-)?\d{3}-\d{3}-\d{4}$/,{message:"Invalid phone number"}).transform(t=>t.replace(/-/g,"").replace(/^1/,""))});let Go=class extends Bo{constructor(){super(...arguments),this.params={firstName:"",lastName:"",email:"",phone:""},this.errors=[]}firstUpdated(){this.phoneCleave=new gA(this.phoneInput,{phone:!0,phoneRegionCode:"US",delimiter:"-"})}submit(t){t.preventDefault();try{this.params=q2.parse(this.params)}catch(e){this.errors=e.errors;return}this.dispatchEvent(new CustomEvent("submit",{composed:!0,detail:this.params}))}cancel(){this.dispatchEvent(new CustomEvent("cancel"))}updateField(t,e){this.params={...this.params,[t]:e}}render(){return Id`
44
44
  <div>
45
45
  <iai-chat-message-assistant
46
46
  content="Your contact information is required to transfer to a live agent."
@@ -385,7 +385,7 @@
385
385
  * @license
386
386
  * Copyright 2021 Google LLC
387
387
  * SPDX-License-Identifier: BSD-3-Clause
388
- */function ha(t,e,r){return t?e(t):r==null?void 0:r(t)}const fv="-",nP=t=>{const e=aP(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:i=>{const a=i.split(fv);return a[0]===""&&a.length!==1&&a.shift(),V0(a,e)||iP(i)},getConflictingClassGroupIds:(i,a)=>{const s=r[i]||[];return a&&n[i]?[...s,...n[i]]:s}}},V0=(t,e)=>{var r;if(t.length===0)return e.classGroupId;const n=t[0],i=e.nextPart.get(n),a=i?V0(t.slice(1),i):void 0;if(a)return a;if(e.validators.length===0)return;const s=t.join(fv);return(r=e.validators.find(({validator:o})=>o(s)))==null?void 0:r.classGroupId},W0=/^\[(.+)\]$/,iP=t=>{if(W0.test(t)){const e=W0.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},aP=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return oP(Object.entries(t.classGroups),r).forEach(([i,a])=>{hv(a,n,i,e)}),n},hv=(t,e,r,n)=>{t.forEach(i=>{if(typeof i=="string"){const a=i===""?e:Z0(e,i);a.classGroupId=r;return}if(typeof i=="function"){if(sP(i)){hv(i(n),e,r,n);return}e.validators.push({validator:i,classGroupId:r});return}Object.entries(i).forEach(([a,s])=>{hv(s,Z0(e,a),r,n)})})},Z0=(t,e)=>{let r=t;return e.split(fv).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},sP=t=>t.isThemeGetter,oP=(t,e)=>e?t.map(([r,n])=>{const i=n.map(a=>typeof a=="string"?e+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([s,o])=>[e+s,o])):a);return[r,i]}):t,uP=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const i=(a,s)=>{r.set(a,s),e++,e>t&&(e=0,n=r,r=new Map)};return{get(a){let s=r.get(a);if(s!==void 0)return s;if((s=n.get(a))!==void 0)return i(a,s),s},set(a,s){r.has(a)?r.set(a,s):i(a,s)}}},G0="!",lP=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,i=e[0],a=e.length,s=o=>{const u=[];let l=0,c=0,d;for(let N=0;N<o.length;N++){let z=o[N];if(l===0){if(z===i&&(n||o.slice(N,N+a)===e)){u.push(o.slice(c,N)),c=N+a;continue}if(z==="/"){d=N;continue}}z==="["?l++:z==="]"&&l--}const f=u.length===0?o:o.substring(c),m=f.startsWith(G0),k=m?f.substring(1):f,L=d&&d>c?d-c:void 0;return{modifiers:u,hasImportantModifier:m,baseClassName:k,maybePostfixModifierPosition:L}};return r?o=>r({className:o,parseClassName:s}):s},cP=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},dP=t=>({cache:uP(t.cacheSize),parseClassName:lP(t),...nP(t)}),fP=/\s+/,hP=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i}=e,a=[],s=t.trim().split(fP);let o="";for(let u=s.length-1;u>=0;u-=1){const l=s[u],{modifiers:c,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:m}=r(l);let k=!!m,L=n(k?f.substring(0,m):f);if(!L){if(!k){o=l+(o.length>0?" "+o:o);continue}if(L=n(f),!L){o=l+(o.length>0?" "+o:o);continue}k=!1}const N=cP(c).join(":"),z=d?N+G0:N,re=z+L;if(a.includes(re))continue;a.push(re);const Me=i(L,k);for(let Oe=0;Oe<Me.length;++Oe){const Be=Me[Oe];a.push(z+Be)}o=l+(o.length>0?" "+o:o)}return o};function pP(){let t=0,e,r,n="";for(;t<arguments.length;)(e=arguments[t++])&&(r=K0(e))&&(n&&(n+=" "),n+=r);return n}const K0=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=K0(t[n]))&&(r&&(r+=" "),r+=e);return r};function vP(t,...e){let r,n,i,a=s;function s(u){const l=e.reduce((c,d)=>d(c),t());return r=dP(l),n=r.cache.get,i=r.cache.set,a=o,o(u)}function o(u){const l=n(u);if(l)return l;const c=hP(u,r);return i(u,c),c}return function(){return a(pP.apply(null,arguments))}}const Dr=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},Y0=/^\[(?:([a-z-]+):)?(.+)\]$/i,gP=/^\d+\/\d+$/,mP=new Set(["px","full","screen"]),yP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bP=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,wP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,_P=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,kP=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,pa=t=>ru(t)||mP.has(t)||gP.test(t),Ja=t=>nu(t,"length",RP),ru=t=>!!t&&!Number.isNaN(Number(t)),pv=t=>nu(t,"number",ru),ql=t=>!!t&&Number.isInteger(Number(t)),SP=t=>t.endsWith("%")&&ru(t.slice(0,-1)),ir=t=>Y0.test(t),Qa=t=>yP.test(t),$P=new Set(["length","size","percentage"]),TP=t=>nu(t,$P,J0),CP=t=>nu(t,"position",J0),EP=new Set(["image","url"]),IP=t=>nu(t,EP,OP),xP=t=>nu(t,"",AP),Vl=()=>!0,nu=(t,e,r)=>{const n=Y0.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},RP=t=>bP.test(t)&&!wP.test(t),J0=()=>!1,AP=t=>_P.test(t),OP=t=>kP.test(t),PP=()=>{const t=Dr("colors"),e=Dr("spacing"),r=Dr("blur"),n=Dr("brightness"),i=Dr("borderColor"),a=Dr("borderRadius"),s=Dr("borderSpacing"),o=Dr("borderWidth"),u=Dr("contrast"),l=Dr("grayscale"),c=Dr("hueRotate"),d=Dr("invert"),f=Dr("gap"),m=Dr("gradientColorStops"),k=Dr("gradientColorStopPositions"),L=Dr("inset"),N=Dr("margin"),z=Dr("opacity"),re=Dr("padding"),Me=Dr("saturate"),Oe=Dr("scale"),Be=Dr("sepia"),Pe=Dr("skew"),Ze=Dr("space"),Z=Dr("translate"),Ie=()=>["auto","contain","none"],_e=()=>["auto","hidden","clip","visible","scroll"],se=()=>["auto",ir,e],Te=()=>[ir,e],te=()=>["",pa,Ja],oe=()=>["auto",ru,ir],q=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ne=()=>["solid","dashed","dotted","double","none"],Se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>["start","end","center","between","around","evenly","stretch"],ye=()=>["","0",ir],ke=()=>["auto","avoid","all","avoid-page","page","left","right","column"],P=()=>[ru,ir];return{cacheSize:500,separator:":",theme:{colors:[Vl],spacing:[pa,Ja],blur:["none","",Qa,ir],brightness:P(),borderColor:[t],borderRadius:["none","","full",Qa,ir],borderSpacing:Te(),borderWidth:te(),contrast:P(),grayscale:ye(),hueRotate:P(),invert:ye(),gap:Te(),gradientColorStops:[t],gradientColorStopPositions:[SP,Ja],inset:se(),margin:se(),opacity:P(),padding:Te(),saturate:P(),scale:P(),sepia:ye(),skew:P(),space:Te(),translate:Te()},classGroups:{aspect:[{aspect:["auto","square","video",ir]}],container:["container"],columns:[{columns:[Qa]}],"break-after":[{"break-after":ke()}],"break-before":[{"break-before":ke()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...q(),ir]}],overflow:[{overflow:_e()}],"overflow-x":[{"overflow-x":_e()}],"overflow-y":[{"overflow-y":_e()}],overscroll:[{overscroll:Ie()}],"overscroll-x":[{"overscroll-x":Ie()}],"overscroll-y":[{"overscroll-y":Ie()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[L]}],"inset-x":[{"inset-x":[L]}],"inset-y":[{"inset-y":[L]}],start:[{start:[L]}],end:[{end:[L]}],top:[{top:[L]}],right:[{right:[L]}],bottom:[{bottom:[L]}],left:[{left:[L]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ql,ir]}],basis:[{basis:se()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ir]}],grow:[{grow:ye()}],shrink:[{shrink:ye()}],order:[{order:["first","last","none",ql,ir]}],"grid-cols":[{"grid-cols":[Vl]}],"col-start-end":[{col:["auto",{span:["full",ql,ir]},ir]}],"col-start":[{"col-start":oe()}],"col-end":[{"col-end":oe()}],"grid-rows":[{"grid-rows":[Vl]}],"row-start-end":[{row:["auto",{span:[ql,ir]},ir]}],"row-start":[{"row-start":oe()}],"row-end":[{"row-end":oe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ir]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ir]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...H()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...H(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...H(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[re]}],px:[{px:[re]}],py:[{py:[re]}],ps:[{ps:[re]}],pe:[{pe:[re]}],pt:[{pt:[re]}],pr:[{pr:[re]}],pb:[{pb:[re]}],pl:[{pl:[re]}],m:[{m:[N]}],mx:[{mx:[N]}],my:[{my:[N]}],ms:[{ms:[N]}],me:[{me:[N]}],mt:[{mt:[N]}],mr:[{mr:[N]}],mb:[{mb:[N]}],ml:[{ml:[N]}],"space-x":[{"space-x":[Ze]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[Ze]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ir,e]}],"min-w":[{"min-w":[ir,e,"min","max","fit"]}],"max-w":[{"max-w":[ir,e,"none","full","min","max","fit","prose",{screen:[Qa]},Qa]}],h:[{h:[ir,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ir,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ir,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ir,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Qa,Ja]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",pv]}],"font-family":[{font:[Vl]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ir]}],"line-clamp":[{"line-clamp":["none",ru,pv]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",pa,ir]}],"list-image":[{"list-image":["none",ir]}],"list-style-type":[{list:["none","disc","decimal",ir]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[z]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[z]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",pa,Ja]}],"underline-offset":[{"underline-offset":["auto",pa,ir]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Te()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ir]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ir]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[z]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...q(),CP]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",TP]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},IP]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[k]}],"gradient-via-pos":[{via:[k]}],"gradient-to-pos":[{to:[k]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[z]}],"border-style":[{border:[...ne(),"hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[z]}],"divide-style":[{divide:ne()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ne()]}],"outline-offset":[{"outline-offset":[pa,ir]}],"outline-w":[{outline:[pa,Ja]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[z]}],"ring-offset-w":[{"ring-offset":[pa,Ja]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Qa,xP]}],"shadow-color":[{shadow:[Vl]}],opacity:[{opacity:[z]}],"mix-blend":[{"mix-blend":[...Se(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Se()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Qa,ir]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[d]}],saturate:[{saturate:[Me]}],sepia:[{sepia:[Be]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[z]}],"backdrop-saturate":[{"backdrop-saturate":[Me]}],"backdrop-sepia":[{"backdrop-sepia":[Be]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ir]}],duration:[{duration:P()}],ease:[{ease:["linear","in","out","in-out",ir]}],delay:[{delay:P()}],animate:[{animate:["none","spin","ping","pulse","bounce",ir]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[Oe]}],"scale-x":[{"scale-x":[Oe]}],"scale-y":[{"scale-y":[Oe]}],rotate:[{rotate:[ql,ir]}],"translate-x":[{"translate-x":[Z]}],"translate-y":[{"translate-y":[Z]}],"skew-x":[{"skew-x":[Pe]}],"skew-y":[{"skew-y":[Pe]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ir]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ir]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Te()}],"scroll-mx":[{"scroll-mx":Te()}],"scroll-my":[{"scroll-my":Te()}],"scroll-ms":[{"scroll-ms":Te()}],"scroll-me":[{"scroll-me":Te()}],"scroll-mt":[{"scroll-mt":Te()}],"scroll-mr":[{"scroll-mr":Te()}],"scroll-mb":[{"scroll-mb":Te()}],"scroll-ml":[{"scroll-ml":Te()}],"scroll-p":[{"scroll-p":Te()}],"scroll-px":[{"scroll-px":Te()}],"scroll-py":[{"scroll-py":Te()}],"scroll-ps":[{"scroll-ps":Te()}],"scroll-pe":[{"scroll-pe":Te()}],"scroll-pt":[{"scroll-pt":Te()}],"scroll-pr":[{"scroll-pr":Te()}],"scroll-pb":[{"scroll-pb":Te()}],"scroll-pl":[{"scroll-pl":Te()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ir]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[pa,Ja,pv]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},MP=vP(PP);var NP=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Q0(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var vv={};(function(t){function e(o){o&&o.options&&clearTimeout(o.options.timer)}function r(o,u,l,c){var d={timer:void 0,lastArgs:[]},f=function(){for(var m=this,k=[],L=0;L<arguments.length;L++)k[L]=arguments[L];d.lastArgs=k,d.timer?clearTimeout(d.timer):u&&l.apply(this,d.lastArgs),d.timer=setTimeout(function(){u||l.apply(m,d.lastArgs),d.timer=void 0},o)};return c&&(f=f.bind(c)),f.options=d,f}function n(o,u,l,c){var d;Object.defineProperty(l,c,{configurable:!0,enumerable:!1,get:function(){return d},set:function(f){d=r(o,u,f,this)}})}function i(o,u,l){var c=l.value;return l.value=r(o,u,c),l}function a(o,u){for(var l=[],c=2;c<arguments.length;c++)l[c-2]=arguments[c];if(l.length===0)throw new Error("function applied debounce decorator should be a method");if(l.length===1)throw new Error("method applied debounce decorator should have valid name");var d=l[0],f=l[1],m=l.length===3&&l[2]?l[2]:Object.getOwnPropertyDescriptor(d,f);if(m)return i(o,u,m);n(o,u,d,f)}function s(){for(var o=[],u=0;u<arguments.length;u++)o[u]=arguments[u];var l=500,c=!1;if(o.length&&(typeof o[0]=="number"||typeof o[0]=="object"&&o[0].leading!==void 0)){typeof o[0]=="number"&&(l=o[0]);var d=void 0;return typeof o[0]=="object"&&o[0].leading!==void 0&&(d=o[0]),1<o.length&&typeof o[1]=="object"&&o[1].leading!==void 0&&(d=o[1]),d&&(c=d.leading),function(){for(var f=[],m=0;m<arguments.length;m++)f[m]=arguments[m];return a.apply(void 0,[l,c].concat(f))}}return a.apply(void 0,[l,c].concat(o))}Object.defineProperty(t,"__esModule",{value:!0}),t.cancel=e,t.debounce=s})(vv);var gr;(function(t){t.assertEqual=i=>i;function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(gr||(gr={}));var gv;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(gv||(gv={}));const gt=gr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Xa=t=>{switch(typeof t){case"undefined":return gt.undefined;case"string":return gt.string;case"number":return isNaN(t)?gt.nan:gt.number;case"boolean":return gt.boolean;case"function":return gt.function;case"bigint":return gt.bigint;case"symbol":return gt.symbol;case"object":return Array.isArray(t)?gt.array:t===null?gt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?gt.promise:typeof Map<"u"&&t instanceof Map?gt.map:typeof Set<"u"&&t instanceof Set?gt.set:typeof Date<"u"&&t instanceof Date?gt.date:gt.object;default:return gt.unknown}},at=gr.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"]),LP=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class yi extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,gr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}yi.create=t=>new yi(t);const Wl=(t,e)=>{let r;switch(t.code){case at.invalid_type:t.received===gt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case at.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,gr.jsonStringifyReplacer)}`;break;case at.unrecognized_keys:r=`Unrecognized key(s) in object: ${gr.joinValues(t.keys,", ")}`;break;case at.invalid_union:r="Invalid input";break;case at.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${gr.joinValues(t.options)}`;break;case at.invalid_enum_value:r=`Invalid enum value. Expected ${gr.joinValues(t.options)}, received '${t.received}'`;break;case at.invalid_arguments:r="Invalid function arguments";break;case at.invalid_return_type:r="Invalid function return type";break;case at.invalid_date:r="Invalid date";break;case at.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:gr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case at.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case at.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case at.custom:r="Invalid input";break;case at.invalid_intersection_types:r="Intersection results could not be merged";break;case at.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case at.not_finite:r="Number must be finite";break;default:r=e.defaultError,gr.assertNever(t)}return{message:r}};let X0=Wl;function DP(t){X0=t}function rf(){return X0}const nf=t=>{const{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],s={...i,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(s,{data:e,defaultError:o}).message;return{...i,path:a,message:i.message||o}},jP=[];function wt(t,e){const r=nf({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,rf(),Wl].filter(n=>!!n)});t.common.issues.push(r)}class pn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const i of r){if(i.status==="aborted")return Qt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const i of r)n.push({key:await i.key,value:await i.value});return pn.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const i of r){const{key:a,value:s}=i;if(a.status==="aborted"||s.status==="aborted")return Qt;a.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[a.value]=s.value)}return{status:e.value,value:n}}}const Qt=Object.freeze({status:"aborted"}),e_=t=>({status:"dirty",value:t}),Sn=t=>({status:"valid",value:t}),mv=t=>t.status==="aborted",yv=t=>t.status==="dirty",Zl=t=>t.status==="valid",af=t=>typeof Promise<"u"&&t instanceof Promise;var Lt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Lt||(Lt={}));class Fi{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const t_=(t,e)=>{if(Zl(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new yi(t.common.issues);return this._error=r,this._error}}};function rr(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,s)=>a.code!=="invalid_type"?{message:s.defaultError}:typeof s.data>"u"?{message:n??s.defaultError}:{message:r??s.defaultError},description:i}}class or{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)}get description(){return this._def.description}_getType(e){return Xa(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Xa(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new pn,ctx:{common:e.parent.common,data:e.data,parsedType:Xa(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(af(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const i={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xa(e)},a=this._parseSync({data:e,path:i.path,parent:i});return t_(i,a)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xa(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(af(i)?i:Promise.resolve(i));return t_(n,a)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{const s=e(i),o=()=>a.addIssue({code:at.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new _i({schema:this,typeName:Ft.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ga.create(this,this._def)}nullable(){return no.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return wi.create(this,this._def)}promise(){return ou.create(this,this._def)}or(e){return Jl.create([this,e],this._def)}and(e){return Ql.create(this,e,this._def)}transform(e){return new _i({...rr(this._def),schema:this,typeName:Ft.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new nc({...rr(this._def),innerType:this,defaultValue:r,typeName:Ft.ZodDefault})}brand(){return new n_({typeName:Ft.ZodBranded,type:this,...rr(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new df({...rr(this._def),innerType:this,catchValue:r,typeName:Ft.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return ic.create(this,e)}readonly(){return hf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const UP=/^c[^\s-]{8,}$/i,FP=/^[a-z][a-z0-9]*$/,BP=/^[0-9A-HJKMNP-TV-Z]{26}$/,zP=/^[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,HP=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,qP="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let bv;const VP=/^(((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}))$/,WP=/^(([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})))$/,ZP=t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function GP(t,e){return!!((e==="v4"||!e)&&VP.test(t)||(e==="v6"||!e)&&WP.test(t))}class bi extends or{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==gt.string){const i=this._getOrReturnCtx(e);return wt(i,{code:at.invalid_type,expected:gt.string,received:i.parsedType}),Qt}const r=new pn;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),wt(n,{code:at.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),wt(n,{code:at.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,s=e.data.length<i.value;(a||s)&&(n=this._getOrReturnCtx(e,n),a?wt(n,{code:at.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&wt(n,{code:at.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")HP.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"email",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")bv||(bv=new RegExp(qP,"u")),bv.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"emoji",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")zP.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"uuid",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")UP.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"cuid",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")FP.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"cuid2",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")BP.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"ulid",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),wt(n,{validation:"url",code:at.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"regex",code:at.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),wt(n,{code:at.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),wt(n,{code:at.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),wt(n,{code:at.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?ZP(i).test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{code:at.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="ip"?GP(e.data,i.version)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"ip",code:at.invalid_string,message:i.message}),r.dirty()):gr.assertNever(i);return{status:r.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:at.invalid_string,...Lt.errToObj(n)})}_addCheck(e){return new bi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Lt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Lt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Lt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Lt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Lt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Lt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Lt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Lt.errToObj(e)})}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,...Lt.errToObj(e==null?void 0:e.message)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Lt.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Lt.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Lt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Lt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Lt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Lt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Lt.errToObj(r)})}nonempty(e){return this.min(1,Lt.errToObj(e))}trim(){return new bi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new bi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new bi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}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 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 minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}bi.create=t=>{var e;return new bi({checks:[],typeName:Ft.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...rr(t)})};function KP(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),s=parseInt(e.toFixed(i).replace(".",""));return a%s/Math.pow(10,i)}class es extends or{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)!==gt.number){const i=this._getOrReturnCtx(e);return wt(i,{code:at.invalid_type,expected:gt.number,received:i.parsedType}),Qt}let r;const n=new pn;for(const i of this._def.checks)i.kind==="int"?gr.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),wt(r,{code:at.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?KP(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),wt(r,{code:at.not_finite,message:i.message}),n.dirty()):gr.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Lt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Lt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Lt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Lt.toString(r))}setLimit(e,r,n,i){return new es({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Lt.toString(i)}]})}_addCheck(e){return new es({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Lt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Lt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Lt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Lt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Lt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Lt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Lt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Lt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Lt.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&gr.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}es.create=t=>new es({checks:[],typeName:Ft.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...rr(t)});class ts extends or{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==gt.bigint){const i=this._getOrReturnCtx(e);return wt(i,{code:at.invalid_type,expected:gt.bigint,received:i.parsedType}),Qt}let r;const n=new pn;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):gr.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Lt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Lt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Lt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Lt.toString(r))}setLimit(e,r,n,i){return new ts({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Lt.toString(i)}]})}_addCheck(e){return new ts({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Lt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Lt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Lt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Lt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Lt.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}ts.create=t=>{var e;return new ts({checks:[],typeName:Ft.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...rr(t)})};class Gl extends or{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==gt.boolean){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.boolean,received:r.parsedType}),Qt}return Sn(e.data)}}Gl.create=t=>new Gl({typeName:Ft.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...rr(t)});class eo extends or{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==gt.date){const i=this._getOrReturnCtx(e);return wt(i,{code:at.invalid_type,expected:gt.date,received:i.parsedType}),Qt}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return wt(i,{code:at.invalid_date}),Qt}const r=new pn;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),wt(n,{code:at.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),wt(n,{code:at.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):gr.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new eo({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Lt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Lt.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}eo.create=t=>new eo({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Ft.ZodDate,...rr(t)});class sf extends or{_parse(e){if(this._getType(e)!==gt.symbol){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.symbol,received:r.parsedType}),Qt}return Sn(e.data)}}sf.create=t=>new sf({typeName:Ft.ZodSymbol,...rr(t)});class Kl extends or{_parse(e){if(this._getType(e)!==gt.undefined){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.undefined,received:r.parsedType}),Qt}return Sn(e.data)}}Kl.create=t=>new Kl({typeName:Ft.ZodUndefined,...rr(t)});class Yl extends or{_parse(e){if(this._getType(e)!==gt.null){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.null,received:r.parsedType}),Qt}return Sn(e.data)}}Yl.create=t=>new Yl({typeName:Ft.ZodNull,...rr(t)});class iu extends or{constructor(){super(...arguments),this._any=!0}_parse(e){return Sn(e.data)}}iu.create=t=>new iu({typeName:Ft.ZodAny,...rr(t)});class to extends or{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Sn(e.data)}}to.create=t=>new to({typeName:Ft.ZodUnknown,...rr(t)});class va extends or{_parse(e){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.never,received:r.parsedType}),Qt}}va.create=t=>new va({typeName:Ft.ZodNever,...rr(t)});class of extends or{_parse(e){if(this._getType(e)!==gt.undefined){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.void,received:r.parsedType}),Qt}return Sn(e.data)}}of.create=t=>new of({typeName:Ft.ZodVoid,...rr(t)});class wi extends or{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==gt.array)return wt(r,{code:at.invalid_type,expected:gt.array,received:r.parsedType}),Qt;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(s||o)&&(wt(r,{code:s?at.too_big:at.too_small,minimum:o?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(wt(r,{code:at.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(wt(r,{code:at.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>i.type._parseAsync(new Fi(r,s,r.path,o)))).then(s=>pn.mergeArray(n,s));const a=[...r.data].map((s,o)=>i.type._parseSync(new Fi(r,s,r.path,o)));return pn.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new wi({...this._def,minLength:{value:e,message:Lt.toString(r)}})}max(e,r){return new wi({...this._def,maxLength:{value:e,message:Lt.toString(r)}})}length(e,r){return new wi({...this._def,exactLength:{value:e,message:Lt.toString(r)}})}nonempty(e){return this.min(1,e)}}wi.create=(t,e)=>new wi({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Ft.ZodArray,...rr(e)});function au(t){if(t instanceof Vr){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=ga.create(au(n))}return new Vr({...t._def,shape:()=>e})}else return t instanceof wi?new wi({...t._def,type:au(t.element)}):t instanceof ga?ga.create(au(t.unwrap())):t instanceof no?no.create(au(t.unwrap())):t instanceof Bi?Bi.create(t.items.map(e=>au(e))):t}class Vr extends or{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=gr.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==gt.object){const u=this._getOrReturnCtx(e);return wt(u,{code:at.invalid_type,expected:gt.object,received:u.parsedType}),Qt}const{status:r,ctx:n}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof va&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||s.push(u);const o=[];for(const u of a){const l=i[u],c=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new Fi(n,c,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof va){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of s)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")s.length>0&&(wt(n,{code:at.unrecognized_keys,keys:s}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of s){const c=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new Fi(n,c,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const c=await l.key;u.push({key:c,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>pn.mergeObjectSync(r,u)):pn.mergeObjectSync(r,o)}get shape(){return this._def.shape()}strict(e){return Lt.errToObj,new Vr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,s,o;const u=(s=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&s!==void 0?s:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=Lt.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Vr({...this._def,unknownKeys:"strip"})}passthrough(){return new Vr({...this._def,unknownKeys:"passthrough"})}extend(e){return new Vr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Vr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ft.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Vr({...this._def,catchall:e})}pick(e){const r={};return gr.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Vr({...this._def,shape:()=>r})}omit(e){const r={};return gr.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new Vr({...this._def,shape:()=>r})}deepPartial(){return au(this)}partial(e){const r={};return gr.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}),new Vr({...this._def,shape:()=>r})}required(e){const r={};return gr.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof ga;)i=i._def.innerType;r[n]=i}}),new Vr({...this._def,shape:()=>r})}keyof(){return r_(gr.objectKeys(this.shape))}}Vr.create=(t,e)=>new Vr({shape:()=>t,unknownKeys:"strip",catchall:va.create(),typeName:Ft.ZodObject,...rr(e)}),Vr.strictCreate=(t,e)=>new Vr({shape:()=>t,unknownKeys:"strict",catchall:va.create(),typeName:Ft.ZodObject,...rr(e)}),Vr.lazycreate=(t,e)=>new Vr({shape:t,unknownKeys:"strip",catchall:va.create(),typeName:Ft.ZodObject,...rr(e)});class Jl extends or{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(o=>new yi(o.ctx.common.issues));return wt(r,{code:at.invalid_union,unionErrors:s}),Qt}if(r.common.async)return Promise.all(n.map(async a=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let a;const s=[];for(const u of n){const l={...r,common:{...r.common,issues:[]},parent:null},c=u._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(u=>new yi(u));return wt(r,{code:at.invalid_union,unionErrors:o}),Qt}}get options(){return this._def.options}}Jl.create=(t,e)=>new Jl({options:t,typeName:Ft.ZodUnion,...rr(e)});const uf=t=>t instanceof ec?uf(t.schema):t instanceof _i?uf(t.innerType()):t instanceof tc?[t.value]:t instanceof rs?t.options:t instanceof rc?Object.keys(t.enum):t instanceof nc?uf(t._def.innerType):t instanceof Kl?[void 0]:t instanceof Yl?[null]:null;class lf extends or{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.object)return wt(r,{code:at.invalid_type,expected:gt.object,received:r.parsedType}),Qt;const n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(wt(r,{code:at.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Qt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const a of r){const s=uf(a.shape[e]);if(!s)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,a)}}return new lf({typeName:Ft.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...rr(n)})}}function wv(t,e){const r=Xa(t),n=Xa(e);if(t===e)return{valid:!0,data:t};if(r===gt.object&&n===gt.object){const i=gr.objectKeys(e),a=gr.objectKeys(t).filter(o=>i.indexOf(o)!==-1),s={...t,...e};for(const o of a){const u=wv(t[o],e[o]);if(!u.valid)return{valid:!1};s[o]=u.data}return{valid:!0,data:s}}else if(r===gt.array&&n===gt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const s=t[a],o=e[a],u=wv(s,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===gt.date&&n===gt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Ql extends or{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=(a,s)=>{if(mv(a)||mv(s))return Qt;const o=wv(a.value,s.value);return o.valid?((yv(a)||yv(s))&&r.dirty(),{status:r.value,value:o.data}):(wt(n,{code:at.invalid_intersection_types}),Qt)};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(([a,s])=>i(a,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Ql.create=(t,e,r)=>new Ql({left:t,right:e,typeName:Ft.ZodIntersection,...rr(r)});class Bi extends or{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.array)return wt(n,{code:at.invalid_type,expected:gt.array,received:n.parsedType}),Qt;if(n.data.length<this._def.items.length)return wt(n,{code:at.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Qt;!this._def.rest&&n.data.length>this._def.items.length&&(wt(n,{code:at.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((a,s)=>{const o=this._def.items[s]||this._def.rest;return o?o._parse(new Fi(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>pn.mergeArray(r,a)):pn.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Bi({...this._def,rest:e})}}Bi.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Bi({items:t,typeName:Ft.ZodTuple,rest:null,...rr(e)})};class Xl extends or{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.object)return wt(n,{code:at.invalid_type,expected:gt.object,received:n.parsedType}),Qt;const i=[],a=this._def.keyType,s=this._def.valueType;for(const o in n.data)i.push({key:a._parse(new Fi(n,o,n.path,o)),value:s._parse(new Fi(n,n.data[o],n.path,o))});return n.common.async?pn.mergeObjectAsync(r,i):pn.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof or?new Xl({keyType:e,valueType:r,typeName:Ft.ZodRecord,...rr(n)}):new Xl({keyType:bi.create(),valueType:e,typeName:Ft.ZodRecord,...rr(r)})}}class cf extends or{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.map)return wt(n,{code:at.invalid_type,expected:gt.map,received:n.parsedType}),Qt;const i=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([o,u],l)=>({key:i._parse(new Fi(n,o,n.path,[l,"key"])),value:a._parse(new Fi(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of s){const l=await u.key,c=await u.value;if(l.status==="aborted"||c.status==="aborted")return Qt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const u of s){const l=u.key,c=u.value;if(l.status==="aborted"||c.status==="aborted")return Qt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}}cf.create=(t,e,r)=>new cf({valueType:e,keyType:t,typeName:Ft.ZodMap,...rr(r)});class ro extends or{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.set)return wt(n,{code:at.invalid_type,expected:gt.set,received:n.parsedType}),Qt;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(wt(n,{code:at.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(wt(n,{code:at.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const a=this._def.valueType;function s(u){const l=new Set;for(const c of u){if(c.status==="aborted")return Qt;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new Fi(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>s(u)):s(o)}min(e,r){return new ro({...this._def,minSize:{value:e,message:Lt.toString(r)}})}max(e,r){return new ro({...this._def,maxSize:{value:e,message:Lt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}ro.create=(t,e)=>new ro({valueType:t,minSize:null,maxSize:null,typeName:Ft.ZodSet,...rr(e)});class su extends or{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.function)return wt(r,{code:at.invalid_type,expected:gt.function,received:r.parsedType}),Qt;function n(o,u){return nf({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,rf(),Wl].filter(l=>!!l),issueData:{code:at.invalid_arguments,argumentsError:u}})}function i(o,u){return nf({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,rf(),Wl].filter(l=>!!l),issueData:{code:at.invalid_return_type,returnTypeError:u}})}const a={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof ou){const o=this;return Sn(async function(...u){const l=new yi([]),c=await o._def.args.parseAsync(u,a).catch(f=>{throw l.addIssue(n(u,f)),l}),d=await Reflect.apply(s,this,c);return await o._def.returns._def.type.parseAsync(d,a).catch(f=>{throw l.addIssue(i(d,f)),l})})}else{const o=this;return Sn(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new yi([n(u,l.error)]);const c=Reflect.apply(s,this,l.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new yi([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new su({...this._def,args:Bi.create(e).rest(to.create())})}returns(e){return new su({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new su({args:e||Bi.create([]).rest(to.create()),returns:r||to.create(),typeName:Ft.ZodFunction,...rr(n)})}}class ec extends or{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}ec.create=(t,e)=>new ec({getter:t,typeName:Ft.ZodLazy,...rr(e)});class tc extends or{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return wt(r,{received:r.data,code:at.invalid_literal,expected:this._def.value}),Qt}return{status:"valid",value:e.data}}get value(){return this._def.value}}tc.create=(t,e)=>new tc({value:t,typeName:Ft.ZodLiteral,...rr(e)});function r_(t,e){return new rs({values:t,typeName:Ft.ZodEnum,...rr(e)})}class rs extends or{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return wt(r,{expected:gr.joinValues(n),received:r.parsedType,code:at.invalid_type}),Qt}if(this._def.values.indexOf(e.data)===-1){const r=this._getOrReturnCtx(e),n=this._def.values;return wt(r,{received:r.data,code:at.invalid_enum_value,options:n}),Qt}return Sn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e){return rs.create(e)}exclude(e){return rs.create(this.options.filter(r=>!e.includes(r)))}}rs.create=r_;class rc extends or{_parse(e){const r=gr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==gt.string&&n.parsedType!==gt.number){const i=gr.objectValues(r);return wt(n,{expected:gr.joinValues(i),received:n.parsedType,code:at.invalid_type}),Qt}if(r.indexOf(e.data)===-1){const i=gr.objectValues(r);return wt(n,{received:n.data,code:at.invalid_enum_value,options:i}),Qt}return Sn(e.data)}get enum(){return this._def.values}}rc.create=(t,e)=>new rc({values:t,typeName:Ft.ZodNativeEnum,...rr(e)});class ou extends or{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.promise&&r.common.async===!1)return wt(r,{code:at.invalid_type,expected:gt.promise,received:r.parsedType}),Qt;const n=r.parsedType===gt.promise?r.data:Promise.resolve(r.data);return Sn(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}ou.create=(t,e)=>new ou({type:t,typeName:Ft.ZodPromise,...rr(e)});class _i extends or{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ft.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:s=>{wt(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const s=i.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(s).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:s,path:n.path,parent:n})}if(i.type==="refinement"){const s=o=>{const u=i.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Qt:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?Qt:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Zl(s))return s;const o=i.transform(s.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>Zl(s)?Promise.resolve(i.transform(s.value,a)).then(o=>({status:r.value,value:o})):s);gr.assertNever(i)}}_i.create=(t,e,r)=>new _i({schema:t,typeName:Ft.ZodEffects,effect:e,...rr(r)}),_i.createWithPreprocess=(t,e,r)=>new _i({schema:e,effect:{type:"preprocess",transform:t},typeName:Ft.ZodEffects,...rr(r)});class ga extends or{_parse(e){return this._getType(e)===gt.undefined?Sn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ga.create=(t,e)=>new ga({innerType:t,typeName:Ft.ZodOptional,...rr(e)});class no extends or{_parse(e){return this._getType(e)===gt.null?Sn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}no.create=(t,e)=>new no({innerType:t,typeName:Ft.ZodNullable,...rr(e)});class nc extends or{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===gt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}nc.create=(t,e)=>new nc({innerType:t,typeName:Ft.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...rr(e)});class df extends or{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return af(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new yi(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new yi(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}df.create=(t,e)=>new df({innerType:t,typeName:Ft.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...rr(e)});class ff extends or{_parse(e){if(this._getType(e)!==gt.nan){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.nan,received:r.parsedType}),Qt}return{status:"valid",value:e.data}}}ff.create=t=>new ff({typeName:Ft.ZodNaN,...rr(t)});const YP=Symbol("zod_brand");class n_ extends or{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class ic extends or{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Qt:i.status==="dirty"?(r.dirty(),e_(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Qt:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new ic({in:e,out:r,typeName:Ft.ZodPipeline})}}class hf extends or{_parse(e){const r=this._def.innerType._parse(e);return Zl(r)&&(r.value=Object.freeze(r.value)),r}}hf.create=(t,e)=>new hf({innerType:t,typeName:Ft.ZodReadonly,...rr(e)});const i_=(t,e={},r)=>t?iu.create().superRefine((n,i)=>{var a,s;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(s=(a=o.fatal)!==null&&a!==void 0?a:r)!==null&&s!==void 0?s:!0,l=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...l,fatal:u})}}):iu.create(),JP={object:Vr.lazycreate};var Ft;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Ft||(Ft={}));const QP=(t,e={message:`Input not instance of ${t.name}`})=>i_(r=>r instanceof t,e),a_=bi.create,s_=es.create,XP=ff.create,eM=ts.create,o_=Gl.create,tM=eo.create,rM=sf.create,nM=Kl.create,iM=Yl.create,aM=iu.create,sM=to.create,oM=va.create,uM=of.create,lM=wi.create,cM=Vr.create,dM=Vr.strictCreate,fM=Jl.create,hM=lf.create,pM=Ql.create,vM=Bi.create,gM=Xl.create,mM=cf.create,yM=ro.create,bM=su.create,wM=ec.create,_M=tc.create,kM=rs.create,SM=rc.create,$M=ou.create,u_=_i.create,TM=ga.create,CM=no.create,EM=_i.createWithPreprocess,IM=ic.create;var mt=Object.freeze({__proto__:null,defaultErrorMap:Wl,setErrorMap:DP,getErrorMap:rf,makeIssue:nf,EMPTY_PATH:jP,addIssueToContext:wt,ParseStatus:pn,INVALID:Qt,DIRTY:e_,OK:Sn,isAborted:mv,isDirty:yv,isValid:Zl,isAsync:af,get util(){return gr},get objectUtil(){return gv},ZodParsedType:gt,getParsedType:Xa,ZodType:or,ZodString:bi,ZodNumber:es,ZodBigInt:ts,ZodBoolean:Gl,ZodDate:eo,ZodSymbol:sf,ZodUndefined:Kl,ZodNull:Yl,ZodAny:iu,ZodUnknown:to,ZodNever:va,ZodVoid:of,ZodArray:wi,ZodObject:Vr,ZodUnion:Jl,ZodDiscriminatedUnion:lf,ZodIntersection:Ql,ZodTuple:Bi,ZodRecord:Xl,ZodMap:cf,ZodSet:ro,ZodFunction:su,ZodLazy:ec,ZodLiteral:tc,ZodEnum:rs,ZodNativeEnum:rc,ZodPromise:ou,ZodEffects:_i,ZodTransformer:_i,ZodOptional:ga,ZodNullable:no,ZodDefault:nc,ZodCatch:df,ZodNaN:ff,BRAND:YP,ZodBranded:n_,ZodPipeline:ic,ZodReadonly:hf,custom:i_,Schema:or,ZodSchema:or,late:JP,get ZodFirstPartyTypeKind(){return Ft},coerce:{string:t=>bi.create({...t,coerce:!0}),number:t=>es.create({...t,coerce:!0}),boolean:t=>Gl.create({...t,coerce:!0}),bigint:t=>ts.create({...t,coerce:!0}),date:t=>eo.create({...t,coerce:!0})},any:aM,array:lM,bigint:eM,boolean:o_,date:tM,discriminatedUnion:hM,effect:u_,enum:kM,function:bM,instanceof:QP,intersection:pM,lazy:wM,literal:_M,map:mM,nan:XP,nativeEnum:SM,never:oM,null:iM,nullable:CM,number:s_,object:cM,oboolean:()=>o_().optional(),onumber:()=>s_().optional(),optional:TM,ostring:()=>a_().optional(),pipeline:IM,preprocess:EM,promise:$M,record:gM,set:yM,strictObject:dM,string:a_,symbol:rM,transformer:u_,tuple:vM,undefined:nM,union:fM,unknown:sM,void:uM,NEVER:Qt,ZodIssueCode:at,quotelessJson:LP,ZodError:yi});const xM={sm:"md:w-[350px]",md:"md:w-[500px]",lg:"md:w-[760px]",xl:"md:w-[900px]",xxl:"md:w-[1200px]"},RM={sm:"md:h-[400px]",md:"md:h-[500px]",lg:"md:h-[600px]",xl:"md:h-[700px]",xxl:"md:h-[800px]"},pf=mt.object({assistantId:mt.string(),clientId:mt.string().optional(),params:mt.record(mt.any()).default({}),config:mt.object({historyKey:mt.string().refine(t=>t.replace(/-/g,"_")).nullable().default("main"),welcomeMessage:mt.string().default("Hello! How can I help you today?"),focusOnOpen:mt.boolean().default(!0),inactivityWarningMessage:mt.string().default("Are you still there? The chat will end soon if we don't hear from you."),chatEndedMessage:mt.string().default("Chat Ended"),resetEndedChatOnLoad:mt.boolean().default(!1),disableMessageRating:mt.boolean().default(!1),initialReplyMessage:mt.string().nullable().default(null),disclaimerMessage:mt.string().nullable().default(null),disclaimerPopover:mt.object({message:mt.string().nullable().default(null),agreeButtonText:mt.string().default("I Agree"),rememberDurationMinutes:mt.number().default(60*24*3)}).default({}),placement:mt.enum(["left","right"]).default("right"),openChatButton:mt.object({imageSrc:mt.string().nullable().default(null),width:mt.union([mt.string(),mt.number()]).default("48px"),height:mt.union([mt.string(),mt.number()]).default("48px"),cta:mt.string().nullable().default(null)}).default({}),chatWindow:mt.object({width:mt.enum(["sm","md","lg","xl","xxl"]).default("sm"),height:mt.enum(["sm","md","lg","xl","xxl"]).default("md"),header:mt.object({text:mt.string().nullable().default("AI Chat"),imageSrc:mt.string().nullable().default(null)}).default({}),showCloseButton:mt.boolean().default(!0)}).default({}),styles:mt.object({primaryColor:mt.string().nullable().default(null),textColor:mt.string().nullable().default(null),linkColor:mt.string().nullable().default(null),openChatButton:mt.object({backgroundColor:mt.string().nullable().default(null),iconColor:mt.string().nullable().default(null)}).default({}),header:mt.object({backgroundColor:mt.string().nullable().default(null),textColor:mt.string().nullable().default(null)}).default({}),button:mt.object({backgroundColor:mt.string().nullable().default(null),textColor:mt.string().nullable().default(null)}).default({}),messages:mt.object({user:mt.object({backgroundColor:mt.string().nullable().default(null),textColor:mt.string().nullable().default(null)}).default({}),assistant:mt.object({backgroundColor:mt.string().nullable().default(null),textColor:mt.string().nullable().default(null)}).default({})}).default({})}).default({})}).default({}),handlers:mt.object({functionCalls:mt.record(mt.function().returns(mt.union([mt.any(),mt.promise(mt.any())]))).default({}),enhancedContent:mt.record(mt.function().returns(mt.union([mt.any(),mt.promise(mt.any())]))).default({})}).default({})});var AM=Object.defineProperty,OM=Object.getOwnPropertyDescriptor,uu=(t,e,r,n)=>{for(var i=n>1?void 0:n?OM(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&AM(e,r,i),i};let ns=class extends Pn{constructor(){super(...arguments),this.isOpen=!1,this.ctaClosed=!1,this.onResizeHandler=()=>{this.isOpen&&window.innerWidth<768?(rP(this,{allowTouchMove:t=>t.nodeName==="IAI-CHAT-POPUP"}),this.isIosDevice||(document.documentElement.style.overflow="hidden")):(q0(this),this.isIosDevice||(document.documentElement.style.overflow=this.initialHtmlOverflow))}}connectedCallback(){super.connectedCallback(),this.cleanOptions=pf.parse(this.options),this.identifyIosDevice(),this.setInitialHtmlOverflow(),this.initialScrollPosition={x:0,y:0},this.onResizeHandler(),window.addEventListener("resize",this.onResizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),q0(this),window.removeEventListener("resize",this.onResizeHandler)}render(){const{placement:t,chatWindow:e}=this.cleanOptions.config,{height:r,cta:n}=this.cleanOptions.config.openChatButton,i=MP("chat-widget w-dvw h-dvh md:mx-8",xM[e.width],RM[e.height],this.isOpen?"":"invisible");return nr`
388
+ */function ha(t,e,r){return t?e(t):r==null?void 0:r(t)}const fv="-",nP=t=>{const e=aP(t),{conflictingClassGroups:r,conflictingClassGroupModifiers:n}=t;return{getClassGroupId:i=>{const a=i.split(fv);return a[0]===""&&a.length!==1&&a.shift(),V0(a,e)||iP(i)},getConflictingClassGroupIds:(i,a)=>{const s=r[i]||[];return a&&n[i]?[...s,...n[i]]:s}}},V0=(t,e)=>{var r;if(t.length===0)return e.classGroupId;const n=t[0],i=e.nextPart.get(n),a=i?V0(t.slice(1),i):void 0;if(a)return a;if(e.validators.length===0)return;const s=t.join(fv);return(r=e.validators.find(({validator:o})=>o(s)))==null?void 0:r.classGroupId},W0=/^\[(.+)\]$/,iP=t=>{if(W0.test(t)){const e=W0.exec(t)[1],r=e==null?void 0:e.substring(0,e.indexOf(":"));if(r)return"arbitrary.."+r}},aP=t=>{const{theme:e,prefix:r}=t,n={nextPart:new Map,validators:[]};return oP(Object.entries(t.classGroups),r).forEach(([i,a])=>{hv(a,n,i,e)}),n},hv=(t,e,r,n)=>{t.forEach(i=>{if(typeof i=="string"){const a=i===""?e:Z0(e,i);a.classGroupId=r;return}if(typeof i=="function"){if(sP(i)){hv(i(n),e,r,n);return}e.validators.push({validator:i,classGroupId:r});return}Object.entries(i).forEach(([a,s])=>{hv(s,Z0(e,a),r,n)})})},Z0=(t,e)=>{let r=t;return e.split(fv).forEach(n=>{r.nextPart.has(n)||r.nextPart.set(n,{nextPart:new Map,validators:[]}),r=r.nextPart.get(n)}),r},sP=t=>t.isThemeGetter,oP=(t,e)=>e?t.map(([r,n])=>{const i=n.map(a=>typeof a=="string"?e+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([s,o])=>[e+s,o])):a);return[r,i]}):t,uP=t=>{if(t<1)return{get:()=>{},set:()=>{}};let e=0,r=new Map,n=new Map;const i=(a,s)=>{r.set(a,s),e++,e>t&&(e=0,n=r,r=new Map)};return{get(a){let s=r.get(a);if(s!==void 0)return s;if((s=n.get(a))!==void 0)return i(a,s),s},set(a,s){r.has(a)?r.set(a,s):i(a,s)}}},G0="!",lP=t=>{const{separator:e,experimentalParseClassName:r}=t,n=e.length===1,i=e[0],a=e.length,s=o=>{const u=[];let l=0,c=0,d;for(let N=0;N<o.length;N++){let z=o[N];if(l===0){if(z===i&&(n||o.slice(N,N+a)===e)){u.push(o.slice(c,N)),c=N+a;continue}if(z==="/"){d=N;continue}}z==="["?l++:z==="]"&&l--}const f=u.length===0?o:o.substring(c),m=f.startsWith(G0),k=m?f.substring(1):f,L=d&&d>c?d-c:void 0;return{modifiers:u,hasImportantModifier:m,baseClassName:k,maybePostfixModifierPosition:L}};return r?o=>r({className:o,parseClassName:s}):s},cP=t=>{if(t.length<=1)return t;const e=[];let r=[];return t.forEach(n=>{n[0]==="["?(e.push(...r.sort(),n),r=[]):r.push(n)}),e.push(...r.sort()),e},dP=t=>({cache:uP(t.cacheSize),parseClassName:lP(t),...nP(t)}),fP=/\s+/,hP=(t,e)=>{const{parseClassName:r,getClassGroupId:n,getConflictingClassGroupIds:i}=e,a=[],s=t.trim().split(fP);let o="";for(let u=s.length-1;u>=0;u-=1){const l=s[u],{modifiers:c,hasImportantModifier:d,baseClassName:f,maybePostfixModifierPosition:m}=r(l);let k=!!m,L=n(k?f.substring(0,m):f);if(!L){if(!k){o=l+(o.length>0?" "+o:o);continue}if(L=n(f),!L){o=l+(o.length>0?" "+o:o);continue}k=!1}const N=cP(c).join(":"),z=d?N+G0:N,re=z+L;if(a.includes(re))continue;a.push(re);const Me=i(L,k);for(let Oe=0;Oe<Me.length;++Oe){const Fe=Me[Oe];a.push(z+Fe)}o=l+(o.length>0?" "+o:o)}return o};function pP(){let t=0,e,r,n="";for(;t<arguments.length;)(e=arguments[t++])&&(r=K0(e))&&(n&&(n+=" "),n+=r);return n}const K0=t=>{if(typeof t=="string")return t;let e,r="";for(let n=0;n<t.length;n++)t[n]&&(e=K0(t[n]))&&(r&&(r+=" "),r+=e);return r};function vP(t,...e){let r,n,i,a=s;function s(u){const l=e.reduce((c,d)=>d(c),t());return r=dP(l),n=r.cache.get,i=r.cache.set,a=o,o(u)}function o(u){const l=n(u);if(l)return l;const c=hP(u,r);return i(u,c),c}return function(){return a(pP.apply(null,arguments))}}const Dr=t=>{const e=r=>r[t]||[];return e.isThemeGetter=!0,e},Y0=/^\[(?:([a-z-]+):)?(.+)\]$/i,gP=/^\d+\/\d+$/,mP=new Set(["px","full","screen"]),yP=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,bP=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,wP=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,_P=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,kP=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,pa=t=>ru(t)||mP.has(t)||gP.test(t),Ja=t=>nu(t,"length",RP),ru=t=>!!t&&!Number.isNaN(Number(t)),pv=t=>nu(t,"number",ru),ql=t=>!!t&&Number.isInteger(Number(t)),SP=t=>t.endsWith("%")&&ru(t.slice(0,-1)),ir=t=>Y0.test(t),Qa=t=>yP.test(t),$P=new Set(["length","size","percentage"]),TP=t=>nu(t,$P,J0),CP=t=>nu(t,"position",J0),EP=new Set(["image","url"]),IP=t=>nu(t,EP,OP),xP=t=>nu(t,"",AP),Vl=()=>!0,nu=(t,e,r)=>{const n=Y0.exec(t);return n?n[1]?typeof e=="string"?n[1]===e:e.has(n[1]):r(n[2]):!1},RP=t=>bP.test(t)&&!wP.test(t),J0=()=>!1,AP=t=>_P.test(t),OP=t=>kP.test(t),PP=()=>{const t=Dr("colors"),e=Dr("spacing"),r=Dr("blur"),n=Dr("brightness"),i=Dr("borderColor"),a=Dr("borderRadius"),s=Dr("borderSpacing"),o=Dr("borderWidth"),u=Dr("contrast"),l=Dr("grayscale"),c=Dr("hueRotate"),d=Dr("invert"),f=Dr("gap"),m=Dr("gradientColorStops"),k=Dr("gradientColorStopPositions"),L=Dr("inset"),N=Dr("margin"),z=Dr("opacity"),re=Dr("padding"),Me=Dr("saturate"),Oe=Dr("scale"),Fe=Dr("sepia"),Pe=Dr("skew"),Ze=Dr("space"),Z=Dr("translate"),Ie=()=>["auto","contain","none"],_e=()=>["auto","hidden","clip","visible","scroll"],se=()=>["auto",ir,e],Te=()=>[ir,e],te=()=>["",pa,Ja],oe=()=>["auto",ru,ir],q=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],ne=()=>["solid","dashed","dotted","double","none"],Se=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],H=()=>["start","end","center","between","around","evenly","stretch"],ye=()=>["","0",ir],ke=()=>["auto","avoid","all","avoid-page","page","left","right","column"],P=()=>[ru,ir];return{cacheSize:500,separator:":",theme:{colors:[Vl],spacing:[pa,Ja],blur:["none","",Qa,ir],brightness:P(),borderColor:[t],borderRadius:["none","","full",Qa,ir],borderSpacing:Te(),borderWidth:te(),contrast:P(),grayscale:ye(),hueRotate:P(),invert:ye(),gap:Te(),gradientColorStops:[t],gradientColorStopPositions:[SP,Ja],inset:se(),margin:se(),opacity:P(),padding:Te(),saturate:P(),scale:P(),sepia:ye(),skew:P(),space:Te(),translate:Te()},classGroups:{aspect:[{aspect:["auto","square","video",ir]}],container:["container"],columns:[{columns:[Qa]}],"break-after":[{"break-after":ke()}],"break-before":[{"break-before":ke()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...q(),ir]}],overflow:[{overflow:_e()}],"overflow-x":[{"overflow-x":_e()}],"overflow-y":[{"overflow-y":_e()}],overscroll:[{overscroll:Ie()}],"overscroll-x":[{"overscroll-x":Ie()}],"overscroll-y":[{"overscroll-y":Ie()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[L]}],"inset-x":[{"inset-x":[L]}],"inset-y":[{"inset-y":[L]}],start:[{start:[L]}],end:[{end:[L]}],top:[{top:[L]}],right:[{right:[L]}],bottom:[{bottom:[L]}],left:[{left:[L]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ql,ir]}],basis:[{basis:se()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",ir]}],grow:[{grow:ye()}],shrink:[{shrink:ye()}],order:[{order:["first","last","none",ql,ir]}],"grid-cols":[{"grid-cols":[Vl]}],"col-start-end":[{col:["auto",{span:["full",ql,ir]},ir]}],"col-start":[{"col-start":oe()}],"col-end":[{"col-end":oe()}],"grid-rows":[{"grid-rows":[Vl]}],"row-start-end":[{row:["auto",{span:[ql,ir]},ir]}],"row-start":[{"row-start":oe()}],"row-end":[{"row-end":oe()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",ir]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",ir]}],gap:[{gap:[f]}],"gap-x":[{"gap-x":[f]}],"gap-y":[{"gap-y":[f]}],"justify-content":[{justify:["normal",...H()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...H(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...H(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[re]}],px:[{px:[re]}],py:[{py:[re]}],ps:[{ps:[re]}],pe:[{pe:[re]}],pt:[{pt:[re]}],pr:[{pr:[re]}],pb:[{pb:[re]}],pl:[{pl:[re]}],m:[{m:[N]}],mx:[{mx:[N]}],my:[{my:[N]}],ms:[{ms:[N]}],me:[{me:[N]}],mt:[{mt:[N]}],mr:[{mr:[N]}],mb:[{mb:[N]}],ml:[{ml:[N]}],"space-x":[{"space-x":[Ze]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[Ze]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",ir,e]}],"min-w":[{"min-w":[ir,e,"min","max","fit"]}],"max-w":[{"max-w":[ir,e,"none","full","min","max","fit","prose",{screen:[Qa]},Qa]}],h:[{h:[ir,e,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[ir,e,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[ir,e,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[ir,e,"auto","min","max","fit"]}],"font-size":[{text:["base",Qa,Ja]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",pv]}],"font-family":[{font:[Vl]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractons"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",ir]}],"line-clamp":[{"line-clamp":["none",ru,pv]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",pa,ir]}],"list-image":[{"list-image":["none",ir]}],"list-style-type":[{list:["none","disc","decimal",ir]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[t]}],"placeholder-opacity":[{"placeholder-opacity":[z]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[t]}],"text-opacity":[{"text-opacity":[z]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...ne(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",pa,Ja]}],"underline-offset":[{"underline-offset":["auto",pa,ir]}],"text-decoration-color":[{decoration:[t]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:Te()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",ir]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",ir]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[z]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...q(),CP]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",TP]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},IP]}],"bg-color":[{bg:[t]}],"gradient-from-pos":[{from:[k]}],"gradient-via-pos":[{via:[k]}],"gradient-to-pos":[{to:[k]}],"gradient-from":[{from:[m]}],"gradient-via":[{via:[m]}],"gradient-to":[{to:[m]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[o]}],"border-w-x":[{"border-x":[o]}],"border-w-y":[{"border-y":[o]}],"border-w-s":[{"border-s":[o]}],"border-w-e":[{"border-e":[o]}],"border-w-t":[{"border-t":[o]}],"border-w-r":[{"border-r":[o]}],"border-w-b":[{"border-b":[o]}],"border-w-l":[{"border-l":[o]}],"border-opacity":[{"border-opacity":[z]}],"border-style":[{border:[...ne(),"hidden"]}],"divide-x":[{"divide-x":[o]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[o]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[z]}],"divide-style":[{divide:ne()}],"border-color":[{border:[i]}],"border-color-x":[{"border-x":[i]}],"border-color-y":[{"border-y":[i]}],"border-color-t":[{"border-t":[i]}],"border-color-r":[{"border-r":[i]}],"border-color-b":[{"border-b":[i]}],"border-color-l":[{"border-l":[i]}],"divide-color":[{divide:[i]}],"outline-style":[{outline:["",...ne()]}],"outline-offset":[{"outline-offset":[pa,ir]}],"outline-w":[{outline:[pa,Ja]}],"outline-color":[{outline:[t]}],"ring-w":[{ring:te()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[t]}],"ring-opacity":[{"ring-opacity":[z]}],"ring-offset-w":[{"ring-offset":[pa,Ja]}],"ring-offset-color":[{"ring-offset":[t]}],shadow:[{shadow:["","inner","none",Qa,xP]}],"shadow-color":[{shadow:[Vl]}],opacity:[{opacity:[z]}],"mix-blend":[{"mix-blend":[...Se(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":Se()}],filter:[{filter:["","none"]}],blur:[{blur:[r]}],brightness:[{brightness:[n]}],contrast:[{contrast:[u]}],"drop-shadow":[{"drop-shadow":["","none",Qa,ir]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[c]}],invert:[{invert:[d]}],saturate:[{saturate:[Me]}],sepia:[{sepia:[Fe]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[r]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[u]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[c]}],"backdrop-invert":[{"backdrop-invert":[d]}],"backdrop-opacity":[{"backdrop-opacity":[z]}],"backdrop-saturate":[{"backdrop-saturate":[Me]}],"backdrop-sepia":[{"backdrop-sepia":[Fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[s]}],"border-spacing-x":[{"border-spacing-x":[s]}],"border-spacing-y":[{"border-spacing-y":[s]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",ir]}],duration:[{duration:P()}],ease:[{ease:["linear","in","out","in-out",ir]}],delay:[{delay:P()}],animate:[{animate:["none","spin","ping","pulse","bounce",ir]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[Oe]}],"scale-x":[{"scale-x":[Oe]}],"scale-y":[{"scale-y":[Oe]}],rotate:[{rotate:[ql,ir]}],"translate-x":[{"translate-x":[Z]}],"translate-y":[{"translate-y":[Z]}],"skew-x":[{"skew-x":[Pe]}],"skew-y":[{"skew-y":[Pe]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",ir]}],accent:[{accent:["auto",t]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",ir]}],"caret-color":[{caret:[t]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":Te()}],"scroll-mx":[{"scroll-mx":Te()}],"scroll-my":[{"scroll-my":Te()}],"scroll-ms":[{"scroll-ms":Te()}],"scroll-me":[{"scroll-me":Te()}],"scroll-mt":[{"scroll-mt":Te()}],"scroll-mr":[{"scroll-mr":Te()}],"scroll-mb":[{"scroll-mb":Te()}],"scroll-ml":[{"scroll-ml":Te()}],"scroll-p":[{"scroll-p":Te()}],"scroll-px":[{"scroll-px":Te()}],"scroll-py":[{"scroll-py":Te()}],"scroll-ps":[{"scroll-ps":Te()}],"scroll-pe":[{"scroll-pe":Te()}],"scroll-pt":[{"scroll-pt":Te()}],"scroll-pr":[{"scroll-pr":Te()}],"scroll-pb":[{"scroll-pb":Te()}],"scroll-pl":[{"scroll-pl":Te()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",ir]}],fill:[{fill:[t,"none"]}],"stroke-w":[{stroke:[pa,Ja,pv]}],stroke:[{stroke:[t,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},MP=vP(PP);var NP=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Q0(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var vv={};(function(t){function e(o){o&&o.options&&clearTimeout(o.options.timer)}function r(o,u,l,c){var d={timer:void 0,lastArgs:[]},f=function(){for(var m=this,k=[],L=0;L<arguments.length;L++)k[L]=arguments[L];d.lastArgs=k,d.timer?clearTimeout(d.timer):u&&l.apply(this,d.lastArgs),d.timer=setTimeout(function(){u||l.apply(m,d.lastArgs),d.timer=void 0},o)};return c&&(f=f.bind(c)),f.options=d,f}function n(o,u,l,c){var d;Object.defineProperty(l,c,{configurable:!0,enumerable:!1,get:function(){return d},set:function(f){d=r(o,u,f,this)}})}function i(o,u,l){var c=l.value;return l.value=r(o,u,c),l}function a(o,u){for(var l=[],c=2;c<arguments.length;c++)l[c-2]=arguments[c];if(l.length===0)throw new Error("function applied debounce decorator should be a method");if(l.length===1)throw new Error("method applied debounce decorator should have valid name");var d=l[0],f=l[1],m=l.length===3&&l[2]?l[2]:Object.getOwnPropertyDescriptor(d,f);if(m)return i(o,u,m);n(o,u,d,f)}function s(){for(var o=[],u=0;u<arguments.length;u++)o[u]=arguments[u];var l=500,c=!1;if(o.length&&(typeof o[0]=="number"||typeof o[0]=="object"&&o[0].leading!==void 0)){typeof o[0]=="number"&&(l=o[0]);var d=void 0;return typeof o[0]=="object"&&o[0].leading!==void 0&&(d=o[0]),1<o.length&&typeof o[1]=="object"&&o[1].leading!==void 0&&(d=o[1]),d&&(c=d.leading),function(){for(var f=[],m=0;m<arguments.length;m++)f[m]=arguments[m];return a.apply(void 0,[l,c].concat(f))}}return a.apply(void 0,[l,c].concat(o))}Object.defineProperty(t,"__esModule",{value:!0}),t.cancel=e,t.debounce=s})(vv);var gr;(function(t){t.assertEqual=i=>i;function e(i){}t.assertIs=e;function r(i){throw new Error}t.assertNever=r,t.arrayToEnum=i=>{const a={};for(const s of i)a[s]=s;return a},t.getValidEnumValues=i=>{const a=t.objectKeys(i).filter(o=>typeof i[i[o]]!="number"),s={};for(const o of a)s[o]=i[o];return t.objectValues(s)},t.objectValues=i=>t.objectKeys(i).map(function(a){return i[a]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const a=[];for(const s in i)Object.prototype.hasOwnProperty.call(i,s)&&a.push(s);return a},t.find=(i,a)=>{for(const s of i)if(a(s))return s},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(s=>typeof s=="string"?`'${s}'`:s).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a})(gr||(gr={}));var gv;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(gv||(gv={}));const gt=gr.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Xa=t=>{switch(typeof t){case"undefined":return gt.undefined;case"string":return gt.string;case"number":return isNaN(t)?gt.nan:gt.number;case"boolean":return gt.boolean;case"function":return gt.function;case"bigint":return gt.bigint;case"symbol":return gt.symbol;case"object":return Array.isArray(t)?gt.array:t===null?gt.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?gt.promise:typeof Map<"u"&&t instanceof Map?gt.map:typeof Set<"u"&&t instanceof Set?gt.set:typeof Date<"u"&&t instanceof Date?gt.date:gt.object;default:return gt.unknown}},at=gr.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"]),LP=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class yi extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const r=e||function(a){return a.message},n={_errors:[]},i=a=>{for(const s of a.issues)if(s.code==="invalid_union")s.unionErrors.map(i);else if(s.code==="invalid_return_type")i(s.returnTypeError);else if(s.code==="invalid_arguments")i(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,u=0;for(;u<s.path.length;){const l=s.path[u];u===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],u++}}};return i(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,gr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const i of this.issues)i.path.length>0?(r[i.path[0]]=r[i.path[0]]||[],r[i.path[0]].push(e(i))):n.push(e(i));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}yi.create=t=>new yi(t);const Wl=(t,e)=>{let r;switch(t.code){case at.invalid_type:t.received===gt.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case at.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,gr.jsonStringifyReplacer)}`;break;case at.unrecognized_keys:r=`Unrecognized key(s) in object: ${gr.joinValues(t.keys,", ")}`;break;case at.invalid_union:r="Invalid input";break;case at.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${gr.joinValues(t.options)}`;break;case at.invalid_enum_value:r=`Invalid enum value. Expected ${gr.joinValues(t.options)}, received '${t.received}'`;break;case at.invalid_arguments:r="Invalid function arguments";break;case at.invalid_return_type:r="Invalid function return type";break;case at.invalid_date:r="Invalid date";break;case at.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:gr.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case at.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case at.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case at.custom:r="Invalid input";break;case at.invalid_intersection_types:r="Intersection results could not be merged";break;case at.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case at.not_finite:r="Number must be finite";break;default:r=e.defaultError,gr.assertNever(t)}return{message:r}};let X0=Wl;function DP(t){X0=t}function rf(){return X0}const nf=t=>{const{data:e,path:r,errorMaps:n,issueData:i}=t,a=[...r,...i.path||[]],s={...i,path:a};let o="";const u=n.filter(l=>!!l).slice().reverse();for(const l of u)o=l(s,{data:e,defaultError:o}).message;return{...i,path:a,message:i.message||o}},jP=[];function wt(t,e){const r=nf({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,rf(),Wl].filter(n=>!!n)});t.common.issues.push(r)}class pn{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const i of r){if(i.status==="aborted")return Qt;i.status==="dirty"&&e.dirty(),n.push(i.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const i of r)n.push({key:await i.key,value:await i.value});return pn.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const i of r){const{key:a,value:s}=i;if(a.status==="aborted"||s.status==="aborted")return Qt;a.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof s.value<"u"||i.alwaysSet)&&(n[a.value]=s.value)}return{status:e.value,value:n}}}const Qt=Object.freeze({status:"aborted"}),e_=t=>({status:"dirty",value:t}),Sn=t=>({status:"valid",value:t}),mv=t=>t.status==="aborted",yv=t=>t.status==="dirty",Zl=t=>t.status==="valid",af=t=>typeof Promise<"u"&&t instanceof Promise;var Lt;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Lt||(Lt={}));class Fi{constructor(e,r,n,i){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const t_=(t,e)=>{if(Zl(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new yi(t.common.issues);return this._error=r,this._error}}};function rr(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:i}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(a,s)=>a.code!=="invalid_type"?{message:s.defaultError}:typeof s.data>"u"?{message:n??s.defaultError}:{message:r??s.defaultError},description:i}}class or{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)}get description(){return this._def.description}_getType(e){return Xa(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:Xa(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new pn,ctx:{common:e.parent.common,data:e.data,parsedType:Xa(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(af(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){var n;const i={common:{issues:[],async:(n=r==null?void 0:r.async)!==null&&n!==void 0?n:!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xa(e)},a=this._parseSync({data:e,path:i.path,parent:i});return t_(i,a)}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Xa(e)},i=this._parse({data:e,path:n.path,parent:n}),a=await(af(i)?i:Promise.resolve(i));return t_(n,a)}refine(e,r){const n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{const s=e(i),o=()=>a.addIssue({code:at.custom,...n(i)});return typeof Promise<"u"&&s instanceof Promise?s.then(u=>u?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,i)=>e(n)?!0:(i.addIssue(typeof r=="function"?r(n,i):r),!1))}_refinement(e){return new _i({schema:this,typeName:Ft.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ga.create(this,this._def)}nullable(){return no.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return wi.create(this,this._def)}promise(){return ou.create(this,this._def)}or(e){return Jl.create([this,e],this._def)}and(e){return Ql.create(this,e,this._def)}transform(e){return new _i({...rr(this._def),schema:this,typeName:Ft.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new nc({...rr(this._def),innerType:this,defaultValue:r,typeName:Ft.ZodDefault})}brand(){return new n_({typeName:Ft.ZodBranded,type:this,...rr(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new df({...rr(this._def),innerType:this,catchValue:r,typeName:Ft.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return ic.create(this,e)}readonly(){return hf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const UP=/^c[^\s-]{8,}$/i,FP=/^[a-z][a-z0-9]*$/,BP=/^[0-9A-HJKMNP-TV-Z]{26}$/,zP=/^[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,HP=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,qP="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let bv;const VP=/^(((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}))$/,WP=/^(([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})))$/,ZP=t=>t.precision?t.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${t.precision}}Z$`):t.precision===0?t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):t.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function GP(t,e){return!!((e==="v4"||!e)&&VP.test(t)||(e==="v6"||!e)&&WP.test(t))}class bi extends or{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==gt.string){const i=this._getOrReturnCtx(e);return wt(i,{code:at.invalid_type,expected:gt.string,received:i.parsedType}),Qt}const r=new pn;let n;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(n=this._getOrReturnCtx(e,n),wt(n,{code:at.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="max")e.data.length>i.value&&(n=this._getOrReturnCtx(e,n),wt(n,{code:at.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),r.dirty());else if(i.kind==="length"){const a=e.data.length>i.value,s=e.data.length<i.value;(a||s)&&(n=this._getOrReturnCtx(e,n),a?wt(n,{code:at.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):s&&wt(n,{code:at.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),r.dirty())}else if(i.kind==="email")HP.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"email",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="emoji")bv||(bv=new RegExp(qP,"u")),bv.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"emoji",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="uuid")zP.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"uuid",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid")UP.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"cuid",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="cuid2")FP.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"cuid2",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="ulid")BP.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"ulid",code:at.invalid_string,message:i.message}),r.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),wt(n,{validation:"url",code:at.invalid_string,message:i.message}),r.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"regex",code:at.invalid_string,message:i.message}),r.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(n=this._getOrReturnCtx(e,n),wt(n,{code:at.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),r.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(n=this._getOrReturnCtx(e,n),wt(n,{code:at.invalid_string,validation:{startsWith:i.value},message:i.message}),r.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(n=this._getOrReturnCtx(e,n),wt(n,{code:at.invalid_string,validation:{endsWith:i.value},message:i.message}),r.dirty()):i.kind==="datetime"?ZP(i).test(e.data)||(n=this._getOrReturnCtx(e,n),wt(n,{code:at.invalid_string,validation:"datetime",message:i.message}),r.dirty()):i.kind==="ip"?GP(e.data,i.version)||(n=this._getOrReturnCtx(e,n),wt(n,{validation:"ip",code:at.invalid_string,message:i.message}),r.dirty()):gr.assertNever(i);return{status:r.value,value:e.data}}_regex(e,r,n){return this.refinement(i=>e.test(i),{validation:r,code:at.invalid_string,...Lt.errToObj(n)})}_addCheck(e){return new bi({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Lt.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Lt.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Lt.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Lt.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Lt.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Lt.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Lt.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Lt.errToObj(e)})}datetime(e){var r;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(r=e==null?void 0:e.offset)!==null&&r!==void 0?r:!1,...Lt.errToObj(e==null?void 0:e.message)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...Lt.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...Lt.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...Lt.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...Lt.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...Lt.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...Lt.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...Lt.errToObj(r)})}nonempty(e){return this.min(1,Lt.errToObj(e))}trim(){return new bi({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new bi({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new bi({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}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 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 minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}bi.create=t=>{var e;return new bi({checks:[],typeName:Ft.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...rr(t)})};function KP(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,i=r>n?r:n,a=parseInt(t.toFixed(i).replace(".","")),s=parseInt(e.toFixed(i).replace(".",""));return a%s/Math.pow(10,i)}class es extends or{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)!==gt.number){const i=this._getOrReturnCtx(e);return wt(i,{code:at.invalid_type,expected:gt.number,received:i.parsedType}),Qt}let r;const n=new pn;for(const i of this._def.checks)i.kind==="int"?gr.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),wt(r,{code:at.invalid_type,expected:"integer",received:"float",message:i.message}),n.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),n.dirty()):i.kind==="multipleOf"?KP(e.data,i.value)!==0&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),wt(r,{code:at.not_finite,message:i.message}),n.dirty()):gr.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Lt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Lt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Lt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Lt.toString(r))}setLimit(e,r,n,i){return new es({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Lt.toString(i)}]})}_addCheck(e){return new es({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Lt.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Lt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Lt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Lt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Lt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Lt.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:Lt.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Lt.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Lt.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&gr.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}es.create=t=>new es({checks:[],typeName:Ft.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...rr(t)});class ts extends or{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==gt.bigint){const i=this._getOrReturnCtx(e);return wt(i,{code:at.invalid_type,expected:gt.bigint,received:i.parsedType}),Qt}let r;const n=new pn;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),wt(r,{code:at.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):gr.assertNever(i);return{status:n.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,Lt.toString(r))}gt(e,r){return this.setLimit("min",e,!1,Lt.toString(r))}lte(e,r){return this.setLimit("max",e,!0,Lt.toString(r))}lt(e,r){return this.setLimit("max",e,!1,Lt.toString(r))}setLimit(e,r,n,i){return new ts({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:Lt.toString(i)}]})}_addCheck(e){return new ts({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Lt.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Lt.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Lt.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Lt.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:Lt.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}ts.create=t=>{var e;return new ts({checks:[],typeName:Ft.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...rr(t)})};class Gl extends or{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==gt.boolean){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.boolean,received:r.parsedType}),Qt}return Sn(e.data)}}Gl.create=t=>new Gl({typeName:Ft.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...rr(t)});class eo extends or{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==gt.date){const i=this._getOrReturnCtx(e);return wt(i,{code:at.invalid_type,expected:gt.date,received:i.parsedType}),Qt}if(isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return wt(i,{code:at.invalid_date}),Qt}const r=new pn;let n;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(n=this._getOrReturnCtx(e,n),wt(n,{code:at.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),r.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(n=this._getOrReturnCtx(e,n),wt(n,{code:at.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),r.dirty()):gr.assertNever(i);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new eo({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:Lt.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:Lt.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}eo.create=t=>new eo({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:Ft.ZodDate,...rr(t)});class sf extends or{_parse(e){if(this._getType(e)!==gt.symbol){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.symbol,received:r.parsedType}),Qt}return Sn(e.data)}}sf.create=t=>new sf({typeName:Ft.ZodSymbol,...rr(t)});class Kl extends or{_parse(e){if(this._getType(e)!==gt.undefined){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.undefined,received:r.parsedType}),Qt}return Sn(e.data)}}Kl.create=t=>new Kl({typeName:Ft.ZodUndefined,...rr(t)});class Yl extends or{_parse(e){if(this._getType(e)!==gt.null){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.null,received:r.parsedType}),Qt}return Sn(e.data)}}Yl.create=t=>new Yl({typeName:Ft.ZodNull,...rr(t)});class iu extends or{constructor(){super(...arguments),this._any=!0}_parse(e){return Sn(e.data)}}iu.create=t=>new iu({typeName:Ft.ZodAny,...rr(t)});class to extends or{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Sn(e.data)}}to.create=t=>new to({typeName:Ft.ZodUnknown,...rr(t)});class va extends or{_parse(e){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.never,received:r.parsedType}),Qt}}va.create=t=>new va({typeName:Ft.ZodNever,...rr(t)});class of extends or{_parse(e){if(this._getType(e)!==gt.undefined){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.void,received:r.parsedType}),Qt}return Sn(e.data)}}of.create=t=>new of({typeName:Ft.ZodVoid,...rr(t)});class wi extends or{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),i=this._def;if(r.parsedType!==gt.array)return wt(r,{code:at.invalid_type,expected:gt.array,received:r.parsedType}),Qt;if(i.exactLength!==null){const s=r.data.length>i.exactLength.value,o=r.data.length<i.exactLength.value;(s||o)&&(wt(r,{code:s?at.too_big:at.too_small,minimum:o?i.exactLength.value:void 0,maximum:s?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),n.dirty())}if(i.minLength!==null&&r.data.length<i.minLength.value&&(wt(r,{code:at.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(wt(r,{code:at.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>i.type._parseAsync(new Fi(r,s,r.path,o)))).then(s=>pn.mergeArray(n,s));const a=[...r.data].map((s,o)=>i.type._parseSync(new Fi(r,s,r.path,o)));return pn.mergeArray(n,a)}get element(){return this._def.type}min(e,r){return new wi({...this._def,minLength:{value:e,message:Lt.toString(r)}})}max(e,r){return new wi({...this._def,maxLength:{value:e,message:Lt.toString(r)}})}length(e,r){return new wi({...this._def,exactLength:{value:e,message:Lt.toString(r)}})}nonempty(e){return this.min(1,e)}}wi.create=(t,e)=>new wi({type:t,minLength:null,maxLength:null,exactLength:null,typeName:Ft.ZodArray,...rr(e)});function au(t){if(t instanceof Vr){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=ga.create(au(n))}return new Vr({...t._def,shape:()=>e})}else return t instanceof wi?new wi({...t._def,type:au(t.element)}):t instanceof ga?ga.create(au(t.unwrap())):t instanceof no?no.create(au(t.unwrap())):t instanceof Bi?Bi.create(t.items.map(e=>au(e))):t}class Vr extends or{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=gr.objectKeys(e);return this._cached={shape:e,keys:r}}_parse(e){if(this._getType(e)!==gt.object){const u=this._getOrReturnCtx(e);return wt(u,{code:at.invalid_type,expected:gt.object,received:u.parsedType}),Qt}const{status:r,ctx:n}=this._processInputParams(e),{shape:i,keys:a}=this._getCached(),s=[];if(!(this._def.catchall instanceof va&&this._def.unknownKeys==="strip"))for(const u in n.data)a.includes(u)||s.push(u);const o=[];for(const u of a){const l=i[u],c=n.data[u];o.push({key:{status:"valid",value:u},value:l._parse(new Fi(n,c,n.path,u)),alwaysSet:u in n.data})}if(this._def.catchall instanceof va){const u=this._def.unknownKeys;if(u==="passthrough")for(const l of s)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(u==="strict")s.length>0&&(wt(n,{code:at.unrecognized_keys,keys:s}),r.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const l of s){const c=n.data[l];o.push({key:{status:"valid",value:l},value:u._parse(new Fi(n,c,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const u=[];for(const l of o){const c=await l.key;u.push({key:c,value:await l.value,alwaysSet:l.alwaysSet})}return u}).then(u=>pn.mergeObjectSync(r,u)):pn.mergeObjectSync(r,o)}get shape(){return this._def.shape()}strict(e){return Lt.errToObj,new Vr({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,a,s,o;const u=(s=(a=(i=this._def).errorMap)===null||a===void 0?void 0:a.call(i,r,n).message)!==null&&s!==void 0?s:n.defaultError;return r.code==="unrecognized_keys"?{message:(o=Lt.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new Vr({...this._def,unknownKeys:"strip"})}passthrough(){return new Vr({...this._def,unknownKeys:"passthrough"})}extend(e){return new Vr({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Vr({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Ft.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new Vr({...this._def,catchall:e})}pick(e){const r={};return gr.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(r[n]=this.shape[n])}),new Vr({...this._def,shape:()=>r})}omit(e){const r={};return gr.objectKeys(this.shape).forEach(n=>{e[n]||(r[n]=this.shape[n])}),new Vr({...this._def,shape:()=>r})}deepPartial(){return au(this)}partial(e){const r={};return gr.objectKeys(this.shape).forEach(n=>{const i=this.shape[n];e&&!e[n]?r[n]=i:r[n]=i.optional()}),new Vr({...this._def,shape:()=>r})}required(e){const r={};return gr.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof ga;)i=i._def.innerType;r[n]=i}}),new Vr({...this._def,shape:()=>r})}keyof(){return r_(gr.objectKeys(this.shape))}}Vr.create=(t,e)=>new Vr({shape:()=>t,unknownKeys:"strip",catchall:va.create(),typeName:Ft.ZodObject,...rr(e)}),Vr.strictCreate=(t,e)=>new Vr({shape:()=>t,unknownKeys:"strict",catchall:va.create(),typeName:Ft.ZodObject,...rr(e)}),Vr.lazycreate=(t,e)=>new Vr({shape:t,unknownKeys:"strip",catchall:va.create(),typeName:Ft.ZodObject,...rr(e)});class Jl extends or{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function i(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=a.map(o=>new yi(o.ctx.common.issues));return wt(r,{code:at.invalid_union,unionErrors:s}),Qt}if(r.common.async)return Promise.all(n.map(async a=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await a._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(i);{let a;const s=[];for(const u of n){const l={...r,common:{...r.common,issues:[]},parent:null},c=u._parseSync({data:r.data,path:r.path,parent:l});if(c.status==="valid")return c;c.status==="dirty"&&!a&&(a={result:c,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;const o=s.map(u=>new yi(u));return wt(r,{code:at.invalid_union,unionErrors:o}),Qt}}get options(){return this._def.options}}Jl.create=(t,e)=>new Jl({options:t,typeName:Ft.ZodUnion,...rr(e)});const uf=t=>t instanceof ec?uf(t.schema):t instanceof _i?uf(t.innerType()):t instanceof tc?[t.value]:t instanceof rs?t.options:t instanceof rc?Object.keys(t.enum):t instanceof nc?uf(t._def.innerType):t instanceof Kl?[void 0]:t instanceof Yl?[null]:null;class lf extends or{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.object)return wt(r,{code:at.invalid_type,expected:gt.object,received:r.parsedType}),Qt;const n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(wt(r,{code:at.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),Qt)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const i=new Map;for(const a of r){const s=uf(a.shape[e]);if(!s)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(i.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);i.set(o,a)}}return new lf({typeName:Ft.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i,...rr(n)})}}function wv(t,e){const r=Xa(t),n=Xa(e);if(t===e)return{valid:!0,data:t};if(r===gt.object&&n===gt.object){const i=gr.objectKeys(e),a=gr.objectKeys(t).filter(o=>i.indexOf(o)!==-1),s={...t,...e};for(const o of a){const u=wv(t[o],e[o]);if(!u.valid)return{valid:!1};s[o]=u.data}return{valid:!0,data:s}}else if(r===gt.array&&n===gt.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let a=0;a<t.length;a++){const s=t[a],o=e[a],u=wv(s,o);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return r===gt.date&&n===gt.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Ql extends or{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=(a,s)=>{if(mv(a)||mv(s))return Qt;const o=wv(a.value,s.value);return o.valid?((yv(a)||yv(s))&&r.dirty(),{status:r.value,value:o.data}):(wt(n,{code:at.invalid_intersection_types}),Qt)};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(([a,s])=>i(a,s)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Ql.create=(t,e,r)=>new Ql({left:t,right:e,typeName:Ft.ZodIntersection,...rr(r)});class Bi extends or{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.array)return wt(n,{code:at.invalid_type,expected:gt.array,received:n.parsedType}),Qt;if(n.data.length<this._def.items.length)return wt(n,{code:at.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Qt;!this._def.rest&&n.data.length>this._def.items.length&&(wt(n,{code:at.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((a,s)=>{const o=this._def.items[s]||this._def.rest;return o?o._parse(new Fi(n,a,n.path,s)):null}).filter(a=>!!a);return n.common.async?Promise.all(i).then(a=>pn.mergeArray(r,a)):pn.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Bi({...this._def,rest:e})}}Bi.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Bi({items:t,typeName:Ft.ZodTuple,rest:null,...rr(e)})};class Xl extends or{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.object)return wt(n,{code:at.invalid_type,expected:gt.object,received:n.parsedType}),Qt;const i=[],a=this._def.keyType,s=this._def.valueType;for(const o in n.data)i.push({key:a._parse(new Fi(n,o,n.path,o)),value:s._parse(new Fi(n,n.data[o],n.path,o))});return n.common.async?pn.mergeObjectAsync(r,i):pn.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof or?new Xl({keyType:e,valueType:r,typeName:Ft.ZodRecord,...rr(n)}):new Xl({keyType:bi.create(),valueType:e,typeName:Ft.ZodRecord,...rr(r)})}}class cf extends or{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.map)return wt(n,{code:at.invalid_type,expected:gt.map,received:n.parsedType}),Qt;const i=this._def.keyType,a=this._def.valueType,s=[...n.data.entries()].map(([o,u],l)=>({key:i._parse(new Fi(n,o,n.path,[l,"key"])),value:a._parse(new Fi(n,u,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of s){const l=await u.key,c=await u.value;if(l.status==="aborted"||c.status==="aborted")return Qt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const u of s){const l=u.key,c=u.value;if(l.status==="aborted"||c.status==="aborted")return Qt;(l.status==="dirty"||c.status==="dirty")&&r.dirty(),o.set(l.value,c.value)}return{status:r.value,value:o}}}}cf.create=(t,e,r)=>new cf({valueType:e,keyType:t,typeName:Ft.ZodMap,...rr(r)});class ro extends or{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==gt.set)return wt(n,{code:at.invalid_type,expected:gt.set,received:n.parsedType}),Qt;const i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(wt(n,{code:at.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(wt(n,{code:at.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),r.dirty());const a=this._def.valueType;function s(u){const l=new Set;for(const c of u){if(c.status==="aborted")return Qt;c.status==="dirty"&&r.dirty(),l.add(c.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((u,l)=>a._parse(new Fi(n,u,n.path,l)));return n.common.async?Promise.all(o).then(u=>s(u)):s(o)}min(e,r){return new ro({...this._def,minSize:{value:e,message:Lt.toString(r)}})}max(e,r){return new ro({...this._def,maxSize:{value:e,message:Lt.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}ro.create=(t,e)=>new ro({valueType:t,minSize:null,maxSize:null,typeName:Ft.ZodSet,...rr(e)});class su extends or{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.function)return wt(r,{code:at.invalid_type,expected:gt.function,received:r.parsedType}),Qt;function n(o,u){return nf({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,rf(),Wl].filter(l=>!!l),issueData:{code:at.invalid_arguments,argumentsError:u}})}function i(o,u){return nf({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,rf(),Wl].filter(l=>!!l),issueData:{code:at.invalid_return_type,returnTypeError:u}})}const a={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof ou){const o=this;return Sn(async function(...u){const l=new yi([]),c=await o._def.args.parseAsync(u,a).catch(f=>{throw l.addIssue(n(u,f)),l}),d=await Reflect.apply(s,this,c);return await o._def.returns._def.type.parseAsync(d,a).catch(f=>{throw l.addIssue(i(d,f)),l})})}else{const o=this;return Sn(function(...u){const l=o._def.args.safeParse(u,a);if(!l.success)throw new yi([n(u,l.error)]);const c=Reflect.apply(s,this,l.data),d=o._def.returns.safeParse(c,a);if(!d.success)throw new yi([i(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new su({...this._def,args:Bi.create(e).rest(to.create())})}returns(e){return new su({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new su({args:e||Bi.create([]).rest(to.create()),returns:r||to.create(),typeName:Ft.ZodFunction,...rr(n)})}}class ec extends or{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}ec.create=(t,e)=>new ec({getter:t,typeName:Ft.ZodLazy,...rr(e)});class tc extends or{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return wt(r,{received:r.data,code:at.invalid_literal,expected:this._def.value}),Qt}return{status:"valid",value:e.data}}get value(){return this._def.value}}tc.create=(t,e)=>new tc({value:t,typeName:Ft.ZodLiteral,...rr(e)});function r_(t,e){return new rs({values:t,typeName:Ft.ZodEnum,...rr(e)})}class rs extends or{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return wt(r,{expected:gr.joinValues(n),received:r.parsedType,code:at.invalid_type}),Qt}if(this._def.values.indexOf(e.data)===-1){const r=this._getOrReturnCtx(e),n=this._def.values;return wt(r,{received:r.data,code:at.invalid_enum_value,options:n}),Qt}return Sn(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e){return rs.create(e)}exclude(e){return rs.create(this.options.filter(r=>!e.includes(r)))}}rs.create=r_;class rc extends or{_parse(e){const r=gr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==gt.string&&n.parsedType!==gt.number){const i=gr.objectValues(r);return wt(n,{expected:gr.joinValues(i),received:n.parsedType,code:at.invalid_type}),Qt}if(r.indexOf(e.data)===-1){const i=gr.objectValues(r);return wt(n,{received:n.data,code:at.invalid_enum_value,options:i}),Qt}return Sn(e.data)}get enum(){return this._def.values}}rc.create=(t,e)=>new rc({values:t,typeName:Ft.ZodNativeEnum,...rr(e)});class ou extends or{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==gt.promise&&r.common.async===!1)return wt(r,{code:at.invalid_type,expected:gt.promise,received:r.parsedType}),Qt;const n=r.parsedType===gt.promise?r.data:Promise.resolve(r.data);return Sn(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}}ou.create=(t,e)=>new ou({type:t,typeName:Ft.ZodPromise,...rr(e)});class _i extends or{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Ft.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),i=this._def.effect||null,a={addIssue:s=>{wt(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){const s=i.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(s).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:s,path:n.path,parent:n})}if(i.type==="refinement"){const s=o=>{const u=i.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?Qt:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?Qt:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(i.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Zl(s))return s;const o=i.transform(s.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>Zl(s)?Promise.resolve(i.transform(s.value,a)).then(o=>({status:r.value,value:o})):s);gr.assertNever(i)}}_i.create=(t,e,r)=>new _i({schema:t,typeName:Ft.ZodEffects,effect:e,...rr(r)}),_i.createWithPreprocess=(t,e,r)=>new _i({schema:e,effect:{type:"preprocess",transform:t},typeName:Ft.ZodEffects,...rr(r)});class ga extends or{_parse(e){return this._getType(e)===gt.undefined?Sn(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ga.create=(t,e)=>new ga({innerType:t,typeName:Ft.ZodOptional,...rr(e)});class no extends or{_parse(e){return this._getType(e)===gt.null?Sn(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}no.create=(t,e)=>new no({innerType:t,typeName:Ft.ZodNullable,...rr(e)});class nc extends or{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===gt.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}nc.create=(t,e)=>new nc({innerType:t,typeName:Ft.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...rr(e)});class df extends or{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return af(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new yi(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new yi(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}df.create=(t,e)=>new df({innerType:t,typeName:Ft.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...rr(e)});class ff extends or{_parse(e){if(this._getType(e)!==gt.nan){const r=this._getOrReturnCtx(e);return wt(r,{code:at.invalid_type,expected:gt.nan,received:r.parsedType}),Qt}return{status:"valid",value:e.data}}}ff.create=t=>new ff({typeName:Ft.ZodNaN,...rr(t)});const YP=Symbol("zod_brand");class n_ extends or{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class ic extends or{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Qt:i.status==="dirty"?(r.dirty(),e_(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?Qt:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(e,r){return new ic({in:e,out:r,typeName:Ft.ZodPipeline})}}class hf extends or{_parse(e){const r=this._def.innerType._parse(e);return Zl(r)&&(r.value=Object.freeze(r.value)),r}}hf.create=(t,e)=>new hf({innerType:t,typeName:Ft.ZodReadonly,...rr(e)});const i_=(t,e={},r)=>t?iu.create().superRefine((n,i)=>{var a,s;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(s=(a=o.fatal)!==null&&a!==void 0?a:r)!==null&&s!==void 0?s:!0,l=typeof o=="string"?{message:o}:o;i.addIssue({code:"custom",...l,fatal:u})}}):iu.create(),JP={object:Vr.lazycreate};var Ft;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(Ft||(Ft={}));const QP=(t,e={message:`Input not instance of ${t.name}`})=>i_(r=>r instanceof t,e),a_=bi.create,s_=es.create,XP=ff.create,eM=ts.create,o_=Gl.create,tM=eo.create,rM=sf.create,nM=Kl.create,iM=Yl.create,aM=iu.create,sM=to.create,oM=va.create,uM=of.create,lM=wi.create,cM=Vr.create,dM=Vr.strictCreate,fM=Jl.create,hM=lf.create,pM=Ql.create,vM=Bi.create,gM=Xl.create,mM=cf.create,yM=ro.create,bM=su.create,wM=ec.create,_M=tc.create,kM=rs.create,SM=rc.create,$M=ou.create,u_=_i.create,TM=ga.create,CM=no.create,EM=_i.createWithPreprocess,IM=ic.create;var mt=Object.freeze({__proto__:null,defaultErrorMap:Wl,setErrorMap:DP,getErrorMap:rf,makeIssue:nf,EMPTY_PATH:jP,addIssueToContext:wt,ParseStatus:pn,INVALID:Qt,DIRTY:e_,OK:Sn,isAborted:mv,isDirty:yv,isValid:Zl,isAsync:af,get util(){return gr},get objectUtil(){return gv},ZodParsedType:gt,getParsedType:Xa,ZodType:or,ZodString:bi,ZodNumber:es,ZodBigInt:ts,ZodBoolean:Gl,ZodDate:eo,ZodSymbol:sf,ZodUndefined:Kl,ZodNull:Yl,ZodAny:iu,ZodUnknown:to,ZodNever:va,ZodVoid:of,ZodArray:wi,ZodObject:Vr,ZodUnion:Jl,ZodDiscriminatedUnion:lf,ZodIntersection:Ql,ZodTuple:Bi,ZodRecord:Xl,ZodMap:cf,ZodSet:ro,ZodFunction:su,ZodLazy:ec,ZodLiteral:tc,ZodEnum:rs,ZodNativeEnum:rc,ZodPromise:ou,ZodEffects:_i,ZodTransformer:_i,ZodOptional:ga,ZodNullable:no,ZodDefault:nc,ZodCatch:df,ZodNaN:ff,BRAND:YP,ZodBranded:n_,ZodPipeline:ic,ZodReadonly:hf,custom:i_,Schema:or,ZodSchema:or,late:JP,get ZodFirstPartyTypeKind(){return Ft},coerce:{string:t=>bi.create({...t,coerce:!0}),number:t=>es.create({...t,coerce:!0}),boolean:t=>Gl.create({...t,coerce:!0}),bigint:t=>ts.create({...t,coerce:!0}),date:t=>eo.create({...t,coerce:!0})},any:aM,array:lM,bigint:eM,boolean:o_,date:tM,discriminatedUnion:hM,effect:u_,enum:kM,function:bM,instanceof:QP,intersection:pM,lazy:wM,literal:_M,map:mM,nan:XP,nativeEnum:SM,never:oM,null:iM,nullable:CM,number:s_,object:cM,oboolean:()=>o_().optional(),onumber:()=>s_().optional(),optional:TM,ostring:()=>a_().optional(),pipeline:IM,preprocess:EM,promise:$M,record:gM,set:yM,strictObject:dM,string:a_,symbol:rM,transformer:u_,tuple:vM,undefined:nM,union:fM,unknown:sM,void:uM,NEVER:Qt,ZodIssueCode:at,quotelessJson:LP,ZodError:yi});const xM={sm:"md:w-[350px]",md:"md:w-[500px]",lg:"md:w-[760px]",xl:"md:w-[900px]",xxl:"md:w-[1200px]"},RM={sm:"md:h-[400px]",md:"md:h-[500px]",lg:"md:h-[600px]",xl:"md:h-[700px]",xxl:"md:h-[800px]"},pf=mt.object({assistantId:mt.string(),clientId:mt.string().optional(),params:mt.record(mt.any()).default({}),config:mt.object({historyKey:mt.string().refine(t=>t.replace(/-/g,"_")).nullable().default("main"),welcomeMessage:mt.string().default("Hello! How can I help you today?"),focusOnOpen:mt.boolean().default(!0),inactivityWarningMessage:mt.string().default("Are you still there? The chat will end soon if we don't hear from you."),chatEndedMessage:mt.string().default("Chat Ended"),resetEndedChatOnLoad:mt.boolean().default(!1),disableMessageRating:mt.boolean().default(!1),initialReplyMessage:mt.string().nullable().default(null),disclaimerMessage:mt.string().nullable().default(null),disclaimerPopover:mt.object({message:mt.string().nullable().default(null),agreeButtonText:mt.string().default("I Agree"),rememberDurationMinutes:mt.number().default(60*24*3)}).default({}),placement:mt.enum(["left","right"]).default("right"),openChatButton:mt.object({imageSrc:mt.string().nullable().default(null),width:mt.union([mt.string(),mt.number()]).default("48px"),height:mt.union([mt.string(),mt.number()]).default("48px"),cta:mt.string().nullable().default(null)}).default({}),chatWindow:mt.object({width:mt.enum(["sm","md","lg","xl","xxl"]).default("sm"),height:mt.enum(["sm","md","lg","xl","xxl"]).default("md"),header:mt.object({text:mt.string().nullable().default("AI Chat"),imageSrc:mt.string().nullable().default(null)}).default({}),showCloseButton:mt.boolean().default(!0)}).default({}),styles:mt.object({primaryColor:mt.string().nullable().default(null),textColor:mt.string().nullable().default(null),linkColor:mt.string().nullable().default(null),openChatButton:mt.object({backgroundColor:mt.string().nullable().default(null),iconColor:mt.string().nullable().default(null)}).default({}),header:mt.object({backgroundColor:mt.string().nullable().default(null),textColor:mt.string().nullable().default(null)}).default({}),button:mt.object({backgroundColor:mt.string().nullable().default(null),textColor:mt.string().nullable().default(null)}).default({}),messages:mt.object({user:mt.object({backgroundColor:mt.string().nullable().default(null),textColor:mt.string().nullable().default(null)}).default({}),assistant:mt.object({backgroundColor:mt.string().nullable().default(null),textColor:mt.string().nullable().default(null)}).default({})}).default({})}).default({})}).default({}),handlers:mt.object({functionCalls:mt.record(mt.function().returns(mt.union([mt.any(),mt.promise(mt.any())]))).default({}),enhancedContent:mt.record(mt.function().returns(mt.union([mt.any(),mt.promise(mt.any())]))).default({})}).default({})});var AM=Object.defineProperty,OM=Object.getOwnPropertyDescriptor,uu=(t,e,r,n)=>{for(var i=n>1?void 0:n?OM(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&AM(e,r,i),i};let ns=class extends Pn{constructor(){super(...arguments),this.isOpen=!1,this.ctaClosed=!1,this.onResizeHandler=()=>{this.isOpen&&window.innerWidth<768?(rP(this,{allowTouchMove:t=>t.nodeName==="IAI-CHAT-POPUP"}),this.isIosDevice||(document.documentElement.style.overflow="hidden")):(q0(this),this.isIosDevice||(document.documentElement.style.overflow=this.initialHtmlOverflow))}}connectedCallback(){super.connectedCallback(),this.cleanOptions=pf.parse(this.options),this.identifyIosDevice(),this.setInitialHtmlOverflow(),this.initialScrollPosition={x:0,y:0},this.onResizeHandler(),window.addEventListener("resize",this.onResizeHandler,{passive:!0})}disconnectedCallback(){super.disconnectedCallback(),q0(this),window.removeEventListener("resize",this.onResizeHandler)}render(){const{placement:t,chatWindow:e}=this.cleanOptions.config,{height:r,cta:n}=this.cleanOptions.config.openChatButton,i=MP("chat-widget w-dvw h-dvh md:mx-8",xM[e.width],RM[e.height],this.isOpen?"":"invisible");return nr`
389
389
  <div
390
390
  class="chat-widget-popup fixed flex flex-col bottom-0 z-40 ${tf({"right-0 items-end":t==="right","left-0 items-start":t==="left"})}"
391
391
  style=${Fl({colorScheme:"normal"})}
@@ -427,7 +427,7 @@
427
427
  max-height: calc(100dvh - var(--iai-i-button-height, 48px) - 4rem);
428
428
  }
429
429
  }
430
- `],uu([Lr({type:Object})],ns.prototype,"options",2),uu([Ws()],ns.prototype,"isOpen",2),uu([Ws()],ns.prototype,"ctaClosed",2),uu([Gd("iai-chat")],ns.prototype,"chatWindow",2),uu([vv.debounce(250)],ns.prototype,"onResizeHandler",2),ns=uu([ji("iai-chat-popup")],ns);const PM=typeof window<"u"&&window||typeof global<"u"&&global||{},MM=PM.IAI_BACKEND_URL||"https://api.ai.inhabit.services",lu={async get(t,e={}){return this.request(t,{...e,method:"GET"})},async post(t,e={},r={}){return this.request(t,{...r,method:"POST",body:JSON.stringify(e)})},async put(t,e={},r={}){return this.request(t,{...r,method:"PUT",body:JSON.stringify(e)})},async delete(t,e={}){return this.request(t,{...e,method:"DELETE"})},async patch(t,e={},r={}){return this.request(t,{...r,method:"PATCH",body:JSON.stringify(e)})},async request(t,e={}){const{returnFullResponse:r=!1,...n}=e,i={...n,headers:{"Content-Type":"application/json",...n.headers}};t=t.replace(/^\//,"");const a=await fetch(`${MM}/${t}`,i);if(!a.ok){if(a.status===429){const o=+(a.headers.get("Retry-After")||30);throw new ac(`Rate limited fetching /${t}: retry after ${o} seconds`,a.status,{retryAfter:o})}const s=[`Failed to fetch /${t}:`];try{const{message:o}=await a.json();if(!o)throw new Error;s.push(o)}catch{s.push(`${a.status} (${a.statusText})`)}throw new ac(s.join(" "),a.status)}if(r)return a;try{return await a.json()}catch{return null}}};async function NM(t,e={},r){return lu.post("/threads",{assistantId:t,params:e,clientId:r})}async function LM(t,e="No reason provided"){await lu.post(`/threads/${t}/end`,{reason:e})}async function DM(t,e){return lu.post(`/threads/${t}/messages`,{content:e})}async function jM(t,e,r){await lu.put(`/threads/${t}/messages/${e}/rate`,{rating:r})}async function UM(t,e,r,n=!1){return lu.post(`/threads/${t}/functions/${e}`,{params:r,rerunLLM:n})}async function FM(t){return lu.post(`/threads/${t}/ping`)}class ac extends Error{constructor(e,r,n){super(e),this.status=r,this.details=n}}function BM(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}class zM{constructor(e,r={}){if(this._assistantId="",this._recurringKeepAliveInterval=null,this._recurringKeepAliveCallers=new Set,this._conversationDetails=null,this._messages=[],this.isTyping=!1,this.inputDisabled=!1,this.chatEndingWarningSent=!1,this.chatEnded=!1,this._resetCounter=0,this.onStorageEvent=n=>{var i;const[a,s,o]=((i=n.key)==null?void 0:i.split("-"))||[];if(!(a!=="iaiChat"||s!==this.options.historyKey))switch(o){case"messageHistory":this.onMessageHistoryStorageEvent(n);break;case"conversation":this.setConversationDetails(JSON.parse(n.newValue||"null"),!0);break;case"lastActivity":this.keepAlive(JSON.parse(n.newValue||"null"),!0);break;case"chatEndingWarningSent":this.setChatEndingWarningSent(JSON.parse(n.newValue||"false"),!0);break;case"chatEnded":this.setChatEnded(JSON.parse(n.newValue||"false"),!0);break;case"typing":this.setTyping(JSON.parse(n.newValue||"false"),!0);break;case"inputDisabled":this.setInputDisabled(JSON.parse(n.newValue||"false"),!0);break}},this.userMessageTypingId=null,this._assistantId=e,this._clientId=r.clientId,this.options={params:{},resetEndedChatOnLoad:!1,historyKey:"main",...r},this._emitter=BM(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),r.events&&Object.entries(r.events).forEach(([n,i])=>{this._emitter.on(n,i)}),r.historyKey){this._messages=this.storageGet("messageHistory",[]);const n=this.storageGet("conversation");n&&this.setConversationDetails(n,!0);const i=this.storageGet("chatEndingWarningSent");i&&this.setChatEndingWarningSent(i,!0);const a=this.storageGet("chatEnded");a&&this.setChatEnded(a,!0);const s=this.storageGet("typing");s&&this.setTyping(s,!0);const o=this.storageGet("inputDisabled");o&&this.setInputDisabled(o,!0);const u=this.storageGet("lastActivity");u&&setTimeout(()=>this.keepAlive(u,!0),0),setTimeout(()=>{this.chatEnded&&this.options.resetEndedChatOnLoad&&this.reset()},0),window.addEventListener("storage",this.onStorageEvent)}}onMessageHistoryStorageEvent(e){if(!e.newValue){this.reset();return}const r=JSON.parse(e.newValue),n=this._messages.map(a=>a.id),i=r.map(a=>a.id);this._messages.forEach(a=>{i.includes(a.id)||this._emitter.emit("messageRemoved",a.id)}),r.forEach(a=>{n.includes(a.id)||this._emitter.emit("message",a)}),this._messages=r}async endChat(e,r=!0){!this.threadId||this.chatEnded||(r&&(this._emitter.emit("chatEnded"),this.setChatEnded(!0)),this.stopInactivityTimers(),await LM(this.threadId,e))}reset(e){this.endChat(e,!1).then(()=>{}),this._messages=[],this.setConversationDetails(null),this.setTyping(!1),this.setInputDisabled(!1),this.setChatEnded(!1),this._recurringKeepAliveCallers.forEach(r=>r()),this.stopInactivityTimers(),this.setChatEndingWarningSent(!1),this.storageRemoveAll(),this._resetCounter+=1,this._emitter.emit("reset")}destroy(){this._emitter.all.clear(),window.removeEventListener("storage",this.onStorageEvent),this.stopInactivityTimers(),this._emitter.emit("destroy")}stopInactivityTimers(){this._inactivityTimeout&&(clearTimeout(this._inactivityTimeout),this._inactivityTimeout=null),this._inactivityWarningTimeout&&(clearTimeout(this._inactivityWarningTimeout),this._inactivityWarningTimeout=null)}keepAlive(e=Date.now(),r=!1){if(this.stopInactivityTimers(),this.chatEnded||!e)return;const{timeUntilChatEnds:n,timeUntilWarnAboutChatEnding:i}=this;if(!n)return;r||this.storageSet("lastActivity",e);const a=Date.now()-e;if(a>n){if(this.chatEnded)return;this.setChatEnded(!0),this._emitter.emit("chatEnded")}else a>i?(this.sendChatEndingWarning(),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||(this.setChatEnded(!0),this._emitter.emit("chatEnded"))},n-a)):(this.setChatEndingWarningSent(!1),this._inactivityWarningTimeout=setTimeout(()=>this.sendChatEndingWarning(),i-a),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||(this.setChatEnded(!0),this._emitter.emit("chatEnded"))},n-a))}registerRecurringKeepAlive(){if(!this.chatStarted)throw new Error("Chat not started");const e=()=>{this._recurringKeepAliveCallers.delete(e),this._recurringKeepAliveCallers.size===0&&this._recurringKeepAliveInterval&&(clearInterval(this._recurringKeepAliveInterval),this._recurringKeepAliveInterval=null)};return this._recurringKeepAliveCallers.add(e),this._recurringKeepAliveInterval||(this._recurringKeepAliveInterval=setInterval(()=>{this.chatStarted&&(this.keepAlive(),FM(this.threadId).then(()=>{}))},3e4)),e}async startChat(){if(this.chatStarted)return;const e=this.getResetChecker(),{id:r,inactivityWaitTime:n,inactivityWarningTime:i}=await NM(this.assistantId,this.params,this.clientId);if(!r)throw new _v("Could not start chat","ChatStartError");if(e.resetOccurred)throw new _v("Chat was reset","ChatReset");this.setConversationDetails({threadId:r,inactivityWaitTime:n,inactivityWarningTime:i})}handleSendUserMessageResponse({messages:e,functions:r}){this.addMessages(e),r.forEach(n=>this._emitter.emit("functionCall",n))}addMessages(e){e.forEach(r=>this.addMessage(r))}addMessage(e){const r={...e,id:e.id||Math.random().toString(36).substring(7)};return this._messages.push(r),this.storageSet("messageHistory",this._messages),this._emitter.emit("message",r),r}removeMessage(e){this._messages.find(r=>r.id===e)&&(this._messages=this._messages.filter(r=>r.id!==e),this.storageSet("messageHistory",this._messages),this._emitter.emit("messageRemoved",e))}async respondToFunctionCall(e,r,n){if(!this.threadId)throw new Error("Thread not started");try{const i=this.getResetChecker();this.setTyping(!0),this.keepAlive();const a=await UM(this.threadId,e,r,n);if(i.resetOccurred)return;this.handleSendUserMessageResponse(a)}catch(i){i instanceof ac&&i.status===429?this.sendErrorMessage(`You are sending messages too quickly. You may try again in ${i.details.retryAfter} second(s).`):this.sendErrorMessage(),console.error("Error sending message:",i)}finally{this.setTyping(!1)}}getTypingManager(){let e=null;return{start:()=>{e=Math.random().toString(36).substring(7),this.userMessageTypingId=e,this.setTyping(!0)},done:()=>{this.userMessageTypingId===e&&(this.setTyping(!1),this.userMessageTypingId=null)}}}async sendUserMessage(e){const r=this.getTypingManager();try{const n=this.getResetChecker();if(this.addMessage({role:"user",content:e}),r.start(),!this.chatStarted){const{initialReplyMessage:a}=this.options;a&&this.addMessage({role:"assistant",content:a});try{await this.startChat()}catch(s){if(s instanceof ac&&s.status===429){this.sendErrorMessage(`You are starting new chats too quickly. You may try again in ${s.details.retryAfter} second(s).`);return}if(s instanceof _v&&s.name==="ChatReset")return;throw s}}this.keepAlive();const i=await DM(this.threadId,e);if(n.resetOccurred)return;this.handleSendUserMessageResponse(i)}catch(n){n instanceof ac&&n.status===429?this.sendErrorMessage(`You are sending messages too quickly. You may try again in ${n.details.retryAfter} second(s).`):this.sendErrorMessage(),console.error("Error sending message:",n)}finally{r.done()}}async rateMessage(e,r){const n=this._messages.find(i=>i.id===e);!n||n.role!=="assistant"||(n.userRating=r,this.storageSet("messageHistory",this._messages),await jM(this.threadId,e,r))}sendErrorMessage(e="There was an unexpected error. Please try again later."){this.addMessage({role:"assistant",content:e})}setTyping(e,r=!1){this.isTyping=e,this._emitter.emit("typing",e),r||this.storageSet("typing",e)}setConversationDetails(e,r=!1){this._conversationDetails=e,r||this.storageSet("conversation",e)}setInputDisabled(e,r=!1){this.inputDisabled=e,this._emitter.emit("inputDisabled",e),r||this.storageSet("inputDisabled",e)}setChatEnded(e,r=!1){this.chatEnded=e,r||this.storageSet("chatEnded",e)}setChatEndingWarningSent(e,r=!1){this.chatEndingWarningSent=e,r||this.storageSet("chatEndingWarningSent",e)}sendChatEndingWarning(){this.chatEndingWarningSent||(this._emitter.emit("inactivityWarning"),this.setChatEndingWarningSent(!0))}getResetChecker(){const e=this._resetCounter,r=this;return{get resetOccurred(){return e!==r._resetCounter}}}get assistantId(){return this._assistantId}get clientId(){return this._clientId}get params(){return this.options.params}get threadId(){var e;return(e=this._conversationDetails)==null?void 0:e.threadId}get timeUntilChatEnds(){const{inactivityWaitTime:e}=this._conversationDetails||{};return e?e*60*1e3:null}get timeUntilWarnAboutChatEnding(){const{inactivityWaitTime:e=0,inactivityWarningTime:r=0}=this._conversationDetails||{};return(e-r)*60*1e3}get messages(){return this._messages}get chatStarted(){return!!this.threadId}storageSet(e,r){this.options.historyKey&&localStorage.setItem(`iaiChat-${this.options.historyKey}-${e}`,JSON.stringify(r))}storageGet(e,r=null){if(!this.options.historyKey)return null;const n=localStorage.getItem(`iaiChat-${this.options.historyKey}-${e}`);return n?JSON.parse(n):r}storageRemove(e){localStorage.removeItem(`iaiChat-${this.options.historyKey}-${e}`)}storageRemoveAll(){this.options.historyKey&&Object.keys(localStorage).forEach(e=>{e.startsWith(`iaiChat-${this.options.historyKey}-`)&&localStorage.removeItem(e)})}}class _v extends Error{constructor(e,r){super(e),this.name=r}}var l_={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(NP,function(){var r=1e3,n=6e4,i=36e5,a="millisecond",s="second",o="minute",u="hour",l="day",c="week",d="month",f="quarter",m="year",k="date",L="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,re={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(oe){var q=["th","st","nd","rd"],ne=oe%100;return"["+oe+(q[(ne-20)%10]||q[ne]||q[0])+"]"}},Me=function(oe,q,ne){var Se=String(oe);return!Se||Se.length>=q?oe:""+Array(q+1-Se.length).join(ne)+oe},Oe={s:Me,z:function(oe){var q=-oe.utcOffset(),ne=Math.abs(q),Se=Math.floor(ne/60),H=ne%60;return(q<=0?"+":"-")+Me(Se,2,"0")+":"+Me(H,2,"0")},m:function oe(q,ne){if(q.date()<ne.date())return-oe(ne,q);var Se=12*(ne.year()-q.year())+(ne.month()-q.month()),H=q.clone().add(Se,d),ye=ne-H<0,ke=q.clone().add(Se+(ye?-1:1),d);return+(-(Se+(ne-H)/(ye?H-ke:ke-H))||0)},a:function(oe){return oe<0?Math.ceil(oe)||0:Math.floor(oe)},p:function(oe){return{M:d,y:m,w:c,d:l,D:k,h:u,m:o,s,ms:a,Q:f}[oe]||String(oe||"").toLowerCase().replace(/s$/,"")},u:function(oe){return oe===void 0}},Be="en",Pe={};Pe[Be]=re;var Ze="$isDayjsObject",Z=function(oe){return oe instanceof Te||!(!oe||!oe[Ze])},Ie=function oe(q,ne,Se){var H;if(!q)return Be;if(typeof q=="string"){var ye=q.toLowerCase();Pe[ye]&&(H=ye),ne&&(Pe[ye]=ne,H=ye);var ke=q.split("-");if(!H&&ke.length>1)return oe(ke[0])}else{var P=q.name;Pe[P]=q,H=P}return!Se&&H&&(Be=H),H||!Se&&Be},_e=function(oe,q){if(Z(oe))return oe.clone();var ne=typeof q=="object"?q:{};return ne.date=oe,ne.args=arguments,new Te(ne)},se=Oe;se.l=Ie,se.i=Z,se.w=function(oe,q){return _e(oe,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var Te=function(){function oe(ne){this.$L=Ie(ne.locale,null,!0),this.parse(ne),this.$x=this.$x||ne.x||{},this[Ze]=!0}var q=oe.prototype;return q.parse=function(ne){this.$d=function(Se){var H=Se.date,ye=Se.utc;if(H===null)return new Date(NaN);if(se.u(H))return new Date;if(H instanceof Date)return new Date(H);if(typeof H=="string"&&!/Z$/i.test(H)){var ke=H.match(N);if(ke){var P=ke[2]-1||0,Qe=(ke[7]||"0").substring(0,3);return ye?new Date(Date.UTC(ke[1],P,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Qe)):new Date(ke[1],P,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Qe)}}return new Date(H)}(ne),this.init()},q.init=function(){var ne=this.$d;this.$y=ne.getFullYear(),this.$M=ne.getMonth(),this.$D=ne.getDate(),this.$W=ne.getDay(),this.$H=ne.getHours(),this.$m=ne.getMinutes(),this.$s=ne.getSeconds(),this.$ms=ne.getMilliseconds()},q.$utils=function(){return se},q.isValid=function(){return this.$d.toString()!==L},q.isSame=function(ne,Se){var H=_e(ne);return this.startOf(Se)<=H&&H<=this.endOf(Se)},q.isAfter=function(ne,Se){return _e(ne)<this.startOf(Se)},q.isBefore=function(ne,Se){return this.endOf(Se)<_e(ne)},q.$g=function(ne,Se,H){return se.u(ne)?this[Se]:this.set(H,ne)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(ne,Se){var H=this,ye=!!se.u(Se)||Se,ke=se.p(ne),P=function(be,ht){var Ve=se.w(H.$u?Date.UTC(H.$y,ht,be):new Date(H.$y,ht,be),H);return ye?Ve:Ve.endOf(l)},Qe=function(be,ht){return se.w(H.toDate()[be].apply(H.toDate("s"),(ye?[0,0,0,0]:[23,59,59,999]).slice(ht)),H)},Ct=this.$W,tt=this.$M,De=this.$D,ce="set"+(this.$u?"UTC":"");switch(ke){case m:return ye?P(1,0):P(31,11);case d:return ye?P(1,tt):P(0,tt+1);case c:var Ge=this.$locale().weekStart||0,Ue=(Ct<Ge?Ct+7:Ct)-Ge;return P(ye?De-Ue:De+(6-Ue),tt);case l:case k:return Qe(ce+"Hours",0);case u:return Qe(ce+"Minutes",1);case o:return Qe(ce+"Seconds",2);case s:return Qe(ce+"Milliseconds",3);default:return this.clone()}},q.endOf=function(ne){return this.startOf(ne,!1)},q.$set=function(ne,Se){var H,ye=se.p(ne),ke="set"+(this.$u?"UTC":""),P=(H={},H[l]=ke+"Date",H[k]=ke+"Date",H[d]=ke+"Month",H[m]=ke+"FullYear",H[u]=ke+"Hours",H[o]=ke+"Minutes",H[s]=ke+"Seconds",H[a]=ke+"Milliseconds",H)[ye],Qe=ye===l?this.$D+(Se-this.$W):Se;if(ye===d||ye===m){var Ct=this.clone().set(k,1);Ct.$d[P](Qe),Ct.init(),this.$d=Ct.set(k,Math.min(this.$D,Ct.daysInMonth())).$d}else P&&this.$d[P](Qe);return this.init(),this},q.set=function(ne,Se){return this.clone().$set(ne,Se)},q.get=function(ne){return this[se.p(ne)]()},q.add=function(ne,Se){var H,ye=this;ne=Number(ne);var ke=se.p(Se),P=function(tt){var De=_e(ye);return se.w(De.date(De.date()+Math.round(tt*ne)),ye)};if(ke===d)return this.set(d,this.$M+ne);if(ke===m)return this.set(m,this.$y+ne);if(ke===l)return P(1);if(ke===c)return P(7);var Qe=(H={},H[o]=n,H[u]=i,H[s]=r,H)[ke]||1,Ct=this.$d.getTime()+ne*Qe;return se.w(Ct,this)},q.subtract=function(ne,Se){return this.add(-1*ne,Se)},q.format=function(ne){var Se=this,H=this.$locale();if(!this.isValid())return H.invalidDate||L;var ye=ne||"YYYY-MM-DDTHH:mm:ssZ",ke=se.z(this),P=this.$H,Qe=this.$m,Ct=this.$M,tt=H.weekdays,De=H.months,ce=H.meridiem,Ge=function(ht,Ve,Kt,Rt){return ht&&(ht[Ve]||ht(Se,ye))||Kt[Ve].slice(0,Rt)},Ue=function(ht){return se.s(P%12||12,ht,"0")},be=ce||function(ht,Ve,Kt){var Rt=ht<12?"AM":"PM";return Kt?Rt.toLowerCase():Rt};return ye.replace(z,function(ht,Ve){return Ve||function(Kt){switch(Kt){case"YY":return String(Se.$y).slice(-2);case"YYYY":return se.s(Se.$y,4,"0");case"M":return Ct+1;case"MM":return se.s(Ct+1,2,"0");case"MMM":return Ge(H.monthsShort,Ct,De,3);case"MMMM":return Ge(De,Ct);case"D":return Se.$D;case"DD":return se.s(Se.$D,2,"0");case"d":return String(Se.$W);case"dd":return Ge(H.weekdaysMin,Se.$W,tt,2);case"ddd":return Ge(H.weekdaysShort,Se.$W,tt,3);case"dddd":return tt[Se.$W];case"H":return String(P);case"HH":return se.s(P,2,"0");case"h":return Ue(1);case"hh":return Ue(2);case"a":return be(P,Qe,!0);case"A":return be(P,Qe,!1);case"m":return String(Qe);case"mm":return se.s(Qe,2,"0");case"s":return String(Se.$s);case"ss":return se.s(Se.$s,2,"0");case"SSS":return se.s(Se.$ms,3,"0");case"Z":return ke}return null}(ht)||ke.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(ne,Se,H){var ye,ke=this,P=se.p(Se),Qe=_e(ne),Ct=(Qe.utcOffset()-this.utcOffset())*n,tt=this-Qe,De=function(){return se.m(ke,Qe)};switch(P){case m:ye=De()/12;break;case d:ye=De();break;case f:ye=De()/3;break;case c:ye=(tt-Ct)/6048e5;break;case l:ye=(tt-Ct)/864e5;break;case u:ye=tt/i;break;case o:ye=tt/n;break;case s:ye=tt/r;break;default:ye=tt}return H?ye:se.a(ye)},q.daysInMonth=function(){return this.endOf(d).$D},q.$locale=function(){return Pe[this.$L]},q.locale=function(ne,Se){if(!ne)return this.$L;var H=this.clone(),ye=Ie(ne,Se,!0);return ye&&(H.$L=ye),H},q.clone=function(){return se.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},oe}(),te=Te.prototype;return _e.prototype=te,[["$ms",a],["$s",s],["$m",o],["$H",u],["$W",l],["$M",d],["$y",m],["$D",k]].forEach(function(oe){te[oe[1]]=function(q){return this.$g(q,oe[0],oe[1])}}),_e.extend=function(oe,q){return oe.$i||(oe(q,Te,_e),oe.$i=!0),_e},_e.locale=Ie,_e.isDayjs=Z,_e.unix=function(oe){return _e(1e3*oe)},_e.en=Pe[Be],_e.Ls=Pe,_e.p={},_e})})(l_);var HM=l_.exports;const c_=Q0(HM);function qM(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}/**
430
+ `],uu([Lr({type:Object})],ns.prototype,"options",2),uu([Ws()],ns.prototype,"isOpen",2),uu([Ws()],ns.prototype,"ctaClosed",2),uu([Gd("iai-chat")],ns.prototype,"chatWindow",2),uu([vv.debounce(250)],ns.prototype,"onResizeHandler",2),ns=uu([ji("iai-chat-popup")],ns);const PM=typeof window<"u"&&window||typeof global<"u"&&global||{},MM=PM.IAI_BACKEND_URL||"https://api.ai.inhabit.services",lu={async get(t,e={}){return this.request(t,{...e,method:"GET"})},async post(t,e={},r={}){return this.request(t,{...r,method:"POST",body:JSON.stringify(e)})},async put(t,e={},r={}){return this.request(t,{...r,method:"PUT",body:JSON.stringify(e)})},async delete(t,e={}){return this.request(t,{...e,method:"DELETE"})},async patch(t,e={},r={}){return this.request(t,{...r,method:"PATCH",body:JSON.stringify(e)})},async request(t,e={}){const{returnFullResponse:r=!1,...n}=e,i={...n,headers:{"Content-Type":"application/json",...n.headers}};t=t.replace(/^\//,"");const a=await fetch(`${MM}/${t}`,i);if(!a.ok){if(a.status===429){const o=+(a.headers.get("Retry-After")||30);throw new ac(`Rate limited fetching /${t}: retry after ${o} seconds`,a.status,{retryAfter:o})}const s=[`Failed to fetch /${t}:`];try{const{message:o}=await a.json();if(!o)throw new Error;s.push(o)}catch{s.push(`${a.status} (${a.statusText})`)}throw new ac(s.join(" "),a.status)}if(r)return a;try{return await a.json()}catch{return null}}};async function NM(t,e={},r){return lu.post("/threads",{assistantId:t,params:e,clientId:r})}async function LM(t,e="No reason provided"){await lu.post(`/threads/${t}/end`,{reason:e})}async function DM(t,e){return lu.post(`/threads/${t}/messages`,{content:e})}async function jM(t,e,r){await lu.put(`/threads/${t}/messages/${e}/rate`,{rating:r})}async function UM(t,e,r,n=!1){return lu.post(`/threads/${t}/functions/${e}`,{params:r,rerunLLM:n})}async function FM(t){return lu.post(`/threads/${t}/ping`)}class ac extends Error{constructor(e,r,n){super(e),this.status=r,this.details=n}}function BM(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}class zM{constructor(e,r={}){if(this._assistantId="",this._recurringKeepAliveInterval=null,this._recurringKeepAliveCallers=new Set,this._conversationDetails=null,this._messages=[],this.isTyping=!1,this.inputDisabled=!1,this.chatEndingWarningSent=!1,this.chatEnded=!1,this._resetCounter=0,this.onStorageEvent=n=>{var i;const[a,s,o]=((i=n.key)==null?void 0:i.split("-"))||[];if(!(a!=="iaiChat"||s!==this.options.historyKey))switch(o){case"messageHistory":this.onMessageHistoryStorageEvent(n);break;case"conversation":this.setConversationDetails(JSON.parse(n.newValue||"null"),!0);break;case"lastActivity":this.keepAlive(JSON.parse(n.newValue||"null"),!0);break;case"chatEndingWarningSent":this.setChatEndingWarningSent(JSON.parse(n.newValue||"false"),!0);break;case"chatEnded":this.setChatEnded(JSON.parse(n.newValue||"false"),!0);break;case"typing":this.setTyping(JSON.parse(n.newValue||"false"),!0);break;case"inputDisabled":this.setInputDisabled(JSON.parse(n.newValue||"false"),!0);break}},this.userMessageTypingId=null,this._assistantId=e,this._clientId=r.clientId,this.options={params:{},resetEndedChatOnLoad:!1,historyKey:"main",...r},this._emitter=BM(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),r.events&&Object.entries(r.events).forEach(([n,i])=>{this._emitter.on(n,i)}),r.historyKey){this._messages=this.storageGet("messageHistory",[]);const n=this.storageGet("conversation");n&&this.setConversationDetails(n,!0);const i=this.storageGet("chatEndingWarningSent");i&&this.setChatEndingWarningSent(i,!0);const a=this.storageGet("chatEnded");a&&this.setChatEnded(a,!0);const s=this.storageGet("typing");s&&this.setTyping(s,!0);const o=this.storageGet("inputDisabled");o&&this.setInputDisabled(o,!0);const u=this.storageGet("lastActivity");u&&setTimeout(()=>this.keepAlive(u,!0),0),setTimeout(()=>{this.chatEnded&&this.options.resetEndedChatOnLoad&&this.reset()},0),window.addEventListener("storage",this.onStorageEvent)}}onMessageHistoryStorageEvent(e){if(!e.newValue){this.reset();return}const r=JSON.parse(e.newValue),n=this._messages.map(a=>a.id),i=r.map(a=>a.id);this._messages.forEach(a=>{i.includes(a.id)||this._emitter.emit("messageRemoved",a.id)}),r.forEach(a=>{n.includes(a.id)||this._emitter.emit("message",a)}),this._messages=r}async endChat(e,r=!0){!this.threadId||this.chatEnded||(r&&(this._emitter.emit("chatEnded"),this.setChatEnded(!0)),this.stopInactivityTimers(),await LM(this.threadId,e))}reset(e){this.endChat(e,!1).then(()=>{}),this._messages=[],this.setConversationDetails(null),this.setTyping(!1),this.setInputDisabled(!1),this.setChatEnded(!1),this._recurringKeepAliveCallers.forEach(r=>r()),this.stopInactivityTimers(),this.setChatEndingWarningSent(!1),this.storageRemoveAll(),this._resetCounter+=1,this._emitter.emit("reset")}destroy(){this._emitter.all.clear(),window.removeEventListener("storage",this.onStorageEvent),this.stopInactivityTimers(),this._emitter.emit("destroy")}stopInactivityTimers(){this._inactivityTimeout&&(clearTimeout(this._inactivityTimeout),this._inactivityTimeout=null),this._inactivityWarningTimeout&&(clearTimeout(this._inactivityWarningTimeout),this._inactivityWarningTimeout=null)}keepAlive(e=Date.now(),r=!1){if(this.stopInactivityTimers(),this.chatEnded||!e)return;const{timeUntilChatEnds:n,timeUntilWarnAboutChatEnding:i}=this;if(!n)return;r||this.storageSet("lastActivity",e);const a=Date.now()-e;if(a>n){if(this.chatEnded)return;this.setChatEnded(!0),this._emitter.emit("chatEnded")}else a>i?(this.sendChatEndingWarning(),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||(this.setChatEnded(!0),this._emitter.emit("chatEnded"))},n-a)):(this.setChatEndingWarningSent(!1),this._inactivityWarningTimeout=setTimeout(()=>this.sendChatEndingWarning(),i-a),this._inactivityTimeout=setTimeout(()=>{this.chatEnded||(this.setChatEnded(!0),this._emitter.emit("chatEnded"))},n-a))}registerRecurringKeepAlive(){if(!this.chatStarted)throw new Error("Chat not started");const e=()=>{this._recurringKeepAliveCallers.delete(e),this._recurringKeepAliveCallers.size===0&&this._recurringKeepAliveInterval&&(clearInterval(this._recurringKeepAliveInterval),this._recurringKeepAliveInterval=null)};return this._recurringKeepAliveCallers.add(e),this._recurringKeepAliveInterval||(this._recurringKeepAliveInterval=setInterval(()=>{this.chatStarted&&(this.keepAlive(),FM(this.threadId).then(()=>{}))},3e4)),e}async startChat(){if(this.chatStarted)return;const e=this.getResetChecker(),{id:r,inactivityWaitTime:n,inactivityWarningTime:i}=await NM(this.assistantId,this.params,this.clientId);if(!r)throw new _v("Could not start chat","ChatStartError");if(e.resetOccurred)throw new _v("Chat was reset","ChatReset");this.setConversationDetails({threadId:r,inactivityWaitTime:n,inactivityWarningTime:i})}handleSendUserMessageResponse({messages:e,functions:r}){this.addMessages(e),r.forEach(n=>this._emitter.emit("functionCall",n))}addMessages(e){e.forEach(r=>this.addMessage(r))}addMessage(e){const r={...e,id:e.id||Math.random().toString(36).substring(7)};return this._messages.push(r),this.storageSet("messageHistory",this._messages),this._emitter.emit("message",r),r}removeMessage(e){this._messages.find(r=>r.id===e)&&(this._messages=this._messages.filter(r=>r.id!==e),this.storageSet("messageHistory",this._messages),this._emitter.emit("messageRemoved",e))}async respondToFunctionCall(e,r,n){if(!this.threadId)throw new Error("Thread not started");try{const i=this.getResetChecker();this.setTyping(!0),this.keepAlive();const a=await UM(this.threadId,e,r,n);if(i.resetOccurred)return;this.handleSendUserMessageResponse(a)}catch(i){i instanceof ac&&i.status===429?this.sendErrorMessage(`You are sending messages too quickly. You may try again in ${i.details.retryAfter} second(s).`):this.sendErrorMessage(),console.error("Error sending message:",i)}finally{this.setTyping(!1)}}getTypingManager(){let e=null;return{start:()=>{e=Math.random().toString(36).substring(7),this.userMessageTypingId=e,this.setTyping(!0)},done:()=>{this.userMessageTypingId===e&&(this.setTyping(!1),this.userMessageTypingId=null)}}}async sendUserMessage(e){const r=this.getTypingManager();try{const n=this.getResetChecker();if(this.addMessage({role:"user",content:e}),r.start(),!this.chatStarted){const{initialReplyMessage:a}=this.options;a&&this.addMessage({role:"assistant",content:a});try{await this.startChat()}catch(s){if(s instanceof ac&&s.status===429){this.sendErrorMessage(`You are starting new chats too quickly. You may try again in ${s.details.retryAfter} second(s).`);return}if(s instanceof _v&&s.name==="ChatReset")return;throw s}}this.keepAlive();const i=await DM(this.threadId,e);if(n.resetOccurred)return;this.handleSendUserMessageResponse(i)}catch(n){n instanceof ac&&n.status===429?this.sendErrorMessage(`You are sending messages too quickly. You may try again in ${n.details.retryAfter} second(s).`):this.sendErrorMessage(),console.error("Error sending message:",n)}finally{r.done()}}async rateMessage(e,r){const n=this._messages.find(i=>i.id===e);!n||n.role!=="assistant"||(n.userRating=r,this.storageSet("messageHistory",this._messages),await jM(this.threadId,e,r))}sendErrorMessage(e="There was an unexpected error. Please try again later."){this.addMessage({role:"assistant",content:e})}setTyping(e,r=!1){this.isTyping=e,this._emitter.emit("typing",e),r||this.storageSet("typing",e)}setConversationDetails(e,r=!1){this._conversationDetails=e,r||this.storageSet("conversation",e)}setInputDisabled(e,r=!1){this.inputDisabled=e,this._emitter.emit("inputDisabled",e),r||this.storageSet("inputDisabled",e)}setChatEnded(e,r=!1){this.chatEnded=e,r||this.storageSet("chatEnded",e)}setChatEndingWarningSent(e,r=!1){this.chatEndingWarningSent=e,r||this.storageSet("chatEndingWarningSent",e)}sendChatEndingWarning(){this.chatEndingWarningSent||(this._emitter.emit("inactivityWarning"),this.setChatEndingWarningSent(!0))}getResetChecker(){const e=this._resetCounter,r=this;return{get resetOccurred(){return e!==r._resetCounter}}}get assistantId(){return this._assistantId}get clientId(){return this._clientId}get params(){return this.options.params}get threadId(){var e;return(e=this._conversationDetails)==null?void 0:e.threadId}get timeUntilChatEnds(){const{inactivityWaitTime:e}=this._conversationDetails||{};return e?e*60*1e3:null}get timeUntilWarnAboutChatEnding(){const{inactivityWaitTime:e=0,inactivityWarningTime:r=0}=this._conversationDetails||{};return(e-r)*60*1e3}get messages(){return this._messages}get chatStarted(){return!!this.threadId}storageSet(e,r){this.options.historyKey&&localStorage.setItem(`iaiChat-${this.options.historyKey}-${e}`,JSON.stringify(r))}storageGet(e,r=null){if(!this.options.historyKey)return null;const n=localStorage.getItem(`iaiChat-${this.options.historyKey}-${e}`);return n?JSON.parse(n):r}storageRemove(e){localStorage.removeItem(`iaiChat-${this.options.historyKey}-${e}`)}storageRemoveAll(){this.options.historyKey&&Object.keys(localStorage).forEach(e=>{e.startsWith(`iaiChat-${this.options.historyKey}-`)&&localStorage.removeItem(e)})}}class _v extends Error{constructor(e,r){super(e),this.name=r}}var l_={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(NP,function(){var r=1e3,n=6e4,i=36e5,a="millisecond",s="second",o="minute",u="hour",l="day",c="week",d="month",f="quarter",m="year",k="date",L="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,re={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(oe){var q=["th","st","nd","rd"],ne=oe%100;return"["+oe+(q[(ne-20)%10]||q[ne]||q[0])+"]"}},Me=function(oe,q,ne){var Se=String(oe);return!Se||Se.length>=q?oe:""+Array(q+1-Se.length).join(ne)+oe},Oe={s:Me,z:function(oe){var q=-oe.utcOffset(),ne=Math.abs(q),Se=Math.floor(ne/60),H=ne%60;return(q<=0?"+":"-")+Me(Se,2,"0")+":"+Me(H,2,"0")},m:function oe(q,ne){if(q.date()<ne.date())return-oe(ne,q);var Se=12*(ne.year()-q.year())+(ne.month()-q.month()),H=q.clone().add(Se,d),ye=ne-H<0,ke=q.clone().add(Se+(ye?-1:1),d);return+(-(Se+(ne-H)/(ye?H-ke:ke-H))||0)},a:function(oe){return oe<0?Math.ceil(oe)||0:Math.floor(oe)},p:function(oe){return{M:d,y:m,w:c,d:l,D:k,h:u,m:o,s,ms:a,Q:f}[oe]||String(oe||"").toLowerCase().replace(/s$/,"")},u:function(oe){return oe===void 0}},Fe="en",Pe={};Pe[Fe]=re;var Ze="$isDayjsObject",Z=function(oe){return oe instanceof Te||!(!oe||!oe[Ze])},Ie=function oe(q,ne,Se){var H;if(!q)return Fe;if(typeof q=="string"){var ye=q.toLowerCase();Pe[ye]&&(H=ye),ne&&(Pe[ye]=ne,H=ye);var ke=q.split("-");if(!H&&ke.length>1)return oe(ke[0])}else{var P=q.name;Pe[P]=q,H=P}return!Se&&H&&(Fe=H),H||!Se&&Fe},_e=function(oe,q){if(Z(oe))return oe.clone();var ne=typeof q=="object"?q:{};return ne.date=oe,ne.args=arguments,new Te(ne)},se=Oe;se.l=Ie,se.i=Z,se.w=function(oe,q){return _e(oe,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var Te=function(){function oe(ne){this.$L=Ie(ne.locale,null,!0),this.parse(ne),this.$x=this.$x||ne.x||{},this[Ze]=!0}var q=oe.prototype;return q.parse=function(ne){this.$d=function(Se){var H=Se.date,ye=Se.utc;if(H===null)return new Date(NaN);if(se.u(H))return new Date;if(H instanceof Date)return new Date(H);if(typeof H=="string"&&!/Z$/i.test(H)){var ke=H.match(N);if(ke){var P=ke[2]-1||0,Qe=(ke[7]||"0").substring(0,3);return ye?new Date(Date.UTC(ke[1],P,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Qe)):new Date(ke[1],P,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Qe)}}return new Date(H)}(ne),this.init()},q.init=function(){var ne=this.$d;this.$y=ne.getFullYear(),this.$M=ne.getMonth(),this.$D=ne.getDate(),this.$W=ne.getDay(),this.$H=ne.getHours(),this.$m=ne.getMinutes(),this.$s=ne.getSeconds(),this.$ms=ne.getMilliseconds()},q.$utils=function(){return se},q.isValid=function(){return this.$d.toString()!==L},q.isSame=function(ne,Se){var H=_e(ne);return this.startOf(Se)<=H&&H<=this.endOf(Se)},q.isAfter=function(ne,Se){return _e(ne)<this.startOf(Se)},q.isBefore=function(ne,Se){return this.endOf(Se)<_e(ne)},q.$g=function(ne,Se,H){return se.u(ne)?this[Se]:this.set(H,ne)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(ne,Se){var H=this,ye=!!se.u(Se)||Se,ke=se.p(ne),P=function(be,ht){var Ve=se.w(H.$u?Date.UTC(H.$y,ht,be):new Date(H.$y,ht,be),H);return ye?Ve:Ve.endOf(l)},Qe=function(be,ht){return se.w(H.toDate()[be].apply(H.toDate("s"),(ye?[0,0,0,0]:[23,59,59,999]).slice(ht)),H)},Ct=this.$W,tt=this.$M,De=this.$D,ce="set"+(this.$u?"UTC":"");switch(ke){case m:return ye?P(1,0):P(31,11);case d:return ye?P(1,tt):P(0,tt+1);case c:var Ge=this.$locale().weekStart||0,Ue=(Ct<Ge?Ct+7:Ct)-Ge;return P(ye?De-Ue:De+(6-Ue),tt);case l:case k:return Qe(ce+"Hours",0);case u:return Qe(ce+"Minutes",1);case o:return Qe(ce+"Seconds",2);case s:return Qe(ce+"Milliseconds",3);default:return this.clone()}},q.endOf=function(ne){return this.startOf(ne,!1)},q.$set=function(ne,Se){var H,ye=se.p(ne),ke="set"+(this.$u?"UTC":""),P=(H={},H[l]=ke+"Date",H[k]=ke+"Date",H[d]=ke+"Month",H[m]=ke+"FullYear",H[u]=ke+"Hours",H[o]=ke+"Minutes",H[s]=ke+"Seconds",H[a]=ke+"Milliseconds",H)[ye],Qe=ye===l?this.$D+(Se-this.$W):Se;if(ye===d||ye===m){var Ct=this.clone().set(k,1);Ct.$d[P](Qe),Ct.init(),this.$d=Ct.set(k,Math.min(this.$D,Ct.daysInMonth())).$d}else P&&this.$d[P](Qe);return this.init(),this},q.set=function(ne,Se){return this.clone().$set(ne,Se)},q.get=function(ne){return this[se.p(ne)]()},q.add=function(ne,Se){var H,ye=this;ne=Number(ne);var ke=se.p(Se),P=function(tt){var De=_e(ye);return se.w(De.date(De.date()+Math.round(tt*ne)),ye)};if(ke===d)return this.set(d,this.$M+ne);if(ke===m)return this.set(m,this.$y+ne);if(ke===l)return P(1);if(ke===c)return P(7);var Qe=(H={},H[o]=n,H[u]=i,H[s]=r,H)[ke]||1,Ct=this.$d.getTime()+ne*Qe;return se.w(Ct,this)},q.subtract=function(ne,Se){return this.add(-1*ne,Se)},q.format=function(ne){var Se=this,H=this.$locale();if(!this.isValid())return H.invalidDate||L;var ye=ne||"YYYY-MM-DDTHH:mm:ssZ",ke=se.z(this),P=this.$H,Qe=this.$m,Ct=this.$M,tt=H.weekdays,De=H.months,ce=H.meridiem,Ge=function(ht,Ve,Kt,Rt){return ht&&(ht[Ve]||ht(Se,ye))||Kt[Ve].slice(0,Rt)},Ue=function(ht){return se.s(P%12||12,ht,"0")},be=ce||function(ht,Ve,Kt){var Rt=ht<12?"AM":"PM";return Kt?Rt.toLowerCase():Rt};return ye.replace(z,function(ht,Ve){return Ve||function(Kt){switch(Kt){case"YY":return String(Se.$y).slice(-2);case"YYYY":return se.s(Se.$y,4,"0");case"M":return Ct+1;case"MM":return se.s(Ct+1,2,"0");case"MMM":return Ge(H.monthsShort,Ct,De,3);case"MMMM":return Ge(De,Ct);case"D":return Se.$D;case"DD":return se.s(Se.$D,2,"0");case"d":return String(Se.$W);case"dd":return Ge(H.weekdaysMin,Se.$W,tt,2);case"ddd":return Ge(H.weekdaysShort,Se.$W,tt,3);case"dddd":return tt[Se.$W];case"H":return String(P);case"HH":return se.s(P,2,"0");case"h":return Ue(1);case"hh":return Ue(2);case"a":return be(P,Qe,!0);case"A":return be(P,Qe,!1);case"m":return String(Qe);case"mm":return se.s(Qe,2,"0");case"s":return String(Se.$s);case"ss":return se.s(Se.$s,2,"0");case"SSS":return se.s(Se.$ms,3,"0");case"Z":return ke}return null}(ht)||ke.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(ne,Se,H){var ye,ke=this,P=se.p(Se),Qe=_e(ne),Ct=(Qe.utcOffset()-this.utcOffset())*n,tt=this-Qe,De=function(){return se.m(ke,Qe)};switch(P){case m:ye=De()/12;break;case d:ye=De();break;case f:ye=De()/3;break;case c:ye=(tt-Ct)/6048e5;break;case l:ye=(tt-Ct)/864e5;break;case u:ye=tt/i;break;case o:ye=tt/n;break;case s:ye=tt/r;break;default:ye=tt}return H?ye:se.a(ye)},q.daysInMonth=function(){return this.endOf(d).$D},q.$locale=function(){return Pe[this.$L]},q.locale=function(ne,Se){if(!ne)return this.$L;var H=this.clone(),ye=Ie(ne,Se,!0);return ye&&(H.$L=ye),H},q.clone=function(){return se.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},oe}(),te=Te.prototype;return _e.prototype=te,[["$ms",a],["$s",s],["$m",o],["$H",u],["$W",l],["$M",d],["$y",m],["$D",k]].forEach(function(oe){te[oe[1]]=function(q){return this.$g(q,oe[0],oe[1])}}),_e.extend=function(oe,q){return oe.$i||(oe(q,Te,_e),oe.$i=!0),_e},_e.locale=Ie,_e.isDayjs=Z,_e.unix=function(oe){return _e(1e3*oe)},_e.en=Pe[Fe],_e.Ls=Pe,_e.p={},_e})})(l_);var HM=l_.exports;const c_=Q0(HM);function qM(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}/**
431
431
  * @license
432
432
  * Copyright 2017 Google LLC
433
433
  * SPDX-License-Identifier: BSD-3-Clause
@@ -439,11 +439,11 @@
439
439
  `);const i=this.lexer.state.top;this.lexer.state.top=!0;const a=this.lexer.blockTokens(n);return this.lexer.state.top=i,{type:"blockquote",raw:r[0],tokens:a,text:n}}}list(e){let r=this.rules.block.list.exec(e);if(r){let n=r[1].trim();const i=n.length>1,a={type:"list",raw:"",ordered:i,start:i?+n.slice(0,-1):"",loose:!1,items:[]};n=i?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=i?n:"[*+-]");const s=new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`);let o="",u="",l=!1;for(;e;){let c=!1;if(!(r=s.exec(e))||this.rules.block.hr.test(e))break;o=r[0],e=e.substring(o.length);let d=r[2].split(`
440
440
  `,1)[0].replace(/^\t+/,z=>" ".repeat(3*z.length)),f=e.split(`
441
441
  `,1)[0],m=0;this.options.pedantic?(m=2,u=d.trimStart()):(m=r[2].search(/[^ ]/),m=m>4?1:m,u=d.slice(m),m+=r[1].length);let k=!1;if(!d&&/^ *$/.test(f)&&(o+=f+`
442
- `,e=e.substring(f.length+1),c=!0),!c){const z=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),re=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),Me=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:\`\`\`|~~~)`),Oe=new RegExp(`^ {0,${Math.min(3,m-1)}}#`);for(;e;){const Be=e.split(`
443
- `,1)[0];if(f=Be,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),Me.test(f)||Oe.test(f)||z.test(f)||re.test(e))break;if(f.search(/[^ ]/)>=m||!f.trim())u+=`
442
+ `,e=e.substring(f.length+1),c=!0),!c){const z=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),re=new RegExp(`^ {0,${Math.min(3,m-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),Me=new RegExp(`^ {0,${Math.min(3,m-1)}}(?:\`\`\`|~~~)`),Oe=new RegExp(`^ {0,${Math.min(3,m-1)}}#`);for(;e;){const Fe=e.split(`
443
+ `,1)[0];if(f=Fe,this.options.pedantic&&(f=f.replace(/^ {1,4}(?=( {4})*[^ ])/g," ")),Me.test(f)||Oe.test(f)||z.test(f)||re.test(e))break;if(f.search(/[^ ]/)>=m||!f.trim())u+=`
444
444
  `+f.slice(m);else{if(k||d.search(/[^ ]/)>=4||Me.test(d)||Oe.test(d)||re.test(d))break;u+=`
445
- `+f}!k&&!f.trim()&&(k=!0),o+=Be+`
446
- `,e=e.substring(Be.length+1),d=f.slice(m)}}a.loose||(l?a.loose=!0:/\n *\n *$/.test(o)&&(l=!0));let L=null,N;this.options.gfm&&(L=/^\[[ xX]\] /.exec(u),L&&(N=L[0]!=="[ ] ",u=u.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:o,task:!!L,checked:N,loose:!1,text:u,tokens:[]}),a.raw+=o}a.items[a.items.length-1].raw=o.trimEnd(),a.items[a.items.length-1].text=u.trimEnd(),a.raw=a.raw.trimEnd();for(let c=0;c<a.items.length;c++)if(this.lexer.state.top=!1,a.items[c].tokens=this.lexer.blockTokens(a.items[c].text,[]),!a.loose){const d=a.items[c].tokens.filter(m=>m.type==="space"),f=d.length>0&&d.some(m=>/\n.*\n/.test(m.raw));a.loose=f}if(a.loose)for(let c=0;c<a.items.length;c++)a.items[c].loose=!0;return a}}html(e){const r=this.rules.block.html.exec(e);if(r)return{type:"html",block:!0,raw:r[0],pre:r[1]==="pre"||r[1]==="script"||r[1]==="style",text:r[0]}}def(e){const r=this.rules.block.def.exec(e);if(r){const n=r[1].toLowerCase().replace(/\s+/g," "),i=r[2]?r[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=r[3]?r[3].substring(1,r[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):r[3];return{type:"def",tag:n,raw:r[0],href:i,title:a}}}table(e){const r=this.rules.block.table.exec(e);if(!r||!/[:|]/.test(r[2]))return;const n=g_(r[1]),i=r[2].replace(/^\||\| *$/g,"").split("|"),a=r[3]&&r[3].trim()?r[3].replace(/\n[ \t]*$/,"").split(`
445
+ `+f}!k&&!f.trim()&&(k=!0),o+=Fe+`
446
+ `,e=e.substring(Fe.length+1),d=f.slice(m)}}a.loose||(l?a.loose=!0:/\n *\n *$/.test(o)&&(l=!0));let L=null,N;this.options.gfm&&(L=/^\[[ xX]\] /.exec(u),L&&(N=L[0]!=="[ ] ",u=u.replace(/^\[[ xX]\] +/,""))),a.items.push({type:"list_item",raw:o,task:!!L,checked:N,loose:!1,text:u,tokens:[]}),a.raw+=o}a.items[a.items.length-1].raw=o.trimEnd(),a.items[a.items.length-1].text=u.trimEnd(),a.raw=a.raw.trimEnd();for(let c=0;c<a.items.length;c++)if(this.lexer.state.top=!1,a.items[c].tokens=this.lexer.blockTokens(a.items[c].text,[]),!a.loose){const d=a.items[c].tokens.filter(m=>m.type==="space"),f=d.length>0&&d.some(m=>/\n.*\n/.test(m.raw));a.loose=f}if(a.loose)for(let c=0;c<a.items.length;c++)a.items[c].loose=!0;return a}}html(e){const r=this.rules.block.html.exec(e);if(r)return{type:"html",block:!0,raw:r[0],pre:r[1]==="pre"||r[1]==="script"||r[1]==="style",text:r[0]}}def(e){const r=this.rules.block.def.exec(e);if(r){const n=r[1].toLowerCase().replace(/\s+/g," "),i=r[2]?r[2].replace(/^<(.*)>$/,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",a=r[3]?r[3].substring(1,r[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):r[3];return{type:"def",tag:n,raw:r[0],href:i,title:a}}}table(e){const r=this.rules.block.table.exec(e);if(!r||!/[:|]/.test(r[2]))return;const n=g_(r[1]),i=r[2].replace(/^\||\| *$/g,"").split("|"),a=r[3]&&r[3].trim()?r[3].replace(/\n[ \t]*$/,"").split(`
447
447
  `):[],s={type:"table",raw:r[0],header:[],align:[],rows:[]};if(n.length===i.length){for(const o of i)/^ *-+: *$/.test(o)?s.align.push("right"):/^ *:-+: *$/.test(o)?s.align.push("center"):/^ *:-+ *$/.test(o)?s.align.push("left"):s.align.push(null);for(const o of n)s.header.push({text:o,tokens:this.lexer.inline(o)});for(const o of a)s.rows.push(g_(o,s.header.length).map(u=>({text:u,tokens:this.lexer.inline(u)})));return s}}lheading(e){const r=this.rules.block.lheading.exec(e);if(r)return{type:"heading",raw:r[0],depth:r[2].charAt(0)==="="?1:2,text:r[1],tokens:this.lexer.inline(r[1])}}paragraph(e){const r=this.rules.block.paragraph.exec(e);if(r){const n=r[1].charAt(r[1].length-1)===`
448
448
  `?r[1].slice(0,-1):r[1];return{type:"paragraph",raw:r[0],text:n,tokens:this.lexer.inline(n)}}}text(e){const r=this.rules.block.text.exec(e);if(r)return{type:"text",raw:r[0],text:r[0],tokens:this.lexer.inline(r[0])}}escape(e){const r=this.rules.inline.escape.exec(e);if(r)return{type:"escape",raw:r[0],text:qn(r[1])}}tag(e){const r=this.rules.inline.tag.exec(e);if(r)return!this.lexer.state.inLink&&/^<a /i.test(r[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&/^<\/a>/i.test(r[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&/^<(pre|code|kbd|script)(\s|>)/i.test(r[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&/^<\/(pre|code|kbd|script)(\s|>)/i.test(r[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:r[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:r[0]}}link(e){const r=this.rules.inline.link.exec(e);if(r){const n=r[2].trim();if(!this.options.pedantic&&/^</.test(n)){if(!/>$/.test(n))return;const s=vf(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{const s=QM(r[2],"()");if(s>-1){const o=(r[0].indexOf("!")===0?5:4)+r[1].length+s;r[2]=r[2].substring(0,s),r[0]=r[0].substring(0,o).trim(),r[3]=""}}let i=r[2],a="";if(this.options.pedantic){const s=/^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(i);s&&(i=s[1],a=s[3])}else a=r[3]?r[3].slice(1,-1):"";return i=i.trim(),/^</.test(i)&&(this.options.pedantic&&!/>$/.test(n)?i=i.slice(1):i=i.slice(1,-1)),m_(r,{href:i&&i.replace(this.rules.inline.anyPunctuation,"$1"),title:a&&a.replace(this.rules.inline.anyPunctuation,"$1")},r[0],this.lexer)}}reflink(e,r){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){const i=(n[2]||n[1]).replace(/\s+/g," "),a=r[i.toLowerCase()];if(!a){const s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return m_(n,a,n[0],this.lexer)}}emStrong(e,r,n=""){let i=this.rules.inline.emStrongLDelim.exec(e);if(!(!i||i[3]&&n.match(/[\p{L}\p{N}]/u))&&(!(i[1]||i[2])||!n||this.rules.inline.punctuation.exec(n))){const a=[...i[0]].length-1;let s,o,u=a,l=0;const c=i[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,r=r.slice(-1*e.length+a);(i=c.exec(r))!=null;){if(s=i[1]||i[2]||i[3]||i[4]||i[5]||i[6],!s)continue;if(o=[...s].length,i[3]||i[4]){u+=o;continue}else if((i[5]||i[6])&&a%3&&!((a+o)%3)){l+=o;continue}if(u-=o,u>0)continue;o=Math.min(o,o+u+l);const d=[...i[0]][0].length,f=e.slice(0,a+i.index+d+o);if(Math.min(a,o)%2){const k=f.slice(1,-1);return{type:"em",raw:f,text:k,tokens:this.lexer.inlineTokens(k)}}const m=f.slice(2,-2);return{type:"strong",raw:f,text:m,tokens:this.lexer.inlineTokens(m)}}}}codespan(e){const r=this.rules.inline.code.exec(e);if(r){let n=r[2].replace(/\n/g," ");const i=/[^ ]/.test(n),a=/^ /.test(n)&&/ $/.test(n);return i&&a&&(n=n.substring(1,n.length-1)),n=qn(n,!0),{type:"codespan",raw:r[0],text:n}}}br(e){const r=this.rules.inline.br.exec(e);if(r)return{type:"br",raw:r[0]}}del(e){const r=this.rules.inline.del.exec(e);if(r)return{type:"del",raw:r[0],text:r[2],tokens:this.lexer.inlineTokens(r[2])}}autolink(e){const r=this.rules.inline.autolink.exec(e);if(r){let n,i;return r[2]==="@"?(n=qn(r[1]),i="mailto:"+n):(n=qn(r[1]),i=n),{type:"link",raw:r[0],text:n,href:i,tokens:[{type:"text",raw:n,text:n}]}}}url(e){var r;let n;if(n=this.rules.inline.url.exec(e)){let i,a;if(n[2]==="@")i=qn(n[0]),a="mailto:"+i;else{let s;do s=n[0],n[0]=((r=this.rules.inline._backpedal.exec(n[0]))==null?void 0:r[0])??"";while(s!==n[0]);i=qn(n[0]),n[1]==="www."?a="http://"+n[0]:a=n[0]}return{type:"link",raw:n[0],text:i,href:a,tokens:[{type:"text",raw:i,text:i}]}}}inlineText(e){const r=this.rules.inline.text.exec(e);if(r){let n;return this.lexer.state.inRawBlock?n=r[0]:n=qn(r[0]),{type:"text",raw:r[0],text:n}}}}const eN=/^(?: *(?:\n|$))+/,tN=/^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/,rN=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,oc=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,nN=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,y_=/(?:[*+-]|\d{1,9}[.)])/,b_=Er(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g,y_).replace(/blockCode/g,/ {4}/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).getRegex(),$v=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,iN=/^[^\n]+/,Tv=/(?!\s*\])(?:\\.|[^\[\]\\])+/,aN=Er(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label",Tv).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),sN=Er(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,y_).getRegex(),mf="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Cv=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,oN=Er("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))","i").replace("comment",Cv).replace("tag",mf).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),w_=Er($v).replace("hr",oc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",mf).getRegex(),uN=Er(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",w_).getRegex(),Ev={blockquote:uN,code:tN,def:aN,fences:rN,heading:nN,hr:oc,html:oN,lheading:b_,list:sN,newline:eN,paragraph:w_,table:sc,text:iN},__=Er("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",oc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code"," {4}[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",mf).getRegex(),lN={...Ev,table:__,paragraph:Er($v).replace("hr",oc).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",__).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",mf).getRegex()},cN={...Ev,html:Er(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Cv).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:sc,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:Er($v).replace("hr",oc).replace("heading",` *#{1,6} *[^
449
449
  ]`).replace("lheading",b_).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},k_=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,dN=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,S_=/^( {2,}|\\)\n(?!\s*$)/,fN=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,uc="\\p{P}\\p{S}",hN=Er(/^((?![*_])[\spunctuation])/,"u").replace(/punctuation/g,uc).getRegex(),pN=/\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g,vN=Er(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/,"u").replace(/punct/g,uc).getRegex(),gN=Er("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])","gu").replace(/punct/g,uc).getRegex(),mN=Er("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])","gu").replace(/punct/g,uc).getRegex(),yN=Er(/\\([punct])/,"gu").replace(/punct/g,uc).getRegex(),bN=Er(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),wN=Er(Cv).replace("(?:-->|$)","-->").getRegex(),_N=Er("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",wN).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),yf=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,kN=Er(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label",yf).replace("href",/<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),$_=Er(/^!?\[(label)\]\[(ref)\]/).replace("label",yf).replace("ref",Tv).getRegex(),T_=Er(/^!?\[(ref)\](?:\[\])?/).replace("ref",Tv).getRegex(),SN=Er("reflink|nolink(?!\\()","g").replace("reflink",$_).replace("nolink",T_).getRegex(),Iv={_backpedal:sc,anyPunctuation:yN,autolink:bN,blockSkip:pN,br:S_,code:dN,del:sc,emStrongLDelim:vN,emStrongRDelimAst:gN,emStrongRDelimUnd:mN,escape:k_,link:kN,nolink:T_,punctuation:hN,reflink:$_,reflinkSearch:SN,tag:_N,text:fN,url:sc},$N={...Iv,link:Er(/^!?\[(label)\]\((.*?)\)/).replace("label",yf).getRegex(),reflink:Er(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",yf).getRegex()},xv={...Iv,escape:Er(k_).replace("])","~|])").getRegex(),url:Er(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},TN={...xv,br:Er(S_).replace("{2,}","*").getRegex(),text:Er(xv.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},bf={normal:Ev,gfm:lN,pedantic:cN},lc={normal:Iv,gfm:xv,breaks:TN,pedantic:$N};class zi{constructor(e){Br(this,"tokens"),Br(this,"options"),Br(this,"state"),Br(this,"tokenizer"),Br(this,"inlineQueue"),this.tokens=[],this.tokens.links=Object.create(null),this.options=e||io,this.options.tokenizer=this.options.tokenizer||new gf,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const r={block:bf.normal,inline:lc.normal};this.options.pedantic?(r.block=bf.pedantic,r.inline=lc.pedantic):this.options.gfm&&(r.block=bf.gfm,this.options.breaks?r.inline=lc.breaks:r.inline=lc.gfm),this.tokenizer.rules=r}static get rules(){return{block:bf,inline:lc}}static lex(e,r){return new zi(r).lex(e)}static lexInline(e,r){return new zi(r).inlineTokens(e)}lex(e){e=e.replace(/\r\n|\r/g,`
@@ -618,7 +618,7 @@ Please report this to https://github.com/markedjs/marked.`,t){const n="<p>An err
618
618
  .name {
619
619
  color: #8c8c8c;
620
620
  }
621
- `],ei([Lr({type:Object})],Mn.prototype,"options",2),ei([Lr()],Mn.prototype,"disableInput",2),ei([Lr()],Mn.prototype,"showTyping",2),ei([Ws()],Mn.prototype,"messages",2),ei([Ws()],Mn.prototype,"inputValue",2),ei([Ws()],Mn.prototype,"internalShowTyping",2),ei([Ws()],Mn.prototype,"showPopoverDisclaimer",2),ei([Ws()],Mn.prototype,"previousThreads",2),ei([Gd("#chat-container")],Mn.prototype,"chatContainer",2),ei([Gd("#message-input")],Mn.prototype,"inputElement",2),ei([vv.debounce(1)],Mn.prototype,"scrollChatToBottom",1),Mn=ei([ji("iai-chat")],Mn);var x_={exports:{}};(function(t){(function(e){if(typeof window>"u")return;var r=0,n=!1,i=!1,a="message",s=a.length,o="[iFrameSizer]",u=o.length,l=null,c=window.requestAnimationFrame,d=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),f={},m=null,k=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){Z("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}});function L(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function N(Q,je,st){Q.addEventListener(je,st,!1)}function z(Q,je,st){Q.removeEventListener(je,st,!1)}function re(){var Q=["moz","webkit","o","ms"],je;for(je=0;je<Q.length&&!c;je+=1)c=window[Q[je]+"RequestAnimationFrame"];c?c=c.bind(window):Pe("setup","RequestAnimationFrame not supported")}function Me(Q){var je="Host page: "+Q;return window.top!==window.self&&(je=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+Q:"Nested host page: "+Q),je}function Oe(Q){return o+"["+Me(Q)+"]"}function Be(Q){return f[Q]?f[Q].log:n}function Pe(Q,je){Ie("log",Q,je,Be(Q))}function Ze(Q,je){Ie("info",Q,je,Be(Q))}function Z(Q,je){Ie("warn",Q,je,!0)}function Ie(Q,je,st,Re){Re===!0&&typeof window.console=="object"&&console[Q](Oe(je),st)}function _e(Q){function je(){function we(){H(ae),q(ge),Bt("onResized",ae)}ot("Height"),ot("Width"),ye(we,ae,"init")}function st(){var we=$e.slice(u).split(":"),K=we[1]?parseInt(we[1],10):0,he=f[we[0]]&&f[we[0]].iframe,G=getComputedStyle(he);return{iframe:he,id:we[0],height:K+Re(G)+kt(G),width:we[2],type:we[3]}}function Re(we){if(we.boxSizing!=="border-box")return 0;var K=we.paddingTop?parseInt(we.paddingTop,10):0,he=we.paddingBottom?parseInt(we.paddingBottom,10):0;return K+he}function kt(we){if(we.boxSizing!=="border-box")return 0;var K=we.borderTopWidth?parseInt(we.borderTopWidth,10):0,he=we.borderBottomWidth?parseInt(we.borderBottomWidth,10):0;return K+he}function ot(we){var K=Number(f[ge]["max"+we]),he=Number(f[ge]["min"+we]),G=we.toLowerCase(),de=Number(ae[G]);Pe(ge,"Checking "+G+" is in range "+he+"-"+K),de<he&&(de=he,Pe(ge,"Set "+G+" to min value")),de>K&&(de=K,Pe(ge,"Set "+G+" to max value")),ae[G]=""+de}function ar(){function we(){function G(){var X=0,Ye=!1;for(Pe(ge,"Checking connection is from allowed list of origins: "+he);X<he.length;X++)if(he[X]===K){Ye=!0;break}return Ye}function de(){var X=f[ge]&&f[ge].remoteHost;return Pe(ge,"Checking connection is from: "+X),K===X}return he.constructor===Array?G():de()}var K=Q.origin,he=f[ge]&&f[ge].checkOrigin;if(he&&""+K!="null"&&!we())throw new Error("Unexpected message received from: "+K+" for "+ae.iframe.id+". Message was: "+Q.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function mr(){return o===(""+$e).slice(0,u)&&$e.slice(u).split(":")[0]in f}function Xe(){var we=ae.type in{true:1,false:1,undefined:1};return we&&Pe(ge,"Ignoring init message from meta parent page"),we}function Or(we){return $e.slice($e.indexOf(":")+s+we)}function jr(we){Pe(ge,"onMessage passed: {iframe: "+ae.iframe.id+", message: "+we+"}"),Bt("onMessage",{iframe:ae.iframe,message:JSON.parse(we)}),Pe(ge,"--")}function lr(){var we=document.body.getBoundingClientRect(),K=ae.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:K.height,iframeWidth:K.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(K.top-we.top,10),offsetLeft:parseInt(K.left-we.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}function cr(we,K){function he(){ke("Send Page Info","pageInfo:"+lr(),we,K)}ce(he,32,K)}function Vt(){function we(de,X){function Ye(){f[G]?cr(f[G].iframe,G):K()}["scroll","resize"].forEach(function(ze){Pe(G,de+ze+" listener for sendPageInfo"),X(window,ze,Ye)})}function K(){we("Remove ",z)}function he(){we("Add ",N)}var G=ge;he(),f[G]&&(f[G].stopPageInfo=K)}function At(){f[ge]&&f[ge].stopPageInfo&&(f[ge].stopPageInfo(),delete f[ge].stopPageInfo)}function M(){var we=!0;return ae.iframe===null&&(Z(ge,"IFrame ("+ae.id+") not found"),we=!1),we}function V(we){var K=we.getBoundingClientRect();return oe(ge),{x:Math.floor(Number(K.left)+Number(l.x)),y:Math.floor(Number(K.top)+Number(l.y))}}function ie(we){function K(){l=X,Fe(),Pe(ge,"--")}function he(){return{x:Number(ae.width)+de.x,y:Number(ae.height)+de.y}}function G(){window.parentIFrame?window.parentIFrame["scrollTo"+(we?"Offset":"")](X.x,X.y):Z(ge,"Unable to scroll to requested position, window.parentIFrame not found")}var de=we?V(ae.iframe):{x:0,y:0},X=he();Pe(ge,"Reposition requested from iFrame (offset x:"+de.x+" y:"+de.y+")"),window.top===window.self?K():G()}function Fe(){Bt("onScroll",l)===!1?ne():q(ge)}function lt(we){function K(){var Ye=V(X);Pe(ge,"Moving to in page link (#"+G+") at x: "+Ye.x+" y: "+Ye.y),l={x:Ye.x,y:Ye.y},Fe(),Pe(ge,"--")}function he(){window.parentIFrame?window.parentIFrame.moveToAnchor(G):Pe(ge,"In page link #"+G+" not found and window.parentIFrame not found")}var G=we.split("#")[1]||"",de=decodeURIComponent(G),X=document.getElementById(de)||document.getElementsByName(de)[0];X?K():window.top===window.self?Pe(ge,"In page link #"+G+" not found"):he()}function yt(we){var K={};if(Number(ae.width)===0&&Number(ae.height)===0){var he=Or(9).split(":");K={x:he[1],y:he[0]}}else K={x:ae.width,y:ae.height};Bt(we,{iframe:ae.iframe,screenX:Number(K.x),screenY:Number(K.y),type:ae.type})}function Bt(we,K){return se(ge,we,K)}function er(){switch(f[ge]&&f[ge].firstRun&&pe(),ae.type){case"close":{te(ae.iframe);break}case"message":{jr(Or(6));break}case"mouseenter":{yt("onMouseEnter");break}case"mouseleave":{yt("onMouseLeave");break}case"autoResize":{f[ge].autoResize=JSON.parse(Or(9));break}case"scrollTo":{ie(!1);break}case"scrollToOffset":{ie(!0);break}case"pageInfo":{cr(f[ge]&&f[ge].iframe,ge),Vt();break}case"pageInfoStop":{At();break}case"inPageLink":{lt(Or(9));break}case"reset":{Se(ae);break}case"init":{je(),Bt("onInit",ae.iframe);break}default:Number(ae.width)===0&&Number(ae.height)===0?Z("Unsupported message received ("+ae.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):je()}}function Ee(we){var K=!0;return f[we]||(K=!1,Z(ae.type+" No settings for "+we+". Message was: "+$e)),K}function Ne(){for(var we in f)ke("iFrame requested init",P(we),f[we].iframe,we)}function pe(){f[ge]&&(f[ge].firstRun=!1)}var $e=Q.data,ae={},ge=null;$e==="[iFrameResizerChild]Ready"?Ne():mr()?(ae=st(),ge=ae.id,f[ge]&&(f[ge].loaded=!0),!Xe()&&Ee(ge)&&(Pe(ge,"Received: "+$e),M()&&ar()&&er())):Ze(ge,"Ignored: "+$e)}function se(Q,je,st){var Re=null,kt=null;if(f[Q])if(Re=f[Q][je],typeof Re=="function")kt=Re(st);else throw new TypeError(je+" on iFrame["+Q+"] is not a function");return kt}function Te(Q){var je=Q.id;delete f[je]}function te(Q){var je=Q.id;if(se(je,"onClose",je)===!1){Pe(je,"Close iframe cancelled by onClose event");return}Pe(je,"Removing iFrame: "+je);try{Q.parentNode&&Q.parentNode.removeChild(Q)}catch(st){Z(st)}se(je,"onClosed",je),Pe(je,"--"),Te(Q)}function oe(Q){l===null&&(l={x:window.pageXOffset===e?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===e?document.documentElement.scrollTop:window.pageYOffset},Pe(Q,"Get page position: "+l.x+","+l.y))}function q(Q){l!==null&&(window.scrollTo(l.x,l.y),Pe(Q,"Set page position: "+l.x+","+l.y),ne())}function ne(){l=null}function Se(Q){function je(){H(Q),ke("reset","reset",Q.iframe,Q.id)}Pe(Q.id,"Size reset requested by "+(Q.type==="init"?"host page":"iFrame")),oe(Q.id),ye(je,Q,"reset")}function H(Q){function je(ot){if(!Q.id){Pe("undefined","messageData id not set");return}Q.iframe.style[ot]=Q[ot]+"px",Pe(Q.id,"IFrame ("+kt+") "+ot+" set to "+Q[ot]+"px")}function st(ot){!i&&Q[ot]==="0"&&(i=!0,Pe(kt,"Hidden iFrame detected, creating visibility listener"),Ge())}function Re(ot){je(ot),st(ot)}var kt=Q.iframe.id;f[kt]&&(f[kt].sizeHeight&&Re("height"),f[kt].sizeWidth&&Re("width"))}function ye(Q,je,st){st!==je.type&&c&&!window.jasmine?(Pe(je.id,"Requesting animation frame"),c(Q)):Q()}function ke(Q,je,st,Re,kt){function ot(){var jr=f[Re]&&f[Re].targetOrigin;Pe(Re,"["+Q+"] Sending msg to iframe["+Re+"] ("+je+") targetOrigin: "+jr),st.contentWindow.postMessage(o+je,jr)}function ar(){Z(Re,"["+Q+"] IFrame("+Re+") not found")}function mr(){st&&"contentWindow"in st&&st.contentWindow!==null?ot():ar()}function Xe(){function jr(){f[Re]&&!f[Re].loaded&&!Or&&(Or=!0,Z(Re,"IFrame has not responded within "+f[Re].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}kt&&f[Re]&&f[Re].warningTimeout&&(f[Re].msgTimeout=setTimeout(jr,f[Re].warningTimeout))}var Or=!1;Re=Re||st.id,f[Re]&&(mr(),Xe())}function P(Q){return Q+":"+f[Q].bodyMarginV1+":"+f[Q].sizeWidth+":"+f[Q].log+":"+f[Q].interval+":"+f[Q].enablePublicMethods+":"+f[Q].autoResize+":"+f[Q].bodyMargin+":"+f[Q].heightCalculationMethod+":"+f[Q].bodyBackground+":"+f[Q].bodyPadding+":"+f[Q].tolerance+":"+f[Q].inPageLinks+":"+f[Q].resizeFrom+":"+f[Q].widthCalculationMethod+":"+f[Q].mouseEvents}function Qe(Q){return typeof Q=="number"}function Ct(Q,je){function st(){function ie(lt){var yt=f[V][lt];yt!==1/0&&yt!==0&&(Q.style[lt]=Qe(yt)?yt+"px":yt,Pe(V,"Set "+lt+" = "+Q.style[lt]))}function Fe(lt){if(f[V]["min"+lt]>f[V]["max"+lt])throw new Error("Value for min"+lt+" can not be greater than max"+lt)}Fe("Height"),Fe("Width"),ie("maxHeight"),ie("minHeight"),ie("maxWidth"),ie("minWidth")}function Re(){var ie=je&&je.id||k.id+r++;return document.getElementById(ie)!==null&&(ie+=r++),ie}function kt(ie){if(typeof ie!="string")throw new TypeError("Invaild id for iFrame. Expected String");return ie===""&&(Q.id=ie=Re(),n=(je||{}).log,Pe(ie,"Added missing iframe ID: "+ie+" ("+Q.src+")")),ie}function ot(){switch(Pe(V,"IFrame scrolling "+(f[V]&&f[V].scrolling?"enabled":"disabled")+" for "+V),Q.style.overflow=(f[V]&&f[V].scrolling)===!1?"hidden":"auto",f[V]&&f[V].scrolling){case"omit":break;case!0:{Q.scrolling="yes";break}case!1:{Q.scrolling="no";break}default:Q.scrolling=f[V]?f[V].scrolling:"no"}}function ar(){(typeof(f[V]&&f[V].bodyMargin)=="number"||(f[V]&&f[V].bodyMargin)==="0")&&(f[V].bodyMarginV1=f[V].bodyMargin,f[V].bodyMargin=""+f[V].bodyMargin+"px")}function mr(){var ie=f[V]&&f[V].firstRun,Fe=f[V]&&f[V].heightCalculationMethod in d;!ie&&Fe&&Se({iframe:Q,height:0,width:0,type:"init"})}function Xe(){f[V]&&(f[V].iframe.iFrameResizer={close:te.bind(null,f[V].iframe),removeListeners:Te.bind(null,f[V].iframe),resize:ke.bind(null,"Window resize","resize",f[V].iframe),moveToAnchor:function(ie){ke("Move to anchor","moveToAnchor:"+ie,f[V].iframe,V)},sendMessage:function(ie){ie=JSON.stringify(ie),ke("Send Message","message:"+ie,f[V].iframe,V)}})}function Or(ie){function Fe(){ke("iFrame.onload",ie,Q,e,!0),mr()}function lt(Bt){if(Q.parentNode){var er=new Bt(function(Ee){Ee.forEach(function(Ne){var pe=Array.prototype.slice.call(Ne.removedNodes);pe.forEach(function($e){$e===Q&&te(Q)})})});er.observe(Q.parentNode,{childList:!0})}}var yt=L();yt&&lt(yt),N(Q,"load",Fe),ke("init",ie,Q,e,!0)}function jr(ie){if(typeof ie!="object")throw new TypeError("Options is not an object")}function lr(ie){for(var Fe in k)Object.prototype.hasOwnProperty.call(k,Fe)&&(f[V][Fe]=Object.prototype.hasOwnProperty.call(ie,Fe)?ie[Fe]:k[Fe])}function cr(ie){return ie===""||ie.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":ie}function Vt(ie){var Fe=ie.split("Callback");if(Fe.length===2){var lt="on"+Fe[0].charAt(0).toUpperCase()+Fe[0].slice(1);this[lt]=this[ie],delete this[ie],Z(V,"Deprecated: '"+ie+"' has been renamed '"+lt+"'. The old method will be removed in the next major version.")}}function At(ie){ie=ie||{},f[V]=Object.create(null),f[V].iframe=Q,f[V].firstRun=!0,f[V].remoteHost=Q.src&&Q.src.split("/").slice(0,3).join("/"),jr(ie),Object.keys(ie).forEach(Vt,ie),lr(ie),f[V]&&(f[V].targetOrigin=f[V].checkOrigin===!0?cr(f[V].remoteHost):"*")}function M(){return V in f&&"iFrameResizer"in Q}var V=kt(Q.id);M()?Z(V,"Ignored iFrame, already setup."):(At(je),ot(),st(),ar(),Or(P(V)),Xe())}function tt(Q,je){m===null&&(m=setTimeout(function(){m=null,Q()},je))}var De={};function ce(Q,je,st){De[st]||(De[st]=setTimeout(function(){De[st]=null,Q()},je))}function Ge(){function Q(){function kt(ot){function ar(Xe){return(f[ot]&&f[ot].iframe.style[Xe])==="0px"}function mr(Xe){return Xe.offsetParent!==null}f[ot]&&mr(f[ot].iframe)&&(ar("height")||ar("width"))&&ke("Visibility change","resize",f[ot].iframe,ot)}Object.keys(f).forEach(function(ot){kt(ot)})}function je(kt){Pe("window","Mutation observed: "+kt[0].target+" "+kt[0].type),tt(Q,16)}function st(){var kt=document.querySelector("body"),ot={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},ar=new Re(je);ar.observe(kt,ot)}var Re=L();Re&&st()}function Ue(Q){function je(){ht("Window "+Q,"resize")}Pe("window","Trigger event: "+Q),tt(je,16)}function be(){function Q(){ht("Tab Visible","resize")}document.visibilityState!=="hidden"&&(Pe("document","Trigger event: Visibility change"),tt(Q,16))}function ht(Q,je){function st(Re){return f[Re]&&f[Re].resizeFrom==="parent"&&f[Re].autoResize&&!f[Re].firstRun}Object.keys(f).forEach(function(Re){st(Re)&&ke(Q,je,f[Re].iframe,Re)})}function Ve(){N(window,"message",_e),N(window,"resize",function(){Ue("resize")}),N(document,"visibilitychange",be),N(document,"-webkit-visibilitychange",be)}function Kt(){function Q(Re,kt){function ot(){if(kt.tagName){if(kt.tagName.toUpperCase()!=="IFRAME")throw new TypeError("Expected <IFRAME> tag, found <"+kt.tagName+">")}else throw new TypeError("Object is not a valid DOM element")}kt&&(ot(),Ct(kt,Re),st.push(kt))}function je(Re){Re&&Re.enablePublicMethods&&Z("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var st;return re(),Ve(),function(Re,kt){switch(st=[],je(Re),typeof kt){case"undefined":case"string":{Array.prototype.forEach.call(document.querySelectorAll(kt||"iframe"),Q.bind(e,Re));break}case"object":{Q(Re,kt);break}default:throw new TypeError("Unexpected data type ("+typeof kt+")")}return st}}function Rt(Q){Q.fn?Q.fn.iFrameResize||(Q.fn.iFrameResize=function(je){function st(Re,kt){Ct(kt,je)}return this.filter("iframe").each(st).end()}):Ze("","Unable to bind to jQuery, it is not fully loaded.")}window.jQuery!==e&&Rt(window.jQuery),t.exports=Kt(),window.iFrameResize=window.iFrameResize||Kt()})()})(x_);var PN=x_.exports;const MN=Q0(PN);var NN=Object.defineProperty,LN=Object.getOwnPropertyDescriptor,Nv=(t,e,r,n)=>{for(var i=n>1?void 0:n?LN(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&NN(e,r,i),i};let hc=class extends Pn{constructor(){super(...arguments),this.src="",this.showCloseButton=!1}async onLoad(t){MN({log:!1,heightCalculationMethod:"max",onMessage:({message:e})=>{this.dispatchEvent(new CustomEvent("message-received",{bubbles:!0,composed:!0,detail:e}))}},t.target)}close(){this.dispatchEvent(new CustomEvent("close"))}render(){return nr`
621
+ `],ei([Lr({type:Object})],Mn.prototype,"options",2),ei([Lr()],Mn.prototype,"disableInput",2),ei([Lr()],Mn.prototype,"showTyping",2),ei([Ws()],Mn.prototype,"messages",2),ei([Ws()],Mn.prototype,"inputValue",2),ei([Ws()],Mn.prototype,"internalShowTyping",2),ei([Ws()],Mn.prototype,"showPopoverDisclaimer",2),ei([Ws()],Mn.prototype,"previousThreads",2),ei([Gd("#chat-container")],Mn.prototype,"chatContainer",2),ei([Gd("#message-input")],Mn.prototype,"inputElement",2),ei([vv.debounce(1)],Mn.prototype,"scrollChatToBottom",1),Mn=ei([ji("iai-chat")],Mn);var x_={exports:{}};(function(t){(function(e){if(typeof window>"u")return;var r=0,n=!1,i=!1,a="message",s=a.length,o="[iFrameSizer]",u=o.length,l=null,c=window.requestAnimationFrame,d=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),f={},m=null,k=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){Z("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}});function L(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function N(Q,je,st){Q.addEventListener(je,st,!1)}function z(Q,je,st){Q.removeEventListener(je,st,!1)}function re(){var Q=["moz","webkit","o","ms"],je;for(je=0;je<Q.length&&!c;je+=1)c=window[Q[je]+"RequestAnimationFrame"];c?c=c.bind(window):Pe("setup","RequestAnimationFrame not supported")}function Me(Q){var je="Host page: "+Q;return window.top!==window.self&&(je=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+Q:"Nested host page: "+Q),je}function Oe(Q){return o+"["+Me(Q)+"]"}function Fe(Q){return f[Q]?f[Q].log:n}function Pe(Q,je){Ie("log",Q,je,Fe(Q))}function Ze(Q,je){Ie("info",Q,je,Fe(Q))}function Z(Q,je){Ie("warn",Q,je,!0)}function Ie(Q,je,st,Re){Re===!0&&typeof window.console=="object"&&console[Q](Oe(je),st)}function _e(Q){function je(){function we(){H(ae),q(ge),Bt("onResized",ae)}ot("Height"),ot("Width"),ye(we,ae,"init")}function st(){var we=$e.slice(u).split(":"),K=we[1]?parseInt(we[1],10):0,he=f[we[0]]&&f[we[0]].iframe,G=getComputedStyle(he);return{iframe:he,id:we[0],height:K+Re(G)+kt(G),width:we[2],type:we[3]}}function Re(we){if(we.boxSizing!=="border-box")return 0;var K=we.paddingTop?parseInt(we.paddingTop,10):0,he=we.paddingBottom?parseInt(we.paddingBottom,10):0;return K+he}function kt(we){if(we.boxSizing!=="border-box")return 0;var K=we.borderTopWidth?parseInt(we.borderTopWidth,10):0,he=we.borderBottomWidth?parseInt(we.borderBottomWidth,10):0;return K+he}function ot(we){var K=Number(f[ge]["max"+we]),he=Number(f[ge]["min"+we]),G=we.toLowerCase(),de=Number(ae[G]);Pe(ge,"Checking "+G+" is in range "+he+"-"+K),de<he&&(de=he,Pe(ge,"Set "+G+" to min value")),de>K&&(de=K,Pe(ge,"Set "+G+" to max value")),ae[G]=""+de}function ar(){function we(){function G(){var X=0,Ye=!1;for(Pe(ge,"Checking connection is from allowed list of origins: "+he);X<he.length;X++)if(he[X]===K){Ye=!0;break}return Ye}function de(){var X=f[ge]&&f[ge].remoteHost;return Pe(ge,"Checking connection is from: "+X),K===X}return he.constructor===Array?G():de()}var K=Q.origin,he=f[ge]&&f[ge].checkOrigin;if(he&&""+K!="null"&&!we())throw new Error("Unexpected message received from: "+K+" for "+ae.iframe.id+". Message was: "+Q.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function mr(){return o===(""+$e).slice(0,u)&&$e.slice(u).split(":")[0]in f}function Xe(){var we=ae.type in{true:1,false:1,undefined:1};return we&&Pe(ge,"Ignoring init message from meta parent page"),we}function Or(we){return $e.slice($e.indexOf(":")+s+we)}function jr(we){Pe(ge,"onMessage passed: {iframe: "+ae.iframe.id+", message: "+we+"}"),Bt("onMessage",{iframe:ae.iframe,message:JSON.parse(we)}),Pe(ge,"--")}function lr(){var we=document.body.getBoundingClientRect(),K=ae.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:K.height,iframeWidth:K.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(K.top-we.top,10),offsetLeft:parseInt(K.left-we.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}function cr(we,K){function he(){ke("Send Page Info","pageInfo:"+lr(),we,K)}ce(he,32,K)}function Vt(){function we(de,X){function Ye(){f[G]?cr(f[G].iframe,G):K()}["scroll","resize"].forEach(function(ze){Pe(G,de+ze+" listener for sendPageInfo"),X(window,ze,Ye)})}function K(){we("Remove ",z)}function he(){we("Add ",N)}var G=ge;he(),f[G]&&(f[G].stopPageInfo=K)}function At(){f[ge]&&f[ge].stopPageInfo&&(f[ge].stopPageInfo(),delete f[ge].stopPageInfo)}function M(){var we=!0;return ae.iframe===null&&(Z(ge,"IFrame ("+ae.id+") not found"),we=!1),we}function V(we){var K=we.getBoundingClientRect();return oe(ge),{x:Math.floor(Number(K.left)+Number(l.x)),y:Math.floor(Number(K.top)+Number(l.y))}}function ie(we){function K(){l=X,Be(),Pe(ge,"--")}function he(){return{x:Number(ae.width)+de.x,y:Number(ae.height)+de.y}}function G(){window.parentIFrame?window.parentIFrame["scrollTo"+(we?"Offset":"")](X.x,X.y):Z(ge,"Unable to scroll to requested position, window.parentIFrame not found")}var de=we?V(ae.iframe):{x:0,y:0},X=he();Pe(ge,"Reposition requested from iFrame (offset x:"+de.x+" y:"+de.y+")"),window.top===window.self?K():G()}function Be(){Bt("onScroll",l)===!1?ne():q(ge)}function lt(we){function K(){var Ye=V(X);Pe(ge,"Moving to in page link (#"+G+") at x: "+Ye.x+" y: "+Ye.y),l={x:Ye.x,y:Ye.y},Be(),Pe(ge,"--")}function he(){window.parentIFrame?window.parentIFrame.moveToAnchor(G):Pe(ge,"In page link #"+G+" not found and window.parentIFrame not found")}var G=we.split("#")[1]||"",de=decodeURIComponent(G),X=document.getElementById(de)||document.getElementsByName(de)[0];X?K():window.top===window.self?Pe(ge,"In page link #"+G+" not found"):he()}function yt(we){var K={};if(Number(ae.width)===0&&Number(ae.height)===0){var he=Or(9).split(":");K={x:he[1],y:he[0]}}else K={x:ae.width,y:ae.height};Bt(we,{iframe:ae.iframe,screenX:Number(K.x),screenY:Number(K.y),type:ae.type})}function Bt(we,K){return se(ge,we,K)}function er(){switch(f[ge]&&f[ge].firstRun&&pe(),ae.type){case"close":{te(ae.iframe);break}case"message":{jr(Or(6));break}case"mouseenter":{yt("onMouseEnter");break}case"mouseleave":{yt("onMouseLeave");break}case"autoResize":{f[ge].autoResize=JSON.parse(Or(9));break}case"scrollTo":{ie(!1);break}case"scrollToOffset":{ie(!0);break}case"pageInfo":{cr(f[ge]&&f[ge].iframe,ge),Vt();break}case"pageInfoStop":{At();break}case"inPageLink":{lt(Or(9));break}case"reset":{Se(ae);break}case"init":{je(),Bt("onInit",ae.iframe);break}default:Number(ae.width)===0&&Number(ae.height)===0?Z("Unsupported message received ("+ae.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):je()}}function Ee(we){var K=!0;return f[we]||(K=!1,Z(ae.type+" No settings for "+we+". Message was: "+$e)),K}function Ne(){for(var we in f)ke("iFrame requested init",P(we),f[we].iframe,we)}function pe(){f[ge]&&(f[ge].firstRun=!1)}var $e=Q.data,ae={},ge=null;$e==="[iFrameResizerChild]Ready"?Ne():mr()?(ae=st(),ge=ae.id,f[ge]&&(f[ge].loaded=!0),!Xe()&&Ee(ge)&&(Pe(ge,"Received: "+$e),M()&&ar()&&er())):Ze(ge,"Ignored: "+$e)}function se(Q,je,st){var Re=null,kt=null;if(f[Q])if(Re=f[Q][je],typeof Re=="function")kt=Re(st);else throw new TypeError(je+" on iFrame["+Q+"] is not a function");return kt}function Te(Q){var je=Q.id;delete f[je]}function te(Q){var je=Q.id;if(se(je,"onClose",je)===!1){Pe(je,"Close iframe cancelled by onClose event");return}Pe(je,"Removing iFrame: "+je);try{Q.parentNode&&Q.parentNode.removeChild(Q)}catch(st){Z(st)}se(je,"onClosed",je),Pe(je,"--"),Te(Q)}function oe(Q){l===null&&(l={x:window.pageXOffset===e?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===e?document.documentElement.scrollTop:window.pageYOffset},Pe(Q,"Get page position: "+l.x+","+l.y))}function q(Q){l!==null&&(window.scrollTo(l.x,l.y),Pe(Q,"Set page position: "+l.x+","+l.y),ne())}function ne(){l=null}function Se(Q){function je(){H(Q),ke("reset","reset",Q.iframe,Q.id)}Pe(Q.id,"Size reset requested by "+(Q.type==="init"?"host page":"iFrame")),oe(Q.id),ye(je,Q,"reset")}function H(Q){function je(ot){if(!Q.id){Pe("undefined","messageData id not set");return}Q.iframe.style[ot]=Q[ot]+"px",Pe(Q.id,"IFrame ("+kt+") "+ot+" set to "+Q[ot]+"px")}function st(ot){!i&&Q[ot]==="0"&&(i=!0,Pe(kt,"Hidden iFrame detected, creating visibility listener"),Ge())}function Re(ot){je(ot),st(ot)}var kt=Q.iframe.id;f[kt]&&(f[kt].sizeHeight&&Re("height"),f[kt].sizeWidth&&Re("width"))}function ye(Q,je,st){st!==je.type&&c&&!window.jasmine?(Pe(je.id,"Requesting animation frame"),c(Q)):Q()}function ke(Q,je,st,Re,kt){function ot(){var jr=f[Re]&&f[Re].targetOrigin;Pe(Re,"["+Q+"] Sending msg to iframe["+Re+"] ("+je+") targetOrigin: "+jr),st.contentWindow.postMessage(o+je,jr)}function ar(){Z(Re,"["+Q+"] IFrame("+Re+") not found")}function mr(){st&&"contentWindow"in st&&st.contentWindow!==null?ot():ar()}function Xe(){function jr(){f[Re]&&!f[Re].loaded&&!Or&&(Or=!0,Z(Re,"IFrame has not responded within "+f[Re].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}kt&&f[Re]&&f[Re].warningTimeout&&(f[Re].msgTimeout=setTimeout(jr,f[Re].warningTimeout))}var Or=!1;Re=Re||st.id,f[Re]&&(mr(),Xe())}function P(Q){return Q+":"+f[Q].bodyMarginV1+":"+f[Q].sizeWidth+":"+f[Q].log+":"+f[Q].interval+":"+f[Q].enablePublicMethods+":"+f[Q].autoResize+":"+f[Q].bodyMargin+":"+f[Q].heightCalculationMethod+":"+f[Q].bodyBackground+":"+f[Q].bodyPadding+":"+f[Q].tolerance+":"+f[Q].inPageLinks+":"+f[Q].resizeFrom+":"+f[Q].widthCalculationMethod+":"+f[Q].mouseEvents}function Qe(Q){return typeof Q=="number"}function Ct(Q,je){function st(){function ie(lt){var yt=f[V][lt];yt!==1/0&&yt!==0&&(Q.style[lt]=Qe(yt)?yt+"px":yt,Pe(V,"Set "+lt+" = "+Q.style[lt]))}function Be(lt){if(f[V]["min"+lt]>f[V]["max"+lt])throw new Error("Value for min"+lt+" can not be greater than max"+lt)}Be("Height"),Be("Width"),ie("maxHeight"),ie("minHeight"),ie("maxWidth"),ie("minWidth")}function Re(){var ie=je&&je.id||k.id+r++;return document.getElementById(ie)!==null&&(ie+=r++),ie}function kt(ie){if(typeof ie!="string")throw new TypeError("Invaild id for iFrame. Expected String");return ie===""&&(Q.id=ie=Re(),n=(je||{}).log,Pe(ie,"Added missing iframe ID: "+ie+" ("+Q.src+")")),ie}function ot(){switch(Pe(V,"IFrame scrolling "+(f[V]&&f[V].scrolling?"enabled":"disabled")+" for "+V),Q.style.overflow=(f[V]&&f[V].scrolling)===!1?"hidden":"auto",f[V]&&f[V].scrolling){case"omit":break;case!0:{Q.scrolling="yes";break}case!1:{Q.scrolling="no";break}default:Q.scrolling=f[V]?f[V].scrolling:"no"}}function ar(){(typeof(f[V]&&f[V].bodyMargin)=="number"||(f[V]&&f[V].bodyMargin)==="0")&&(f[V].bodyMarginV1=f[V].bodyMargin,f[V].bodyMargin=""+f[V].bodyMargin+"px")}function mr(){var ie=f[V]&&f[V].firstRun,Be=f[V]&&f[V].heightCalculationMethod in d;!ie&&Be&&Se({iframe:Q,height:0,width:0,type:"init"})}function Xe(){f[V]&&(f[V].iframe.iFrameResizer={close:te.bind(null,f[V].iframe),removeListeners:Te.bind(null,f[V].iframe),resize:ke.bind(null,"Window resize","resize",f[V].iframe),moveToAnchor:function(ie){ke("Move to anchor","moveToAnchor:"+ie,f[V].iframe,V)},sendMessage:function(ie){ie=JSON.stringify(ie),ke("Send Message","message:"+ie,f[V].iframe,V)}})}function Or(ie){function Be(){ke("iFrame.onload",ie,Q,e,!0),mr()}function lt(Bt){if(Q.parentNode){var er=new Bt(function(Ee){Ee.forEach(function(Ne){var pe=Array.prototype.slice.call(Ne.removedNodes);pe.forEach(function($e){$e===Q&&te(Q)})})});er.observe(Q.parentNode,{childList:!0})}}var yt=L();yt&&lt(yt),N(Q,"load",Be),ke("init",ie,Q,e,!0)}function jr(ie){if(typeof ie!="object")throw new TypeError("Options is not an object")}function lr(ie){for(var Be in k)Object.prototype.hasOwnProperty.call(k,Be)&&(f[V][Be]=Object.prototype.hasOwnProperty.call(ie,Be)?ie[Be]:k[Be])}function cr(ie){return ie===""||ie.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":ie}function Vt(ie){var Be=ie.split("Callback");if(Be.length===2){var lt="on"+Be[0].charAt(0).toUpperCase()+Be[0].slice(1);this[lt]=this[ie],delete this[ie],Z(V,"Deprecated: '"+ie+"' has been renamed '"+lt+"'. The old method will be removed in the next major version.")}}function At(ie){ie=ie||{},f[V]=Object.create(null),f[V].iframe=Q,f[V].firstRun=!0,f[V].remoteHost=Q.src&&Q.src.split("/").slice(0,3).join("/"),jr(ie),Object.keys(ie).forEach(Vt,ie),lr(ie),f[V]&&(f[V].targetOrigin=f[V].checkOrigin===!0?cr(f[V].remoteHost):"*")}function M(){return V in f&&"iFrameResizer"in Q}var V=kt(Q.id);M()?Z(V,"Ignored iFrame, already setup."):(At(je),ot(),st(),ar(),Or(P(V)),Xe())}function tt(Q,je){m===null&&(m=setTimeout(function(){m=null,Q()},je))}var De={};function ce(Q,je,st){De[st]||(De[st]=setTimeout(function(){De[st]=null,Q()},je))}function Ge(){function Q(){function kt(ot){function ar(Xe){return(f[ot]&&f[ot].iframe.style[Xe])==="0px"}function mr(Xe){return Xe.offsetParent!==null}f[ot]&&mr(f[ot].iframe)&&(ar("height")||ar("width"))&&ke("Visibility change","resize",f[ot].iframe,ot)}Object.keys(f).forEach(function(ot){kt(ot)})}function je(kt){Pe("window","Mutation observed: "+kt[0].target+" "+kt[0].type),tt(Q,16)}function st(){var kt=document.querySelector("body"),ot={attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0},ar=new Re(je);ar.observe(kt,ot)}var Re=L();Re&&st()}function Ue(Q){function je(){ht("Window "+Q,"resize")}Pe("window","Trigger event: "+Q),tt(je,16)}function be(){function Q(){ht("Tab Visible","resize")}document.visibilityState!=="hidden"&&(Pe("document","Trigger event: Visibility change"),tt(Q,16))}function ht(Q,je){function st(Re){return f[Re]&&f[Re].resizeFrom==="parent"&&f[Re].autoResize&&!f[Re].firstRun}Object.keys(f).forEach(function(Re){st(Re)&&ke(Q,je,f[Re].iframe,Re)})}function Ve(){N(window,"message",_e),N(window,"resize",function(){Ue("resize")}),N(document,"visibilitychange",be),N(document,"-webkit-visibilitychange",be)}function Kt(){function Q(Re,kt){function ot(){if(kt.tagName){if(kt.tagName.toUpperCase()!=="IFRAME")throw new TypeError("Expected <IFRAME> tag, found <"+kt.tagName+">")}else throw new TypeError("Object is not a valid DOM element")}kt&&(ot(),Ct(kt,Re),st.push(kt))}function je(Re){Re&&Re.enablePublicMethods&&Z("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var st;return re(),Ve(),function(Re,kt){switch(st=[],je(Re),typeof kt){case"undefined":case"string":{Array.prototype.forEach.call(document.querySelectorAll(kt||"iframe"),Q.bind(e,Re));break}case"object":{Q(Re,kt);break}default:throw new TypeError("Unexpected data type ("+typeof kt+")")}return st}}function Rt(Q){Q.fn?Q.fn.iFrameResize||(Q.fn.iFrameResize=function(je){function st(Re,kt){Ct(kt,je)}return this.filter("iframe").each(st).end()}):Ze("","Unable to bind to jQuery, it is not fully loaded.")}window.jQuery!==e&&Rt(window.jQuery),t.exports=Kt(),window.iFrameResize=window.iFrameResize||Kt()})()})(x_);var PN=x_.exports;const MN=Q0(PN);var NN=Object.defineProperty,LN=Object.getOwnPropertyDescriptor,Nv=(t,e,r,n)=>{for(var i=n>1?void 0:n?LN(e,r):e,a=t.length-1,s;a>=0;a--)(s=t[a])&&(i=(n?s(e,r,i):s(i))||i);return n&&i&&NN(e,r,i),i};let hc=class extends Pn{constructor(){super(...arguments),this.src="",this.showCloseButton=!1}async onLoad(t){MN({log:!1,heightCalculationMethod:"max",onMessage:({message:e})=>{this.dispatchEvent(new CustomEvent("message-received",{bubbles:!0,composed:!0,detail:e}))}},t.target)}close(){this.dispatchEvent(new CustomEvent("close"))}render(){return nr`
622
622
  <div class="relative">
623
623
  ${ha(this.showCloseButton,()=>nr`
624
624
  <button class="absolute top-0 right-0 m-2 h-6 text-white focus:outline-none" @click="${this.close}">
@@ -760,21 +760,21 @@ Please report this to https://github.com/markedjs/marked.`,t){const n="<p>An err
760
760
  `}function JN({html:t,params:e}){return t`
761
761
  <div>
762
762
  <iai-chat-carousel>
763
- ${e.units.map(r=>{const n=r.floorPlanImage!=="Data not available"?t`<img src="${r.floorPlanImage}" alt="">`:"";return t`
763
+ ${e.units.map(r=>{const n=r.floorPlanImage!=="Data not available"?t`<img src="${r.floorPlanImage}" alt="">`:"",i=r.pricing.isVisitForPrice?r.pricing.rentString:`$${r.pricing.rent}/mo for a ${r.pricing.term} Month Lease`;return t`
764
764
  <div>
765
765
  <h2>Unit ${r.unitName}</h2>
766
766
  <ul>
767
767
  <li>Bedrooms: ${r.bedroomCount}</li>
768
768
  <li>Bathrooms: ${r.bathroomCount}</li>
769
769
  <li>SQFT: ${r.squareFeet}</li>
770
- <li>Rent: $${r.pricing.rent}/mo for a ${r.pricing.term} Month Lease</li>
770
+ <li>Rent: ${i}</li>
771
771
  ${n}
772
772
  </ul>
773
773
  </div>
774
774
  `})}
775
775
  </iai-chat-carousel>
776
776
  </div>
777
- `}var P_={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(sn,function(){var r=1e3,n=6e4,i=36e5,a="millisecond",s="second",o="minute",u="hour",l="day",c="week",d="month",f="quarter",m="year",k="date",L="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,re={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(oe){var q=["th","st","nd","rd"],ne=oe%100;return"["+oe+(q[(ne-20)%10]||q[ne]||q[0])+"]"}},Me=function(oe,q,ne){var Se=String(oe);return!Se||Se.length>=q?oe:""+Array(q+1-Se.length).join(ne)+oe},Oe={s:Me,z:function(oe){var q=-oe.utcOffset(),ne=Math.abs(q),Se=Math.floor(ne/60),H=ne%60;return(q<=0?"+":"-")+Me(Se,2,"0")+":"+Me(H,2,"0")},m:function oe(q,ne){if(q.date()<ne.date())return-oe(ne,q);var Se=12*(ne.year()-q.year())+(ne.month()-q.month()),H=q.clone().add(Se,d),ye=ne-H<0,ke=q.clone().add(Se+(ye?-1:1),d);return+(-(Se+(ne-H)/(ye?H-ke:ke-H))||0)},a:function(oe){return oe<0?Math.ceil(oe)||0:Math.floor(oe)},p:function(oe){return{M:d,y:m,w:c,d:l,D:k,h:u,m:o,s,ms:a,Q:f}[oe]||String(oe||"").toLowerCase().replace(/s$/,"")},u:function(oe){return oe===void 0}},Be="en",Pe={};Pe[Be]=re;var Ze="$isDayjsObject",Z=function(oe){return oe instanceof Te||!(!oe||!oe[Ze])},Ie=function oe(q,ne,Se){var H;if(!q)return Be;if(typeof q=="string"){var ye=q.toLowerCase();Pe[ye]&&(H=ye),ne&&(Pe[ye]=ne,H=ye);var ke=q.split("-");if(!H&&ke.length>1)return oe(ke[0])}else{var P=q.name;Pe[P]=q,H=P}return!Se&&H&&(Be=H),H||!Se&&Be},_e=function(oe,q){if(Z(oe))return oe.clone();var ne=typeof q=="object"?q:{};return ne.date=oe,ne.args=arguments,new Te(ne)},se=Oe;se.l=Ie,se.i=Z,se.w=function(oe,q){return _e(oe,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var Te=function(){function oe(ne){this.$L=Ie(ne.locale,null,!0),this.parse(ne),this.$x=this.$x||ne.x||{},this[Ze]=!0}var q=oe.prototype;return q.parse=function(ne){this.$d=function(Se){var H=Se.date,ye=Se.utc;if(H===null)return new Date(NaN);if(se.u(H))return new Date;if(H instanceof Date)return new Date(H);if(typeof H=="string"&&!/Z$/i.test(H)){var ke=H.match(N);if(ke){var P=ke[2]-1||0,Qe=(ke[7]||"0").substring(0,3);return ye?new Date(Date.UTC(ke[1],P,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Qe)):new Date(ke[1],P,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Qe)}}return new Date(H)}(ne),this.init()},q.init=function(){var ne=this.$d;this.$y=ne.getFullYear(),this.$M=ne.getMonth(),this.$D=ne.getDate(),this.$W=ne.getDay(),this.$H=ne.getHours(),this.$m=ne.getMinutes(),this.$s=ne.getSeconds(),this.$ms=ne.getMilliseconds()},q.$utils=function(){return se},q.isValid=function(){return this.$d.toString()!==L},q.isSame=function(ne,Se){var H=_e(ne);return this.startOf(Se)<=H&&H<=this.endOf(Se)},q.isAfter=function(ne,Se){return _e(ne)<this.startOf(Se)},q.isBefore=function(ne,Se){return this.endOf(Se)<_e(ne)},q.$g=function(ne,Se,H){return se.u(ne)?this[Se]:this.set(H,ne)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(ne,Se){var H=this,ye=!!se.u(Se)||Se,ke=se.p(ne),P=function(be,ht){var Ve=se.w(H.$u?Date.UTC(H.$y,ht,be):new Date(H.$y,ht,be),H);return ye?Ve:Ve.endOf(l)},Qe=function(be,ht){return se.w(H.toDate()[be].apply(H.toDate("s"),(ye?[0,0,0,0]:[23,59,59,999]).slice(ht)),H)},Ct=this.$W,tt=this.$M,De=this.$D,ce="set"+(this.$u?"UTC":"");switch(ke){case m:return ye?P(1,0):P(31,11);case d:return ye?P(1,tt):P(0,tt+1);case c:var Ge=this.$locale().weekStart||0,Ue=(Ct<Ge?Ct+7:Ct)-Ge;return P(ye?De-Ue:De+(6-Ue),tt);case l:case k:return Qe(ce+"Hours",0);case u:return Qe(ce+"Minutes",1);case o:return Qe(ce+"Seconds",2);case s:return Qe(ce+"Milliseconds",3);default:return this.clone()}},q.endOf=function(ne){return this.startOf(ne,!1)},q.$set=function(ne,Se){var H,ye=se.p(ne),ke="set"+(this.$u?"UTC":""),P=(H={},H[l]=ke+"Date",H[k]=ke+"Date",H[d]=ke+"Month",H[m]=ke+"FullYear",H[u]=ke+"Hours",H[o]=ke+"Minutes",H[s]=ke+"Seconds",H[a]=ke+"Milliseconds",H)[ye],Qe=ye===l?this.$D+(Se-this.$W):Se;if(ye===d||ye===m){var Ct=this.clone().set(k,1);Ct.$d[P](Qe),Ct.init(),this.$d=Ct.set(k,Math.min(this.$D,Ct.daysInMonth())).$d}else P&&this.$d[P](Qe);return this.init(),this},q.set=function(ne,Se){return this.clone().$set(ne,Se)},q.get=function(ne){return this[se.p(ne)]()},q.add=function(ne,Se){var H,ye=this;ne=Number(ne);var ke=se.p(Se),P=function(tt){var De=_e(ye);return se.w(De.date(De.date()+Math.round(tt*ne)),ye)};if(ke===d)return this.set(d,this.$M+ne);if(ke===m)return this.set(m,this.$y+ne);if(ke===l)return P(1);if(ke===c)return P(7);var Qe=(H={},H[o]=n,H[u]=i,H[s]=r,H)[ke]||1,Ct=this.$d.getTime()+ne*Qe;return se.w(Ct,this)},q.subtract=function(ne,Se){return this.add(-1*ne,Se)},q.format=function(ne){var Se=this,H=this.$locale();if(!this.isValid())return H.invalidDate||L;var ye=ne||"YYYY-MM-DDTHH:mm:ssZ",ke=se.z(this),P=this.$H,Qe=this.$m,Ct=this.$M,tt=H.weekdays,De=H.months,ce=H.meridiem,Ge=function(ht,Ve,Kt,Rt){return ht&&(ht[Ve]||ht(Se,ye))||Kt[Ve].slice(0,Rt)},Ue=function(ht){return se.s(P%12||12,ht,"0")},be=ce||function(ht,Ve,Kt){var Rt=ht<12?"AM":"PM";return Kt?Rt.toLowerCase():Rt};return ye.replace(z,function(ht,Ve){return Ve||function(Kt){switch(Kt){case"YY":return String(Se.$y).slice(-2);case"YYYY":return se.s(Se.$y,4,"0");case"M":return Ct+1;case"MM":return se.s(Ct+1,2,"0");case"MMM":return Ge(H.monthsShort,Ct,De,3);case"MMMM":return Ge(De,Ct);case"D":return Se.$D;case"DD":return se.s(Se.$D,2,"0");case"d":return String(Se.$W);case"dd":return Ge(H.weekdaysMin,Se.$W,tt,2);case"ddd":return Ge(H.weekdaysShort,Se.$W,tt,3);case"dddd":return tt[Se.$W];case"H":return String(P);case"HH":return se.s(P,2,"0");case"h":return Ue(1);case"hh":return Ue(2);case"a":return be(P,Qe,!0);case"A":return be(P,Qe,!1);case"m":return String(Qe);case"mm":return se.s(Qe,2,"0");case"s":return String(Se.$s);case"ss":return se.s(Se.$s,2,"0");case"SSS":return se.s(Se.$ms,3,"0");case"Z":return ke}return null}(ht)||ke.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(ne,Se,H){var ye,ke=this,P=se.p(Se),Qe=_e(ne),Ct=(Qe.utcOffset()-this.utcOffset())*n,tt=this-Qe,De=function(){return se.m(ke,Qe)};switch(P){case m:ye=De()/12;break;case d:ye=De();break;case f:ye=De()/3;break;case c:ye=(tt-Ct)/6048e5;break;case l:ye=(tt-Ct)/864e5;break;case u:ye=tt/i;break;case o:ye=tt/n;break;case s:ye=tt/r;break;default:ye=tt}return H?ye:se.a(ye)},q.daysInMonth=function(){return this.endOf(d).$D},q.$locale=function(){return Pe[this.$L]},q.locale=function(ne,Se){if(!ne)return this.$L;var H=this.clone(),ye=Ie(ne,Se,!0);return ye&&(H.$L=ye),H},q.clone=function(){return se.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},oe}(),te=Te.prototype;return _e.prototype=te,[["$ms",a],["$s",s],["$m",o],["$H",u],["$W",l],["$M",d],["$y",m],["$D",k]].forEach(function(oe){te[oe[1]]=function(q){return this.$g(q,oe[0],oe[1])}}),_e.extend=function(oe,q){return oe.$i||(oe(q,Te,_e),oe.$i=!0),_e},_e.locale=Ie,_e.isDayjs=Z,_e.unix=function(oe){return _e(1e3*oe)},_e.en=Pe[Be],_e.Ls=Pe,_e.p={},_e})})(P_);var QN=P_.exports;const XN=F2(QN);function e4(t){return async function({id:r,params:n,chatWindow:i}){i.setInputDisabled(!0);const a=i.chatManager.registerRecurringKeepAlive(),{threadId:s}=i.chatManager,o={isAIChat:!0,guestCardId:n.guestCardId||null,AIChatSessionTimeout:!1,...s&&{AIChatUniqueSessionId:s},...n.firstName&&{firstName:n.firstName},...n.lastName&&{lastName:n.lastName},...n.email&&{email:n.email},...n.phoneNumber&&{phone:n.phoneNumber},...n.desiredMoveInDate&&{moveInDate:XN(n.desiredMoveInDate).format("MM/DD/YYYY")},...n.AccessWidgetLeadId&&{AccessWidgetLeadId:n.AccessWidgetLeadId}},u=document.createElement("iai-chat-iframe-modal");u.title="Schedule a Tour",u.src=`${t}?${new URLSearchParams(o).toString()}`,u.showHeader=!1;const l=()=>{a(),u.remove(),window.removeEventListener("beforeunload",f),i.removeEventListener("iai-chat-reset",l),i.setInputDisabled(!1)},c=async({detail:m})=>{if(m.type!=="tourScheduled")return;const{tourType:k,tourDate:L,tourTime:N,prospectName:z,guestCardId:re,accessWidgetLeadId:Me}=m;l(),i.setInputDisabled(!0),i.addMessage({role:"system",content:"Your tour has been scheduled!"});try{await i.sendFunctionCallResponse(r,{status:"scheduled",tourType:k,tourDate:L,tourTime:N,guestCardId:re,firstName:z,accessWidgetLeadId:Me},!0)}finally{i.setInputDisabled(!1)}},d=async()=>{l(),i.setInputDisabled(!0),i.addMessage({role:"system",content:"Tour Scheduler Closed"});try{await i.sendFunctionCallResponse(r,{status:"canceled"},!0)}finally{i.setInputDisabled(!1)}},f=async()=>{l(),i.addMessage({role:"system",content:"Tour Scheduler Closed"})};u.addEventListener("message-received",c),u.addEventListener("close",d),i.addEventListener("iai-chat-reset",l),window.addEventListener("beforeunload",f),document.body.appendChild(u),i.addMessage({role:"system",content:"Tour Scheduler Opened"})}}const t4=typeof window<"u"&&window||typeof global<"u"&&global||{},M_=t4.IAI_BACKEND_URL||"https://api.ai.inhabit.services",ss={async get(t,e={}){return this.request(t,{...e,method:"GET"})},async post(t,e={},r={}){return this.request(t,{...r,method:"POST",body:JSON.stringify(e)})},async put(t,e={},r={}){return this.request(t,{...r,method:"PUT",body:JSON.stringify(e)})},async delete(t,e={}){return this.request(t,{...e,method:"DELETE"})},async patch(t,e={},r={}){return this.request(t,{...r,method:"PATCH",body:JSON.stringify(e)})},async request(t,e={}){const{returnFullResponse:r=!1,...n}=e,i={...n,headers:{"Content-Type":"application/json",...n.headers}};t=t.replace(/^\//,"");const a=await fetch(`${M_}/${t}`,i);if(!a.ok){if(a.status===429){const o=+(a.headers.get("Retry-After")||30);throw new Lv(`Rate limited fetching /${t}: retry after ${o} seconds`,a.status,{retryAfter:o})}const s=[`Failed to fetch /${t}:`];try{const{message:o}=await a.json();if(!o)throw new Error;s.push(o)}catch{s.push(`${a.status} (${a.statusText})`)}throw new Lv(s.join(" "),a.status)}if(r)return a;try{return await a.json()}catch{return null}}};async function r4(t,e={},r){return ss.post("/threads",{assistantId:t,params:e,clientId:r})}async function n4(t,e="No reason provided"){await ss.post(`/threads/${t}/end`,{reason:e})}async function i4(t,e){return ss.post(`/threads/${t}/messages`,{content:e})}async function a4(t,e,r){const n=(await ss.post(`/threads/${t}/messages/streaming`,{content:e},{returnFullResponse:!0})).body.getReader(),i=new TextDecoder("utf-8");let a=!1,s="";const o=async()=>{const{done:u,value:l}=await n.read();if(u)return JSON.parse(s);const c=i.decode(l);if(a)s+=c;else if(c.includes("---START_RESULT---")){const[d,f]=c.split("---START_RESULT---");a=!0,s+=f,d&&r(d)}else r(c);return o()};return o()}async function s4(t,e,r){await ss.put(`/threads/${t}/messages/${e}/rate`,{rating:r})}async function o4(t,e,r,n=!1){return ss.post(`/threads/${t}/functions/${e}`,{params:r,rerunLLM:n})}async function u4(t){return ss.post(`/threads/${t}/ping`)}class Lv extends Error{constructor(e,r,n){super(e),this.status=r,this.details=n}}const l4=Object.freeze(Object.defineProperty({__proto__:null,APIError:Lv,baseApi:ss,baseUrl:M_,createThread:r4,endThread:n4,pingThread:u4,rateMessage:s4,respondToFunctionCall:o4,sendUserMessage:i4,sendUserMessageStreaming:a4},Symbol.toStringTag,{value:"Module"}));function N_(t,e){let r=!1;e.on("conversationCreated",()=>{t.setInputDisabled(!1),localStorage.setItem(oo(t.cleanOptions.config.historyKey),JSON.stringify(e.getState()))}),e.on("agentJoined",o=>{const u=o.friendlyName||o.identity||"Agent";t.addMessage({role:"system",content:`${u} has joined the chat`})}),e.on("agentLeftConversation",o=>{const u=e.getState().identity;if(o.identity===u){console.log("[transferToTwilio] Customer left (not showing message to self)");return}const l=o.friendlyName||o.identity||"Agent";t.addMessage({role:"system",content:`${l} has left the chat`})}),e.on("agentTyping",o=>{o.identity!==e.getState().identity&&t.setTypingIndicatorVisible(!0)}),e.on("typingEnded",()=>{t.setTypingIndicatorVisible(!1)}),e.on("message",o=>{console.log("[transferToTwilio] Message event received");const u=o.author||o.identity||"unknown",l=o.body||o.message||"",c=e.getState().identity;if(u===c||u==="customer"||u==="user"){console.log("[transferToTwilio] Skipping own message from:",u);return}t.setTypingIndicatorVisible(!1);const d=o.authorFriendlyName||u;t.addMessage({role:"assistant",name:d,content:l})}),e.on("conversationClosed",()=>{t.addMessage({role:"system",content:"The chat has ended"}),t.setInputDisabled(!0),localStorage.removeItem(oo(t.cleanOptions.config.historyKey))}),e.on("conversationLeft",o=>{if(console.log("[transferToTwilio] Conversation left event"),r){console.log("[transferToTwilio] User-initiated reset, skipping end message"),r=!1;return}t.addMessage({role:"system",content:"The chat has ended"}),t.setInputDisabled(!0),localStorage.removeItem(oo(t.cleanOptions.config.historyKey))}),e.on("error",o=>{console.error("[Twilio Error]:",o),t.addMessage({role:"system",content:`Error: ${o.message||"An error occurred"}`})}),e.on("connected",()=>{console.log("[Twilio] Connected to backend")}),e.on("disconnected",()=>{console.log("[Twilio] Disconnected from backend")}),e.connect();const n=async o=>{o.preventDefault(),t.addMessage({role:"user",content:o.detail.message}),await e.sendMessage({body:o.detail.message,author:"customer",triggerStudioFlow:!1})},i=async()=>{e.destroy(),t.removeEventListener("iai-chat-send-user-message",n),t.removeEventListener("iai-chat-reset",s),t.removeEventListener("iai-chat-destroy",i)},a=t.cleanOptions.config.disclaimerMessage,s=async()=>{r=!0,await e.terminateConversation(),await i(),localStorage.removeItem(oo(t.cleanOptions.config.historyKey)),t.cleanOptions.config.disclaimerMessage=a};t.cleanOptions.config.disclaimerMessage="",t.addEventListener("iai-chat-send-user-message",n),t.addEventListener("iai-chat-reset",s),t.addEventListener("iai-chat-destroy",i)}function c4(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}var Dv;(t=>{(e=>{e.TEXT="TEXT"})(t.MessageType||(t.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(t.AcknowledgeType||(t.AcknowledgeType={})),(e=>{e.GENERIC="GENERIC",e.SMS="SMS",e.RCS="RCS",e.FACEBOOK="FACEBOOK",e.TWITTER="TWITTER",e.WHATSAPP="WHATSAPP",e.WECHAT="WECHAT",e.QQMOBILE="QQMOBILE",e.APPLE_BUSINESS_CHAT="APPLE_BUSINESS_CHAT",e.SKYPE="SKYPE",e.SNAPCHAT="SNAPCHAT",e.VIBER="VIBER",e.LINE="LINE",e.TELEGRAM="TELEGRAM",e.KAKAO="KAKAO"})(t.ContentType||(t.ContentType={})),(e=>{e.SYSTEM="SYSTEM",e.USER="USER"})(t.ConversationEventOrigin||(t.ConversationEventOrigin={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.TERMINATED="TERMINATED"})(t.ConversationStatus||(t.ConversationStatus={}))})(Dv||(Dv={})),Dv.AcknowledgeType;var zr;(t=>{(e=>{e.TEXT="TEXT",e.MEDIA="MEDIA"})(t.MessageType||(t.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(t.AcknowledgeType||(t.AcknowledgeType={})),(e=>{e.CONNECTING="connecting",e.CONNECTED="connected",e.DISCONNECTING="disconnecting",e.DISCONNECTED="disconnected",e.DENIED="denied",e.ERROR="error"})(t.ConnectionState||(t.ConnectionState={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE",e.CLOSED="CLOSED"})(t.ConversationStatus||(t.ConversationStatus={})),(e=>{e.CHAT="chat",e.SMS="sms",e.WHATSAPP="whatsapp"})(t.ParticipantType||(t.ParticipantType={})),(e=>{e.QUEUED="queued",e.SENT="sent",e.DELIVERED="delivered",e.READ="read",e.FAILED="failed",e.UNDELIVERED="undelivered"})(t.DeliveryStatus||(t.DeliveryStatus={}))})(zr||(zr={}));class $f{constructor(){this._emitter=c4(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),this.client=null,this.conversation=null,this.accessToken=null,this.identity=null,this.conversationSid=null,this.conversationStarted=!1,this.connectionState=zr.ConnectionState.DISCONNECTED,this.conversationStatus=zr.ConversationStatus.PENDING,this.config=null,this.messageQueue=[]}serialize(){return JSON.stringify({accessToken:this.accessToken,identity:this.identity,conversationSid:this.conversationSid,conversationStarted:this.conversationStarted,connectionState:this.connectionState,conversationStatus:this.conversationStatus})}static deserialize(e){const r=JSON.parse(e),n=new $f;return r.accessToken&&r.identity&&(n.accessToken=r.accessToken,n.identity=r.identity),r.conversationSid&&(n.conversationSid=r.conversationSid),n.conversationStarted=r.conversationStarted||!1,n.connectionState=r.connectionState||zr.ConnectionState.DISCONNECTED,n.conversationStatus=r.conversationStatus||zr.ConversationStatus.PENDING,n}setupClientListeners(){this.client&&(this.client.on("connectionStateChanged",e=>{const r=this.connectionState,n=this.mapConnectionState(e);this.connectionState=n,this._emitter.emit("connectionStateChanged",{previous:r,current:n}),n===zr.ConnectionState.CONNECTED&&r!==zr.ConnectionState.CONNECTED&&this.processMessageQueue()}),this.client.on("tokenAboutToExpire",async()=>{console.log("Token about to expire, refreshing..."),await this.refreshToken()}),this.client.on("tokenExpired",async()=>{console.warn("Token expired, refreshing..."),await this.refreshToken()}),this.client.on("conversationJoined",e=>{console.log("Conversation joined"),this._emitter.emit("conversationJoined",{conversationSid:e.sid,timestamp:new Date})}),this.client.on("conversationLeft",e=>{console.log("Conversation left"),this._emitter.emit("conversationLeft",{conversationSid:e.sid,timestamp:new Date})}),this.client.on("connectionError",e=>{console.error("Twilio connection error:",e),this.handleError("Connection error",e)}))}async initialize(e){try{this.config=e,this.accessToken=e.accessToken,this.identity=e.identity,this.tokenRefreshUrl=e.tokenRefreshUrl;const{Client:r}=await Promise.resolve().then(()=>dre);this.client=new r(e.accessToken,{logLevel:e.logLevel||"error"}),this.setupClientListeners(),await this.waitForClientReady(),e.conversationSid&&(this.conversationSid=e.conversationSid,await this.joinConversation(e.conversationSid))}catch(r){throw console.error("Failed to initialize Twilio Manager:",r),this.handleError("Initialization failed",r),r}}async waitForClientReady(){return new Promise((e,r)=>{if(!this.client){r(new Error("Client not initialized"));return}const n=setTimeout(()=>{r(new Error("Client initialization timeout"))},3e4);this.client.on("initialized",()=>{clearTimeout(n),e()}),this.client.on("initFailed",i=>{clearTimeout(n),r(i)})})}mapConnectionState(e){switch(e){case"connecting":return zr.ConnectionState.CONNECTING;case"connected":return zr.ConnectionState.CONNECTED;case"disconnecting":return zr.ConnectionState.DISCONNECTING;case"disconnected":return zr.ConnectionState.DISCONNECTED;case"denied":return zr.ConnectionState.DENIED;case"error":return zr.ConnectionState.ERROR;default:return zr.ConnectionState.DISCONNECTED}}async refreshToken(){try{if(!this.tokenRefreshUrl)throw new Error("Token refresh URL not configured");const e=await fetch(this.tokenRefreshUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:this.identity})});if(!e.ok)throw new Error(`Token refresh failed: ${e.statusText}`);const r=await e.json();this.accessToken=r.token,this.client&&(await this.client.updateToken(r.token),console.log("Token refreshed successfully"),this._emitter.emit("tokenRefreshed",{timestamp:new Date}))}catch(e){throw console.error("Token refresh failed:",e),this.handleError("Token refresh failed",e),e}}async createConversation(e){try{if(!this.client)throw new Error("Client not initialized");const r=await this.client.createConversation({friendlyName:e.friendlyName,uniqueName:e.uniqueName,attributes:e.attributes});this.conversation=r,this.conversationSid=r.sid,await r.join(),this.setupConversationListeners(r);const n={sid:r.sid,friendlyName:r.friendlyName,uniqueName:r.uniqueName,attributes:r.attributes,dateCreated:r.dateCreated,dateUpdated:r.dateUpdated,state:r.state,status:zr.ConversationStatus.ACTIVE};return this.conversationStarted=!0,this.conversationStatus=zr.ConversationStatus.ACTIVE,this._emitter.emit("conversationCreated",n),n}catch(r){throw console.error("Failed to create conversation:",r),this.handleError("Conversation creation failed",r),r}}async joinConversation(e){try{if(!this.client)throw new Error("Client not initialized");console.log("Joining conversation:",e);const r=await this.client.getConversationBySid(e);try{await r.join()}catch(n){if(n.code!==50403)throw n}this.conversation=r,this.conversationSid=e,this.setupConversationListeners(r),this.conversationStarted=!0,this.conversationStatus=zr.ConversationStatus.ACTIVE,this._emitter.emit("conversationJoined",{conversationSid:e,timestamp:new Date})}catch(r){throw console.error("Failed to join conversation:",r),this.handleError("Failed to join conversation",r),r}}async initializeConversation(e){return this.createConversation(e)}setupConversationListeners(e){const r=(n,i)=>{let a;const s=o=>{try{const u=o.replace(/_([0-9A-Fa-f]{2})/g,"%$1");return decodeURIComponent(u)}catch(u){return console.warn("Could not decode Twilio identity:",u),o}};return n&&n.attributes&&(a=n.attributes.public_identity||n.attributes.full_name||n.attributes.friendlyName,a&&(a=s(a))),!a&&i&&(a=s(i)),a};e.on("messageAdded",async n=>{console.log("Message added");let i;try{const s=await e.getParticipantByIdentity(n.author);i=r(s,n.author)}catch(s){console.warn("Could not fetch participant info for friendly name:",s),i=r(null,n.author)}const a={index:n.index,sid:n.sid,body:n.body,author:n.author,authorFriendlyName:i,participantSid:n.participantSid,timestamp:n.dateCreated,attributes:n.attributes,media:n.attachedMedia};this._emitter.emit("message",a),n.author!==this.identity&&await this.acknowledgeMessage(n.index.toString())}),e.on("typingStarted",n=>{console.log("Typing started");const i={identity:n.identity,participantSid:n.sid,isTyping:!0};this._emitter.emit("agentTyping",i)}),e.on("typingEnded",n=>{console.log("Typing ended");const i={identity:n.identity,participantSid:n.sid,isTyping:!1};this._emitter.emit("typingEnded",i)}),e.on("participantJoined",n=>{console.log("Participant joined");const i=r(n,n.identity),a={sid:n.sid,identity:n.identity,friendlyName:i,attributes:n.attributes,timestamp:new Date};this._emitter.emit("agentJoined",a)}),e.on("participantLeft",n=>{console.log("Participant left");const i=r(n,n.identity),a={sid:n.sid,identity:n.identity,friendlyName:i,timestamp:new Date};this._emitter.emit("agentLeftConversation",a)}),e.on("participantUpdated",n=>{console.log("Participant updated"),this._emitter.emit("participantUpdated",n)}),e.on("updated",n=>{console.log("Conversation updated"),this._emitter.emit("conversationUpdated",n)})}async sendMessage(e,r){try{if(!this.conversation||!this.conversationStarted)throw new Error("Conversation not started");let n,i;if(typeof e=="string"?(n=e,i=r):(n=e.body,i=e.attributes),this.connectionState!==zr.ConnectionState.CONNECTED)return new Promise((s,o)=>{this.messageQueue.push({content:n,attributes:i,resolve:s,reject:o})});const a=await this.conversation.sendMessage(n,i);return this._emitter.emit("messageSent",{content:n,attributes:i,index:a,timestamp:new Date}),await Promise.resolve()}catch(n){throw console.error("Failed to send message:",n),this.handleError("Message sending failed",n),n}}async sendTyping(){try{if(!this.conversation)throw new Error("Conversation not started");this.typingTimeout&&clearTimeout(this.typingTimeout),await this.conversation.typing(),this.typingTimeout=setTimeout(()=>{this.typingTimeout=void 0},3e3)}catch(e){console.error("Failed to send typing indicator:",e)}}async acknowledgeMessage(e){try{if(!this.conversation)throw new Error("Conversation not started");const r=parseInt(e,10);if(isNaN(r)){console.warn("Invalid message ID format:",e);return}await this.conversation.updateLastReadMessageIndex(r),this._emitter.emit("messageAcknowledged",{messageId:e,timestamp:new Date})}catch(r){console.error("Failed to acknowledge message:",r)}}async processMessageQueue(){for(;this.messageQueue.length>0;){const e=this.messageQueue.shift();if(e)try{await this.sendMessage(e.content,e.attributes),e.resolve()}catch(r){e.reject(r)}}}async terminateConversation(){try{if(!this.conversation)throw new Error("Conversation not started");await this.conversation.leave(),this._emitter.emit("conversationTerminated",{conversationSid:this.conversationSid,timestamp:new Date}),this.conversation=null,this.conversationSid=null,this.conversationStarted=!1,this.conversationStatus=zr.ConversationStatus.CLOSED}catch(e){throw console.error("Failed to terminate conversation:",e),this.handleError("Conversation termination failed",e),e}}async connect(){if(!this.client)throw new Error("Client not initialized");if(!this.conversationSid)throw new Error("Conversation not started")}async reconnectClient(){try{if(!this.config)throw new Error("Configuration not available");await this.initialize(this.config),await this.processMessageQueue()}catch(e){throw console.error("Failed to reconnect client:",e),e}}async disconnect(){this.client&&(this.client=null),this.connectionState=zr.ConnectionState.DISCONNECTED}async reconnect(){await this.disconnect(),this.config&&await this.initialize(this.config)}destroy(){this.tokenRefreshTimeout&&(clearTimeout(this.tokenRefreshTimeout),this.tokenRefreshTimeout=void 0),this.typingTimeout&&(clearTimeout(this.typingTimeout),this.typingTimeout=void 0),this.client&&(this.client.shutdown(),this.client=null),this.conversation=null,this.conversationSid=null,this.accessToken=null,this.identity=null,this.conversationStarted=!1,this.connectionState=zr.ConnectionState.DISCONNECTED,this.conversationStatus=zr.ConversationStatus.CLOSED,this.messageQueue=[],this._emitter.all.clear()}handleError(e,r){const n={message:e,code:r==null?void 0:r.code,status:r==null?void 0:r.status,details:r,timestamp:new Date};this._emitter.emit("error",n)}get token(){return this.accessToken}get userIdentity(){return this.identity}get currentConversationSid(){return this.conversationSid}getConnectionStatus(){return this.connectionState}getConversationState(){return this.conversationStatus}isConnected(){return this.connectionState===zr.ConnectionState.CONNECTED}getClient(){return this.client}getConversation(){return this.conversation}getState(){return{system:"twilio",conversationSid:this.conversationSid,identity:this.identity,connectionState:this.connectionState,conversationStatus:this.conversationStatus,conversationStarted:this.conversationStarted}}}const{baseApi:d4}=l4;function oo(t){return`any-${t||"main"}-chatSession`}async function f4({id:t,params:e,chatWindow:r,html:n}){const{threadId:i}=r.chatManager;r=r;const a=async()=>{var re,Me;const{firstName:d,lastName:f,phone:m,email:k,propertyId:L}=e,N={propertyId:L||e.propertyId||((Me=(re=r.options)==null?void 0:re.params)==null?void 0:Me.propertyId),firstName:d,lastName:f,phoneNumber:m,email:k,threadId:i},{guestCardId:z}=await d4.post("/anyone-home/newGuestCard",N);e.guestCardId=z},s=async()=>{r.removeMessage("transferMessageId"),r.removeMessage("guestCardFormId"),await r.sendFunctionCallResponse(t,{transfer:"Declined"},!0),r.setInputDisabled(!1)},o=async()=>{r.removeMessage("transferMessageId"),e.guestCardId?(u(),await l()):await c()},u=()=>{r.addMessage({id:"waitMessageId",role:"system",content:"Please wait while we connect you to a live agent"}),r.setInputDisabled(!0)},l=async()=>{var Me,Oe;await r.sendFunctionCallResponse(t,{transfer:"Accepted",guestCardId:e.guestCardId,firstName:e.firstName,lastName:e.lastName,phoneNumber:e.phoneNumber,email:e.email},!1),await r.chatManager.endChat("Transferred to live agent",!1);const{summary:d,subject:f,guestCardId:m,firstName:k,lastName:L,phone:N,email:z}=e,re=e.propertyName||((Oe=(Me=r.options)==null?void 0:Me.params)==null?void 0:Oe.propertyName);{const Be="https://five9.ah.inhabit.work",Pe=z||`customer-${Date.now()}`,Ze=await fetch(`${Be}/api/twilio/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:Pe})});if(!Ze.ok)throw new Error(`Failed to get Twilio token: ${Ze.statusText}`);const{token:Z}=await Ze.json(),Ie=new $f;await Ie.initialize({accessToken:Z,identity:Pe,autoReconnect:!0,logLevel:"info"}),await Ie.createConversation({friendlyName:`${k} ${L} - ${f||"Customer Chat"}`,uniqueName:`chat-${Date.now()}-${m}`,attributes:{pre_engagement_data:{gc_id:m,friendlyName:k,last_name:L,phone:N,email:z,question:f,aiSummary:d,propertyName:re}}});const _e="FW490d224a211a6f2bea01c23aaa492122";try{const{conversationSid:se}=Ie.getState(),Te=await fetch(`${Be}/twilio-conversations/${se}/attach-studio-flow`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowSid:_e,filters:["onMessageAdded"]})});if(Te.ok){const te=await Te.json()}else console.warn("[TransferToLiveAgent] Failed to attach Studio Flow webhook:",await Te.text())}catch(se){console.error("[TransferToLiveAgent] Error attaching Studio Flow webhook:",se)}try{const{conversationSid:se}=Ie.getState(),Te=`${Be}/twilio-conversations/${se}/webhooks`.replace(/^http:/,"https:"),te=await fetch(`${Be}/twilio-conversations/${se}/attach-webhook`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({webhookUrl:Te,method:"POST",filters:["onMessageAdded","onMessageUpdated","onParticipantAdded","onParticipantRemoved","onConversationUpdated"]})});if(te.ok){const oe=await te.json()}else console.warn("[TransferToLiveAgent] Failed to attach backend webhook:",await te.text())}catch(se){console.error("[TransferToLiveAgent] Error attaching backend webhook:",se)}try{await Ie.sendMessage({body:"Customer has been transferred to live agent",attributes:{gc_id:m,friendlyName:k,last_name:L,email:z,phone:N,question:f||"General inquiry",aiSummary:d||"No prior conversation",propertyName:re,messageType:"transfer_trigger"}})}catch(se){console.error("[TransferToLiveAgent] Error sending Studio Flow trigger message:",se)}localStorage.setItem(oo(r.cleanOptions.config.historyKey),JSON.stringify(Ie.getState())),r.setInputDisabled(!1),N_(r,Ie)}},c=async()=>{const d=async f=>{e={...e,...f.detail},r.removeMessage("guestCardFormId"),u();try{await a()}catch(m){console.log(m)}await l()};r.addMessage({id:"guestCardFormId",role:"system",contentHtmlTemplate:n`
777
+ `}var P_={exports:{}};(function(t,e){(function(r,n){t.exports=n()})(sn,function(){var r=1e3,n=6e4,i=36e5,a="millisecond",s="second",o="minute",u="hour",l="day",c="week",d="month",f="quarter",m="year",k="date",L="Invalid Date",N=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,z=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,re={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(oe){var q=["th","st","nd","rd"],ne=oe%100;return"["+oe+(q[(ne-20)%10]||q[ne]||q[0])+"]"}},Me=function(oe,q,ne){var Se=String(oe);return!Se||Se.length>=q?oe:""+Array(q+1-Se.length).join(ne)+oe},Oe={s:Me,z:function(oe){var q=-oe.utcOffset(),ne=Math.abs(q),Se=Math.floor(ne/60),H=ne%60;return(q<=0?"+":"-")+Me(Se,2,"0")+":"+Me(H,2,"0")},m:function oe(q,ne){if(q.date()<ne.date())return-oe(ne,q);var Se=12*(ne.year()-q.year())+(ne.month()-q.month()),H=q.clone().add(Se,d),ye=ne-H<0,ke=q.clone().add(Se+(ye?-1:1),d);return+(-(Se+(ne-H)/(ye?H-ke:ke-H))||0)},a:function(oe){return oe<0?Math.ceil(oe)||0:Math.floor(oe)},p:function(oe){return{M:d,y:m,w:c,d:l,D:k,h:u,m:o,s,ms:a,Q:f}[oe]||String(oe||"").toLowerCase().replace(/s$/,"")},u:function(oe){return oe===void 0}},Fe="en",Pe={};Pe[Fe]=re;var Ze="$isDayjsObject",Z=function(oe){return oe instanceof Te||!(!oe||!oe[Ze])},Ie=function oe(q,ne,Se){var H;if(!q)return Fe;if(typeof q=="string"){var ye=q.toLowerCase();Pe[ye]&&(H=ye),ne&&(Pe[ye]=ne,H=ye);var ke=q.split("-");if(!H&&ke.length>1)return oe(ke[0])}else{var P=q.name;Pe[P]=q,H=P}return!Se&&H&&(Fe=H),H||!Se&&Fe},_e=function(oe,q){if(Z(oe))return oe.clone();var ne=typeof q=="object"?q:{};return ne.date=oe,ne.args=arguments,new Te(ne)},se=Oe;se.l=Ie,se.i=Z,se.w=function(oe,q){return _e(oe,{locale:q.$L,utc:q.$u,x:q.$x,$offset:q.$offset})};var Te=function(){function oe(ne){this.$L=Ie(ne.locale,null,!0),this.parse(ne),this.$x=this.$x||ne.x||{},this[Ze]=!0}var q=oe.prototype;return q.parse=function(ne){this.$d=function(Se){var H=Se.date,ye=Se.utc;if(H===null)return new Date(NaN);if(se.u(H))return new Date;if(H instanceof Date)return new Date(H);if(typeof H=="string"&&!/Z$/i.test(H)){var ke=H.match(N);if(ke){var P=ke[2]-1||0,Qe=(ke[7]||"0").substring(0,3);return ye?new Date(Date.UTC(ke[1],P,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Qe)):new Date(ke[1],P,ke[3]||1,ke[4]||0,ke[5]||0,ke[6]||0,Qe)}}return new Date(H)}(ne),this.init()},q.init=function(){var ne=this.$d;this.$y=ne.getFullYear(),this.$M=ne.getMonth(),this.$D=ne.getDate(),this.$W=ne.getDay(),this.$H=ne.getHours(),this.$m=ne.getMinutes(),this.$s=ne.getSeconds(),this.$ms=ne.getMilliseconds()},q.$utils=function(){return se},q.isValid=function(){return this.$d.toString()!==L},q.isSame=function(ne,Se){var H=_e(ne);return this.startOf(Se)<=H&&H<=this.endOf(Se)},q.isAfter=function(ne,Se){return _e(ne)<this.startOf(Se)},q.isBefore=function(ne,Se){return this.endOf(Se)<_e(ne)},q.$g=function(ne,Se,H){return se.u(ne)?this[Se]:this.set(H,ne)},q.unix=function(){return Math.floor(this.valueOf()/1e3)},q.valueOf=function(){return this.$d.getTime()},q.startOf=function(ne,Se){var H=this,ye=!!se.u(Se)||Se,ke=se.p(ne),P=function(be,ht){var Ve=se.w(H.$u?Date.UTC(H.$y,ht,be):new Date(H.$y,ht,be),H);return ye?Ve:Ve.endOf(l)},Qe=function(be,ht){return se.w(H.toDate()[be].apply(H.toDate("s"),(ye?[0,0,0,0]:[23,59,59,999]).slice(ht)),H)},Ct=this.$W,tt=this.$M,De=this.$D,ce="set"+(this.$u?"UTC":"");switch(ke){case m:return ye?P(1,0):P(31,11);case d:return ye?P(1,tt):P(0,tt+1);case c:var Ge=this.$locale().weekStart||0,Ue=(Ct<Ge?Ct+7:Ct)-Ge;return P(ye?De-Ue:De+(6-Ue),tt);case l:case k:return Qe(ce+"Hours",0);case u:return Qe(ce+"Minutes",1);case o:return Qe(ce+"Seconds",2);case s:return Qe(ce+"Milliseconds",3);default:return this.clone()}},q.endOf=function(ne){return this.startOf(ne,!1)},q.$set=function(ne,Se){var H,ye=se.p(ne),ke="set"+(this.$u?"UTC":""),P=(H={},H[l]=ke+"Date",H[k]=ke+"Date",H[d]=ke+"Month",H[m]=ke+"FullYear",H[u]=ke+"Hours",H[o]=ke+"Minutes",H[s]=ke+"Seconds",H[a]=ke+"Milliseconds",H)[ye],Qe=ye===l?this.$D+(Se-this.$W):Se;if(ye===d||ye===m){var Ct=this.clone().set(k,1);Ct.$d[P](Qe),Ct.init(),this.$d=Ct.set(k,Math.min(this.$D,Ct.daysInMonth())).$d}else P&&this.$d[P](Qe);return this.init(),this},q.set=function(ne,Se){return this.clone().$set(ne,Se)},q.get=function(ne){return this[se.p(ne)]()},q.add=function(ne,Se){var H,ye=this;ne=Number(ne);var ke=se.p(Se),P=function(tt){var De=_e(ye);return se.w(De.date(De.date()+Math.round(tt*ne)),ye)};if(ke===d)return this.set(d,this.$M+ne);if(ke===m)return this.set(m,this.$y+ne);if(ke===l)return P(1);if(ke===c)return P(7);var Qe=(H={},H[o]=n,H[u]=i,H[s]=r,H)[ke]||1,Ct=this.$d.getTime()+ne*Qe;return se.w(Ct,this)},q.subtract=function(ne,Se){return this.add(-1*ne,Se)},q.format=function(ne){var Se=this,H=this.$locale();if(!this.isValid())return H.invalidDate||L;var ye=ne||"YYYY-MM-DDTHH:mm:ssZ",ke=se.z(this),P=this.$H,Qe=this.$m,Ct=this.$M,tt=H.weekdays,De=H.months,ce=H.meridiem,Ge=function(ht,Ve,Kt,Rt){return ht&&(ht[Ve]||ht(Se,ye))||Kt[Ve].slice(0,Rt)},Ue=function(ht){return se.s(P%12||12,ht,"0")},be=ce||function(ht,Ve,Kt){var Rt=ht<12?"AM":"PM";return Kt?Rt.toLowerCase():Rt};return ye.replace(z,function(ht,Ve){return Ve||function(Kt){switch(Kt){case"YY":return String(Se.$y).slice(-2);case"YYYY":return se.s(Se.$y,4,"0");case"M":return Ct+1;case"MM":return se.s(Ct+1,2,"0");case"MMM":return Ge(H.monthsShort,Ct,De,3);case"MMMM":return Ge(De,Ct);case"D":return Se.$D;case"DD":return se.s(Se.$D,2,"0");case"d":return String(Se.$W);case"dd":return Ge(H.weekdaysMin,Se.$W,tt,2);case"ddd":return Ge(H.weekdaysShort,Se.$W,tt,3);case"dddd":return tt[Se.$W];case"H":return String(P);case"HH":return se.s(P,2,"0");case"h":return Ue(1);case"hh":return Ue(2);case"a":return be(P,Qe,!0);case"A":return be(P,Qe,!1);case"m":return String(Qe);case"mm":return se.s(Qe,2,"0");case"s":return String(Se.$s);case"ss":return se.s(Se.$s,2,"0");case"SSS":return se.s(Se.$ms,3,"0");case"Z":return ke}return null}(ht)||ke.replace(":","")})},q.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},q.diff=function(ne,Se,H){var ye,ke=this,P=se.p(Se),Qe=_e(ne),Ct=(Qe.utcOffset()-this.utcOffset())*n,tt=this-Qe,De=function(){return se.m(ke,Qe)};switch(P){case m:ye=De()/12;break;case d:ye=De();break;case f:ye=De()/3;break;case c:ye=(tt-Ct)/6048e5;break;case l:ye=(tt-Ct)/864e5;break;case u:ye=tt/i;break;case o:ye=tt/n;break;case s:ye=tt/r;break;default:ye=tt}return H?ye:se.a(ye)},q.daysInMonth=function(){return this.endOf(d).$D},q.$locale=function(){return Pe[this.$L]},q.locale=function(ne,Se){if(!ne)return this.$L;var H=this.clone(),ye=Ie(ne,Se,!0);return ye&&(H.$L=ye),H},q.clone=function(){return se.w(this.$d,this)},q.toDate=function(){return new Date(this.valueOf())},q.toJSON=function(){return this.isValid()?this.toISOString():null},q.toISOString=function(){return this.$d.toISOString()},q.toString=function(){return this.$d.toUTCString()},oe}(),te=Te.prototype;return _e.prototype=te,[["$ms",a],["$s",s],["$m",o],["$H",u],["$W",l],["$M",d],["$y",m],["$D",k]].forEach(function(oe){te[oe[1]]=function(q){return this.$g(q,oe[0],oe[1])}}),_e.extend=function(oe,q){return oe.$i||(oe(q,Te,_e),oe.$i=!0),_e},_e.locale=Ie,_e.isDayjs=Z,_e.unix=function(oe){return _e(1e3*oe)},_e.en=Pe[Fe],_e.Ls=Pe,_e.p={},_e})})(P_);var QN=P_.exports;const XN=F2(QN);function e4(t){return async function({id:r,params:n,chatWindow:i}){i.setInputDisabled(!0);const a=i.chatManager.registerRecurringKeepAlive(),{threadId:s}=i.chatManager,o={isAIChat:!0,guestCardId:n.guestCardId||null,AIChatSessionTimeout:!1,...s&&{AIChatUniqueSessionId:s},...n.firstName&&{firstName:n.firstName},...n.lastName&&{lastName:n.lastName},...n.email&&{email:n.email},...n.phoneNumber&&{phone:n.phoneNumber},...n.desiredMoveInDate&&{moveInDate:XN(n.desiredMoveInDate).format("MM/DD/YYYY")},...n.AccessWidgetLeadId&&{AccessWidgetLeadId:n.AccessWidgetLeadId}},u=document.createElement("iai-chat-iframe-modal");u.title="Schedule a Tour",u.src=`${t}?${new URLSearchParams(o).toString()}`,u.showHeader=!1;const l=()=>{a(),u.remove(),window.removeEventListener("beforeunload",f),i.removeEventListener("iai-chat-reset",l),i.setInputDisabled(!1)},c=async({detail:m})=>{if(m.type!=="tourScheduled")return;const{tourType:k,tourDate:L,tourTime:N,prospectName:z,guestCardId:re,accessWidgetLeadId:Me}=m;l(),i.setInputDisabled(!0),i.addMessage({role:"system",content:"Your tour has been scheduled!"});try{await i.sendFunctionCallResponse(r,{status:"scheduled",tourType:k,tourDate:L,tourTime:N,guestCardId:re,firstName:z,accessWidgetLeadId:Me},!0)}finally{i.setInputDisabled(!1)}},d=async()=>{l(),i.setInputDisabled(!0),i.addMessage({role:"system",content:"Tour Scheduler Closed"});try{await i.sendFunctionCallResponse(r,{status:"canceled"},!0)}finally{i.setInputDisabled(!1)}},f=async()=>{l(),i.addMessage({role:"system",content:"Tour Scheduler Closed"})};u.addEventListener("message-received",c),u.addEventListener("close",d),i.addEventListener("iai-chat-reset",l),window.addEventListener("beforeunload",f),document.body.appendChild(u),i.addMessage({role:"system",content:"Tour Scheduler Opened"})}}const t4=typeof window<"u"&&window||typeof global<"u"&&global||{},M_=t4.IAI_BACKEND_URL||"https://api.ai.inhabit.services",ss={async get(t,e={}){return this.request(t,{...e,method:"GET"})},async post(t,e={},r={}){return this.request(t,{...r,method:"POST",body:JSON.stringify(e)})},async put(t,e={},r={}){return this.request(t,{...r,method:"PUT",body:JSON.stringify(e)})},async delete(t,e={}){return this.request(t,{...e,method:"DELETE"})},async patch(t,e={},r={}){return this.request(t,{...r,method:"PATCH",body:JSON.stringify(e)})},async request(t,e={}){const{returnFullResponse:r=!1,...n}=e,i={...n,headers:{"Content-Type":"application/json",...n.headers}};t=t.replace(/^\//,"");const a=await fetch(`${M_}/${t}`,i);if(!a.ok){if(a.status===429){const o=+(a.headers.get("Retry-After")||30);throw new Lv(`Rate limited fetching /${t}: retry after ${o} seconds`,a.status,{retryAfter:o})}const s=[`Failed to fetch /${t}:`];try{const{message:o}=await a.json();if(!o)throw new Error;s.push(o)}catch{s.push(`${a.status} (${a.statusText})`)}throw new Lv(s.join(" "),a.status)}if(r)return a;try{return await a.json()}catch{return null}}};async function r4(t,e={},r){return ss.post("/threads",{assistantId:t,params:e,clientId:r})}async function n4(t,e="No reason provided"){await ss.post(`/threads/${t}/end`,{reason:e})}async function i4(t,e){return ss.post(`/threads/${t}/messages`,{content:e})}async function a4(t,e,r){const n=(await ss.post(`/threads/${t}/messages/streaming`,{content:e},{returnFullResponse:!0})).body.getReader(),i=new TextDecoder("utf-8");let a=!1,s="";const o=async()=>{const{done:u,value:l}=await n.read();if(u)return JSON.parse(s);const c=i.decode(l);if(a)s+=c;else if(c.includes("---START_RESULT---")){const[d,f]=c.split("---START_RESULT---");a=!0,s+=f,d&&r(d)}else r(c);return o()};return o()}async function s4(t,e,r){await ss.put(`/threads/${t}/messages/${e}/rate`,{rating:r})}async function o4(t,e,r,n=!1){return ss.post(`/threads/${t}/functions/${e}`,{params:r,rerunLLM:n})}async function u4(t){return ss.post(`/threads/${t}/ping`)}class Lv extends Error{constructor(e,r,n){super(e),this.status=r,this.details=n}}const l4=Object.freeze(Object.defineProperty({__proto__:null,APIError:Lv,baseApi:ss,baseUrl:M_,createThread:r4,endThread:n4,pingThread:u4,rateMessage:s4,respondToFunctionCall:o4,sendUserMessage:i4,sendUserMessageStreaming:a4},Symbol.toStringTag,{value:"Module"}));function N_(t,e){let r=!1;e.on("conversationCreated",()=>{t.setInputDisabled(!1),localStorage.setItem(oo(t.cleanOptions.config.historyKey),JSON.stringify(e.getState()))}),e.on("agentJoined",o=>{const u=o.friendlyName||o.identity||"Agent";t.addMessage({role:"system",content:`${u} has joined the chat`})}),e.on("agentLeftConversation",o=>{const u=e.getState().identity;if(o.identity===u){console.log("[transferToTwilio] Customer left (not showing message to self)");return}const l=o.friendlyName||o.identity||"Agent";t.addMessage({role:"system",content:`${l} has left the chat`})}),e.on("agentTyping",o=>{o.identity!==e.getState().identity&&t.setTypingIndicatorVisible(!0)}),e.on("typingEnded",()=>{t.setTypingIndicatorVisible(!1)}),e.on("message",o=>{console.log("[transferToTwilio] Message event received");const u=o.author||o.identity||"unknown",l=o.body||o.message||"",c=e.getState().identity;if(u===c||u==="customer"||u==="user"){console.log("[transferToTwilio] Skipping own message from:",u);return}t.setTypingIndicatorVisible(!1);const d=o.authorFriendlyName||u;t.addMessage({role:"assistant",name:d,content:l})}),e.on("conversationClosed",()=>{t.addMessage({role:"system",content:"The chat has ended"}),t.setInputDisabled(!0),localStorage.removeItem(oo(t.cleanOptions.config.historyKey))}),e.on("conversationLeft",o=>{if(console.log("[transferToTwilio] Conversation left event"),r){console.log("[transferToTwilio] User-initiated reset, skipping end message"),r=!1;return}t.addMessage({role:"system",content:"The chat has ended"}),t.setInputDisabled(!0),localStorage.removeItem(oo(t.cleanOptions.config.historyKey))}),e.on("error",o=>{console.error("[Twilio Error]:",o),t.addMessage({role:"system",content:`Error: ${o.message||"An error occurred"}`})}),e.on("connected",()=>{console.log("[Twilio] Connected to backend")}),e.on("disconnected",()=>{console.log("[Twilio] Disconnected from backend")}),e.connect();const n=async o=>{o.preventDefault(),t.addMessage({role:"user",content:o.detail.message}),await e.sendMessage({body:o.detail.message,author:"customer",triggerStudioFlow:!1})},i=async()=>{e.destroy(),t.removeEventListener("iai-chat-send-user-message",n),t.removeEventListener("iai-chat-reset",s),t.removeEventListener("iai-chat-destroy",i)},a=t.cleanOptions.config.disclaimerMessage,s=async()=>{r=!0,await e.terminateConversation(),await i(),localStorage.removeItem(oo(t.cleanOptions.config.historyKey)),t.cleanOptions.config.disclaimerMessage=a};t.cleanOptions.config.disclaimerMessage="",t.addEventListener("iai-chat-send-user-message",n),t.addEventListener("iai-chat-reset",s),t.addEventListener("iai-chat-destroy",i)}function c4(t){return{all:t=t||new Map,on:function(e,r){var n=t.get(e);n?n.push(r):t.set(e,[r])},off:function(e,r){var n=t.get(e);n&&(r?n.splice(n.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var n=t.get(e);n&&n.slice().map(function(i){i(r)}),(n=t.get("*"))&&n.slice().map(function(i){i(e,r)})}}}var Dv;(t=>{(e=>{e.TEXT="TEXT"})(t.MessageType||(t.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(t.AcknowledgeType||(t.AcknowledgeType={})),(e=>{e.GENERIC="GENERIC",e.SMS="SMS",e.RCS="RCS",e.FACEBOOK="FACEBOOK",e.TWITTER="TWITTER",e.WHATSAPP="WHATSAPP",e.WECHAT="WECHAT",e.QQMOBILE="QQMOBILE",e.APPLE_BUSINESS_CHAT="APPLE_BUSINESS_CHAT",e.SKYPE="SKYPE",e.SNAPCHAT="SNAPCHAT",e.VIBER="VIBER",e.LINE="LINE",e.TELEGRAM="TELEGRAM",e.KAKAO="KAKAO"})(t.ContentType||(t.ContentType={})),(e=>{e.SYSTEM="SYSTEM",e.USER="USER"})(t.ConversationEventOrigin||(t.ConversationEventOrigin={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.TERMINATED="TERMINATED"})(t.ConversationStatus||(t.ConversationStatus={}))})(Dv||(Dv={})),Dv.AcknowledgeType;var zr;(t=>{(e=>{e.TEXT="TEXT",e.MEDIA="MEDIA"})(t.MessageType||(t.MessageType={})),(e=>{e.DELIVERED="DELIVERED",e.READ="READ",e.FAILED="FAILED"})(t.AcknowledgeType||(t.AcknowledgeType={})),(e=>{e.CONNECTING="connecting",e.CONNECTED="connected",e.DISCONNECTING="disconnecting",e.DISCONNECTED="disconnected",e.DENIED="denied",e.ERROR="error"})(t.ConnectionState||(t.ConnectionState={})),(e=>{e.PENDING="PENDING",e.ACTIVE="ACTIVE",e.INACTIVE="INACTIVE",e.CLOSED="CLOSED"})(t.ConversationStatus||(t.ConversationStatus={})),(e=>{e.CHAT="chat",e.SMS="sms",e.WHATSAPP="whatsapp"})(t.ParticipantType||(t.ParticipantType={})),(e=>{e.QUEUED="queued",e.SENT="sent",e.DELIVERED="delivered",e.READ="read",e.FAILED="failed",e.UNDELIVERED="undelivered"})(t.DeliveryStatus||(t.DeliveryStatus={}))})(zr||(zr={}));class $f{constructor(){this._emitter=c4(),this.on=this._emitter.on.bind(this._emitter),this.off=this._emitter.off.bind(this._emitter),this.client=null,this.conversation=null,this.accessToken=null,this.identity=null,this.conversationSid=null,this.conversationStarted=!1,this.connectionState=zr.ConnectionState.DISCONNECTED,this.conversationStatus=zr.ConversationStatus.PENDING,this.config=null,this.messageQueue=[]}serialize(){return JSON.stringify({accessToken:this.accessToken,identity:this.identity,conversationSid:this.conversationSid,conversationStarted:this.conversationStarted,connectionState:this.connectionState,conversationStatus:this.conversationStatus})}static deserialize(e){const r=JSON.parse(e),n=new $f;return r.accessToken&&r.identity&&(n.accessToken=r.accessToken,n.identity=r.identity),r.conversationSid&&(n.conversationSid=r.conversationSid),n.conversationStarted=r.conversationStarted||!1,n.connectionState=r.connectionState||zr.ConnectionState.DISCONNECTED,n.conversationStatus=r.conversationStatus||zr.ConversationStatus.PENDING,n}setupClientListeners(){this.client&&(this.client.on("connectionStateChanged",e=>{const r=this.connectionState,n=this.mapConnectionState(e);this.connectionState=n,this._emitter.emit("connectionStateChanged",{previous:r,current:n}),n===zr.ConnectionState.CONNECTED&&r!==zr.ConnectionState.CONNECTED&&this.processMessageQueue()}),this.client.on("tokenAboutToExpire",async()=>{console.log("Token about to expire, refreshing..."),await this.refreshToken()}),this.client.on("tokenExpired",async()=>{console.warn("Token expired, refreshing..."),await this.refreshToken()}),this.client.on("conversationJoined",e=>{console.log("Conversation joined"),this._emitter.emit("conversationJoined",{conversationSid:e.sid,timestamp:new Date})}),this.client.on("conversationLeft",e=>{console.log("Conversation left"),this._emitter.emit("conversationLeft",{conversationSid:e.sid,timestamp:new Date})}),this.client.on("connectionError",e=>{console.error("Twilio connection error:",e),this.handleError("Connection error",e)}))}async initialize(e){try{this.config=e,this.accessToken=e.accessToken,this.identity=e.identity,this.tokenRefreshUrl=e.tokenRefreshUrl;const{Client:r}=await Promise.resolve().then(()=>dre);this.client=new r(e.accessToken,{logLevel:e.logLevel||"error"}),this.setupClientListeners(),await this.waitForClientReady(),e.conversationSid&&(this.conversationSid=e.conversationSid,await this.joinConversation(e.conversationSid))}catch(r){throw console.error("Failed to initialize Twilio Manager:",r),this.handleError("Initialization failed",r),r}}async waitForClientReady(){return new Promise((e,r)=>{if(!this.client){r(new Error("Client not initialized"));return}const n=setTimeout(()=>{r(new Error("Client initialization timeout"))},3e4);this.client.on("initialized",()=>{clearTimeout(n),e()}),this.client.on("initFailed",i=>{clearTimeout(n),r(i)})})}mapConnectionState(e){switch(e){case"connecting":return zr.ConnectionState.CONNECTING;case"connected":return zr.ConnectionState.CONNECTED;case"disconnecting":return zr.ConnectionState.DISCONNECTING;case"disconnected":return zr.ConnectionState.DISCONNECTED;case"denied":return zr.ConnectionState.DENIED;case"error":return zr.ConnectionState.ERROR;default:return zr.ConnectionState.DISCONNECTED}}async refreshToken(){try{if(!this.tokenRefreshUrl)throw new Error("Token refresh URL not configured");const e=await fetch(this.tokenRefreshUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:this.identity})});if(!e.ok)throw new Error(`Token refresh failed: ${e.statusText}`);const r=await e.json();this.accessToken=r.token,this.client&&(await this.client.updateToken(r.token),console.log("Token refreshed successfully"),this._emitter.emit("tokenRefreshed",{timestamp:new Date}))}catch(e){throw console.error("Token refresh failed:",e),this.handleError("Token refresh failed",e),e}}async createConversation(e){try{if(!this.client)throw new Error("Client not initialized");const r=await this.client.createConversation({friendlyName:e.friendlyName,uniqueName:e.uniqueName,attributes:e.attributes});this.conversation=r,this.conversationSid=r.sid,await r.join(),this.setupConversationListeners(r);const n={sid:r.sid,friendlyName:r.friendlyName,uniqueName:r.uniqueName,attributes:r.attributes,dateCreated:r.dateCreated,dateUpdated:r.dateUpdated,state:r.state,status:zr.ConversationStatus.ACTIVE};return this.conversationStarted=!0,this.conversationStatus=zr.ConversationStatus.ACTIVE,this._emitter.emit("conversationCreated",n),n}catch(r){throw console.error("Failed to create conversation:",r),this.handleError("Conversation creation failed",r),r}}async joinConversation(e){try{if(!this.client)throw new Error("Client not initialized");console.log("Joining conversation:",e);const r=await this.client.getConversationBySid(e);try{await r.join()}catch(n){if(n.code!==50403)throw n}this.conversation=r,this.conversationSid=e,this.setupConversationListeners(r),this.conversationStarted=!0,this.conversationStatus=zr.ConversationStatus.ACTIVE,this._emitter.emit("conversationJoined",{conversationSid:e,timestamp:new Date})}catch(r){throw console.error("Failed to join conversation:",r),this.handleError("Failed to join conversation",r),r}}async initializeConversation(e){return this.createConversation(e)}setupConversationListeners(e){const r=(n,i)=>{let a;const s=o=>{try{const u=o.replace(/_([0-9A-Fa-f]{2})/g,"%$1");return decodeURIComponent(u)}catch(u){return console.warn("Could not decode Twilio identity:",u),o}};return n&&n.attributes&&(a=n.attributes.public_identity||n.attributes.full_name||n.attributes.friendlyName,a&&(a=s(a))),!a&&i&&(a=s(i)),a};e.on("messageAdded",async n=>{console.log("Message added");let i;try{const s=await e.getParticipantByIdentity(n.author);i=r(s,n.author)}catch(s){console.warn("Could not fetch participant info for friendly name:",s),i=r(null,n.author)}const a={index:n.index,sid:n.sid,body:n.body,author:n.author,authorFriendlyName:i,participantSid:n.participantSid,timestamp:n.dateCreated,attributes:n.attributes,media:n.attachedMedia};this._emitter.emit("message",a),n.author!==this.identity&&await this.acknowledgeMessage(n.index.toString())}),e.on("typingStarted",n=>{console.log("Typing started");const i={identity:n.identity,participantSid:n.sid,isTyping:!0};this._emitter.emit("agentTyping",i)}),e.on("typingEnded",n=>{console.log("Typing ended");const i={identity:n.identity,participantSid:n.sid,isTyping:!1};this._emitter.emit("typingEnded",i)}),e.on("participantJoined",n=>{console.log("Participant joined");const i=r(n,n.identity),a={sid:n.sid,identity:n.identity,friendlyName:i,attributes:n.attributes,timestamp:new Date};this._emitter.emit("agentJoined",a)}),e.on("participantLeft",n=>{console.log("Participant left");const i=r(n,n.identity),a={sid:n.sid,identity:n.identity,friendlyName:i,timestamp:new Date};this._emitter.emit("agentLeftConversation",a)}),e.on("participantUpdated",n=>{console.log("Participant updated"),this._emitter.emit("participantUpdated",n)}),e.on("updated",n=>{console.log("Conversation updated"),this._emitter.emit("conversationUpdated",n)})}async sendMessage(e,r){try{if(!this.conversation||!this.conversationStarted)throw new Error("Conversation not started");let n,i;if(typeof e=="string"?(n=e,i=r):(n=e.body,i=e.attributes),this.connectionState!==zr.ConnectionState.CONNECTED)return new Promise((s,o)=>{this.messageQueue.push({content:n,attributes:i,resolve:s,reject:o})});const a=await this.conversation.sendMessage(n,i);return this._emitter.emit("messageSent",{content:n,attributes:i,index:a,timestamp:new Date}),await Promise.resolve()}catch(n){throw console.error("Failed to send message:",n),this.handleError("Message sending failed",n),n}}async sendTyping(){try{if(!this.conversation)throw new Error("Conversation not started");this.typingTimeout&&clearTimeout(this.typingTimeout),await this.conversation.typing(),this.typingTimeout=setTimeout(()=>{this.typingTimeout=void 0},3e3)}catch(e){console.error("Failed to send typing indicator:",e)}}async acknowledgeMessage(e){try{if(!this.conversation)throw new Error("Conversation not started");const r=parseInt(e,10);if(isNaN(r)){console.warn("Invalid message ID format:",e);return}await this.conversation.updateLastReadMessageIndex(r),this._emitter.emit("messageAcknowledged",{messageId:e,timestamp:new Date})}catch(r){console.error("Failed to acknowledge message:",r)}}async processMessageQueue(){for(;this.messageQueue.length>0;){const e=this.messageQueue.shift();if(e)try{await this.sendMessage(e.content,e.attributes),e.resolve()}catch(r){e.reject(r)}}}async terminateConversation(){try{if(!this.conversation)throw new Error("Conversation not started");await this.conversation.leave(),this._emitter.emit("conversationTerminated",{conversationSid:this.conversationSid,timestamp:new Date}),this.conversation=null,this.conversationSid=null,this.conversationStarted=!1,this.conversationStatus=zr.ConversationStatus.CLOSED}catch(e){throw console.error("Failed to terminate conversation:",e),this.handleError("Conversation termination failed",e),e}}async connect(){if(!this.client)throw new Error("Client not initialized");if(!this.conversationSid)throw new Error("Conversation not started")}async reconnectClient(){try{if(!this.config)throw new Error("Configuration not available");await this.initialize(this.config),await this.processMessageQueue()}catch(e){throw console.error("Failed to reconnect client:",e),e}}async disconnect(){this.client&&(this.client=null),this.connectionState=zr.ConnectionState.DISCONNECTED}async reconnect(){await this.disconnect(),this.config&&await this.initialize(this.config)}destroy(){this.tokenRefreshTimeout&&(clearTimeout(this.tokenRefreshTimeout),this.tokenRefreshTimeout=void 0),this.typingTimeout&&(clearTimeout(this.typingTimeout),this.typingTimeout=void 0),this.client&&(this.client.shutdown(),this.client=null),this.conversation=null,this.conversationSid=null,this.accessToken=null,this.identity=null,this.conversationStarted=!1,this.connectionState=zr.ConnectionState.DISCONNECTED,this.conversationStatus=zr.ConversationStatus.CLOSED,this.messageQueue=[],this._emitter.all.clear()}handleError(e,r){const n={message:e,code:r==null?void 0:r.code,status:r==null?void 0:r.status,details:r,timestamp:new Date};this._emitter.emit("error",n)}get token(){return this.accessToken}get userIdentity(){return this.identity}get currentConversationSid(){return this.conversationSid}getConnectionStatus(){return this.connectionState}getConversationState(){return this.conversationStatus}isConnected(){return this.connectionState===zr.ConnectionState.CONNECTED}getClient(){return this.client}getConversation(){return this.conversation}getState(){return{system:"twilio",conversationSid:this.conversationSid,identity:this.identity,connectionState:this.connectionState,conversationStatus:this.conversationStatus,conversationStarted:this.conversationStarted}}}const{baseApi:d4}=l4;function oo(t){return`any-${t||"main"}-chatSession`}async function f4({id:t,params:e,chatWindow:r,html:n}){const{threadId:i}=r.chatManager;r=r;const a=async()=>{var re,Me;const{firstName:d,lastName:f,phone:m,email:k,propertyId:L}=e,N={propertyId:L||e.propertyId||((Me=(re=r.options)==null?void 0:re.params)==null?void 0:Me.propertyId),firstName:d,lastName:f,phoneNumber:m,email:k,threadId:i},{guestCardId:z}=await d4.post("/anyone-home/newGuestCard",N);e.guestCardId=z},s=async()=>{r.removeMessage("transferMessageId"),r.removeMessage("guestCardFormId"),await r.sendFunctionCallResponse(t,{transfer:"Declined"},!0),r.setInputDisabled(!1)},o=async()=>{r.removeMessage("transferMessageId"),e.guestCardId?(u(),await l()):await c()},u=()=>{r.addMessage({id:"waitMessageId",role:"system",content:"Please wait while we connect you to a live agent"}),r.setInputDisabled(!0)},l=async()=>{var Me,Oe;await r.sendFunctionCallResponse(t,{transfer:"Accepted",guestCardId:e.guestCardId,firstName:e.firstName,lastName:e.lastName,phoneNumber:e.phoneNumber,email:e.email},!1),await r.chatManager.endChat("Transferred to live agent",!1);const{summary:d,subject:f,guestCardId:m,firstName:k,lastName:L,phone:N,email:z}=e,re=e.propertyName||((Oe=(Me=r.options)==null?void 0:Me.params)==null?void 0:Oe.propertyName);{const Fe="https://five9.ah.inhabit.work",Pe=z||`customer-${Date.now()}`,Ze=await fetch(`${Fe}/api/twilio/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:Pe})});if(!Ze.ok)throw new Error(`Failed to get Twilio token: ${Ze.statusText}`);const{token:Z}=await Ze.json(),Ie=new $f;await Ie.initialize({accessToken:Z,identity:Pe,tokenRefreshUrl:`${Fe}/api/twilio/token-refresh`,autoReconnect:!0,logLevel:"info"}),await Ie.createConversation({friendlyName:`${k} ${L} - ${f||"Customer Chat"}`,uniqueName:`chat-${Date.now()}-${m}`,attributes:{pre_engagement_data:{gc_id:m,friendlyName:k,last_name:L,phone:N,email:z,question:f,aiSummary:d,propertyName:re}}});const _e="FW490d224a211a6f2bea01c23aaa492122";try{const{conversationSid:se}=Ie.getState(),Te=await fetch(`${Fe}/twilio-conversations/${se}/attach-studio-flow`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowSid:_e,filters:["onMessageAdded"]})});if(Te.ok){const te=await Te.json()}else console.warn("[TransferToLiveAgent] Failed to attach Studio Flow webhook:",await Te.text())}catch(se){console.error("[TransferToLiveAgent] Error attaching Studio Flow webhook:",se)}try{const{conversationSid:se}=Ie.getState(),Te=`${Fe}/twilio-conversations/${se}/webhooks`.replace(/^http:/,"https:"),te=await fetch(`${Fe}/twilio-conversations/${se}/attach-webhook`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({webhookUrl:Te,method:"POST",filters:["onMessageAdded","onMessageUpdated","onParticipantAdded","onParticipantRemoved","onConversationUpdated"]})});if(te.ok){const oe=await te.json()}else console.warn("[TransferToLiveAgent] Failed to attach backend webhook:",await te.text())}catch(se){console.error("[TransferToLiveAgent] Error attaching backend webhook:",se)}try{await Ie.sendMessage({body:"Customer has been transferred to live agent",attributes:{gc_id:m,friendlyName:k,last_name:L,email:z,phone:N,question:f||"General inquiry",aiSummary:d||"No prior conversation",propertyName:re,messageType:"transfer_trigger"}})}catch(se){console.error("[TransferToLiveAgent] Error sending Studio Flow trigger message:",se)}localStorage.setItem(oo(r.cleanOptions.config.historyKey),JSON.stringify(Ie.getState())),r.setInputDisabled(!1),N_(r,Ie)}},c=async()=>{const d=async f=>{e={...e,...f.detail},r.removeMessage("guestCardFormId"),u();try{await a()}catch(m){console.log(m)}await l()};r.addMessage({id:"guestCardFormId",role:"system",contentHtmlTemplate:n`
778
778
  <any-contact-form
779
779
  .params=${e}
780
780
  @submit=${d}
@@ -785,10 +785,10 @@ Please report this to https://github.com/markedjs/marked.`,t){const n="<p>An err
785
785
  @transfer=${o}
786
786
  @cancel=${s}
787
787
  ></any-transfer-confirmation>
788
- `})}class h4{constructor(e,r){const n=pf.parse({assistantId:"657acbb4-d23e-487f-9090-4ac9a237b474",...e,config:{...e.config,styles:e.styles||{}}});n.handlers.functionCalls.transferToLiveAgent=f4,n.handlers.functionCalls.showScheduleTourWidget=e4(r.schedulerUrl),n.handlers.enhancedContent.unitList=JN,n.handlers.enhancedContent.photoViewer=YN,this.chatWidget=new KN(n);const i=localStorage.getItem(oo(n.config.historyKey));if(i){const{chatWidget:a}=this;(async()=>{try{const s=JSON.parse(i),o="https://five9.ah.inhabit.work",u=s.identity||`customer-${Date.now()}`,l=await fetch(`${o}/api/twilio/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:u})});if(!l.ok)throw new Error("Failed to get Twilio token for session restoration");const{token:c}=await l.json(),d=new $f;await d.initialize({accessToken:c,identity:u,conversationSid:s.conversationSid,autoReconnect:!0,logLevel:"info"}),N_(a.api.chatWindow,d)}catch(s){console.error("Failed to restore Twilio session:",s),localStorage.removeItem(oo(n.config.historyKey))}})()}}destroy(){this.chatWidget.destroy()}}var L_={},vc=function(t){return t&&t.Math===Math&&t},ur=vc(typeof globalThis=="object"&&globalThis)||vc(typeof window=="object"&&window)||vc(typeof self=="object"&&self)||vc(typeof sn=="object"&&sn)||vc(typeof sn=="object"&&sn)||function(){return this}()||Function("return this")(),ma={},qt=function(t){try{return!!t()}catch{return!0}},p4=qt,xr=!p4(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),v4=qt,gc=!v4(function(){var t=(function(){}).bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),g4=gc,Tf=Function.prototype.call,$r=g4?Tf.bind(Tf):function(){return Tf.apply(Tf,arguments)},mc={},D_={}.propertyIsEnumerable,j_=Object.getOwnPropertyDescriptor,m4=j_&&!D_.call({1:2},1);mc.f=m4?function(e){var r=j_(this,e);return!!r&&r.enumerable}:D_;var uo=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},U_=gc,F_=Function.prototype,jv=F_.call,y4=U_&&F_.bind.bind(jv,jv),Gt=U_?y4:function(t){return function(){return jv.apply(t,arguments)}},B_=Gt,b4=B_({}.toString),w4=B_("".slice),qi=function(t){return w4(b4(t),8,-1)},_4=Gt,k4=qt,S4=qi,Uv=Object,$4=_4("".split),yc=k4(function(){return!Uv("z").propertyIsEnumerable(0)})?function(t){return S4(t)==="String"?$4(t,""):Uv(t)}:Uv,ki=function(t){return t==null},T4=ki,C4=TypeError,Si=function(t){if(T4(t))throw new C4("Can't call method on "+t);return t},E4=yc,I4=Si,Vn=function(t){return E4(I4(t))},Fv=typeof document=="object"&&document.all,Tr=typeof Fv>"u"&&Fv!==void 0?function(t){return typeof t=="function"||t===Fv}:function(t){return typeof t=="function"},x4=Tr,Mr=function(t){return typeof t=="object"?t!==null:x4(t)},Bv=ur,R4=Tr,A4=function(t){return R4(t)?t:void 0},$i=function(t,e){return arguments.length<2?A4(Bv[t]):Bv[t]&&Bv[t][e]},O4=Gt,ya=O4({}.isPrototypeOf),lo=typeof navigator<"u"&&String(navigator.userAgent)||"",z_=ur,zv=lo,H_=z_.process,q_=z_.Deno,V_=H_&&H_.versions||q_&&q_.version,W_=V_&&V_.v8,Ti,Cf;W_&&(Ti=W_.split("."),Cf=Ti[0]>0&&Ti[0]<4?1:+(Ti[0]+Ti[1])),!Cf&&zv&&(Ti=zv.match(/Edge\/(\d+)/),(!Ti||Ti[1]>=74)&&(Ti=zv.match(/Chrome\/(\d+)/),Ti&&(Cf=+Ti[1])));var fu=Cf,Z_=fu,P4=qt,M4=ur,N4=M4.String,hu=!!Object.getOwnPropertySymbols&&!P4(function(){var t=Symbol("symbol detection");return!N4(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Z_&&Z_<41}),L4=hu,G_=L4&&!Symbol.sham&&typeof Symbol.iterator=="symbol",D4=$i,j4=Tr,U4=ya,F4=G_,B4=Object,pu=F4?function(t){return typeof t=="symbol"}:function(t){var e=D4("Symbol");return j4(e)&&U4(e.prototype,B4(t))},z4=String,co=function(t){try{return z4(t)}catch{return"Object"}},H4=Tr,q4=co,V4=TypeError,ti=function(t){if(H4(t))return t;throw new V4(q4(t)+" is not a function")},W4=ti,Z4=ki,fo=function(t,e){var r=t[e];return Z4(r)?void 0:W4(r)},Hv=$r,qv=Tr,Vv=Mr,G4=TypeError,K4=function(t,e){var r,n;if(e==="string"&&qv(r=t.toString)&&!Vv(n=Hv(r,t))||qv(r=t.valueOf)&&!Vv(n=Hv(r,t))||e!=="string"&&qv(r=t.toString)&&!Vv(n=Hv(r,t)))return n;throw new G4("Can't convert object to primitive value")},K_={exports:{}},Y_=!1,J_=ur,Y4=Object.defineProperty,Wv=function(t,e){try{Y4(J_,t,{value:e,configurable:!0,writable:!0})}catch{J_[t]=e}return e},J4=ur,Q4=Wv,Q_="__core-js_shared__",X_=K_.exports=J4[Q_]||Q4(Q_,{});(X_.versions||(X_.versions=[])).push({version:"3.37.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Zv=K_.exports,e1=Zv,vu=function(t,e){return e1[t]||(e1[t]=e||{})},X4=Si,e3=Object,vn=function(t){return e3(X4(t))},t3=Gt,r3=vn,n3=t3({}.hasOwnProperty),Hr=Object.hasOwn||function(e,r){return n3(r3(e),r)},i3=Gt,a3=0,s3=Math.random(),o3=i3(1 .toString),bc=function(t){return"Symbol("+(t===void 0?"":t)+")_"+o3(++a3+s3,36)},u3=ur,l3=vu,t1=Hr,c3=bc,d3=hu,f3=G_,gu=u3.Symbol,Gv=l3("wks"),h3=f3?gu.for||gu:gu&&gu.withoutSetter||c3,Cr=function(t){return t1(Gv,t)||(Gv[t]=d3&&t1(gu,t)?gu[t]:h3("Symbol."+t)),Gv[t]},p3=$r,r1=Mr,n1=pu,v3=fo,g3=K4,m3=Cr,y3=TypeError,b3=m3("toPrimitive"),Kv=function(t,e){if(!r1(t)||n1(t))return t;var r=v3(t,b3),n;if(r){if(e===void 0&&(e="default"),n=p3(r,t,e),!r1(n)||n1(n))return n;throw new y3("Can't convert object to primitive value")}return e===void 0&&(e="number"),g3(t,e)},w3=Kv,_3=pu,Ef=function(t){var e=w3(t,"string");return _3(e)?e:e+""},k3=ur,i1=Mr,Yv=k3.document,S3=i1(Yv)&&i1(Yv.createElement),If=function(t){return S3?Yv.createElement(t):{}},$3=xr,T3=qt,C3=If,a1=!$3&&!T3(function(){return Object.defineProperty(C3("div"),"a",{get:function(){return 7}}).a!==7}),E3=xr,I3=$r,x3=mc,R3=uo,A3=Vn,O3=Ef,P3=Hr,M3=a1,s1=Object.getOwnPropertyDescriptor;ma.f=E3?s1:function(e,r){if(e=A3(e),r=O3(r),M3)try{return s1(e,r)}catch{}if(P3(e,r))return R3(!I3(x3.f,e,r),e[r])};var $n={},N3=xr,L3=qt,o1=N3&&L3(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),D3=Mr,j3=String,U3=TypeError,Wr=function(t){if(D3(t))return t;throw new U3(j3(t)+" is not an object")},F3=xr,B3=a1,z3=o1,xf=Wr,u1=Ef,H3=TypeError,Jv=Object.defineProperty,q3=Object.getOwnPropertyDescriptor,Qv="enumerable",Xv="configurable",eg="writable";$n.f=F3?z3?function(e,r,n){if(xf(e),r=u1(r),xf(n),typeof e=="function"&&r==="prototype"&&"value"in n&&eg in n&&!n[eg]){var i=q3(e,r);i&&i[eg]&&(e[r]=n.value,n={configurable:Xv in n?n[Xv]:i[Xv],enumerable:Qv in n?n[Qv]:i[Qv],writable:!1})}return Jv(e,r,n)}:Jv:function(e,r,n){if(xf(e),r=u1(r),xf(n),B3)try{return Jv(e,r,n)}catch{}if("get"in n||"set"in n)throw new H3("Accessors not supported");return"value"in n&&(e[r]=n.value),e};var V3=xr,W3=$n,Z3=uo,ba=V3?function(t,e,r){return W3.f(t,e,Z3(1,r))}:function(t,e,r){return t[e]=r,t},l1={exports:{}},tg=xr,G3=Hr,c1=Function.prototype,K3=tg&&Object.getOwnPropertyDescriptor,rg=G3(c1,"name"),Y3=rg&&(function(){}).name==="something",J3=rg&&(!tg||tg&&K3(c1,"name").configurable),wc={EXISTS:rg,PROPER:Y3,CONFIGURABLE:J3},Q3=Gt,X3=Tr,ng=Zv,eL=Q3(Function.toString);X3(ng.inspectSource)||(ng.inspectSource=function(t){return eL(t)});var ig=ng.inspectSource,tL=ur,rL=Tr,d1=tL.WeakMap,nL=rL(d1)&&/native code/.test(String(d1)),iL=vu,aL=bc,f1=iL("keys"),Rf=function(t){return f1[t]||(f1[t]=aL(t))},_c={},sL=nL,h1=ur,oL=Mr,uL=ba,ag=Hr,sg=Zv,lL=Rf,cL=_c,p1="Object already initialized",og=h1.TypeError,dL=h1.WeakMap,Af,kc,Of,fL=function(t){return Of(t)?kc(t):Af(t,{})},hL=function(t){return function(e){var r;if(!oL(e)||(r=kc(e)).type!==t)throw new og("Incompatible receiver, "+t+" required");return r}};if(sL||sg.state){var Vi=sg.state||(sg.state=new dL);Vi.get=Vi.get,Vi.has=Vi.has,Vi.set=Vi.set,Af=function(t,e){if(Vi.has(t))throw new og(p1);return e.facade=t,Vi.set(t,e),e},kc=function(t){return Vi.get(t)||{}},Of=function(t){return Vi.has(t)}}else{var mu=lL("state");cL[mu]=!0,Af=function(t,e){if(ag(t,mu))throw new og(p1);return e.facade=t,uL(t,mu,e),e},kc=function(t){return ag(t,mu)?t[mu]:{}},Of=function(t){return ag(t,mu)}}var Wn={set:Af,get:kc,has:Of,enforce:fL,getterFor:hL},ug=Gt,pL=qt,vL=Tr,Pf=Hr,lg=xr,gL=wc.CONFIGURABLE,mL=ig,v1=Wn,yL=v1.enforce,bL=v1.get,g1=String,Mf=Object.defineProperty,wL=ug("".slice),_L=ug("".replace),kL=ug([].join),SL=lg&&!pL(function(){return Mf(function(){},"length",{value:8}).length!==8}),$L=String(String).split("String"),TL=l1.exports=function(t,e,r){wL(g1(e),0,7)==="Symbol("&&(e="["+_L(g1(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(e="get "+e),r&&r.setter&&(e="set "+e),(!Pf(t,"name")||gL&&t.name!==e)&&(lg?Mf(t,"name",{value:e,configurable:!0}):t.name=e),SL&&r&&Pf(r,"arity")&&t.length!==r.arity&&Mf(t,"length",{value:r.arity});try{r&&Pf(r,"constructor")&&r.constructor?lg&&Mf(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch{}var n=yL(t);return Pf(n,"source")||(n.source=kL($L,typeof e=="string"?e:"")),t};Function.prototype.toString=TL(function(){return vL(this)&&bL(this).source||mL(this)},"toString");var m1=l1.exports,CL=Tr,EL=$n,IL=m1,xL=Wv,Tn=function(t,e,r,n){n||(n={});var i=n.enumerable,a=n.name!==void 0?n.name:e;if(CL(r)&&IL(r,a,n),n.global)i?t[e]=r:xL(e,r);else{try{n.unsafe?t[e]&&(i=!0):delete t[e]}catch{}i?t[e]=r:EL.f(t,e,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return t},ho={},RL=Math.ceil,AL=Math.floor,OL=Math.trunc||function(e){var r=+e;return(r>0?AL:RL)(r)},PL=OL,Wi=function(t){var e=+t;return e!==e||e===0?0:PL(e)},ML=Wi,NL=Math.max,LL=Math.min,yu=function(t,e){var r=ML(t);return r<0?NL(r+e,0):LL(r,e)},DL=Wi,jL=Math.min,wa=function(t){var e=DL(t);return e>0?jL(e,9007199254740991):0},UL=wa,gn=function(t){return UL(t.length)},FL=Vn,BL=yu,zL=gn,y1=function(t){return function(e,r,n){var i=FL(e),a=zL(i);if(a===0)return!t&&-1;var s=BL(n,a),o;if(t&&r!==r){for(;a>s;)if(o=i[s++],o!==o)return!0}else for(;a>s;s++)if((t||s in i)&&i[s]===r)return t||s||0;return!t&&-1}},Nf={includes:y1(!0),indexOf:y1(!1)},HL=Gt,cg=Hr,qL=Vn,VL=Nf.indexOf,WL=_c,b1=HL([].push),w1=function(t,e){var r=qL(t),n=0,i=[],a;for(a in r)!cg(WL,a)&&cg(r,a)&&b1(i,a);for(;e.length>n;)cg(r,a=e[n++])&&(~VL(i,a)||b1(i,a));return i},dg=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ZL=w1,GL=dg,KL=GL.concat("length","prototype");ho.f=Object.getOwnPropertyNames||function(e){return ZL(e,KL)};var Sc={};Sc.f=Object.getOwnPropertySymbols;var YL=$i,JL=Gt,QL=ho,XL=Sc,eD=Wr,tD=JL([].concat),_1=YL("Reflect","ownKeys")||function(e){var r=QL.f(eD(e)),n=XL.f;return n?tD(r,n(e)):r},k1=Hr,rD=_1,nD=ma,iD=$n,fg=function(t,e,r){for(var n=rD(e),i=iD.f,a=nD.f,s=0;s<n.length;s++){var o=n[s];!k1(t,o)&&!(r&&k1(r,o))&&i(t,o,a(e,o))}},aD=qt,sD=Tr,oD=/#|\.prototype\./,$c=function(t,e){var r=lD[uD(t)];return r===dD?!0:r===cD?!1:sD(e)?aD(e):!!e},uD=$c.normalize=function(t){return String(t).replace(oD,".").toLowerCase()},lD=$c.data={},cD=$c.NATIVE="N",dD=$c.POLYFILL="P",Lf=$c,Df=ur,fD=ma.f,hD=ba,pD=Tn,vD=Wv,gD=fg,mD=Lf,Xt=function(t,e){var r=t.target,n=t.global,i=t.stat,a,s,o,u,l,c;if(n?s=Df:i?s=Df[r]||vD(r,{}):s=Df[r]&&Df[r].prototype,s)for(o in e){if(l=e[o],t.dontCallGetSet?(c=fD(s,o),u=c&&c.value):u=s[o],a=mD(n?o:r+(i?".":"#")+o,t.forced),!a&&u!==void 0){if(typeof l==typeof u)continue;gD(l,u)}(t.sham||u&&u.sham)&&hD(l,"sham",!0),pD(s,o,l,t)}},yD=$n.f,bD=Hr,wD=Cr,S1=wD("toStringTag"),Zi=function(t,e,r){t&&!r&&(t=t.prototype),t&&!bD(t,S1)&&yD(t,S1,{configurable:!0,value:e})},_D=Xt,kD=ur,SD=Zi;_D({global:!0},{Reflect:{}}),SD(kD.Reflect,"Reflect",!0);var $D=gc,$1=Function.prototype,T1=$1.apply,C1=$1.call,po=typeof Reflect=="object"&&Reflect.apply||($D?C1.bind(T1):function(){return C1.apply(T1,arguments)}),TD=Gt,Gi=TD([].slice),E1=Gt,CD=ti,ED=Mr,ID=Hr,I1=Gi,xD=gc,x1=Function,RD=E1([].concat),AD=E1([].join),hg={},OD=function(t,e,r){if(!ID(hg,e)){for(var n=[],i=0;i<e;i++)n[i]="a["+i+"]";hg[e]=x1("C,a","return new C("+AD(n,",")+")")}return hg[e](t,r)},PD=xD?x1.bind:function(e){var r=CD(this),n=r.prototype,i=I1(arguments,1),a=function(){var o=RD(i,I1(arguments));return this instanceof a?OD(r,o.length,o):r.apply(e,o)};return ED(n)&&(a.prototype=n),a},MD=Cr,ND=MD("toStringTag"),R1={};R1[ND]="z";var pg=String(R1)==="[object z]",LD=pg,DD=Tr,jf=qi,jD=Cr,UD=jD("toStringTag"),FD=Object,BD=jf(function(){return arguments}())==="Arguments",zD=function(t,e){try{return t[e]}catch{}},_a=LD?jf:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=zD(e=FD(t),UD))=="string"?r:BD?jf(e):(n=jf(e))==="Object"&&DD(e.callee)?"Arguments":n},HD=Gt,qD=qt,A1=Tr,VD=_a,WD=$i,ZD=ig,O1=function(){},P1=WD("Reflect","construct"),vg=/^\s*(?:class|function)\b/,GD=HD(vg.exec),KD=!vg.test(O1),Tc=function(e){if(!A1(e))return!1;try{return P1(O1,[],e),!0}catch{return!1}},M1=function(e){if(!A1(e))return!1;switch(VD(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return KD||!!GD(vg,ZD(e))}catch{return!0}};M1.sham=!0;var Uf=!P1||qD(function(){var t;return Tc(Tc.call)||!Tc(Object)||!Tc(function(){t=!0})||t})?M1:Tc,YD=Uf,JD=co,QD=TypeError,gg=function(t){if(YD(t))return t;throw new QD(JD(t)+" is not a constructor")},mg={},XD=w1,ej=dg,Cc=Object.keys||function(e){return XD(e,ej)},tj=xr,rj=o1,nj=$n,ij=Wr,aj=Vn,sj=Cc;mg.f=tj&&!rj?Object.defineProperties:function(e,r){ij(e);for(var n=aj(r),i=sj(r),a=i.length,s=0,o;a>s;)nj.f(e,o=i[s++],n[o]);return e};var oj=$i,N1=oj("document","documentElement"),uj=Wr,lj=mg,L1=dg,cj=_c,dj=N1,fj=If,hj=Rf,D1=">",j1="<",yg="prototype",bg="script",U1=hj("IE_PROTO"),wg=function(){},F1=function(t){return j1+bg+D1+t+j1+"/"+bg+D1},B1=function(t){t.write(F1("")),t.close();var e=t.parentWindow.Object;return t=null,e},pj=function(){var t=fj("iframe"),e="java"+bg+":",r;return t.style.display="none",dj.appendChild(t),t.src=String(e),r=t.contentWindow.document,r.open(),r.write(F1("document.F=Object")),r.close(),r.F},Ff,Bf=function(){try{Ff=new ActiveXObject("htmlfile")}catch{}Bf=typeof document<"u"?document.domain&&Ff?B1(Ff):pj():B1(Ff);for(var t=L1.length;t--;)delete Bf[yg][L1[t]];return Bf()};cj[U1]=!0;var os=Object.create||function(e,r){var n;return e!==null?(wg[yg]=uj(e),n=new wg,wg[yg]=null,n[U1]=e):n=Bf(),r===void 0?n:lj.f(n,r)},vj=Xt,gj=$i,_g=po,mj=PD,z1=gg,yj=Wr,H1=Mr,bj=os,q1=qt,kg=gj("Reflect","construct"),wj=Object.prototype,_j=[].push,V1=q1(function(){function t(){}return!(kg(function(){},[],t)instanceof t)}),W1=!q1(function(){kg(function(){})}),Z1=V1||W1;vj({target:"Reflect",stat:!0,forced:Z1,sham:Z1},{construct:function(e,r){z1(e),yj(r);var n=arguments.length<3?e:z1(arguments[2]);if(W1&&!V1)return kg(e,r,n);if(e===n){switch(r.length){case 0:return new e;case 1:return new e(r[0]);case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[1],r[2]);case 4:return new e(r[0],r[1],r[2],r[3])}var i=[null];return _g(_j,i,r),new(_g(mj,e,i))}var a=n.prototype,s=bj(H1(a)?a:wj),o=_g(e,s,r);return H1(o)?o:s}});var kj=Xt,Sj=vn,G1=Cc,$j=qt,Tj=$j(function(){G1(1)});kj({target:"Object",stat:!0,forced:Tj},{keys:function(e){return G1(Sj(e))}});var Cj=_a,Ej=String,Xr=function(t){if(Cj(t)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return Ej(t)},Sg={},Ij=qi,xj=Vn,K1=ho.f,Rj=Gi,Y1=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Aj=function(t){try{return K1(t)}catch{return Rj(Y1)}};Sg.f=function(e){return Y1&&Ij(e)==="Window"?Aj(e):K1(xj(e))};var J1=m1,Oj=$n,Ki=function(t,e,r){return r.get&&J1(r.get,e,{getter:!0}),r.set&&J1(r.set,e,{setter:!0}),Oj.f(t,e,r)},$g={},Pj=Cr;$g.f=Pj;var Mj=ur,Q1=Mj,X1=Q1,Nj=Hr,Lj=$g,Dj=$n.f,ek=function(t){var e=X1.Symbol||(X1.Symbol={});Nj(e,t)||Dj(e,t,{value:Lj.f(t)})},jj=$r,Uj=$i,Fj=Cr,Bj=Tn,zj=function(){var t=Uj("Symbol"),e=t&&t.prototype,r=e&&e.valueOf,n=Fj("toPrimitive");e&&!e[n]&&Bj(e,n,function(i){return jj(r,this)},{arity:1})},Hj=qi,qj=Gt,Tg=function(t){if(Hj(t)==="Function")return qj(t)},tk=Tg,Vj=ti,Wj=gc,Zj=tk(tk.bind),ka=function(t,e){return Vj(t),e===void 0?t:Wj?Zj(t,e):function(){return t.apply(e,arguments)}},Gj=qi,Ec=Array.isArray||function(e){return Gj(e)==="Array"},rk=Ec,Kj=Uf,Yj=Mr,Jj=Cr,Qj=Jj("species"),nk=Array,Xj=function(t){var e;return rk(t)&&(e=t.constructor,Kj(e)&&(e===nk||rk(e.prototype))?e=void 0:Yj(e)&&(e=e[Qj],e===null&&(e=void 0))),e===void 0?nk:e},eU=Xj,Cg=function(t,e){return new(eU(t))(e===0?0:e)},tU=ka,rU=Gt,nU=yc,iU=vn,aU=gn,sU=Cg,ik=rU([].push),us=function(t){var e=t===1,r=t===2,n=t===3,i=t===4,a=t===6,s=t===7,o=t===5||a;return function(u,l,c,d){for(var f=iU(u),m=nU(f),k=aU(m),L=tU(l,c),N=0,z=d||sU,re=e?z(u,k):r||s?z(u,0):void 0,Me,Oe;k>N;N++)if((o||N in m)&&(Me=m[N],Oe=L(Me,N,f),t))if(e)re[N]=Oe;else if(Oe)switch(t){case 3:return!0;case 5:return Me;case 6:return N;case 2:ik(re,Me)}else switch(t){case 4:return!1;case 7:ik(re,Me)}return a?-1:n||i?i:re}},Nn={forEach:us(0),map:us(1),filter:us(2),some:us(3),every:us(4),find:us(5),findIndex:us(6),filterReject:us(7)},zf=Xt,Ic=ur,Eg=$r,oU=Gt,bu=xr,wu=hu,uU=qt,ln=Hr,lU=ya,Ig=Wr,Hf=Vn,xg=Ef,cU=Xr,Rg=uo,_u=os,ak=Cc,dU=ho,sk=Sg,fU=Sc,ok=ma,uk=$n,hU=mg,lk=mc,Ag=Tn,pU=Ki,Og=vu,vU=Rf,ck=_c,dk=bc,gU=Cr,mU=$g,yU=ek,bU=zj,wU=Zi,fk=Wn,qf=Nn.forEach,Ln=vU("hidden"),Vf="Symbol",xc="prototype",_U=fk.set,hk=fk.getterFor(Vf),ri=Object[xc],vo=Ic.Symbol,Rc=vo&&vo[xc],kU=Ic.RangeError,SU=Ic.TypeError,Pg=Ic.QObject,pk=ok.f,go=uk.f,vk=sk.f,$U=lk.f,gk=oU([].push),Sa=Og("symbols"),Ac=Og("op-symbols"),TU=Og("wks"),Mg=!Pg||!Pg[xc]||!Pg[xc].findChild,mk=function(t,e,r){var n=pk(ri,e);n&&delete ri[e],go(t,e,r),n&&t!==ri&&go(ri,e,n)},Ng=bu&&uU(function(){return _u(go({},"a",{get:function(){return go(this,"a",{value:7}).a}})).a!==7})?mk:go,Lg=function(t,e){var r=Sa[t]=_u(Rc);return _U(r,{type:Vf,tag:t,description:e}),bu||(r.description=e),r},Wf=function(e,r,n){e===ri&&Wf(Ac,r,n),Ig(e);var i=xg(r);return Ig(n),ln(Sa,i)?(n.enumerable?(ln(e,Ln)&&e[Ln][i]&&(e[Ln][i]=!1),n=_u(n,{enumerable:Rg(0,!1)})):(ln(e,Ln)||go(e,Ln,Rg(1,_u(null))),e[Ln][i]=!0),Ng(e,i,n)):go(e,i,n)},Dg=function(e,r){Ig(e);var n=Hf(r),i=ak(n).concat(wk(n));return qf(i,function(a){(!bu||Eg(jg,n,a))&&Wf(e,a,n[a])}),e},CU=function(e,r){return r===void 0?_u(e):Dg(_u(e),r)},jg=function(e){var r=xg(e),n=Eg($U,this,r);return this===ri&&ln(Sa,r)&&!ln(Ac,r)?!1:n||!ln(this,r)||!ln(Sa,r)||ln(this,Ln)&&this[Ln][r]?n:!0},yk=function(e,r){var n=Hf(e),i=xg(r);if(!(n===ri&&ln(Sa,i)&&!ln(Ac,i))){var a=pk(n,i);return a&&ln(Sa,i)&&!(ln(n,Ln)&&n[Ln][i])&&(a.enumerable=!0),a}},bk=function(e){var r=vk(Hf(e)),n=[];return qf(r,function(i){!ln(Sa,i)&&!ln(ck,i)&&gk(n,i)}),n},wk=function(t){var e=t===ri,r=vk(e?Ac:Hf(t)),n=[];return qf(r,function(i){ln(Sa,i)&&(!e||ln(ri,i))&&gk(n,Sa[i])}),n};wu||(vo=function(){if(lU(Rc,this))throw new SU("Symbol is not a constructor");var e=!arguments.length||arguments[0]===void 0?void 0:cU(arguments[0]),r=dk(e),n=function(i){var a=this===void 0?Ic:this;a===ri&&Eg(n,Ac,i),ln(a,Ln)&&ln(a[Ln],r)&&(a[Ln][r]=!1);var s=Rg(1,i);try{Ng(a,r,s)}catch(o){if(!(o instanceof kU))throw o;mk(a,r,s)}};return bu&&Mg&&Ng(ri,r,{configurable:!0,set:n}),Lg(r,e)},Rc=vo[xc],Ag(Rc,"toString",function(){return hk(this).tag}),Ag(vo,"withoutSetter",function(t){return Lg(dk(t),t)}),lk.f=jg,uk.f=Wf,hU.f=Dg,ok.f=yk,dU.f=sk.f=bk,fU.f=wk,mU.f=function(t){return Lg(gU(t),t)},bu&&(pU(Rc,"description",{configurable:!0,get:function(){return hk(this).description}}),Ag(ri,"propertyIsEnumerable",jg,{unsafe:!0}))),zf({global:!0,constructor:!0,wrap:!0,forced:!wu,sham:!wu},{Symbol:vo}),qf(ak(TU),function(t){yU(t)}),zf({target:Vf,stat:!0,forced:!wu},{useSetter:function(){Mg=!0},useSimple:function(){Mg=!1}}),zf({target:"Object",stat:!0,forced:!wu,sham:!bu},{create:CU,defineProperty:Wf,defineProperties:Dg,getOwnPropertyDescriptor:yk}),zf({target:"Object",stat:!0,forced:!wu},{getOwnPropertyNames:bk}),bU(),wU(vo,Vf),ck[Ln]=!0;var EU=hu,_k=EU&&!!Symbol.for&&!!Symbol.keyFor,IU=Xt,xU=$i,RU=Hr,AU=Xr,kk=vu,OU=_k,Ug=kk("string-to-symbol-registry"),PU=kk("symbol-to-string-registry");IU({target:"Symbol",stat:!0,forced:!OU},{for:function(t){var e=AU(t);if(RU(Ug,e))return Ug[e];var r=xU("Symbol")(e);return Ug[e]=r,PU[r]=e,r}});var MU=Xt,NU=Hr,LU=pu,DU=co,jU=vu,UU=_k,Sk=jU("symbol-to-string-registry");MU({target:"Symbol",stat:!0,forced:!UU},{keyFor:function(e){if(!LU(e))throw new TypeError(DU(e)+" is not a symbol");if(NU(Sk,e))return Sk[e]}});var FU=Gt,$k=Ec,BU=Tr,Tk=qi,zU=Xr,Ck=FU([].push),HU=function(t){if(BU(t))return t;if($k(t)){for(var e=t.length,r=[],n=0;n<e;n++){var i=t[n];typeof i=="string"?Ck(r,i):(typeof i=="number"||Tk(i)==="Number"||Tk(i)==="String")&&Ck(r,zU(i))}var a=r.length,s=!0;return function(o,u){if(s)return s=!1,u;if($k(this))return u;for(var l=0;l<a;l++)if(r[l]===o)return u}}},qU=Xt,Ek=$i,Ik=po,VU=$r,Oc=Gt,xk=qt,Rk=Tr,Ak=pu,Ok=Gi,WU=HU,ZU=hu,GU=String,ls=Ek("JSON","stringify"),Zf=Oc(/./.exec),Pk=Oc("".charAt),KU=Oc("".charCodeAt),YU=Oc("".replace),JU=Oc(1 .toString),QU=/[\uD800-\uDFFF]/g,Mk=/^[\uD800-\uDBFF]$/,Nk=/^[\uDC00-\uDFFF]$/,Lk=!ZU||xk(function(){var t=Ek("Symbol")("stringify detection");return ls([t])!=="[null]"||ls({a:t})!=="{}"||ls(Object(t))!=="{}"}),Dk=xk(function(){return ls("\uDF06\uD834")!=='"\\udf06\\ud834"'||ls("\uDEAD")!=='"\\udead"'}),XU=function(t,e){var r=Ok(arguments),n=WU(e);if(!(!Rk(n)&&(t===void 0||Ak(t))))return r[1]=function(i,a){if(Rk(n)&&(a=VU(n,this,GU(i),a)),!Ak(a))return a},Ik(ls,null,r)},e6=function(t,e,r){var n=Pk(r,e-1),i=Pk(r,e+1);return Zf(Mk,t)&&!Zf(Nk,i)||Zf(Nk,t)&&!Zf(Mk,n)?"\\u"+JU(KU(t,0),16):t};ls&&qU({target:"JSON",stat:!0,arity:3,forced:Lk||Dk},{stringify:function(e,r,n){var i=Ok(arguments),a=Ik(Lk?XU:ls,null,i);return Dk&&typeof a=="string"?YU(a,QU,e6):a}});var t6=Xt,r6=hu,n6=qt,jk=Sc,i6=vn,a6=!r6||n6(function(){jk.f(1)});t6({target:"Object",stat:!0,forced:a6},{getOwnPropertySymbols:function(e){var r=jk.f;return r?r(i6(e)):[]}});var s6=qt,o6=Cr,u6=fu,l6=o6("species"),Pc=function(t){return u6>=51||!s6(function(){var e=[],r=e.constructor={};return r[l6]=function(){return{foo:1}},e[t](Boolean).foo!==1})},c6=Xt,d6=Nn.filter,f6=Pc,h6=f6("filter");c6({target:"Array",proto:!0,forced:!h6},{filter:function(e){return d6(this,e,arguments.length>1?arguments[1]:void 0)}});var p6=Xt,v6=qt,g6=Vn,Uk=ma.f,Fk=xr,m6=!Fk||v6(function(){Uk(1)});p6({target:"Object",stat:!0,forced:m6,sham:!Fk},{getOwnPropertyDescriptor:function(e,r){return Uk(g6(e),r)}});var y6=xr,b6=$n,w6=uo,Mc=function(t,e,r){y6?b6.f(t,e,w6(0,r)):t[e]=r},_6=Xt,k6=xr,S6=_1,$6=Vn,T6=ma,C6=Mc;_6({target:"Object",stat:!0,sham:!k6},{getOwnPropertyDescriptors:function(e){for(var r=$6(e),n=T6.f,i=S6(r),a={},s=0,o,u;i.length>s;)u=n(r,o=i[s++]),u!==void 0&&C6(a,o,u);return a}});var Bk={exports:{}};(function(t){function e(n,i,a,s,o,u,l){try{var c=n[u](l),d=c.value}catch(f){return void a(f)}c.done?i(d):Promise.resolve(d).then(s,o)}function r(n){return function(){var i=this,a=arguments;return new Promise(function(s,o){var u=n.apply(i,a);function l(d){e(u,s,o,l,c,"next",d)}function c(d){e(u,s,o,l,c,"throw",d)}l(void 0)})}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(Bk);var ku=Bk.exports,zk={exports:{}};(function(t){function e(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(zk);var cs=zk.exports,Hk={exports:{}},qk={exports:{}};(function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,a){return i.__proto__=a,i},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(qk);var Fg=qk.exports;(function(t){var e=Fg;function r(n,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(i&&i.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),i&&e(n,i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(Hk);var Yi=Hk.exports,Vk={exports:{}},Wk={exports:{}};(function(t){function e(r){"@babel/helpers - typeof";return t.exports=e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(Wk);var ni=Wk.exports;(function(t){var e=ni.default,r=cs;function n(i,a){if(a&&(e(a)=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(Vk);var Ji=Vk.exports,Zk={exports:{}};(function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(Zk);var ii=Zk.exports,Gk={exports:{}},Kk={exports:{}},Yk={exports:{}};(function(t){var e=ni.default;function r(n,i){if(e(n)!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var s=a.call(n,i||"default");if(e(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(Yk);var E6=Yk.exports;(function(t){var e=ni.default,r=E6;function n(i){var a=r(i,"string");return e(a)=="symbol"?a:a+""}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(Kk);var Jk=Kk.exports;(function(t){var e=Jk;function r(n,i,a){return(i=e(i))in n?Object.defineProperty(n,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[i]=a,n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(Gk);var ds=Gk.exports,Qk={exports:{}};(function(t){var e=Jk;function r(i,a){for(var s=0;s<a.length;s++){var o=a[s];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(i,e(o.key),o)}}function n(i,a,s){return a&&r(i.prototype,a),s&&r(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(Qk);var $a=Qk.exports,Xk={exports:{}};(function(t){function e(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(Xk);var Qi=Xk.exports,I6=Xt,x6=Nn.map,R6=Pc,A6=R6("map");I6({target:"Array",proto:!0,forced:!A6},{map:function(e){return x6(this,e,arguments.length>1?arguments[1]:void 0)}});var O6=pg,P6=_a,M6=O6?{}.toString:function(){return"[object "+P6(this)+"]"},N6=pg,L6=Tn,D6=M6;N6||L6(Object.prototype,"toString",D6,{unsafe:!0});var eS={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},j6=If,Bg=j6("span").classList,tS=Bg&&Bg.constructor&&Bg.constructor.prototype,rS=tS===Object.prototype?void 0:tS,U6=qt,Gf=function(t,e){var r=[][t];return!!r&&U6(function(){r.call(null,e||function(){return 1},1)})},F6=Nn.forEach,B6=Gf,z6=B6("forEach"),H6=z6?[].forEach:function(e){return F6(this,e,arguments.length>1?arguments[1]:void 0)},nS=ur,iS=eS,q6=rS,zg=H6,V6=ba,aS=function(t){if(t&&t.forEach!==zg)try{V6(t,"forEach",zg)}catch{t.forEach=zg}};for(var Hg in iS)iS[Hg]&&aS(nS[Hg]&&nS[Hg].prototype);aS(q6);var W6=ur,Z6=qi,Kf=Z6(W6.process)==="process",G6=Gt,K6=ti,Y6=function(t,e,r){try{return G6(K6(Object.getOwnPropertyDescriptor(t,e)[r]))}catch{}},J6=Mr,Q6=function(t){return J6(t)||t===null},X6=Q6,e5=String,t5=TypeError,r5=function(t){if(X6(t))return t;throw new t5("Can't set "+e5(t)+" as a prototype")},n5=Y6,i5=Mr,a5=Si,s5=r5,Su=Object.setPrototypeOf||("__proto__"in{}?function(){var t=!1,e={},r;try{r=n5(Object.prototype,"__proto__","set"),r(e,[]),t=e instanceof Array}catch{}return function(i,a){return a5(i),s5(a),i5(i)&&(t?r(i,a):i.__proto__=a),i}}():void 0),o5=$i,u5=Ki,l5=Cr,c5=xr,sS=l5("species"),Yf=function(t){var e=o5(t);c5&&e&&!e[sS]&&u5(e,sS,{configurable:!0,get:function(){return this}})},d5=ya,f5=TypeError,fs=function(t,e){if(d5(e,t))return t;throw new f5("Incorrect invocation")},oS=Wr,h5=gg,p5=ki,v5=Cr,g5=v5("species"),qg=function(t,e){var r=oS(t).constructor,n;return r===void 0||p5(n=oS(r)[g5])?e:h5(n)},m5=TypeError,Vg=function(t,e){if(t<e)throw new m5("Not enough arguments");return t},y5=lo,uS=/(?:ipad|iphone|ipod).*applewebkit/i.test(y5),Zn=ur,b5=po,w5=ka,lS=Tr,_5=Hr,cS=qt,dS=N1,k5=Gi,fS=If,S5=Vg,$5=uS,T5=Kf,Wg=Zn.setImmediate,Zg=Zn.clearImmediate,C5=Zn.process,Gg=Zn.Dispatch,E5=Zn.Function,hS=Zn.MessageChannel,I5=Zn.String,Kg=0,Nc={},pS="onreadystatechange",Lc,mo,Yg,Jg;cS(function(){Lc=Zn.location});var Qg=function(t){if(_5(Nc,t)){var e=Nc[t];delete Nc[t],e()}},Xg=function(t){return function(){Qg(t)}},vS=function(t){Qg(t.data)},gS=function(t){Zn.postMessage(I5(t),Lc.protocol+"//"+Lc.host)};(!Wg||!Zg)&&(Wg=function(e){S5(arguments.length,1);var r=lS(e)?e:E5(e),n=k5(arguments,1);return Nc[++Kg]=function(){b5(r,void 0,n)},mo(Kg),Kg},Zg=function(e){delete Nc[e]},T5?mo=function(t){C5.nextTick(Xg(t))}:Gg&&Gg.now?mo=function(t){Gg.now(Xg(t))}:hS&&!$5?(Yg=new hS,Jg=Yg.port2,Yg.port1.onmessage=vS,mo=w5(Jg.postMessage,Jg)):Zn.addEventListener&&lS(Zn.postMessage)&&!Zn.importScripts&&Lc&&Lc.protocol!=="file:"&&!cS(gS)?(mo=gS,Zn.addEventListener("message",vS,!1)):pS in fS("script")?mo=function(t){dS.appendChild(fS("script"))[pS]=function(){dS.removeChild(this),Qg(t)}}:mo=function(t){setTimeout(Xg(t),0)});var mS={set:Wg,clear:Zg},yS=ur,x5=xr,R5=Object.getOwnPropertyDescriptor,bS=function(t){if(!x5)return yS[t];var e=R5(yS,t);return e&&e.value},wS=function(){this.head=null,this.tail=null};wS.prototype={add:function(t){var e={item:t,next:null},r=this.tail;r?r.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t){var e=this.head=t.next;return e===null&&(this.tail=null),t.item}}};var _S=wS,A5=lo,O5=/ipad|iphone|ipod/i.test(A5)&&typeof Pebble<"u",P5=lo,M5=/web0s(?!.*chrome)/i.test(P5),$u=ur,N5=bS,kS=ka,em=mS.set,L5=_S,D5=uS,j5=O5,U5=M5,tm=Kf,SS=$u.MutationObserver||$u.WebKitMutationObserver,$S=$u.document,TS=$u.process,Jf=$u.Promise,rm=N5("queueMicrotask"),Tu,nm,im,Qf,CS;if(!rm){var Xf=new L5,eh=function(){var t,e;for(tm&&(t=TS.domain)&&t.exit();e=Xf.get();)try{e()}catch(r){throw Xf.head&&Tu(),r}t&&t.enter()};!D5&&!tm&&!U5&&SS&&$S?(nm=!0,im=$S.createTextNode(""),new SS(eh).observe(im,{characterData:!0}),Tu=function(){im.data=nm=!nm}):!j5&&Jf&&Jf.resolve?(Qf=Jf.resolve(void 0),Qf.constructor=Jf,CS=kS(Qf.then,Qf),Tu=function(){CS(eh)}):tm?Tu=function(){TS.nextTick(eh)}:(em=kS(em,$u),Tu=function(){em(eh)}),rm=function(t){Xf.head||Tu(),Xf.add(t)}}var F5=rm,B5=function(t,e){try{arguments.length===1?console.error(t):console.error(t,e)}catch{}},am=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}},z5=ur,th=z5.Promise,ES=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",H5=ES,q5=Kf,V5=!H5&&!q5&&typeof window=="object"&&typeof document=="object",W5=ur,Dc=th,Z5=Tr,G5=Lf,K5=ig,Y5=Cr,J5=V5,Q5=ES,sm=fu;Dc&&Dc.prototype;var X5=Y5("species"),om=!1,IS=Z5(W5.PromiseRejectionEvent),eF=G5("Promise",function(){var t=K5(Dc),e=t!==String(Dc);if(!e&&sm===66)return!0;if(!sm||sm<51||!/native code/.test(t)){var r=new Dc(function(a){a(1)}),n=function(a){a(function(){},function(){})},i=r.constructor={};if(i[X5]=n,om=r.then(function(){})instanceof n,!om)return!0}return!e&&(J5||Q5)&&!IS}),jc={CONSTRUCTOR:eF,REJECTION_EVENT:IS,SUBCLASSING:om},Cu={},xS=ti,tF=TypeError,rF=function(t){var e,r;this.promise=new t(function(n,i){if(e!==void 0||r!==void 0)throw new tF("Bad Promise constructor");e=n,r=i}),this.resolve=xS(e),this.reject=xS(r)};Cu.f=function(t){return new rF(t)};var nF=Xt,rh=Kf,hs=ur,Eu=$r,RS=Tn,AS=Su,iF=Zi,aF=Yf,sF=ti,nh=Tr,oF=Mr,uF=fs,lF=qg,OS=mS.set,um=F5,cF=B5,dF=am,fF=_S,PS=Wn,ih=th,lm=jc,MS=Cu,ah="Promise",NS=lm.CONSTRUCTOR,hF=lm.REJECTION_EVENT,pF=lm.SUBCLASSING,cm=PS.getterFor(ah),vF=PS.set,Iu=ih&&ih.prototype,yo=ih,sh=Iu,LS=hs.TypeError,dm=hs.document,fm=hs.process,hm=MS.f,gF=hm,mF=!!(dm&&dm.createEvent&&hs.dispatchEvent),DS="unhandledrejection",yF="rejectionhandled",jS=0,US=1,bF=2,pm=1,FS=2,oh,BS,wF,zS,HS=function(t){var e;return oF(t)&&nh(e=t.then)?e:!1},qS=function(t,e){var r=e.value,n=e.state===US,i=n?t.ok:t.fail,a=t.resolve,s=t.reject,o=t.domain,u,l,c;try{i?(n||(e.rejection===FS&&kF(e),e.rejection=pm),i===!0?u=r:(o&&o.enter(),u=i(r),o&&(o.exit(),c=!0)),u===t.promise?s(new LS("Promise-chain cycle")):(l=HS(u))?Eu(l,u,a,s):a(u)):s(r)}catch(d){o&&!c&&o.exit(),s(d)}},VS=function(t,e){t.notified||(t.notified=!0,um(function(){for(var r=t.reactions,n;n=r.get();)qS(n,t);t.notified=!1,e&&!t.rejection&&_F(t)}))},WS=function(t,e,r){var n,i;mF?(n=dm.createEvent("Event"),n.promise=e,n.reason=r,n.initEvent(t,!1,!0),hs.dispatchEvent(n)):n={promise:e,reason:r},!hF&&(i=hs["on"+t])?i(n):t===DS&&cF("Unhandled promise rejection",r)},_F=function(t){Eu(OS,hs,function(){var e=t.facade,r=t.value,n=ZS(t),i;if(n&&(i=dF(function(){rh?fm.emit("unhandledRejection",r,e):WS(DS,e,r)}),t.rejection=rh||ZS(t)?FS:pm,i.error))throw i.value})},ZS=function(t){return t.rejection!==pm&&!t.parent},kF=function(t){Eu(OS,hs,function(){var e=t.facade;rh?fm.emit("rejectionHandled",e):WS(yF,e,t.value)})},xu=function(t,e,r){return function(n){t(e,n,r)}},Ru=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=bF,VS(t,!0))},vm=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw new LS("Promise can't be resolved itself");var n=HS(e);n?um(function(){var i={done:!1};try{Eu(n,e,xu(vm,i,t),xu(Ru,i,t))}catch(a){Ru(i,a,t)}}):(t.value=e,t.state=US,VS(t,!1))}catch(i){Ru({done:!1},i,t)}}};if(NS&&(yo=function(e){uF(this,sh),sF(e),Eu(oh,this);var r=cm(this);try{e(xu(vm,r),xu(Ru,r))}catch(n){Ru(r,n)}},sh=yo.prototype,oh=function(e){vF(this,{type:ah,done:!1,notified:!1,parent:!1,reactions:new fF,rejection:!1,state:jS,value:void 0})},oh.prototype=RS(sh,"then",function(e,r){var n=cm(this),i=hm(lF(this,yo));return n.parent=!0,i.ok=nh(e)?e:!0,i.fail=nh(r)&&r,i.domain=rh?fm.domain:void 0,n.state===jS?n.reactions.add(i):um(function(){qS(i,n)}),i.promise}),BS=function(){var t=new oh,e=cm(t);this.promise=t,this.resolve=xu(vm,e),this.reject=xu(Ru,e)},MS.f=hm=function(t){return t===yo||t===wF?new BS(t):gF(t)},nh(ih)&&Iu!==Object.prototype)){zS=Iu.then,pF||RS(Iu,"then",function(e,r){var n=this;return new yo(function(i,a){Eu(zS,n,i,a)}).then(e,r)},{unsafe:!0});try{delete Iu.constructor}catch{}AS&&AS(Iu,sh)}nF({global:!0,constructor:!0,wrap:!0,forced:NS},{Promise:yo}),iF(yo,ah,!1),aF(ah);var Uc={},SF=Cr,$F=Uc,TF=SF("iterator"),CF=Array.prototype,gm=function(t){return t!==void 0&&($F.Array===t||CF[TF]===t)},EF=_a,GS=fo,IF=ki,xF=Uc,RF=Cr,AF=RF("iterator"),Fc=function(t){if(!IF(t))return GS(t,AF)||GS(t,"@@iterator")||xF[EF(t)]},OF=$r,PF=ti,MF=Wr,NF=co,LF=Fc,DF=TypeError,uh=function(t,e){var r=arguments.length<2?LF(t):e;if(PF(r))return MF(OF(r,t));throw new DF(NF(t)+" is not iterable")},jF=$r,KS=Wr,UF=fo,YS=function(t,e,r){var n,i;KS(t);try{if(n=UF(t,"return"),!n){if(e==="throw")throw r;return r}n=jF(n,t)}catch(a){i=!0,n=a}if(e==="throw")throw r;if(i)throw n;return KS(n),r},FF=ka,BF=$r,zF=Wr,HF=co,qF=gm,VF=gn,JS=ya,WF=uh,ZF=Fc,QS=YS,GF=TypeError,lh=function(t,e){this.stopped=t,this.result=e},XS=lh.prototype,Bc=function(t,e,r){var n=r&&r.that,i=!!(r&&r.AS_ENTRIES),a=!!(r&&r.IS_RECORD),s=!!(r&&r.IS_ITERATOR),o=!!(r&&r.INTERRUPTED),u=FF(e,n),l,c,d,f,m,k,L,N=function(re){return l&&QS(l,"normal",re),new lh(!0,re)},z=function(re){return i?(zF(re),o?u(re[0],re[1],N):u(re[0],re[1])):o?u(re,N):u(re)};if(a)l=t.iterator;else if(s)l=t;else{if(c=ZF(t),!c)throw new GF(HF(t)+" is not iterable");if(qF(c)){for(d=0,f=VF(t);f>d;d++)if(m=z(t[d]),m&&JS(XS,m))return m;return new lh(!1)}l=WF(t,c)}for(k=a?t.next:l.next;!(L=BF(k,l)).done;){try{m=z(L.value)}catch(re){QS(l,"throw",re)}if(typeof m=="object"&&m&&JS(XS,m))return m}return new lh(!1)},KF=Cr,e$=KF("iterator"),t$=!1;try{var YF=0,r$={next:function(){return{done:!!YF++}},return:function(){t$=!0}};r$[e$]=function(){return this},Array.from(r$,function(){throw 2})}catch{}var ch=function(t,e){try{if(!e&&!t$)return!1}catch{return!1}var r=!1;try{var n={};n[e$]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch{}return r},JF=th,QF=ch,XF=jc.CONSTRUCTOR,n$=XF||!QF(function(t){JF.all(t).then(void 0,function(){})}),e8=Xt,t8=$r,r8=ti,n8=Cu,i8=am,a8=Bc,s8=n$;e8({target:"Promise",stat:!0,forced:s8},{all:function(e){var r=this,n=n8.f(r),i=n.resolve,a=n.reject,s=i8(function(){var o=r8(r.resolve),u=[],l=0,c=1;a8(e,function(d){var f=l++,m=!1;c++,t8(o,r,d).then(function(k){m||(m=!0,u[f]=k,--c||i(u))},a)}),--c||i(u)});return s.error&&a(s.value),n.promise}});var o8=Xt,u8=jc.CONSTRUCTOR,mm=th,l8=$i,c8=Tr,d8=Tn,i$=mm&&mm.prototype;if(o8({target:"Promise",proto:!0,forced:u8,real:!0},{catch:function(t){return this.then(void 0,t)}}),c8(mm)){var a$=l8("Promise").prototype.catch;i$.catch!==a$&&d8(i$,"catch",a$,{unsafe:!0})}var f8=Xt,h8=$r,p8=ti,v8=Cu,g8=am,m8=Bc,y8=n$;f8({target:"Promise",stat:!0,forced:y8},{race:function(e){var r=this,n=v8.f(r),i=n.reject,a=g8(function(){var s=p8(r.resolve);m8(e,function(o){h8(s,r,o).then(n.resolve,i)})});return a.error&&i(a.value),n.promise}});var b8=Xt,w8=Cu,_8=jc.CONSTRUCTOR;b8({target:"Promise",stat:!0,forced:_8},{reject:function(e){var r=w8.f(this),n=r.reject;return n(e),r.promise}});var k8=Wr,S8=Mr,$8=Cu,T8=function(t,e){if(k8(t),S8(e)&&e.constructor===t)return e;var r=$8.f(t),n=r.resolve;return n(e),r.promise},C8=Xt,E8=$i,I8=jc.CONSTRUCTOR,x8=T8;E8("Promise"),C8({target:"Promise",stat:!0,forced:I8},{resolve:function(e){return x8(this,e)}});var s$={exports:{}},o$={exports:{}};(function(t){function e(r,n){this.v=r,this.k=n}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(o$);var u$=o$.exports,l$={exports:{}},c$={exports:{}};(function(t){function e(r,n,i,a){var s=Object.defineProperty;try{s({},"",{})}catch{s=0}t.exports=e=function(u,l,c,d){function f(m,k){e(u,m,function(L){return this._invoke(m,k,L)})}l?s?s(u,l,{value:c,enumerable:!d,configurable:!d,writable:!d}):u[l]=c:(f("next",0),f("throw",1),f("return",2))},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n,i,a)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(c$);var d$=c$.exports;(function(t){var e=d$;function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var n,i,a=typeof Symbol=="function"?Symbol:{},s=a.iterator||"@@iterator",o=a.toStringTag||"@@toStringTag";function u(N,z,re,Me){var Oe=z&&z.prototype instanceof c?z:c,Be=Object.create(Oe.prototype);return e(Be,"_invoke",function(Pe,Ze,Z){var Ie,_e,se,Te=0,te=Z||[],oe=!1,q={p:0,n:0,v:n,a:ne,f:ne.bind(n,4),d:function(H,ye){return Ie=H,_e=0,se=n,q.n=ye,l}};function ne(Se,H){for(_e=Se,se=H,i=0;!oe&&Te&&!ye&&i<te.length;i++){var ye,ke=te[i],P=q.p,Qe=ke[2];Se>3?(ye=Qe===H)&&(se=ke[(_e=ke[4])?5:(_e=3,3)],ke[4]=ke[5]=n):ke[0]<=P&&((ye=Se<2&&P<ke[1])?(_e=0,q.v=H,q.n=ke[1]):P<Qe&&(ye=Se<3||ke[0]>H||H>Qe)&&(ke[4]=Se,ke[5]=H,q.n=Qe,_e=0))}if(ye||Se>1)return l;throw oe=!0,H}return function(Se,H,ye){if(Te>1)throw TypeError("Generator is already running");for(oe&&H===1&&ne(H,ye),_e=H,se=ye;(i=_e<2?n:se)||!oe;){Ie||(_e?_e<3?(_e>1&&(q.n=-1),ne(_e,se)):q.n=se:q.v=se);try{if(Te=2,Ie){if(_e||(Se="next"),i=Ie[Se]){if(!(i=i.call(Ie,se)))throw TypeError("iterator result is not an object");if(!i.done)return i;se=i.value,_e<2&&(_e=0)}else _e===1&&(i=Ie.return)&&i.call(Ie),_e<2&&(se=TypeError("The iterator does not provide a '"+Se+"' method"),_e=1);Ie=n}else if((i=(oe=q.n<0)?se:Pe.call(Ze,q))!==l)break}catch(ke){Ie=n,_e=1,se=ke}finally{Te=1}}return{value:i,done:oe}}}(N,re,Me),!0),Be}var l={};function c(){}function d(){}function f(){}i=Object.getPrototypeOf;var m=[][s]?i(i([][s]())):(e(i={},s,function(){return this}),i),k=f.prototype=c.prototype=Object.create(m);function L(N){return Object.setPrototypeOf?Object.setPrototypeOf(N,f):(N.__proto__=f,e(N,o,"GeneratorFunction")),N.prototype=Object.create(k),N}return d.prototype=f,e(k,"constructor",f),e(f,"constructor",d),d.displayName="GeneratorFunction",e(f,o,"GeneratorFunction"),e(k),e(k,o,"Generator"),e(k,s,function(){return this}),e(k,"toString",function(){return"[object Generator]"}),(t.exports=r=function(){return{w:u,m:L}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(l$);var f$=l$.exports,h$={exports:{}},p$={exports:{}},v$={exports:{}};(function(t){var e=u$,r=d$;function n(i,a){function s(u,l,c,d){try{var f=i[u](l),m=f.value;return m instanceof e?a.resolve(m.v).then(function(k){s("next",k,c,d)},function(k){s("throw",k,c,d)}):a.resolve(m).then(function(k){f.value=k,c(f)},function(k){return s("throw",k,c,d)})}catch(k){d(k)}}var o;this.next||(r(n.prototype),r(n.prototype,typeof Symbol=="function"&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(u,l,c){function d(){return new a(function(f,m){s(u,c,f,m)})}return o=o?o.then(d,d):d()},!0)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(v$);var g$=v$.exports;(function(t){var e=f$,r=g$;function n(i,a,s,o,u){return new r(e().w(i,a,s,o),u||Promise)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(p$);var m$=p$.exports;(function(t){var e=m$;function r(n,i,a,s,o){var u=e(n,i,a,s,o);return u.next().then(function(l){return l.done?l.value:u.next()})}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(h$);var R8=h$.exports,y$={exports:{}};(function(t){function e(r){var n=Object(r),i=[];for(var a in n)i.unshift(a);return function s(){for(;i.length;)if((a=i.pop())in n)return s.value=a,s.done=!1,s;return s.done=!0,s}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(y$);var A8=y$.exports,b$={exports:{}};(function(t){var e=ni.default;function r(n){if(n!=null){var i=n[typeof Symbol=="function"&&Symbol.iterator||"@@iterator"],a=0;if(i)return i.call(n);if(typeof n.next=="function")return n;if(!isNaN(n.length))return{next:function(){return n&&a>=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}}}throw new TypeError(e(n)+" is not iterable")}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(b$);var O8=b$.exports;(function(t){var e=u$,r=f$,n=R8,i=m$,a=g$,s=A8,o=O8;function u(){var l=r(),c=l.m(u),d=(Object.getPrototypeOf?Object.getPrototypeOf(c):c.__proto__).constructor;function f(L){var N=typeof L=="function"&&L.constructor;return!!N&&(N===d||(N.displayName||N.name)==="GeneratorFunction")}var m={throw:1,return:2,break:3,continue:3};function k(L){var N,z;return function(re){N||(N={stop:function(){return z(re.a,2)},catch:function(){return re.v},abrupt:function(Oe,Be){return z(re.a,m[Oe],Be)},delegateYield:function(Oe,Be,Pe){return N.resultName=Be,z(re.d,o(Oe),Pe)},finish:function(Oe){return z(re.f,Oe)}},z=function(Oe,Be,Pe){re.p=N.prev,re.n=N.next;try{return Oe(Be,Pe)}finally{N.next=re.n}}),N.resultName&&(N[N.resultName]=re.v,N.resultName=void 0),N.sent=re.v,N.next=re.n;try{return L.call(this,N)}finally{re.p=N.prev,re.n=N.next}}}return(t.exports=u=function(){return{wrap:function(z,re,Me,Oe){return l.w(k(z),re,Me,Oe&&Oe.reverse())},isGeneratorFunction:f,mark:l.m,awrap:function(z,re){return new e(z,re)},AsyncIterator:a,async:function(z,re,Me,Oe,Be){return(f(re)?i:n)(k(z),re,Me,Oe,Be)},keys:s,values:o}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=u,t.exports.__esModule=!0,t.exports.default=t.exports})(s$);var P8=s$.exports,dh=P8(),Au=dh;try{regeneratorRuntime=dh}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=dh:Function("r","regeneratorRuntime = r")(dh)}var M8=TypeError,N8=9007199254740991,w$=function(t){if(t>N8)throw M8("Maximum allowed index exceeded");return t},L8=Xt,D8=qt,j8=Ec,U8=Mr,F8=vn,B8=gn,_$=w$,k$=Mc,z8=Cg,H8=Pc,q8=Cr,V8=fu,S$=q8("isConcatSpreadable"),W8=V8>=51||!D8(function(){var t=[];return t[S$]=!1,t.concat()[0]!==t}),Z8=function(t){if(!U8(t))return!1;var e=t[S$];return e!==void 0?!!e:j8(t)},G8=!W8||!H8("concat");L8({target:"Array",proto:!0,arity:1,forced:G8},{concat:function(e){var r=F8(this),n=z8(r,0),i=0,a,s,o,u,l;for(a=-1,o=arguments.length;a<o;a++)if(l=a===-1?r:arguments[a],Z8(l))for(u=B8(l),_$(i+u),s=0;s<u;s++,i++)s in l&&k$(n,i,l[s]);else _$(i+1),k$(n,i++,l);return n.length=i,n}});var K8=Wr,Y8=YS,J8=function(t,e,r,n){try{return n?e(K8(r)[0],r[1]):e(r)}catch(i){Y8(t,"throw",i)}},Q8=ka,X8=$r,eB=vn,tB=J8,rB=gm,nB=Uf,iB=gn,$$=Mc,aB=uh,sB=Fc,T$=Array,C$=function(e){var r=eB(e),n=nB(this),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0;s&&(a=Q8(a,i>2?arguments[2]:void 0));var o=sB(r),u=0,l,c,d,f,m,k;if(o&&!(this===T$&&rB(o)))for(c=n?new this:[],f=aB(r,o),m=f.next;!(d=X8(m,f)).done;u++)k=s?tB(f,a,[d.value,u],!0):d.value,$$(c,u,k);else for(l=iB(r),c=n?new this(l):T$(l);l>u;u++)k=s?a(r[u],u):r[u],$$(c,u,k);return c.length=u,c},oB=Xt,uB=C$,lB=ch,cB=!lB(function(t){Array.from(t)});oB({target:"Array",stat:!0,forced:cB},{from:uB});var ym=Gt,dB=Wi,fB=Xr,hB=Si,pB=ym("".charAt),E$=ym("".charCodeAt),vB=ym("".slice),I$=function(t){return function(e,r){var n=fB(hB(e)),i=dB(r),a=n.length,s,o;return i<0||i>=a?t?"":void 0:(s=E$(n,i),s<55296||s>56319||i+1===a||(o=E$(n,i+1))<56320||o>57343?t?pB(n,i):s:t?vB(n,i,i+2):(s-55296<<10)+(o-56320)+65536)}},bm={codeAt:I$(!1),charAt:I$(!0)},gB=qt,mB=!gB(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),yB=Hr,bB=Tr,wB=vn,_B=Rf,kB=mB,x$=_B("IE_PROTO"),wm=Object,SB=wm.prototype,zc=kB?wm.getPrototypeOf:function(t){var e=wB(t);if(yB(e,x$))return e[x$];var r=e.constructor;return bB(r)&&e instanceof r?r.prototype:e instanceof wm?SB:null},$B=qt,TB=Tr,CB=Mr,R$=zc,EB=Tn,IB=Cr,_m=IB("iterator"),A$=!1,bo,km,Sm;[].keys&&(Sm=[].keys(),"next"in Sm?(km=R$(R$(Sm)),km!==Object.prototype&&(bo=km)):A$=!0);var xB=!CB(bo)||$B(function(){var t={};return bo[_m].call(t)!==t});xB&&(bo={}),TB(bo[_m])||EB(bo,_m,function(){return this});var O$={IteratorPrototype:bo,BUGGY_SAFARI_ITERATORS:A$},RB=O$.IteratorPrototype,AB=os,OB=uo,PB=Zi,MB=Uc,NB=function(){return this},P$=function(t,e,r,n){var i=e+" Iterator";return t.prototype=AB(RB,{next:OB(+!n,r)}),PB(t,i,!1),MB[i]=NB,t},LB=Xt,DB=$r,M$=wc,jB=Tr,UB=P$,N$=zc,L$=Su,FB=Zi,BB=ba,$m=Tn,zB=Cr,HB=Uc,D$=O$,qB=M$.PROPER,VB=M$.CONFIGURABLE,j$=D$.IteratorPrototype,fh=D$.BUGGY_SAFARI_ITERATORS,Hc=zB("iterator"),U$="keys",qc="values",F$="entries",WB=function(){return this},Tm=function(t,e,r,n,i,a,s){UB(r,e,n);var o=function(z){if(z===i&&f)return f;if(!fh&&z&&z in c)return c[z];switch(z){case U$:return function(){return new r(this,z)};case qc:return function(){return new r(this,z)};case F$:return function(){return new r(this,z)}}return function(){return new r(this)}},u=e+" Iterator",l=!1,c=t.prototype,d=c[Hc]||c["@@iterator"]||i&&c[i],f=!fh&&d||o(i),m=e==="Array"&&c.entries||d,k,L,N;if(m&&(k=N$(m.call(new t)),k!==Object.prototype&&k.next&&(N$(k)!==j$&&(L$?L$(k,j$):jB(k[Hc])||$m(k,Hc,WB)),FB(k,u,!0))),qB&&i===qc&&d&&d.name!==qc&&(VB?BB(c,"name",qc):(l=!0,f=function(){return DB(d,this)})),i)if(L={values:o(qc),keys:a?f:o(U$),entries:o(F$)},s)for(N in L)(fh||l||!(N in c))&&$m(c,N,L[N]);else LB({target:e,proto:!0,forced:fh||l},L);return c[Hc]!==f&&$m(c,Hc,f,{name:i}),HB[e]=f,L},hh=function(t,e){return{value:t,done:e}},ZB=bm.charAt,GB=Xr,B$=Wn,KB=Tm,z$=hh,H$="String Iterator",YB=B$.set,JB=B$.getterFor(H$);KB(String,"String",function(t){YB(this,{type:H$,string:GB(t),index:0})},function(){var e=JB(this),r=e.string,n=e.index,i;return n>=r.length?z$(void 0,!0):(i=ZB(r,n),e.index+=i.length,z$(i,!1))});var q$={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(sn,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],a={},s=null;function o(L,N){var z=L[N];if(typeof z.bind=="function")return z.bind(L);try{return Function.prototype.bind.call(z,L)}catch{return function(){return Function.prototype.apply.apply(z,[L,arguments])}}}function u(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(L){return L==="debug"&&(L="log"),typeof console===r?!1:L==="trace"&&n?u:console[L]!==void 0?o(console,L):console.log!==void 0?o(console,"log"):e}function c(){for(var L=this.getLevel(),N=0;N<i.length;N++){var z=i[N];this[z]=N<L?e:this.methodFactory(z,L,this.name)}if(this.log=this.debug,typeof console===r&&L<this.levels.SILENT)return"No console available for logging"}function d(L){return function(){typeof console!==r&&(c.call(this),this[L].apply(this,arguments))}}function f(L,N,z){return l(L)||d.apply(this,arguments)}function m(L,N){var z=this,re,Me,Oe,Be="loglevel";typeof L=="string"?Be+=":"+L:typeof L=="symbol"&&(Be=void 0);function Pe(se){var Te=(i[se]||"silent").toUpperCase();if(!(typeof window===r||!Be)){try{window.localStorage[Be]=Te;return}catch{}try{window.document.cookie=encodeURIComponent(Be)+"="+Te+";"}catch{}}}function Ze(){var se;if(!(typeof window===r||!Be)){try{se=window.localStorage[Be]}catch{}if(typeof se===r)try{var Te=window.document.cookie,te=encodeURIComponent(Be),oe=Te.indexOf(te+"=");oe!==-1&&(se=/^([^;]+)/.exec(Te.slice(oe+te.length+1))[1])}catch{}return z.levels[se]===void 0&&(se=void 0),se}}function Z(){if(!(typeof window===r||!Be)){try{window.localStorage.removeItem(Be)}catch{}try{window.document.cookie=encodeURIComponent(Be)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Ie(se){var Te=se;if(typeof Te=="string"&&z.levels[Te.toUpperCase()]!==void 0&&(Te=z.levels[Te.toUpperCase()]),typeof Te=="number"&&Te>=0&&Te<=z.levels.SILENT)return Te;throw new TypeError("log.setLevel() called with invalid level: "+se)}z.name=L,z.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},z.methodFactory=N||f,z.getLevel=function(){return Oe??Me??re},z.setLevel=function(se,Te){return Oe=Ie(se),Te!==!1&&Pe(Oe),c.call(z)},z.setDefaultLevel=function(se){Me=Ie(se),Ze()||z.setLevel(se,!1)},z.resetLevel=function(){Oe=null,Z(),c.call(z)},z.enableAll=function(se){z.setLevel(z.levels.TRACE,se)},z.disableAll=function(se){z.setLevel(z.levels.SILENT,se)},z.rebuild=function(){if(s!==z&&(re=Ie(s.getLevel())),c.call(z),s===z)for(var se in a)a[se].rebuild()},re=Ie(s?s.getLevel():"WARN");var _e=Ze();_e!=null&&(Oe=Ie(_e)),c.call(z)}s=new m,s.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var z=a[N];return z||(z=a[N]=new m(N,s.methodFactory)),z};var k=typeof window!==r?window.log:void 0;return s.noConflict=function(){return typeof window!==r&&window.log===s&&(window.log=k),s},s.getLoggers=function(){return a},s.default=s,s})})(q$);var Ou=q$.exports;const wo="\\d+(?:[\\.,]\\d+)?",QB=`(${wo}W)`,XB=`(${wo}Y)?(${wo}M)?(${wo}D)?`,e9=`T(${wo}H)?(${wo}M)?(${wo}S)?`,t9=`P(?:${QB}|${XB}(?:${e9})?)`,r9=["weeks","years","months","days","hours","minutes","seconds"],Cm=new RegExp(t9),V$=t=>t.match(Cm).slice(1).reduce((e,r,n)=>(e[r9[n]]=parseFloat(r)||0,e),{}),Em=(t,e)=>{const r=e?e.getTime():Date.now(),n=new Date(r);return n.setFullYear(n.getFullYear()+t.years),n.setMonth(n.getMonth()+t.months),n.setDate(n.getDate()+t.days),n.setHours(n.getHours()+t.hours),n.setMinutes(n.getMinutes()+t.minutes),n.setMilliseconds(n.getMilliseconds()+t.seconds*1e3),n.setDate(n.getDate()+t.weeks*7),n},W$=(t,e)=>{const r=e?e.getTime():Date.now(),n=new Date(r);return(Em(t,n).getTime()-n.getTime())/1e3},n9=B2(Object.freeze(Object.defineProperty({__proto__:null,default:{end:Em,toSeconds:W$,pattern:Cm,parse:V$},end:Em,parse:V$,pattern:Cm,toSeconds:W$},Symbol.toStringTag,{value:"Module"})));var i9=Cr,a9=os,s9=$n.f,Im=i9("unscopables"),xm=Array.prototype;xm[Im]===void 0&&s9(xm,Im,{configurable:!0,value:a9(null)});var Rm=function(t){xm[Im][t]=!0},o9=Vn,Am=Rm,Z$=Uc,G$=Wn,u9=$n.f,l9=Tm,ph=hh,c9=xr,K$="Array Iterator",d9=G$.set,f9=G$.getterFor(K$),Y$=l9(Array,"Array",function(t,e){d9(this,{type:K$,target:o9(t),index:0,kind:e})},function(){var t=f9(this),e=t.target,r=t.index++;if(!e||r>=e.length)return t.target=void 0,ph(void 0,!0);switch(t.kind){case"keys":return ph(r,!1);case"values":return ph(e[r],!1)}return ph([r,e[r]],!1)},"values"),J$=Z$.Arguments=Z$.Array;if(Am("keys"),Am("values"),Am("entries"),c9&&J$.name!=="values")try{u9(J$,"name",{value:"values"})}catch{}var Q$=ur,X$=eS,h9=rS,Vc=Y$,eT=ba,p9=Zi,v9=Cr,Om=v9("iterator"),Pm=Vc.values,tT=function(t,e){if(t){if(t[Om]!==Pm)try{eT(t,Om,Pm)}catch{t[Om]=Pm}if(p9(t,e,!0),X$[e]){for(var r in Vc)if(t[r]!==Vc[r])try{eT(t,r,Vc[r])}catch{t[r]=Vc[r]}}}};for(var Mm in X$)tT(Q$[Mm]&&Q$[Mm].prototype,Mm);tT(h9,"DOMTokenList");var g9=Tr,m9=Mr,rT=Su,vh=function(t,e,r){var n,i;return rT&&g9(n=e.constructor)&&n!==r&&m9(i=n.prototype)&&i!==r.prototype&&rT(t,i),t},y9=Gt,b9=y9(1 .valueOf),w9=`
788
+ `})}class h4{constructor(e,r){const n=pf.parse({assistantId:"657acbb4-d23e-487f-9090-4ac9a237b474",...e,config:{...e.config,styles:e.styles||{}}});n.handlers.functionCalls.transferToLiveAgent=f4,n.handlers.functionCalls.showScheduleTourWidget=e4(r.schedulerUrl),n.handlers.enhancedContent.unitList=JN,n.handlers.enhancedContent.photoViewer=YN,this.chatWidget=new KN(n);const i=localStorage.getItem(oo(n.config.historyKey));if(i){const{chatWidget:a}=this;(async()=>{try{const s=JSON.parse(i),o="https://five9.ah.inhabit.work",u=s.identity||`customer-${Date.now()}`,l=await fetch(`${o}/api/twilio/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:u})});if(!l.ok)throw new Error("Failed to get Twilio token for session restoration");const{token:c}=await l.json(),d=new $f;await d.initialize({accessToken:c,identity:u,conversationSid:s.conversationSid,tokenRefreshUrl:`${o}/api/twilio/token-refresh`,autoReconnect:!0,logLevel:"info"}),N_(a.api.chatWindow,d)}catch(s){console.error("Failed to restore Twilio session:",s),localStorage.removeItem(oo(n.config.historyKey))}})()}}destroy(){this.chatWidget.destroy()}}var L_={},vc=function(t){return t&&t.Math===Math&&t},ur=vc(typeof globalThis=="object"&&globalThis)||vc(typeof window=="object"&&window)||vc(typeof self=="object"&&self)||vc(typeof sn=="object"&&sn)||vc(typeof sn=="object"&&sn)||function(){return this}()||Function("return this")(),ma={},qt=function(t){try{return!!t()}catch{return!0}},p4=qt,xr=!p4(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7}),v4=qt,gc=!v4(function(){var t=(function(){}).bind();return typeof t!="function"||t.hasOwnProperty("prototype")}),g4=gc,Tf=Function.prototype.call,$r=g4?Tf.bind(Tf):function(){return Tf.apply(Tf,arguments)},mc={},D_={}.propertyIsEnumerable,j_=Object.getOwnPropertyDescriptor,m4=j_&&!D_.call({1:2},1);mc.f=m4?function(e){var r=j_(this,e);return!!r&&r.enumerable}:D_;var uo=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}},U_=gc,F_=Function.prototype,jv=F_.call,y4=U_&&F_.bind.bind(jv,jv),Gt=U_?y4:function(t){return function(){return jv.apply(t,arguments)}},B_=Gt,b4=B_({}.toString),w4=B_("".slice),qi=function(t){return w4(b4(t),8,-1)},_4=Gt,k4=qt,S4=qi,Uv=Object,$4=_4("".split),yc=k4(function(){return!Uv("z").propertyIsEnumerable(0)})?function(t){return S4(t)==="String"?$4(t,""):Uv(t)}:Uv,ki=function(t){return t==null},T4=ki,C4=TypeError,Si=function(t){if(T4(t))throw new C4("Can't call method on "+t);return t},E4=yc,I4=Si,Vn=function(t){return E4(I4(t))},Fv=typeof document=="object"&&document.all,Tr=typeof Fv>"u"&&Fv!==void 0?function(t){return typeof t=="function"||t===Fv}:function(t){return typeof t=="function"},x4=Tr,Mr=function(t){return typeof t=="object"?t!==null:x4(t)},Bv=ur,R4=Tr,A4=function(t){return R4(t)?t:void 0},$i=function(t,e){return arguments.length<2?A4(Bv[t]):Bv[t]&&Bv[t][e]},O4=Gt,ya=O4({}.isPrototypeOf),lo=typeof navigator<"u"&&String(navigator.userAgent)||"",z_=ur,zv=lo,H_=z_.process,q_=z_.Deno,V_=H_&&H_.versions||q_&&q_.version,W_=V_&&V_.v8,Ti,Cf;W_&&(Ti=W_.split("."),Cf=Ti[0]>0&&Ti[0]<4?1:+(Ti[0]+Ti[1])),!Cf&&zv&&(Ti=zv.match(/Edge\/(\d+)/),(!Ti||Ti[1]>=74)&&(Ti=zv.match(/Chrome\/(\d+)/),Ti&&(Cf=+Ti[1])));var fu=Cf,Z_=fu,P4=qt,M4=ur,N4=M4.String,hu=!!Object.getOwnPropertySymbols&&!P4(function(){var t=Symbol("symbol detection");return!N4(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&Z_&&Z_<41}),L4=hu,G_=L4&&!Symbol.sham&&typeof Symbol.iterator=="symbol",D4=$i,j4=Tr,U4=ya,F4=G_,B4=Object,pu=F4?function(t){return typeof t=="symbol"}:function(t){var e=D4("Symbol");return j4(e)&&U4(e.prototype,B4(t))},z4=String,co=function(t){try{return z4(t)}catch{return"Object"}},H4=Tr,q4=co,V4=TypeError,ti=function(t){if(H4(t))return t;throw new V4(q4(t)+" is not a function")},W4=ti,Z4=ki,fo=function(t,e){var r=t[e];return Z4(r)?void 0:W4(r)},Hv=$r,qv=Tr,Vv=Mr,G4=TypeError,K4=function(t,e){var r,n;if(e==="string"&&qv(r=t.toString)&&!Vv(n=Hv(r,t))||qv(r=t.valueOf)&&!Vv(n=Hv(r,t))||e!=="string"&&qv(r=t.toString)&&!Vv(n=Hv(r,t)))return n;throw new G4("Can't convert object to primitive value")},K_={exports:{}},Y_=!1,J_=ur,Y4=Object.defineProperty,Wv=function(t,e){try{Y4(J_,t,{value:e,configurable:!0,writable:!0})}catch{J_[t]=e}return e},J4=ur,Q4=Wv,Q_="__core-js_shared__",X_=K_.exports=J4[Q_]||Q4(Q_,{});(X_.versions||(X_.versions=[])).push({version:"3.37.1",mode:"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.37.1/LICENSE",source:"https://github.com/zloirock/core-js"});var Zv=K_.exports,e1=Zv,vu=function(t,e){return e1[t]||(e1[t]=e||{})},X4=Si,e3=Object,vn=function(t){return e3(X4(t))},t3=Gt,r3=vn,n3=t3({}.hasOwnProperty),Hr=Object.hasOwn||function(e,r){return n3(r3(e),r)},i3=Gt,a3=0,s3=Math.random(),o3=i3(1 .toString),bc=function(t){return"Symbol("+(t===void 0?"":t)+")_"+o3(++a3+s3,36)},u3=ur,l3=vu,t1=Hr,c3=bc,d3=hu,f3=G_,gu=u3.Symbol,Gv=l3("wks"),h3=f3?gu.for||gu:gu&&gu.withoutSetter||c3,Cr=function(t){return t1(Gv,t)||(Gv[t]=d3&&t1(gu,t)?gu[t]:h3("Symbol."+t)),Gv[t]},p3=$r,r1=Mr,n1=pu,v3=fo,g3=K4,m3=Cr,y3=TypeError,b3=m3("toPrimitive"),Kv=function(t,e){if(!r1(t)||n1(t))return t;var r=v3(t,b3),n;if(r){if(e===void 0&&(e="default"),n=p3(r,t,e),!r1(n)||n1(n))return n;throw new y3("Can't convert object to primitive value")}return e===void 0&&(e="number"),g3(t,e)},w3=Kv,_3=pu,Ef=function(t){var e=w3(t,"string");return _3(e)?e:e+""},k3=ur,i1=Mr,Yv=k3.document,S3=i1(Yv)&&i1(Yv.createElement),If=function(t){return S3?Yv.createElement(t):{}},$3=xr,T3=qt,C3=If,a1=!$3&&!T3(function(){return Object.defineProperty(C3("div"),"a",{get:function(){return 7}}).a!==7}),E3=xr,I3=$r,x3=mc,R3=uo,A3=Vn,O3=Ef,P3=Hr,M3=a1,s1=Object.getOwnPropertyDescriptor;ma.f=E3?s1:function(e,r){if(e=A3(e),r=O3(r),M3)try{return s1(e,r)}catch{}if(P3(e,r))return R3(!I3(x3.f,e,r),e[r])};var $n={},N3=xr,L3=qt,o1=N3&&L3(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42}),D3=Mr,j3=String,U3=TypeError,Wr=function(t){if(D3(t))return t;throw new U3(j3(t)+" is not an object")},F3=xr,B3=a1,z3=o1,xf=Wr,u1=Ef,H3=TypeError,Jv=Object.defineProperty,q3=Object.getOwnPropertyDescriptor,Qv="enumerable",Xv="configurable",eg="writable";$n.f=F3?z3?function(e,r,n){if(xf(e),r=u1(r),xf(n),typeof e=="function"&&r==="prototype"&&"value"in n&&eg in n&&!n[eg]){var i=q3(e,r);i&&i[eg]&&(e[r]=n.value,n={configurable:Xv in n?n[Xv]:i[Xv],enumerable:Qv in n?n[Qv]:i[Qv],writable:!1})}return Jv(e,r,n)}:Jv:function(e,r,n){if(xf(e),r=u1(r),xf(n),B3)try{return Jv(e,r,n)}catch{}if("get"in n||"set"in n)throw new H3("Accessors not supported");return"value"in n&&(e[r]=n.value),e};var V3=xr,W3=$n,Z3=uo,ba=V3?function(t,e,r){return W3.f(t,e,Z3(1,r))}:function(t,e,r){return t[e]=r,t},l1={exports:{}},tg=xr,G3=Hr,c1=Function.prototype,K3=tg&&Object.getOwnPropertyDescriptor,rg=G3(c1,"name"),Y3=rg&&(function(){}).name==="something",J3=rg&&(!tg||tg&&K3(c1,"name").configurable),wc={EXISTS:rg,PROPER:Y3,CONFIGURABLE:J3},Q3=Gt,X3=Tr,ng=Zv,eL=Q3(Function.toString);X3(ng.inspectSource)||(ng.inspectSource=function(t){return eL(t)});var ig=ng.inspectSource,tL=ur,rL=Tr,d1=tL.WeakMap,nL=rL(d1)&&/native code/.test(String(d1)),iL=vu,aL=bc,f1=iL("keys"),Rf=function(t){return f1[t]||(f1[t]=aL(t))},_c={},sL=nL,h1=ur,oL=Mr,uL=ba,ag=Hr,sg=Zv,lL=Rf,cL=_c,p1="Object already initialized",og=h1.TypeError,dL=h1.WeakMap,Af,kc,Of,fL=function(t){return Of(t)?kc(t):Af(t,{})},hL=function(t){return function(e){var r;if(!oL(e)||(r=kc(e)).type!==t)throw new og("Incompatible receiver, "+t+" required");return r}};if(sL||sg.state){var Vi=sg.state||(sg.state=new dL);Vi.get=Vi.get,Vi.has=Vi.has,Vi.set=Vi.set,Af=function(t,e){if(Vi.has(t))throw new og(p1);return e.facade=t,Vi.set(t,e),e},kc=function(t){return Vi.get(t)||{}},Of=function(t){return Vi.has(t)}}else{var mu=lL("state");cL[mu]=!0,Af=function(t,e){if(ag(t,mu))throw new og(p1);return e.facade=t,uL(t,mu,e),e},kc=function(t){return ag(t,mu)?t[mu]:{}},Of=function(t){return ag(t,mu)}}var Wn={set:Af,get:kc,has:Of,enforce:fL,getterFor:hL},ug=Gt,pL=qt,vL=Tr,Pf=Hr,lg=xr,gL=wc.CONFIGURABLE,mL=ig,v1=Wn,yL=v1.enforce,bL=v1.get,g1=String,Mf=Object.defineProperty,wL=ug("".slice),_L=ug("".replace),kL=ug([].join),SL=lg&&!pL(function(){return Mf(function(){},"length",{value:8}).length!==8}),$L=String(String).split("String"),TL=l1.exports=function(t,e,r){wL(g1(e),0,7)==="Symbol("&&(e="["+_L(g1(e),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),r&&r.getter&&(e="get "+e),r&&r.setter&&(e="set "+e),(!Pf(t,"name")||gL&&t.name!==e)&&(lg?Mf(t,"name",{value:e,configurable:!0}):t.name=e),SL&&r&&Pf(r,"arity")&&t.length!==r.arity&&Mf(t,"length",{value:r.arity});try{r&&Pf(r,"constructor")&&r.constructor?lg&&Mf(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch{}var n=yL(t);return Pf(n,"source")||(n.source=kL($L,typeof e=="string"?e:"")),t};Function.prototype.toString=TL(function(){return vL(this)&&bL(this).source||mL(this)},"toString");var m1=l1.exports,CL=Tr,EL=$n,IL=m1,xL=Wv,Tn=function(t,e,r,n){n||(n={});var i=n.enumerable,a=n.name!==void 0?n.name:e;if(CL(r)&&IL(r,a,n),n.global)i?t[e]=r:xL(e,r);else{try{n.unsafe?t[e]&&(i=!0):delete t[e]}catch{}i?t[e]=r:EL.f(t,e,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return t},ho={},RL=Math.ceil,AL=Math.floor,OL=Math.trunc||function(e){var r=+e;return(r>0?AL:RL)(r)},PL=OL,Wi=function(t){var e=+t;return e!==e||e===0?0:PL(e)},ML=Wi,NL=Math.max,LL=Math.min,yu=function(t,e){var r=ML(t);return r<0?NL(r+e,0):LL(r,e)},DL=Wi,jL=Math.min,wa=function(t){var e=DL(t);return e>0?jL(e,9007199254740991):0},UL=wa,gn=function(t){return UL(t.length)},FL=Vn,BL=yu,zL=gn,y1=function(t){return function(e,r,n){var i=FL(e),a=zL(i);if(a===0)return!t&&-1;var s=BL(n,a),o;if(t&&r!==r){for(;a>s;)if(o=i[s++],o!==o)return!0}else for(;a>s;s++)if((t||s in i)&&i[s]===r)return t||s||0;return!t&&-1}},Nf={includes:y1(!0),indexOf:y1(!1)},HL=Gt,cg=Hr,qL=Vn,VL=Nf.indexOf,WL=_c,b1=HL([].push),w1=function(t,e){var r=qL(t),n=0,i=[],a;for(a in r)!cg(WL,a)&&cg(r,a)&&b1(i,a);for(;e.length>n;)cg(r,a=e[n++])&&(~VL(i,a)||b1(i,a));return i},dg=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],ZL=w1,GL=dg,KL=GL.concat("length","prototype");ho.f=Object.getOwnPropertyNames||function(e){return ZL(e,KL)};var Sc={};Sc.f=Object.getOwnPropertySymbols;var YL=$i,JL=Gt,QL=ho,XL=Sc,eD=Wr,tD=JL([].concat),_1=YL("Reflect","ownKeys")||function(e){var r=QL.f(eD(e)),n=XL.f;return n?tD(r,n(e)):r},k1=Hr,rD=_1,nD=ma,iD=$n,fg=function(t,e,r){for(var n=rD(e),i=iD.f,a=nD.f,s=0;s<n.length;s++){var o=n[s];!k1(t,o)&&!(r&&k1(r,o))&&i(t,o,a(e,o))}},aD=qt,sD=Tr,oD=/#|\.prototype\./,$c=function(t,e){var r=lD[uD(t)];return r===dD?!0:r===cD?!1:sD(e)?aD(e):!!e},uD=$c.normalize=function(t){return String(t).replace(oD,".").toLowerCase()},lD=$c.data={},cD=$c.NATIVE="N",dD=$c.POLYFILL="P",Lf=$c,Df=ur,fD=ma.f,hD=ba,pD=Tn,vD=Wv,gD=fg,mD=Lf,Xt=function(t,e){var r=t.target,n=t.global,i=t.stat,a,s,o,u,l,c;if(n?s=Df:i?s=Df[r]||vD(r,{}):s=Df[r]&&Df[r].prototype,s)for(o in e){if(l=e[o],t.dontCallGetSet?(c=fD(s,o),u=c&&c.value):u=s[o],a=mD(n?o:r+(i?".":"#")+o,t.forced),!a&&u!==void 0){if(typeof l==typeof u)continue;gD(l,u)}(t.sham||u&&u.sham)&&hD(l,"sham",!0),pD(s,o,l,t)}},yD=$n.f,bD=Hr,wD=Cr,S1=wD("toStringTag"),Zi=function(t,e,r){t&&!r&&(t=t.prototype),t&&!bD(t,S1)&&yD(t,S1,{configurable:!0,value:e})},_D=Xt,kD=ur,SD=Zi;_D({global:!0},{Reflect:{}}),SD(kD.Reflect,"Reflect",!0);var $D=gc,$1=Function.prototype,T1=$1.apply,C1=$1.call,po=typeof Reflect=="object"&&Reflect.apply||($D?C1.bind(T1):function(){return C1.apply(T1,arguments)}),TD=Gt,Gi=TD([].slice),E1=Gt,CD=ti,ED=Mr,ID=Hr,I1=Gi,xD=gc,x1=Function,RD=E1([].concat),AD=E1([].join),hg={},OD=function(t,e,r){if(!ID(hg,e)){for(var n=[],i=0;i<e;i++)n[i]="a["+i+"]";hg[e]=x1("C,a","return new C("+AD(n,",")+")")}return hg[e](t,r)},PD=xD?x1.bind:function(e){var r=CD(this),n=r.prototype,i=I1(arguments,1),a=function(){var o=RD(i,I1(arguments));return this instanceof a?OD(r,o.length,o):r.apply(e,o)};return ED(n)&&(a.prototype=n),a},MD=Cr,ND=MD("toStringTag"),R1={};R1[ND]="z";var pg=String(R1)==="[object z]",LD=pg,DD=Tr,jf=qi,jD=Cr,UD=jD("toStringTag"),FD=Object,BD=jf(function(){return arguments}())==="Arguments",zD=function(t,e){try{return t[e]}catch{}},_a=LD?jf:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=zD(e=FD(t),UD))=="string"?r:BD?jf(e):(n=jf(e))==="Object"&&DD(e.callee)?"Arguments":n},HD=Gt,qD=qt,A1=Tr,VD=_a,WD=$i,ZD=ig,O1=function(){},P1=WD("Reflect","construct"),vg=/^\s*(?:class|function)\b/,GD=HD(vg.exec),KD=!vg.test(O1),Tc=function(e){if(!A1(e))return!1;try{return P1(O1,[],e),!0}catch{return!1}},M1=function(e){if(!A1(e))return!1;switch(VD(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return KD||!!GD(vg,ZD(e))}catch{return!0}};M1.sham=!0;var Uf=!P1||qD(function(){var t;return Tc(Tc.call)||!Tc(Object)||!Tc(function(){t=!0})||t})?M1:Tc,YD=Uf,JD=co,QD=TypeError,gg=function(t){if(YD(t))return t;throw new QD(JD(t)+" is not a constructor")},mg={},XD=w1,ej=dg,Cc=Object.keys||function(e){return XD(e,ej)},tj=xr,rj=o1,nj=$n,ij=Wr,aj=Vn,sj=Cc;mg.f=tj&&!rj?Object.defineProperties:function(e,r){ij(e);for(var n=aj(r),i=sj(r),a=i.length,s=0,o;a>s;)nj.f(e,o=i[s++],n[o]);return e};var oj=$i,N1=oj("document","documentElement"),uj=Wr,lj=mg,L1=dg,cj=_c,dj=N1,fj=If,hj=Rf,D1=">",j1="<",yg="prototype",bg="script",U1=hj("IE_PROTO"),wg=function(){},F1=function(t){return j1+bg+D1+t+j1+"/"+bg+D1},B1=function(t){t.write(F1("")),t.close();var e=t.parentWindow.Object;return t=null,e},pj=function(){var t=fj("iframe"),e="java"+bg+":",r;return t.style.display="none",dj.appendChild(t),t.src=String(e),r=t.contentWindow.document,r.open(),r.write(F1("document.F=Object")),r.close(),r.F},Ff,Bf=function(){try{Ff=new ActiveXObject("htmlfile")}catch{}Bf=typeof document<"u"?document.domain&&Ff?B1(Ff):pj():B1(Ff);for(var t=L1.length;t--;)delete Bf[yg][L1[t]];return Bf()};cj[U1]=!0;var os=Object.create||function(e,r){var n;return e!==null?(wg[yg]=uj(e),n=new wg,wg[yg]=null,n[U1]=e):n=Bf(),r===void 0?n:lj.f(n,r)},vj=Xt,gj=$i,_g=po,mj=PD,z1=gg,yj=Wr,H1=Mr,bj=os,q1=qt,kg=gj("Reflect","construct"),wj=Object.prototype,_j=[].push,V1=q1(function(){function t(){}return!(kg(function(){},[],t)instanceof t)}),W1=!q1(function(){kg(function(){})}),Z1=V1||W1;vj({target:"Reflect",stat:!0,forced:Z1,sham:Z1},{construct:function(e,r){z1(e),yj(r);var n=arguments.length<3?e:z1(arguments[2]);if(W1&&!V1)return kg(e,r,n);if(e===n){switch(r.length){case 0:return new e;case 1:return new e(r[0]);case 2:return new e(r[0],r[1]);case 3:return new e(r[0],r[1],r[2]);case 4:return new e(r[0],r[1],r[2],r[3])}var i=[null];return _g(_j,i,r),new(_g(mj,e,i))}var a=n.prototype,s=bj(H1(a)?a:wj),o=_g(e,s,r);return H1(o)?o:s}});var kj=Xt,Sj=vn,G1=Cc,$j=qt,Tj=$j(function(){G1(1)});kj({target:"Object",stat:!0,forced:Tj},{keys:function(e){return G1(Sj(e))}});var Cj=_a,Ej=String,Xr=function(t){if(Cj(t)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return Ej(t)},Sg={},Ij=qi,xj=Vn,K1=ho.f,Rj=Gi,Y1=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Aj=function(t){try{return K1(t)}catch{return Rj(Y1)}};Sg.f=function(e){return Y1&&Ij(e)==="Window"?Aj(e):K1(xj(e))};var J1=m1,Oj=$n,Ki=function(t,e,r){return r.get&&J1(r.get,e,{getter:!0}),r.set&&J1(r.set,e,{setter:!0}),Oj.f(t,e,r)},$g={},Pj=Cr;$g.f=Pj;var Mj=ur,Q1=Mj,X1=Q1,Nj=Hr,Lj=$g,Dj=$n.f,ek=function(t){var e=X1.Symbol||(X1.Symbol={});Nj(e,t)||Dj(e,t,{value:Lj.f(t)})},jj=$r,Uj=$i,Fj=Cr,Bj=Tn,zj=function(){var t=Uj("Symbol"),e=t&&t.prototype,r=e&&e.valueOf,n=Fj("toPrimitive");e&&!e[n]&&Bj(e,n,function(i){return jj(r,this)},{arity:1})},Hj=qi,qj=Gt,Tg=function(t){if(Hj(t)==="Function")return qj(t)},tk=Tg,Vj=ti,Wj=gc,Zj=tk(tk.bind),ka=function(t,e){return Vj(t),e===void 0?t:Wj?Zj(t,e):function(){return t.apply(e,arguments)}},Gj=qi,Ec=Array.isArray||function(e){return Gj(e)==="Array"},rk=Ec,Kj=Uf,Yj=Mr,Jj=Cr,Qj=Jj("species"),nk=Array,Xj=function(t){var e;return rk(t)&&(e=t.constructor,Kj(e)&&(e===nk||rk(e.prototype))?e=void 0:Yj(e)&&(e=e[Qj],e===null&&(e=void 0))),e===void 0?nk:e},eU=Xj,Cg=function(t,e){return new(eU(t))(e===0?0:e)},tU=ka,rU=Gt,nU=yc,iU=vn,aU=gn,sU=Cg,ik=rU([].push),us=function(t){var e=t===1,r=t===2,n=t===3,i=t===4,a=t===6,s=t===7,o=t===5||a;return function(u,l,c,d){for(var f=iU(u),m=nU(f),k=aU(m),L=tU(l,c),N=0,z=d||sU,re=e?z(u,k):r||s?z(u,0):void 0,Me,Oe;k>N;N++)if((o||N in m)&&(Me=m[N],Oe=L(Me,N,f),t))if(e)re[N]=Oe;else if(Oe)switch(t){case 3:return!0;case 5:return Me;case 6:return N;case 2:ik(re,Me)}else switch(t){case 4:return!1;case 7:ik(re,Me)}return a?-1:n||i?i:re}},Nn={forEach:us(0),map:us(1),filter:us(2),some:us(3),every:us(4),find:us(5),findIndex:us(6),filterReject:us(7)},zf=Xt,Ic=ur,Eg=$r,oU=Gt,bu=xr,wu=hu,uU=qt,ln=Hr,lU=ya,Ig=Wr,Hf=Vn,xg=Ef,cU=Xr,Rg=uo,_u=os,ak=Cc,dU=ho,sk=Sg,fU=Sc,ok=ma,uk=$n,hU=mg,lk=mc,Ag=Tn,pU=Ki,Og=vu,vU=Rf,ck=_c,dk=bc,gU=Cr,mU=$g,yU=ek,bU=zj,wU=Zi,fk=Wn,qf=Nn.forEach,Ln=vU("hidden"),Vf="Symbol",xc="prototype",_U=fk.set,hk=fk.getterFor(Vf),ri=Object[xc],vo=Ic.Symbol,Rc=vo&&vo[xc],kU=Ic.RangeError,SU=Ic.TypeError,Pg=Ic.QObject,pk=ok.f,go=uk.f,vk=sk.f,$U=lk.f,gk=oU([].push),Sa=Og("symbols"),Ac=Og("op-symbols"),TU=Og("wks"),Mg=!Pg||!Pg[xc]||!Pg[xc].findChild,mk=function(t,e,r){var n=pk(ri,e);n&&delete ri[e],go(t,e,r),n&&t!==ri&&go(ri,e,n)},Ng=bu&&uU(function(){return _u(go({},"a",{get:function(){return go(this,"a",{value:7}).a}})).a!==7})?mk:go,Lg=function(t,e){var r=Sa[t]=_u(Rc);return _U(r,{type:Vf,tag:t,description:e}),bu||(r.description=e),r},Wf=function(e,r,n){e===ri&&Wf(Ac,r,n),Ig(e);var i=xg(r);return Ig(n),ln(Sa,i)?(n.enumerable?(ln(e,Ln)&&e[Ln][i]&&(e[Ln][i]=!1),n=_u(n,{enumerable:Rg(0,!1)})):(ln(e,Ln)||go(e,Ln,Rg(1,_u(null))),e[Ln][i]=!0),Ng(e,i,n)):go(e,i,n)},Dg=function(e,r){Ig(e);var n=Hf(r),i=ak(n).concat(wk(n));return qf(i,function(a){(!bu||Eg(jg,n,a))&&Wf(e,a,n[a])}),e},CU=function(e,r){return r===void 0?_u(e):Dg(_u(e),r)},jg=function(e){var r=xg(e),n=Eg($U,this,r);return this===ri&&ln(Sa,r)&&!ln(Ac,r)?!1:n||!ln(this,r)||!ln(Sa,r)||ln(this,Ln)&&this[Ln][r]?n:!0},yk=function(e,r){var n=Hf(e),i=xg(r);if(!(n===ri&&ln(Sa,i)&&!ln(Ac,i))){var a=pk(n,i);return a&&ln(Sa,i)&&!(ln(n,Ln)&&n[Ln][i])&&(a.enumerable=!0),a}},bk=function(e){var r=vk(Hf(e)),n=[];return qf(r,function(i){!ln(Sa,i)&&!ln(ck,i)&&gk(n,i)}),n},wk=function(t){var e=t===ri,r=vk(e?Ac:Hf(t)),n=[];return qf(r,function(i){ln(Sa,i)&&(!e||ln(ri,i))&&gk(n,Sa[i])}),n};wu||(vo=function(){if(lU(Rc,this))throw new SU("Symbol is not a constructor");var e=!arguments.length||arguments[0]===void 0?void 0:cU(arguments[0]),r=dk(e),n=function(i){var a=this===void 0?Ic:this;a===ri&&Eg(n,Ac,i),ln(a,Ln)&&ln(a[Ln],r)&&(a[Ln][r]=!1);var s=Rg(1,i);try{Ng(a,r,s)}catch(o){if(!(o instanceof kU))throw o;mk(a,r,s)}};return bu&&Mg&&Ng(ri,r,{configurable:!0,set:n}),Lg(r,e)},Rc=vo[xc],Ag(Rc,"toString",function(){return hk(this).tag}),Ag(vo,"withoutSetter",function(t){return Lg(dk(t),t)}),lk.f=jg,uk.f=Wf,hU.f=Dg,ok.f=yk,dU.f=sk.f=bk,fU.f=wk,mU.f=function(t){return Lg(gU(t),t)},bu&&(pU(Rc,"description",{configurable:!0,get:function(){return hk(this).description}}),Ag(ri,"propertyIsEnumerable",jg,{unsafe:!0}))),zf({global:!0,constructor:!0,wrap:!0,forced:!wu,sham:!wu},{Symbol:vo}),qf(ak(TU),function(t){yU(t)}),zf({target:Vf,stat:!0,forced:!wu},{useSetter:function(){Mg=!0},useSimple:function(){Mg=!1}}),zf({target:"Object",stat:!0,forced:!wu,sham:!bu},{create:CU,defineProperty:Wf,defineProperties:Dg,getOwnPropertyDescriptor:yk}),zf({target:"Object",stat:!0,forced:!wu},{getOwnPropertyNames:bk}),bU(),wU(vo,Vf),ck[Ln]=!0;var EU=hu,_k=EU&&!!Symbol.for&&!!Symbol.keyFor,IU=Xt,xU=$i,RU=Hr,AU=Xr,kk=vu,OU=_k,Ug=kk("string-to-symbol-registry"),PU=kk("symbol-to-string-registry");IU({target:"Symbol",stat:!0,forced:!OU},{for:function(t){var e=AU(t);if(RU(Ug,e))return Ug[e];var r=xU("Symbol")(e);return Ug[e]=r,PU[r]=e,r}});var MU=Xt,NU=Hr,LU=pu,DU=co,jU=vu,UU=_k,Sk=jU("symbol-to-string-registry");MU({target:"Symbol",stat:!0,forced:!UU},{keyFor:function(e){if(!LU(e))throw new TypeError(DU(e)+" is not a symbol");if(NU(Sk,e))return Sk[e]}});var FU=Gt,$k=Ec,BU=Tr,Tk=qi,zU=Xr,Ck=FU([].push),HU=function(t){if(BU(t))return t;if($k(t)){for(var e=t.length,r=[],n=0;n<e;n++){var i=t[n];typeof i=="string"?Ck(r,i):(typeof i=="number"||Tk(i)==="Number"||Tk(i)==="String")&&Ck(r,zU(i))}var a=r.length,s=!0;return function(o,u){if(s)return s=!1,u;if($k(this))return u;for(var l=0;l<a;l++)if(r[l]===o)return u}}},qU=Xt,Ek=$i,Ik=po,VU=$r,Oc=Gt,xk=qt,Rk=Tr,Ak=pu,Ok=Gi,WU=HU,ZU=hu,GU=String,ls=Ek("JSON","stringify"),Zf=Oc(/./.exec),Pk=Oc("".charAt),KU=Oc("".charCodeAt),YU=Oc("".replace),JU=Oc(1 .toString),QU=/[\uD800-\uDFFF]/g,Mk=/^[\uD800-\uDBFF]$/,Nk=/^[\uDC00-\uDFFF]$/,Lk=!ZU||xk(function(){var t=Ek("Symbol")("stringify detection");return ls([t])!=="[null]"||ls({a:t})!=="{}"||ls(Object(t))!=="{}"}),Dk=xk(function(){return ls("\uDF06\uD834")!=='"\\udf06\\ud834"'||ls("\uDEAD")!=='"\\udead"'}),XU=function(t,e){var r=Ok(arguments),n=WU(e);if(!(!Rk(n)&&(t===void 0||Ak(t))))return r[1]=function(i,a){if(Rk(n)&&(a=VU(n,this,GU(i),a)),!Ak(a))return a},Ik(ls,null,r)},e6=function(t,e,r){var n=Pk(r,e-1),i=Pk(r,e+1);return Zf(Mk,t)&&!Zf(Nk,i)||Zf(Nk,t)&&!Zf(Mk,n)?"\\u"+JU(KU(t,0),16):t};ls&&qU({target:"JSON",stat:!0,arity:3,forced:Lk||Dk},{stringify:function(e,r,n){var i=Ok(arguments),a=Ik(Lk?XU:ls,null,i);return Dk&&typeof a=="string"?YU(a,QU,e6):a}});var t6=Xt,r6=hu,n6=qt,jk=Sc,i6=vn,a6=!r6||n6(function(){jk.f(1)});t6({target:"Object",stat:!0,forced:a6},{getOwnPropertySymbols:function(e){var r=jk.f;return r?r(i6(e)):[]}});var s6=qt,o6=Cr,u6=fu,l6=o6("species"),Pc=function(t){return u6>=51||!s6(function(){var e=[],r=e.constructor={};return r[l6]=function(){return{foo:1}},e[t](Boolean).foo!==1})},c6=Xt,d6=Nn.filter,f6=Pc,h6=f6("filter");c6({target:"Array",proto:!0,forced:!h6},{filter:function(e){return d6(this,e,arguments.length>1?arguments[1]:void 0)}});var p6=Xt,v6=qt,g6=Vn,Uk=ma.f,Fk=xr,m6=!Fk||v6(function(){Uk(1)});p6({target:"Object",stat:!0,forced:m6,sham:!Fk},{getOwnPropertyDescriptor:function(e,r){return Uk(g6(e),r)}});var y6=xr,b6=$n,w6=uo,Mc=function(t,e,r){y6?b6.f(t,e,w6(0,r)):t[e]=r},_6=Xt,k6=xr,S6=_1,$6=Vn,T6=ma,C6=Mc;_6({target:"Object",stat:!0,sham:!k6},{getOwnPropertyDescriptors:function(e){for(var r=$6(e),n=T6.f,i=S6(r),a={},s=0,o,u;i.length>s;)u=n(r,o=i[s++]),u!==void 0&&C6(a,o,u);return a}});var Bk={exports:{}};(function(t){function e(n,i,a,s,o,u,l){try{var c=n[u](l),d=c.value}catch(f){return void a(f)}c.done?i(d):Promise.resolve(d).then(s,o)}function r(n){return function(){var i=this,a=arguments;return new Promise(function(s,o){var u=n.apply(i,a);function l(d){e(u,s,o,l,c,"next",d)}function c(d){e(u,s,o,l,c,"throw",d)}l(void 0)})}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(Bk);var ku=Bk.exports,zk={exports:{}};(function(t){function e(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(zk);var cs=zk.exports,Hk={exports:{}},qk={exports:{}};(function(t){function e(r,n){return t.exports=e=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,a){return i.__proto__=a,i},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(qk);var Fg=qk.exports;(function(t){var e=Fg;function r(n,i){if(typeof i!="function"&&i!==null)throw new TypeError("Super expression must either be null or a function");n.prototype=Object.create(i&&i.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),Object.defineProperty(n,"prototype",{writable:!1}),i&&e(n,i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(Hk);var Yi=Hk.exports,Vk={exports:{}},Wk={exports:{}};(function(t){function e(r){"@babel/helpers - typeof";return t.exports=e=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(Wk);var ni=Wk.exports;(function(t){var e=ni.default,r=cs;function n(i,a){if(a&&(e(a)=="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(Vk);var Ji=Vk.exports,Zk={exports:{}};(function(t){function e(r){return t.exports=e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(Zk);var ii=Zk.exports,Gk={exports:{}},Kk={exports:{}},Yk={exports:{}};(function(t){var e=ni.default;function r(n,i){if(e(n)!="object"||!n)return n;var a=n[Symbol.toPrimitive];if(a!==void 0){var s=a.call(n,i||"default");if(e(s)!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(n)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(Yk);var E6=Yk.exports;(function(t){var e=ni.default,r=E6;function n(i){var a=r(i,"string");return e(a)=="symbol"?a:a+""}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(Kk);var Jk=Kk.exports;(function(t){var e=Jk;function r(n,i,a){return(i=e(i))in n?Object.defineProperty(n,i,{value:a,enumerable:!0,configurable:!0,writable:!0}):n[i]=a,n}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(Gk);var ds=Gk.exports,Qk={exports:{}};(function(t){var e=Jk;function r(i,a){for(var s=0;s<a.length;s++){var o=a[s];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(i,e(o.key),o)}}function n(i,a,s){return a&&r(i.prototype,a),s&&r(i,s),Object.defineProperty(i,"prototype",{writable:!1}),i}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(Qk);var $a=Qk.exports,Xk={exports:{}};(function(t){function e(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(Xk);var Qi=Xk.exports,I6=Xt,x6=Nn.map,R6=Pc,A6=R6("map");I6({target:"Array",proto:!0,forced:!A6},{map:function(e){return x6(this,e,arguments.length>1?arguments[1]:void 0)}});var O6=pg,P6=_a,M6=O6?{}.toString:function(){return"[object "+P6(this)+"]"},N6=pg,L6=Tn,D6=M6;N6||L6(Object.prototype,"toString",D6,{unsafe:!0});var eS={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},j6=If,Bg=j6("span").classList,tS=Bg&&Bg.constructor&&Bg.constructor.prototype,rS=tS===Object.prototype?void 0:tS,U6=qt,Gf=function(t,e){var r=[][t];return!!r&&U6(function(){r.call(null,e||function(){return 1},1)})},F6=Nn.forEach,B6=Gf,z6=B6("forEach"),H6=z6?[].forEach:function(e){return F6(this,e,arguments.length>1?arguments[1]:void 0)},nS=ur,iS=eS,q6=rS,zg=H6,V6=ba,aS=function(t){if(t&&t.forEach!==zg)try{V6(t,"forEach",zg)}catch{t.forEach=zg}};for(var Hg in iS)iS[Hg]&&aS(nS[Hg]&&nS[Hg].prototype);aS(q6);var W6=ur,Z6=qi,Kf=Z6(W6.process)==="process",G6=Gt,K6=ti,Y6=function(t,e,r){try{return G6(K6(Object.getOwnPropertyDescriptor(t,e)[r]))}catch{}},J6=Mr,Q6=function(t){return J6(t)||t===null},X6=Q6,e5=String,t5=TypeError,r5=function(t){if(X6(t))return t;throw new t5("Can't set "+e5(t)+" as a prototype")},n5=Y6,i5=Mr,a5=Si,s5=r5,Su=Object.setPrototypeOf||("__proto__"in{}?function(){var t=!1,e={},r;try{r=n5(Object.prototype,"__proto__","set"),r(e,[]),t=e instanceof Array}catch{}return function(i,a){return a5(i),s5(a),i5(i)&&(t?r(i,a):i.__proto__=a),i}}():void 0),o5=$i,u5=Ki,l5=Cr,c5=xr,sS=l5("species"),Yf=function(t){var e=o5(t);c5&&e&&!e[sS]&&u5(e,sS,{configurable:!0,get:function(){return this}})},d5=ya,f5=TypeError,fs=function(t,e){if(d5(e,t))return t;throw new f5("Incorrect invocation")},oS=Wr,h5=gg,p5=ki,v5=Cr,g5=v5("species"),qg=function(t,e){var r=oS(t).constructor,n;return r===void 0||p5(n=oS(r)[g5])?e:h5(n)},m5=TypeError,Vg=function(t,e){if(t<e)throw new m5("Not enough arguments");return t},y5=lo,uS=/(?:ipad|iphone|ipod).*applewebkit/i.test(y5),Zn=ur,b5=po,w5=ka,lS=Tr,_5=Hr,cS=qt,dS=N1,k5=Gi,fS=If,S5=Vg,$5=uS,T5=Kf,Wg=Zn.setImmediate,Zg=Zn.clearImmediate,C5=Zn.process,Gg=Zn.Dispatch,E5=Zn.Function,hS=Zn.MessageChannel,I5=Zn.String,Kg=0,Nc={},pS="onreadystatechange",Lc,mo,Yg,Jg;cS(function(){Lc=Zn.location});var Qg=function(t){if(_5(Nc,t)){var e=Nc[t];delete Nc[t],e()}},Xg=function(t){return function(){Qg(t)}},vS=function(t){Qg(t.data)},gS=function(t){Zn.postMessage(I5(t),Lc.protocol+"//"+Lc.host)};(!Wg||!Zg)&&(Wg=function(e){S5(arguments.length,1);var r=lS(e)?e:E5(e),n=k5(arguments,1);return Nc[++Kg]=function(){b5(r,void 0,n)},mo(Kg),Kg},Zg=function(e){delete Nc[e]},T5?mo=function(t){C5.nextTick(Xg(t))}:Gg&&Gg.now?mo=function(t){Gg.now(Xg(t))}:hS&&!$5?(Yg=new hS,Jg=Yg.port2,Yg.port1.onmessage=vS,mo=w5(Jg.postMessage,Jg)):Zn.addEventListener&&lS(Zn.postMessage)&&!Zn.importScripts&&Lc&&Lc.protocol!=="file:"&&!cS(gS)?(mo=gS,Zn.addEventListener("message",vS,!1)):pS in fS("script")?mo=function(t){dS.appendChild(fS("script"))[pS]=function(){dS.removeChild(this),Qg(t)}}:mo=function(t){setTimeout(Xg(t),0)});var mS={set:Wg,clear:Zg},yS=ur,x5=xr,R5=Object.getOwnPropertyDescriptor,bS=function(t){if(!x5)return yS[t];var e=R5(yS,t);return e&&e.value},wS=function(){this.head=null,this.tail=null};wS.prototype={add:function(t){var e={item:t,next:null},r=this.tail;r?r.next=e:this.head=e,this.tail=e},get:function(){var t=this.head;if(t){var e=this.head=t.next;return e===null&&(this.tail=null),t.item}}};var _S=wS,A5=lo,O5=/ipad|iphone|ipod/i.test(A5)&&typeof Pebble<"u",P5=lo,M5=/web0s(?!.*chrome)/i.test(P5),$u=ur,N5=bS,kS=ka,em=mS.set,L5=_S,D5=uS,j5=O5,U5=M5,tm=Kf,SS=$u.MutationObserver||$u.WebKitMutationObserver,$S=$u.document,TS=$u.process,Jf=$u.Promise,rm=N5("queueMicrotask"),Tu,nm,im,Qf,CS;if(!rm){var Xf=new L5,eh=function(){var t,e;for(tm&&(t=TS.domain)&&t.exit();e=Xf.get();)try{e()}catch(r){throw Xf.head&&Tu(),r}t&&t.enter()};!D5&&!tm&&!U5&&SS&&$S?(nm=!0,im=$S.createTextNode(""),new SS(eh).observe(im,{characterData:!0}),Tu=function(){im.data=nm=!nm}):!j5&&Jf&&Jf.resolve?(Qf=Jf.resolve(void 0),Qf.constructor=Jf,CS=kS(Qf.then,Qf),Tu=function(){CS(eh)}):tm?Tu=function(){TS.nextTick(eh)}:(em=kS(em,$u),Tu=function(){em(eh)}),rm=function(t){Xf.head||Tu(),Xf.add(t)}}var F5=rm,B5=function(t,e){try{arguments.length===1?console.error(t):console.error(t,e)}catch{}},am=function(t){try{return{error:!1,value:t()}}catch(e){return{error:!0,value:e}}},z5=ur,th=z5.Promise,ES=typeof Deno=="object"&&Deno&&typeof Deno.version=="object",H5=ES,q5=Kf,V5=!H5&&!q5&&typeof window=="object"&&typeof document=="object",W5=ur,Dc=th,Z5=Tr,G5=Lf,K5=ig,Y5=Cr,J5=V5,Q5=ES,sm=fu;Dc&&Dc.prototype;var X5=Y5("species"),om=!1,IS=Z5(W5.PromiseRejectionEvent),eF=G5("Promise",function(){var t=K5(Dc),e=t!==String(Dc);if(!e&&sm===66)return!0;if(!sm||sm<51||!/native code/.test(t)){var r=new Dc(function(a){a(1)}),n=function(a){a(function(){},function(){})},i=r.constructor={};if(i[X5]=n,om=r.then(function(){})instanceof n,!om)return!0}return!e&&(J5||Q5)&&!IS}),jc={CONSTRUCTOR:eF,REJECTION_EVENT:IS,SUBCLASSING:om},Cu={},xS=ti,tF=TypeError,rF=function(t){var e,r;this.promise=new t(function(n,i){if(e!==void 0||r!==void 0)throw new tF("Bad Promise constructor");e=n,r=i}),this.resolve=xS(e),this.reject=xS(r)};Cu.f=function(t){return new rF(t)};var nF=Xt,rh=Kf,hs=ur,Eu=$r,RS=Tn,AS=Su,iF=Zi,aF=Yf,sF=ti,nh=Tr,oF=Mr,uF=fs,lF=qg,OS=mS.set,um=F5,cF=B5,dF=am,fF=_S,PS=Wn,ih=th,lm=jc,MS=Cu,ah="Promise",NS=lm.CONSTRUCTOR,hF=lm.REJECTION_EVENT,pF=lm.SUBCLASSING,cm=PS.getterFor(ah),vF=PS.set,Iu=ih&&ih.prototype,yo=ih,sh=Iu,LS=hs.TypeError,dm=hs.document,fm=hs.process,hm=MS.f,gF=hm,mF=!!(dm&&dm.createEvent&&hs.dispatchEvent),DS="unhandledrejection",yF="rejectionhandled",jS=0,US=1,bF=2,pm=1,FS=2,oh,BS,wF,zS,HS=function(t){var e;return oF(t)&&nh(e=t.then)?e:!1},qS=function(t,e){var r=e.value,n=e.state===US,i=n?t.ok:t.fail,a=t.resolve,s=t.reject,o=t.domain,u,l,c;try{i?(n||(e.rejection===FS&&kF(e),e.rejection=pm),i===!0?u=r:(o&&o.enter(),u=i(r),o&&(o.exit(),c=!0)),u===t.promise?s(new LS("Promise-chain cycle")):(l=HS(u))?Eu(l,u,a,s):a(u)):s(r)}catch(d){o&&!c&&o.exit(),s(d)}},VS=function(t,e){t.notified||(t.notified=!0,um(function(){for(var r=t.reactions,n;n=r.get();)qS(n,t);t.notified=!1,e&&!t.rejection&&_F(t)}))},WS=function(t,e,r){var n,i;mF?(n=dm.createEvent("Event"),n.promise=e,n.reason=r,n.initEvent(t,!1,!0),hs.dispatchEvent(n)):n={promise:e,reason:r},!hF&&(i=hs["on"+t])?i(n):t===DS&&cF("Unhandled promise rejection",r)},_F=function(t){Eu(OS,hs,function(){var e=t.facade,r=t.value,n=ZS(t),i;if(n&&(i=dF(function(){rh?fm.emit("unhandledRejection",r,e):WS(DS,e,r)}),t.rejection=rh||ZS(t)?FS:pm,i.error))throw i.value})},ZS=function(t){return t.rejection!==pm&&!t.parent},kF=function(t){Eu(OS,hs,function(){var e=t.facade;rh?fm.emit("rejectionHandled",e):WS(yF,e,t.value)})},xu=function(t,e,r){return function(n){t(e,n,r)}},Ru=function(t,e,r){t.done||(t.done=!0,r&&(t=r),t.value=e,t.state=bF,VS(t,!0))},vm=function(t,e,r){if(!t.done){t.done=!0,r&&(t=r);try{if(t.facade===e)throw new LS("Promise can't be resolved itself");var n=HS(e);n?um(function(){var i={done:!1};try{Eu(n,e,xu(vm,i,t),xu(Ru,i,t))}catch(a){Ru(i,a,t)}}):(t.value=e,t.state=US,VS(t,!1))}catch(i){Ru({done:!1},i,t)}}};if(NS&&(yo=function(e){uF(this,sh),sF(e),Eu(oh,this);var r=cm(this);try{e(xu(vm,r),xu(Ru,r))}catch(n){Ru(r,n)}},sh=yo.prototype,oh=function(e){vF(this,{type:ah,done:!1,notified:!1,parent:!1,reactions:new fF,rejection:!1,state:jS,value:void 0})},oh.prototype=RS(sh,"then",function(e,r){var n=cm(this),i=hm(lF(this,yo));return n.parent=!0,i.ok=nh(e)?e:!0,i.fail=nh(r)&&r,i.domain=rh?fm.domain:void 0,n.state===jS?n.reactions.add(i):um(function(){qS(i,n)}),i.promise}),BS=function(){var t=new oh,e=cm(t);this.promise=t,this.resolve=xu(vm,e),this.reject=xu(Ru,e)},MS.f=hm=function(t){return t===yo||t===wF?new BS(t):gF(t)},nh(ih)&&Iu!==Object.prototype)){zS=Iu.then,pF||RS(Iu,"then",function(e,r){var n=this;return new yo(function(i,a){Eu(zS,n,i,a)}).then(e,r)},{unsafe:!0});try{delete Iu.constructor}catch{}AS&&AS(Iu,sh)}nF({global:!0,constructor:!0,wrap:!0,forced:NS},{Promise:yo}),iF(yo,ah,!1),aF(ah);var Uc={},SF=Cr,$F=Uc,TF=SF("iterator"),CF=Array.prototype,gm=function(t){return t!==void 0&&($F.Array===t||CF[TF]===t)},EF=_a,GS=fo,IF=ki,xF=Uc,RF=Cr,AF=RF("iterator"),Fc=function(t){if(!IF(t))return GS(t,AF)||GS(t,"@@iterator")||xF[EF(t)]},OF=$r,PF=ti,MF=Wr,NF=co,LF=Fc,DF=TypeError,uh=function(t,e){var r=arguments.length<2?LF(t):e;if(PF(r))return MF(OF(r,t));throw new DF(NF(t)+" is not iterable")},jF=$r,KS=Wr,UF=fo,YS=function(t,e,r){var n,i;KS(t);try{if(n=UF(t,"return"),!n){if(e==="throw")throw r;return r}n=jF(n,t)}catch(a){i=!0,n=a}if(e==="throw")throw r;if(i)throw n;return KS(n),r},FF=ka,BF=$r,zF=Wr,HF=co,qF=gm,VF=gn,JS=ya,WF=uh,ZF=Fc,QS=YS,GF=TypeError,lh=function(t,e){this.stopped=t,this.result=e},XS=lh.prototype,Bc=function(t,e,r){var n=r&&r.that,i=!!(r&&r.AS_ENTRIES),a=!!(r&&r.IS_RECORD),s=!!(r&&r.IS_ITERATOR),o=!!(r&&r.INTERRUPTED),u=FF(e,n),l,c,d,f,m,k,L,N=function(re){return l&&QS(l,"normal",re),new lh(!0,re)},z=function(re){return i?(zF(re),o?u(re[0],re[1],N):u(re[0],re[1])):o?u(re,N):u(re)};if(a)l=t.iterator;else if(s)l=t;else{if(c=ZF(t),!c)throw new GF(HF(t)+" is not iterable");if(qF(c)){for(d=0,f=VF(t);f>d;d++)if(m=z(t[d]),m&&JS(XS,m))return m;return new lh(!1)}l=WF(t,c)}for(k=a?t.next:l.next;!(L=BF(k,l)).done;){try{m=z(L.value)}catch(re){QS(l,"throw",re)}if(typeof m=="object"&&m&&JS(XS,m))return m}return new lh(!1)},KF=Cr,e$=KF("iterator"),t$=!1;try{var YF=0,r$={next:function(){return{done:!!YF++}},return:function(){t$=!0}};r$[e$]=function(){return this},Array.from(r$,function(){throw 2})}catch{}var ch=function(t,e){try{if(!e&&!t$)return!1}catch{return!1}var r=!1;try{var n={};n[e$]=function(){return{next:function(){return{done:r=!0}}}},t(n)}catch{}return r},JF=th,QF=ch,XF=jc.CONSTRUCTOR,n$=XF||!QF(function(t){JF.all(t).then(void 0,function(){})}),e8=Xt,t8=$r,r8=ti,n8=Cu,i8=am,a8=Bc,s8=n$;e8({target:"Promise",stat:!0,forced:s8},{all:function(e){var r=this,n=n8.f(r),i=n.resolve,a=n.reject,s=i8(function(){var o=r8(r.resolve),u=[],l=0,c=1;a8(e,function(d){var f=l++,m=!1;c++,t8(o,r,d).then(function(k){m||(m=!0,u[f]=k,--c||i(u))},a)}),--c||i(u)});return s.error&&a(s.value),n.promise}});var o8=Xt,u8=jc.CONSTRUCTOR,mm=th,l8=$i,c8=Tr,d8=Tn,i$=mm&&mm.prototype;if(o8({target:"Promise",proto:!0,forced:u8,real:!0},{catch:function(t){return this.then(void 0,t)}}),c8(mm)){var a$=l8("Promise").prototype.catch;i$.catch!==a$&&d8(i$,"catch",a$,{unsafe:!0})}var f8=Xt,h8=$r,p8=ti,v8=Cu,g8=am,m8=Bc,y8=n$;f8({target:"Promise",stat:!0,forced:y8},{race:function(e){var r=this,n=v8.f(r),i=n.reject,a=g8(function(){var s=p8(r.resolve);m8(e,function(o){h8(s,r,o).then(n.resolve,i)})});return a.error&&i(a.value),n.promise}});var b8=Xt,w8=Cu,_8=jc.CONSTRUCTOR;b8({target:"Promise",stat:!0,forced:_8},{reject:function(e){var r=w8.f(this),n=r.reject;return n(e),r.promise}});var k8=Wr,S8=Mr,$8=Cu,T8=function(t,e){if(k8(t),S8(e)&&e.constructor===t)return e;var r=$8.f(t),n=r.resolve;return n(e),r.promise},C8=Xt,E8=$i,I8=jc.CONSTRUCTOR,x8=T8;E8("Promise"),C8({target:"Promise",stat:!0,forced:I8},{resolve:function(e){return x8(this,e)}});var s$={exports:{}},o$={exports:{}};(function(t){function e(r,n){this.v=r,this.k=n}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(o$);var u$=o$.exports,l$={exports:{}},c$={exports:{}};(function(t){function e(r,n,i,a){var s=Object.defineProperty;try{s({},"",{})}catch{s=0}t.exports=e=function(u,l,c,d){function f(m,k){e(u,m,function(L){return this._invoke(m,k,L)})}l?s?s(u,l,{value:c,enumerable:!d,configurable:!d,writable:!d}):u[l]=c:(f("next",0),f("throw",1),f("return",2))},t.exports.__esModule=!0,t.exports.default=t.exports,e(r,n,i,a)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(c$);var d$=c$.exports;(function(t){var e=d$;function r(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var n,i,a=typeof Symbol=="function"?Symbol:{},s=a.iterator||"@@iterator",o=a.toStringTag||"@@toStringTag";function u(N,z,re,Me){var Oe=z&&z.prototype instanceof c?z:c,Fe=Object.create(Oe.prototype);return e(Fe,"_invoke",function(Pe,Ze,Z){var Ie,_e,se,Te=0,te=Z||[],oe=!1,q={p:0,n:0,v:n,a:ne,f:ne.bind(n,4),d:function(H,ye){return Ie=H,_e=0,se=n,q.n=ye,l}};function ne(Se,H){for(_e=Se,se=H,i=0;!oe&&Te&&!ye&&i<te.length;i++){var ye,ke=te[i],P=q.p,Qe=ke[2];Se>3?(ye=Qe===H)&&(se=ke[(_e=ke[4])?5:(_e=3,3)],ke[4]=ke[5]=n):ke[0]<=P&&((ye=Se<2&&P<ke[1])?(_e=0,q.v=H,q.n=ke[1]):P<Qe&&(ye=Se<3||ke[0]>H||H>Qe)&&(ke[4]=Se,ke[5]=H,q.n=Qe,_e=0))}if(ye||Se>1)return l;throw oe=!0,H}return function(Se,H,ye){if(Te>1)throw TypeError("Generator is already running");for(oe&&H===1&&ne(H,ye),_e=H,se=ye;(i=_e<2?n:se)||!oe;){Ie||(_e?_e<3?(_e>1&&(q.n=-1),ne(_e,se)):q.n=se:q.v=se);try{if(Te=2,Ie){if(_e||(Se="next"),i=Ie[Se]){if(!(i=i.call(Ie,se)))throw TypeError("iterator result is not an object");if(!i.done)return i;se=i.value,_e<2&&(_e=0)}else _e===1&&(i=Ie.return)&&i.call(Ie),_e<2&&(se=TypeError("The iterator does not provide a '"+Se+"' method"),_e=1);Ie=n}else if((i=(oe=q.n<0)?se:Pe.call(Ze,q))!==l)break}catch(ke){Ie=n,_e=1,se=ke}finally{Te=1}}return{value:i,done:oe}}}(N,re,Me),!0),Fe}var l={};function c(){}function d(){}function f(){}i=Object.getPrototypeOf;var m=[][s]?i(i([][s]())):(e(i={},s,function(){return this}),i),k=f.prototype=c.prototype=Object.create(m);function L(N){return Object.setPrototypeOf?Object.setPrototypeOf(N,f):(N.__proto__=f,e(N,o,"GeneratorFunction")),N.prototype=Object.create(k),N}return d.prototype=f,e(k,"constructor",f),e(f,"constructor",d),d.displayName="GeneratorFunction",e(f,o,"GeneratorFunction"),e(k),e(k,o,"Generator"),e(k,s,function(){return this}),e(k,"toString",function(){return"[object Generator]"}),(t.exports=r=function(){return{w:u,m:L}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(l$);var f$=l$.exports,h$={exports:{}},p$={exports:{}},v$={exports:{}};(function(t){var e=u$,r=d$;function n(i,a){function s(u,l,c,d){try{var f=i[u](l),m=f.value;return m instanceof e?a.resolve(m.v).then(function(k){s("next",k,c,d)},function(k){s("throw",k,c,d)}):a.resolve(m).then(function(k){f.value=k,c(f)},function(k){return s("throw",k,c,d)})}catch(k){d(k)}}var o;this.next||(r(n.prototype),r(n.prototype,typeof Symbol=="function"&&Symbol.asyncIterator||"@asyncIterator",function(){return this})),r(this,"_invoke",function(u,l,c){function d(){return new a(function(f,m){s(u,c,f,m)})}return o=o?o.then(d,d):d()},!0)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(v$);var g$=v$.exports;(function(t){var e=f$,r=g$;function n(i,a,s,o,u){return new r(e().w(i,a,s,o),u||Promise)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(p$);var m$=p$.exports;(function(t){var e=m$;function r(n,i,a,s,o){var u=e(n,i,a,s,o);return u.next().then(function(l){return l.done?l.value:u.next()})}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(h$);var R8=h$.exports,y$={exports:{}};(function(t){function e(r){var n=Object(r),i=[];for(var a in n)i.unshift(a);return function s(){for(;i.length;)if((a=i.pop())in n)return s.value=a,s.done=!1,s;return s.done=!0,s}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(y$);var A8=y$.exports,b$={exports:{}};(function(t){var e=ni.default;function r(n){if(n!=null){var i=n[typeof Symbol=="function"&&Symbol.iterator||"@@iterator"],a=0;if(i)return i.call(n);if(typeof n.next=="function")return n;if(!isNaN(n.length))return{next:function(){return n&&a>=n.length&&(n=void 0),{value:n&&n[a++],done:!n}}}}throw new TypeError(e(n)+" is not iterable")}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(b$);var O8=b$.exports;(function(t){var e=u$,r=f$,n=R8,i=m$,a=g$,s=A8,o=O8;function u(){var l=r(),c=l.m(u),d=(Object.getPrototypeOf?Object.getPrototypeOf(c):c.__proto__).constructor;function f(L){var N=typeof L=="function"&&L.constructor;return!!N&&(N===d||(N.displayName||N.name)==="GeneratorFunction")}var m={throw:1,return:2,break:3,continue:3};function k(L){var N,z;return function(re){N||(N={stop:function(){return z(re.a,2)},catch:function(){return re.v},abrupt:function(Oe,Fe){return z(re.a,m[Oe],Fe)},delegateYield:function(Oe,Fe,Pe){return N.resultName=Fe,z(re.d,o(Oe),Pe)},finish:function(Oe){return z(re.f,Oe)}},z=function(Oe,Fe,Pe){re.p=N.prev,re.n=N.next;try{return Oe(Fe,Pe)}finally{N.next=re.n}}),N.resultName&&(N[N.resultName]=re.v,N.resultName=void 0),N.sent=re.v,N.next=re.n;try{return L.call(this,N)}finally{re.p=N.prev,re.n=N.next}}}return(t.exports=u=function(){return{wrap:function(z,re,Me,Oe){return l.w(k(z),re,Me,Oe&&Oe.reverse())},isGeneratorFunction:f,mark:l.m,awrap:function(z,re){return new e(z,re)},AsyncIterator:a,async:function(z,re,Me,Oe,Fe){return(f(re)?i:n)(k(z),re,Me,Oe,Fe)},keys:s,values:o}},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=u,t.exports.__esModule=!0,t.exports.default=t.exports})(s$);var P8=s$.exports,dh=P8(),Au=dh;try{regeneratorRuntime=dh}catch{typeof globalThis=="object"?globalThis.regeneratorRuntime=dh:Function("r","regeneratorRuntime = r")(dh)}var M8=TypeError,N8=9007199254740991,w$=function(t){if(t>N8)throw M8("Maximum allowed index exceeded");return t},L8=Xt,D8=qt,j8=Ec,U8=Mr,F8=vn,B8=gn,_$=w$,k$=Mc,z8=Cg,H8=Pc,q8=Cr,V8=fu,S$=q8("isConcatSpreadable"),W8=V8>=51||!D8(function(){var t=[];return t[S$]=!1,t.concat()[0]!==t}),Z8=function(t){if(!U8(t))return!1;var e=t[S$];return e!==void 0?!!e:j8(t)},G8=!W8||!H8("concat");L8({target:"Array",proto:!0,arity:1,forced:G8},{concat:function(e){var r=F8(this),n=z8(r,0),i=0,a,s,o,u,l;for(a=-1,o=arguments.length;a<o;a++)if(l=a===-1?r:arguments[a],Z8(l))for(u=B8(l),_$(i+u),s=0;s<u;s++,i++)s in l&&k$(n,i,l[s]);else _$(i+1),k$(n,i++,l);return n.length=i,n}});var K8=Wr,Y8=YS,J8=function(t,e,r,n){try{return n?e(K8(r)[0],r[1]):e(r)}catch(i){Y8(t,"throw",i)}},Q8=ka,X8=$r,eB=vn,tB=J8,rB=gm,nB=Uf,iB=gn,$$=Mc,aB=uh,sB=Fc,T$=Array,C$=function(e){var r=eB(e),n=nB(this),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0;s&&(a=Q8(a,i>2?arguments[2]:void 0));var o=sB(r),u=0,l,c,d,f,m,k;if(o&&!(this===T$&&rB(o)))for(c=n?new this:[],f=aB(r,o),m=f.next;!(d=X8(m,f)).done;u++)k=s?tB(f,a,[d.value,u],!0):d.value,$$(c,u,k);else for(l=iB(r),c=n?new this(l):T$(l);l>u;u++)k=s?a(r[u],u):r[u],$$(c,u,k);return c.length=u,c},oB=Xt,uB=C$,lB=ch,cB=!lB(function(t){Array.from(t)});oB({target:"Array",stat:!0,forced:cB},{from:uB});var ym=Gt,dB=Wi,fB=Xr,hB=Si,pB=ym("".charAt),E$=ym("".charCodeAt),vB=ym("".slice),I$=function(t){return function(e,r){var n=fB(hB(e)),i=dB(r),a=n.length,s,o;return i<0||i>=a?t?"":void 0:(s=E$(n,i),s<55296||s>56319||i+1===a||(o=E$(n,i+1))<56320||o>57343?t?pB(n,i):s:t?vB(n,i,i+2):(s-55296<<10)+(o-56320)+65536)}},bm={codeAt:I$(!1),charAt:I$(!0)},gB=qt,mB=!gB(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}),yB=Hr,bB=Tr,wB=vn,_B=Rf,kB=mB,x$=_B("IE_PROTO"),wm=Object,SB=wm.prototype,zc=kB?wm.getPrototypeOf:function(t){var e=wB(t);if(yB(e,x$))return e[x$];var r=e.constructor;return bB(r)&&e instanceof r?r.prototype:e instanceof wm?SB:null},$B=qt,TB=Tr,CB=Mr,R$=zc,EB=Tn,IB=Cr,_m=IB("iterator"),A$=!1,bo,km,Sm;[].keys&&(Sm=[].keys(),"next"in Sm?(km=R$(R$(Sm)),km!==Object.prototype&&(bo=km)):A$=!0);var xB=!CB(bo)||$B(function(){var t={};return bo[_m].call(t)!==t});xB&&(bo={}),TB(bo[_m])||EB(bo,_m,function(){return this});var O$={IteratorPrototype:bo,BUGGY_SAFARI_ITERATORS:A$},RB=O$.IteratorPrototype,AB=os,OB=uo,PB=Zi,MB=Uc,NB=function(){return this},P$=function(t,e,r,n){var i=e+" Iterator";return t.prototype=AB(RB,{next:OB(+!n,r)}),PB(t,i,!1),MB[i]=NB,t},LB=Xt,DB=$r,M$=wc,jB=Tr,UB=P$,N$=zc,L$=Su,FB=Zi,BB=ba,$m=Tn,zB=Cr,HB=Uc,D$=O$,qB=M$.PROPER,VB=M$.CONFIGURABLE,j$=D$.IteratorPrototype,fh=D$.BUGGY_SAFARI_ITERATORS,Hc=zB("iterator"),U$="keys",qc="values",F$="entries",WB=function(){return this},Tm=function(t,e,r,n,i,a,s){UB(r,e,n);var o=function(z){if(z===i&&f)return f;if(!fh&&z&&z in c)return c[z];switch(z){case U$:return function(){return new r(this,z)};case qc:return function(){return new r(this,z)};case F$:return function(){return new r(this,z)}}return function(){return new r(this)}},u=e+" Iterator",l=!1,c=t.prototype,d=c[Hc]||c["@@iterator"]||i&&c[i],f=!fh&&d||o(i),m=e==="Array"&&c.entries||d,k,L,N;if(m&&(k=N$(m.call(new t)),k!==Object.prototype&&k.next&&(N$(k)!==j$&&(L$?L$(k,j$):jB(k[Hc])||$m(k,Hc,WB)),FB(k,u,!0))),qB&&i===qc&&d&&d.name!==qc&&(VB?BB(c,"name",qc):(l=!0,f=function(){return DB(d,this)})),i)if(L={values:o(qc),keys:a?f:o(U$),entries:o(F$)},s)for(N in L)(fh||l||!(N in c))&&$m(c,N,L[N]);else LB({target:e,proto:!0,forced:fh||l},L);return c[Hc]!==f&&$m(c,Hc,f,{name:i}),HB[e]=f,L},hh=function(t,e){return{value:t,done:e}},ZB=bm.charAt,GB=Xr,B$=Wn,KB=Tm,z$=hh,H$="String Iterator",YB=B$.set,JB=B$.getterFor(H$);KB(String,"String",function(t){YB(this,{type:H$,string:GB(t),index:0})},function(){var e=JB(this),r=e.string,n=e.index,i;return n>=r.length?z$(void 0,!0):(i=ZB(r,n),e.index+=i.length,z$(i,!1))});var q$={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(sn,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"],a={},s=null;function o(L,N){var z=L[N];if(typeof z.bind=="function")return z.bind(L);try{return Function.prototype.bind.call(z,L)}catch{return function(){return Function.prototype.apply.apply(z,[L,arguments])}}}function u(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(L){return L==="debug"&&(L="log"),typeof console===r?!1:L==="trace"&&n?u:console[L]!==void 0?o(console,L):console.log!==void 0?o(console,"log"):e}function c(){for(var L=this.getLevel(),N=0;N<i.length;N++){var z=i[N];this[z]=N<L?e:this.methodFactory(z,L,this.name)}if(this.log=this.debug,typeof console===r&&L<this.levels.SILENT)return"No console available for logging"}function d(L){return function(){typeof console!==r&&(c.call(this),this[L].apply(this,arguments))}}function f(L,N,z){return l(L)||d.apply(this,arguments)}function m(L,N){var z=this,re,Me,Oe,Fe="loglevel";typeof L=="string"?Fe+=":"+L:typeof L=="symbol"&&(Fe=void 0);function Pe(se){var Te=(i[se]||"silent").toUpperCase();if(!(typeof window===r||!Fe)){try{window.localStorage[Fe]=Te;return}catch{}try{window.document.cookie=encodeURIComponent(Fe)+"="+Te+";"}catch{}}}function Ze(){var se;if(!(typeof window===r||!Fe)){try{se=window.localStorage[Fe]}catch{}if(typeof se===r)try{var Te=window.document.cookie,te=encodeURIComponent(Fe),oe=Te.indexOf(te+"=");oe!==-1&&(se=/^([^;]+)/.exec(Te.slice(oe+te.length+1))[1])}catch{}return z.levels[se]===void 0&&(se=void 0),se}}function Z(){if(!(typeof window===r||!Fe)){try{window.localStorage.removeItem(Fe)}catch{}try{window.document.cookie=encodeURIComponent(Fe)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}function Ie(se){var Te=se;if(typeof Te=="string"&&z.levels[Te.toUpperCase()]!==void 0&&(Te=z.levels[Te.toUpperCase()]),typeof Te=="number"&&Te>=0&&Te<=z.levels.SILENT)return Te;throw new TypeError("log.setLevel() called with invalid level: "+se)}z.name=L,z.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},z.methodFactory=N||f,z.getLevel=function(){return Oe??Me??re},z.setLevel=function(se,Te){return Oe=Ie(se),Te!==!1&&Pe(Oe),c.call(z)},z.setDefaultLevel=function(se){Me=Ie(se),Ze()||z.setLevel(se,!1)},z.resetLevel=function(){Oe=null,Z(),c.call(z)},z.enableAll=function(se){z.setLevel(z.levels.TRACE,se)},z.disableAll=function(se){z.setLevel(z.levels.SILENT,se)},z.rebuild=function(){if(s!==z&&(re=Ie(s.getLevel())),c.call(z),s===z)for(var se in a)a[se].rebuild()},re=Ie(s?s.getLevel():"WARN");var _e=Ze();_e!=null&&(Oe=Ie(_e)),c.call(z)}s=new m,s.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var z=a[N];return z||(z=a[N]=new m(N,s.methodFactory)),z};var k=typeof window!==r?window.log:void 0;return s.noConflict=function(){return typeof window!==r&&window.log===s&&(window.log=k),s},s.getLoggers=function(){return a},s.default=s,s})})(q$);var Ou=q$.exports;const wo="\\d+(?:[\\.,]\\d+)?",QB=`(${wo}W)`,XB=`(${wo}Y)?(${wo}M)?(${wo}D)?`,e9=`T(${wo}H)?(${wo}M)?(${wo}S)?`,t9=`P(?:${QB}|${XB}(?:${e9})?)`,r9=["weeks","years","months","days","hours","minutes","seconds"],Cm=new RegExp(t9),V$=t=>t.match(Cm).slice(1).reduce((e,r,n)=>(e[r9[n]]=parseFloat(r)||0,e),{}),Em=(t,e)=>{const r=e?e.getTime():Date.now(),n=new Date(r);return n.setFullYear(n.getFullYear()+t.years),n.setMonth(n.getMonth()+t.months),n.setDate(n.getDate()+t.days),n.setHours(n.getHours()+t.hours),n.setMinutes(n.getMinutes()+t.minutes),n.setMilliseconds(n.getMilliseconds()+t.seconds*1e3),n.setDate(n.getDate()+t.weeks*7),n},W$=(t,e)=>{const r=e?e.getTime():Date.now(),n=new Date(r);return(Em(t,n).getTime()-n.getTime())/1e3},n9=B2(Object.freeze(Object.defineProperty({__proto__:null,default:{end:Em,toSeconds:W$,pattern:Cm,parse:V$},end:Em,parse:V$,pattern:Cm,toSeconds:W$},Symbol.toStringTag,{value:"Module"})));var i9=Cr,a9=os,s9=$n.f,Im=i9("unscopables"),xm=Array.prototype;xm[Im]===void 0&&s9(xm,Im,{configurable:!0,value:a9(null)});var Rm=function(t){xm[Im][t]=!0},o9=Vn,Am=Rm,Z$=Uc,G$=Wn,u9=$n.f,l9=Tm,ph=hh,c9=xr,K$="Array Iterator",d9=G$.set,f9=G$.getterFor(K$),Y$=l9(Array,"Array",function(t,e){d9(this,{type:K$,target:o9(t),index:0,kind:e})},function(){var t=f9(this),e=t.target,r=t.index++;if(!e||r>=e.length)return t.target=void 0,ph(void 0,!0);switch(t.kind){case"keys":return ph(r,!1);case"values":return ph(e[r],!1)}return ph([r,e[r]],!1)},"values"),J$=Z$.Arguments=Z$.Array;if(Am("keys"),Am("values"),Am("entries"),c9&&J$.name!=="values")try{u9(J$,"name",{value:"values"})}catch{}var Q$=ur,X$=eS,h9=rS,Vc=Y$,eT=ba,p9=Zi,v9=Cr,Om=v9("iterator"),Pm=Vc.values,tT=function(t,e){if(t){if(t[Om]!==Pm)try{eT(t,Om,Pm)}catch{t[Om]=Pm}if(p9(t,e,!0),X$[e]){for(var r in Vc)if(t[r]!==Vc[r])try{eT(t,r,Vc[r])}catch{t[r]=Vc[r]}}}};for(var Mm in X$)tT(Q$[Mm]&&Q$[Mm].prototype,Mm);tT(h9,"DOMTokenList");var g9=Tr,m9=Mr,rT=Su,vh=function(t,e,r){var n,i;return rT&&g9(n=e.constructor)&&n!==r&&m9(i=n.prototype)&&i!==r.prototype&&rT(t,i),t},y9=Gt,b9=y9(1 .valueOf),w9=`
789
789
  \v\f\r                 \u2028\u2029\uFEFF`,_9=Gt,k9=Si,S9=Xr,Nm=w9,nT=_9("".replace),$9=RegExp("^["+Nm+"]+"),T9=RegExp("(^|[^"+Nm+"])["+Nm+"]+$"),Lm=function(t){return function(e){var r=S9(k9(e));return t&1&&(r=nT(r,$9,"")),t&2&&(r=nT(r,T9,"$1")),r}},C9={start:Lm(1),end:Lm(2),trim:Lm(3)},E9=Xt,iT=Y_,I9=xr,aT=ur,sT=Q1,oT=Gt,x9=Lf,uT=Hr,R9=vh,A9=ya,O9=pu,lT=Kv,P9=qt,M9=ho.f,N9=ma.f,L9=$n.f,D9=b9,j9=C9.trim,gh="Number",Pu=aT[gh];sT[gh];var Dm=Pu.prototype,U9=aT.TypeError,F9=oT("".slice),mh=oT("".charCodeAt),B9=function(t){var e=lT(t,"number");return typeof e=="bigint"?e:z9(e)},z9=function(t){var e=lT(t,"number"),r,n,i,a,s,o,u,l;if(O9(e))throw new U9("Cannot convert a Symbol value to a number");if(typeof e=="string"&&e.length>2){if(e=j9(e),r=mh(e,0),r===43||r===45){if(n=mh(e,2),n===88||n===120)return NaN}else if(r===48){switch(mh(e,1)){case 66:case 98:i=2,a=49;break;case 79:case 111:i=8,a=55;break;default:return+e}for(s=F9(e,2),o=s.length,u=0;u<o;u++)if(l=mh(s,u),l<48||l>a)return NaN;return parseInt(s,i)}}return+e},jm=x9(gh,!Pu(" 0o1")||!Pu("0b1")||Pu("+0x1")),H9=function(t){return A9(Dm,t)&&P9(function(){D9(t)})},yh=function(e){var r=arguments.length<1?0:Pu(B9(e));return H9(this)?R9(Object(r),this,yh):r};yh.prototype=Dm,jm&&!iT&&(Dm.constructor=yh),E9({global:!0,constructor:!0,wrap:!0,forced:jm},{Number:yh});var q9=function(t,e){for(var r=I9?M9(e):"MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,EPSILON,MAX_SAFE_INTEGER,MIN_SAFE_INTEGER,isFinite,isInteger,isNaN,isSafeInteger,parseFloat,parseInt,fromString,range".split(","),n=0,i;r.length>n;n++)uT(e,i=r[n])&&!uT(t,i)&&L9(t,i,N9(e,i))};(jm||iT)&&q9(sT[gh],Pu);var V9=Wr,cT=function(){var t=V9(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e},Um=qt,W9=ur,Fm=W9.RegExp,Bm=Um(function(){var t=Fm("a","y");return t.lastIndex=2,t.exec("abcd")!==null}),Z9=Bm||Um(function(){return!Fm("a","y").sticky}),G9=Bm||Um(function(){var t=Fm("^r","gy");return t.lastIndex=2,t.exec("str")!==null}),dT={BROKEN_CARET:G9,MISSED_STICKY:Z9,UNSUPPORTED_Y:Bm},K9=qt,Y9=ur,J9=Y9.RegExp,Q9=K9(function(){var t=J9(".","s");return!(t.dotAll&&t.test(`
790
790
  `)&&t.flags==="s")}),X9=qt,e7=ur,t7=e7.RegExp,r7=X9(function(){var t=t7("(?<a>b)","g");return t.exec("b").groups.a!=="b"||"b".replace(t,"$<a>c")!=="bc"}),Mu=$r,bh=Gt,n7=Xr,i7=cT,a7=dT,s7=vu,o7=os,u7=Wn.get,l7=Q9,c7=r7,d7=s7("native-string-replace",String.prototype.replace),wh=RegExp.prototype.exec,zm=wh,f7=bh("".charAt),h7=bh("".indexOf),p7=bh("".replace),Hm=bh("".slice),qm=function(){var t=/a/,e=/b*/g;return Mu(wh,t,"a"),Mu(wh,e,"a"),t.lastIndex!==0||e.lastIndex!==0}(),fT=a7.BROKEN_CARET,Vm=/()??/.exec("")[1]!==void 0,v7=qm||Vm||fT||l7||c7;v7&&(zm=function(e){var r=this,n=u7(r),i=n7(e),a=n.raw,s,o,u,l,c,d,f;if(a)return a.lastIndex=r.lastIndex,s=Mu(zm,a,i),r.lastIndex=a.lastIndex,s;var m=n.groups,k=fT&&r.sticky,L=Mu(i7,r),N=r.source,z=0,re=i;if(k&&(L=p7(L,"y",""),h7(L,"g")===-1&&(L+="g"),re=Hm(i,r.lastIndex),r.lastIndex>0&&(!r.multiline||r.multiline&&f7(i,r.lastIndex-1)!==`
791
- `)&&(N="(?: "+N+")",re=" "+re,z++),o=new RegExp("^(?:"+N+")",L)),Vm&&(o=new RegExp("^"+N+"$(?!\\s)",L)),qm&&(u=r.lastIndex),l=Mu(wh,k?o:r,re),k?l?(l.input=Hm(l.input,z),l[0]=Hm(l[0],z),l.index=r.lastIndex,r.lastIndex+=l[0].length):r.lastIndex=0:qm&&l&&(r.lastIndex=r.global?l.index+l[0].length:u),Vm&&l&&l.length>1&&Mu(d7,l[0],o,function(){for(c=1;c<arguments.length-2;c++)arguments[c]===void 0&&(l[c]=void 0)}),l&&m)for(l.groups=d=o7(null),c=0;c<m.length;c++)f=m[c],d[f[0]]=l[f[1]];return l});var Wm=zm,g7=Xt,hT=Wm;g7({target:"RegExp",proto:!0,forced:/./.exec!==hT},{exec:hT});var pT=$r,vT=Tn,m7=Wm,gT=qt,mT=Cr,y7=ba,b7=mT("species"),Zm=RegExp.prototype,_h=function(t,e,r,n){var i=mT(t),a=!gT(function(){var l={};return l[i]=function(){return 7},""[t](l)!==7}),s=a&&!gT(function(){var l=!1,c=/a/;return t==="split"&&(c={},c.constructor={},c.constructor[b7]=function(){return c},c.flags="",c[i]=/./[i]),c.exec=function(){return l=!0,null},c[i](""),!l});if(!a||!s||r){var o=/./[i],u=e(i,""[t],function(l,c,d,f,m){var k=c.exec;return k===m7||k===Zm.exec?a&&!m?{done:!0,value:pT(o,c,d,f)}:{done:!0,value:pT(l,d,c,f)}:{done:!1}});vT(String.prototype,t,u[0]),vT(Zm,i,u[1])}n&&y7(Zm[i],"sham",!0)},w7=bm.charAt,Gm=function(t,e,r){return e+(r?w7(t,e).length:1)},Km=Gt,_7=vn,k7=Math.floor,Ym=Km("".charAt),S7=Km("".replace),Jm=Km("".slice),$7=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,T7=/\$([$&'`]|\d{1,2})/g,C7=function(t,e,r,n,i,a){var s=r+t.length,o=n.length,u=T7;return i!==void 0&&(i=_7(i),u=$7),S7(a,u,function(l,c){var d;switch(Ym(c,0)){case"$":return"$";case"&":return t;case"`":return Jm(e,0,r);case"'":return Jm(e,s);case"<":d=i[Jm(c,1,-1)];break;default:var f=+c;if(f===0)return l;if(f>o){var m=k7(f/10);return m===0?l:m<=o?n[m-1]===void 0?Ym(c,1):n[m-1]+Ym(c,1):l}d=n[f-1]}return d===void 0?"":d})},yT=$r,E7=Wr,I7=Tr,x7=qi,R7=Wm,A7=TypeError,kh=function(t,e){var r=t.exec;if(I7(r)){var n=yT(r,t,e);return n!==null&&E7(n),n}if(x7(t)==="RegExp")return yT(R7,t,e);throw new A7("RegExp#exec called on incompatible receiver")},O7=po,bT=$r,Sh=Gt,P7=_h,M7=qt,N7=Wr,L7=Tr,D7=ki,j7=Wi,U7=wa,Nu=Xr,F7=Si,B7=Gm,z7=fo,H7=C7,q7=kh,V7=Cr,Qm=V7("replace"),W7=Math.max,Z7=Math.min,G7=Sh([].concat),Xm=Sh([].push),wT=Sh("".indexOf),_T=Sh("".slice),K7=function(t){return t===void 0?t:String(t)},Y7=function(){return"a".replace(/./,"$0")==="$0"}(),kT=function(){return/./[Qm]?/./[Qm]("a","$0")==="":!1}(),J7=!M7(function(){var t=/./;return t.exec=function(){var e=[];return e.groups={a:"7"},e},"".replace(t,"$<a>")!=="7"});P7("replace",function(t,e,r){var n=kT?"$":"$0";return[function(a,s){var o=F7(this),u=D7(a)?void 0:z7(a,Qm);return u?bT(u,a,o,s):bT(e,Nu(o),a,s)},function(i,a){var s=N7(this),o=Nu(i);if(typeof a=="string"&&wT(a,n)===-1&&wT(a,"$<")===-1){var u=r(e,s,o,a);if(u.done)return u.value}var l=L7(a);l||(a=Nu(a));var c=s.global,d;c&&(d=s.unicode,s.lastIndex=0);for(var f=[],m;m=q7(s,o),!(m===null||(Xm(f,m),!c));){var k=Nu(m[0]);k===""&&(s.lastIndex=B7(o,U7(s.lastIndex),d))}for(var L="",N=0,z=0;z<f.length;z++){m=f[z];for(var re=Nu(m[0]),Me=W7(Z7(j7(m.index),o.length),0),Oe=[],Be,Pe=1;Pe<m.length;Pe++)Xm(Oe,K7(m[Pe]));var Ze=m.groups;if(l){var Z=G7([re],Oe,Me,o);Ze!==void 0&&Xm(Z,Ze),Be=Nu(O7(a,void 0,Z))}else Be=H7(re,o,Me,Oe,Ze,a);Me>=N&&(L+=_T(o,N,Me)+Be,N=Me+re.length)}return L+_T(o,N)}]},!J7||!Y7||kT);var Q7=Xt,X7=Gt,ez=yc,tz=Vn,rz=Gf,nz=X7([].join),iz=ez!==Object,az=iz||!rz("join",",");Q7({target:"Array",proto:!0,forced:az},{join:function(e){return nz(tz(this),e===void 0?",":e)}});var en={},sz=xr,oz=wc.EXISTS,ST=Gt,uz=Ki,$T=Function.prototype,lz=ST($T.toString),TT=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,cz=ST(TT.exec),dz="name";sz&&!oz&&uz($T,dz,{configurable:!0,get:function(){try{return cz(TT,lz(this))[1]}catch{return""}}});var CT={exports:{}},ET={exports:{}};(function(t){function e(r){if(Array.isArray(r))return r}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(ET);var fz=ET.exports,IT={exports:{}};(function(t){function e(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var a,s,o,u,l=[],c=!0,d=!1;try{if(o=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;c=!1}else for(;!(c=(a=o.call(i)).done)&&(l.push(a.value),l.length!==n);c=!0);}catch(f){d=!0,s=f}finally{try{if(!c&&i.return!=null&&(u=i.return(),Object(u)!==u))return}finally{if(d)throw s}}return l}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(IT);var hz=IT.exports,xT={exports:{}},RT={exports:{}};(function(t){function e(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,a=Array(n);i<n;i++)a[i]=r[i];return a}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(RT);var AT=RT.exports;(function(t){var e=AT;function r(n,i){if(n){if(typeof n=="string")return e(n,i);var a={}.toString.call(n).slice(8,-1);return a==="Object"&&n.constructor&&(a=n.constructor.name),a==="Map"||a==="Set"?Array.from(n):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(n,i):void 0}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(xT);var OT=xT.exports,PT={exports:{}};(function(t){function e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
791
+ `)&&(N="(?: "+N+")",re=" "+re,z++),o=new RegExp("^(?:"+N+")",L)),Vm&&(o=new RegExp("^"+N+"$(?!\\s)",L)),qm&&(u=r.lastIndex),l=Mu(wh,k?o:r,re),k?l?(l.input=Hm(l.input,z),l[0]=Hm(l[0],z),l.index=r.lastIndex,r.lastIndex+=l[0].length):r.lastIndex=0:qm&&l&&(r.lastIndex=r.global?l.index+l[0].length:u),Vm&&l&&l.length>1&&Mu(d7,l[0],o,function(){for(c=1;c<arguments.length-2;c++)arguments[c]===void 0&&(l[c]=void 0)}),l&&m)for(l.groups=d=o7(null),c=0;c<m.length;c++)f=m[c],d[f[0]]=l[f[1]];return l});var Wm=zm,g7=Xt,hT=Wm;g7({target:"RegExp",proto:!0,forced:/./.exec!==hT},{exec:hT});var pT=$r,vT=Tn,m7=Wm,gT=qt,mT=Cr,y7=ba,b7=mT("species"),Zm=RegExp.prototype,_h=function(t,e,r,n){var i=mT(t),a=!gT(function(){var l={};return l[i]=function(){return 7},""[t](l)!==7}),s=a&&!gT(function(){var l=!1,c=/a/;return t==="split"&&(c={},c.constructor={},c.constructor[b7]=function(){return c},c.flags="",c[i]=/./[i]),c.exec=function(){return l=!0,null},c[i](""),!l});if(!a||!s||r){var o=/./[i],u=e(i,""[t],function(l,c,d,f,m){var k=c.exec;return k===m7||k===Zm.exec?a&&!m?{done:!0,value:pT(o,c,d,f)}:{done:!0,value:pT(l,d,c,f)}:{done:!1}});vT(String.prototype,t,u[0]),vT(Zm,i,u[1])}n&&y7(Zm[i],"sham",!0)},w7=bm.charAt,Gm=function(t,e,r){return e+(r?w7(t,e).length:1)},Km=Gt,_7=vn,k7=Math.floor,Ym=Km("".charAt),S7=Km("".replace),Jm=Km("".slice),$7=/\$([$&'`]|\d{1,2}|<[^>]*>)/g,T7=/\$([$&'`]|\d{1,2})/g,C7=function(t,e,r,n,i,a){var s=r+t.length,o=n.length,u=T7;return i!==void 0&&(i=_7(i),u=$7),S7(a,u,function(l,c){var d;switch(Ym(c,0)){case"$":return"$";case"&":return t;case"`":return Jm(e,0,r);case"'":return Jm(e,s);case"<":d=i[Jm(c,1,-1)];break;default:var f=+c;if(f===0)return l;if(f>o){var m=k7(f/10);return m===0?l:m<=o?n[m-1]===void 0?Ym(c,1):n[m-1]+Ym(c,1):l}d=n[f-1]}return d===void 0?"":d})},yT=$r,E7=Wr,I7=Tr,x7=qi,R7=Wm,A7=TypeError,kh=function(t,e){var r=t.exec;if(I7(r)){var n=yT(r,t,e);return n!==null&&E7(n),n}if(x7(t)==="RegExp")return yT(R7,t,e);throw new A7("RegExp#exec called on incompatible receiver")},O7=po,bT=$r,Sh=Gt,P7=_h,M7=qt,N7=Wr,L7=Tr,D7=ki,j7=Wi,U7=wa,Nu=Xr,F7=Si,B7=Gm,z7=fo,H7=C7,q7=kh,V7=Cr,Qm=V7("replace"),W7=Math.max,Z7=Math.min,G7=Sh([].concat),Xm=Sh([].push),wT=Sh("".indexOf),_T=Sh("".slice),K7=function(t){return t===void 0?t:String(t)},Y7=function(){return"a".replace(/./,"$0")==="$0"}(),kT=function(){return/./[Qm]?/./[Qm]("a","$0")==="":!1}(),J7=!M7(function(){var t=/./;return t.exec=function(){var e=[];return e.groups={a:"7"},e},"".replace(t,"$<a>")!=="7"});P7("replace",function(t,e,r){var n=kT?"$":"$0";return[function(a,s){var o=F7(this),u=D7(a)?void 0:z7(a,Qm);return u?bT(u,a,o,s):bT(e,Nu(o),a,s)},function(i,a){var s=N7(this),o=Nu(i);if(typeof a=="string"&&wT(a,n)===-1&&wT(a,"$<")===-1){var u=r(e,s,o,a);if(u.done)return u.value}var l=L7(a);l||(a=Nu(a));var c=s.global,d;c&&(d=s.unicode,s.lastIndex=0);for(var f=[],m;m=q7(s,o),!(m===null||(Xm(f,m),!c));){var k=Nu(m[0]);k===""&&(s.lastIndex=B7(o,U7(s.lastIndex),d))}for(var L="",N=0,z=0;z<f.length;z++){m=f[z];for(var re=Nu(m[0]),Me=W7(Z7(j7(m.index),o.length),0),Oe=[],Fe,Pe=1;Pe<m.length;Pe++)Xm(Oe,K7(m[Pe]));var Ze=m.groups;if(l){var Z=G7([re],Oe,Me,o);Ze!==void 0&&Xm(Z,Ze),Fe=Nu(O7(a,void 0,Z))}else Fe=H7(re,o,Me,Oe,Ze,a);Me>=N&&(L+=_T(o,N,Me)+Fe,N=Me+re.length)}return L+_T(o,N)}]},!J7||!Y7||kT);var Q7=Xt,X7=Gt,ez=yc,tz=Vn,rz=Gf,nz=X7([].join),iz=ez!==Object,az=iz||!rz("join",",");Q7({target:"Array",proto:!0,forced:az},{join:function(e){return nz(tz(this),e===void 0?",":e)}});var en={},sz=xr,oz=wc.EXISTS,ST=Gt,uz=Ki,$T=Function.prototype,lz=ST($T.toString),TT=/function\b(?:\s|\/\*[\S\s]*?\*\/|\/\/[^\n\r]*[\n\r]+)*([^\s(/]*)/,cz=ST(TT.exec),dz="name";sz&&!oz&&uz($T,dz,{configurable:!0,get:function(){try{return cz(TT,lz(this))[1]}catch{return""}}});var CT={exports:{}},ET={exports:{}};(function(t){function e(r){if(Array.isArray(r))return r}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(ET);var fz=ET.exports,IT={exports:{}};(function(t){function e(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var a,s,o,u,l=[],c=!0,d=!1;try{if(o=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;c=!1}else for(;!(c=(a=o.call(i)).done)&&(l.push(a.value),l.length!==n);c=!0);}catch(f){d=!0,s=f}finally{try{if(!c&&i.return!=null&&(u=i.return(),Object(u)!==u))return}finally{if(d)throw s}}return l}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(IT);var hz=IT.exports,xT={exports:{}},RT={exports:{}};(function(t){function e(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,a=Array(n);i<n;i++)a[i]=r[i];return a}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(RT);var AT=RT.exports;(function(t){var e=AT;function r(n,i){if(n){if(typeof n=="string")return e(n,i);var a={}.toString.call(n).slice(8,-1);return a==="Object"&&n.constructor&&(a=n.constructor.name),a==="Map"||a==="Set"?Array.from(n):a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?e(n,i):void 0}}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(xT);var OT=xT.exports,PT={exports:{}};(function(t){function e(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
792
792
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(PT);var pz=PT.exports;(function(t){var e=fz,r=hz,n=OT,i=pz;function a(s,o){return e(s)||r(s,o)||n(s,o)||i()}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(CT);var Wc=CT.exports,vz=Xt,MT=Ec,gz=Uf,mz=Mr,NT=yu,yz=gn,bz=Vn,wz=Mc,_z=Cr,kz=Pc,Sz=Gi,$z=kz("slice"),Tz=_z("species"),ey=Array,Cz=Math.max;vz({target:"Array",proto:!0,forced:!$z},{slice:function(e,r){var n=bz(this),i=yz(n),a=NT(e,i),s=NT(r===void 0?i:r,i),o,u,l;if(MT(n)&&(o=n.constructor,gz(o)&&(o===ey||MT(o.prototype))?o=void 0:mz(o)&&(o=o[Tz],o===null&&(o=void 0)),o===ey||o===void 0))return Sz(n,a,s);for(u=new(o===void 0?ey:o)(Cz(s-a,0)),l=0;a<s;a++,l++)a in n&&wz(u,l,n[a]);return u.length=l,u}});var Ez=Xt,LT=$r,Iz=Tr,DT=Wr,xz=Xr,Rz=function(){var t=!1,e=/[ac]/;return e.exec=function(){return t=!0,/./.exec.apply(this,arguments)},e.test("abc")===!0&&t}(),Az=/./.test;Ez({target:"RegExp",proto:!0,forced:!Rz},{test:function(t){var e=DT(this),r=xz(t),n=e.exec;if(!Iz(n))return LT(Az,e,r);var i=LT(n,e,r);return i===null?!1:(DT(i),!0)}});var Oz=Xt,Pz=xr,Mz=ur,$h=Gt,Nz=Hr,Lz=Tr,Dz=ya,jz=Xr,Uz=Ki,Fz=fg,Ta=Mz.Symbol,_o=Ta&&Ta.prototype;if(Pz&&Lz(Ta)&&(!("description"in _o)||Ta().description!==void 0)){var jT={},Th=function(){var e=arguments.length<1||arguments[0]===void 0?void 0:jz(arguments[0]),r=Dz(_o,this)?new Ta(e):e===void 0?Ta():Ta(e);return e===""&&(jT[r]=!0),r};Fz(Th,Ta),Th.prototype=_o,_o.constructor=Th;var Bz=String(Ta("description detection"))==="Symbol(description detection)",zz=$h(_o.valueOf),Hz=$h(_o.toString),qz=/^Symbol\((.*)\)[^)]+$/,Vz=$h("".replace),Wz=$h("".slice);Uz(_o,"description",{configurable:!0,get:function(){var e=zz(this);if(Nz(jT,e))return"";var r=Hz(e),n=Bz?Wz(r,7,-1):Vz(r,qz,"$1");return n===""?void 0:n}}),Oz({global:!0,constructor:!0,forced:!0},{Symbol:Th})}var Zz=ek;Zz("iterator");var UT={exports:{}},FT={exports:{}};(function(t){var e=AT;function r(n){if(Array.isArray(n))return e(n)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports})(FT);var Gz=FT.exports,BT={exports:{}};(function(t){function e(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(BT);var Kz=BT.exports,zT={exports:{}};(function(t){function e(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
793
793
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(zT);var Yz=zT.exports;(function(t){var e=Gz,r=Kz,n=OT,i=Yz;function a(s){return e(s)||r(s)||n(s)||i()}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(UT);var Zc=UT.exports,Jz=Xt,Qz=Nf.includes,Xz=qt,eH=Rm,tH=Xz(function(){return!Array(1).includes()});Jz({target:"Array",proto:!0,forced:tH},{includes:function(e){return Qz(this,e,arguments.length>1?arguments[1]:void 0)}}),eH("includes");var rH=Mr,nH=Math.floor,HT=Number.isInteger||function(e){return!rH(e)&&isFinite(e)&&nH(e)===e},iH=Xt,aH=HT;iH({target:"Number",stat:!0},{isInteger:aH});var qT=xr,sH=qt,VT=Gt,oH=zc,uH=Cc,lH=Vn,cH=mc.f,WT=VT(cH),dH=VT([].push),fH=qT&&sH(function(){var t=Object.create(null);return t[2]=2,!WT(t,2)}),ZT=function(t){return function(e){for(var r=lH(e),n=uH(r),i=fH&&oH(r)===null,a=n.length,s=0,o=[],u;a>s;)u=n[s++],(!qT||(i?u in r:WT(r,u)))&&dH(o,t?[u,r[u]]:r[u]);return o}},hH={entries:ZT(!0),values:ZT(!1)},pH=Xt,vH=hH.entries;pH({target:"Object",stat:!0},{entries:function(e){return vH(e)}});/*
794
794
  @license
@@ -814,7 +814,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
814
814
 
815
815
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
816
816
 
817
- */Object.defineProperty(xh,"__esModule",{value:!0});var WH=Zc,ZH=Qi,GH=$a,KH=cs,YH=Rh,JH=Yi,QH=Ji,XH=ii,eq=ds;function Ia(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var rC=Ia(WH),tq=Ia(ZH),rq=Ia(GH),nq=Ia(KH),ko=Ia(YH),iq=Ia(JH),aq=Ia(QH),xa=Ia(XH),sq=Ia(eq),oq;function vs(){}vs.prototype=Object.create(null);function Rr(){Rr.init.call(this)}Rr.EventEmitter=Rr,Rr.usingDomains=!1,Rr.prototype.domain=void 0,Rr.prototype._events=void 0,Rr.prototype._maxListeners=void 0,Rr.defaultMaxListeners=10,Rr.init=function(){this.domain=null,Rr.usingDomains&&oq.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new vs,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Rr.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function nC(t){return t._maxListeners===void 0?Rr.defaultMaxListeners:t._maxListeners}Rr.prototype.getMaxListeners=function(){return nC(this)};function uq(t,e,r){if(e)t.call(r);else for(var n=t.length,i=Kc(t,n),a=0;a<n;++a)i[a].call(r)}function lq(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=Kc(t,i),s=0;s<i;++s)a[s].call(r,n)}function cq(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=Kc(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function dq(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=Kc(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function fq(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=Kc(t,i),s=0;s<i;++s)a[s].apply(r,n)}Rr.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:uq(n,d,this);break;case 2:lq(n,d,this,arguments[1]);break;case 3:cq(n,d,this,arguments[1],arguments[2]);break;case 4:dq(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];fq(n,d,this,a)}return!0};function iC(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new vs,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=nC(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,hq(o)}return t}function hq(t){typeof console.warn=="function"?console.warn(t):console.log(t)}Rr.prototype.addListener=function(e,r){return iC(this,e,r,!1)},Rr.prototype.on=Rr.prototype.addListener,Rr.prototype.prependListener=function(e,r){return iC(this,e,r,!0)};function aC(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}Rr.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,aC(this,e,r)),this},Rr.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,aC(this,e,r)),this},Rr.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new vs:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new vs,this;delete i[e]}else pq(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},Rr.prototype.off=function(t,e){return this.removeListener(t,e)},Rr.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new vs,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new vs:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new vs,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},Rr.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=vq(r):n=[]):n=[],n},Rr.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):sC.call(t,e)},Rr.prototype.listenerCount=sC;function sC(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}Rr.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function pq(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function Kc(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function vq(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function gq(t){var e=mq();return function(){var n=xa.default(t),i;if(e){var a=xa.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return aq.default(this,i)}}function mq(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var yq=function(t){iq.default(r,t);var e=gq(r);function r(){var n;return tq.default(this,r),n=e.call(this),sq.default(nq.default(n),"eventHistory",new Map),n}return rq.default(r,[{key:"on",value:function(i,a){return ko.default(xa.default(r.prototype),"on",this).call(this,i,a)}},{key:"once",value:function(i,a){return ko.default(xa.default(r.prototype),"once",this).call(this,i,a)}},{key:"off",value:function(i,a){return ko.default(xa.default(r.prototype),"off",this).call(this,i,a)}},{key:"emit",value:function(i){for(var a,s=arguments.length,o=new Array(s>1?s-1:0),u=1;u<s;u++)o[u-1]=arguments[u];return this.eventHistory.set(i,o),(a=ko.default(xa.default(r.prototype),"emit",this)).call.apply(a,[this,i].concat(o))}},{key:"addListener",value:function(i,a){return ko.default(xa.default(r.prototype),"addListener",this).call(this,i,a)}},{key:"removeListener",value:function(i,a){return ko.default(xa.default(r.prototype),"removeListener",this).call(this,i,a)}},{key:"addListenerWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0&&a.apply(void 0,rC.default(s)),this.addListener(i,a)}},{key:"onWithReplay",value:function(i,a){return this.addListenerWithReplay(i,a)}},{key:"onceWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0?(a.apply(void 0,rC.default(s)),this):ko.default(xa.default(r.prototype),"once",this).call(this,i,a)}}]),r}(Rr);xh.ReplayEventEmitter=yq;var Ah={exports:{}};Ah.exports,function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,a=2,s=9007199254740991,o="[object Arguments]",u="[object Array]",l="[object AsyncFunction]",c="[object Boolean]",d="[object Date]",f="[object Error]",m="[object Function]",k="[object GeneratorFunction]",L="[object Map]",N="[object Number]",z="[object Null]",re="[object Object]",Me="[object Promise]",Oe="[object Proxy]",Be="[object RegExp]",Pe="[object Set]",Ze="[object String]",Z="[object Symbol]",Ie="[object Undefined]",_e="[object WeakMap]",se="[object ArrayBuffer]",Te="[object DataView]",te="[object Float32Array]",oe="[object Float64Array]",q="[object Int8Array]",ne="[object Int16Array]",Se="[object Int32Array]",H="[object Uint8Array]",ye="[object Uint8ClampedArray]",ke="[object Uint16Array]",P="[object Uint32Array]",Qe=/[\\^$.*+?()[\]{}|]/g,Ct=/^\[object .+?Constructor\]$/,tt=/^(?:0|[1-9]\d*)$/,De={};De[te]=De[oe]=De[q]=De[ne]=De[Se]=De[H]=De[ye]=De[ke]=De[P]=!0,De[o]=De[u]=De[se]=De[c]=De[Te]=De[d]=De[f]=De[m]=De[L]=De[N]=De[re]=De[Be]=De[Pe]=De[Ze]=De[_e]=!1;var ce=typeof sn=="object"&&sn&&sn.Object===Object&&sn,Ge=typeof self=="object"&&self&&self.Object===Object&&self,Ue=ce||Ge||Function("return this")(),be=e&&!e.nodeType&&e,ht=be&&!0&&t&&!t.nodeType&&t,Ve=ht&&ht.exports===be,Kt=Ve&&ce.process,Rt=function(){try{return Kt&&Kt.binding&&Kt.binding("util")}catch{}}(),Q=Rt&&Rt.isTypedArray;function je(F,ve){for(var qe=-1,bt=F==null?0:F.length,Pr=0,Yt=[];++qe<bt;){var Fr=F[qe];ve(Fr,qe,F)&&(Yt[Pr++]=Fr)}return Yt}function st(F,ve){for(var qe=-1,bt=ve.length,Pr=F.length;++qe<bt;)F[Pr+qe]=ve[qe];return F}function Re(F,ve){for(var qe=-1,bt=F==null?0:F.length;++qe<bt;)if(ve(F[qe],qe,F))return!0;return!1}function kt(F,ve){for(var qe=-1,bt=Array(F);++qe<F;)bt[qe]=ve(qe);return bt}function ot(F){return function(ve){return F(ve)}}function ar(F,ve){return F.has(ve)}function mr(F,ve){return F==null?void 0:F[ve]}function Xe(F){var ve=-1,qe=Array(F.size);return F.forEach(function(bt,Pr){qe[++ve]=[Pr,bt]}),qe}function Or(F,ve){return function(qe){return F(ve(qe))}}function jr(F){var ve=-1,qe=Array(F.size);return F.forEach(function(bt){qe[++ve]=bt}),qe}var lr=Array.prototype,cr=Function.prototype,Vt=Object.prototype,At=Ue["__core-js_shared__"],M=cr.toString,V=Vt.hasOwnProperty,ie=function(){var F=/[^.]+$/.exec(At&&At.keys&&At.keys.IE_PROTO||"");return F?"Symbol(src)_1."+F:""}(),Fe=Vt.toString,lt=RegExp("^"+M.call(V).replace(Qe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),yt=Ve?Ue.Buffer:void 0,Bt=Ue.Symbol,er=Ue.Uint8Array,Ee=Vt.propertyIsEnumerable,Ne=lr.splice,pe=Bt?Bt.toStringTag:void 0,$e=Object.getOwnPropertySymbols,ae=yt?yt.isBuffer:void 0,ge=Or(Object.keys,Object),we=He(Ue,"DataView"),K=He(Ue,"Map"),he=He(Ue,"Promise"),G=He(Ue,"Set"),de=He(Ue,"WeakMap"),X=He(Object,"create"),Ye=T(we),ze=T(K),ct=T(he),ut=T(G),ft=T(de),Et=Bt?Bt.prototype:void 0,It=Et?Et.valueOf:void 0;function _t(F){var ve=-1,qe=F==null?0:F.length;for(this.clear();++ve<qe;){var bt=F[ve];this.set(bt[0],bt[1])}}function St(){this.__data__=X?X(null):{},this.size=0}function xt(F){var ve=this.has(F)&&delete this.__data__[F];return this.size-=ve?1:0,ve}function Dt(F){var ve=this.__data__;if(X){var qe=ve[F];return qe===n?void 0:qe}return V.call(ve,F)?ve[F]:void 0}function rn(F){var ve=this.__data__;return X?ve[F]!==void 0:V.call(ve,F)}function yn(F,ve){var qe=this.__data__;return this.size+=this.has(F)?0:1,qe[F]=X&&ve===void 0?n:ve,this}_t.prototype.clear=St,_t.prototype.delete=xt,_t.prototype.get=Dt,_t.prototype.has=rn,_t.prototype.set=yn;function jt(F){var ve=-1,qe=F==null?0:F.length;for(this.clear();++ve<qe;){var bt=F[ve];this.set(bt[0],bt[1])}}function Fn(){this.__data__=[],this.size=0}function sa(F){var ve=this.__data__,qe=Nr(ve,F);if(qe<0)return!1;var bt=ve.length-1;return qe==bt?ve.pop():Ne.call(ve,qe,1),--this.size,!0}function Ua(F){var ve=this.__data__,qe=Nr(ve,F);return qe<0?void 0:ve[qe][1]}function Jn(F){return Nr(this.__data__,F)>-1}function oa(F,ve){var qe=this.__data__,bt=Nr(qe,F);return bt<0?(++this.size,qe.push([F,ve])):qe[bt][1]=ve,this}jt.prototype.clear=Fn,jt.prototype.delete=sa,jt.prototype.get=Ua,jt.prototype.has=Jn,jt.prototype.set=oa;function Qn(F){var ve=-1,qe=F==null?0:F.length;for(this.clear();++ve<qe;){var bt=F[ve];this.set(bt[0],bt[1])}}function fi(){this.size=0,this.__data__={hash:new _t,map:new(K||jt),string:new _t}}function Fa(F){var ve=xe(this,F).delete(F);return this.size-=ve?1:0,ve}function Jr(F){return xe(this,F).get(F)}function Ai(F){return xe(this,F).has(F)}function Es(F,ve){var qe=xe(this,F),bt=qe.size;return qe.set(F,ve),this.size+=qe.size==bt?0:1,this}Qn.prototype.clear=fi,Qn.prototype.delete=Fa,Qn.prototype.get=Jr,Qn.prototype.has=Ai,Qn.prototype.set=Es;function Oi(F){var ve=-1,qe=F==null?0:F.length;for(this.__data__=new Qn;++ve<qe;)this.add(F[ve])}function Is(F){return this.__data__.set(F,n),this}function Oo(F){return this.__data__.has(F)}Oi.prototype.add=Oi.prototype.push=Is,Oi.prototype.has=Oo;function Bn(F){var ve=this.__data__=new jt(F);this.size=ve.size}function xs(){this.__data__=new jt,this.size=0}function Po(F){var ve=this.__data__,qe=ve.delete(F);return this.size=ve.size,qe}function Mo(F){return this.__data__.get(F)}function cn(F){return this.__data__.has(F)}function Rs(F,ve){var qe=this.__data__;if(qe instanceof jt){var bt=qe.__data__;if(!K||bt.length<r-1)return bt.push([F,ve]),this.size=++qe.size,this;qe=this.__data__=new Qn(bt)}return qe.set(F,ve),this.size=qe.size,this}Bn.prototype.clear=xs,Bn.prototype.delete=Po,Bn.prototype.get=Mo,Bn.prototype.has=cn,Bn.prototype.set=Rs;function Rn(F,ve){var qe=O(F),bt=!qe&&U(F),Pr=!qe&&!bt&&Ce(F),Yt=!qe&&!bt&&!Pr&&Qr(F),Fr=qe||bt||Pr||Yt,Gr=Fr?kt(F.length,String):[],nn=Gr.length;for(var Mt in F)V.call(F,Mt)&&!(Fr&&(Mt=="length"||Pr&&(Mt=="offset"||Mt=="parent")||Yt&&(Mt=="buffer"||Mt=="byteLength"||Mt=="byteOffset")||On(Mt,nn)))&&Gr.push(Mt);return Gr}function Nr(F,ve){for(var qe=F.length;qe--;)if($(F[qe][0],ve))return qe;return-1}function No(F,ve,qe){var bt=ve(F);return O(F)?bt:st(bt,qe(F))}function Xn(F){return F==null?F===void 0?Ie:z:pe&&pe in Object(F)?it(F):C(F)}function An(F){return Pi(F)&&Xn(F)==o}function As(F,ve,qe,bt,Pr){return F===ve?!0:F==null||ve==null||!Pi(F)&&!Pi(ve)?F!==F&&ve!==ve:ee(F,ve,qe,bt,As,Pr)}function ee(F,ve,qe,bt,Pr,Yt){var Fr=O(F),Gr=O(ve),nn=Fr?u:Ur(F),Mt=Gr?u:Ur(ve);nn=nn==o?re:nn,Mt=Mt==o?re:Mt;var wn=nn==re,_n=Mt==re,dn=nn==Mt;if(dn&&Ce(F)){if(!Ce(ve))return!1;Fr=!0,wn=!1}if(dn&&!wn)return Yt||(Yt=new Bn),Fr||Qr(F)?I(F,ve,qe,bt,Pr,Yt):W(F,ve,nn,qe,bt,Pr,Yt);if(!(qe&i)){var zn=wn&&V.call(F,"__wrapped__"),Wt=_n&&V.call(ve,"__wrapped__");if(zn||Wt){var ua=zn?F.value():F,E=Wt?ve.value():ve;return Yt||(Yt=new Bn),Pr(ua,E,qe,bt,Yt)}}return dn?(Yt||(Yt=new Bn),j(F,ve,qe,bt,Pr,Yt)):!1}function ue(F){if(!fn(F)||D(F))return!1;var ve=nt(F)?lt:Ct;return ve.test(T(F))}function R(F){return Pi(F)&&Ot(F.length)&&!!De[Xn(F)]}function A(F){if(!B(F))return ge(F);var ve=[];for(var qe in Object(F))V.call(F,qe)&&qe!="constructor"&&ve.push(qe);return ve}function I(F,ve,qe,bt,Pr,Yt){var Fr=qe&i,Gr=F.length,nn=ve.length;if(Gr!=nn&&!(Fr&&nn>Gr))return!1;var Mt=Yt.get(F);if(Mt&&Yt.get(ve))return Mt==ve;var wn=-1,_n=!0,dn=qe&a?new Oi:void 0;for(Yt.set(F,ve),Yt.set(ve,F);++wn<Gr;){var zn=F[wn],Wt=ve[wn];if(bt)var ua=Fr?bt(Wt,zn,wn,ve,F,Yt):bt(zn,Wt,wn,F,ve,Yt);if(ua!==void 0){if(ua)continue;_n=!1;break}if(dn){if(!Re(ve,function(E,x){if(!ar(dn,x)&&(zn===E||Pr(zn,E,qe,bt,Yt)))return dn.push(x)})){_n=!1;break}}else if(!(zn===Wt||Pr(zn,Wt,qe,bt,Yt))){_n=!1;break}}return Yt.delete(F),Yt.delete(ve),_n}function W(F,ve,qe,bt,Pr,Yt,Fr){switch(qe){case Te:if(F.byteLength!=ve.byteLength||F.byteOffset!=ve.byteOffset)return!1;F=F.buffer,ve=ve.buffer;case se:return!(F.byteLength!=ve.byteLength||!Yt(new er(F),new er(ve)));case c:case d:case N:return $(+F,+ve);case f:return F.name==ve.name&&F.message==ve.message;case Be:case Ze:return F==ve+"";case L:var Gr=Xe;case Pe:var nn=bt&i;if(Gr||(Gr=jr),F.size!=ve.size&&!nn)return!1;var Mt=Fr.get(F);if(Mt)return Mt==ve;bt|=a,Fr.set(F,ve);var wn=I(Gr(F),Gr(ve),bt,Pr,Yt,Fr);return Fr.delete(F),wn;case Z:if(It)return It.call(F)==It.call(ve)}return!1}function j(F,ve,qe,bt,Pr,Yt){var Fr=qe&i,Gr=Le(F),nn=Gr.length,Mt=Le(ve),wn=Mt.length;if(nn!=wn&&!Fr)return!1;for(var _n=nn;_n--;){var dn=Gr[_n];if(!(Fr?dn in ve:V.call(ve,dn)))return!1}var zn=Yt.get(F);if(zn&&Yt.get(ve))return zn==ve;var Wt=!0;Yt.set(F,ve),Yt.set(ve,F);for(var ua=Fr;++_n<nn;){dn=Gr[_n];var E=F[dn],x=ve[dn];if(bt)var b=Fr?bt(x,E,dn,ve,F,Yt):bt(E,x,dn,F,ve,Yt);if(!(b===void 0?E===x||Pr(E,x,qe,bt,Yt):b)){Wt=!1;break}ua||(ua=dn=="constructor")}if(Wt&&!ua){var p=F.constructor,h=ve.constructor;p!=h&&"constructor"in F&&"constructor"in ve&&!(typeof p=="function"&&p instanceof p&&typeof h=="function"&&h instanceof h)&&(Wt=!1)}return Yt.delete(F),Yt.delete(ve),Wt}function Le(F){return No(F,Mi,$t)}function xe(F,ve){var qe=F.__data__;return bn(ve)?qe[typeof ve=="string"?"string":"hash"]:qe.map}function He(F,ve){var qe=mr(F,ve);return ue(qe)?qe:void 0}function it(F){var ve=V.call(F,pe),qe=F[pe];try{F[pe]=void 0;var bt=!0}catch{}var Pr=Fe.call(F);return bt&&(ve?F[pe]=qe:delete F[pe]),Pr}var $t=$e?function(F){return F==null?[]:(F=Object(F),je($e(F),function(ve){return Ee.call(F,ve)}))}:Ep,Ur=Xn;(we&&Ur(new we(new ArrayBuffer(1)))!=Te||K&&Ur(new K)!=L||he&&Ur(he.resolve())!=Me||G&&Ur(new G)!=Pe||de&&Ur(new de)!=_e)&&(Ur=function(F){var ve=Xn(F),qe=ve==re?F.constructor:void 0,bt=qe?T(qe):"";if(bt)switch(bt){case Ye:return Te;case ze:return L;case ct:return Me;case ut:return Pe;case ft:return _e}return ve});function On(F,ve){return ve=ve??s,!!ve&&(typeof F=="number"||tt.test(F))&&F>-1&&F%1==0&&F<ve}function bn(F){var ve=typeof F;return ve=="string"||ve=="number"||ve=="symbol"||ve=="boolean"?F!=="__proto__":F===null}function D(F){return!!ie&&ie in F}function B(F){var ve=F&&F.constructor,qe=typeof ve=="function"&&ve.prototype||Vt;return F===qe}function C(F){return Fe.call(F)}function T(F){if(F!=null){try{return M.call(F)}catch{}try{return F+""}catch{}}return""}function $(F,ve){return F===ve||F!==F&&ve!==ve}var U=An(function(){return arguments}())?An:function(F){return Pi(F)&&V.call(F,"callee")&&!Ee.call(F,"callee")},O=Array.isArray;function Ae(F){return F!=null&&Ot(F.length)&&!nt(F)}var Ce=ae||sw;function Je(F,ve){return As(F,ve)}function nt(F){if(!fn(F))return!1;var ve=Xn(F);return ve==m||ve==k||ve==l||ve==Oe}function Ot(F){return typeof F=="number"&&F>-1&&F%1==0&&F<=s}function fn(F){var ve=typeof F;return F!=null&&(ve=="object"||ve=="function")}function Pi(F){return F!=null&&typeof F=="object"}var Qr=Q?ot(Q):R;function Mi(F){return Ae(F)?Rn(F):A(F)}function Ep(){return[]}function sw(){return!1}t.exports=Je}(Ah,Ah.exports);var bq=Ah.exports,oC={exports:{}},wq=qt,_q=wq(function(){if(typeof ArrayBuffer=="function"){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}}),kq=qt,Sq=Mr,$q=qi,uC=_q,Oh=Object.isExtensible,Tq=kq(function(){Oh(1)}),Cq=Tq||uC?function(e){return!Sq(e)||uC&&$q(e)==="ArrayBuffer"?!1:Oh?Oh(e):!0}:Oh,Eq=qt,lC=!Eq(function(){return Object.isExtensible(Object.preventExtensions({}))}),Iq=Xt,xq=Gt,Rq=_c,Aq=Mr,ny=Hr,Oq=$n.f,cC=ho,Pq=Sg,iy=Cq,Mq=bc,Nq=lC,dC=!1,Ra=Mq("meta"),Lq=0,ay=function(t){Oq(t,Ra,{value:{objectID:"O"+Lq++,weakData:{}}})},Dq=function(t,e){if(!Aq(t))return typeof t=="symbol"?t:(typeof t=="string"?"S":"P")+t;if(!ny(t,Ra)){if(!iy(t))return"F";if(!e)return"E";ay(t)}return t[Ra].objectID},jq=function(t,e){if(!ny(t,Ra)){if(!iy(t))return!0;if(!e)return!1;ay(t)}return t[Ra].weakData},Uq=function(t){return Nq&&dC&&iy(t)&&!ny(t,Ra)&&ay(t),t},Fq=function(){Bq.enable=function(){},dC=!0;var t=cC.f,e=xq([].splice),r={};r[Ra]=1,t(r).length&&(cC.f=function(n){for(var i=t(n),a=0,s=i.length;a<s;a++)if(i[a]===Ra){e(i,a,1);break}return i},Iq({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Pq.f}))},Bq=oC.exports={enable:Fq,fastKey:Dq,getWeakData:jq,onFreeze:Uq};Rq[Ra]=!0;var Ph=oC.exports,zq=Xt,Hq=ur,qq=Gt,fC=Lf,Vq=Tn,Wq=Ph,Zq=Bc,Gq=fs,Kq=Tr,Yq=ki,sy=Mr,oy=qt,Jq=ch,Qq=Zi,Xq=vh,uy=function(t,e,r){var n=t.indexOf("Map")!==-1,i=t.indexOf("Weak")!==-1,a=n?"set":"add",s=Hq[t],o=s&&s.prototype,u=s,l={},c=function(z){var re=qq(o[z]);Vq(o,z,z==="add"?function(Oe){return re(this,Oe===0?0:Oe),this}:z==="delete"?function(Me){return i&&!sy(Me)?!1:re(this,Me===0?0:Me)}:z==="get"?function(Oe){return i&&!sy(Oe)?void 0:re(this,Oe===0?0:Oe)}:z==="has"?function(Oe){return i&&!sy(Oe)?!1:re(this,Oe===0?0:Oe)}:function(Oe,Be){return re(this,Oe===0?0:Oe,Be),this})},d=fC(t,!Kq(s)||!(i||o.forEach&&!oy(function(){new s().entries().next()})));if(d)u=r.getConstructor(e,t,n,a),Wq.enable();else if(fC(t,!0)){var f=new u,m=f[a](i?{}:-0,1)!==f,k=oy(function(){f.has(1)}),L=Jq(function(z){new s(z)}),N=!i&&oy(function(){for(var z=new s,re=5;re--;)z[a](re,re);return!z.has(-0)});L||(u=e(function(z,re){Gq(z,o);var Me=Xq(new s,z,u);return Yq(re)||Zq(re,Me[a],{that:Me,AS_ENTRIES:n}),Me}),u.prototype=o,o.constructor=u),(k||N)&&(c("delete"),c("has"),n&&c("get")),(N||m)&&c(a),i&&o.clear&&delete o.clear}return l[t]=u,zq({global:!0,constructor:!0,forced:u!==s},l),Qq(u,t),i||r.setStrong(u,t,n),u},eV=Tn,Mh=function(t,e,r){for(var n in e)eV(t,n,e[n],r);return t},hC=os,tV=Ki,pC=Mh,rV=ka,nV=fs,iV=ki,aV=Bc,sV=Tm,Nh=hh,oV=Yf,Yc=xr,vC=Ph.fastKey,gC=Wn,mC=gC.set,ly=gC.getterFor,yC={getConstructor:function(t,e,r,n){var i=t(function(l,c){nV(l,a),mC(l,{type:e,index:hC(null),first:void 0,last:void 0,size:0}),Yc||(l.size=0),iV(c)||aV(c,l[n],{that:l,AS_ENTRIES:r})}),a=i.prototype,s=ly(e),o=function(l,c,d){var f=s(l),m=u(l,c),k,L;return m?m.value=d:(f.last=m={index:L=vC(c,!0),key:c,value:d,previous:k=f.last,next:void 0,removed:!1},f.first||(f.first=m),k&&(k.next=m),Yc?f.size++:l.size++,L!=="F"&&(f.index[L]=m)),l},u=function(l,c){var d=s(l),f=vC(c),m;if(f!=="F")return d.index[f];for(m=d.first;m;m=m.next)if(m.key===c)return m};return pC(a,{clear:function(){for(var c=this,d=s(c),f=d.first;f;)f.removed=!0,f.previous&&(f.previous=f.previous.next=void 0),f=f.next;d.first=d.last=void 0,d.index=hC(null),Yc?d.size=0:c.size=0},delete:function(l){var c=this,d=s(c),f=u(c,l);if(f){var m=f.next,k=f.previous;delete d.index[f.index],f.removed=!0,k&&(k.next=m),m&&(m.previous=k),d.first===f&&(d.first=m),d.last===f&&(d.last=k),Yc?d.size--:c.size--}return!!f},forEach:function(c){for(var d=s(this),f=rV(c,arguments.length>1?arguments[1]:void 0),m;m=m?m.next:d.first;)for(f(m.value,m.key,this);m&&m.removed;)m=m.previous},has:function(c){return!!u(this,c)}}),pC(a,r?{get:function(c){var d=u(this,c);return d&&d.value},set:function(c,d){return o(this,c===0?0:c,d)}}:{add:function(c){return o(this,c=c===0?0:c,c)}}),Yc&&tV(a,"size",{configurable:!0,get:function(){return s(this).size}}),i},setStrong:function(t,e,r){var n=e+" Iterator",i=ly(e),a=ly(n);sV(t,e,function(s,o){mC(this,{type:n,target:s,state:i(s),kind:o,last:void 0})},function(){for(var s=a(this),o=s.kind,u=s.last;u&&u.removed;)u=u.previous;return!s.target||!(s.last=u=u?u.next:s.state.first)?(s.target=void 0,Nh(void 0,!0)):Nh(o==="keys"?u.key:o==="values"?u.value:[u.key,u.value],!1)},r?"entries":"values",!r,!0),oV(e)}},uV=uy,lV=yC;uV("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},lV);var Xi={};/*
817
+ */Object.defineProperty(xh,"__esModule",{value:!0});var WH=Zc,ZH=Qi,GH=$a,KH=cs,YH=Rh,JH=Yi,QH=Ji,XH=ii,eq=ds;function Ia(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var rC=Ia(WH),tq=Ia(ZH),rq=Ia(GH),nq=Ia(KH),ko=Ia(YH),iq=Ia(JH),aq=Ia(QH),xa=Ia(XH),sq=Ia(eq),oq;function vs(){}vs.prototype=Object.create(null);function Rr(){Rr.init.call(this)}Rr.EventEmitter=Rr,Rr.usingDomains=!1,Rr.prototype.domain=void 0,Rr.prototype._events=void 0,Rr.prototype._maxListeners=void 0,Rr.defaultMaxListeners=10,Rr.init=function(){this.domain=null,Rr.usingDomains&&oq.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new vs,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Rr.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function nC(t){return t._maxListeners===void 0?Rr.defaultMaxListeners:t._maxListeners}Rr.prototype.getMaxListeners=function(){return nC(this)};function uq(t,e,r){if(e)t.call(r);else for(var n=t.length,i=Kc(t,n),a=0;a<n;++a)i[a].call(r)}function lq(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=Kc(t,i),s=0;s<i;++s)a[s].call(r,n)}function cq(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=Kc(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function dq(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=Kc(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function fq(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=Kc(t,i),s=0;s<i;++s)a[s].apply(r,n)}Rr.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:uq(n,d,this);break;case 2:lq(n,d,this,arguments[1]);break;case 3:cq(n,d,this,arguments[1],arguments[2]);break;case 4:dq(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];fq(n,d,this,a)}return!0};function iC(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new vs,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=nC(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,hq(o)}return t}function hq(t){typeof console.warn=="function"?console.warn(t):console.log(t)}Rr.prototype.addListener=function(e,r){return iC(this,e,r,!1)},Rr.prototype.on=Rr.prototype.addListener,Rr.prototype.prependListener=function(e,r){return iC(this,e,r,!0)};function aC(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}Rr.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,aC(this,e,r)),this},Rr.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,aC(this,e,r)),this},Rr.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new vs:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new vs,this;delete i[e]}else pq(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},Rr.prototype.off=function(t,e){return this.removeListener(t,e)},Rr.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new vs,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new vs:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new vs,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},Rr.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=vq(r):n=[]):n=[],n},Rr.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):sC.call(t,e)},Rr.prototype.listenerCount=sC;function sC(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}Rr.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function pq(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function Kc(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function vq(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function gq(t){var e=mq();return function(){var n=xa.default(t),i;if(e){var a=xa.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return aq.default(this,i)}}function mq(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var yq=function(t){iq.default(r,t);var e=gq(r);function r(){var n;return tq.default(this,r),n=e.call(this),sq.default(nq.default(n),"eventHistory",new Map),n}return rq.default(r,[{key:"on",value:function(i,a){return ko.default(xa.default(r.prototype),"on",this).call(this,i,a)}},{key:"once",value:function(i,a){return ko.default(xa.default(r.prototype),"once",this).call(this,i,a)}},{key:"off",value:function(i,a){return ko.default(xa.default(r.prototype),"off",this).call(this,i,a)}},{key:"emit",value:function(i){for(var a,s=arguments.length,o=new Array(s>1?s-1:0),u=1;u<s;u++)o[u-1]=arguments[u];return this.eventHistory.set(i,o),(a=ko.default(xa.default(r.prototype),"emit",this)).call.apply(a,[this,i].concat(o))}},{key:"addListener",value:function(i,a){return ko.default(xa.default(r.prototype),"addListener",this).call(this,i,a)}},{key:"removeListener",value:function(i,a){return ko.default(xa.default(r.prototype),"removeListener",this).call(this,i,a)}},{key:"addListenerWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0&&a.apply(void 0,rC.default(s)),this.addListener(i,a)}},{key:"onWithReplay",value:function(i,a){return this.addListenerWithReplay(i,a)}},{key:"onceWithReplay",value:function(i,a){var s=this.eventHistory.get(i);return s!==void 0?(a.apply(void 0,rC.default(s)),this):ko.default(xa.default(r.prototype),"once",this).call(this,i,a)}}]),r}(Rr);xh.ReplayEventEmitter=yq;var Ah={exports:{}};Ah.exports,function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,a=2,s=9007199254740991,o="[object Arguments]",u="[object Array]",l="[object AsyncFunction]",c="[object Boolean]",d="[object Date]",f="[object Error]",m="[object Function]",k="[object GeneratorFunction]",L="[object Map]",N="[object Number]",z="[object Null]",re="[object Object]",Me="[object Promise]",Oe="[object Proxy]",Fe="[object RegExp]",Pe="[object Set]",Ze="[object String]",Z="[object Symbol]",Ie="[object Undefined]",_e="[object WeakMap]",se="[object ArrayBuffer]",Te="[object DataView]",te="[object Float32Array]",oe="[object Float64Array]",q="[object Int8Array]",ne="[object Int16Array]",Se="[object Int32Array]",H="[object Uint8Array]",ye="[object Uint8ClampedArray]",ke="[object Uint16Array]",P="[object Uint32Array]",Qe=/[\\^$.*+?()[\]{}|]/g,Ct=/^\[object .+?Constructor\]$/,tt=/^(?:0|[1-9]\d*)$/,De={};De[te]=De[oe]=De[q]=De[ne]=De[Se]=De[H]=De[ye]=De[ke]=De[P]=!0,De[o]=De[u]=De[se]=De[c]=De[Te]=De[d]=De[f]=De[m]=De[L]=De[N]=De[re]=De[Fe]=De[Pe]=De[Ze]=De[_e]=!1;var ce=typeof sn=="object"&&sn&&sn.Object===Object&&sn,Ge=typeof self=="object"&&self&&self.Object===Object&&self,Ue=ce||Ge||Function("return this")(),be=e&&!e.nodeType&&e,ht=be&&!0&&t&&!t.nodeType&&t,Ve=ht&&ht.exports===be,Kt=Ve&&ce.process,Rt=function(){try{return Kt&&Kt.binding&&Kt.binding("util")}catch{}}(),Q=Rt&&Rt.isTypedArray;function je(F,ve){for(var qe=-1,bt=F==null?0:F.length,Pr=0,Yt=[];++qe<bt;){var Fr=F[qe];ve(Fr,qe,F)&&(Yt[Pr++]=Fr)}return Yt}function st(F,ve){for(var qe=-1,bt=ve.length,Pr=F.length;++qe<bt;)F[Pr+qe]=ve[qe];return F}function Re(F,ve){for(var qe=-1,bt=F==null?0:F.length;++qe<bt;)if(ve(F[qe],qe,F))return!0;return!1}function kt(F,ve){for(var qe=-1,bt=Array(F);++qe<F;)bt[qe]=ve(qe);return bt}function ot(F){return function(ve){return F(ve)}}function ar(F,ve){return F.has(ve)}function mr(F,ve){return F==null?void 0:F[ve]}function Xe(F){var ve=-1,qe=Array(F.size);return F.forEach(function(bt,Pr){qe[++ve]=[Pr,bt]}),qe}function Or(F,ve){return function(qe){return F(ve(qe))}}function jr(F){var ve=-1,qe=Array(F.size);return F.forEach(function(bt){qe[++ve]=bt}),qe}var lr=Array.prototype,cr=Function.prototype,Vt=Object.prototype,At=Ue["__core-js_shared__"],M=cr.toString,V=Vt.hasOwnProperty,ie=function(){var F=/[^.]+$/.exec(At&&At.keys&&At.keys.IE_PROTO||"");return F?"Symbol(src)_1."+F:""}(),Be=Vt.toString,lt=RegExp("^"+M.call(V).replace(Qe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),yt=Ve?Ue.Buffer:void 0,Bt=Ue.Symbol,er=Ue.Uint8Array,Ee=Vt.propertyIsEnumerable,Ne=lr.splice,pe=Bt?Bt.toStringTag:void 0,$e=Object.getOwnPropertySymbols,ae=yt?yt.isBuffer:void 0,ge=Or(Object.keys,Object),we=He(Ue,"DataView"),K=He(Ue,"Map"),he=He(Ue,"Promise"),G=He(Ue,"Set"),de=He(Ue,"WeakMap"),X=He(Object,"create"),Ye=T(we),ze=T(K),ct=T(he),ut=T(G),ft=T(de),Et=Bt?Bt.prototype:void 0,It=Et?Et.valueOf:void 0;function _t(F){var ve=-1,qe=F==null?0:F.length;for(this.clear();++ve<qe;){var bt=F[ve];this.set(bt[0],bt[1])}}function St(){this.__data__=X?X(null):{},this.size=0}function xt(F){var ve=this.has(F)&&delete this.__data__[F];return this.size-=ve?1:0,ve}function Dt(F){var ve=this.__data__;if(X){var qe=ve[F];return qe===n?void 0:qe}return V.call(ve,F)?ve[F]:void 0}function rn(F){var ve=this.__data__;return X?ve[F]!==void 0:V.call(ve,F)}function yn(F,ve){var qe=this.__data__;return this.size+=this.has(F)?0:1,qe[F]=X&&ve===void 0?n:ve,this}_t.prototype.clear=St,_t.prototype.delete=xt,_t.prototype.get=Dt,_t.prototype.has=rn,_t.prototype.set=yn;function jt(F){var ve=-1,qe=F==null?0:F.length;for(this.clear();++ve<qe;){var bt=F[ve];this.set(bt[0],bt[1])}}function Fn(){this.__data__=[],this.size=0}function sa(F){var ve=this.__data__,qe=Nr(ve,F);if(qe<0)return!1;var bt=ve.length-1;return qe==bt?ve.pop():Ne.call(ve,qe,1),--this.size,!0}function Ua(F){var ve=this.__data__,qe=Nr(ve,F);return qe<0?void 0:ve[qe][1]}function Jn(F){return Nr(this.__data__,F)>-1}function oa(F,ve){var qe=this.__data__,bt=Nr(qe,F);return bt<0?(++this.size,qe.push([F,ve])):qe[bt][1]=ve,this}jt.prototype.clear=Fn,jt.prototype.delete=sa,jt.prototype.get=Ua,jt.prototype.has=Jn,jt.prototype.set=oa;function Qn(F){var ve=-1,qe=F==null?0:F.length;for(this.clear();++ve<qe;){var bt=F[ve];this.set(bt[0],bt[1])}}function fi(){this.size=0,this.__data__={hash:new _t,map:new(K||jt),string:new _t}}function Fa(F){var ve=xe(this,F).delete(F);return this.size-=ve?1:0,ve}function Jr(F){return xe(this,F).get(F)}function Ai(F){return xe(this,F).has(F)}function Es(F,ve){var qe=xe(this,F),bt=qe.size;return qe.set(F,ve),this.size+=qe.size==bt?0:1,this}Qn.prototype.clear=fi,Qn.prototype.delete=Fa,Qn.prototype.get=Jr,Qn.prototype.has=Ai,Qn.prototype.set=Es;function Oi(F){var ve=-1,qe=F==null?0:F.length;for(this.__data__=new Qn;++ve<qe;)this.add(F[ve])}function Is(F){return this.__data__.set(F,n),this}function Oo(F){return this.__data__.has(F)}Oi.prototype.add=Oi.prototype.push=Is,Oi.prototype.has=Oo;function Bn(F){var ve=this.__data__=new jt(F);this.size=ve.size}function xs(){this.__data__=new jt,this.size=0}function Po(F){var ve=this.__data__,qe=ve.delete(F);return this.size=ve.size,qe}function Mo(F){return this.__data__.get(F)}function cn(F){return this.__data__.has(F)}function Rs(F,ve){var qe=this.__data__;if(qe instanceof jt){var bt=qe.__data__;if(!K||bt.length<r-1)return bt.push([F,ve]),this.size=++qe.size,this;qe=this.__data__=new Qn(bt)}return qe.set(F,ve),this.size=qe.size,this}Bn.prototype.clear=xs,Bn.prototype.delete=Po,Bn.prototype.get=Mo,Bn.prototype.has=cn,Bn.prototype.set=Rs;function Rn(F,ve){var qe=O(F),bt=!qe&&U(F),Pr=!qe&&!bt&&Ce(F),Yt=!qe&&!bt&&!Pr&&Qr(F),Fr=qe||bt||Pr||Yt,Gr=Fr?kt(F.length,String):[],nn=Gr.length;for(var Mt in F)V.call(F,Mt)&&!(Fr&&(Mt=="length"||Pr&&(Mt=="offset"||Mt=="parent")||Yt&&(Mt=="buffer"||Mt=="byteLength"||Mt=="byteOffset")||On(Mt,nn)))&&Gr.push(Mt);return Gr}function Nr(F,ve){for(var qe=F.length;qe--;)if($(F[qe][0],ve))return qe;return-1}function No(F,ve,qe){var bt=ve(F);return O(F)?bt:st(bt,qe(F))}function Xn(F){return F==null?F===void 0?Ie:z:pe&&pe in Object(F)?it(F):C(F)}function An(F){return Pi(F)&&Xn(F)==o}function As(F,ve,qe,bt,Pr){return F===ve?!0:F==null||ve==null||!Pi(F)&&!Pi(ve)?F!==F&&ve!==ve:ee(F,ve,qe,bt,As,Pr)}function ee(F,ve,qe,bt,Pr,Yt){var Fr=O(F),Gr=O(ve),nn=Fr?u:Ur(F),Mt=Gr?u:Ur(ve);nn=nn==o?re:nn,Mt=Mt==o?re:Mt;var wn=nn==re,_n=Mt==re,dn=nn==Mt;if(dn&&Ce(F)){if(!Ce(ve))return!1;Fr=!0,wn=!1}if(dn&&!wn)return Yt||(Yt=new Bn),Fr||Qr(F)?I(F,ve,qe,bt,Pr,Yt):W(F,ve,nn,qe,bt,Pr,Yt);if(!(qe&i)){var zn=wn&&V.call(F,"__wrapped__"),Wt=_n&&V.call(ve,"__wrapped__");if(zn||Wt){var ua=zn?F.value():F,E=Wt?ve.value():ve;return Yt||(Yt=new Bn),Pr(ua,E,qe,bt,Yt)}}return dn?(Yt||(Yt=new Bn),j(F,ve,qe,bt,Pr,Yt)):!1}function ue(F){if(!fn(F)||D(F))return!1;var ve=nt(F)?lt:Ct;return ve.test(T(F))}function R(F){return Pi(F)&&Ot(F.length)&&!!De[Xn(F)]}function A(F){if(!B(F))return ge(F);var ve=[];for(var qe in Object(F))V.call(F,qe)&&qe!="constructor"&&ve.push(qe);return ve}function I(F,ve,qe,bt,Pr,Yt){var Fr=qe&i,Gr=F.length,nn=ve.length;if(Gr!=nn&&!(Fr&&nn>Gr))return!1;var Mt=Yt.get(F);if(Mt&&Yt.get(ve))return Mt==ve;var wn=-1,_n=!0,dn=qe&a?new Oi:void 0;for(Yt.set(F,ve),Yt.set(ve,F);++wn<Gr;){var zn=F[wn],Wt=ve[wn];if(bt)var ua=Fr?bt(Wt,zn,wn,ve,F,Yt):bt(zn,Wt,wn,F,ve,Yt);if(ua!==void 0){if(ua)continue;_n=!1;break}if(dn){if(!Re(ve,function(E,x){if(!ar(dn,x)&&(zn===E||Pr(zn,E,qe,bt,Yt)))return dn.push(x)})){_n=!1;break}}else if(!(zn===Wt||Pr(zn,Wt,qe,bt,Yt))){_n=!1;break}}return Yt.delete(F),Yt.delete(ve),_n}function W(F,ve,qe,bt,Pr,Yt,Fr){switch(qe){case Te:if(F.byteLength!=ve.byteLength||F.byteOffset!=ve.byteOffset)return!1;F=F.buffer,ve=ve.buffer;case se:return!(F.byteLength!=ve.byteLength||!Yt(new er(F),new er(ve)));case c:case d:case N:return $(+F,+ve);case f:return F.name==ve.name&&F.message==ve.message;case Fe:case Ze:return F==ve+"";case L:var Gr=Xe;case Pe:var nn=bt&i;if(Gr||(Gr=jr),F.size!=ve.size&&!nn)return!1;var Mt=Fr.get(F);if(Mt)return Mt==ve;bt|=a,Fr.set(F,ve);var wn=I(Gr(F),Gr(ve),bt,Pr,Yt,Fr);return Fr.delete(F),wn;case Z:if(It)return It.call(F)==It.call(ve)}return!1}function j(F,ve,qe,bt,Pr,Yt){var Fr=qe&i,Gr=Le(F),nn=Gr.length,Mt=Le(ve),wn=Mt.length;if(nn!=wn&&!Fr)return!1;for(var _n=nn;_n--;){var dn=Gr[_n];if(!(Fr?dn in ve:V.call(ve,dn)))return!1}var zn=Yt.get(F);if(zn&&Yt.get(ve))return zn==ve;var Wt=!0;Yt.set(F,ve),Yt.set(ve,F);for(var ua=Fr;++_n<nn;){dn=Gr[_n];var E=F[dn],x=ve[dn];if(bt)var b=Fr?bt(x,E,dn,ve,F,Yt):bt(E,x,dn,F,ve,Yt);if(!(b===void 0?E===x||Pr(E,x,qe,bt,Yt):b)){Wt=!1;break}ua||(ua=dn=="constructor")}if(Wt&&!ua){var p=F.constructor,h=ve.constructor;p!=h&&"constructor"in F&&"constructor"in ve&&!(typeof p=="function"&&p instanceof p&&typeof h=="function"&&h instanceof h)&&(Wt=!1)}return Yt.delete(F),Yt.delete(ve),Wt}function Le(F){return No(F,Mi,$t)}function xe(F,ve){var qe=F.__data__;return bn(ve)?qe[typeof ve=="string"?"string":"hash"]:qe.map}function He(F,ve){var qe=mr(F,ve);return ue(qe)?qe:void 0}function it(F){var ve=V.call(F,pe),qe=F[pe];try{F[pe]=void 0;var bt=!0}catch{}var Pr=Be.call(F);return bt&&(ve?F[pe]=qe:delete F[pe]),Pr}var $t=$e?function(F){return F==null?[]:(F=Object(F),je($e(F),function(ve){return Ee.call(F,ve)}))}:Ep,Ur=Xn;(we&&Ur(new we(new ArrayBuffer(1)))!=Te||K&&Ur(new K)!=L||he&&Ur(he.resolve())!=Me||G&&Ur(new G)!=Pe||de&&Ur(new de)!=_e)&&(Ur=function(F){var ve=Xn(F),qe=ve==re?F.constructor:void 0,bt=qe?T(qe):"";if(bt)switch(bt){case Ye:return Te;case ze:return L;case ct:return Me;case ut:return Pe;case ft:return _e}return ve});function On(F,ve){return ve=ve??s,!!ve&&(typeof F=="number"||tt.test(F))&&F>-1&&F%1==0&&F<ve}function bn(F){var ve=typeof F;return ve=="string"||ve=="number"||ve=="symbol"||ve=="boolean"?F!=="__proto__":F===null}function D(F){return!!ie&&ie in F}function B(F){var ve=F&&F.constructor,qe=typeof ve=="function"&&ve.prototype||Vt;return F===qe}function C(F){return Be.call(F)}function T(F){if(F!=null){try{return M.call(F)}catch{}try{return F+""}catch{}}return""}function $(F,ve){return F===ve||F!==F&&ve!==ve}var U=An(function(){return arguments}())?An:function(F){return Pi(F)&&V.call(F,"callee")&&!Ee.call(F,"callee")},O=Array.isArray;function Ae(F){return F!=null&&Ot(F.length)&&!nt(F)}var Ce=ae||sw;function Je(F,ve){return As(F,ve)}function nt(F){if(!fn(F))return!1;var ve=Xn(F);return ve==m||ve==k||ve==l||ve==Oe}function Ot(F){return typeof F=="number"&&F>-1&&F%1==0&&F<=s}function fn(F){var ve=typeof F;return F!=null&&(ve=="object"||ve=="function")}function Pi(F){return F!=null&&typeof F=="object"}var Qr=Q?ot(Q):R;function Mi(F){return Ae(F)?Rn(F):A(F)}function Ep(){return[]}function sw(){return!1}t.exports=Je}(Ah,Ah.exports);var bq=Ah.exports,oC={exports:{}},wq=qt,_q=wq(function(){if(typeof ArrayBuffer=="function"){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}}),kq=qt,Sq=Mr,$q=qi,uC=_q,Oh=Object.isExtensible,Tq=kq(function(){Oh(1)}),Cq=Tq||uC?function(e){return!Sq(e)||uC&&$q(e)==="ArrayBuffer"?!1:Oh?Oh(e):!0}:Oh,Eq=qt,lC=!Eq(function(){return Object.isExtensible(Object.preventExtensions({}))}),Iq=Xt,xq=Gt,Rq=_c,Aq=Mr,ny=Hr,Oq=$n.f,cC=ho,Pq=Sg,iy=Cq,Mq=bc,Nq=lC,dC=!1,Ra=Mq("meta"),Lq=0,ay=function(t){Oq(t,Ra,{value:{objectID:"O"+Lq++,weakData:{}}})},Dq=function(t,e){if(!Aq(t))return typeof t=="symbol"?t:(typeof t=="string"?"S":"P")+t;if(!ny(t,Ra)){if(!iy(t))return"F";if(!e)return"E";ay(t)}return t[Ra].objectID},jq=function(t,e){if(!ny(t,Ra)){if(!iy(t))return!0;if(!e)return!1;ay(t)}return t[Ra].weakData},Uq=function(t){return Nq&&dC&&iy(t)&&!ny(t,Ra)&&ay(t),t},Fq=function(){Bq.enable=function(){},dC=!0;var t=cC.f,e=xq([].splice),r={};r[Ra]=1,t(r).length&&(cC.f=function(n){for(var i=t(n),a=0,s=i.length;a<s;a++)if(i[a]===Ra){e(i,a,1);break}return i},Iq({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Pq.f}))},Bq=oC.exports={enable:Fq,fastKey:Dq,getWeakData:jq,onFreeze:Uq};Rq[Ra]=!0;var Ph=oC.exports,zq=Xt,Hq=ur,qq=Gt,fC=Lf,Vq=Tn,Wq=Ph,Zq=Bc,Gq=fs,Kq=Tr,Yq=ki,sy=Mr,oy=qt,Jq=ch,Qq=Zi,Xq=vh,uy=function(t,e,r){var n=t.indexOf("Map")!==-1,i=t.indexOf("Weak")!==-1,a=n?"set":"add",s=Hq[t],o=s&&s.prototype,u=s,l={},c=function(z){var re=qq(o[z]);Vq(o,z,z==="add"?function(Oe){return re(this,Oe===0?0:Oe),this}:z==="delete"?function(Me){return i&&!sy(Me)?!1:re(this,Me===0?0:Me)}:z==="get"?function(Oe){return i&&!sy(Oe)?void 0:re(this,Oe===0?0:Oe)}:z==="has"?function(Oe){return i&&!sy(Oe)?!1:re(this,Oe===0?0:Oe)}:function(Oe,Fe){return re(this,Oe===0?0:Oe,Fe),this})},d=fC(t,!Kq(s)||!(i||o.forEach&&!oy(function(){new s().entries().next()})));if(d)u=r.getConstructor(e,t,n,a),Wq.enable();else if(fC(t,!0)){var f=new u,m=f[a](i?{}:-0,1)!==f,k=oy(function(){f.has(1)}),L=Jq(function(z){new s(z)}),N=!i&&oy(function(){for(var z=new s,re=5;re--;)z[a](re,re);return!z.has(-0)});L||(u=e(function(z,re){Gq(z,o);var Me=Xq(new s,z,u);return Yq(re)||Zq(re,Me[a],{that:Me,AS_ENTRIES:n}),Me}),u.prototype=o,o.constructor=u),(k||N)&&(c("delete"),c("has"),n&&c("get")),(N||m)&&c(a),i&&o.clear&&delete o.clear}return l[t]=u,zq({global:!0,constructor:!0,forced:u!==s},l),Qq(u,t),i||r.setStrong(u,t,n),u},eV=Tn,Mh=function(t,e,r){for(var n in e)eV(t,n,e[n],r);return t},hC=os,tV=Ki,pC=Mh,rV=ka,nV=fs,iV=ki,aV=Bc,sV=Tm,Nh=hh,oV=Yf,Yc=xr,vC=Ph.fastKey,gC=Wn,mC=gC.set,ly=gC.getterFor,yC={getConstructor:function(t,e,r,n){var i=t(function(l,c){nV(l,a),mC(l,{type:e,index:hC(null),first:void 0,last:void 0,size:0}),Yc||(l.size=0),iV(c)||aV(c,l[n],{that:l,AS_ENTRIES:r})}),a=i.prototype,s=ly(e),o=function(l,c,d){var f=s(l),m=u(l,c),k,L;return m?m.value=d:(f.last=m={index:L=vC(c,!0),key:c,value:d,previous:k=f.last,next:void 0,removed:!1},f.first||(f.first=m),k&&(k.next=m),Yc?f.size++:l.size++,L!=="F"&&(f.index[L]=m)),l},u=function(l,c){var d=s(l),f=vC(c),m;if(f!=="F")return d.index[f];for(m=d.first;m;m=m.next)if(m.key===c)return m};return pC(a,{clear:function(){for(var c=this,d=s(c),f=d.first;f;)f.removed=!0,f.previous&&(f.previous=f.previous.next=void 0),f=f.next;d.first=d.last=void 0,d.index=hC(null),Yc?d.size=0:c.size=0},delete:function(l){var c=this,d=s(c),f=u(c,l);if(f){var m=f.next,k=f.previous;delete d.index[f.index],f.removed=!0,k&&(k.next=m),m&&(m.previous=k),d.first===f&&(d.first=m),d.last===f&&(d.last=k),Yc?d.size--:c.size--}return!!f},forEach:function(c){for(var d=s(this),f=rV(c,arguments.length>1?arguments[1]:void 0),m;m=m?m.next:d.first;)for(f(m.value,m.key,this);m&&m.removed;)m=m.previous},has:function(c){return!!u(this,c)}}),pC(a,r?{get:function(c){var d=u(this,c);return d&&d.value},set:function(c,d){return o(this,c===0?0:c,d)}}:{add:function(c){return o(this,c=c===0?0:c,c)}}),Yc&&tV(a,"size",{configurable:!0,get:function(){return s(this).size}}),i},setStrong:function(t,e,r){var n=e+" Iterator",i=ly(e),a=ly(n);sV(t,e,function(s,o){mC(this,{type:n,target:s,state:i(s),kind:o,last:void 0})},function(){for(var s=a(this),o=s.kind,u=s.last;u&&u.removed;)u=u.previous;return!s.target||!(s.last=u=u?u.next:s.state.first)?(s.target=void 0,Nh(void 0,!0)):Nh(o==="keys"?u.key:o==="values"?u.value:[u.key,u.value],!1)},r?"entries":"values",!r,!0),oV(e)}},uV=uy,lV=yC;uV("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},lV);var Xi={};/*
818
818
  @license
819
819
  Copyright (c) 2016, Twilio, Inc.
820
820
 
@@ -830,12 +830,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
830
830
  OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
831
831
  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
832
832
 
833
- */Object.defineProperty(Xi,"__esModule",{value:!0});var cV=Qi,dV=$a,fV=cs,hV=Yi,pV=Ji,vV=ii,gV=ds;function So(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var cy=So(cV),dy=So(dV),Aa=So(fV),fy=So(hV),bC=So(pV),Lh=So(vV),Oa=So(gV),mV;function gs(){}gs.prototype=Object.create(null);function wr(){wr.init.call(this)}wr.EventEmitter=wr,wr.usingDomains=!1,wr.prototype.domain=void 0,wr.prototype._events=void 0,wr.prototype._maxListeners=void 0,wr.defaultMaxListeners=10,wr.init=function(){this.domain=null,wr.usingDomains&&mV.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new gs,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},wr.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function wC(t){return t._maxListeners===void 0?wr.defaultMaxListeners:t._maxListeners}wr.prototype.getMaxListeners=function(){return wC(this)};function yV(t,e,r){if(e)t.call(r);else for(var n=t.length,i=Jc(t,n),a=0;a<n;++a)i[a].call(r)}function bV(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=Jc(t,i),s=0;s<i;++s)a[s].call(r,n)}function wV(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=Jc(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function _V(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=Jc(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function kV(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=Jc(t,i),s=0;s<i;++s)a[s].apply(r,n)}wr.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:yV(n,d,this);break;case 2:bV(n,d,this,arguments[1]);break;case 3:wV(n,d,this,arguments[1],arguments[2]);break;case 4:_V(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];kV(n,d,this,a)}return!0};function _C(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new gs,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=wC(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,SV(o)}return t}function SV(t){typeof console.warn=="function"?console.warn(t):console.log(t)}wr.prototype.addListener=function(e,r){return _C(this,e,r,!1)},wr.prototype.on=wr.prototype.addListener,wr.prototype.prependListener=function(e,r){return _C(this,e,r,!0)};function kC(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}wr.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,kC(this,e,r)),this},wr.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,kC(this,e,r)),this},wr.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new gs:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new gs,this;delete i[e]}else $V(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},wr.prototype.off=function(t,e){return this.removeListener(t,e)},wr.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new gs,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new gs:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new gs,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},wr.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=TV(r):n=[]):n=[],n},wr.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):SC.call(t,e)},wr.prototype.listenerCount=SC;function SC(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}wr.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function $V(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function Jc(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function TV(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function $C(t){var e=CV();return function(){var n=Lh.default(t),i;if(e){var a=Lh.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return bC.default(this,i)}}function CV(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var TC=function(t){fy.default(r,t);var e=$C(r);function r(n){var i;return cy.default(this,r),i=e.call(this),Oa.default(Aa.default(i),"timeout",null),Oa.default(Aa.default(i),"startTimestamp",-1),i.minDelay=n.min,i.maxDelay=n.max,i.initialDelay=n.initial||0,i.maxAttemptsCount=n.maxAttemptsCount||0,i.maxAttemptsTime=n.maxAttemptsTime||0,i.randomness=n.randomness||0,i.inProgress=!1,i.attemptNum=0,i.prevDelay=0,i.currDelay=0,i}return dy.default(r,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(i){if(typeof i=="number")return this.prevDelay=0,this.currDelay=i,i;if(this.attemptNum==0)return this.initialDelay;if(this.attemptNum==1)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var a=this.currDelay+this.prevDelay;return this.maxDelay&&a>this.maxDelay&&(this.currDelay=this.maxDelay,a=this.maxDelay),this.currDelay=a,a}},{key:"randomize",value:function(i){var a=i*this.randomness,s=Math.round(Math.random()*a*2-a);return Math.max(0,i+s)}},{key:"scheduleAttempt",value:function(i){var a=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount){this.cleanup(),this.emit("failed",new Error("Maximum attempt count limit reached"));return}var s=this.nextDelay(i);if(s=this.randomize(s),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+s){this.cleanup(),this.emit("failed",new Error("Maximum attempt time limit reached"));return}this.timeout=setTimeout(function(){return a.attempt()},s)}},{key:"cleanup",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}},{key:"start",value:function(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}},{key:"cancel",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}},{key:"succeeded",value:function(i){this.emit("succeeded",i)}},{key:"failed",value:function(i,a){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(a)}}]),r}(wr),EV=function(t){fy.default(r,t);var e=$C(r);function r(n){var i;return cy.default(this,r),i=e.call(this),Oa.default(Aa.default(i),"resolve",function(){}),Oa.default(Aa.default(i),"reject",function(){}),i.retrier=new TC(n),i}return dy.default(r,[{key:"run",value:function(i){var a=this;return this.retrier.on("attempt",function(){i().then(function(s){return a.retrier.succeeded(s)}).catch(function(s){return a.retrier.failed(s)})}),this.retrier.on("succeeded",function(s){return a.resolve(s)}),this.retrier.on("cancelled",function(){return a.reject(new Error("Cancelled"))}),this.retrier.on("failed",function(s){return a.reject(s)}),new Promise(function(s,o){a.resolve=s,a.reject=o,a.retrier.start()})}},{key:"cancel",value:function(){this.retrier.cancel()}}]),r}(wr);function IV(t){var e=xV();return function(){var n=Lh.default(t),i;if(e){var a=Lh.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return bC.default(this,i)}}function xV(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Dh(t){return t!=null}var RV=function(t){fy.default(r,t);var e=IV(r);function r(n){var i;cy.default(this,r),i=e.call(this),Oa.default(Aa.default(i),"backoffDelay",0),Oa.default(Aa.default(i),"nextBackoffDelay",0),Oa.default(Aa.default(i),"backoffNumber",0),Oa.default(Aa.default(i),"timeoutID",null),Oa.default(Aa.default(i),"maxNumberOfRetry",-1),n=n||{};var a=n,s=a.initialDelay,o=a.maxDelay,u=a.randomisationFactor,l=a.factor;if(Dh(s)&&s<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(Dh(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(Dh(u)&&(u<0||u>1))throw new Error("The randomisation factor must be between 0 and 1.");if(Dh(l)&&l<=1)throw new Error("Exponential factor should be greater than 1.");if(i.initialDelay=s||100,i.maxDelay=o||1e4,i.maxDelay<=i.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return i.randomisationFactor=u||0,i.factor=l||2,i.reset(),i}return dy.default(r,[{key:"backoff",value:function(i){this.timeoutID==null&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",i),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,i)))}},{key:"reset",value:function(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}},{key:"failAfter",value:function(i){if(i<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(i));this.maxNumberOfRetry=i}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var i=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*i))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(i){return new r(i)}}]),r}(wr);Xi.AsyncRetrier=EV,Xi.Backoff=RV,Xi.Retrier=TC;var hy={},AV=$r,OV=Hr,PV=ya,MV=cT,CC=RegExp.prototype,NV=function(t){var e=t.flags;return e===void 0&&!("flags"in CC)&&!OV(t,"flags")&&PV(CC,t)?AV(MV,t):e},LV=wc.PROPER,DV=Tn,jV=Wr,EC=Xr,UV=qt,FV=NV,py="toString",IC=RegExp.prototype,xC=IC[py],BV=UV(function(){return xC.call({source:"a",flags:"b"})!=="/a/b"}),zV=LV&&xC.name!==py;(BV||zV)&&DV(IC,py,function(){var e=jV(this),r=EC(e.source),n=EC(FV(e));return"/"+r+"/"+n},{unsafe:!0});var HV=uy,qV=yC;HV("Set",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},qV);var RC={exports:{}};(function(t,e){(function(n,i){t.exports=i()})(sn,function(){return function(r){var n={};function i(a){if(n[a])return n[a].exports;var s=n[a]={i:a,l:!1,exports:{}};return r[a].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=r,i.c=n,i.i=function(a){return a},i.d=function(a,s,o){i.o(a,s)||Object.defineProperty(a,s,{configurable:!1,enumerable:!0,get:o})},i.n=function(a){var s=a&&a.__esModule?function(){return a.default}:function(){return a};return i.d(s,"a",s),s},i.o=function(a,s){return Object.prototype.hasOwnProperty.call(a,s)},i.p="",i(i.s=5)}([function(r,n,i){r.exports=function(a,s){var o,u,l;for(o=1;o<arguments.length;o++){u=arguments[o];for(l in u)u.hasOwnProperty(l)&&(a[l]=u[l])}return a}},function(r,n,i){var a=i(0);r.exports={build:function(s,o){var u,l,c,d=o.plugins;for(u=0,l=d.length;u<l;u++)c=d[u],c.methods&&a(s,c.methods),c.properties&&Object.defineProperties(s,c.properties)},hook:function(s,o,u){var l,c,d,f,m=s.config.plugins,k=[s.context];for(u&&(k=k.concat(u)),l=0,c=m.length;l<c;l++)f=m[l],d=m[l][o],d&&d.apply(f,k)}}},function(r,n,i){function a(s){if(s.length===0)return s;var o,u,l=s.split(/[_-]/);if(l.length===1&&l[0][0].toLowerCase()===l[0][0])return s;for(u=l[0].toLowerCase(),o=1;o<l.length;o++)u=u+l[o].charAt(0).toUpperCase()+l[o].substring(1).toLowerCase();return u}a.prepended=function(s,o){return o=a(o),s+o[0].toUpperCase()+o.substring(1)},r.exports=a},function(r,n,i){var a=i(0),s=i(2);function o(u,l){u=u||{},this.options=u,this.defaults=l.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(u.init),this.data=this.configureData(u.data),this.methods=this.configureMethods(u.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(u.transitions||[]),this.plugins=this.configurePlugins(u.plugins,l.plugin)}a(o.prototype,{addState:function(u){this.map[u]||(this.states.push(u),this.addStateLifecycleNames(u),this.map[u]={})},addStateLifecycleNames:function(u){this.lifecycle.onEnter[u]=s.prepended("onEnter",u),this.lifecycle.onLeave[u]=s.prepended("onLeave",u),this.lifecycle.on[u]=s.prepended("on",u)},addTransition:function(u){this.transitions.indexOf(u)<0&&(this.transitions.push(u),this.addTransitionLifecycleNames(u))},addTransitionLifecycleNames:function(u){this.lifecycle.onBefore[u]=s.prepended("onBefore",u),this.lifecycle.onAfter[u]=s.prepended("onAfter",u),this.lifecycle.on[u]=s.prepended("on",u)},mapTransition:function(u){var l=u.name,c=u.from,d=u.to;return this.addState(c),typeof d!="function"&&this.addState(d),this.addTransition(l),this.map[c][l]=u,u},configureLifecycle:function(){return{onBefore:{transition:"onBeforeTransition"},onAfter:{transition:"onAfterTransition"},onEnter:{state:"onEnterState"},onLeave:{state:"onLeaveState"},on:{transition:"onTransition"}}},configureInitTransition:function(u){return typeof u=="string"?this.mapTransition(a({},this.defaults.init,{to:u,active:!0})):typeof u=="object"?this.mapTransition(a({},this.defaults.init,u,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(u){return typeof u=="function"?u:typeof u=="object"?function(){return u}:function(){return{}}},configureMethods:function(u){return u||{}},configurePlugins:function(u,l){u=u||[];var c,d,f;for(c=0,d=u.length;c<d;c++)f=u[c],typeof f=="function"&&(u[c]=f=f()),f.configure&&f.configure(this);return u},configureTransitions:function(u){var l,c,d,f,m,k=this.defaults.wildcard;for(c=0;c<u.length;c++)for(d=u[c],f=Array.isArray(d.from)?d.from:[d.from||k],m=d.to||k,l=0;l<f.length;l++)this.mapTransition({name:d.name,from:f[l],to:m})},transitionFor:function(u,l){var c=this.defaults.wildcard;return this.map[u][l]||this.map[c][l]},transitionsFor:function(u){var l=this.defaults.wildcard;return Object.keys(this.map[u]).concat(Object.keys(this.map[l]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),r.exports=o},function(r,n,i){var a=i(0),s=i(6),o=i(1),u=[null,[]];function l(c,d){this.context=c,this.config=d,this.state=d.init.from,this.observers=[c]}a(l.prototype,{init:function(c){if(a(this.context,this.config.data.apply(this.context,c)),o.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(c){return Array.isArray(c)?c.indexOf(this.state)>=0:this.state===c},isPending:function(){return this.pending},can:function(c){return!this.isPending()&&!!this.seek(c)},cannot:function(c){return!this.can(c)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(c,d){var f=this.config.defaults.wildcard,m=this.config.transitionFor(this.state,c),k=m&&m.to;return typeof k=="function"?k.apply(this.context,d):k===f?this.state:k},fire:function(c,d){return this.transit(c,this.state,this.seek(c,d),d)},transit:function(c,d,f,m){var k=this.config.lifecycle,L=this.config.options.observeUnchangedState||d!==f;return f?this.isPending()?this.context.onPendingTransition(c,d,f):(this.config.addState(f),this.beginTransit(),m.unshift({transition:c,from:d,to:f,fsm:this.context}),this.observeEvents([this.observersForEvent(k.onBefore.transition),this.observersForEvent(k.onBefore[c]),L?this.observersForEvent(k.onLeave.state):u,L?this.observersForEvent(k.onLeave[d]):u,this.observersForEvent(k.on.transition),L?["doTransit",[this]]:u,L?this.observersForEvent(k.onEnter.state):u,L?this.observersForEvent(k.onEnter[f]):u,L?this.observersForEvent(k.on[f]):u,this.observersForEvent(k.onAfter.transition),this.observersForEvent(k.onAfter[c]),this.observersForEvent(k.on[c])],m)):this.context.onInvalidTransition(c,d,f)},beginTransit:function(){this.pending=!0},endTransit:function(c){return this.pending=!1,c},failTransit:function(c){throw this.pending=!1,c},doTransit:function(c){this.state=c.to},observe:function(c){if(c.length===2){var d={};d[c[0]]=c[1],this.observers.push(d)}else this.observers.push(c[0])},observersForEvent:function(c){for(var d=0,f=this.observers.length,m,k=[];d<f;d++)m=this.observers[d],m[c]&&k.push(m);return[c,k,!0]},observeEvents:function(c,d,f,m){if(c.length===0)return this.endTransit(m===void 0?!0:m);var k=c[0][0],L=c[0][1],N=c[0][2];if(d[0].event=k,k&&N&&k!==f&&o.hook(this,"lifecycle",d),L.length===0)return c.shift(),this.observeEvents(c,d,k,m);var z=L.shift(),re=z[k].apply(z,d);return re&&typeof re.then=="function"?re.then(this.observeEvents.bind(this,c,d,k)).catch(this.failTransit.bind(this)):re===!1?this.endTransit(!1):this.observeEvents(c,d,k,re)},onInvalidTransition:function(c,d,f){throw new s("transition is invalid in current state",c,d,f,this.state)},onPendingTransition:function(c,d,f){throw new s("transition is invalid while previous transition is still in progress",c,d,f,this.state)}}),r.exports=l},function(r,n,i){var a=i(0),s=i(2),o=i(1),u=i(3),l=i(4),c={is:function(N){return this._fsm.is(N)},can:function(N){return this._fsm.can(N)},cannot:function(N){return this._fsm.cannot(N)},observe:function(){return this._fsm.observe(arguments)},transitions:function(){return this._fsm.transitions()},allTransitions:function(){return this._fsm.allTransitions()},allStates:function(){return this._fsm.allStates()},onInvalidTransition:function(N,z,re){return this._fsm.onInvalidTransition(N,z,re)},onPendingTransition:function(N,z,re){return this._fsm.onPendingTransition(N,z,re)}},d={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(N){throw Error("use transitions to change state")}}};function f(N){return k(this||{},N)}function m(){var N,z;typeof arguments[0]=="function"?(N=arguments[0],z=arguments[1]||{}):(N=function(){this._fsm.apply(this,arguments)},z=arguments[0]||{});var re=new u(z,f);return L(N.prototype,re),N.prototype._fsm.config=re,N}function k(N,z){var re=new u(z,f);return L(N,re),N._fsm(),N}function L(N,z){if(typeof N!="object"||Array.isArray(N))throw Error("StateMachine can only be applied to objects");o.build(N,z),Object.defineProperties(N,d),a(N,c),a(N,z.methods),z.allTransitions().forEach(function(re){N[s(re)]=function(){return this._fsm.fire(re,[].slice.call(arguments))}}),N._fsm=function(){this._fsm=new l(this,z),this._fsm.init(arguments)}}f.version="3.0.1",f.factory=m,f.apply=k,f.defaults={wildcard:"*",init:{name:"init",from:"none"}},r.exports=f},function(r,n,i){r.exports=function(a,s,o,u,l){this.message=a,this.transition=s,this.from=o,this.to=u,this.current=l}}])})})(RC);var AC=RC.exports,vy={exports:{}},OC=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(OC){var PC=new Uint8Array(16);vy.exports=function(){return OC(PC),PC}}else{var MC=new Array(16);vy.exports=function(){for(var e=0,r;e<16;e++)e&3||(r=Math.random()*4294967296),MC[e]=r>>>((e&3)<<3)&255;return MC}}for(var NC=vy.exports,LC=[],jh=0;jh<256;++jh)LC[jh]=(jh+256).toString(16).substr(1);function VV(t,e){var r=e||0,n=LC;return[n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]]].join("")}var DC=VV,WV=NC,ZV=DC,jC,gy,my=0,yy=0;function GV(t,e,r){var n=e&&r||0,i=e||[];t=t||{};var a=t.node||jC,s=t.clockseq!==void 0?t.clockseq:gy;if(a==null||s==null){var o=WV();a==null&&(a=jC=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=gy=(o[6]<<8|o[7])&16383)}var u=t.msecs!==void 0?t.msecs:new Date().getTime(),l=t.nsecs!==void 0?t.nsecs:yy+1,c=u-my+(l-yy)/1e4;if(c<0&&t.clockseq===void 0&&(s=s+1&16383),(c<0||u>my)&&t.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");my=u,yy=l,gy=s,u+=122192928e5;var d=((u&268435455)*1e4+l)%4294967296;i[n++]=d>>>24&255,i[n++]=d>>>16&255,i[n++]=d>>>8&255,i[n++]=d&255;var f=u/4294967296*1e4&268435455;i[n++]=f>>>8&255,i[n++]=f&255,i[n++]=f>>>24&15|16,i[n++]=f>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return e||ZV(i)}var KV=GV,YV=NC,JV=DC;function QV(t,e,r){var n=e&&r||0;typeof t=="string"&&(e=t==="binary"?new Array(16):null,t=null),t=t||{};var i=t.random||(t.rng||YV)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e)for(var a=0;a<16;++a)e[n+a]=i[a];return e||JV(i)}var XV=QV,eW=KV,UC=XV,by=UC;by.v1=eW,by.v4=UC;var Qc=by,wy={exports:{}},FC=typeof ArrayBuffer<"u"&&typeof DataView<"u",tW=FC,_y=xr,Cn=ur,BC=Tr,Uh=Mr,ms=Hr,ky=_a,rW=co,nW=ba,Sy=Tn,iW=Ki,aW=ya,Fh=zc,Du=Su,sW=Cr,oW=bc,zC=Wn,HC=zC.enforce,uW=zC.get,Bh=Cn.Int8Array,$y=Bh&&Bh.prototype,qC=Cn.Uint8ClampedArray,VC=qC&&qC.prototype,ea=Bh&&Fh(Bh),Ci=$y&&Fh($y),lW=Object.prototype,Ty=Cn.TypeError,WC=sW("toStringTag"),Cy=oW("TYPED_ARRAY_TAG"),zh="TypedArrayConstructor",Pa=tW&&!!Du&&ky(Cn.opera)!=="Opera",ZC=!1,Dn,ys,ju,Ma={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Ey={BigInt64Array:8,BigUint64Array:8},cW=function(e){if(!Uh(e))return!1;var r=ky(e);return r==="DataView"||ms(Ma,r)||ms(Ey,r)},GC=function(t){var e=Fh(t);if(Uh(e)){var r=uW(e);return r&&ms(r,zh)?r[zh]:GC(e)}},KC=function(t){if(!Uh(t))return!1;var e=ky(t);return ms(Ma,e)||ms(Ey,e)},dW=function(t){if(KC(t))return t;throw new Ty("Target is not a typed array")},fW=function(t){if(BC(t)&&(!Du||aW(ea,t)))return t;throw new Ty(rW(t)+" is not a typed array constructor")},hW=function(t,e,r,n){if(_y){if(r)for(var i in Ma){var a=Cn[i];if(a&&ms(a.prototype,t))try{delete a.prototype[t]}catch{try{a.prototype[t]=e}catch{}}}(!Ci[t]||r)&&Sy(Ci,t,r?e:Pa&&$y[t]||e,n)}},pW=function(t,e,r){var n,i;if(_y){if(Du){if(r){for(n in Ma)if(i=Cn[n],i&&ms(i,t))try{delete i[t]}catch{}}if(!ea[t]||r)try{return Sy(ea,t,r?e:Pa&&ea[t]||e)}catch{}else return}for(n in Ma)i=Cn[n],i&&(!i[t]||r)&&Sy(i,t,e)}};for(Dn in Ma)ys=Cn[Dn],ju=ys&&ys.prototype,ju?HC(ju)[zh]=ys:Pa=!1;for(Dn in Ey)ys=Cn[Dn],ju=ys&&ys.prototype,ju&&(HC(ju)[zh]=ys);if((!Pa||!BC(ea)||ea===Function.prototype)&&(ea=function(){throw new Ty("Incorrect invocation")},Pa))for(Dn in Ma)Cn[Dn]&&Du(Cn[Dn],ea);if((!Pa||!Ci||Ci===lW)&&(Ci=ea.prototype,Pa))for(Dn in Ma)Cn[Dn]&&Du(Cn[Dn].prototype,Ci);if(Pa&&Fh(VC)!==Ci&&Du(VC,Ci),_y&&!ms(Ci,WC)){ZC=!0,iW(Ci,WC,{configurable:!0,get:function(){return Uh(this)?this[Cy]:void 0}});for(Dn in Ma)Cn[Dn]&&nW(Cn[Dn],Cy,Dn)}var Ar={NATIVE_ARRAY_BUFFER_VIEWS:Pa,TYPED_ARRAY_TAG:ZC&&Cy,aTypedArray:dW,aTypedArrayConstructor:fW,exportTypedArrayMethod:hW,exportTypedArrayStaticMethod:pW,getTypedArrayConstructor:GC,isView:cW,isTypedArray:KC,TypedArray:ea,TypedArrayPrototype:Ci},YC=ur,Iy=qt,vW=ch,gW=Ar.NATIVE_ARRAY_BUFFER_VIEWS,mW=YC.ArrayBuffer,$o=YC.Int8Array,yW=!gW||!Iy(function(){$o(1)})||!Iy(function(){new $o(-1)})||!vW(function(t){new $o,new $o(null),new $o(1.5),new $o(t)},!0)||Iy(function(){return new $o(new mW(2),1,void 0).length!==1}),bW=Wi,wW=wa,_W=RangeError,JC=function(t){if(t===void 0)return 0;var e=bW(t),r=wW(e);if(e!==r)throw new _W("Wrong length or index");return r},kW=Math.sign||function(e){var r=+e;return r===0||r!==r?r:r<0?-1:1},SW=kW,$W=Math.abs,QC=2220446049250313e-31,XC=1/QC,TW=function(t){return t+XC-XC},CW=function(t,e,r,n){var i=+t,a=$W(i),s=SW(i);if(a<n)return s*TW(a/n/e)*n*e;var o=(1+e/QC)*a,u=o-(o-a);return u>r||u!==u?s*(1/0):s*u},EW=CW,IW=11920928955078125e-23,xW=34028234663852886e22,RW=11754943508222875e-54,AW=Math.fround||function(e){return EW(e,IW,xW,RW)},OW=Array,PW=Math.abs,Na=Math.pow,MW=Math.floor,NW=Math.log,LW=Math.LN2,DW=function(t,e,r){var n=OW(r),i=r*8-e-1,a=(1<<i)-1,s=a>>1,o=e===23?Na(2,-24)-Na(2,-77):0,u=t<0||t===0&&1/t<0?1:0,l=0,c,d,f;for(t=PW(t),t!==t||t===1/0?(d=t!==t?1:0,c=a):(c=MW(NW(t)/LW),f=Na(2,-c),t*f<1&&(c--,f*=2),c+s>=1?t+=o/f:t+=o*Na(2,1-s),t*f>=2&&(c++,f/=2),c+s>=a?(d=0,c=a):c+s>=1?(d=(t*f-1)*Na(2,e),c+=s):(d=t*Na(2,s-1)*Na(2,e),c=0));e>=8;)n[l++]=d&255,d/=256,e-=8;for(c=c<<e|d,i+=e;i>0;)n[l++]=c&255,c/=256,i-=8;return n[--l]|=u*128,n},jW=function(t,e){var r=t.length,n=r*8-e-1,i=(1<<n)-1,a=i>>1,s=n-7,o=r-1,u=t[o--],l=u&127,c;for(u>>=7;s>0;)l=l*256+t[o--],s-=8;for(c=l&(1<<-s)-1,l>>=-s,s+=e;s>0;)c=c*256+t[o--],s-=8;if(l===0)l=1-a;else{if(l===i)return c?NaN:u?-1/0:1/0;c+=Na(2,e),l-=a}return(u?-1:1)*c*Na(2,l-e)},UW={pack:DW,unpack:jW},FW=vn,eE=yu,BW=gn,tE=function(e){for(var r=FW(this),n=BW(r),i=arguments.length,a=eE(i>1?arguments[1]:void 0,n),s=i>2?arguments[2]:void 0,o=s===void 0?n:eE(s,n);o>a;)r[a++]=e;return r},Hh=ur,xy=Gt,Ry=xr,zW=FC,rE=wc,HW=ba,qW=Ki,nE=Mh,Ay=qt,qh=fs,VW=Wi,WW=wa,Vh=JC,ZW=AW,iE=UW,GW=zc,aE=Su,KW=tE,YW=Gi,JW=vh,QW=fg,sE=Zi,Oy=Wn,XW=rE.PROPER,oE=rE.CONFIGURABLE,Uu="ArrayBuffer",Wh="DataView",Fu="prototype",eZ="Wrong length",uE="Wrong index",lE=Oy.getterFor(Uu),Xc=Oy.getterFor(Wh),cE=Oy.set,Ei=Hh[Uu],Gn=Ei,Bu=Gn&&Gn[Fu],ta=Hh[Wh],To=ta&&ta[Fu],dE=Object.prototype,tZ=Hh.Array,Zh=Hh.RangeError,rZ=xy(KW),nZ=xy([].reverse),fE=iE.pack,hE=iE.unpack,pE=function(t){return[t&255]},vE=function(t){return[t&255,t>>8&255]},gE=function(t){return[t&255,t>>8&255,t>>16&255,t>>24&255]},mE=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},iZ=function(t){return fE(ZW(t),23,4)},aZ=function(t){return fE(t,52,8)},Gh=function(t,e,r){qW(t[Fu],e,{configurable:!0,get:function(){return r(this)[e]}})},bs=function(t,e,r,n){var i=Xc(t),a=Vh(r),s=!!n;if(a+e>i.byteLength)throw new Zh(uE);var o=i.bytes,u=a+i.byteOffset,l=YW(o,u,u+e);return s?l:nZ(l)},ws=function(t,e,r,n,i,a){var s=Xc(t),o=Vh(r),u=n(+i),l=!!a;if(o+e>s.byteLength)throw new Zh(uE);for(var c=s.bytes,d=o+s.byteOffset,f=0;f<e;f++)c[d+f]=u[l?f:e-f-1]};if(!zW)Gn=function(e){qh(this,Bu);var r=Vh(e);cE(this,{type:Uu,bytes:rZ(tZ(r),0),byteLength:r}),Ry||(this.byteLength=r,this.detached=!1)},Bu=Gn[Fu],ta=function(e,r,n){qh(this,To),qh(e,Bu);var i=lE(e),a=i.byteLength,s=VW(r);if(s<0||s>a)throw new Zh("Wrong offset");if(n=n===void 0?a-s:WW(n),s+n>a)throw new Zh(eZ);cE(this,{type:Wh,buffer:e,byteLength:n,byteOffset:s,bytes:i.bytes}),Ry||(this.buffer=e,this.byteLength=n,this.byteOffset=s)},To=ta[Fu],Ry&&(Gh(Gn,"byteLength",lE),Gh(ta,"buffer",Xc),Gh(ta,"byteLength",Xc),Gh(ta,"byteOffset",Xc)),nE(To,{getInt8:function(e){return bs(this,1,e)[0]<<24>>24},getUint8:function(e){return bs(this,1,e)[0]},getInt16:function(e){var r=bs(this,2,e,arguments.length>1?arguments[1]:!1);return(r[1]<<8|r[0])<<16>>16},getUint16:function(e){var r=bs(this,2,e,arguments.length>1?arguments[1]:!1);return r[1]<<8|r[0]},getInt32:function(e){return mE(bs(this,4,e,arguments.length>1?arguments[1]:!1))},getUint32:function(e){return mE(bs(this,4,e,arguments.length>1?arguments[1]:!1))>>>0},getFloat32:function(e){return hE(bs(this,4,e,arguments.length>1?arguments[1]:!1),23)},getFloat64:function(e){return hE(bs(this,8,e,arguments.length>1?arguments[1]:!1),52)},setInt8:function(e,r){ws(this,1,e,pE,r)},setUint8:function(e,r){ws(this,1,e,pE,r)},setInt16:function(e,r){ws(this,2,e,vE,r,arguments.length>2?arguments[2]:!1)},setUint16:function(e,r){ws(this,2,e,vE,r,arguments.length>2?arguments[2]:!1)},setInt32:function(e,r){ws(this,4,e,gE,r,arguments.length>2?arguments[2]:!1)},setUint32:function(e,r){ws(this,4,e,gE,r,arguments.length>2?arguments[2]:!1)},setFloat32:function(e,r){ws(this,4,e,iZ,r,arguments.length>2?arguments[2]:!1)},setFloat64:function(e,r){ws(this,8,e,aZ,r,arguments.length>2?arguments[2]:!1)}});else{var yE=XW&&Ei.name!==Uu;!Ay(function(){Ei(1)})||!Ay(function(){new Ei(-1)})||Ay(function(){return new Ei,new Ei(1.5),new Ei(NaN),Ei.length!==1||yE&&!oE})?(Gn=function(e){return qh(this,Bu),JW(new Ei(Vh(e)),this,Gn)},Gn[Fu]=Bu,Bu.constructor=Gn,QW(Gn,Ei)):yE&&oE&&HW(Ei,"name",Uu),aE&&GW(To)!==dE&&aE(To,dE);var Kh=new ta(new Gn(2)),bE=xy(To.setInt8);Kh.setInt8(0,2147483648),Kh.setInt8(1,2147483649),(Kh.getInt8(0)||!Kh.getInt8(1))&&nE(To,{setInt8:function(e,r){bE(this,e,r<<24>>24)},setUint8:function(e,r){bE(this,e,r<<24>>24)}},{unsafe:!0})}sE(Gn,Uu),sE(ta,Wh);var wE={ArrayBuffer:Gn,DataView:ta},sZ=Wi,oZ=RangeError,uZ=function(t){var e=sZ(t);if(e<0)throw new oZ("The argument can't be less than 0");return e},lZ=uZ,cZ=RangeError,_E=function(t,e){var r=lZ(t);if(r%e)throw new cZ("Wrong offset");return r},dZ=Math.round,fZ=function(t){var e=dZ(t);return e<0?0:e>255?255:e&255},hZ=_a,pZ=function(t){var e=hZ(t);return e==="BigInt64Array"||e==="BigUint64Array"},vZ=Kv,gZ=TypeError,kE=function(t){var e=vZ(t,"number");if(typeof e=="number")throw new gZ("Can't convert number to bigint");return BigInt(e)},mZ=ka,yZ=$r,bZ=gg,wZ=vn,_Z=gn,kZ=uh,SZ=Fc,$Z=gm,TZ=pZ,CZ=Ar.aTypedArrayConstructor,EZ=kE,IZ=function(e){var r=bZ(this),n=wZ(e),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0,o=SZ(n),u,l,c,d,f,m,k,L;if(o&&!$Z(o))for(k=kZ(n,o),L=k.next,n=[];!(m=yZ(L,k)).done;)n.push(m.value);for(s&&i>2&&(a=mZ(a,arguments[2])),l=_Z(n),c=new(CZ(r))(l),d=TZ(c),u=0;l>u;u++)f=s?a(n[u],u):n[u],c[u]=d?EZ(f):+f;return c},xZ=gn,SE=function(t,e,r){for(var n=0,i=arguments.length>2?r:xZ(e),a=new t(i);i>n;)a[n]=e[n++];return a},$E=Xt,TE=ur,CE=$r,RZ=xr,AZ=yW,ed=Ar,EE=wE,IE=fs,OZ=uo,td=ba,PZ=HT,MZ=wa,xE=JC,Py=_E,NZ=fZ,RE=Ef,rd=Hr,LZ=_a,My=Mr,DZ=pu,jZ=os,UZ=ya,Yh=Su,FZ=ho.f,AE=IZ,BZ=Nn.forEach,zZ=Yf,HZ=Ki,OE=$n,PE=ma,ME=SE,Ny=Wn,qZ=vh,Ly=Ny.get,VZ=Ny.set,WZ=Ny.enforce,NE=OE.f,ZZ=PE.f,Dy=TE.RangeError,LE=EE.ArrayBuffer,GZ=LE.prototype,KZ=EE.DataView,Jh=ed.NATIVE_ARRAY_BUFFER_VIEWS,DE=ed.TYPED_ARRAY_TAG,jE=ed.TypedArray,nd=ed.TypedArrayPrototype,jy=ed.isTypedArray,Qh="BYTES_PER_ELEMENT",Uy="Wrong length",Xh=function(t,e){HZ(t,e,{configurable:!0,get:function(){return Ly(this)[e]}})},UE=function(t){var e;return UZ(GZ,t)||(e=LZ(t))==="ArrayBuffer"||e==="SharedArrayBuffer"},FE=function(t,e){return jy(t)&&!DZ(e)&&e in t&&PZ(+e)&&e>=0},BE=function(e,r){return r=RE(r),FE(e,r)?OZ(2,e[r]):ZZ(e,r)},zE=function(e,r,n){return r=RE(r),FE(e,r)&&My(n)&&rd(n,"value")&&!rd(n,"get")&&!rd(n,"set")&&!n.configurable&&(!rd(n,"writable")||n.writable)&&(!rd(n,"enumerable")||n.enumerable)?(e[r]=n.value,e):NE(e,r,n)};RZ?(Jh||(PE.f=BE,OE.f=zE,Xh(nd,"buffer"),Xh(nd,"byteOffset"),Xh(nd,"byteLength"),Xh(nd,"length")),$E({target:"Object",stat:!0,forced:!Jh},{getOwnPropertyDescriptor:BE,defineProperty:zE}),wy.exports=function(t,e,r){var n=t.match(/\d+/)[0]/8,i=t+(r?"Clamped":"")+"Array",a="get"+t,s="set"+t,o=TE[i],u=o,l=u&&u.prototype,c={},d=function(L,N){var z=Ly(L);return z.view[a](N*n+z.byteOffset,!0)},f=function(L,N,z){var re=Ly(L);re.view[s](N*n+re.byteOffset,r?NZ(z):z,!0)},m=function(L,N){NE(L,N,{get:function(){return d(this,N)},set:function(z){return f(this,N,z)},enumerable:!0})};Jh?AZ&&(u=e(function(L,N,z,re){return IE(L,l),qZ(function(){return My(N)?UE(N)?re!==void 0?new o(N,Py(z,n),re):z!==void 0?new o(N,Py(z,n)):new o(N):jy(N)?ME(u,N):CE(AE,u,N):new o(xE(N))}(),L,u)}),Yh&&Yh(u,jE),BZ(FZ(o),function(L){L in u||td(u,L,o[L])}),u.prototype=l):(u=e(function(L,N,z,re){IE(L,l);var Me=0,Oe=0,Be,Pe,Ze;if(!My(N))Ze=xE(N),Pe=Ze*n,Be=new LE(Pe);else if(UE(N)){Be=N,Oe=Py(z,n);var Z=N.byteLength;if(re===void 0){if(Z%n)throw new Dy(Uy);if(Pe=Z-Oe,Pe<0)throw new Dy(Uy)}else if(Pe=MZ(re)*n,Pe+Oe>Z)throw new Dy(Uy);Ze=Pe/n}else return jy(N)?ME(u,N):CE(AE,u,N);for(VZ(L,{buffer:Be,byteOffset:Oe,byteLength:Pe,length:Ze,view:new KZ(Be)});Me<Ze;)m(L,Me++)}),Yh&&Yh(u,jE),l=u.prototype=jZ(nd)),l.constructor!==u&&td(l,"constructor",u),WZ(l).TypedArrayConstructor=u,DE&&td(l,DE,i);var k=u!==o;c[i]=u,$E({global:!0,constructor:!0,forced:k,sham:!Jh},c),Qh in u||td(u,Qh,n),Qh in l||td(l,Qh,n),zZ(i)}):wy.exports=function(){};var YZ=wy.exports,JZ=YZ;JZ("Uint8",function(t){return function(r,n,i){return t(this,r,n,i)}});var HE=Ar,QZ=gn,XZ=Wi,eG=HE.aTypedArray,tG=HE.exportTypedArrayMethod;tG("at",function(e){var r=eG(this),n=QZ(r),i=XZ(e),a=i>=0?i:n+i;return a<0||a>=n?void 0:r[a]});var qE=co,rG=TypeError,Fy=function(t,e){if(!delete t[e])throw new rG("Cannot delete property "+qE(e)+" of "+qE(t))},nG=vn,By=yu,iG=gn,aG=Fy,sG=Math.min,oG=[].copyWithin||function(e,r){var n=nG(this),i=iG(n),a=By(e,i),s=By(r,i),o=arguments.length>2?arguments[2]:void 0,u=sG((o===void 0?i:By(o,i))-s,i-a),l=1;for(s<a&&a<s+u&&(l=-1,s+=u-1,a+=u-1);u-- >0;)s in n?n[a]=n[s]:aG(n,a),a+=l,s+=l;return n},uG=Gt,VE=Ar,lG=oG,cG=uG(lG),dG=VE.aTypedArray,fG=VE.exportTypedArrayMethod;fG("copyWithin",function(e,r){return cG(dG(this),e,r,arguments.length>2?arguments[2]:void 0)});var WE=Ar,hG=Nn.every,pG=WE.aTypedArray,vG=WE.exportTypedArrayMethod;vG("every",function(e){return hG(pG(this),e,arguments.length>1?arguments[1]:void 0)});var ZE=Ar,gG=tE,mG=kE,yG=_a,bG=$r,wG=Gt,_G=qt,kG=ZE.aTypedArray,SG=ZE.exportTypedArrayMethod,$G=wG("".slice),TG=_G(function(){var t=0;return new Int8Array(2).fill({valueOf:function(){return t++}}),t!==1});SG("fill",function(e){var r=arguments.length;kG(this);var n=$G(yG(this),0,3)==="Big"?mG(e):+e;return bG(gG,this,n,r>1?arguments[1]:void 0,r>2?arguments[2]:void 0)},TG);var GE=Ar,CG=qg,EG=GE.aTypedArrayConstructor,IG=GE.getTypedArrayConstructor,ep=function(t){return EG(CG(t,IG(t)))},xG=SE,RG=ep,AG=function(t,e){return xG(RG(t),e)},KE=Ar,OG=Nn.filter,PG=AG,MG=KE.aTypedArray,NG=KE.exportTypedArrayMethod;NG("filter",function(e){var r=OG(MG(this),e,arguments.length>1?arguments[1]:void 0);return PG(this,r)});var YE=Ar,LG=Nn.find,DG=YE.aTypedArray,jG=YE.exportTypedArrayMethod;jG("find",function(e){return LG(DG(this),e,arguments.length>1?arguments[1]:void 0)});var JE=Ar,UG=Nn.findIndex,FG=JE.aTypedArray,BG=JE.exportTypedArrayMethod;BG("findIndex",function(e){return UG(FG(this),e,arguments.length>1?arguments[1]:void 0)});var QE=Ar,zG=Nn.forEach,HG=QE.aTypedArray,qG=QE.exportTypedArrayMethod;qG("forEach",function(e){zG(HG(this),e,arguments.length>1?arguments[1]:void 0)});var XE=Ar,VG=Nf.includes,WG=XE.aTypedArray,ZG=XE.exportTypedArrayMethod;ZG("includes",function(e){return VG(WG(this),e,arguments.length>1?arguments[1]:void 0)});var eI=Ar,GG=Nf.indexOf,KG=eI.aTypedArray,YG=eI.exportTypedArrayMethod;YG("indexOf",function(e){return GG(KG(this),e,arguments.length>1?arguments[1]:void 0)});var JG=ur,QG=qt,zy=Gt,tI=Ar,Hy=Y$,XG=Cr,qy=XG("iterator"),rI=JG.Uint8Array,eK=zy(Hy.values),tK=zy(Hy.keys),rK=zy(Hy.entries),Vy=tI.aTypedArray,tp=tI.exportTypedArrayMethod,zu=rI&&rI.prototype,rp=!QG(function(){zu[qy].call([1])}),nI=!!zu&&zu.values&&zu[qy]===zu.values&&zu.values.name==="values",iI=function(){return eK(Vy(this))};tp("entries",function(){return rK(Vy(this))},rp),tp("keys",function(){return tK(Vy(this))},rp),tp("values",iI,rp||!nI,{name:"values"}),tp(qy,iI,rp||!nI,{name:"values"});var aI=Ar,nK=Gt,iK=aI.aTypedArray,aK=aI.exportTypedArrayMethod,sK=nK([].join);aK("join",function(e){return sK(iK(this),e)});var oK=po,uK=Vn,lK=Wi,cK=gn,dK=Gf,fK=Math.min,Wy=[].lastIndexOf,sI=!!Wy&&1/[1].lastIndexOf(1,-0)<0,hK=dK("lastIndexOf"),pK=sI||!hK,vK=pK?function(e){if(sI)return oK(Wy,this,arguments)||0;var r=uK(this),n=cK(r);if(n===0)return-1;var i=n-1;for(arguments.length>1&&(i=fK(i,lK(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in r&&r[i]===e)return i||0;return-1}:Wy,oI=Ar,gK=po,mK=vK,yK=oI.aTypedArray,bK=oI.exportTypedArrayMethod;bK("lastIndexOf",function(e){var r=arguments.length;return gK(mK,yK(this),r>1?[e,arguments[1]]:[e])});var uI=Ar,wK=Nn.map,_K=ep,kK=uI.aTypedArray,SK=uI.exportTypedArrayMethod;SK("map",function(e){return wK(kK(this),e,arguments.length>1?arguments[1]:void 0,function(r,n){return new(_K(r))(n)})});var $K=ti,TK=vn,CK=yc,EK=gn,lI=TypeError,cI="Reduce of empty array with no initial value",dI=function(t){return function(e,r,n,i){var a=TK(e),s=CK(a),o=EK(a);if($K(r),o===0&&n<2)throw new lI(cI);var u=t?o-1:0,l=t?-1:1;if(n<2)for(;;){if(u in s){i=s[u],u+=l;break}if(u+=l,t?u<0:o<=u)throw new lI(cI)}for(;t?u>=0:o>u;u+=l)u in s&&(i=r(i,s[u],u,a));return i}},fI={left:dI(!1),right:dI(!0)},hI=Ar,IK=fI.left,xK=hI.aTypedArray,RK=hI.exportTypedArrayMethod;RK("reduce",function(e){var r=arguments.length;return IK(xK(this),e,r,r>1?arguments[1]:void 0)});var pI=Ar,AK=fI.right,OK=pI.aTypedArray,PK=pI.exportTypedArrayMethod;PK("reduceRight",function(e){var r=arguments.length;return AK(OK(this),e,r,r>1?arguments[1]:void 0)});var vI=Ar,MK=vI.aTypedArray,NK=vI.exportTypedArrayMethod,LK=Math.floor;NK("reverse",function(){for(var e=this,r=MK(e).length,n=LK(r/2),i=0,a;i<n;)a=e[i],e[i++]=e[--r],e[r]=a;return e});var gI=ur,mI=$r,Zy=Ar,DK=gn,jK=_E,UK=vn,yI=qt,FK=gI.RangeError,Gy=gI.Int8Array,bI=Gy&&Gy.prototype,wI=bI&&bI.set,BK=Zy.aTypedArray,zK=Zy.exportTypedArrayMethod,Ky=!yI(function(){var t=new Uint8ClampedArray(2);return mI(wI,t,{length:1,0:3},1),t[1]!==3}),HK=Ky&&Zy.NATIVE_ARRAY_BUFFER_VIEWS&&yI(function(){var t=new Gy(2);return t.set(1),t.set("2",1),t[0]!==0||t[1]!==2});zK("set",function(e){BK(this);var r=jK(arguments.length>1?arguments[1]:void 0,1),n=UK(e);if(Ky)return mI(wI,this,n,r);var i=this.length,a=DK(n),s=0;if(a+r>i)throw new FK("Wrong length");for(;s<a;)this[r+s]=n[s++]},!Ky||HK);var _I=Ar,qK=ep,VK=qt,WK=Gi,ZK=_I.aTypedArray,GK=_I.exportTypedArrayMethod,KK=VK(function(){new Int8Array(1).slice()});GK("slice",function(e,r){for(var n=WK(ZK(this),e,r),i=qK(this),a=0,s=n.length,o=new i(s);s>a;)o[a]=n[a++];return o},KK);var kI=Ar,YK=Nn.some,JK=kI.aTypedArray,QK=kI.exportTypedArrayMethod;QK("some",function(e){return YK(JK(this),e,arguments.length>1?arguments[1]:void 0)});var SI=Gi,XK=Math.floor,Yy=function(t,e){var r=t.length;if(r<8)for(var n=1,i,a;n<r;){for(a=n,i=t[n];a&&e(t[a-1],i)>0;)t[a]=t[--a];a!==n++&&(t[a]=i)}else for(var s=XK(r/2),o=Yy(SI(t,0,s),e),u=Yy(SI(t,s),e),l=o.length,c=u.length,d=0,f=0;d<l||f<c;)t[d+f]=d<l&&f<c?e(o[d],u[f])<=0?o[d++]:u[f++]:d<l?o[d++]:u[f++];return t},Jy=Yy,eY=lo,$I=eY.match(/firefox\/(\d+)/i),TI=!!$I&&+$I[1],tY=lo,CI=/MSIE|Trident/.test(tY),rY=lo,EI=rY.match(/AppleWebKit\/(\d+)\./),II=!!EI&&+EI[1],nY=ur,iY=Tg,Qy=qt,aY=ti,sY=Jy,xI=Ar,RI=TI,oY=CI,AI=fu,OI=II,uY=xI.aTypedArray,lY=xI.exportTypedArrayMethod,id=nY.Uint16Array,Hu=id&&iY(id.prototype.sort),cY=!!Hu&&!(Qy(function(){Hu(new id(2),null)})&&Qy(function(){Hu(new id(2),{})})),PI=!!Hu&&!Qy(function(){if(AI)return AI<74;if(RI)return RI<67;if(oY)return!0;if(OI)return OI<602;var t=new id(516),e=Array(516),r,n;for(r=0;r<516;r++)n=r%4,t[r]=515-r,e[r]=r-2*n+3;for(Hu(t,function(i,a){return(i/4|0)-(a/4|0)}),r=0;r<516;r++)if(t[r]!==e[r])return!0}),dY=function(t){return function(e,r){return t!==void 0?+t(e,r)||0:r!==r?-1:e!==e?1:e===0&&r===0?1/e>0&&1/r<0?1:-1:e>r}};lY("sort",function(e){return e!==void 0&&aY(e),PI?Hu(this,e):sY(uY(this),dY(e))},!PI||cY);var MI=Ar,fY=wa,NI=yu,hY=ep,pY=MI.aTypedArray,vY=MI.exportTypedArrayMethod;vY("subarray",function(e,r){var n=pY(this),i=n.length,a=NI(e,i),s=hY(n);return new s(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,fY((r===void 0?i:NI(r,i))-a))});var gY=ur,mY=po,LI=Ar,Xy=qt,DI=Gi,np=gY.Int8Array,jI=LI.aTypedArray,yY=LI.exportTypedArrayMethod,UI=[].toLocaleString,bY=!!np&&Xy(function(){UI.call(new np(1))}),wY=Xy(function(){return[1,2].toLocaleString()!==new np([1,2]).toLocaleString()})||!Xy(function(){np.prototype.toLocaleString.call([1,2])});yY("toLocaleString",function(){return mY(UI,bY?DI(jI(this)):jI(this),DI(arguments))},wY);var _Y=Ar.exportTypedArrayMethod,kY=qt,SY=ur,$Y=Gt,FI=SY.Uint8Array,TY=FI&&FI.prototype||{},ip=[].toString,CY=$Y([].join);kY(function(){ip.call({})})&&(ip=function(){return CY(this)});var EY=TY.toString!==ip;_Y("toString",ip,EY);var eb=$r,BI=Gt,IY=_h,xY=Wr,RY=ki,AY=Si,OY=qg,PY=Gm,MY=wa,zI=Xr,NY=fo,HI=kh,LY=dT,DY=qt,qu=LY.UNSUPPORTED_Y,jY=4294967295,UY=Math.min,tb=BI([].push),rb=BI("".slice),FY=!DY(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var r="ab".split(t);return r.length!==2||r[0]!=="a"||r[1]!=="b"}),qI="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;IY("split",function(t,e,r){var n="0".split(void 0,0).length?function(i,a){return i===void 0&&a===0?[]:eb(e,this,i,a)}:e;return[function(a,s){var o=AY(this),u=RY(a)?void 0:NY(a,t);return u?eb(u,a,o,s):eb(n,zI(o),a,s)},function(i,a){var s=xY(this),o=zI(i);if(!qI){var u=r(n,s,o,a,n!==e);if(u.done)return u.value}var l=OY(s,RegExp),c=s.unicode,d=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(qu?"g":"y"),f=new l(qu?"^(?:"+s.source+")":s,d),m=a===void 0?jY:a>>>0;if(m===0)return[];if(o.length===0)return HI(f,o)===null?[o]:[];for(var k=0,L=0,N=[];L<o.length;){f.lastIndex=qu?0:L;var z=HI(f,qu?rb(o,L):o),re;if(z===null||(re=UY(MY(f.lastIndex+(qu?L:0)),o.length))===k)L=PY(o,L,c);else{if(tb(N,rb(o,k,L)),N.length===m)return N;for(var Me=1;Me<=z.length-1;Me++)if(tb(N,z[Me]),N.length===m)return N;L=k=re}}return tb(N,rb(o,k)),N}]},qI||!FY,qu);var VI={exports:{}},WI={exports:{}};(function(t){function e(r){try{return Function.toString.call(r).indexOf("[native code]")!==-1}catch{return typeof r=="function"}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(WI);var BY=WI.exports,ZI={exports:{}},GI={exports:{}};(function(t){function e(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(t.exports=e=function(){return!!r},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(GI);var zY=GI.exports;(function(t){var e=zY,r=Fg;function n(i,a,s){if(e())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,a);var u=new(i.bind.apply(i,o));return s&&r(u,s.prototype),u}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(ZI);var HY=ZI.exports;(function(t){var e=ii,r=Fg,n=BY,i=HY;function a(s){var o=typeof Map=="function"?new Map:void 0;return t.exports=a=function(l){if(l===null||!n(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(l))return o.get(l);o.set(l,c)}function c(){return i(l,arguments,e(this).constructor)}return c.prototype=Object.create(l.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),r(c,l)},t.exports.__esModule=!0,t.exports.default=t.exports,a(s)}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(VI);var ad=VI.exports,ap={exports:{}};/*!
833
+ */Object.defineProperty(Xi,"__esModule",{value:!0});var cV=Qi,dV=$a,fV=cs,hV=Yi,pV=Ji,vV=ii,gV=ds;function So(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}var cy=So(cV),dy=So(dV),Aa=So(fV),fy=So(hV),bC=So(pV),Lh=So(vV),Oa=So(gV),mV;function gs(){}gs.prototype=Object.create(null);function wr(){wr.init.call(this)}wr.EventEmitter=wr,wr.usingDomains=!1,wr.prototype.domain=void 0,wr.prototype._events=void 0,wr.prototype._maxListeners=void 0,wr.defaultMaxListeners=10,wr.init=function(){this.domain=null,wr.usingDomains&&mV.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new gs,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},wr.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function wC(t){return t._maxListeners===void 0?wr.defaultMaxListeners:t._maxListeners}wr.prototype.getMaxListeners=function(){return wC(this)};function yV(t,e,r){if(e)t.call(r);else for(var n=t.length,i=Jc(t,n),a=0;a<n;++a)i[a].call(r)}function bV(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=Jc(t,i),s=0;s<i;++s)a[s].call(r,n)}function wV(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=Jc(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function _V(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=Jc(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function kV(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=Jc(t,i),s=0;s<i;++s)a[s].apply(r,n)}wr.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:yV(n,d,this);break;case 2:bV(n,d,this,arguments[1]);break;case 3:wV(n,d,this,arguments[1],arguments[2]);break;case 4:_V(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];kV(n,d,this,a)}return!0};function _C(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new gs,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=wC(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,SV(o)}return t}function SV(t){typeof console.warn=="function"?console.warn(t):console.log(t)}wr.prototype.addListener=function(e,r){return _C(this,e,r,!1)},wr.prototype.on=wr.prototype.addListener,wr.prototype.prependListener=function(e,r){return _C(this,e,r,!0)};function kC(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}wr.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,kC(this,e,r)),this},wr.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,kC(this,e,r)),this},wr.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new gs:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new gs,this;delete i[e]}else $V(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},wr.prototype.off=function(t,e){return this.removeListener(t,e)},wr.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new gs,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new gs:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new gs,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},wr.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=TV(r):n=[]):n=[],n},wr.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):SC.call(t,e)},wr.prototype.listenerCount=SC;function SC(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}wr.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function $V(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function Jc(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function TV(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function $C(t){var e=CV();return function(){var n=Lh.default(t),i;if(e){var a=Lh.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return bC.default(this,i)}}function CV(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var TC=function(t){fy.default(r,t);var e=$C(r);function r(n){var i;return cy.default(this,r),i=e.call(this),Oa.default(Aa.default(i),"timeout",null),Oa.default(Aa.default(i),"startTimestamp",-1),i.minDelay=n.min,i.maxDelay=n.max,i.initialDelay=n.initial||0,i.maxAttemptsCount=n.maxAttemptsCount||0,i.maxAttemptsTime=n.maxAttemptsTime||0,i.randomness=n.randomness||0,i.inProgress=!1,i.attemptNum=0,i.prevDelay=0,i.currDelay=0,i}return dy.default(r,[{key:"attempt",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.attemptNum++,this.emit("attempt",this)}},{key:"nextDelay",value:function(i){if(typeof i=="number")return this.prevDelay=0,this.currDelay=i,i;if(this.attemptNum==0)return this.initialDelay;if(this.attemptNum==1)return this.currDelay=this.minDelay,this.currDelay;this.prevDelay=this.currDelay;var a=this.currDelay+this.prevDelay;return this.maxDelay&&a>this.maxDelay&&(this.currDelay=this.maxDelay,a=this.maxDelay),this.currDelay=a,a}},{key:"randomize",value:function(i){var a=i*this.randomness,s=Math.round(Math.random()*a*2-a);return Math.max(0,i+s)}},{key:"scheduleAttempt",value:function(i){var a=this;if(this.maxAttemptsCount&&this.attemptNum>=this.maxAttemptsCount){this.cleanup(),this.emit("failed",new Error("Maximum attempt count limit reached"));return}var s=this.nextDelay(i);if(s=this.randomize(s),this.maxAttemptsTime&&this.startTimestamp+this.maxAttemptsTime<Date.now()+s){this.cleanup(),this.emit("failed",new Error("Maximum attempt time limit reached"));return}this.timeout=setTimeout(function(){return a.attempt()},s)}},{key:"cleanup",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null),this.inProgress=!1,this.attemptNum=0,this.prevDelay=0,this.currDelay=0}},{key:"start",value:function(){if(this.inProgress)throw new Error("Retrier is already in progress");this.inProgress=!0,this.startTimestamp=Date.now(),this.scheduleAttempt(this.initialDelay)}},{key:"cancel",value:function(){this.timeout&&(clearTimeout(this.timeout),this.timeout=null,this.inProgress=!1,this.emit("cancelled"))}},{key:"succeeded",value:function(i){this.emit("succeeded",i)}},{key:"failed",value:function(i,a){if(this.timeout)throw new Error("Retrier attempt is already in progress");this.scheduleAttempt(a)}}]),r}(wr),EV=function(t){fy.default(r,t);var e=$C(r);function r(n){var i;return cy.default(this,r),i=e.call(this),Oa.default(Aa.default(i),"resolve",function(){}),Oa.default(Aa.default(i),"reject",function(){}),i.retrier=new TC(n),i}return dy.default(r,[{key:"run",value:function(i){var a=this;return this.retrier.on("attempt",function(){i().then(function(s){return a.retrier.succeeded(s)}).catch(function(s){return a.retrier.failed(s)})}),this.retrier.on("succeeded",function(s){return a.resolve(s)}),this.retrier.on("cancelled",function(){return a.reject(new Error("Cancelled"))}),this.retrier.on("failed",function(s){return a.reject(s)}),new Promise(function(s,o){a.resolve=s,a.reject=o,a.retrier.start()})}},{key:"cancel",value:function(){this.retrier.cancel()}}]),r}(wr);function IV(t){var e=xV();return function(){var n=Lh.default(t),i;if(e){var a=Lh.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return bC.default(this,i)}}function xV(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Dh(t){return t!=null}var RV=function(t){fy.default(r,t);var e=IV(r);function r(n){var i;cy.default(this,r),i=e.call(this),Oa.default(Aa.default(i),"backoffDelay",0),Oa.default(Aa.default(i),"nextBackoffDelay",0),Oa.default(Aa.default(i),"backoffNumber",0),Oa.default(Aa.default(i),"timeoutID",null),Oa.default(Aa.default(i),"maxNumberOfRetry",-1),n=n||{};var a=n,s=a.initialDelay,o=a.maxDelay,u=a.randomisationFactor,l=a.factor;if(Dh(s)&&s<1)throw new Error("The initial timeout must be equal to or greater than 1.");if(Dh(o)&&o<=1)throw new Error("The maximal timeout must be greater than 1.");if(Dh(u)&&(u<0||u>1))throw new Error("The randomisation factor must be between 0 and 1.");if(Dh(l)&&l<=1)throw new Error("Exponential factor should be greater than 1.");if(i.initialDelay=s||100,i.maxDelay=o||1e4,i.maxDelay<=i.initialDelay)throw new Error("The maximal backoff delay must be greater than the initial backoff delay.");return i.randomisationFactor=u||0,i.factor=l||2,i.reset(),i}return dy.default(r,[{key:"backoff",value:function(i){this.timeoutID==null&&(this.backoffNumber===this.maxNumberOfRetry?(this.emit("fail",i),this.reset()):(this.backoffDelay=this.next(),this.timeoutID=setTimeout(this.onBackoff.bind(this),this.backoffDelay),this.emit("backoff",this.backoffNumber,this.backoffDelay,i)))}},{key:"reset",value:function(){this.backoffDelay=0,this.nextBackoffDelay=this.initialDelay,this.backoffNumber=0,this.timeoutID&&clearTimeout(this.timeoutID),this.timeoutID=null}},{key:"failAfter",value:function(i){if(i<=0)throw new Error("Expected a maximum number of retry greater than 0 but got ".concat(i));this.maxNumberOfRetry=i}},{key:"next",value:function(){this.backoffDelay=Math.min(this.nextBackoffDelay,this.maxDelay),this.nextBackoffDelay=this.backoffDelay*this.factor;var i=1+Math.random()*this.randomisationFactor;return Math.min(this.maxDelay,Math.round(this.backoffDelay*i))}},{key:"onBackoff",value:function(){this.timeoutID=null,this.emit("ready",this.backoffNumber,this.backoffDelay),this.backoffNumber++}}],[{key:"exponential",value:function(i){return new r(i)}}]),r}(wr);Xi.AsyncRetrier=EV,Xi.Backoff=RV,Xi.Retrier=TC;var hy={},AV=$r,OV=Hr,PV=ya,MV=cT,CC=RegExp.prototype,NV=function(t){var e=t.flags;return e===void 0&&!("flags"in CC)&&!OV(t,"flags")&&PV(CC,t)?AV(MV,t):e},LV=wc.PROPER,DV=Tn,jV=Wr,EC=Xr,UV=qt,FV=NV,py="toString",IC=RegExp.prototype,xC=IC[py],BV=UV(function(){return xC.call({source:"a",flags:"b"})!=="/a/b"}),zV=LV&&xC.name!==py;(BV||zV)&&DV(IC,py,function(){var e=jV(this),r=EC(e.source),n=EC(FV(e));return"/"+r+"/"+n},{unsafe:!0});var HV=uy,qV=yC;HV("Set",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},qV);var RC={exports:{}};(function(t,e){(function(n,i){t.exports=i()})(sn,function(){return function(r){var n={};function i(a){if(n[a])return n[a].exports;var s=n[a]={i:a,l:!1,exports:{}};return r[a].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=r,i.c=n,i.i=function(a){return a},i.d=function(a,s,o){i.o(a,s)||Object.defineProperty(a,s,{configurable:!1,enumerable:!0,get:o})},i.n=function(a){var s=a&&a.__esModule?function(){return a.default}:function(){return a};return i.d(s,"a",s),s},i.o=function(a,s){return Object.prototype.hasOwnProperty.call(a,s)},i.p="",i(i.s=5)}([function(r,n,i){r.exports=function(a,s){var o,u,l;for(o=1;o<arguments.length;o++){u=arguments[o];for(l in u)u.hasOwnProperty(l)&&(a[l]=u[l])}return a}},function(r,n,i){var a=i(0);r.exports={build:function(s,o){var u,l,c,d=o.plugins;for(u=0,l=d.length;u<l;u++)c=d[u],c.methods&&a(s,c.methods),c.properties&&Object.defineProperties(s,c.properties)},hook:function(s,o,u){var l,c,d,f,m=s.config.plugins,k=[s.context];for(u&&(k=k.concat(u)),l=0,c=m.length;l<c;l++)f=m[l],d=m[l][o],d&&d.apply(f,k)}}},function(r,n,i){function a(s){if(s.length===0)return s;var o,u,l=s.split(/[_-]/);if(l.length===1&&l[0][0].toLowerCase()===l[0][0])return s;for(u=l[0].toLowerCase(),o=1;o<l.length;o++)u=u+l[o].charAt(0).toUpperCase()+l[o].substring(1).toLowerCase();return u}a.prepended=function(s,o){return o=a(o),s+o[0].toUpperCase()+o.substring(1)},r.exports=a},function(r,n,i){var a=i(0),s=i(2);function o(u,l){u=u||{},this.options=u,this.defaults=l.defaults,this.states=[],this.transitions=[],this.map={},this.lifecycle=this.configureLifecycle(),this.init=this.configureInitTransition(u.init),this.data=this.configureData(u.data),this.methods=this.configureMethods(u.methods),this.map[this.defaults.wildcard]={},this.configureTransitions(u.transitions||[]),this.plugins=this.configurePlugins(u.plugins,l.plugin)}a(o.prototype,{addState:function(u){this.map[u]||(this.states.push(u),this.addStateLifecycleNames(u),this.map[u]={})},addStateLifecycleNames:function(u){this.lifecycle.onEnter[u]=s.prepended("onEnter",u),this.lifecycle.onLeave[u]=s.prepended("onLeave",u),this.lifecycle.on[u]=s.prepended("on",u)},addTransition:function(u){this.transitions.indexOf(u)<0&&(this.transitions.push(u),this.addTransitionLifecycleNames(u))},addTransitionLifecycleNames:function(u){this.lifecycle.onBefore[u]=s.prepended("onBefore",u),this.lifecycle.onAfter[u]=s.prepended("onAfter",u),this.lifecycle.on[u]=s.prepended("on",u)},mapTransition:function(u){var l=u.name,c=u.from,d=u.to;return this.addState(c),typeof d!="function"&&this.addState(d),this.addTransition(l),this.map[c][l]=u,u},configureLifecycle:function(){return{onBefore:{transition:"onBeforeTransition"},onAfter:{transition:"onAfterTransition"},onEnter:{state:"onEnterState"},onLeave:{state:"onLeaveState"},on:{transition:"onTransition"}}},configureInitTransition:function(u){return typeof u=="string"?this.mapTransition(a({},this.defaults.init,{to:u,active:!0})):typeof u=="object"?this.mapTransition(a({},this.defaults.init,u,{active:!0})):(this.addState(this.defaults.init.from),this.defaults.init)},configureData:function(u){return typeof u=="function"?u:typeof u=="object"?function(){return u}:function(){return{}}},configureMethods:function(u){return u||{}},configurePlugins:function(u,l){u=u||[];var c,d,f;for(c=0,d=u.length;c<d;c++)f=u[c],typeof f=="function"&&(u[c]=f=f()),f.configure&&f.configure(this);return u},configureTransitions:function(u){var l,c,d,f,m,k=this.defaults.wildcard;for(c=0;c<u.length;c++)for(d=u[c],f=Array.isArray(d.from)?d.from:[d.from||k],m=d.to||k,l=0;l<f.length;l++)this.mapTransition({name:d.name,from:f[l],to:m})},transitionFor:function(u,l){var c=this.defaults.wildcard;return this.map[u][l]||this.map[c][l]},transitionsFor:function(u){var l=this.defaults.wildcard;return Object.keys(this.map[u]).concat(Object.keys(this.map[l]))},allStates:function(){return this.states},allTransitions:function(){return this.transitions}}),r.exports=o},function(r,n,i){var a=i(0),s=i(6),o=i(1),u=[null,[]];function l(c,d){this.context=c,this.config=d,this.state=d.init.from,this.observers=[c]}a(l.prototype,{init:function(c){if(a(this.context,this.config.data.apply(this.context,c)),o.hook(this,"init"),this.config.init.active)return this.fire(this.config.init.name,[])},is:function(c){return Array.isArray(c)?c.indexOf(this.state)>=0:this.state===c},isPending:function(){return this.pending},can:function(c){return!this.isPending()&&!!this.seek(c)},cannot:function(c){return!this.can(c)},allStates:function(){return this.config.allStates()},allTransitions:function(){return this.config.allTransitions()},transitions:function(){return this.config.transitionsFor(this.state)},seek:function(c,d){var f=this.config.defaults.wildcard,m=this.config.transitionFor(this.state,c),k=m&&m.to;return typeof k=="function"?k.apply(this.context,d):k===f?this.state:k},fire:function(c,d){return this.transit(c,this.state,this.seek(c,d),d)},transit:function(c,d,f,m){var k=this.config.lifecycle,L=this.config.options.observeUnchangedState||d!==f;return f?this.isPending()?this.context.onPendingTransition(c,d,f):(this.config.addState(f),this.beginTransit(),m.unshift({transition:c,from:d,to:f,fsm:this.context}),this.observeEvents([this.observersForEvent(k.onBefore.transition),this.observersForEvent(k.onBefore[c]),L?this.observersForEvent(k.onLeave.state):u,L?this.observersForEvent(k.onLeave[d]):u,this.observersForEvent(k.on.transition),L?["doTransit",[this]]:u,L?this.observersForEvent(k.onEnter.state):u,L?this.observersForEvent(k.onEnter[f]):u,L?this.observersForEvent(k.on[f]):u,this.observersForEvent(k.onAfter.transition),this.observersForEvent(k.onAfter[c]),this.observersForEvent(k.on[c])],m)):this.context.onInvalidTransition(c,d,f)},beginTransit:function(){this.pending=!0},endTransit:function(c){return this.pending=!1,c},failTransit:function(c){throw this.pending=!1,c},doTransit:function(c){this.state=c.to},observe:function(c){if(c.length===2){var d={};d[c[0]]=c[1],this.observers.push(d)}else this.observers.push(c[0])},observersForEvent:function(c){for(var d=0,f=this.observers.length,m,k=[];d<f;d++)m=this.observers[d],m[c]&&k.push(m);return[c,k,!0]},observeEvents:function(c,d,f,m){if(c.length===0)return this.endTransit(m===void 0?!0:m);var k=c[0][0],L=c[0][1],N=c[0][2];if(d[0].event=k,k&&N&&k!==f&&o.hook(this,"lifecycle",d),L.length===0)return c.shift(),this.observeEvents(c,d,k,m);var z=L.shift(),re=z[k].apply(z,d);return re&&typeof re.then=="function"?re.then(this.observeEvents.bind(this,c,d,k)).catch(this.failTransit.bind(this)):re===!1?this.endTransit(!1):this.observeEvents(c,d,k,re)},onInvalidTransition:function(c,d,f){throw new s("transition is invalid in current state",c,d,f,this.state)},onPendingTransition:function(c,d,f){throw new s("transition is invalid while previous transition is still in progress",c,d,f,this.state)}}),r.exports=l},function(r,n,i){var a=i(0),s=i(2),o=i(1),u=i(3),l=i(4),c={is:function(N){return this._fsm.is(N)},can:function(N){return this._fsm.can(N)},cannot:function(N){return this._fsm.cannot(N)},observe:function(){return this._fsm.observe(arguments)},transitions:function(){return this._fsm.transitions()},allTransitions:function(){return this._fsm.allTransitions()},allStates:function(){return this._fsm.allStates()},onInvalidTransition:function(N,z,re){return this._fsm.onInvalidTransition(N,z,re)},onPendingTransition:function(N,z,re){return this._fsm.onPendingTransition(N,z,re)}},d={state:{configurable:!1,enumerable:!0,get:function(){return this._fsm.state},set:function(N){throw Error("use transitions to change state")}}};function f(N){return k(this||{},N)}function m(){var N,z;typeof arguments[0]=="function"?(N=arguments[0],z=arguments[1]||{}):(N=function(){this._fsm.apply(this,arguments)},z=arguments[0]||{});var re=new u(z,f);return L(N.prototype,re),N.prototype._fsm.config=re,N}function k(N,z){var re=new u(z,f);return L(N,re),N._fsm(),N}function L(N,z){if(typeof N!="object"||Array.isArray(N))throw Error("StateMachine can only be applied to objects");o.build(N,z),Object.defineProperties(N,d),a(N,c),a(N,z.methods),z.allTransitions().forEach(function(re){N[s(re)]=function(){return this._fsm.fire(re,[].slice.call(arguments))}}),N._fsm=function(){this._fsm=new l(this,z),this._fsm.init(arguments)}}f.version="3.0.1",f.factory=m,f.apply=k,f.defaults={wildcard:"*",init:{name:"init",from:"none"}},r.exports=f},function(r,n,i){r.exports=function(a,s,o,u,l){this.message=a,this.transition=s,this.from=o,this.to=u,this.current=l}}])})})(RC);var AC=RC.exports,vy={exports:{}},OC=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(OC){var PC=new Uint8Array(16);vy.exports=function(){return OC(PC),PC}}else{var MC=new Array(16);vy.exports=function(){for(var e=0,r;e<16;e++)e&3||(r=Math.random()*4294967296),MC[e]=r>>>((e&3)<<3)&255;return MC}}for(var NC=vy.exports,LC=[],jh=0;jh<256;++jh)LC[jh]=(jh+256).toString(16).substr(1);function VV(t,e){var r=e||0,n=LC;return[n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],"-",n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]],n[t[r++]]].join("")}var DC=VV,WV=NC,ZV=DC,jC,gy,my=0,yy=0;function GV(t,e,r){var n=e&&r||0,i=e||[];t=t||{};var a=t.node||jC,s=t.clockseq!==void 0?t.clockseq:gy;if(a==null||s==null){var o=WV();a==null&&(a=jC=[o[0]|1,o[1],o[2],o[3],o[4],o[5]]),s==null&&(s=gy=(o[6]<<8|o[7])&16383)}var u=t.msecs!==void 0?t.msecs:new Date().getTime(),l=t.nsecs!==void 0?t.nsecs:yy+1,c=u-my+(l-yy)/1e4;if(c<0&&t.clockseq===void 0&&(s=s+1&16383),(c<0||u>my)&&t.nsecs===void 0&&(l=0),l>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");my=u,yy=l,gy=s,u+=122192928e5;var d=((u&268435455)*1e4+l)%4294967296;i[n++]=d>>>24&255,i[n++]=d>>>16&255,i[n++]=d>>>8&255,i[n++]=d&255;var f=u/4294967296*1e4&268435455;i[n++]=f>>>8&255,i[n++]=f&255,i[n++]=f>>>24&15|16,i[n++]=f>>>16&255,i[n++]=s>>>8|128,i[n++]=s&255;for(var m=0;m<6;++m)i[n+m]=a[m];return e||ZV(i)}var KV=GV,YV=NC,JV=DC;function QV(t,e,r){var n=e&&r||0;typeof t=="string"&&(e=t==="binary"?new Array(16):null,t=null),t=t||{};var i=t.random||(t.rng||YV)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e)for(var a=0;a<16;++a)e[n+a]=i[a];return e||JV(i)}var XV=QV,eW=KV,UC=XV,by=UC;by.v1=eW,by.v4=UC;var Qc=by,wy={exports:{}},FC=typeof ArrayBuffer<"u"&&typeof DataView<"u",tW=FC,_y=xr,Cn=ur,BC=Tr,Uh=Mr,ms=Hr,ky=_a,rW=co,nW=ba,Sy=Tn,iW=Ki,aW=ya,Fh=zc,Du=Su,sW=Cr,oW=bc,zC=Wn,HC=zC.enforce,uW=zC.get,Bh=Cn.Int8Array,$y=Bh&&Bh.prototype,qC=Cn.Uint8ClampedArray,VC=qC&&qC.prototype,ea=Bh&&Fh(Bh),Ci=$y&&Fh($y),lW=Object.prototype,Ty=Cn.TypeError,WC=sW("toStringTag"),Cy=oW("TYPED_ARRAY_TAG"),zh="TypedArrayConstructor",Pa=tW&&!!Du&&ky(Cn.opera)!=="Opera",ZC=!1,Dn,ys,ju,Ma={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},Ey={BigInt64Array:8,BigUint64Array:8},cW=function(e){if(!Uh(e))return!1;var r=ky(e);return r==="DataView"||ms(Ma,r)||ms(Ey,r)},GC=function(t){var e=Fh(t);if(Uh(e)){var r=uW(e);return r&&ms(r,zh)?r[zh]:GC(e)}},KC=function(t){if(!Uh(t))return!1;var e=ky(t);return ms(Ma,e)||ms(Ey,e)},dW=function(t){if(KC(t))return t;throw new Ty("Target is not a typed array")},fW=function(t){if(BC(t)&&(!Du||aW(ea,t)))return t;throw new Ty(rW(t)+" is not a typed array constructor")},hW=function(t,e,r,n){if(_y){if(r)for(var i in Ma){var a=Cn[i];if(a&&ms(a.prototype,t))try{delete a.prototype[t]}catch{try{a.prototype[t]=e}catch{}}}(!Ci[t]||r)&&Sy(Ci,t,r?e:Pa&&$y[t]||e,n)}},pW=function(t,e,r){var n,i;if(_y){if(Du){if(r){for(n in Ma)if(i=Cn[n],i&&ms(i,t))try{delete i[t]}catch{}}if(!ea[t]||r)try{return Sy(ea,t,r?e:Pa&&ea[t]||e)}catch{}else return}for(n in Ma)i=Cn[n],i&&(!i[t]||r)&&Sy(i,t,e)}};for(Dn in Ma)ys=Cn[Dn],ju=ys&&ys.prototype,ju?HC(ju)[zh]=ys:Pa=!1;for(Dn in Ey)ys=Cn[Dn],ju=ys&&ys.prototype,ju&&(HC(ju)[zh]=ys);if((!Pa||!BC(ea)||ea===Function.prototype)&&(ea=function(){throw new Ty("Incorrect invocation")},Pa))for(Dn in Ma)Cn[Dn]&&Du(Cn[Dn],ea);if((!Pa||!Ci||Ci===lW)&&(Ci=ea.prototype,Pa))for(Dn in Ma)Cn[Dn]&&Du(Cn[Dn].prototype,Ci);if(Pa&&Fh(VC)!==Ci&&Du(VC,Ci),_y&&!ms(Ci,WC)){ZC=!0,iW(Ci,WC,{configurable:!0,get:function(){return Uh(this)?this[Cy]:void 0}});for(Dn in Ma)Cn[Dn]&&nW(Cn[Dn],Cy,Dn)}var Ar={NATIVE_ARRAY_BUFFER_VIEWS:Pa,TYPED_ARRAY_TAG:ZC&&Cy,aTypedArray:dW,aTypedArrayConstructor:fW,exportTypedArrayMethod:hW,exportTypedArrayStaticMethod:pW,getTypedArrayConstructor:GC,isView:cW,isTypedArray:KC,TypedArray:ea,TypedArrayPrototype:Ci},YC=ur,Iy=qt,vW=ch,gW=Ar.NATIVE_ARRAY_BUFFER_VIEWS,mW=YC.ArrayBuffer,$o=YC.Int8Array,yW=!gW||!Iy(function(){$o(1)})||!Iy(function(){new $o(-1)})||!vW(function(t){new $o,new $o(null),new $o(1.5),new $o(t)},!0)||Iy(function(){return new $o(new mW(2),1,void 0).length!==1}),bW=Wi,wW=wa,_W=RangeError,JC=function(t){if(t===void 0)return 0;var e=bW(t),r=wW(e);if(e!==r)throw new _W("Wrong length or index");return r},kW=Math.sign||function(e){var r=+e;return r===0||r!==r?r:r<0?-1:1},SW=kW,$W=Math.abs,QC=2220446049250313e-31,XC=1/QC,TW=function(t){return t+XC-XC},CW=function(t,e,r,n){var i=+t,a=$W(i),s=SW(i);if(a<n)return s*TW(a/n/e)*n*e;var o=(1+e/QC)*a,u=o-(o-a);return u>r||u!==u?s*(1/0):s*u},EW=CW,IW=11920928955078125e-23,xW=34028234663852886e22,RW=11754943508222875e-54,AW=Math.fround||function(e){return EW(e,IW,xW,RW)},OW=Array,PW=Math.abs,Na=Math.pow,MW=Math.floor,NW=Math.log,LW=Math.LN2,DW=function(t,e,r){var n=OW(r),i=r*8-e-1,a=(1<<i)-1,s=a>>1,o=e===23?Na(2,-24)-Na(2,-77):0,u=t<0||t===0&&1/t<0?1:0,l=0,c,d,f;for(t=PW(t),t!==t||t===1/0?(d=t!==t?1:0,c=a):(c=MW(NW(t)/LW),f=Na(2,-c),t*f<1&&(c--,f*=2),c+s>=1?t+=o/f:t+=o*Na(2,1-s),t*f>=2&&(c++,f/=2),c+s>=a?(d=0,c=a):c+s>=1?(d=(t*f-1)*Na(2,e),c+=s):(d=t*Na(2,s-1)*Na(2,e),c=0));e>=8;)n[l++]=d&255,d/=256,e-=8;for(c=c<<e|d,i+=e;i>0;)n[l++]=c&255,c/=256,i-=8;return n[--l]|=u*128,n},jW=function(t,e){var r=t.length,n=r*8-e-1,i=(1<<n)-1,a=i>>1,s=n-7,o=r-1,u=t[o--],l=u&127,c;for(u>>=7;s>0;)l=l*256+t[o--],s-=8;for(c=l&(1<<-s)-1,l>>=-s,s+=e;s>0;)c=c*256+t[o--],s-=8;if(l===0)l=1-a;else{if(l===i)return c?NaN:u?-1/0:1/0;c+=Na(2,e),l-=a}return(u?-1:1)*c*Na(2,l-e)},UW={pack:DW,unpack:jW},FW=vn,eE=yu,BW=gn,tE=function(e){for(var r=FW(this),n=BW(r),i=arguments.length,a=eE(i>1?arguments[1]:void 0,n),s=i>2?arguments[2]:void 0,o=s===void 0?n:eE(s,n);o>a;)r[a++]=e;return r},Hh=ur,xy=Gt,Ry=xr,zW=FC,rE=wc,HW=ba,qW=Ki,nE=Mh,Ay=qt,qh=fs,VW=Wi,WW=wa,Vh=JC,ZW=AW,iE=UW,GW=zc,aE=Su,KW=tE,YW=Gi,JW=vh,QW=fg,sE=Zi,Oy=Wn,XW=rE.PROPER,oE=rE.CONFIGURABLE,Uu="ArrayBuffer",Wh="DataView",Fu="prototype",eZ="Wrong length",uE="Wrong index",lE=Oy.getterFor(Uu),Xc=Oy.getterFor(Wh),cE=Oy.set,Ei=Hh[Uu],Gn=Ei,Bu=Gn&&Gn[Fu],ta=Hh[Wh],To=ta&&ta[Fu],dE=Object.prototype,tZ=Hh.Array,Zh=Hh.RangeError,rZ=xy(KW),nZ=xy([].reverse),fE=iE.pack,hE=iE.unpack,pE=function(t){return[t&255]},vE=function(t){return[t&255,t>>8&255]},gE=function(t){return[t&255,t>>8&255,t>>16&255,t>>24&255]},mE=function(t){return t[3]<<24|t[2]<<16|t[1]<<8|t[0]},iZ=function(t){return fE(ZW(t),23,4)},aZ=function(t){return fE(t,52,8)},Gh=function(t,e,r){qW(t[Fu],e,{configurable:!0,get:function(){return r(this)[e]}})},bs=function(t,e,r,n){var i=Xc(t),a=Vh(r),s=!!n;if(a+e>i.byteLength)throw new Zh(uE);var o=i.bytes,u=a+i.byteOffset,l=YW(o,u,u+e);return s?l:nZ(l)},ws=function(t,e,r,n,i,a){var s=Xc(t),o=Vh(r),u=n(+i),l=!!a;if(o+e>s.byteLength)throw new Zh(uE);for(var c=s.bytes,d=o+s.byteOffset,f=0;f<e;f++)c[d+f]=u[l?f:e-f-1]};if(!zW)Gn=function(e){qh(this,Bu);var r=Vh(e);cE(this,{type:Uu,bytes:rZ(tZ(r),0),byteLength:r}),Ry||(this.byteLength=r,this.detached=!1)},Bu=Gn[Fu],ta=function(e,r,n){qh(this,To),qh(e,Bu);var i=lE(e),a=i.byteLength,s=VW(r);if(s<0||s>a)throw new Zh("Wrong offset");if(n=n===void 0?a-s:WW(n),s+n>a)throw new Zh(eZ);cE(this,{type:Wh,buffer:e,byteLength:n,byteOffset:s,bytes:i.bytes}),Ry||(this.buffer=e,this.byteLength=n,this.byteOffset=s)},To=ta[Fu],Ry&&(Gh(Gn,"byteLength",lE),Gh(ta,"buffer",Xc),Gh(ta,"byteLength",Xc),Gh(ta,"byteOffset",Xc)),nE(To,{getInt8:function(e){return bs(this,1,e)[0]<<24>>24},getUint8:function(e){return bs(this,1,e)[0]},getInt16:function(e){var r=bs(this,2,e,arguments.length>1?arguments[1]:!1);return(r[1]<<8|r[0])<<16>>16},getUint16:function(e){var r=bs(this,2,e,arguments.length>1?arguments[1]:!1);return r[1]<<8|r[0]},getInt32:function(e){return mE(bs(this,4,e,arguments.length>1?arguments[1]:!1))},getUint32:function(e){return mE(bs(this,4,e,arguments.length>1?arguments[1]:!1))>>>0},getFloat32:function(e){return hE(bs(this,4,e,arguments.length>1?arguments[1]:!1),23)},getFloat64:function(e){return hE(bs(this,8,e,arguments.length>1?arguments[1]:!1),52)},setInt8:function(e,r){ws(this,1,e,pE,r)},setUint8:function(e,r){ws(this,1,e,pE,r)},setInt16:function(e,r){ws(this,2,e,vE,r,arguments.length>2?arguments[2]:!1)},setUint16:function(e,r){ws(this,2,e,vE,r,arguments.length>2?arguments[2]:!1)},setInt32:function(e,r){ws(this,4,e,gE,r,arguments.length>2?arguments[2]:!1)},setUint32:function(e,r){ws(this,4,e,gE,r,arguments.length>2?arguments[2]:!1)},setFloat32:function(e,r){ws(this,4,e,iZ,r,arguments.length>2?arguments[2]:!1)},setFloat64:function(e,r){ws(this,8,e,aZ,r,arguments.length>2?arguments[2]:!1)}});else{var yE=XW&&Ei.name!==Uu;!Ay(function(){Ei(1)})||!Ay(function(){new Ei(-1)})||Ay(function(){return new Ei,new Ei(1.5),new Ei(NaN),Ei.length!==1||yE&&!oE})?(Gn=function(e){return qh(this,Bu),JW(new Ei(Vh(e)),this,Gn)},Gn[Fu]=Bu,Bu.constructor=Gn,QW(Gn,Ei)):yE&&oE&&HW(Ei,"name",Uu),aE&&GW(To)!==dE&&aE(To,dE);var Kh=new ta(new Gn(2)),bE=xy(To.setInt8);Kh.setInt8(0,2147483648),Kh.setInt8(1,2147483649),(Kh.getInt8(0)||!Kh.getInt8(1))&&nE(To,{setInt8:function(e,r){bE(this,e,r<<24>>24)},setUint8:function(e,r){bE(this,e,r<<24>>24)}},{unsafe:!0})}sE(Gn,Uu),sE(ta,Wh);var wE={ArrayBuffer:Gn,DataView:ta},sZ=Wi,oZ=RangeError,uZ=function(t){var e=sZ(t);if(e<0)throw new oZ("The argument can't be less than 0");return e},lZ=uZ,cZ=RangeError,_E=function(t,e){var r=lZ(t);if(r%e)throw new cZ("Wrong offset");return r},dZ=Math.round,fZ=function(t){var e=dZ(t);return e<0?0:e>255?255:e&255},hZ=_a,pZ=function(t){var e=hZ(t);return e==="BigInt64Array"||e==="BigUint64Array"},vZ=Kv,gZ=TypeError,kE=function(t){var e=vZ(t,"number");if(typeof e=="number")throw new gZ("Can't convert number to bigint");return BigInt(e)},mZ=ka,yZ=$r,bZ=gg,wZ=vn,_Z=gn,kZ=uh,SZ=Fc,$Z=gm,TZ=pZ,CZ=Ar.aTypedArrayConstructor,EZ=kE,IZ=function(e){var r=bZ(this),n=wZ(e),i=arguments.length,a=i>1?arguments[1]:void 0,s=a!==void 0,o=SZ(n),u,l,c,d,f,m,k,L;if(o&&!$Z(o))for(k=kZ(n,o),L=k.next,n=[];!(m=yZ(L,k)).done;)n.push(m.value);for(s&&i>2&&(a=mZ(a,arguments[2])),l=_Z(n),c=new(CZ(r))(l),d=TZ(c),u=0;l>u;u++)f=s?a(n[u],u):n[u],c[u]=d?EZ(f):+f;return c},xZ=gn,SE=function(t,e,r){for(var n=0,i=arguments.length>2?r:xZ(e),a=new t(i);i>n;)a[n]=e[n++];return a},$E=Xt,TE=ur,CE=$r,RZ=xr,AZ=yW,ed=Ar,EE=wE,IE=fs,OZ=uo,td=ba,PZ=HT,MZ=wa,xE=JC,Py=_E,NZ=fZ,RE=Ef,rd=Hr,LZ=_a,My=Mr,DZ=pu,jZ=os,UZ=ya,Yh=Su,FZ=ho.f,AE=IZ,BZ=Nn.forEach,zZ=Yf,HZ=Ki,OE=$n,PE=ma,ME=SE,Ny=Wn,qZ=vh,Ly=Ny.get,VZ=Ny.set,WZ=Ny.enforce,NE=OE.f,ZZ=PE.f,Dy=TE.RangeError,LE=EE.ArrayBuffer,GZ=LE.prototype,KZ=EE.DataView,Jh=ed.NATIVE_ARRAY_BUFFER_VIEWS,DE=ed.TYPED_ARRAY_TAG,jE=ed.TypedArray,nd=ed.TypedArrayPrototype,jy=ed.isTypedArray,Qh="BYTES_PER_ELEMENT",Uy="Wrong length",Xh=function(t,e){HZ(t,e,{configurable:!0,get:function(){return Ly(this)[e]}})},UE=function(t){var e;return UZ(GZ,t)||(e=LZ(t))==="ArrayBuffer"||e==="SharedArrayBuffer"},FE=function(t,e){return jy(t)&&!DZ(e)&&e in t&&PZ(+e)&&e>=0},BE=function(e,r){return r=RE(r),FE(e,r)?OZ(2,e[r]):ZZ(e,r)},zE=function(e,r,n){return r=RE(r),FE(e,r)&&My(n)&&rd(n,"value")&&!rd(n,"get")&&!rd(n,"set")&&!n.configurable&&(!rd(n,"writable")||n.writable)&&(!rd(n,"enumerable")||n.enumerable)?(e[r]=n.value,e):NE(e,r,n)};RZ?(Jh||(PE.f=BE,OE.f=zE,Xh(nd,"buffer"),Xh(nd,"byteOffset"),Xh(nd,"byteLength"),Xh(nd,"length")),$E({target:"Object",stat:!0,forced:!Jh},{getOwnPropertyDescriptor:BE,defineProperty:zE}),wy.exports=function(t,e,r){var n=t.match(/\d+/)[0]/8,i=t+(r?"Clamped":"")+"Array",a="get"+t,s="set"+t,o=TE[i],u=o,l=u&&u.prototype,c={},d=function(L,N){var z=Ly(L);return z.view[a](N*n+z.byteOffset,!0)},f=function(L,N,z){var re=Ly(L);re.view[s](N*n+re.byteOffset,r?NZ(z):z,!0)},m=function(L,N){NE(L,N,{get:function(){return d(this,N)},set:function(z){return f(this,N,z)},enumerable:!0})};Jh?AZ&&(u=e(function(L,N,z,re){return IE(L,l),qZ(function(){return My(N)?UE(N)?re!==void 0?new o(N,Py(z,n),re):z!==void 0?new o(N,Py(z,n)):new o(N):jy(N)?ME(u,N):CE(AE,u,N):new o(xE(N))}(),L,u)}),Yh&&Yh(u,jE),BZ(FZ(o),function(L){L in u||td(u,L,o[L])}),u.prototype=l):(u=e(function(L,N,z,re){IE(L,l);var Me=0,Oe=0,Fe,Pe,Ze;if(!My(N))Ze=xE(N),Pe=Ze*n,Fe=new LE(Pe);else if(UE(N)){Fe=N,Oe=Py(z,n);var Z=N.byteLength;if(re===void 0){if(Z%n)throw new Dy(Uy);if(Pe=Z-Oe,Pe<0)throw new Dy(Uy)}else if(Pe=MZ(re)*n,Pe+Oe>Z)throw new Dy(Uy);Ze=Pe/n}else return jy(N)?ME(u,N):CE(AE,u,N);for(VZ(L,{buffer:Fe,byteOffset:Oe,byteLength:Pe,length:Ze,view:new KZ(Fe)});Me<Ze;)m(L,Me++)}),Yh&&Yh(u,jE),l=u.prototype=jZ(nd)),l.constructor!==u&&td(l,"constructor",u),WZ(l).TypedArrayConstructor=u,DE&&td(l,DE,i);var k=u!==o;c[i]=u,$E({global:!0,constructor:!0,forced:k,sham:!Jh},c),Qh in u||td(u,Qh,n),Qh in l||td(l,Qh,n),zZ(i)}):wy.exports=function(){};var YZ=wy.exports,JZ=YZ;JZ("Uint8",function(t){return function(r,n,i){return t(this,r,n,i)}});var HE=Ar,QZ=gn,XZ=Wi,eG=HE.aTypedArray,tG=HE.exportTypedArrayMethod;tG("at",function(e){var r=eG(this),n=QZ(r),i=XZ(e),a=i>=0?i:n+i;return a<0||a>=n?void 0:r[a]});var qE=co,rG=TypeError,Fy=function(t,e){if(!delete t[e])throw new rG("Cannot delete property "+qE(e)+" of "+qE(t))},nG=vn,By=yu,iG=gn,aG=Fy,sG=Math.min,oG=[].copyWithin||function(e,r){var n=nG(this),i=iG(n),a=By(e,i),s=By(r,i),o=arguments.length>2?arguments[2]:void 0,u=sG((o===void 0?i:By(o,i))-s,i-a),l=1;for(s<a&&a<s+u&&(l=-1,s+=u-1,a+=u-1);u-- >0;)s in n?n[a]=n[s]:aG(n,a),a+=l,s+=l;return n},uG=Gt,VE=Ar,lG=oG,cG=uG(lG),dG=VE.aTypedArray,fG=VE.exportTypedArrayMethod;fG("copyWithin",function(e,r){return cG(dG(this),e,r,arguments.length>2?arguments[2]:void 0)});var WE=Ar,hG=Nn.every,pG=WE.aTypedArray,vG=WE.exportTypedArrayMethod;vG("every",function(e){return hG(pG(this),e,arguments.length>1?arguments[1]:void 0)});var ZE=Ar,gG=tE,mG=kE,yG=_a,bG=$r,wG=Gt,_G=qt,kG=ZE.aTypedArray,SG=ZE.exportTypedArrayMethod,$G=wG("".slice),TG=_G(function(){var t=0;return new Int8Array(2).fill({valueOf:function(){return t++}}),t!==1});SG("fill",function(e){var r=arguments.length;kG(this);var n=$G(yG(this),0,3)==="Big"?mG(e):+e;return bG(gG,this,n,r>1?arguments[1]:void 0,r>2?arguments[2]:void 0)},TG);var GE=Ar,CG=qg,EG=GE.aTypedArrayConstructor,IG=GE.getTypedArrayConstructor,ep=function(t){return EG(CG(t,IG(t)))},xG=SE,RG=ep,AG=function(t,e){return xG(RG(t),e)},KE=Ar,OG=Nn.filter,PG=AG,MG=KE.aTypedArray,NG=KE.exportTypedArrayMethod;NG("filter",function(e){var r=OG(MG(this),e,arguments.length>1?arguments[1]:void 0);return PG(this,r)});var YE=Ar,LG=Nn.find,DG=YE.aTypedArray,jG=YE.exportTypedArrayMethod;jG("find",function(e){return LG(DG(this),e,arguments.length>1?arguments[1]:void 0)});var JE=Ar,UG=Nn.findIndex,FG=JE.aTypedArray,BG=JE.exportTypedArrayMethod;BG("findIndex",function(e){return UG(FG(this),e,arguments.length>1?arguments[1]:void 0)});var QE=Ar,zG=Nn.forEach,HG=QE.aTypedArray,qG=QE.exportTypedArrayMethod;qG("forEach",function(e){zG(HG(this),e,arguments.length>1?arguments[1]:void 0)});var XE=Ar,VG=Nf.includes,WG=XE.aTypedArray,ZG=XE.exportTypedArrayMethod;ZG("includes",function(e){return VG(WG(this),e,arguments.length>1?arguments[1]:void 0)});var eI=Ar,GG=Nf.indexOf,KG=eI.aTypedArray,YG=eI.exportTypedArrayMethod;YG("indexOf",function(e){return GG(KG(this),e,arguments.length>1?arguments[1]:void 0)});var JG=ur,QG=qt,zy=Gt,tI=Ar,Hy=Y$,XG=Cr,qy=XG("iterator"),rI=JG.Uint8Array,eK=zy(Hy.values),tK=zy(Hy.keys),rK=zy(Hy.entries),Vy=tI.aTypedArray,tp=tI.exportTypedArrayMethod,zu=rI&&rI.prototype,rp=!QG(function(){zu[qy].call([1])}),nI=!!zu&&zu.values&&zu[qy]===zu.values&&zu.values.name==="values",iI=function(){return eK(Vy(this))};tp("entries",function(){return rK(Vy(this))},rp),tp("keys",function(){return tK(Vy(this))},rp),tp("values",iI,rp||!nI,{name:"values"}),tp(qy,iI,rp||!nI,{name:"values"});var aI=Ar,nK=Gt,iK=aI.aTypedArray,aK=aI.exportTypedArrayMethod,sK=nK([].join);aK("join",function(e){return sK(iK(this),e)});var oK=po,uK=Vn,lK=Wi,cK=gn,dK=Gf,fK=Math.min,Wy=[].lastIndexOf,sI=!!Wy&&1/[1].lastIndexOf(1,-0)<0,hK=dK("lastIndexOf"),pK=sI||!hK,vK=pK?function(e){if(sI)return oK(Wy,this,arguments)||0;var r=uK(this),n=cK(r);if(n===0)return-1;var i=n-1;for(arguments.length>1&&(i=fK(i,lK(arguments[1]))),i<0&&(i=n+i);i>=0;i--)if(i in r&&r[i]===e)return i||0;return-1}:Wy,oI=Ar,gK=po,mK=vK,yK=oI.aTypedArray,bK=oI.exportTypedArrayMethod;bK("lastIndexOf",function(e){var r=arguments.length;return gK(mK,yK(this),r>1?[e,arguments[1]]:[e])});var uI=Ar,wK=Nn.map,_K=ep,kK=uI.aTypedArray,SK=uI.exportTypedArrayMethod;SK("map",function(e){return wK(kK(this),e,arguments.length>1?arguments[1]:void 0,function(r,n){return new(_K(r))(n)})});var $K=ti,TK=vn,CK=yc,EK=gn,lI=TypeError,cI="Reduce of empty array with no initial value",dI=function(t){return function(e,r,n,i){var a=TK(e),s=CK(a),o=EK(a);if($K(r),o===0&&n<2)throw new lI(cI);var u=t?o-1:0,l=t?-1:1;if(n<2)for(;;){if(u in s){i=s[u],u+=l;break}if(u+=l,t?u<0:o<=u)throw new lI(cI)}for(;t?u>=0:o>u;u+=l)u in s&&(i=r(i,s[u],u,a));return i}},fI={left:dI(!1),right:dI(!0)},hI=Ar,IK=fI.left,xK=hI.aTypedArray,RK=hI.exportTypedArrayMethod;RK("reduce",function(e){var r=arguments.length;return IK(xK(this),e,r,r>1?arguments[1]:void 0)});var pI=Ar,AK=fI.right,OK=pI.aTypedArray,PK=pI.exportTypedArrayMethod;PK("reduceRight",function(e){var r=arguments.length;return AK(OK(this),e,r,r>1?arguments[1]:void 0)});var vI=Ar,MK=vI.aTypedArray,NK=vI.exportTypedArrayMethod,LK=Math.floor;NK("reverse",function(){for(var e=this,r=MK(e).length,n=LK(r/2),i=0,a;i<n;)a=e[i],e[i++]=e[--r],e[r]=a;return e});var gI=ur,mI=$r,Zy=Ar,DK=gn,jK=_E,UK=vn,yI=qt,FK=gI.RangeError,Gy=gI.Int8Array,bI=Gy&&Gy.prototype,wI=bI&&bI.set,BK=Zy.aTypedArray,zK=Zy.exportTypedArrayMethod,Ky=!yI(function(){var t=new Uint8ClampedArray(2);return mI(wI,t,{length:1,0:3},1),t[1]!==3}),HK=Ky&&Zy.NATIVE_ARRAY_BUFFER_VIEWS&&yI(function(){var t=new Gy(2);return t.set(1),t.set("2",1),t[0]!==0||t[1]!==2});zK("set",function(e){BK(this);var r=jK(arguments.length>1?arguments[1]:void 0,1),n=UK(e);if(Ky)return mI(wI,this,n,r);var i=this.length,a=DK(n),s=0;if(a+r>i)throw new FK("Wrong length");for(;s<a;)this[r+s]=n[s++]},!Ky||HK);var _I=Ar,qK=ep,VK=qt,WK=Gi,ZK=_I.aTypedArray,GK=_I.exportTypedArrayMethod,KK=VK(function(){new Int8Array(1).slice()});GK("slice",function(e,r){for(var n=WK(ZK(this),e,r),i=qK(this),a=0,s=n.length,o=new i(s);s>a;)o[a]=n[a++];return o},KK);var kI=Ar,YK=Nn.some,JK=kI.aTypedArray,QK=kI.exportTypedArrayMethod;QK("some",function(e){return YK(JK(this),e,arguments.length>1?arguments[1]:void 0)});var SI=Gi,XK=Math.floor,Yy=function(t,e){var r=t.length;if(r<8)for(var n=1,i,a;n<r;){for(a=n,i=t[n];a&&e(t[a-1],i)>0;)t[a]=t[--a];a!==n++&&(t[a]=i)}else for(var s=XK(r/2),o=Yy(SI(t,0,s),e),u=Yy(SI(t,s),e),l=o.length,c=u.length,d=0,f=0;d<l||f<c;)t[d+f]=d<l&&f<c?e(o[d],u[f])<=0?o[d++]:u[f++]:d<l?o[d++]:u[f++];return t},Jy=Yy,eY=lo,$I=eY.match(/firefox\/(\d+)/i),TI=!!$I&&+$I[1],tY=lo,CI=/MSIE|Trident/.test(tY),rY=lo,EI=rY.match(/AppleWebKit\/(\d+)\./),II=!!EI&&+EI[1],nY=ur,iY=Tg,Qy=qt,aY=ti,sY=Jy,xI=Ar,RI=TI,oY=CI,AI=fu,OI=II,uY=xI.aTypedArray,lY=xI.exportTypedArrayMethod,id=nY.Uint16Array,Hu=id&&iY(id.prototype.sort),cY=!!Hu&&!(Qy(function(){Hu(new id(2),null)})&&Qy(function(){Hu(new id(2),{})})),PI=!!Hu&&!Qy(function(){if(AI)return AI<74;if(RI)return RI<67;if(oY)return!0;if(OI)return OI<602;var t=new id(516),e=Array(516),r,n;for(r=0;r<516;r++)n=r%4,t[r]=515-r,e[r]=r-2*n+3;for(Hu(t,function(i,a){return(i/4|0)-(a/4|0)}),r=0;r<516;r++)if(t[r]!==e[r])return!0}),dY=function(t){return function(e,r){return t!==void 0?+t(e,r)||0:r!==r?-1:e!==e?1:e===0&&r===0?1/e>0&&1/r<0?1:-1:e>r}};lY("sort",function(e){return e!==void 0&&aY(e),PI?Hu(this,e):sY(uY(this),dY(e))},!PI||cY);var MI=Ar,fY=wa,NI=yu,hY=ep,pY=MI.aTypedArray,vY=MI.exportTypedArrayMethod;vY("subarray",function(e,r){var n=pY(this),i=n.length,a=NI(e,i),s=hY(n);return new s(n.buffer,n.byteOffset+a*n.BYTES_PER_ELEMENT,fY((r===void 0?i:NI(r,i))-a))});var gY=ur,mY=po,LI=Ar,Xy=qt,DI=Gi,np=gY.Int8Array,jI=LI.aTypedArray,yY=LI.exportTypedArrayMethod,UI=[].toLocaleString,bY=!!np&&Xy(function(){UI.call(new np(1))}),wY=Xy(function(){return[1,2].toLocaleString()!==new np([1,2]).toLocaleString()})||!Xy(function(){np.prototype.toLocaleString.call([1,2])});yY("toLocaleString",function(){return mY(UI,bY?DI(jI(this)):jI(this),DI(arguments))},wY);var _Y=Ar.exportTypedArrayMethod,kY=qt,SY=ur,$Y=Gt,FI=SY.Uint8Array,TY=FI&&FI.prototype||{},ip=[].toString,CY=$Y([].join);kY(function(){ip.call({})})&&(ip=function(){return CY(this)});var EY=TY.toString!==ip;_Y("toString",ip,EY);var eb=$r,BI=Gt,IY=_h,xY=Wr,RY=ki,AY=Si,OY=qg,PY=Gm,MY=wa,zI=Xr,NY=fo,HI=kh,LY=dT,DY=qt,qu=LY.UNSUPPORTED_Y,jY=4294967295,UY=Math.min,tb=BI([].push),rb=BI("".slice),FY=!DY(function(){var t=/(?:)/,e=t.exec;t.exec=function(){return e.apply(this,arguments)};var r="ab".split(t);return r.length!==2||r[0]!=="a"||r[1]!=="b"}),qI="abbc".split(/(b)*/)[1]==="c"||"test".split(/(?:)/,-1).length!==4||"ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||".".split(/()()/).length>1||"".split(/.?/).length;IY("split",function(t,e,r){var n="0".split(void 0,0).length?function(i,a){return i===void 0&&a===0?[]:eb(e,this,i,a)}:e;return[function(a,s){var o=AY(this),u=RY(a)?void 0:NY(a,t);return u?eb(u,a,o,s):eb(n,zI(o),a,s)},function(i,a){var s=xY(this),o=zI(i);if(!qI){var u=r(n,s,o,a,n!==e);if(u.done)return u.value}var l=OY(s,RegExp),c=s.unicode,d=(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.unicode?"u":"")+(qu?"g":"y"),f=new l(qu?"^(?:"+s.source+")":s,d),m=a===void 0?jY:a>>>0;if(m===0)return[];if(o.length===0)return HI(f,o)===null?[o]:[];for(var k=0,L=0,N=[];L<o.length;){f.lastIndex=qu?0:L;var z=HI(f,qu?rb(o,L):o),re;if(z===null||(re=UY(MY(f.lastIndex+(qu?L:0)),o.length))===k)L=PY(o,L,c);else{if(tb(N,rb(o,k,L)),N.length===m)return N;for(var Me=1;Me<=z.length-1;Me++)if(tb(N,z[Me]),N.length===m)return N;L=k=re}}return tb(N,rb(o,k)),N}]},qI||!FY,qu);var VI={exports:{}},WI={exports:{}};(function(t){function e(r){try{return Function.toString.call(r).indexOf("[native code]")!==-1}catch{return typeof r=="function"}}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(WI);var BY=WI.exports,ZI={exports:{}},GI={exports:{}};(function(t){function e(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(t.exports=e=function(){return!!r},t.exports.__esModule=!0,t.exports.default=t.exports)()}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports})(GI);var zY=GI.exports;(function(t){var e=zY,r=Fg;function n(i,a,s){if(e())return Reflect.construct.apply(null,arguments);var o=[null];o.push.apply(o,a);var u=new(i.bind.apply(i,o));return s&&r(u,s.prototype),u}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports})(ZI);var HY=ZI.exports;(function(t){var e=ii,r=Fg,n=BY,i=HY;function a(s){var o=typeof Map=="function"?new Map:void 0;return t.exports=a=function(l){if(l===null||!n(l))return l;if(typeof l!="function")throw new TypeError("Super expression must either be null or a function");if(o!==void 0){if(o.has(l))return o.get(l);o.set(l,c)}function c(){return i(l,arguments,e(this).constructor)}return c.prototype=Object.create(l.prototype,{constructor:{value:c,enumerable:!1,writable:!0,configurable:!0}}),r(c,l)},t.exports.__esModule=!0,t.exports.default=t.exports,a(s)}t.exports=a,t.exports.__esModule=!0,t.exports.default=t.exports})(VI);var ad=VI.exports,ap={exports:{}};/*!
834
834
  * Platform.js v1.3.6
835
835
  * Copyright 2014-2020 Benjamin Tan
836
836
  * Copyright 2011-2013 John-David Dalton
837
837
  * Available under MIT license
838
- */ap.exports,function(t,e){(function(){var r={function:!0,object:!0},n=r[typeof window]&&window||this,i=e,a=t&&!t.nodeType&&t,s=i&&a&&typeof sn=="object"&&sn;s&&(s.global===s||s.window===s||s.self===s)&&(n=s);var o=Math.pow(2,53)-1,u=/\bOpera/,l=Object.prototype,c=l.hasOwnProperty,d=l.toString;function f(Z){return Z=String(Z),Z.charAt(0).toUpperCase()+Z.slice(1)}function m(Z,Ie,_e){var se={"10.0":"10","6.4":"10 Technical Preview","6.3":"8.1","6.2":"8","6.1":"Server 2008 R2 / 7","6.0":"Server 2008 / Vista","5.2":"Server 2003 / XP 64-bit","5.1":"XP","5.01":"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return Ie&&_e&&/^Win/i.test(Z)&&!/^Windows Phone /i.test(Z)&&(se=se[/[\d.]+$/.exec(Z)])&&(Z="Windows "+se),Z=String(Z),Ie&&_e&&(Z=Z.replace(RegExp(Ie,"i"),_e)),Z=L(Z.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0]),Z}function k(Z,Ie){var _e=-1,se=Z?Z.length:0;if(typeof se=="number"&&se>-1&&se<=o)for(;++_e<se;)Ie(Z[_e],_e,Z);else N(Z,Ie)}function L(Z){return Z=Be(Z),/^(?:webOS|i(?:OS|P))/.test(Z)?Z:f(Z)}function N(Z,Ie){for(var _e in Z)c.call(Z,_e)&&Ie(Z[_e],_e,Z)}function z(Z){return Z==null?f(Z):d.call(Z).slice(8,-1)}function re(Z,Ie){var _e=Z!=null?typeof Z[Ie]:"number";return!/^(?:boolean|number|string|undefined)$/.test(_e)&&(_e=="object"?!!Z[Ie]:!0)}function Me(Z){return String(Z).replace(/([ -])(?!$)/g,"$1?")}function Oe(Z,Ie){var _e=null;return k(Z,function(se,Te){_e=Ie(_e,se,Te,Z)}),_e}function Be(Z){return String(Z).replace(/^ +| +$/g,"")}function Pe(Z){var Ie=n,_e=Z&&typeof Z=="object"&&z(Z)!="String";_e&&(Ie=Z,Z=null);var se=Ie.navigator||{},Te=se.userAgent||"";Z||(Z=Te);var te=_e?!!se.likeChrome:/\bChrome\b/.test(Z)&&!/internal|\n/i.test(d.toString()),oe="Object",q=_e?oe:"ScriptBridgingProxyObject",ne=_e?oe:"Environment",Se=_e&&Ie.java?"JavaPackage":z(Ie.java),H=_e?oe:"RuntimeObject",ye=/\bJava/.test(Se)&&Ie.java,ke=ye&&z(Ie.environment)==ne,P=ye?"a":"α",Qe=ye?"b":"β",Ct=Ie.document||{},tt=Ie.operamini||Ie.opera,De=u.test(De=_e&&tt?tt["[[Class]]"]:z(tt))?De:tt=null,ce,Ge=Z,Ue=[],be=null,ht=Z==Te,Ve=ht&&tt&&typeof tt.version=="function"&&tt.version(),Kt,Rt=kt([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),Q=ar(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),je=Xe([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),st=ot({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),Re=mr(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function kt(cr){return Oe(cr,function(Vt,At){return Vt||RegExp("\\b"+(At.pattern||Me(At))+"\\b","i").exec(Z)&&(At.label||At)})}function ot(cr){return Oe(cr,function(Vt,At,M){return Vt||(At[je]||At[/^[a-z]+(?: +[a-z]+\b)*/i.exec(je)]||RegExp("\\b"+Me(M)+"(?:\\b|\\w*\\d)","i").exec(Z))&&M})}function ar(cr){return Oe(cr,function(Vt,At){return Vt||RegExp("\\b"+(At.pattern||Me(At))+"\\b","i").exec(Z)&&(At.label||At)})}function mr(cr){return Oe(cr,function(Vt,At){var M=At.pattern||Me(At);return!Vt&&(Vt=RegExp("\\b"+M+"(?:/[\\d.]+|[ \\w.]*)","i").exec(Z))&&(Vt=m(Vt,M,At.label||At)),Vt})}function Xe(cr){return Oe(cr,function(Vt,At){var M=At.pattern||Me(At);return!Vt&&(Vt=RegExp("\\b"+M+" *\\d+[.\\w_]*","i").exec(Z)||RegExp("\\b"+M+" *\\w+-[\\w]*","i").exec(Z)||RegExp("\\b"+M+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(Z))&&((Vt=String(At.label&&!RegExp(M,"i").test(At.label)?At.label:Vt).split("/"))[1]&&!/[\d.]+/.test(Vt[0])&&(Vt[0]+=" "+Vt[1]),At=At.label||At,Vt=L(Vt[0].replace(RegExp(M,"i"),At).replace(RegExp("; *(?:"+At+"[_-])?","i")," ").replace(RegExp("("+At+")[-_.]?(\\w)","i"),"$1 $2"))),Vt})}function Or(cr){return Oe(cr,function(Vt,At){return Vt||(RegExp(At+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(Z)||0)[1]||null})}function jr(){return this.description||""}if(Rt&&(Rt=[Rt]),/\bAndroid\b/.test(Re)&&!je&&(ce=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(Z))&&(je=Be(ce[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),st&&!je?je=Xe([st]):st&&je&&(je=je.replace(RegExp("^("+Me(st)+")[-_.\\s]","i"),st+" ").replace(RegExp("^("+Me(st)+")[-_.]?(\\w)","i"),st+" $2")),(ce=/\bGoogle TV\b/.exec(je))&&(je=ce[0]),/\bSimulator\b/i.test(Z)&&(je=(je?je+" ":"")+"Simulator"),Q=="Opera Mini"&&/\bOPiOS\b/.test(Z)&&Ue.push("running in Turbo/Uncompressed mode"),Q=="IE"&&/\blike iPhone OS\b/.test(Z)?(ce=Pe(Z.replace(/like iPhone OS/,"")),st=ce.manufacturer,je=ce.product):/^iP/.test(je)?(Q||(Q="Safari"),Re="iOS"+((ce=/ OS ([\d_]+)/i.exec(Z))?" "+ce[1].replace(/_/g,"."):"")):Q=="Konqueror"&&/^Linux\b/i.test(Re)?Re="Kubuntu":st&&st!="Google"&&(/Chrome/.test(Q)&&!/\bMobile Safari\b/i.test(Z)||/\bVita\b/.test(je))||/\bAndroid\b/.test(Re)&&/^Chrome/.test(Q)&&/\bVersion\//i.test(Z)?(Q="Android Browser",Re=/\bAndroid\b/.test(Re)?Re:"Android"):Q=="Silk"?(/\bMobi/i.test(Z)||(Re="Android",Ue.unshift("desktop mode")),/Accelerated *= *true/i.test(Z)&&Ue.unshift("accelerated")):Q=="UC Browser"&&/\bUCWEB\b/.test(Z)?Ue.push("speed mode"):Q=="PaleMoon"&&(ce=/\bFirefox\/([\d.]+)\b/.exec(Z))?Ue.push("identifying as Firefox "+ce[1]):Q=="Firefox"&&(ce=/\b(Mobile|Tablet|TV)\b/i.exec(Z))?(Re||(Re="Firefox OS"),je||(je=ce[1])):!Q||(ce=!/\bMinefield\b/i.test(Z)&&/\b(?:Firefox|Safari)\b/.exec(Q))?(Q&&!je&&/[\/,]|^[^(]+?\)/.test(Z.slice(Z.indexOf(ce+"/")+8))&&(Q=null),(ce=je||st||Re)&&(je||st||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(Re))&&(Q=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(Re)?Re:ce)+" Browser")):Q=="Electron"&&(ce=(/\bChrome\/([\d.]+)\b/.exec(Z)||0)[1])&&Ue.push("Chromium "+ce),Ve||(Ve=Or(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",Me(Q),"(?:Firefox|Minefield|NetFront)"])),(ce=Rt=="iCab"&&parseFloat(Ve)>3&&"WebKit"||/\bOpera\b/.test(Q)&&(/\bOPR\b/.test(Z)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(Z)&&!/^(?:Trident|EdgeHTML)$/.test(Rt)&&"WebKit"||!Rt&&/\bMSIE\b/i.test(Z)&&(Re=="Mac OS"?"Tasman":"Trident")||Rt=="WebKit"&&/\bPlayStation\b(?! Vita\b)/i.test(Q)&&"NetFront")&&(Rt=[ce]),Q=="IE"&&(ce=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(Z)||0)[1])?(Q+=" Mobile",Re="Windows Phone "+(/\+$/.test(ce)?ce:ce+".x"),Ue.unshift("desktop mode")):/\bWPDesktop\b/i.test(Z)?(Q="IE Mobile",Re="Windows Phone 8.x",Ue.unshift("desktop mode"),Ve||(Ve=(/\brv:([\d.]+)/.exec(Z)||0)[1])):Q!="IE"&&Rt=="Trident"&&(ce=/\brv:([\d.]+)/.exec(Z))&&(Q&&Ue.push("identifying as "+Q+(Ve?" "+Ve:"")),Q="IE",Ve=ce[1]),ht){if(re(Ie,"global"))if(ye&&(ce=ye.lang.System,Ge=ce.getProperty("os.arch"),Re=Re||ce.getProperty("os.name")+" "+ce.getProperty("os.version")),ke){try{Ve=Ie.require("ringo/engine").version.join("."),Q="RingoJS"}catch{(ce=Ie.system)&&ce.global.system==Ie.system&&(Q="Narwhal",Re||(Re=ce[0].os||null))}Q||(Q="Rhino")}else typeof Ie.process=="object"&&!Ie.process.browser&&(ce=Ie.process)&&(typeof ce.versions=="object"&&(typeof ce.versions.electron=="string"?(Ue.push("Node "+ce.versions.node),Q="Electron",Ve=ce.versions.electron):typeof ce.versions.nw=="string"&&(Ue.push("Chromium "+Ve,"Node "+ce.versions.node),Q="NW.js",Ve=ce.versions.nw)),Q||(Q="Node.js",Ge=ce.arch,Re=ce.platform,Ve=/[\d.]+/.exec(ce.version),Ve=Ve?Ve[0]:null));else z(ce=Ie.runtime)==q?(Q="Adobe AIR",Re=ce.flash.system.Capabilities.os):z(ce=Ie.phantom)==H?(Q="PhantomJS",Ve=(ce=ce.version||null)&&ce.major+"."+ce.minor+"."+ce.patch):typeof Ct.documentMode=="number"&&(ce=/\bTrident\/(\d+)/i.exec(Z))?(Ve=[Ve,Ct.documentMode],(ce=+ce[1]+4)!=Ve[1]&&(Ue.push("IE "+Ve[1]+" mode"),Rt&&(Rt[1]=""),Ve[1]=ce),Ve=Q=="IE"?String(Ve[1].toFixed(1)):Ve[0]):typeof Ct.documentMode=="number"&&/^(?:Chrome|Firefox)\b/.test(Q)&&(Ue.push("masking as "+Q+" "+Ve),Q="IE",Ve="11.0",Rt=["Trident"],Re="Windows");Re=Re&&L(Re)}if(Ve&&(ce=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(Ve)||/(?:alpha|beta)(?: ?\d)?/i.exec(Z+";"+(ht&&se.appMinorVersion))||/\bMinefield\b/i.test(Z)&&"a")&&(be=/b/i.test(ce)?"beta":"alpha",Ve=Ve.replace(RegExp(ce+"\\+?$"),"")+(be=="beta"?Qe:P)+(/\d+\+?/.exec(ce)||"")),Q=="Fennec"||Q=="Firefox"&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(Re))Q="Firefox Mobile";else if(Q=="Maxthon"&&Ve)Ve=Ve.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(je))je=="Xbox 360"&&(Re=null),je=="Xbox 360"&&/\bIEMobile\b/.test(Z)&&Ue.unshift("mobile mode");else if((/^(?:Chrome|IE|Opera)$/.test(Q)||Q&&!je&&!/Browser|Mobi/.test(Q))&&(Re=="Windows CE"||/Mobi/i.test(Z)))Q+=" Mobile";else if(Q=="IE"&&ht)try{Ie.external===null&&Ue.unshift("platform preview")}catch{Ue.unshift("embedded")}else(/\bBlackBerry\b/.test(je)||/\bBB10\b/.test(Z))&&(ce=(RegExp(je.replace(/ +/g," *")+"/([.\\d]+)","i").exec(Z)||0)[1]||Ve)?(ce=[ce,/BB10/.test(Z)],Re=(ce[1]?(je=null,st="BlackBerry"):"Device Software")+" "+ce[0],Ve=null):this!=N&&je!="Wii"&&(ht&&tt||/Opera/.test(Q)&&/\b(?:MSIE|Firefox)\b/i.test(Z)||Q=="Firefox"&&/\bOS X (?:\d+\.){2,}/.test(Re)||Q=="IE"&&(Re&&!/^Win/.test(Re)&&Ve>5.5||/\bWindows XP\b/.test(Re)&&Ve>8||Ve==8&&!/\bTrident\b/.test(Z)))&&!u.test(ce=Pe.call(N,Z.replace(u,"")+";"))&&ce.name&&(ce="ing as "+ce.name+((ce=ce.version)?" "+ce:""),u.test(Q)?(/\bIE\b/.test(ce)&&Re=="Mac OS"&&(Re=null),ce="identify"+ce):(ce="mask"+ce,De?Q=L(De.replace(/([a-z])([A-Z])/g,"$1 $2")):Q="Opera",/\bIE\b/.test(ce)&&(Re=null),ht||(Ve=null)),Rt=["Presto"],Ue.push(ce));(ce=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(Z)||0)[1])&&(ce=[parseFloat(ce.replace(/\.(\d)$/,".0$1")),ce],Q=="Safari"&&ce[1].slice(-1)=="+"?(Q="WebKit Nightly",be="alpha",Ve=ce[1].slice(0,-1)):(Ve==ce[1]||Ve==(ce[2]=(/\bSafari\/([\d.]+\+?)/i.exec(Z)||0)[1]))&&(Ve=null),ce[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(Z)||0)[1],ce[0]==537.36&&ce[2]==537.36&&parseFloat(ce[1])>=28&&Rt=="WebKit"&&(Rt=["Blink"]),!ht||!te&&!ce[1]?(Rt&&(Rt[1]="like Safari"),ce=(ce=ce[0],ce<400?1:ce<500?2:ce<526?3:ce<533?4:ce<534?"4+":ce<535?5:ce<537?6:ce<538?7:ce<601?8:ce<602?9:ce<604?10:ce<606?11:ce<608?12:"12")):(Rt&&(Rt[1]="like Chrome"),ce=ce[1]||(ce=ce[0],ce<530?1:ce<532?2:ce<532.05?3:ce<533?4:ce<534.03?5:ce<534.07?6:ce<534.1?7:ce<534.13?8:ce<534.16?9:ce<534.24?10:ce<534.3?11:ce<535.01?12:ce<535.02?"13+":ce<535.07?15:ce<535.11?16:ce<535.19?17:ce<536.05?18:ce<536.1?19:ce<537.01?20:ce<537.11?"21+":ce<537.13?23:ce<537.18?24:ce<537.24?25:ce<537.36?26:Rt!="Blink"?"27":"28")),Rt&&(Rt[1]+=" "+(ce+=typeof ce=="number"?".x":/[.+]/.test(ce)?"":"+")),Q=="Safari"&&(!Ve||parseInt(Ve)>45)?Ve=ce:Q=="Chrome"&&/\bHeadlessChrome/i.test(Z)&&Ue.unshift("headless")),Q=="Opera"&&(ce=/\bzbov|zvav$/.exec(Re))?(Q+=" ",Ue.unshift("desktop mode"),ce=="zvav"?(Q+="Mini",Ve=null):Q+="Mobile",Re=Re.replace(RegExp(" *"+ce+"$"),"")):Q=="Safari"&&/\bChrome\b/.exec(Rt&&Rt[1])?(Ue.unshift("desktop mode"),Q="Chrome Mobile",Ve=null,/\bOS X\b/.test(Re)?(st="Apple",Re="iOS 4.3+"):Re=null):/\bSRWare Iron\b/.test(Q)&&!Ve&&(Ve=Or("Chrome")),Ve&&Ve.indexOf(ce=/[\d.]+$/.exec(Re))==0&&Z.indexOf("/"+ce+"-")>-1&&(Re=Be(Re.replace(ce,""))),Re&&Re.indexOf(Q)!=-1&&!RegExp(Q+" OS").test(Re)&&(Re=Re.replace(RegExp(" *"+Me(Q)+" *"),"")),Rt&&!/\b(?:Avant|Nook)\b/.test(Q)&&(/Browser|Lunascape|Maxthon/.test(Q)||Q!="Safari"&&/^iOS/.test(Re)&&/\bSafari\b/.test(Rt[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(Q)&&Rt[1])&&(ce=Rt[Rt.length-1])&&Ue.push(ce),Ue.length&&(Ue=["("+Ue.join("; ")+")"]),st&&je&&je.indexOf(st)<0&&Ue.push("on "+st),je&&Ue.push((/^on /.test(Ue[Ue.length-1])?"":"on ")+je),Re&&(ce=/ ([\d.+]+)$/.exec(Re),Kt=ce&&Re.charAt(Re.length-ce[0].length-1)=="/",Re={architecture:32,family:ce&&!Kt?Re.replace(ce[0],""):Re,version:ce?ce[1]:null,toString:function(){var cr=this.version;return this.family+(cr&&!Kt?" "+cr:"")+(this.architecture==64?" 64-bit":"")}}),(ce=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(Ge))&&!/\bi686\b/i.test(Ge)?(Re&&(Re.architecture=64,Re.family=Re.family.replace(RegExp(" *"+ce),"")),Q&&(/\bWOW64\b/i.test(Z)||ht&&/\w(?:86|32)$/.test(se.cpuClass||se.platform)&&!/\bWin64; x64\b/i.test(Z))&&Ue.unshift("32-bit")):Re&&/^OS X/.test(Re.family)&&Q=="Chrome"&&parseFloat(Ve)>=39&&(Re.architecture=64),Z||(Z=null);var lr={};return lr.description=Z,lr.layout=Rt&&Rt[0],lr.manufacturer=st,lr.name=Q,lr.prerelease=be,lr.product=je,lr.ua=Z,lr.version=Q&&Ve,lr.os=Re||{architecture:null,family:null,version:null,toString:function(){return"null"}},lr.parse=Pe,lr.toString=jr,lr.version&&Ue.unshift(Ve),lr.name&&Ue.unshift(Q),Re&&Q&&!(Re==String(Re).split(" ")[0]&&(Re==Q.split(" ")[0]||je))&&Ue.push(je?"("+Re+")":"on "+Re),Ue.length&&(lr.description=Ue.join(" ")),lr}var Ze=Pe();i&&a?N(Ze,function(Z,Ie){i[Ie]=Z}):n.platform=Ze}).call(sn)}(ap,ap.exports);var nb=ap.exports,qY=$r,VY=_h,WY=Wr,ZY=ki,GY=wa,ib=Xr,KY=Si,YY=fo,JY=Gm,KI=kh;VY("match",function(t,e,r){return[function(i){var a=KY(this),s=ZY(i)?void 0:YY(i,t);return s?qY(s,i,a):new RegExp(i)[t](ib(a))},function(n){var i=WY(this),a=ib(n),s=r(e,i,a);if(s.done)return s.value;if(!i.global)return KI(i,a);var o=i.unicode;i.lastIndex=0;for(var u=[],l=0,c;(c=KI(i,a))!==null;){var d=ib(c[0]);u[l]=d,d===""&&(i.lastIndex=JY(a,GY(i.lastIndex),o)),l++}return l===0?null:u}]});var QY=Object.is||function(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r},XY=$r,eJ=_h,tJ=Wr,rJ=ki,nJ=Si,YI=QY,JI=Xr,iJ=fo,aJ=kh;eJ("search",function(t,e,r){return[function(i){var a=nJ(this),s=rJ(i)?void 0:iJ(i,t);return s?XY(s,i,a):new RegExp(i)[t](JI(a))},function(n){var i=tJ(this),a=JI(n),s=r(e,i,a);if(s.done)return s.value;var o=i.lastIndex;YI(o,0)||(i.lastIndex=0);var u=aJ(i,a);return YI(i.lastIndex,o)||(i.lastIndex=o),u===null?-1:u.index}]});var sJ=xr,oJ=Ec,uJ=TypeError,lJ=Object.getOwnPropertyDescriptor,cJ=sJ&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}(),dJ=cJ?function(t,e){if(oJ(t)&&!lJ(t,"length").writable)throw new uJ("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e},fJ=Xt,hJ=vn,pJ=yu,vJ=Wi,gJ=gn,mJ=dJ,yJ=w$,bJ=Cg,wJ=Mc,ab=Fy,_J=Pc,kJ=_J("splice"),SJ=Math.max,$J=Math.min;fJ({target:"Array",proto:!0,forced:!kJ},{splice:function(e,r){var n=hJ(this),i=gJ(n),a=pJ(e,i),s=arguments.length,o,u,l,c,d,f;for(s===0?o=u=0:s===1?(o=0,u=i-a):(o=s-2,u=$J(SJ(vJ(r),0),i-a)),yJ(i+o-u),l=bJ(n,u),c=0;c<u;c++)d=a+c,d in n&&wJ(l,c,n[d]);if(l.length=u,o<u){for(c=a;c<i-u;c++)d=c+u,f=c+o,d in n?n[f]=n[d]:ab(n,f);for(c=i;c>i-u+o;c--)ab(n,c-1)}else if(o>u)for(c=i-u;c>a;c--)d=c+u-1,f=c+o-1,d in n?n[f]=n[d]:ab(n,f);for(c=0;c<o;c++)n[c+a]=arguments[c+2];return mJ(n,i-u+o),l}});/*
838
+ */ap.exports,function(t,e){(function(){var r={function:!0,object:!0},n=r[typeof window]&&window||this,i=e,a=t&&!t.nodeType&&t,s=i&&a&&typeof sn=="object"&&sn;s&&(s.global===s||s.window===s||s.self===s)&&(n=s);var o=Math.pow(2,53)-1,u=/\bOpera/,l=Object.prototype,c=l.hasOwnProperty,d=l.toString;function f(Z){return Z=String(Z),Z.charAt(0).toUpperCase()+Z.slice(1)}function m(Z,Ie,_e){var se={"10.0":"10","6.4":"10 Technical Preview","6.3":"8.1","6.2":"8","6.1":"Server 2008 R2 / 7","6.0":"Server 2008 / Vista","5.2":"Server 2003 / XP 64-bit","5.1":"XP","5.01":"2000 SP1","5.0":"2000","4.0":"NT","4.90":"ME"};return Ie&&_e&&/^Win/i.test(Z)&&!/^Windows Phone /i.test(Z)&&(se=se[/[\d.]+$/.exec(Z)])&&(Z="Windows "+se),Z=String(Z),Ie&&_e&&(Z=Z.replace(RegExp(Ie,"i"),_e)),Z=L(Z.replace(/ ce$/i," CE").replace(/\bhpw/i,"web").replace(/\bMacintosh\b/,"Mac OS").replace(/_PowerPC\b/i," OS").replace(/\b(OS X) [^ \d]+/i,"$1").replace(/\bMac (OS X)\b/,"$1").replace(/\/(\d)/," $1").replace(/_/g,".").replace(/(?: BePC|[ .]*fc[ \d.]+)$/i,"").replace(/\bx86\.64\b/gi,"x86_64").replace(/\b(Windows Phone) OS\b/,"$1").replace(/\b(Chrome OS \w+) [\d.]+\b/,"$1").split(" on ")[0]),Z}function k(Z,Ie){var _e=-1,se=Z?Z.length:0;if(typeof se=="number"&&se>-1&&se<=o)for(;++_e<se;)Ie(Z[_e],_e,Z);else N(Z,Ie)}function L(Z){return Z=Fe(Z),/^(?:webOS|i(?:OS|P))/.test(Z)?Z:f(Z)}function N(Z,Ie){for(var _e in Z)c.call(Z,_e)&&Ie(Z[_e],_e,Z)}function z(Z){return Z==null?f(Z):d.call(Z).slice(8,-1)}function re(Z,Ie){var _e=Z!=null?typeof Z[Ie]:"number";return!/^(?:boolean|number|string|undefined)$/.test(_e)&&(_e=="object"?!!Z[Ie]:!0)}function Me(Z){return String(Z).replace(/([ -])(?!$)/g,"$1?")}function Oe(Z,Ie){var _e=null;return k(Z,function(se,Te){_e=Ie(_e,se,Te,Z)}),_e}function Fe(Z){return String(Z).replace(/^ +| +$/g,"")}function Pe(Z){var Ie=n,_e=Z&&typeof Z=="object"&&z(Z)!="String";_e&&(Ie=Z,Z=null);var se=Ie.navigator||{},Te=se.userAgent||"";Z||(Z=Te);var te=_e?!!se.likeChrome:/\bChrome\b/.test(Z)&&!/internal|\n/i.test(d.toString()),oe="Object",q=_e?oe:"ScriptBridgingProxyObject",ne=_e?oe:"Environment",Se=_e&&Ie.java?"JavaPackage":z(Ie.java),H=_e?oe:"RuntimeObject",ye=/\bJava/.test(Se)&&Ie.java,ke=ye&&z(Ie.environment)==ne,P=ye?"a":"α",Qe=ye?"b":"β",Ct=Ie.document||{},tt=Ie.operamini||Ie.opera,De=u.test(De=_e&&tt?tt["[[Class]]"]:z(tt))?De:tt=null,ce,Ge=Z,Ue=[],be=null,ht=Z==Te,Ve=ht&&tt&&typeof tt.version=="function"&&tt.version(),Kt,Rt=kt([{label:"EdgeHTML",pattern:"Edge"},"Trident",{label:"WebKit",pattern:"AppleWebKit"},"iCab","Presto","NetFront","Tasman","KHTML","Gecko"]),Q=ar(["Adobe AIR","Arora","Avant Browser","Breach","Camino","Electron","Epiphany","Fennec","Flock","Galeon","GreenBrowser","iCab","Iceweasel","K-Meleon","Konqueror","Lunascape","Maxthon",{label:"Microsoft Edge",pattern:"(?:Edge|Edg|EdgA|EdgiOS)"},"Midori","Nook Browser","PaleMoon","PhantomJS","Raven","Rekonq","RockMelt",{label:"Samsung Internet",pattern:"SamsungBrowser"},"SeaMonkey",{label:"Silk",pattern:"(?:Cloud9|Silk-Accelerated)"},"Sleipnir","SlimBrowser",{label:"SRWare Iron",pattern:"Iron"},"Sunrise","Swiftfox","Vivaldi","Waterfox","WebPositive",{label:"Yandex Browser",pattern:"YaBrowser"},{label:"UC Browser",pattern:"UCBrowser"},"Opera Mini",{label:"Opera Mini",pattern:"OPiOS"},"Opera",{label:"Opera",pattern:"OPR"},"Chromium","Chrome",{label:"Chrome",pattern:"(?:HeadlessChrome)"},{label:"Chrome Mobile",pattern:"(?:CriOS|CrMo)"},{label:"Firefox",pattern:"(?:Firefox|Minefield)"},{label:"Firefox for iOS",pattern:"FxiOS"},{label:"IE",pattern:"IEMobile"},{label:"IE",pattern:"MSIE"},"Safari"]),je=Xe([{label:"BlackBerry",pattern:"BB10"},"BlackBerry",{label:"Galaxy S",pattern:"GT-I9000"},{label:"Galaxy S2",pattern:"GT-I9100"},{label:"Galaxy S3",pattern:"GT-I9300"},{label:"Galaxy S4",pattern:"GT-I9500"},{label:"Galaxy S5",pattern:"SM-G900"},{label:"Galaxy S6",pattern:"SM-G920"},{label:"Galaxy S6 Edge",pattern:"SM-G925"},{label:"Galaxy S7",pattern:"SM-G930"},{label:"Galaxy S7 Edge",pattern:"SM-G935"},"Google TV","Lumia","iPad","iPod","iPhone","Kindle",{label:"Kindle Fire",pattern:"(?:Cloud9|Silk-Accelerated)"},"Nexus","Nook","PlayBook","PlayStation Vita","PlayStation","TouchPad","Transformer",{label:"Wii U",pattern:"WiiU"},"Wii","Xbox One",{label:"Xbox 360",pattern:"Xbox"},"Xoom"]),st=ot({Apple:{iPad:1,iPhone:1,iPod:1},Alcatel:{},Archos:{},Amazon:{Kindle:1,"Kindle Fire":1},Asus:{Transformer:1},"Barnes & Noble":{Nook:1},BlackBerry:{PlayBook:1},Google:{"Google TV":1,Nexus:1},HP:{TouchPad:1},HTC:{},Huawei:{},Lenovo:{},LG:{},Microsoft:{Xbox:1,"Xbox One":1},Motorola:{Xoom:1},Nintendo:{"Wii U":1,Wii:1},Nokia:{Lumia:1},Oppo:{},Samsung:{"Galaxy S":1,"Galaxy S2":1,"Galaxy S3":1,"Galaxy S4":1},Sony:{PlayStation:1,"PlayStation Vita":1},Xiaomi:{Mi:1,Redmi:1}}),Re=mr(["Windows Phone","KaiOS","Android","CentOS",{label:"Chrome OS",pattern:"CrOS"},"Debian",{label:"DragonFly BSD",pattern:"DragonFly"},"Fedora","FreeBSD","Gentoo","Haiku","Kubuntu","Linux Mint","OpenBSD","Red Hat","SuSE","Ubuntu","Xubuntu","Cygwin","Symbian OS","hpwOS","webOS ","webOS","Tablet OS","Tizen","Linux","Mac OS X","Macintosh","Mac","Windows 98;","Windows "]);function kt(cr){return Oe(cr,function(Vt,At){return Vt||RegExp("\\b"+(At.pattern||Me(At))+"\\b","i").exec(Z)&&(At.label||At)})}function ot(cr){return Oe(cr,function(Vt,At,M){return Vt||(At[je]||At[/^[a-z]+(?: +[a-z]+\b)*/i.exec(je)]||RegExp("\\b"+Me(M)+"(?:\\b|\\w*\\d)","i").exec(Z))&&M})}function ar(cr){return Oe(cr,function(Vt,At){return Vt||RegExp("\\b"+(At.pattern||Me(At))+"\\b","i").exec(Z)&&(At.label||At)})}function mr(cr){return Oe(cr,function(Vt,At){var M=At.pattern||Me(At);return!Vt&&(Vt=RegExp("\\b"+M+"(?:/[\\d.]+|[ \\w.]*)","i").exec(Z))&&(Vt=m(Vt,M,At.label||At)),Vt})}function Xe(cr){return Oe(cr,function(Vt,At){var M=At.pattern||Me(At);return!Vt&&(Vt=RegExp("\\b"+M+" *\\d+[.\\w_]*","i").exec(Z)||RegExp("\\b"+M+" *\\w+-[\\w]*","i").exec(Z)||RegExp("\\b"+M+"(?:; *(?:[a-z]+[_-])?[a-z]+\\d+|[^ ();-]*)","i").exec(Z))&&((Vt=String(At.label&&!RegExp(M,"i").test(At.label)?At.label:Vt).split("/"))[1]&&!/[\d.]+/.test(Vt[0])&&(Vt[0]+=" "+Vt[1]),At=At.label||At,Vt=L(Vt[0].replace(RegExp(M,"i"),At).replace(RegExp("; *(?:"+At+"[_-])?","i")," ").replace(RegExp("("+At+")[-_.]?(\\w)","i"),"$1 $2"))),Vt})}function Or(cr){return Oe(cr,function(Vt,At){return Vt||(RegExp(At+"(?:-[\\d.]+/|(?: for [\\w-]+)?[ /-])([\\d.]+[^ ();/_-]*)","i").exec(Z)||0)[1]||null})}function jr(){return this.description||""}if(Rt&&(Rt=[Rt]),/\bAndroid\b/.test(Re)&&!je&&(ce=/\bAndroid[^;]*;(.*?)(?:Build|\) AppleWebKit)\b/i.exec(Z))&&(je=Fe(ce[1]).replace(/^[a-z]{2}-[a-z]{2};\s*/i,"")||null),st&&!je?je=Xe([st]):st&&je&&(je=je.replace(RegExp("^("+Me(st)+")[-_.\\s]","i"),st+" ").replace(RegExp("^("+Me(st)+")[-_.]?(\\w)","i"),st+" $2")),(ce=/\bGoogle TV\b/.exec(je))&&(je=ce[0]),/\bSimulator\b/i.test(Z)&&(je=(je?je+" ":"")+"Simulator"),Q=="Opera Mini"&&/\bOPiOS\b/.test(Z)&&Ue.push("running in Turbo/Uncompressed mode"),Q=="IE"&&/\blike iPhone OS\b/.test(Z)?(ce=Pe(Z.replace(/like iPhone OS/,"")),st=ce.manufacturer,je=ce.product):/^iP/.test(je)?(Q||(Q="Safari"),Re="iOS"+((ce=/ OS ([\d_]+)/i.exec(Z))?" "+ce[1].replace(/_/g,"."):"")):Q=="Konqueror"&&/^Linux\b/i.test(Re)?Re="Kubuntu":st&&st!="Google"&&(/Chrome/.test(Q)&&!/\bMobile Safari\b/i.test(Z)||/\bVita\b/.test(je))||/\bAndroid\b/.test(Re)&&/^Chrome/.test(Q)&&/\bVersion\//i.test(Z)?(Q="Android Browser",Re=/\bAndroid\b/.test(Re)?Re:"Android"):Q=="Silk"?(/\bMobi/i.test(Z)||(Re="Android",Ue.unshift("desktop mode")),/Accelerated *= *true/i.test(Z)&&Ue.unshift("accelerated")):Q=="UC Browser"&&/\bUCWEB\b/.test(Z)?Ue.push("speed mode"):Q=="PaleMoon"&&(ce=/\bFirefox\/([\d.]+)\b/.exec(Z))?Ue.push("identifying as Firefox "+ce[1]):Q=="Firefox"&&(ce=/\b(Mobile|Tablet|TV)\b/i.exec(Z))?(Re||(Re="Firefox OS"),je||(je=ce[1])):!Q||(ce=!/\bMinefield\b/i.test(Z)&&/\b(?:Firefox|Safari)\b/.exec(Q))?(Q&&!je&&/[\/,]|^[^(]+?\)/.test(Z.slice(Z.indexOf(ce+"/")+8))&&(Q=null),(ce=je||st||Re)&&(je||st||/\b(?:Android|Symbian OS|Tablet OS|webOS)\b/.test(Re))&&(Q=/[a-z]+(?: Hat)?/i.exec(/\bAndroid\b/.test(Re)?Re:ce)+" Browser")):Q=="Electron"&&(ce=(/\bChrome\/([\d.]+)\b/.exec(Z)||0)[1])&&Ue.push("Chromium "+ce),Ve||(Ve=Or(["(?:Cloud9|CriOS|CrMo|Edge|Edg|EdgA|EdgiOS|FxiOS|HeadlessChrome|IEMobile|Iron|Opera ?Mini|OPiOS|OPR|Raven|SamsungBrowser|Silk(?!/[\\d.]+$)|UCBrowser|YaBrowser)","Version",Me(Q),"(?:Firefox|Minefield|NetFront)"])),(ce=Rt=="iCab"&&parseFloat(Ve)>3&&"WebKit"||/\bOpera\b/.test(Q)&&(/\bOPR\b/.test(Z)?"Blink":"Presto")||/\b(?:Midori|Nook|Safari)\b/i.test(Z)&&!/^(?:Trident|EdgeHTML)$/.test(Rt)&&"WebKit"||!Rt&&/\bMSIE\b/i.test(Z)&&(Re=="Mac OS"?"Tasman":"Trident")||Rt=="WebKit"&&/\bPlayStation\b(?! Vita\b)/i.test(Q)&&"NetFront")&&(Rt=[ce]),Q=="IE"&&(ce=(/; *(?:XBLWP|ZuneWP)(\d+)/i.exec(Z)||0)[1])?(Q+=" Mobile",Re="Windows Phone "+(/\+$/.test(ce)?ce:ce+".x"),Ue.unshift("desktop mode")):/\bWPDesktop\b/i.test(Z)?(Q="IE Mobile",Re="Windows Phone 8.x",Ue.unshift("desktop mode"),Ve||(Ve=(/\brv:([\d.]+)/.exec(Z)||0)[1])):Q!="IE"&&Rt=="Trident"&&(ce=/\brv:([\d.]+)/.exec(Z))&&(Q&&Ue.push("identifying as "+Q+(Ve?" "+Ve:"")),Q="IE",Ve=ce[1]),ht){if(re(Ie,"global"))if(ye&&(ce=ye.lang.System,Ge=ce.getProperty("os.arch"),Re=Re||ce.getProperty("os.name")+" "+ce.getProperty("os.version")),ke){try{Ve=Ie.require("ringo/engine").version.join("."),Q="RingoJS"}catch{(ce=Ie.system)&&ce.global.system==Ie.system&&(Q="Narwhal",Re||(Re=ce[0].os||null))}Q||(Q="Rhino")}else typeof Ie.process=="object"&&!Ie.process.browser&&(ce=Ie.process)&&(typeof ce.versions=="object"&&(typeof ce.versions.electron=="string"?(Ue.push("Node "+ce.versions.node),Q="Electron",Ve=ce.versions.electron):typeof ce.versions.nw=="string"&&(Ue.push("Chromium "+Ve,"Node "+ce.versions.node),Q="NW.js",Ve=ce.versions.nw)),Q||(Q="Node.js",Ge=ce.arch,Re=ce.platform,Ve=/[\d.]+/.exec(ce.version),Ve=Ve?Ve[0]:null));else z(ce=Ie.runtime)==q?(Q="Adobe AIR",Re=ce.flash.system.Capabilities.os):z(ce=Ie.phantom)==H?(Q="PhantomJS",Ve=(ce=ce.version||null)&&ce.major+"."+ce.minor+"."+ce.patch):typeof Ct.documentMode=="number"&&(ce=/\bTrident\/(\d+)/i.exec(Z))?(Ve=[Ve,Ct.documentMode],(ce=+ce[1]+4)!=Ve[1]&&(Ue.push("IE "+Ve[1]+" mode"),Rt&&(Rt[1]=""),Ve[1]=ce),Ve=Q=="IE"?String(Ve[1].toFixed(1)):Ve[0]):typeof Ct.documentMode=="number"&&/^(?:Chrome|Firefox)\b/.test(Q)&&(Ue.push("masking as "+Q+" "+Ve),Q="IE",Ve="11.0",Rt=["Trident"],Re="Windows");Re=Re&&L(Re)}if(Ve&&(ce=/(?:[ab]|dp|pre|[ab]\d+pre)(?:\d+\+?)?$/i.exec(Ve)||/(?:alpha|beta)(?: ?\d)?/i.exec(Z+";"+(ht&&se.appMinorVersion))||/\bMinefield\b/i.test(Z)&&"a")&&(be=/b/i.test(ce)?"beta":"alpha",Ve=Ve.replace(RegExp(ce+"\\+?$"),"")+(be=="beta"?Qe:P)+(/\d+\+?/.exec(ce)||"")),Q=="Fennec"||Q=="Firefox"&&/\b(?:Android|Firefox OS|KaiOS)\b/.test(Re))Q="Firefox Mobile";else if(Q=="Maxthon"&&Ve)Ve=Ve.replace(/\.[\d.]+/,".x");else if(/\bXbox\b/i.test(je))je=="Xbox 360"&&(Re=null),je=="Xbox 360"&&/\bIEMobile\b/.test(Z)&&Ue.unshift("mobile mode");else if((/^(?:Chrome|IE|Opera)$/.test(Q)||Q&&!je&&!/Browser|Mobi/.test(Q))&&(Re=="Windows CE"||/Mobi/i.test(Z)))Q+=" Mobile";else if(Q=="IE"&&ht)try{Ie.external===null&&Ue.unshift("platform preview")}catch{Ue.unshift("embedded")}else(/\bBlackBerry\b/.test(je)||/\bBB10\b/.test(Z))&&(ce=(RegExp(je.replace(/ +/g," *")+"/([.\\d]+)","i").exec(Z)||0)[1]||Ve)?(ce=[ce,/BB10/.test(Z)],Re=(ce[1]?(je=null,st="BlackBerry"):"Device Software")+" "+ce[0],Ve=null):this!=N&&je!="Wii"&&(ht&&tt||/Opera/.test(Q)&&/\b(?:MSIE|Firefox)\b/i.test(Z)||Q=="Firefox"&&/\bOS X (?:\d+\.){2,}/.test(Re)||Q=="IE"&&(Re&&!/^Win/.test(Re)&&Ve>5.5||/\bWindows XP\b/.test(Re)&&Ve>8||Ve==8&&!/\bTrident\b/.test(Z)))&&!u.test(ce=Pe.call(N,Z.replace(u,"")+";"))&&ce.name&&(ce="ing as "+ce.name+((ce=ce.version)?" "+ce:""),u.test(Q)?(/\bIE\b/.test(ce)&&Re=="Mac OS"&&(Re=null),ce="identify"+ce):(ce="mask"+ce,De?Q=L(De.replace(/([a-z])([A-Z])/g,"$1 $2")):Q="Opera",/\bIE\b/.test(ce)&&(Re=null),ht||(Ve=null)),Rt=["Presto"],Ue.push(ce));(ce=(/\bAppleWebKit\/([\d.]+\+?)/i.exec(Z)||0)[1])&&(ce=[parseFloat(ce.replace(/\.(\d)$/,".0$1")),ce],Q=="Safari"&&ce[1].slice(-1)=="+"?(Q="WebKit Nightly",be="alpha",Ve=ce[1].slice(0,-1)):(Ve==ce[1]||Ve==(ce[2]=(/\bSafari\/([\d.]+\+?)/i.exec(Z)||0)[1]))&&(Ve=null),ce[1]=(/\b(?:Headless)?Chrome\/([\d.]+)/i.exec(Z)||0)[1],ce[0]==537.36&&ce[2]==537.36&&parseFloat(ce[1])>=28&&Rt=="WebKit"&&(Rt=["Blink"]),!ht||!te&&!ce[1]?(Rt&&(Rt[1]="like Safari"),ce=(ce=ce[0],ce<400?1:ce<500?2:ce<526?3:ce<533?4:ce<534?"4+":ce<535?5:ce<537?6:ce<538?7:ce<601?8:ce<602?9:ce<604?10:ce<606?11:ce<608?12:"12")):(Rt&&(Rt[1]="like Chrome"),ce=ce[1]||(ce=ce[0],ce<530?1:ce<532?2:ce<532.05?3:ce<533?4:ce<534.03?5:ce<534.07?6:ce<534.1?7:ce<534.13?8:ce<534.16?9:ce<534.24?10:ce<534.3?11:ce<535.01?12:ce<535.02?"13+":ce<535.07?15:ce<535.11?16:ce<535.19?17:ce<536.05?18:ce<536.1?19:ce<537.01?20:ce<537.11?"21+":ce<537.13?23:ce<537.18?24:ce<537.24?25:ce<537.36?26:Rt!="Blink"?"27":"28")),Rt&&(Rt[1]+=" "+(ce+=typeof ce=="number"?".x":/[.+]/.test(ce)?"":"+")),Q=="Safari"&&(!Ve||parseInt(Ve)>45)?Ve=ce:Q=="Chrome"&&/\bHeadlessChrome/i.test(Z)&&Ue.unshift("headless")),Q=="Opera"&&(ce=/\bzbov|zvav$/.exec(Re))?(Q+=" ",Ue.unshift("desktop mode"),ce=="zvav"?(Q+="Mini",Ve=null):Q+="Mobile",Re=Re.replace(RegExp(" *"+ce+"$"),"")):Q=="Safari"&&/\bChrome\b/.exec(Rt&&Rt[1])?(Ue.unshift("desktop mode"),Q="Chrome Mobile",Ve=null,/\bOS X\b/.test(Re)?(st="Apple",Re="iOS 4.3+"):Re=null):/\bSRWare Iron\b/.test(Q)&&!Ve&&(Ve=Or("Chrome")),Ve&&Ve.indexOf(ce=/[\d.]+$/.exec(Re))==0&&Z.indexOf("/"+ce+"-")>-1&&(Re=Fe(Re.replace(ce,""))),Re&&Re.indexOf(Q)!=-1&&!RegExp(Q+" OS").test(Re)&&(Re=Re.replace(RegExp(" *"+Me(Q)+" *"),"")),Rt&&!/\b(?:Avant|Nook)\b/.test(Q)&&(/Browser|Lunascape|Maxthon/.test(Q)||Q!="Safari"&&/^iOS/.test(Re)&&/\bSafari\b/.test(Rt[1])||/^(?:Adobe|Arora|Breach|Midori|Opera|Phantom|Rekonq|Rock|Samsung Internet|Sleipnir|SRWare Iron|Vivaldi|Web)/.test(Q)&&Rt[1])&&(ce=Rt[Rt.length-1])&&Ue.push(ce),Ue.length&&(Ue=["("+Ue.join("; ")+")"]),st&&je&&je.indexOf(st)<0&&Ue.push("on "+st),je&&Ue.push((/^on /.test(Ue[Ue.length-1])?"":"on ")+je),Re&&(ce=/ ([\d.+]+)$/.exec(Re),Kt=ce&&Re.charAt(Re.length-ce[0].length-1)=="/",Re={architecture:32,family:ce&&!Kt?Re.replace(ce[0],""):Re,version:ce?ce[1]:null,toString:function(){var cr=this.version;return this.family+(cr&&!Kt?" "+cr:"")+(this.architecture==64?" 64-bit":"")}}),(ce=/\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(Ge))&&!/\bi686\b/i.test(Ge)?(Re&&(Re.architecture=64,Re.family=Re.family.replace(RegExp(" *"+ce),"")),Q&&(/\bWOW64\b/i.test(Z)||ht&&/\w(?:86|32)$/.test(se.cpuClass||se.platform)&&!/\bWin64; x64\b/i.test(Z))&&Ue.unshift("32-bit")):Re&&/^OS X/.test(Re.family)&&Q=="Chrome"&&parseFloat(Ve)>=39&&(Re.architecture=64),Z||(Z=null);var lr={};return lr.description=Z,lr.layout=Rt&&Rt[0],lr.manufacturer=st,lr.name=Q,lr.prerelease=be,lr.product=je,lr.ua=Z,lr.version=Q&&Ve,lr.os=Re||{architecture:null,family:null,version:null,toString:function(){return"null"}},lr.parse=Pe,lr.toString=jr,lr.version&&Ue.unshift(Ve),lr.name&&Ue.unshift(Q),Re&&Q&&!(Re==String(Re).split(" ")[0]&&(Re==Q.split(" ")[0]||je))&&Ue.push(je?"("+Re+")":"on "+Re),Ue.length&&(lr.description=Ue.join(" ")),lr}var Ze=Pe();i&&a?N(Ze,function(Z,Ie){i[Ie]=Z}):n.platform=Ze}).call(sn)}(ap,ap.exports);var nb=ap.exports,qY=$r,VY=_h,WY=Wr,ZY=ki,GY=wa,ib=Xr,KY=Si,YY=fo,JY=Gm,KI=kh;VY("match",function(t,e,r){return[function(i){var a=KY(this),s=ZY(i)?void 0:YY(i,t);return s?qY(s,i,a):new RegExp(i)[t](ib(a))},function(n){var i=WY(this),a=ib(n),s=r(e,i,a);if(s.done)return s.value;if(!i.global)return KI(i,a);var o=i.unicode;i.lastIndex=0;for(var u=[],l=0,c;(c=KI(i,a))!==null;){var d=ib(c[0]);u[l]=d,d===""&&(i.lastIndex=JY(a,GY(i.lastIndex),o)),l++}return l===0?null:u}]});var QY=Object.is||function(e,r){return e===r?e!==0||1/e===1/r:e!==e&&r!==r},XY=$r,eJ=_h,tJ=Wr,rJ=ki,nJ=Si,YI=QY,JI=Xr,iJ=fo,aJ=kh;eJ("search",function(t,e,r){return[function(i){var a=nJ(this),s=rJ(i)?void 0:iJ(i,t);return s?XY(s,i,a):new RegExp(i)[t](JI(a))},function(n){var i=tJ(this),a=JI(n),s=r(e,i,a);if(s.done)return s.value;var o=i.lastIndex;YI(o,0)||(i.lastIndex=0);var u=aJ(i,a);return YI(i.lastIndex,o)||(i.lastIndex=o),u===null?-1:u.index}]});var sJ=xr,oJ=Ec,uJ=TypeError,lJ=Object.getOwnPropertyDescriptor,cJ=sJ&&!function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(t){return t instanceof TypeError}}(),dJ=cJ?function(t,e){if(oJ(t)&&!lJ(t,"length").writable)throw new uJ("Cannot set read only .length");return t.length=e}:function(t,e){return t.length=e},fJ=Xt,hJ=vn,pJ=yu,vJ=Wi,gJ=gn,mJ=dJ,yJ=w$,bJ=Cg,wJ=Mc,ab=Fy,_J=Pc,kJ=_J("splice"),SJ=Math.max,$J=Math.min;fJ({target:"Array",proto:!0,forced:!kJ},{splice:function(e,r){var n=hJ(this),i=gJ(n),a=pJ(e,i),s=arguments.length,o,u,l,c,d,f;for(s===0?o=u=0:s===1?(o=0,u=i-a):(o=s-2,u=$J(SJ(vJ(r),0),i-a)),yJ(i+o-u),l=bJ(n,u),c=0;c<u;c++)d=a+c,d in n&&wJ(l,c,n[d]);if(l.length=u,o<u){for(c=a;c<i-u;c++)d=c+u,f=c+o,d in n?n[f]=n[d]:ab(n,f);for(c=i;c>i-u+o;c--)ab(n,c-1)}else if(o>u)for(c=i-u;c>a;c--)d=c+u-1,f=c+o-1,d in n?n[f]=n[d]:ab(n,f);for(c=0;c<o;c++)n[c+a]=arguments[c+2];return mJ(n,i-u+o),l}});/*
839
839
  @license
840
840
  The following license applies to all parts of this software except as
841
841
  documented below.
@@ -918,10 +918,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
918
918
  OTHER DEALINGS IN THE SOFTWARE.
919
919
 
920
920
 
921
- */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=ku,n=cs,i=Rh,a=Yi,s=Ji,o=ii,u=$a,l=Qi,c=ds,d=Au,f=ni,m=en,k=Ou,L=AC,N=Qc,z=ad,re=Xi,Me=xh,Oe=nb;function Be(ee){return ee&&typeof ee=="object"&&"default"in ee?ee:{default:ee}}function Pe(ee){if(ee&&ee.__esModule)return ee;var ue=Object.create(null);return ee&&Object.keys(ee).forEach(function(R){if(R!=="default"){var A=Object.getOwnPropertyDescriptor(ee,R);Object.defineProperty(ue,R,A.get?A:{enumerable:!0,get:function(){return ee[R]}})}}),ue.default=ee,Object.freeze(ue)}var Ze=Be(r),Z=Be(n),Ie=Be(i),_e=Be(a),se=Be(s),Te=Be(o),te=Be(u),oe=Be(l),q=Be(c),ne=Be(d),Se=Be(f),H=Pe(k),ye=Pe(L),ke=Be(z),P=Pe(Oe);function Qe(ee,ue,R,A){var I=arguments.length,W=I<3?ue:A===null?A=Object.getOwnPropertyDescriptor(ue,R):A,j;if((typeof Reflect>"u"?"undefined":Se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")W=Reflect.decorate(ee,ue,R,A);else for(var Le=ee.length-1;Le>=0;Le--)(j=ee[Le])&&(W=(I<3?j(W):I>3?j(ue,R,W):j(ue,R))||W);return I>3&&W&&Object.defineProperty(ue,R,W),W}function Ct(ee,ue){if((typeof Reflect>"u"?"undefined":Se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(ee,ue)}var tt=H.getLogger("twilsock");function De(ee,ue){return["".concat(new Date().toISOString()," Twilsock ").concat(ee,":")].concat(Array.from(ue))}var ce=function(){function ee(ue){oe.default(this,ee),q.default(this,"prefix",""),this.prefix=ue!=null&&ue.length>0?" "+ue+":":""}return te.default(ee,[{key:"setLevel",value:function(R){tt.setLevel(R)}},{key:"trace",value:function(){if(tt.getLevel()==tt.levels.TRACE){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.debug.apply(null,De("T",A))}}},{key:"debug",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.debug.apply(null,De("D",A))}},{key:"info",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.info.apply(null,De("I",A))}},{key:"warn",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.warn.apply(null,De("W",A))}},{key:"error",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.error.apply(null,De("E",A))}}],[{key:"setLevel",value:function(R){tt.setLevel(R)}},{key:"trace",value:function(){if(tt.getLevel()==tt.levels.TRACE){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.debug.apply(null,De("T",A))}}},{key:"debug",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.debug.apply(null,De("D",A))}},{key:"info",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.info.apply(null,De("I",A))}},{key:"warn",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.warn.apply(null,De("W",A))}},{key:"error",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.error.apply(null,De("E",A))}}]),ee}(),Ge=new ce(""),Ue="0.13.12",be=function(){function ee(ue,R,A){oe.default(this,ee),q.default(this,"confirmedCapabilities",new Set),this.activeGrant=R,this._token=ue;var I=A.region||"us1",W="wss://tsock.".concat(I,".twilio.com/v3/wsconnect"),j=A.twilsock||A.Twilsock||{};this.url=j.uri||W,this._continuationToken=A.continuationToken?A.continuationToken:null,this.logLevel=A.logLevel?A.logLevel:"error",this.retryPolicy=A.retryPolicy?A.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=A.clientMetadata?A.clientMetadata:{},this.clientMetadata.ver=Ue,this.initRegistrations=A.initRegistrations?A.initRegistrations:null,this.tweaks=A.tweaks?A.tweaks:null}return te.default(ee,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(R){this._token=R}},{key:"updateContinuationToken",value:function(R){this._continuationToken=R}}]),ee}(),ht=te.default(function ee(ue){oe.default(this,ee),this.id=ue||"TM".concat(N.v4())});function Ve(ee){var ue=Kt();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function Kt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Rt=function(ee){_e.default(R,ee);var ue=Ve(R);function R(A,I,W,j,Le){var xe;return oe.default(this,R),xe=ue.call(this),q.default(Z.default(xe),"method","init"),xe.token=A,xe.continuation_token=I,xe.metadata=W,xe.registrations=j,xe.tweaks=Le,xe.capabilities=["client_update","offline_storage","telemetry.v1"],xe}return te.default(R)}(ht);function Q(ee){var ue=je();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function je(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var st=function(ee){_e.default(R,ee);var ue=Q(R);function R(A,I,W,j,Le,xe,He){var it;return oe.default(this,R),it=ue.call(this,A),it.continuationToken=I,it.continuationTokenStatus=j,it.offlineStorage=Le,it.initRegistrations=xe,it.debugInfo=He,it.confirmedCapabilities=W,it}return te.default(R)}(ht);function Re(ee){var ue=kt();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function kt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ot=function(ee){_e.default(R,ee);var ue=Re(R);function R(A){var I;return oe.default(this,R),I=ue.call(this),q.default(Z.default(I),"method","update"),I.token=A,I}return te.default(R)}(ht);function ar(ee){var ue=mr();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function mr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Xe=function(ee){_e.default(R,ee);var ue=ar(R);function R(A,I,W){var j;return oe.default(this,R),j=ue.call(this),q.default(Z.default(j),"method","message"),j.active_grant=A,j.payload_type=I,j.http_request=W,j}return te.default(R)}(ht);function Or(ee){var ue=jr();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function jr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var lr=function(ee){_e.default(R,ee);var ue=Or(R);function R(A){var I;return oe.default(this,R),I=ue.call(this,A),q.default(Z.default(I),"method","reply"),q.default(Z.default(I),"payload_type","application/json"),q.default(Z.default(I),"status",{code:200,status:"OK"}),I}return te.default(R)}(ht);function cr(ee){var ue=Vt();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function Vt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var At=function(ee){_e.default(R,ee);var ue=cr(R);function R(){var A;return oe.default(this,R),A=ue.call(this),q.default(Z.default(A),"method","close"),A}return te.default(R)}(ht);function M(ee){var ue=V();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function V(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ie=te.default(function ee(ue,R,A,I,W,j){oe.default(this,ee),this.start=ue,this.end=R,this.title=A,this.details=I,this.id=W,this.type=j}),Fe=function(ee){_e.default(R,ee);var ue=M(R);function R(A){var I;return oe.default(this,R),I=ue.call(this),q.default(Z.default(I),"method","telemetry.v1"),I.events=A,I}return te.default(R)}(ht);function lt(ee){var ue=encodeURIComponent(ee),R=ue.replace(/%([0-9A-F]{2})/g,function(A,I){return String.fromCharCode(+("0x"+I))});return R.length}function yt(ee){var ue=encodeURIComponent(ee),R=ue.replace(/%([0-9A-F]{2})/g,function(I,W){return String.fromCharCode(+("0x"+W))}),A=new Uint8Array(R.length);return Array.prototype.forEach.call(R,function(I,W){A[W]=I.charCodeAt(0)}),A}function Bt(ee){var ue=Array.prototype.map.call(ee,function(A){return String.fromCharCode(A)}).join(""),R=ue.replace(/(.)/g,function(A,I){var W=I.charCodeAt(0).toString(16).toUpperCase();return W.length<2&&(W="0"+W),"%"+W});return decodeURIComponent(R)}function er(ee){return JSON.parse(Bt(ee))}function Ee(ee){for(var ue="",R=0;R<ee.length;++R){var A=String.fromCharCode(ee[R]);if(ue+=A,A==="\r"){R+=2;break}}var I=ue.split(" ");return{size:R,protocol:I[0],version:I[1],headerSize:Number(I[2])}}var Ne=function(){function ee(){oe.default(this,ee)}return te.default(ee,null,[{key:"parse",value:function(R){var A=2,I=new Uint8Array(R),W=Ee(I);if(W.protocol!=="TWILSOCK"||W.version!=="V3.0")return Ge.error("unsupported protocol: ".concat(W.protocol," ver ").concat(W.version)),null;var j;try{j=er(I.subarray(W.size,W.size+W.headerSize))}catch(it){return Ge.error("failed to parse message header",it,R),null}Ge.debug("message received:",j.method);var Le;if(j.payload_size>0){var xe=A+W.size+W.headerSize,He=j.payload_size;if(!j.hasOwnProperty("payload_type")||j.payload_type.indexOf("application/json")===0)try{Le=er(I.subarray(xe,xe+He))}catch(it){return Ge.error("failed to parse message body",it,R),null}else j.payload_type.indexOf("text/plain")===0&&(Le=Bt(I.subarray(xe,xe+He)))}return{method:j.method,header:j,payload:Le}}},{key:"createPacket",value:function(R){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";R.payload_size=lt(A);var I=JSON.stringify(R),W="TWILSOCK V3.0 "+lt(I);Ge.debug("send request:",W+I+A);var j=yt(W+`\r
921
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=ku,n=cs,i=Rh,a=Yi,s=Ji,o=ii,u=$a,l=Qi,c=ds,d=Au,f=ni,m=en,k=Ou,L=AC,N=Qc,z=ad,re=Xi,Me=xh,Oe=nb;function Fe(ee){return ee&&typeof ee=="object"&&"default"in ee?ee:{default:ee}}function Pe(ee){if(ee&&ee.__esModule)return ee;var ue=Object.create(null);return ee&&Object.keys(ee).forEach(function(R){if(R!=="default"){var A=Object.getOwnPropertyDescriptor(ee,R);Object.defineProperty(ue,R,A.get?A:{enumerable:!0,get:function(){return ee[R]}})}}),ue.default=ee,Object.freeze(ue)}var Ze=Fe(r),Z=Fe(n),Ie=Fe(i),_e=Fe(a),se=Fe(s),Te=Fe(o),te=Fe(u),oe=Fe(l),q=Fe(c),ne=Fe(d),Se=Fe(f),H=Pe(k),ye=Pe(L),ke=Fe(z),P=Pe(Oe);function Qe(ee,ue,R,A){var I=arguments.length,W=I<3?ue:A===null?A=Object.getOwnPropertyDescriptor(ue,R):A,j;if((typeof Reflect>"u"?"undefined":Se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")W=Reflect.decorate(ee,ue,R,A);else for(var Le=ee.length-1;Le>=0;Le--)(j=ee[Le])&&(W=(I<3?j(W):I>3?j(ue,R,W):j(ue,R))||W);return I>3&&W&&Object.defineProperty(ue,R,W),W}function Ct(ee,ue){if((typeof Reflect>"u"?"undefined":Se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(ee,ue)}var tt=H.getLogger("twilsock");function De(ee,ue){return["".concat(new Date().toISOString()," Twilsock ").concat(ee,":")].concat(Array.from(ue))}var ce=function(){function ee(ue){oe.default(this,ee),q.default(this,"prefix",""),this.prefix=ue!=null&&ue.length>0?" "+ue+":":""}return te.default(ee,[{key:"setLevel",value:function(R){tt.setLevel(R)}},{key:"trace",value:function(){if(tt.getLevel()==tt.levels.TRACE){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.debug.apply(null,De("T",A))}}},{key:"debug",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.debug.apply(null,De("D",A))}},{key:"info",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.info.apply(null,De("I",A))}},{key:"warn",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.warn.apply(null,De("W",A))}},{key:"error",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.error.apply(null,De("E",A))}}],[{key:"setLevel",value:function(R){tt.setLevel(R)}},{key:"trace",value:function(){if(tt.getLevel()==tt.levels.TRACE){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.debug.apply(null,De("T",A))}}},{key:"debug",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.debug.apply(null,De("D",A))}},{key:"info",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.info.apply(null,De("I",A))}},{key:"warn",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.warn.apply(null,De("W",A))}},{key:"error",value:function(){for(var R=arguments.length,A=new Array(R),I=0;I<R;I++)A[I]=arguments[I];tt.error.apply(null,De("E",A))}}]),ee}(),Ge=new ce(""),Ue="0.13.12",be=function(){function ee(ue,R,A){oe.default(this,ee),q.default(this,"confirmedCapabilities",new Set),this.activeGrant=R,this._token=ue;var I=A.region||"us1",W="wss://tsock.".concat(I,".twilio.com/v3/wsconnect"),j=A.twilsock||A.Twilsock||{};this.url=j.uri||W,this._continuationToken=A.continuationToken?A.continuationToken:null,this.logLevel=A.logLevel?A.logLevel:"error",this.retryPolicy=A.retryPolicy?A.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=A.clientMetadata?A.clientMetadata:{},this.clientMetadata.ver=Ue,this.initRegistrations=A.initRegistrations?A.initRegistrations:null,this.tweaks=A.tweaks?A.tweaks:null}return te.default(ee,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(R){this._token=R}},{key:"updateContinuationToken",value:function(R){this._continuationToken=R}}]),ee}(),ht=te.default(function ee(ue){oe.default(this,ee),this.id=ue||"TM".concat(N.v4())});function Ve(ee){var ue=Kt();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function Kt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Rt=function(ee){_e.default(R,ee);var ue=Ve(R);function R(A,I,W,j,Le){var xe;return oe.default(this,R),xe=ue.call(this),q.default(Z.default(xe),"method","init"),xe.token=A,xe.continuation_token=I,xe.metadata=W,xe.registrations=j,xe.tweaks=Le,xe.capabilities=["client_update","offline_storage","telemetry.v1"],xe}return te.default(R)}(ht);function Q(ee){var ue=je();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function je(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var st=function(ee){_e.default(R,ee);var ue=Q(R);function R(A,I,W,j,Le,xe,He){var it;return oe.default(this,R),it=ue.call(this,A),it.continuationToken=I,it.continuationTokenStatus=j,it.offlineStorage=Le,it.initRegistrations=xe,it.debugInfo=He,it.confirmedCapabilities=W,it}return te.default(R)}(ht);function Re(ee){var ue=kt();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function kt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ot=function(ee){_e.default(R,ee);var ue=Re(R);function R(A){var I;return oe.default(this,R),I=ue.call(this),q.default(Z.default(I),"method","update"),I.token=A,I}return te.default(R)}(ht);function ar(ee){var ue=mr();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function mr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Xe=function(ee){_e.default(R,ee);var ue=ar(R);function R(A,I,W){var j;return oe.default(this,R),j=ue.call(this),q.default(Z.default(j),"method","message"),j.active_grant=A,j.payload_type=I,j.http_request=W,j}return te.default(R)}(ht);function Or(ee){var ue=jr();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function jr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var lr=function(ee){_e.default(R,ee);var ue=Or(R);function R(A){var I;return oe.default(this,R),I=ue.call(this,A),q.default(Z.default(I),"method","reply"),q.default(Z.default(I),"payload_type","application/json"),q.default(Z.default(I),"status",{code:200,status:"OK"}),I}return te.default(R)}(ht);function cr(ee){var ue=Vt();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function Vt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var At=function(ee){_e.default(R,ee);var ue=cr(R);function R(){var A;return oe.default(this,R),A=ue.call(this),q.default(Z.default(A),"method","close"),A}return te.default(R)}(ht);function M(ee){var ue=V();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function V(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ie=te.default(function ee(ue,R,A,I,W,j){oe.default(this,ee),this.start=ue,this.end=R,this.title=A,this.details=I,this.id=W,this.type=j}),Be=function(ee){_e.default(R,ee);var ue=M(R);function R(A){var I;return oe.default(this,R),I=ue.call(this),q.default(Z.default(I),"method","telemetry.v1"),I.events=A,I}return te.default(R)}(ht);function lt(ee){var ue=encodeURIComponent(ee),R=ue.replace(/%([0-9A-F]{2})/g,function(A,I){return String.fromCharCode(+("0x"+I))});return R.length}function yt(ee){var ue=encodeURIComponent(ee),R=ue.replace(/%([0-9A-F]{2})/g,function(I,W){return String.fromCharCode(+("0x"+W))}),A=new Uint8Array(R.length);return Array.prototype.forEach.call(R,function(I,W){A[W]=I.charCodeAt(0)}),A}function Bt(ee){var ue=Array.prototype.map.call(ee,function(A){return String.fromCharCode(A)}).join(""),R=ue.replace(/(.)/g,function(A,I){var W=I.charCodeAt(0).toString(16).toUpperCase();return W.length<2&&(W="0"+W),"%"+W});return decodeURIComponent(R)}function er(ee){return JSON.parse(Bt(ee))}function Ee(ee){for(var ue="",R=0;R<ee.length;++R){var A=String.fromCharCode(ee[R]);if(ue+=A,A==="\r"){R+=2;break}}var I=ue.split(" ");return{size:R,protocol:I[0],version:I[1],headerSize:Number(I[2])}}var Ne=function(){function ee(){oe.default(this,ee)}return te.default(ee,null,[{key:"parse",value:function(R){var A=2,I=new Uint8Array(R),W=Ee(I);if(W.protocol!=="TWILSOCK"||W.version!=="V3.0")return Ge.error("unsupported protocol: ".concat(W.protocol," ver ").concat(W.version)),null;var j;try{j=er(I.subarray(W.size,W.size+W.headerSize))}catch(it){return Ge.error("failed to parse message header",it,R),null}Ge.debug("message received:",j.method);var Le;if(j.payload_size>0){var xe=A+W.size+W.headerSize,He=j.payload_size;if(!j.hasOwnProperty("payload_type")||j.payload_type.indexOf("application/json")===0)try{Le=er(I.subarray(xe,xe+He))}catch(it){return Ge.error("failed to parse message body",it,R),null}else j.payload_type.indexOf("text/plain")===0&&(Le=Bt(I.subarray(xe,xe+He)))}return{method:j.method,header:j,payload:Le}}},{key:"createPacket",value:function(R){var A=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";R.payload_size=lt(A);var I=JSON.stringify(R),W="TWILSOCK V3.0 "+lt(I);Ge.debug("send request:",W+I+A);var j=yt(W+`\r
922
922
  `+I+`\r
923
923
  `+A);return j.buffer}}]),ee}();function pe(ee){var ue=$e();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function $e(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ae=function(ee){_e.default(R,ee);var ue=pe(R);function R(A){return oe.default(this,R),ue.call(this,A)}return te.default(R)}(ke.default(Error));function ge(ee){var ue=we();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function we(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var K=function(ee){_e.default(R,ee);var ue=ge(R);function R(A,I){var W;return oe.default(this,R),W=ue.call(this,A),W.reply=I,W}return te.default(R)}(ae);function he(ee,ue){var R=Object.keys(ee);if(Object.getOwnPropertySymbols){var A=Object.getOwnPropertySymbols(ee);ue&&(A=A.filter(function(I){return Object.getOwnPropertyDescriptor(ee,I).enumerable})),R.push.apply(R,A)}return R}function G(ee){for(var ue=1;ue<arguments.length;ue++){var R=arguments[ue]!=null?arguments[ue]:{};ue%2?he(Object(R),!0).forEach(function(A){q.default(ee,A,R[A])}):Object.getOwnPropertyDescriptors?Object.defineProperties(ee,Object.getOwnPropertyDescriptors(R)):he(Object(R)).forEach(function(A){Object.defineProperty(ee,A,Object.getOwnPropertyDescriptor(R,A))})}return ee}function de(ee){var ue=X();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function X(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ye=function(ee){_e.default(R,ee);var ue=de(R);function R(A){var I;return oe.default(this,R),I=ue.call(this),q.default(Z.default(I),"newBackoff",null),q.default(Z.default(I),"usedBackoff",null),q.default(Z.default(I),"retrier",null),I.options=A?G({},A):{},I}return te.default(R,[{key:"inProgress",get:function(){return!!this.retrier}},{key:"start",value:function(){if(this.inProgress)throw new Error("Already waiting for next attempt, call finishAttempt(success : boolean) to finish it");this.createRetrier()}},{key:"stop",value:function(){this.cleanRetrier(),this.newBackoff=null,this.usedBackoff=null}},{key:"modifyBackoff",value:function(I){this.newBackoff=I}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");if(this.newBackoff){var I=!this.usedBackoff||this.usedBackoff<this.newBackoff;if(I)this.createRetrier();else{var W;(W=this.retrier)===null||W===void 0||W.failed(new Error)}}else{var j;(j=this.retrier)===null||j===void 0||j.failed(new Error)}}},{key:"cancel",value:function(){var I;(I=this.retrier)===null||I===void 0||I.cancel()}},{key:"cleanRetrier",value:function(){var I,W;(I=this.retrier)===null||I===void 0||I.removeAllListeners(),(W=this.retrier)===null||W===void 0||W.cancel(),this.retrier=null}},{key:"getRetryPolicy",value:function(){var I=G({},this.options);return this.newBackoff&&(I.min=this.newBackoff,I.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),I.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,I}},{key:"createRetrier",value:function(){var I=this;this.cleanRetrier();var W=this.getRetryPolicy();this.retrier=new re.Retrier(W),this.retrier.once("attempt",function(){var j,Le;(j=I.retrier)===null||j===void 0||j.on("attempt",function(){return I.emit("attempt")}),(Le=I.retrier)===null||Le===void 0||Le.failed(new Error("Skipping first attempt"))}),this.retrier.on("failed",function(j){return I.emit("failed",j)}),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start()}}]),R}(Me.ReplayEventEmitter);function ze(ee){var ue=ct();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function ct(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ut=3e3;function ft(ee){setTimeout(ee,0)}var Et=function(ee){_e.default(R,ee);var ue=ze(R);function R(A,I,W){var j;oe.default(this,R),j=ue.call(this),q.default(Z.default(j),"disconnectingTimer",null),q.default(Z.default(j),"disconnectedPromiseResolve",null),q.default(Z.default(j),"terminalStates",["disconnected","rejected"]),q.default(Z.default(j),"tokenExpiredSasCode",20104),q.default(Z.default(j),"terminationReason","Connection is not initialized"),j.websocket=A,j.websocket.on("connected",function(){return j.fsm.socketConnected()}),j.websocket.on("disconnected",function(){return j.fsm.socketClosed()}),j.websocket.on("message",function(xe){return j.onIncomingMessage(xe)}),j.websocket.on("socketError",function(xe){j.emit("connectionError",{terminal:!1,message:"Socket error: ".concat(xe.message),httpStatusCode:null,errorCode:null}),j.emit("stateChanged","retrying")}),j.transport=I,j.config=W,j.retrier=new Ye(W.retryPolicy),j.retrier.on("attempt",function(){return j.retry()}),j.retrier.on("failed",function(xe){Ge.warn("Retrying failed: ".concat(xe.message)),j.disconnect()}),typeof window<"u"&&typeof window.addEventListener<"u"&&(window.addEventListener("online",function(){Ge.debug("Browser reported connectivity state: online"),j.resetBackoff(),j.fsm.systemOnline()}),window.addEventListener("offline",function(){Ge.debug("Browser reported connectivity state: offline"),j.websocket.close(),j.fsm.socketClosed()}));var Le=ye.factory({init:"disconnected",transitions:[{name:"userConnect",from:["disconnected","rejected"],to:"connecting"},{name:"userConnect",from:["connecting","connected"]},{name:"userDisconnect",from:["connecting","initialising","connected","updating","retrying","rejected","waitSocketClosed","waitOffloadSocketClosed"],to:"disconnecting"},{name:"userRetry",from:["retrying"],to:"connecting"},{name:"socketConnected",from:["connecting"],to:"initialising"},{name:"socketClosed",from:["connecting","initialising","connected","updating","error","waitOffloadSocketClosed"],to:"retrying"},{name:"socketClosed",from:["disconnecting"],to:"disconnected"},{name:"socketClosed",from:["waitSocketClosed"],to:"disconnected"},{name:"socketClosed",from:["rejected"],to:"rejected"},{name:"initSuccess",from:["initialising"],to:"connected"},{name:"initError",from:["initialising"],to:"error"},{name:"tokenRejected",from:["initialising","updating"],to:"rejected"},{name:"protocolError",from:["initialising","connected","updating"],to:"error"},{name:"receiveClose",from:["initialising","connected","updating"],to:"waitSocketClosed"},{name:"receiveOffload",from:["initialising","connected","updating"],to:"waitOffloadSocketClosed"},{name:"unsupportedProtocol",from:["initialising","connected","updating"],to:"unsupported"},{name:"receiveFatalClose",from:["initialising","connected","updating"],to:"unsupported"},{name:"userUpdateToken",from:["disconnected","rejected","connecting","retrying"],to:"connecting"},{name:"userUpdateToken",from:["connected"],to:"updating"},{name:"updateSuccess",from:["updating"],to:"connected"},{name:"updateError",from:["updating"],to:"error"},{name:"userSend",from:["connected"],to:"connected"},{name:"systemOnline",from:["retrying"],to:"connecting"}],methods:{onConnecting:function(){j.setupSocket(),j.emit("connecting")},onEnterInitialising:function(){j.sendInit()},onLeaveInitialising:function(){j.cancelInit()},onEnterUpdating:function(){j.sendUpdate()},onLeaveUpdating:function(){j.cancelUpdate()},onEnterRetrying:function(){j.initRetry(),j.emit("connecting")},onEnterConnected:function(){j.resetBackoff(),j.onConnected()},onUserUpdateToken:function(){j.resetBackoff()},onTokenRejected:function(){j.resetBackoff(),j.closeSocket(!0),j.finalizeSocket()},onUserDisconnect:function(){j.closeSocket(!0)},onEnterDisconnecting:function(){j.startDisconnectTimer()},onLeaveDisconnecting:function(){j.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){j.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){j.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){j.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){j.cancelDisconnectTimer()},onDisconnected:function(){j.resetBackoff(),j.finalizeSocket()},onReceiveClose:function(){j.onCloseReceived()},onReceiveOffload:function(He,it){Ge.debug("onreceiveoffload: ",it),j.modifyBackoff(it.body),j.onCloseReceived()},onUnsupported:function(){j.closeSocket(!0),j.finalizeSocket()},onError:function(He,it){j.closeSocket(it),j.finalizeSocket()},onEnterState:function(He){He.from!=="none"&&j.changeState(He)},onInvalidTransition:function(He,it,$t){Ge.warn("FSM: unexpected transition",it,$t)}}});return j.fsm=new Le,j}return te.default(R,[{key:"changeState",value:function(I){Ge.debug("FSM: ".concat(I.transition,": ").concat(I.from," --> ").concat(I.to)),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){Ge.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function(I){Ge.trace("modifyBackoff",I);var W=I?I.backoff_policy:null;W&&typeof W.reconnect_min_ms=="number"&&this.retrier.modifyBackoff(W.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var I=this;Ge.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout(function(){Ge.debug("disconnecting is timed out"),I.closeSocket(!0)},ut)}},{key:"cancelDisconnectTimer",value:function(){Ge.trace("cancelDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null)}},{key:"isConnected",get:function(){return this.state==="connected"&&this.websocket.isConnected}},{key:"state",get:function(){switch(this.fsm.state){case"connecting":case"initialising":case"retrying":case"error":return"connecting";case"updating":case"connected":return"connected";case"rejected":return"denied";case"disconnecting":case"waitSocketClosed":case"waitOffloadSocketClosed":return"disconnecting";case"disconnected":default:return"disconnected"}}},{key:"initRetry",value:function(){Ge.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){this.fsm.state!="connecting"?(Ge.trace("retry"),this.websocket.close(),this.fsm.userRetry()):Ge.trace("can retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){Ge.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){Ge.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function(I){var W=Ne.parse(I);if(W){var j=W.method,Le=W.header,xe=W.payload;if(j!=="reply"&&this.confirmReceiving(Le),j==="notification")this.emit("message",Le.message_type,xe);else if(Le.method==="reply")this.transport.processReply({id:Le.id,status:Le.status,header:Le,body:xe});else if(Le.method==="client_update")Le.client_update_type==="token_about_to_expire"&&this.emit("tokenAboutToExpire");else if(Le.method==="close")if(Le.status.code===308)Ge.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:Le.status.status,body:xe});else if(Le.status.code===406){var He="Server closed connection because can't parse protocol: ".concat(JSON.stringify(Le.status));this.emitReplyConnectionError(He,Le,!0),Ge.error(He),this.fsm.receiveFatalClose()}else Le.status.code===417?(Ge.error("Server closed connection because can't parse client reply: ".concat(JSON.stringify(Le.status))),this.fsm.receiveFatalClose(Le.status.status)):Le.status.code===410?(Ge.warn("Server closed connection: ".concat(JSON.stringify(Le.status))),this.fsm.receiveClose(Le.status.status),this.emit("tokenExpired")):Le.status.code===401?(Ge.error("Server closed connection: ".concat(JSON.stringify(Le.status))),this.fsm.receiveClose(Le.status.status)):(Ge.warn("unexpected message: ",Le.status),this.fsm.receiveOffload({status:Le.status.status,body:null}))}}},{key:"sendInit",value:function(){var A=Ze.default(ne.default.mark(function W(){var j,Le;return ne.default.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:return Ge.trace("sendInit"),He.prev=1,this.emit("beforeSendInit"),He.next=5,this.transport.sendInit();case 5:j=He.sent,this.config.updateContinuationToken(j.continuationToken),this.config.confirmedCapabilities=j.confirmedCapabilities,this.fsm.initSuccess(j),this.emit("initialized",j),this.emit("tokenUpdated"),He.next=17;break;case 13:He.prev=13,He.t0=He.catch(1),He.t0 instanceof K?(Le=!1,Ge.warn("Init rejected by server: ".concat(JSON.stringify(He.t0.reply.status))),this.emit("sendInitFailed"),He.t0.reply.status.code===401||He.t0.reply.status.code===403?(Le=!0,this.fsm.tokenRejected(He.t0.reply.status),He.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):He.t0.reply.status.code===429?(this.modifyBackoff(He.t0.reply.body),this.fsm.initError(!0)):He.t0.reply.status.code===500?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(He.t0.message,He.t0.reply,Le)):(this.terminationReason=He.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: ".concat(He.t0.message,`
924
- `).concat(JSON.stringify(He.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",He.t0);case 17:case"end":return He.stop()}},W,this,[[1,13]])}));function I(){return A.apply(this,arguments)}return I}()},{key:"sendUpdate",value:function(){var A=Ze.default(ne.default.mark(function W(){var j,Le,xe;return ne.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return Ge.trace("sendUpdate"),j=new ot(this.config.token),it.prev=2,it.next=5,this.transport.sendWithReply(j);case 5:Le=it.sent,this.fsm.updateSuccess(Le.body),this.emit("tokenUpdated"),it.next=14;break;case 10:it.prev=10,it.t0=it.catch(2),it.t0 instanceof K?(xe=!1,Ge.warn("Token update rejected by server: ".concat(JSON.stringify(it.t0.reply.status))),it.t0.reply.status.code===401||it.t0.reply.status.code===403?(xe=!0,this.fsm.tokenRejected(it.t0.reply.status),it.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):it.t0.reply.status.code===429?(this.modifyBackoff(it.t0.reply.body),this.fsm.updateError(it.t0.reply.status)):this.fsm.updateError(it.t0.reply.status),this.emitReplyConnectionError(it.t0.message,it.t0.reply,xe)):(this.emit("error",!1,it.t0.message,null,null),this.fsm.updateError(it.t0)),this.emit("tokenUpdated",it.t0);case 14:case"end":return it.stop()}},W,this,[[2,10]])}));function I(){return A.apply(this,arguments)}return I}()},{key:"emitReplyConnectionError",value:function(I,W,j){var Le=W.status&&W.status.description?W.status.description:I,xe=W.status.code,He=W.status&&W.status.errorCode?W.status.errorCode:null;j&&(this.terminationReason=Le),this.emit("connectionError",{terminal:j,message:"Connection error: ".concat(Le),httpStatusCode:xe,errorCode:He})}},{key:"cancelInit",value:function(){Ge.trace("cancelInit")}},{key:"cancelUpdate",value:function(){Ge.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(I){Ge.trace("confirmReceiving");try{this.transport.send(new lr(I.id))}catch(W){Ge.debug("failed to confirm packet receiving",W)}}},{key:"closeSocket",value:function(I){var W=this;Ge.trace("closeSocket (graceful: ".concat(I,")")),I&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),ft(function(){return W.fsm.socketClosed()})}},{key:"connect",value:function(){Ge.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var I=this;return Ge.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(W){I.disconnectedPromiseResolve=W,I.fsm.userDisconnect()})}},{key:"updateToken",value:function(I){var W=this;return Ge.trace("updateToken:",I),new Promise(function(j,Le){W.once("tokenUpdated",function(xe){xe?Le(xe):j()}),W.fsm.userUpdateToken()})}},{key:"isTerminalState",get:function(){return this.terminalStates.indexOf(this.fsm.state)!==-1}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),R}(Me.ReplayEventEmitter),It=function(){function ee(){oe.default(this,ee)}return te.default(ee,null,[{key:"getMetadata",value:function(R){var A,I,W,j,Le,xe,He,it,$t=R&&R.clientMetadata?R.clientMetadata:{},Ur=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],On={env:(A=P.name)!==null&&A!==void 0?A:"unknown",envv:(I=P.version)!==null&&I!==void 0?I:"unknown",os:(W=(j=P.os)===null||j===void 0?void 0:j.family)!==null&&W!==void 0?W:"unknown",osv:(Le=(xe=P.os)===null||xe===void 0?void 0:xe.version)!==null&&Le!==void 0?Le:"unknown",osa:(He=(it=P.os)===null||it===void 0?void 0:it.architecture)!==null&&He!==void 0?He:"unknown",sdk:"js-default"},bn={};return Ur.filter(function(D){return D in $t||D in On}).forEach(function(D){return bn[D]=D in $t?$t[D]:On[D]}),bn}}]),ee}(),_t=3e4;function St(ee){return ee>=200&&ee<300}function xt(ee){switch(Se.default(ee)){case"undefined":return"";case"object":return JSON.stringify(ee);default:return ee}}var Dt=function(){function ee(ue,R){var A=this;oe.default(this,ee),this.config=R,this.activeRequests=new Map,this.channel=ue,this.channel.on("reply",function(I){return A.processReply(I)}),this.channel.on("disconnected",function(){A.activeRequests.forEach(function(I){clearTimeout(I.timeout),I.reject(new ae("disconnected"))}),A.activeRequests.clear()})}return te.default(ee,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(R){var A=this.activeRequests.get(R.id);A&&(clearTimeout(A.timeout),this.activeRequests.delete(R.id),St(R.status.code)?A.resolve(R):(A.reject(new K("Transport failure: "+R.status.status,R)),Ge.trace("message rejected")))}},{key:"storeRequest",value:function(R,A,I){var W={resolve:A,reject:I,timeout:setTimeout(function(){Ge.trace("request",R,"is timed out"),I(new ae("Twilsock: request timeout: "+R))},_t)};this.activeRequests.set(R,W)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(R){clearTimeout(R.timeout),R.reject(new ae("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var ue=Ze.default(ne.default.mark(function A(){var I,W,j;return ne.default.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:return Ge.trace("sendInit"),I=It.getMetadata(this.config),W=new Rt(this.config.token,this.config.continuationToken,I,this.config.initRegistrations,this.config.tweaks),xe.next=5,this.sendWithReply(W);case 5:return j=xe.sent,xe.abrupt("return",new st(j.id,j.header.continuation_token,new Set(j.header.capabilities),j.header.continuation_token_status,j.header.offline_storage,j.header.init_registrations,j.header.debug_info));case 7:case"end":return xe.stop()}},A,this)}));function R(){return ue.apply(this,arguments)}return R}()},{key:"sendClose",value:function(){var R=new At;this.send(R)}},{key:"sendWithReply",value:function(R,A){var I=this;return new Promise(function(W,j){var Le=I.send(R,A);I.storeRequest(Le,W,j)})}},{key:"send",value:function(R,A){R.id=R.id||"TM".concat(N.v4());var I=Ne.createPacket(R,xt(A));try{return this.channel.send(I),R.id}catch(W){throw Ge.debug("failed to send ",R,W),Ge.trace(W.stack),W}}}]),ee}();function rn(ee){var ue=yn();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function yn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var jt=function(ee){_e.default(R,ee);var ue=rn(R);function R(A){var I;return oe.default(this,R),I=ue.call(this),q.default(Z.default(I),"socket",null),I.url=A,I.url=A,I.WebSocket=e.WebSocket||e.MozWebSocket||{},I}return te.default(R,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var I=this;Ge.trace("connecting to socket");var W;try{W=new this.WebSocket(this.url)}catch(j){Ge.debug("Socket error: ".concat(this.url)),this.emit("socketError",j);return}W.binaryType="arraybuffer",W.onopen=function(){Ge.debug("socket opened ".concat(I.url)),I.emit("connected")},W.onclose=function(j){Ge.debug("socket closed",j),I.emit("disconnected",j)},W.onerror=function(j){Ge.debug("Socket error:",j),I.emit("socketError",j)},W.onmessage=function(j){I.emit("message",j.data)},this.socket=W}},{key:"send",value:function(I){return this.socket&&this.socket.send(I)}},{key:"close",value:function(){if(Ge.trace("closing socket"),this.socket){this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null;try{this.socket.close()}finally{}}}}]),R}(Me.ReplayEventEmitter);function Fn(ee){var ue=sa();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function sa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ua=function(ee){_e.default(R,ee);var ue=Fn(R);function R(A){var I;return oe.default(this,R),I=ue.call(this),I.transport=A,I.registrations=new Map,I.registrationsInProgress=new Map,I}return te.default(R,[{key:"putNotificationContext",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le){var xe;return ne.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return xe={method:"put_notification_ctx",notification_ctx_id:j},it.next=3,this.transport.sendWithReply(xe,Le);case 3:case"end":return it.stop()}},W,this)}));function I(W,j){return A.apply(this,arguments)}return I}()},{key:"deleteNotificationContext",value:function(){var A=Ze.default(ne.default.mark(function W(j){var Le;return ne.default.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:return Le={method:"delete_notification_ctx",notification_ctx_id:j},He.next=3,this.transport.sendWithReply(Le);case 3:case"end":return He.stop()}},W,this)}));function I(W){return A.apply(this,arguments)}return I}()},{key:"updateRegistration",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le){var xe,He;return ne.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return Ge.debug("update registration for context",j),xe=this.registrationsInProgress.get(j),xe||(xe=new Set,this.registrationsInProgress.set(j,xe)),He=N.v4(),xe.add(He),$t.prev=5,$t.next=8,this.putNotificationContext(j,Le);case 8:Ge.debug("registration attempt succeeded for context",Le),xe.delete(He),xe.size===0&&(this.registrationsInProgress.delete(j),this.emit("registered",j)),$t.next=19;break;case 13:$t.prev=13,$t.t0=$t.catch(5),Ge.warn("registration attempt failed for context",Le),Ge.debug($t.t0),xe.delete(He),xe.size===0&&(this.registrationsInProgress.delete(j),this.emit("registrationFailed",j,$t.t0));case 19:case"end":return $t.stop()}},W,this,[[5,13]])}));function I(W,j){return A.apply(this,arguments)}return I}()},{key:"updateRegistrations",value:function(){var A=Ze.default(ne.default.mark(function W(){var j=this,Le;return ne.default.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:return Ge.trace("refreshing ".concat(this.registrations.size," registrations")),Le=[],this.registrations.forEach(function(it,$t){Le.push(j.updateRegistration($t,it))}),He.next=5,Promise.all(Le);case 5:case"end":return He.stop()}},W,this)}));function I(){return A.apply(this,arguments)}return I}()},{key:"setNotificationsContext",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le){return ne.default.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:if(!(!j||!Le)){He.next=2;break}throw new ae("Invalid arguments provided");case 2:return this.registrations.set(j,Le),He.next=5,this.updateRegistration(j,Le);case 5:return He.abrupt("return",He.sent);case 6:case"end":return He.stop()}},W,this)}));function I(W,j){return A.apply(this,arguments)}return I}()},{key:"removeNotificationsContext",value:function(){var A=Ze.default(ne.default.mark(function W(j){return ne.default.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:if(this.registrations.has(j)){xe.next=2;break}return xe.abrupt("return");case 2:return xe.next=4,this.deleteNotificationContext(j);case 4:this.transport.isConnected&&this.registrations.delete(j);case 5:case"end":return xe.stop()}},W,this)}));function I(W){return A.apply(this,arguments)}return I}()}]),R}(Me.ReplayEventEmitter);function Jn(ee){var ue=oa();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function oa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Qn=function(ee){_e.default(R,ee);var ue=Jn(R);function R(A,I,W){var j;return oe.default(this,R),j=ue.call(this,I),j.status=A,j.description=I,j.body=W,j}return te.default(R)}(ae);function fi(ee){var ue=Fa();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function Fa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Jr=function(ee){_e.default(R,ee);var ue=fi(R);function R(A){return oe.default(this,R),ue.call(this,A)}return te.default(R)}(ae),Ai=2e4;function Es(ee){return ee>=200&&ee<300}function Oi(ee){return ee&&ee.header&&ee.header.http_status}function Is(ee){var ue=ee.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(ue){var R={protocol:ue[1],host:ue[2],hostname:ue[3],port:ue[4],pathname:ue[5],search:ue[6],hash:ue[7],params:{}};if(R.search.length>0){var A=R.search.substring(1);R.params=A.split("&").map(function(I){return I.split("=")}).reduce(function(I,W){return I.hasOwnProperty(W[0])?Array.isArray(I[W[0]])?I[W[0]].push(W[1]):I[W[0]]=[I[W[0]],W[1]]:I[W[0]]=W[1],I},{})}return R}throw new ae("Incorrect URI: "+ee)}function Oo(ee,ue){var R=Is(ue),A={method:ee,host:R.host,path:R.pathname};return R.params&&(A.params=R.params),A}function Bn(ee,ue,R,A,I){return{to:Oo(ee,ue),headers:R,body:A,grant:I}}var xs=function(){function ee(ue,R,A){oe.default(this,ee),this.config=A,this.transport=ue,this.pendingMessages=[],this.twilsock=R}return te.default(ee,[{key:"saveMessage",value:function(R){var A=this;return new Promise(function(I,W){var j={message:R,resolve:I,reject:W,alreadyRejected:!1,timeout:setTimeout(function(){Ge.debug("request is timed out"),W(new ae("request '".concat(R.to.method,"' to '").concat(R.to.host,"' timed out"))),j.alreadyRejected=!0},Ai)};A.pendingMessages.push(j)})}},{key:"sendPendingMessages",value:function(){for(var R=this,A=function(){var j=R.pendingMessages[0];if(!j.alreadyRejected)try{var Le=j.message;R.actualSend(Le).then(function(xe){return j.resolve(xe)}).catch(function(xe){return j.reject(xe)}),clearTimeout(j.timeout)}catch(xe){return Ge.debug("Failed to send pending message",xe),"break"}R.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var I=A();if(I==="break")break}}},{key:"rejectPendingMessages",value:function(){var R=this;this.pendingMessages.forEach(function(A){A.reject(new Jr("Unable to connect: "+R.twilsock.getTerminationReason)),A.alreadyRejected=!0,clearTimeout(A.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var ue=Ze.default(ne.default.mark(function A(I){var W,j,Le,xe,He,it,$t,Ur;return ne.default.wrap(function(bn){for(;;)switch(bn.prev=bn.next){case 0:return j=I.to,Le=I.headers,xe=I.body,He=(W=I.grant)!==null&&W!==void 0?W:this.config.activeGrant,it={host:j.host,path:j.path,method:j.method,params:j.params,headers:Le},$t=new Xe(He,Le["Content-Type"]||"application/json",it),Ge.trace("Sending upstream message",$t),bn.next=9,this.transport.sendWithReply($t,xe);case 9:if(Ur=bn.sent,Ge.trace("Received upstream message response",Ur),!(Oi(Ur)&&!Es(Ur.header.http_status.code))){bn.next=13;break}throw new Qn(Ur.header.http_status.code,Ur.header.http_status.status,Ur.body);case 13:return bn.abrupt("return",{status:Ur.header.http_status,headers:Ur.header.http_headers,body:Ur.body});case 14:case"end":return bn.stop()}},A,this)}));function R(A){return ue.apply(this,arguments)}return R}()},{key:"send",value:function(R,A){var I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},W=arguments.length>3?arguments[3]:void 0,j=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new Jr("Unable to connect: "+this.twilsock.getTerminationReason));var Le=Bn(R,A,I,W,j);return this.twilsock.isConnected?this.actualSend(Le):this.saveMessage(Le)}}]),ee}(),Po=function(){function ee(){var ue=this;oe.default(this,ee),this._promise=new Promise(function(R,A){ue._resolve=R,ue._reject=A})}return te.default(ee,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(R){this._resolve(R)}},{key:"set",value:function(R){this._resolve(R)}},{key:"fail",value:function(R){this._reject(R)}}]),ee}(),Mo=function(){function ee(ue){oe.default(this,ee),this.id=ue}return te.default(ee,null,[{key:"create",value:function(R){if(R instanceof Object&&"storage_id"in R)return new ee(R.storage_id);throw new ae('Field "storage_id" is missing')}}]),ee}(),cn=function(){function ee(){return oe.default(this,ee),q.default(this,"initializedFlag","twilio_twilsock_token_storage"),q.default(this,"tokenStoragePrefix","twilio_continuation_token_"),ee._instance||(this.initialize(),ee._instance=this),ee._instance}return te.default(ee,[{key:"sessionStorage",value:function(){try{return e.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return e.window}catch{return null}}},{key:"storeToken",value:function(R,A){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(A),R)}},{key:"getStoredToken",value:function(R){return this.canStore()?this.sessionStorage.getItem(this.getKeyName(R)):null}},{key:"initialize",value:function(){var R=this;if(this.canStore()){var A=this.sessionStorage.getItem(this.initializedFlag);A&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var I=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){I(R.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var R=[],A=0;A<this.sessionStorage.length;A++){var I=this.sessionStorage.key(A);I&&I.indexOf(this.tokenStoragePrefix)===0&&R.push(I)}var W=this.sessionStorage.removeItem;R.forEach(function(j){return W(j)}),W(this.initializedFlag)}}},{key:"getKeyName",value:function(R){return"".concat(this.tokenStoragePrefix).concat(R)}},{key:"canStore",value:function(){return!!(this.sessionStorage&&this.sessionStorage.length&&this.window)}}]),ee}();q.default(cn,"_instance",null);var Rs=new cn,Rn=function(){function ee(ue,R,A,I,W,j){oe.default(this,ee),this.title=ue,this.details=R,this.start=A,this.type=W,this.id=j,this.end=I}return te.default(ee,[{key:"toTelemetryEvent",value:function(){var R=new Date,A=this.start,I=this.end?this.end:R;if(I<A){var W=I;I=A,A=W}var j=A.getTime()-R.getTime(),Le=I.getTime()-R.getTime(),xe=new ie(j,Le,this.title,this.details,this.id,this.type);return xe}}]),ee}();t.TelemetryPoint=void 0,function(ee){ee[ee.Start=0]="Start",ee[ee.End=1]="End"}(t.TelemetryPoint||(t.TelemetryPoint={})),t.EventSendingLimitation=void 0,function(ee){ee[ee.MinEventsPortion=0]="MinEventsPortion",ee[ee.AnyEvents=1]="AnyEvents",ee[ee.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(t.EventSendingLimitation||(t.EventSendingLimitation={}));var Nr=function(){function ee(ue,R){oe.default(this,ee),q.default(this,"minEventsPortionToSend",50),q.default(this,"maxEventsPortionToSend",100),q.default(this,"pendingEvents",new Map),q.default(this,"readyEvents",[]),q.default(this,"hasInitializationFinished",!1),q.default(this,"_canSendTelemetry",!1),this.config=ue,this.packetInterface=R}return te.default(ee,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(R){Ge.debug("TelemetryTracker.canSendTelemetry: ".concat(R," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!R&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=R,R&&this.sendTelemetry(t.EventSendingLimitation.AnyEvents),R&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(R){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(R)}},{key:"addPartialEvent",value:function(R,A,I){Ge.debug("Adding ".concat(I===t.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(A,"' event"));var W=this.pendingEvents.has(A);if(I===t.TelemetryPoint.Start)W&&Ge.debug("Overwriting starting point for '".concat(A,"' event")),this.pendingEvents.set(A,R);else{if(!W){Ge.info("Could not find started event for '".concat(A,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(A),R)),this.pendingEvents.delete(A)}}},{key:"getTelemetryToSend",value:function(R){return!this.canSendTelemetry||this.readyEvents.length==0?[]:R==t.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(R==t.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(R){var A=this,I=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),W=this.readyEvents.splice(0,I);return R&&W.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(j,Le){if(!(W.length>=A.maxEventsPortionToSend)){var xe=A.pendingEvents.get(Le);A.pendingEvents.delete(Le),W.push(new Rn("[UNFINISHED] ".concat(xe.title),xe.details,xe.start,null,xe.type,xe.id))}}),W}},{key:"merge",value:function(R,A){return new Rn(A.title?A.title:R.title,A.details?A.details:R.details,R.start,A.end,A.type?A.type:R.type,A.id?A.id:R.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(t.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(R){var A=this.getTelemetryToSend(R);if(A.length!==0)try{this.packetInterface.send(new Fe(A.map(function(I){return I.toTelemetryEvent()})))}catch(I){Ge.debug("Error while sending ".concat(A.length," telemetry events due to ").concat(I,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(A)}}}]),ee}();function No(ee){var ue=Xn();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function Xn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var An=te.default(function ee(){oe.default(this,ee)});q.default(An,"TWILSOCK_CONNECT","twilsock.sdk.connect"),q.default(An,"TWILSOCK_INIT","twilsock.sdk.init"),t.TwilsockClient=function(ee){_e.default(R,ee);var ue=No(R);function R(A,I,W){var j;oe.default(this,R),j=ue.call(this),q.default(Z.default(j),"version",Ue),q.default(Z.default(j),"offlineStorageDeferred",new Po),W.continuationToken=W.continuationToken?W.continuationToken:Rs.getStoredToken(I);var Le=j.config=new be(A,I,W);Ge.setLevel(Le.logLevel);var xe=new jt(Le.url),He=new Dt(xe,Le);return j.channel=new Et(xe,He,Le),j.registrations=new Ua(He),j.upstream=new xs(He,j.channel,Le),j.telemetryTracker=new Nr(Le,He),j.channel.on("initialized",function(){return j.telemetryTracker.canSendTelemetry=!0}),xe.on("disconnected",function(){return j.telemetryTracker.canSendTelemetry=!1}),j.registrations.on("registered",function(it){return j.emit("registered",it)}),j.channel.on("message",function(it,$t){return setTimeout(function(){return j.emit("message",it,$t)},0)}),j.channel.on("stateChanged",function(it){return setTimeout(function(){return j.emit("stateChanged",it)},0)}),j.channel.on("connectionError",function(it){return setTimeout(function(){return j.emit("connectionError",it)},0)}),j.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return j.emit("tokenAboutToExpire")},0)}),j.channel.on("tokenExpired",function(){return setTimeout(function(){return j.emit("tokenExpired")},0)}),j.channel.on("connected",function(){return j.registrations.updateRegistrations()}),j.channel.on("connected",function(){return j.upstream.sendPendingMessages()}),j.channel.on("connected",function(){return setTimeout(function(){return j.emit("connected")},0)}),j.channel.on("beforeConnect",function(){return j.telemetryTracker.addPartialEvent(new Rn("Establish WebSocket connection","",new Date),An.TWILSOCK_CONNECT,t.TelemetryPoint.Start)}),j.channel.on("connected",function(){return j.telemetryTracker.addPartialEvent(new Rn("Establish WebSocket connection","",new Date,new Date),An.TWILSOCK_CONNECT,t.TelemetryPoint.End)}),j.channel.on("beforeSendInit",function(){return j.telemetryTracker.addPartialEvent(new Rn("Send Twilsock init","",new Date),An.TWILSOCK_INIT,t.TelemetryPoint.Start)}),j.channel.on("initialized",function(){return j.telemetryTracker.addPartialEvent(new Rn("Send Twilsock init","Succeeded",new Date,new Date),An.TWILSOCK_INIT,t.TelemetryPoint.End)}),j.channel.on("sendInitFailed",function(){return j.telemetryTracker.addPartialEvent(new Rn("Send Twilsock init","Failed",new Date,new Date),An.TWILSOCK_INIT,t.TelemetryPoint.End)}),j.channel.on("initialized",function(it){j.handleStorageId(I,it),Rs.storeToken(it.continuationToken,I),setTimeout(function(){return j.emit("initialized",it)},0)}),j.channel.on("disconnected",function(){return setTimeout(function(){return j.emit("disconnected")},0)}),j.channel.on("disconnected",function(){return j.upstream.rejectPendingMessages()}),j.channel.on("disconnected",function(){return j.offlineStorageDeferred.fail(new ae("Client disconnected"))}),j.offlineStorageDeferred.promise.catch(function(){}),j}return te.default(R,[{key:"emit",value:function(I){for(var W,j=arguments.length,Le=new Array(j>1?j-1:0),xe=1;xe<j;xe++)Le[xe-1]=arguments[xe];return Ge.debug("Emitting ".concat(I.toString(),"(").concat(Le.map(function(He){return JSON.stringify(He)}).join(", "),")")),(W=Ie.default(Te.default(R.prototype),"emit",this)).call.apply(W,[this,I].concat(Le))}},{key:"handleStorageId",value:function(I,W){if(!W.offlineStorage)this.offlineStorageDeferred.fail(new ae("No offline storage id"));else if(W.offlineStorage.hasOwnProperty(I))try{this.offlineStorageDeferred.set(Mo.create(W.offlineStorage[I])),Ge.debug("Offline storage for '".concat(I,"' product: ").concat(JSON.stringify(W.offlineStorage[I]),"."))}catch(j){this.offlineStorageDeferred.fail(new ae("Failed to parse offline storage for ".concat(I," ").concat(JSON.stringify(W.offlineStorage[I]),". ").concat(j,".")))}else this.offlineStorageDeferred.fail(new ae("No offline storage id for '".concat(I,"' product: ").concat(JSON.stringify(W.offlineStorage))))}},{key:"storageId",value:function(){return this.offlineStorageDeferred.promise}},{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"state",get:function(){return this.channel.state}},{key:"updateToken",value:function(){var A=Ze.default(ne.default.mark(function W(j){return ne.default.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:if(Ge.trace("updating token '".concat(j,"'")),this.config.token!==j){xe.next=3;break}return xe.abrupt("return");case 3:return this.config.updateToken(j),xe.next=6,this.channel.updateToken(j);case 6:return xe.abrupt("return",xe.sent);case 7:case"end":return xe.stop()}},W,this)}));function I(W){return A.apply(this,arguments)}return I}()},{key:"setNotificationsContext",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le){return ne.default.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:return He.next=2,this.registrations.setNotificationsContext(j,Le);case 2:case"end":return He.stop()}},W,this)}));function I(W,j){return A.apply(this,arguments)}return I}()},{key:"removeNotificationsContext",value:function(){var A=Ze.default(ne.default.mark(function W(j){return ne.default.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:return xe.next=2,this.registrations.removeNotificationsContext(j);case 2:case"end":return xe.stop()}},W,this)}));function I(W){return A.apply(this,arguments)}return I}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var A=Ze.default(ne.default.mark(function W(){return ne.default.wrap(function(Le){for(;;)switch(Le.prev=Le.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEventsIncludingUnfinished),Le.next=3,this.channel.disconnect();case 3:return Le.abrupt("return",Le.sent);case 4:case"end":return Le.stop()}},W,this)}));function I(){return A.apply(this,arguments)}return I}()},{key:"get",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le,xe){return ne.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),it.next=3,this.upstream.send("GET",j,Le,void 0,xe);case 3:return it.abrupt("return",it.sent);case 4:case"end":return it.stop()}},W,this)}));function I(W,j,Le){return A.apply(this,arguments)}return I}()},{key:"post",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le,xe,He){return ne.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),$t.next=3,this.upstream.send("POST",j,Le,xe,He);case 3:return $t.abrupt("return",$t.sent);case 4:case"end":return $t.stop()}},W,this)}));function I(W,j,Le,xe){return A.apply(this,arguments)}return I}()},{key:"put",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le,xe,He){return ne.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),$t.next=3,this.upstream.send("PUT",j,Le,xe,He);case 3:return $t.abrupt("return",$t.sent);case 4:case"end":return $t.stop()}},W,this)}));function I(W,j,Le,xe){return A.apply(this,arguments)}return I}()},{key:"delete",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le,xe,He){return ne.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),$t.next=3,this.upstream.send("DELETE",j,Le,xe,He);case 3:return $t.abrupt("return",$t.sent);case 4:case"end":return $t.stop()}},W,this)}));function I(W,j,Le,xe){return A.apply(this,arguments)}return I}()},{key:"addTelemetryEvent",value:function(I){this.telemetryTracker.addTelemetryEvent(I),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(I,W,j){this.telemetryTracker.addPartialEvent(I,W,j),j===t.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),R}(Me.ReplayEventEmitter),t.TwilsockClient=Qe([m.validateConstructorTypes(m.nonEmptyString,m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),Ct("design:paramtypes",[String,String,Object])],t.TwilsockClient);var As=function(){function ee(ue){oe.default(this,ee),this.product=ue,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return te.default(ee,[{key:"populateInitRegistrations",value:function(R){var A=new Set(this.message_types);for(var I in R)A.add(R[I]);this.message_types=Array.from(A)}}]),ee}();t.InitRegistration=As,t.TelemetryEventDescription=Rn,t.TelemetryTracker=Nr,t.TransportUnavailableError=Jr,t.Twilsock=t.TwilsockClient,t.TwilsockError=ae})(hy);var QI={},XI=xr,TJ=Gt,CJ=$r,EJ=qt,sb=Cc,IJ=Sc,xJ=mc,RJ=vn,AJ=yc,Vu=Object.assign,ex=Object.defineProperty,OJ=TJ([].concat),tx=!Vu||EJ(function(){if(XI&&Vu({b:1},Vu(ex({},"a",{enumerable:!0,get:function(){ex(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var t={},e={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return t[r]=7,n.split("").forEach(function(i){e[i]=i}),Vu({},t)[r]!==7||sb(Vu({},e)).join("")!==n})?function(e,r){for(var n=RJ(e),i=arguments.length,a=1,s=IJ.f,o=xJ.f;i>a;)for(var u=AJ(arguments[a++]),l=s?OJ(sb(u),s(u)):sb(u),c=l.length,d=0,f;c>d;)f=l[d++],(!XI||CJ(o,u,f))&&(n[f]=u[f]);return n}:Vu,PJ=Xt,rx=tx;PJ({target:"Object",stat:!0,arity:2,forced:Object.assign!==rx},{assign:rx});/*
924
+ `).concat(JSON.stringify(He.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",He.t0);case 17:case"end":return He.stop()}},W,this,[[1,13]])}));function I(){return A.apply(this,arguments)}return I}()},{key:"sendUpdate",value:function(){var A=Ze.default(ne.default.mark(function W(){var j,Le,xe;return ne.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return Ge.trace("sendUpdate"),j=new ot(this.config.token),it.prev=2,it.next=5,this.transport.sendWithReply(j);case 5:Le=it.sent,this.fsm.updateSuccess(Le.body),this.emit("tokenUpdated"),it.next=14;break;case 10:it.prev=10,it.t0=it.catch(2),it.t0 instanceof K?(xe=!1,Ge.warn("Token update rejected by server: ".concat(JSON.stringify(it.t0.reply.status))),it.t0.reply.status.code===401||it.t0.reply.status.code===403?(xe=!0,this.fsm.tokenRejected(it.t0.reply.status),it.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):it.t0.reply.status.code===429?(this.modifyBackoff(it.t0.reply.body),this.fsm.updateError(it.t0.reply.status)):this.fsm.updateError(it.t0.reply.status),this.emitReplyConnectionError(it.t0.message,it.t0.reply,xe)):(this.emit("error",!1,it.t0.message,null,null),this.fsm.updateError(it.t0)),this.emit("tokenUpdated",it.t0);case 14:case"end":return it.stop()}},W,this,[[2,10]])}));function I(){return A.apply(this,arguments)}return I}()},{key:"emitReplyConnectionError",value:function(I,W,j){var Le=W.status&&W.status.description?W.status.description:I,xe=W.status.code,He=W.status&&W.status.errorCode?W.status.errorCode:null;j&&(this.terminationReason=Le),this.emit("connectionError",{terminal:j,message:"Connection error: ".concat(Le),httpStatusCode:xe,errorCode:He})}},{key:"cancelInit",value:function(){Ge.trace("cancelInit")}},{key:"cancelUpdate",value:function(){Ge.trace("cancelUpdate")}},{key:"confirmReceiving",value:function(I){Ge.trace("confirmReceiving");try{this.transport.send(new lr(I.id))}catch(W){Ge.debug("failed to confirm packet receiving",W)}}},{key:"closeSocket",value:function(I){var W=this;Ge.trace("closeSocket (graceful: ".concat(I,")")),I&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),ft(function(){return W.fsm.socketClosed()})}},{key:"connect",value:function(){Ge.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var I=this;return Ge.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(W){I.disconnectedPromiseResolve=W,I.fsm.userDisconnect()})}},{key:"updateToken",value:function(I){var W=this;return Ge.trace("updateToken:",I),new Promise(function(j,Le){W.once("tokenUpdated",function(xe){xe?Le(xe):j()}),W.fsm.userUpdateToken()})}},{key:"isTerminalState",get:function(){return this.terminalStates.indexOf(this.fsm.state)!==-1}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),R}(Me.ReplayEventEmitter),It=function(){function ee(){oe.default(this,ee)}return te.default(ee,null,[{key:"getMetadata",value:function(R){var A,I,W,j,Le,xe,He,it,$t=R&&R.clientMetadata?R.clientMetadata:{},Ur=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],On={env:(A=P.name)!==null&&A!==void 0?A:"unknown",envv:(I=P.version)!==null&&I!==void 0?I:"unknown",os:(W=(j=P.os)===null||j===void 0?void 0:j.family)!==null&&W!==void 0?W:"unknown",osv:(Le=(xe=P.os)===null||xe===void 0?void 0:xe.version)!==null&&Le!==void 0?Le:"unknown",osa:(He=(it=P.os)===null||it===void 0?void 0:it.architecture)!==null&&He!==void 0?He:"unknown",sdk:"js-default"},bn={};return Ur.filter(function(D){return D in $t||D in On}).forEach(function(D){return bn[D]=D in $t?$t[D]:On[D]}),bn}}]),ee}(),_t=3e4;function St(ee){return ee>=200&&ee<300}function xt(ee){switch(Se.default(ee)){case"undefined":return"";case"object":return JSON.stringify(ee);default:return ee}}var Dt=function(){function ee(ue,R){var A=this;oe.default(this,ee),this.config=R,this.activeRequests=new Map,this.channel=ue,this.channel.on("reply",function(I){return A.processReply(I)}),this.channel.on("disconnected",function(){A.activeRequests.forEach(function(I){clearTimeout(I.timeout),I.reject(new ae("disconnected"))}),A.activeRequests.clear()})}return te.default(ee,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(R){var A=this.activeRequests.get(R.id);A&&(clearTimeout(A.timeout),this.activeRequests.delete(R.id),St(R.status.code)?A.resolve(R):(A.reject(new K("Transport failure: "+R.status.status,R)),Ge.trace("message rejected")))}},{key:"storeRequest",value:function(R,A,I){var W={resolve:A,reject:I,timeout:setTimeout(function(){Ge.trace("request",R,"is timed out"),I(new ae("Twilsock: request timeout: "+R))},_t)};this.activeRequests.set(R,W)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(R){clearTimeout(R.timeout),R.reject(new ae("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var ue=Ze.default(ne.default.mark(function A(){var I,W,j;return ne.default.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:return Ge.trace("sendInit"),I=It.getMetadata(this.config),W=new Rt(this.config.token,this.config.continuationToken,I,this.config.initRegistrations,this.config.tweaks),xe.next=5,this.sendWithReply(W);case 5:return j=xe.sent,xe.abrupt("return",new st(j.id,j.header.continuation_token,new Set(j.header.capabilities),j.header.continuation_token_status,j.header.offline_storage,j.header.init_registrations,j.header.debug_info));case 7:case"end":return xe.stop()}},A,this)}));function R(){return ue.apply(this,arguments)}return R}()},{key:"sendClose",value:function(){var R=new At;this.send(R)}},{key:"sendWithReply",value:function(R,A){var I=this;return new Promise(function(W,j){var Le=I.send(R,A);I.storeRequest(Le,W,j)})}},{key:"send",value:function(R,A){R.id=R.id||"TM".concat(N.v4());var I=Ne.createPacket(R,xt(A));try{return this.channel.send(I),R.id}catch(W){throw Ge.debug("failed to send ",R,W),Ge.trace(W.stack),W}}}]),ee}();function rn(ee){var ue=yn();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function yn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var jt=function(ee){_e.default(R,ee);var ue=rn(R);function R(A){var I;return oe.default(this,R),I=ue.call(this),q.default(Z.default(I),"socket",null),I.url=A,I.url=A,I.WebSocket=e.WebSocket||e.MozWebSocket||{},I}return te.default(R,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var I=this;Ge.trace("connecting to socket");var W;try{W=new this.WebSocket(this.url)}catch(j){Ge.debug("Socket error: ".concat(this.url)),this.emit("socketError",j);return}W.binaryType="arraybuffer",W.onopen=function(){Ge.debug("socket opened ".concat(I.url)),I.emit("connected")},W.onclose=function(j){Ge.debug("socket closed",j),I.emit("disconnected",j)},W.onerror=function(j){Ge.debug("Socket error:",j),I.emit("socketError",j)},W.onmessage=function(j){I.emit("message",j.data)},this.socket=W}},{key:"send",value:function(I){return this.socket&&this.socket.send(I)}},{key:"close",value:function(){if(Ge.trace("closing socket"),this.socket){this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null;try{this.socket.close()}finally{}}}}]),R}(Me.ReplayEventEmitter);function Fn(ee){var ue=sa();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function sa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ua=function(ee){_e.default(R,ee);var ue=Fn(R);function R(A){var I;return oe.default(this,R),I=ue.call(this),I.transport=A,I.registrations=new Map,I.registrationsInProgress=new Map,I}return te.default(R,[{key:"putNotificationContext",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le){var xe;return ne.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return xe={method:"put_notification_ctx",notification_ctx_id:j},it.next=3,this.transport.sendWithReply(xe,Le);case 3:case"end":return it.stop()}},W,this)}));function I(W,j){return A.apply(this,arguments)}return I}()},{key:"deleteNotificationContext",value:function(){var A=Ze.default(ne.default.mark(function W(j){var Le;return ne.default.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:return Le={method:"delete_notification_ctx",notification_ctx_id:j},He.next=3,this.transport.sendWithReply(Le);case 3:case"end":return He.stop()}},W,this)}));function I(W){return A.apply(this,arguments)}return I}()},{key:"updateRegistration",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le){var xe,He;return ne.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return Ge.debug("update registration for context",j),xe=this.registrationsInProgress.get(j),xe||(xe=new Set,this.registrationsInProgress.set(j,xe)),He=N.v4(),xe.add(He),$t.prev=5,$t.next=8,this.putNotificationContext(j,Le);case 8:Ge.debug("registration attempt succeeded for context",Le),xe.delete(He),xe.size===0&&(this.registrationsInProgress.delete(j),this.emit("registered",j)),$t.next=19;break;case 13:$t.prev=13,$t.t0=$t.catch(5),Ge.warn("registration attempt failed for context",Le),Ge.debug($t.t0),xe.delete(He),xe.size===0&&(this.registrationsInProgress.delete(j),this.emit("registrationFailed",j,$t.t0));case 19:case"end":return $t.stop()}},W,this,[[5,13]])}));function I(W,j){return A.apply(this,arguments)}return I}()},{key:"updateRegistrations",value:function(){var A=Ze.default(ne.default.mark(function W(){var j=this,Le;return ne.default.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:return Ge.trace("refreshing ".concat(this.registrations.size," registrations")),Le=[],this.registrations.forEach(function(it,$t){Le.push(j.updateRegistration($t,it))}),He.next=5,Promise.all(Le);case 5:case"end":return He.stop()}},W,this)}));function I(){return A.apply(this,arguments)}return I}()},{key:"setNotificationsContext",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le){return ne.default.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:if(!(!j||!Le)){He.next=2;break}throw new ae("Invalid arguments provided");case 2:return this.registrations.set(j,Le),He.next=5,this.updateRegistration(j,Le);case 5:return He.abrupt("return",He.sent);case 6:case"end":return He.stop()}},W,this)}));function I(W,j){return A.apply(this,arguments)}return I}()},{key:"removeNotificationsContext",value:function(){var A=Ze.default(ne.default.mark(function W(j){return ne.default.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:if(this.registrations.has(j)){xe.next=2;break}return xe.abrupt("return");case 2:return xe.next=4,this.deleteNotificationContext(j);case 4:this.transport.isConnected&&this.registrations.delete(j);case 5:case"end":return xe.stop()}},W,this)}));function I(W){return A.apply(this,arguments)}return I}()}]),R}(Me.ReplayEventEmitter);function Jn(ee){var ue=oa();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function oa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Qn=function(ee){_e.default(R,ee);var ue=Jn(R);function R(A,I,W){var j;return oe.default(this,R),j=ue.call(this,I),j.status=A,j.description=I,j.body=W,j}return te.default(R)}(ae);function fi(ee){var ue=Fa();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function Fa(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Jr=function(ee){_e.default(R,ee);var ue=fi(R);function R(A){return oe.default(this,R),ue.call(this,A)}return te.default(R)}(ae),Ai=2e4;function Es(ee){return ee>=200&&ee<300}function Oi(ee){return ee&&ee.header&&ee.header.http_status}function Is(ee){var ue=ee.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(ue){var R={protocol:ue[1],host:ue[2],hostname:ue[3],port:ue[4],pathname:ue[5],search:ue[6],hash:ue[7],params:{}};if(R.search.length>0){var A=R.search.substring(1);R.params=A.split("&").map(function(I){return I.split("=")}).reduce(function(I,W){return I.hasOwnProperty(W[0])?Array.isArray(I[W[0]])?I[W[0]].push(W[1]):I[W[0]]=[I[W[0]],W[1]]:I[W[0]]=W[1],I},{})}return R}throw new ae("Incorrect URI: "+ee)}function Oo(ee,ue){var R=Is(ue),A={method:ee,host:R.host,path:R.pathname};return R.params&&(A.params=R.params),A}function Bn(ee,ue,R,A,I){return{to:Oo(ee,ue),headers:R,body:A,grant:I}}var xs=function(){function ee(ue,R,A){oe.default(this,ee),this.config=A,this.transport=ue,this.pendingMessages=[],this.twilsock=R}return te.default(ee,[{key:"saveMessage",value:function(R){var A=this;return new Promise(function(I,W){var j={message:R,resolve:I,reject:W,alreadyRejected:!1,timeout:setTimeout(function(){Ge.debug("request is timed out"),W(new ae("request '".concat(R.to.method,"' to '").concat(R.to.host,"' timed out"))),j.alreadyRejected=!0},Ai)};A.pendingMessages.push(j)})}},{key:"sendPendingMessages",value:function(){for(var R=this,A=function(){var j=R.pendingMessages[0];if(!j.alreadyRejected)try{var Le=j.message;R.actualSend(Le).then(function(xe){return j.resolve(xe)}).catch(function(xe){return j.reject(xe)}),clearTimeout(j.timeout)}catch(xe){return Ge.debug("Failed to send pending message",xe),"break"}R.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var I=A();if(I==="break")break}}},{key:"rejectPendingMessages",value:function(){var R=this;this.pendingMessages.forEach(function(A){A.reject(new Jr("Unable to connect: "+R.twilsock.getTerminationReason)),A.alreadyRejected=!0,clearTimeout(A.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var ue=Ze.default(ne.default.mark(function A(I){var W,j,Le,xe,He,it,$t,Ur;return ne.default.wrap(function(bn){for(;;)switch(bn.prev=bn.next){case 0:return j=I.to,Le=I.headers,xe=I.body,He=(W=I.grant)!==null&&W!==void 0?W:this.config.activeGrant,it={host:j.host,path:j.path,method:j.method,params:j.params,headers:Le},$t=new Xe(He,Le["Content-Type"]||"application/json",it),Ge.trace("Sending upstream message",$t),bn.next=9,this.transport.sendWithReply($t,xe);case 9:if(Ur=bn.sent,Ge.trace("Received upstream message response",Ur),!(Oi(Ur)&&!Es(Ur.header.http_status.code))){bn.next=13;break}throw new Qn(Ur.header.http_status.code,Ur.header.http_status.status,Ur.body);case 13:return bn.abrupt("return",{status:Ur.header.http_status,headers:Ur.header.http_headers,body:Ur.body});case 14:case"end":return bn.stop()}},A,this)}));function R(A){return ue.apply(this,arguments)}return R}()},{key:"send",value:function(R,A){var I=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},W=arguments.length>3?arguments[3]:void 0,j=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new Jr("Unable to connect: "+this.twilsock.getTerminationReason));var Le=Bn(R,A,I,W,j);return this.twilsock.isConnected?this.actualSend(Le):this.saveMessage(Le)}}]),ee}(),Po=function(){function ee(){var ue=this;oe.default(this,ee),this._promise=new Promise(function(R,A){ue._resolve=R,ue._reject=A})}return te.default(ee,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(R){this._resolve(R)}},{key:"set",value:function(R){this._resolve(R)}},{key:"fail",value:function(R){this._reject(R)}}]),ee}(),Mo=function(){function ee(ue){oe.default(this,ee),this.id=ue}return te.default(ee,null,[{key:"create",value:function(R){if(R instanceof Object&&"storage_id"in R)return new ee(R.storage_id);throw new ae('Field "storage_id" is missing')}}]),ee}(),cn=function(){function ee(){return oe.default(this,ee),q.default(this,"initializedFlag","twilio_twilsock_token_storage"),q.default(this,"tokenStoragePrefix","twilio_continuation_token_"),ee._instance||(this.initialize(),ee._instance=this),ee._instance}return te.default(ee,[{key:"sessionStorage",value:function(){try{return e.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return e.window}catch{return null}}},{key:"storeToken",value:function(R,A){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(A),R)}},{key:"getStoredToken",value:function(R){return this.canStore()?this.sessionStorage.getItem(this.getKeyName(R)):null}},{key:"initialize",value:function(){var R=this;if(this.canStore()){var A=this.sessionStorage.getItem(this.initializedFlag);A&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var I=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){I(R.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var R=[],A=0;A<this.sessionStorage.length;A++){var I=this.sessionStorage.key(A);I&&I.indexOf(this.tokenStoragePrefix)===0&&R.push(I)}var W=this.sessionStorage.removeItem;R.forEach(function(j){return W(j)}),W(this.initializedFlag)}}},{key:"getKeyName",value:function(R){return"".concat(this.tokenStoragePrefix).concat(R)}},{key:"canStore",value:function(){return!!(this.sessionStorage&&this.sessionStorage.length&&this.window)}}]),ee}();q.default(cn,"_instance",null);var Rs=new cn,Rn=function(){function ee(ue,R,A,I,W,j){oe.default(this,ee),this.title=ue,this.details=R,this.start=A,this.type=W,this.id=j,this.end=I}return te.default(ee,[{key:"toTelemetryEvent",value:function(){var R=new Date,A=this.start,I=this.end?this.end:R;if(I<A){var W=I;I=A,A=W}var j=A.getTime()-R.getTime(),Le=I.getTime()-R.getTime(),xe=new ie(j,Le,this.title,this.details,this.id,this.type);return xe}}]),ee}();t.TelemetryPoint=void 0,function(ee){ee[ee.Start=0]="Start",ee[ee.End=1]="End"}(t.TelemetryPoint||(t.TelemetryPoint={})),t.EventSendingLimitation=void 0,function(ee){ee[ee.MinEventsPortion=0]="MinEventsPortion",ee[ee.AnyEvents=1]="AnyEvents",ee[ee.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(t.EventSendingLimitation||(t.EventSendingLimitation={}));var Nr=function(){function ee(ue,R){oe.default(this,ee),q.default(this,"minEventsPortionToSend",50),q.default(this,"maxEventsPortionToSend",100),q.default(this,"pendingEvents",new Map),q.default(this,"readyEvents",[]),q.default(this,"hasInitializationFinished",!1),q.default(this,"_canSendTelemetry",!1),this.config=ue,this.packetInterface=R}return te.default(ee,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(R){Ge.debug("TelemetryTracker.canSendTelemetry: ".concat(R," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!R&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=R,R&&this.sendTelemetry(t.EventSendingLimitation.AnyEvents),R&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(R){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(R)}},{key:"addPartialEvent",value:function(R,A,I){Ge.debug("Adding ".concat(I===t.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(A,"' event"));var W=this.pendingEvents.has(A);if(I===t.TelemetryPoint.Start)W&&Ge.debug("Overwriting starting point for '".concat(A,"' event")),this.pendingEvents.set(A,R);else{if(!W){Ge.info("Could not find started event for '".concat(A,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(A),R)),this.pendingEvents.delete(A)}}},{key:"getTelemetryToSend",value:function(R){return!this.canSendTelemetry||this.readyEvents.length==0?[]:R==t.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(R==t.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(R){var A=this,I=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),W=this.readyEvents.splice(0,I);return R&&W.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(j,Le){if(!(W.length>=A.maxEventsPortionToSend)){var xe=A.pendingEvents.get(Le);A.pendingEvents.delete(Le),W.push(new Rn("[UNFINISHED] ".concat(xe.title),xe.details,xe.start,null,xe.type,xe.id))}}),W}},{key:"merge",value:function(R,A){return new Rn(A.title?A.title:R.title,A.details?A.details:R.details,R.start,A.end,A.type?A.type:R.type,A.id?A.id:R.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(t.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(R){var A=this.getTelemetryToSend(R);if(A.length!==0)try{this.packetInterface.send(new Be(A.map(function(I){return I.toTelemetryEvent()})))}catch(I){Ge.debug("Error while sending ".concat(A.length," telemetry events due to ").concat(I,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(A)}}}]),ee}();function No(ee){var ue=Xn();return function(){var A=Te.default(ee),I;if(ue){var W=Te.default(this).constructor;I=Reflect.construct(A,arguments,W)}else I=A.apply(this,arguments);return se.default(this,I)}}function Xn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var An=te.default(function ee(){oe.default(this,ee)});q.default(An,"TWILSOCK_CONNECT","twilsock.sdk.connect"),q.default(An,"TWILSOCK_INIT","twilsock.sdk.init"),t.TwilsockClient=function(ee){_e.default(R,ee);var ue=No(R);function R(A,I,W){var j;oe.default(this,R),j=ue.call(this),q.default(Z.default(j),"version",Ue),q.default(Z.default(j),"offlineStorageDeferred",new Po),W.continuationToken=W.continuationToken?W.continuationToken:Rs.getStoredToken(I);var Le=j.config=new be(A,I,W);Ge.setLevel(Le.logLevel);var xe=new jt(Le.url),He=new Dt(xe,Le);return j.channel=new Et(xe,He,Le),j.registrations=new Ua(He),j.upstream=new xs(He,j.channel,Le),j.telemetryTracker=new Nr(Le,He),j.channel.on("initialized",function(){return j.telemetryTracker.canSendTelemetry=!0}),xe.on("disconnected",function(){return j.telemetryTracker.canSendTelemetry=!1}),j.registrations.on("registered",function(it){return j.emit("registered",it)}),j.channel.on("message",function(it,$t){return setTimeout(function(){return j.emit("message",it,$t)},0)}),j.channel.on("stateChanged",function(it){return setTimeout(function(){return j.emit("stateChanged",it)},0)}),j.channel.on("connectionError",function(it){return setTimeout(function(){return j.emit("connectionError",it)},0)}),j.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return j.emit("tokenAboutToExpire")},0)}),j.channel.on("tokenExpired",function(){return setTimeout(function(){return j.emit("tokenExpired")},0)}),j.channel.on("connected",function(){return j.registrations.updateRegistrations()}),j.channel.on("connected",function(){return j.upstream.sendPendingMessages()}),j.channel.on("connected",function(){return setTimeout(function(){return j.emit("connected")},0)}),j.channel.on("beforeConnect",function(){return j.telemetryTracker.addPartialEvent(new Rn("Establish WebSocket connection","",new Date),An.TWILSOCK_CONNECT,t.TelemetryPoint.Start)}),j.channel.on("connected",function(){return j.telemetryTracker.addPartialEvent(new Rn("Establish WebSocket connection","",new Date,new Date),An.TWILSOCK_CONNECT,t.TelemetryPoint.End)}),j.channel.on("beforeSendInit",function(){return j.telemetryTracker.addPartialEvent(new Rn("Send Twilsock init","",new Date),An.TWILSOCK_INIT,t.TelemetryPoint.Start)}),j.channel.on("initialized",function(){return j.telemetryTracker.addPartialEvent(new Rn("Send Twilsock init","Succeeded",new Date,new Date),An.TWILSOCK_INIT,t.TelemetryPoint.End)}),j.channel.on("sendInitFailed",function(){return j.telemetryTracker.addPartialEvent(new Rn("Send Twilsock init","Failed",new Date,new Date),An.TWILSOCK_INIT,t.TelemetryPoint.End)}),j.channel.on("initialized",function(it){j.handleStorageId(I,it),Rs.storeToken(it.continuationToken,I),setTimeout(function(){return j.emit("initialized",it)},0)}),j.channel.on("disconnected",function(){return setTimeout(function(){return j.emit("disconnected")},0)}),j.channel.on("disconnected",function(){return j.upstream.rejectPendingMessages()}),j.channel.on("disconnected",function(){return j.offlineStorageDeferred.fail(new ae("Client disconnected"))}),j.offlineStorageDeferred.promise.catch(function(){}),j}return te.default(R,[{key:"emit",value:function(I){for(var W,j=arguments.length,Le=new Array(j>1?j-1:0),xe=1;xe<j;xe++)Le[xe-1]=arguments[xe];return Ge.debug("Emitting ".concat(I.toString(),"(").concat(Le.map(function(He){return JSON.stringify(He)}).join(", "),")")),(W=Ie.default(Te.default(R.prototype),"emit",this)).call.apply(W,[this,I].concat(Le))}},{key:"handleStorageId",value:function(I,W){if(!W.offlineStorage)this.offlineStorageDeferred.fail(new ae("No offline storage id"));else if(W.offlineStorage.hasOwnProperty(I))try{this.offlineStorageDeferred.set(Mo.create(W.offlineStorage[I])),Ge.debug("Offline storage for '".concat(I,"' product: ").concat(JSON.stringify(W.offlineStorage[I]),"."))}catch(j){this.offlineStorageDeferred.fail(new ae("Failed to parse offline storage for ".concat(I," ").concat(JSON.stringify(W.offlineStorage[I]),". ").concat(j,".")))}else this.offlineStorageDeferred.fail(new ae("No offline storage id for '".concat(I,"' product: ").concat(JSON.stringify(W.offlineStorage))))}},{key:"storageId",value:function(){return this.offlineStorageDeferred.promise}},{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"state",get:function(){return this.channel.state}},{key:"updateToken",value:function(){var A=Ze.default(ne.default.mark(function W(j){return ne.default.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:if(Ge.trace("updating token '".concat(j,"'")),this.config.token!==j){xe.next=3;break}return xe.abrupt("return");case 3:return this.config.updateToken(j),xe.next=6,this.channel.updateToken(j);case 6:return xe.abrupt("return",xe.sent);case 7:case"end":return xe.stop()}},W,this)}));function I(W){return A.apply(this,arguments)}return I}()},{key:"setNotificationsContext",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le){return ne.default.wrap(function(He){for(;;)switch(He.prev=He.next){case 0:return He.next=2,this.registrations.setNotificationsContext(j,Le);case 2:case"end":return He.stop()}},W,this)}));function I(W,j){return A.apply(this,arguments)}return I}()},{key:"removeNotificationsContext",value:function(){var A=Ze.default(ne.default.mark(function W(j){return ne.default.wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:return xe.next=2,this.registrations.removeNotificationsContext(j);case 2:case"end":return xe.stop()}},W,this)}));function I(W){return A.apply(this,arguments)}return I}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var A=Ze.default(ne.default.mark(function W(){return ne.default.wrap(function(Le){for(;;)switch(Le.prev=Le.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEventsIncludingUnfinished),Le.next=3,this.channel.disconnect();case 3:return Le.abrupt("return",Le.sent);case 4:case"end":return Le.stop()}},W,this)}));function I(){return A.apply(this,arguments)}return I}()},{key:"get",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le,xe){return ne.default.wrap(function(it){for(;;)switch(it.prev=it.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),it.next=3,this.upstream.send("GET",j,Le,void 0,xe);case 3:return it.abrupt("return",it.sent);case 4:case"end":return it.stop()}},W,this)}));function I(W,j,Le){return A.apply(this,arguments)}return I}()},{key:"post",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le,xe,He){return ne.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),$t.next=3,this.upstream.send("POST",j,Le,xe,He);case 3:return $t.abrupt("return",$t.sent);case 4:case"end":return $t.stop()}},W,this)}));function I(W,j,Le,xe){return A.apply(this,arguments)}return I}()},{key:"put",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le,xe,He){return ne.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),$t.next=3,this.upstream.send("PUT",j,Le,xe,He);case 3:return $t.abrupt("return",$t.sent);case 4:case"end":return $t.stop()}},W,this)}));function I(W,j,Le,xe){return A.apply(this,arguments)}return I}()},{key:"delete",value:function(){var A=Ze.default(ne.default.mark(function W(j,Le,xe,He){return ne.default.wrap(function($t){for(;;)switch($t.prev=$t.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),$t.next=3,this.upstream.send("DELETE",j,Le,xe,He);case 3:return $t.abrupt("return",$t.sent);case 4:case"end":return $t.stop()}},W,this)}));function I(W,j,Le,xe){return A.apply(this,arguments)}return I}()},{key:"addTelemetryEvent",value:function(I){this.telemetryTracker.addTelemetryEvent(I),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function(I,W,j){this.telemetryTracker.addPartialEvent(I,W,j),j===t.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),R}(Me.ReplayEventEmitter),t.TwilsockClient=Qe([m.validateConstructorTypes(m.nonEmptyString,m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),Ct("design:paramtypes",[String,String,Object])],t.TwilsockClient);var As=function(){function ee(ue){oe.default(this,ee),this.product=ue,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return te.default(ee,[{key:"populateInitRegistrations",value:function(R){var A=new Set(this.message_types);for(var I in R)A.add(R[I]);this.message_types=Array.from(A)}}]),ee}();t.InitRegistration=As,t.TelemetryEventDescription=Rn,t.TelemetryTracker=Nr,t.TransportUnavailableError=Jr,t.Twilsock=t.TwilsockClient,t.TwilsockError=ae})(hy);var QI={},XI=xr,TJ=Gt,CJ=$r,EJ=qt,sb=Cc,IJ=Sc,xJ=mc,RJ=vn,AJ=yc,Vu=Object.assign,ex=Object.defineProperty,OJ=TJ([].concat),tx=!Vu||EJ(function(){if(XI&&Vu({b:1},Vu(ex({},"a",{enumerable:!0,get:function(){ex(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var t={},e={},r=Symbol("assign detection"),n="abcdefghijklmnopqrst";return t[r]=7,n.split("").forEach(function(i){e[i]=i}),Vu({},t)[r]!==7||sb(Vu({},e)).join("")!==n})?function(e,r){for(var n=RJ(e),i=arguments.length,a=1,s=IJ.f,o=xJ.f;i>a;)for(var u=AJ(arguments[a++]),l=s?OJ(sb(u),s(u)):sb(u),c=l.length,d=0,f;c>d;)f=l[d++],(!XI||CJ(o,u,f))&&(n[f]=u[f]);return n}:Vu,PJ=Xt,rx=tx;PJ({target:"Object",stat:!0,arity:2,forced:Object.assign!==rx},{assign:rx});/*
925
925
  @license
926
926
  The MIT License (MIT)
927
927
 
@@ -945,7 +945,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
945
945
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
946
946
  SOFTWARE.
947
947
 
948
- */(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=ku,r=Qi,n=$a,i=Yi,a=Ji,s=ii,o=Au,u=ni,l=hy,c=cs,d=ds,f=Xi,m=Wc,k=Zc,L=Ou,N=Qc,z=en;function re(Ee){return Ee&&typeof Ee=="object"&&"default"in Ee?Ee:{default:Ee}}function Me(Ee){if(Ee&&Ee.__esModule)return Ee;var Ne=Object.create(null);return Ee&&Object.keys(Ee).forEach(function(pe){if(pe!=="default"){var $e=Object.getOwnPropertyDescriptor(Ee,pe);Object.defineProperty(Ne,pe,$e.get?$e:{enumerable:!0,get:function(){return Ee[pe]}})}}),Ne.default=Ee,Object.freeze(Ne)}var Oe=re(e),Be=re(r),Pe=re(n),Ze=re(i),Z=re(a),Ie=re(s),_e=re(o),se=re(u),Te=re(c),te=re(d),oe=re(m),q=re(k),ne=Me(L),Se=Me(N);function H(Ee,Ne,pe,$e){var ae=arguments.length,ge=ae<3?Ne:$e===null?$e=Object.getOwnPropertyDescriptor(Ne,pe):$e,we;if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")ge=Reflect.decorate(Ee,Ne,pe,$e);else for(var K=Ee.length-1;K>=0;K--)(we=Ee[K])&&(ge=(ae<3?we(ge):ae>3?we(Ne,pe,ge):we(Ne,pe))||ge);return ae>3&&ge&&Object.defineProperty(Ne,pe,ge),ge}function ye(Ee,Ne){if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(Ee,Ne)}var ke;function P(){}P.prototype=Object.create(null);function Qe(){Qe.init.call(this)}Qe.EventEmitter=Qe,Qe.usingDomains=!1,Qe.prototype.domain=void 0,Qe.prototype._events=void 0,Qe.prototype._maxListeners=void 0,Qe.defaultMaxListeners=10,Qe.init=function(){this.domain=null,Qe.usingDomains&&ke.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new P,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Qe.prototype.setMaxListeners=function(Ne){if(typeof Ne!="number"||Ne<0||isNaN(Ne))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=Ne,this};function Ct(Ee){return Ee._maxListeners===void 0?Qe.defaultMaxListeners:Ee._maxListeners}Qe.prototype.getMaxListeners=function(){return Ct(this)};function tt(Ee,Ne,pe){if(Ne)Ee.call(pe);else for(var $e=Ee.length,ae=Q(Ee,$e),ge=0;ge<$e;++ge)ae[ge].call(pe)}function De(Ee,Ne,pe,$e){if(Ne)Ee.call(pe,$e);else for(var ae=Ee.length,ge=Q(Ee,ae),we=0;we<ae;++we)ge[we].call(pe,$e)}function ce(Ee,Ne,pe,$e,ae){if(Ne)Ee.call(pe,$e,ae);else for(var ge=Ee.length,we=Q(Ee,ge),K=0;K<ge;++K)we[K].call(pe,$e,ae)}function Ge(Ee,Ne,pe,$e,ae,ge){if(Ne)Ee.call(pe,$e,ae,ge);else for(var we=Ee.length,K=Q(Ee,we),he=0;he<we;++he)K[he].call(pe,$e,ae,ge)}function Ue(Ee,Ne,pe,$e){if(Ne)Ee.apply(pe,$e);else for(var ae=Ee.length,ge=Q(Ee,ae),we=0;we<ae;++we)ge[we].apply(pe,$e)}Qe.prototype.emit=function(Ne){var pe,$e,ae,ge,we,K,he,G=Ne==="error";if(K=this._events,K)G=G&&K.error==null;else if(!G)return!1;if(he=this.domain,G){if(pe=arguments[1],he)pe||(pe=new Error('Uncaught, unspecified "error" event')),pe.domainEmitter=this,pe.domain=he,pe.domainThrown=!1,he.emit("error",pe);else{if(pe instanceof Error)throw pe;var de=new Error('Uncaught, unspecified "error" event. ('+pe+")");throw de.context=pe,de}return!1}if($e=K[Ne],!$e)return!1;var X=typeof $e=="function";switch(ae=arguments.length,ae){case 1:tt($e,X,this);break;case 2:De($e,X,this,arguments[1]);break;case 3:ce($e,X,this,arguments[1],arguments[2]);break;case 4:Ge($e,X,this,arguments[1],arguments[2],arguments[3]);break;default:for(ge=new Array(ae-1),we=1;we<ae;we++)ge[we-1]=arguments[we];Ue($e,X,this,ge)}return!0};function be(Ee,Ne,pe,$e){var ae,ge,we;if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');if(ge=Ee._events,ge?(ge.newListener&&(Ee.emit("newListener",Ne,pe.listener?pe.listener:pe),ge=Ee._events),we=ge[Ne]):(ge=Ee._events=new P,Ee._eventsCount=0),!we)we=ge[Ne]=pe,++Ee._eventsCount;else if(typeof we=="function"?we=ge[Ne]=$e?[pe,we]:[we,pe]:$e?we.unshift(pe):we.push(pe),!we.warned&&(ae=Ct(Ee),ae&&ae>0&&we.length>ae)){we.warned=!0;var K=new Error("Possible EventEmitter memory leak detected. "+we.length+" "+Ne+" listeners added. Use emitter.setMaxListeners() to increase limit");K.name="MaxListenersExceededWarning",K.emitter=Ee,K.type=Ne,K.count=we.length,ht(K)}return Ee}function ht(Ee){typeof console.warn=="function"?console.warn(Ee):console.log(Ee)}Qe.prototype.addListener=function(Ne,pe){return be(this,Ne,pe,!1)},Qe.prototype.on=Qe.prototype.addListener,Qe.prototype.prependListener=function(Ne,pe){return be(this,Ne,pe,!0)};function Ve(Ee,Ne,pe){var $e=!1;function ae(){Ee.removeListener(Ne,ae),$e||($e=!0,pe.apply(Ee,arguments))}return ae.listener=pe,ae}Qe.prototype.once=function(Ne,pe){if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');return this.on(Ne,Ve(this,Ne,pe)),this},Qe.prototype.prependOnceListener=function(Ne,pe){if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(Ne,Ve(this,Ne,pe)),this},Qe.prototype.removeListener=function(Ne,pe){var $e,ae,ge,we,K;if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');if(ae=this._events,!ae)return this;if($e=ae[Ne],!$e)return this;if($e===pe||$e.listener&&$e.listener===pe)--this._eventsCount===0?this._events=new P:(delete ae[Ne],ae.removeListener&&this.emit("removeListener",Ne,$e.listener||pe));else if(typeof $e!="function"){for(ge=-1,we=$e.length;we-- >0;)if($e[we]===pe||$e[we].listener&&$e[we].listener===pe){K=$e[we].listener,ge=we;break}if(ge<0)return this;if($e.length===1){if($e[0]=void 0,--this._eventsCount===0)return this._events=new P,this;delete ae[Ne]}else Rt($e,ge);ae.removeListener&&this.emit("removeListener",Ne,K||pe)}return this},Qe.prototype.off=function(Ee,Ne){return this.removeListener(Ee,Ne)},Qe.prototype.removeAllListeners=function(Ne){var pe,$e;if($e=this._events,!$e)return this;if(!$e.removeListener)return arguments.length===0?(this._events=new P,this._eventsCount=0):$e[Ne]&&(--this._eventsCount===0?this._events=new P:delete $e[Ne]),this;if(arguments.length===0){for(var ae=Object.keys($e),ge=0,we;ge<ae.length;++ge)we=ae[ge],we!=="removeListener"&&this.removeAllListeners(we);return this.removeAllListeners("removeListener"),this._events=new P,this._eventsCount=0,this}if(pe=$e[Ne],typeof pe=="function")this.removeListener(Ne,pe);else if(pe)do this.removeListener(Ne,pe[pe.length-1]);while(pe[0]);return this},Qe.prototype.listeners=function(Ne){var pe,$e,ae=this._events;return ae?(pe=ae[Ne],pe?typeof pe=="function"?$e=[pe.listener||pe]:$e=je(pe):$e=[]):$e=[],$e},Qe.listenerCount=function(Ee,Ne){return typeof Ee.listenerCount=="function"?Ee.listenerCount(Ne):Kt.call(Ee,Ne)},Qe.prototype.listenerCount=Kt;function Kt(Ee){var Ne=this._events;if(Ne){var pe=Ne[Ee];if(typeof pe=="function")return 1;if(pe)return pe.length}return 0}Qe.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function Rt(Ee,Ne){for(var pe=Ne,$e=pe+1,ae=Ee.length;$e<ae;pe+=1,$e+=1)Ee[pe]=Ee[$e];Ee.pop()}function Q(Ee,Ne){for(var pe=new Array(Ne);Ne--;)pe[Ne]=Ee[Ne];return pe}function je(Ee){for(var Ne=new Array(Ee.length),pe=0;pe<Ne.length;++pe)Ne[pe]=Ee[pe].listener||Ee[pe];return Ne}var st=ne.getLogger("twilio-notificatiions");function Re(Ee,Ne){return["".concat(new Date().toISOString()," Twilio.Notifications ").concat(Ee,":")].concat(Array.from(Ne))}var kt=function(){function Ee(){Be.default(this,Ee)}return Pe.default(Ee,[{key:"setLevel",value:function(pe){st.setLevel(pe)}},{key:"trace",value:function(){if(st.getLevel()==st.levels.TRACE){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];st.debug.apply(null,Re("T",$e))}}},{key:"debug",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];st.debug.apply(null,Re("D",$e))}},{key:"info",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];st.info.apply(null,Re("I",$e))}},{key:"warn",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];st.warn.apply(null,Re("W",$e))}},{key:"error",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];st.error.apply(null,Re("E",$e))}}]),Ee}(),ot=new kt;function ar(Ee){var Ne=mr();return function(){var $e=Ie.default(Ee),ae;if(Ne){var ge=Ie.default(this).constructor;ae=Reflect.construct($e,arguments,ge)}else ae=$e.apply(this,arguments);return Z.default(this,ae)}}function mr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Xe=Pe.default(function Ee(){var Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",pe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",$e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;Be.default(this,Ee),this.token=Ne,this.notificationId=pe,this.messageTypes=$e});function Or(Ee,Ne){return[].concat(q.default(q.default(Ee).filter(function(pe){return!Ne.has(pe)})),q.default(q.default(Ne).filter(function(pe){return!Ee.has(pe)})))}function jr(Ee,Ne){var pe=new Set;return Ee.notificationId!==Ne.notificationId&&pe.add("notificationId"),Ee.token!==Ne.token&&pe.add("token"),Or(Ee.messageTypes,Ne.messageTypes).length>0&&pe.add("messageType"),[pe.size>0,pe]}var lr=function(Ee){Ze.default(pe,Ee);var Ne=ar(pe);function pe($e){var ae;return Be.default(this,pe),ae=Ne.call(this),te.default(Te.default(ae),"desiredState",new Xe),te.default(Te.default(ae),"currentState",new Xe),te.default(Te.default(ae),"_hasActiveAttempt",!1),ae.channelType=$e,ae}return Pe.default(pe,[{key:"setNotificationId",value:function(ae){this.desiredState.notificationId=ae}},{key:"isActive",value:function(){return this.desiredState.notificationId!==""}},{key:"subscribe",value:function(ae){if(this.desiredState.messageTypes.has(ae)){ot.debug("message type '".concat(ae,"' for channel ").concat(this.channelType," is already registered"));return}this.desiredState.messageTypes.add(ae)}},{key:"unsubscribe",value:function(ae){this.desiredState.messageTypes.has(ae)&&this.desiredState.messageTypes.delete(ae)}},{key:"updateToken",value:function(ae){this.desiredState.token=ae}},{key:"commitChanges",value:function(){var $e=Oe.default(_e.default.mark(function ge(){var we,K,he,G,de,X;return _e.default.wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:if(!this._hasActiveAttempt){ze.next=3;break}throw ot.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(we=jr(this.desiredState,this.currentState),K=oe.default(we,2),he=K[0],G=K[1],he){ze.next=6;break}return ze.abrupt("return");case 6:if(this.currentState.notificationId||G.delete("notificationId"),ot.trace("Persisting ".concat(this.channelType," registration"),G,this.desiredState),ze.prev=8,this._hasActiveAttempt=!0,de=new Xe,de.token=this.desiredState.token,de.notificationId=this.desiredState.notificationId,de.messageTypes=new Set(this.desiredState.messageTypes),!(de.messageTypes.size>0)){ze.next=24;break}return ze.next=17,this.updateRegistration(de,G);case 17:X=ze.sent,this.currentState.token=X.token,this.currentState.notificationId=X.notificationId,this.currentState.messageTypes=new Set(X.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),ze.next=30;break;case 24:return ze.next=26,this.removeRegistration();case 26:this.currentState.token=de.token,this.currentState.notificationId=de.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:ze.next=35;break;case 32:throw ze.prev=32,ze.t0=ze.catch(8),ze.t0;case 35:return ze.prev=35,this._hasActiveAttempt=!1,ze.finish(35);case 38:case"end":return ze.stop()}},ge,this,[[8,32,35,38]])}));function ae(){return $e.apply(this,arguments)}return ae}()}]),pe}(Qe);function cr(Ee){var Ne=Vt();return function(){var $e=Ie.default(Ee),ae;if(Ne){var ge=Ie.default(this).constructor;ae=Reflect.construct($e,arguments,ge)}else ae=$e.apply(this,arguments);return Z.default(this,ae)}}function Vt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var At={min:2e3,max:12e4,randomness:.2},M=function(Ee){Ze.default(pe,Ee);var Ne=cr(pe);function pe($e,ae,ge,we){var K;return Be.default(this,pe),K=Ne.call(this,$e),te.default(Te.default(K),"registrationId",null),K.context=ae,K.twilsock=ge,K.registrarUrl=we,K}return Pe.default(pe,[{key:"updateRegistration",value:function(){var $e=Oe.default(_e.default.mark(function ge(we,K){var he=this,G,de,X,Ye,ze;return _e.default.wrap(function(ut){for(;;)switch(ut.prev=ut.next){case 0:if(!K.has("notificationId")){ut.next=3;break}return ut.next=3,this.removeRegistration();case 3:if(!(!we.notificationId||!we.notificationId.length)){ut.next=6;break}throw ot.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return ot.trace("Registering",this.channelType,we),G={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(we.messageTypes),data:{registration_id:we.notificationId}},de=this.context.productId,X="".concat(this.registrarUrl,"?productId=").concat(de),Ye={"Content-Type":"application/json"},ot.trace("Creating registration for channel ".concat(this.channelType)),ut.prev=12,ut.next=15,new f.AsyncRetrier(At).run(function(){return he.twilsock.post(X,Ye,G,de)});case 15:ze=ut.sent,this.registrationId=ze.body.id,ot.debug("Registration created: ",ze),ut.next=24;break;case 20:throw ut.prev=20,ut.t0=ut.catch(12),ot.error("Registration failed: ",ut.t0),ut.t0;case 24:return ut.abrupt("return",we);case 25:case"end":return ut.stop()}},ge,this,[[12,20]])}));function ae(ge,we){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistration",value:function(){var $e=Oe.default(_e.default.mark(function ge(){var we=this,K,he,G;return _e.default.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:if(this.registrationId){X.next=2;break}return X.abrupt("return");case 2:return K=this.context.productId,he="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(K),G={"Content-Type":"application/json"},ot.trace("Removing registration for ".concat(this.channelType)),X.prev=6,X.next=9,new f.AsyncRetrier(Object.assign(At,{maxAttemptsCount:3})).run(function(){return we.twilsock.delete(he,G,{},K)});case 9:this.registrationId=null,this.currentState.notificationId="",ot.debug("Registration removed for ".concat(this.channelType)),X.next=18;break;case 14:throw X.prev=14,X.t0=X.catch(6),ot.error("Failed to remove registration ",this.channelType,X.t0),X.t0;case 18:case"end":return X.stop()}},ge,this,[[6,14]])}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"sendDeviceRemoveRequest",value:function(){var $e=Oe.default(_e.default.mark(function ge(we){var K=this,he,G,de,X;return _e.default.wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:if(we!==""){ze.next=2;break}throw new Error("Empty registration ID");case 2:return he=this.context.productId,G="".concat(this.registrarUrl,"?productId=").concat(he),de={"Content-Type":"application/json"},X={binding_type:this.channelType,address:we},ze.prev=6,ot.trace("Removing old registrations for ".concat(this.channelType)),ze.next=10,new f.AsyncRetrier(Object.assign(At,{maxAttemptsCount:3})).run(function(){return K.twilsock.delete(G,de,X,he)});case 10:this.registrationId=null,this.currentState.notificationId="",ot.debug("Registration removed for ".concat(this.channelType)),ze.next=19;break;case 15:throw ze.prev=15,ze.t0=ze.catch(6),ot.error("Failed to remove registration ",this.channelType,ze.t0),ze.t0;case 19:case"end":return ze.stop()}},ge,this,[[6,15]])}));function ae(ge){return $e.apply(this,arguments)}return ae}()}]),pe}(lr);function V(Ee){var Ne=ie();return function(){var $e=Ie.default(Ee),ae;if(Ne){var ge=Ie.default(this).constructor;ae=Reflect.construct($e,arguments,ge)}else ae=$e.apply(this,arguments);return Z.default(this,ae)}}function ie(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Fe=function(Ee){Ze.default(pe,Ee);var Ne=V(pe);function pe($e,ae,ge){var we;return Be.default(this,pe),we=Ne.call(this,"twilsock"),te.default(Te.default(we),"contextId",Se.v4()),we.productId=$e,we.platform=ae,we.twilsock=ge,we}return Pe.default(pe,[{key:"updateRegistration",value:function(){var $e=Oe.default(_e.default.mark(function ge(we,K){var he,G;return _e.default.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:if(K.has("messageType")){X.next=2;break}return X.abrupt("return",we);case 2:return he=Array.from(we.messageTypes),G={product_id:this.productId,notification_protocol_version:4,endpoint_platform:this.platform,message_types:he},X.prev=4,X.next=7,this.twilsock.setNotificationsContext(this.contextId,G);case 7:X.next=13;break;case 9:throw X.prev=9,X.t0=X.catch(4),ot.error("Failed to update twilsock notification context: ".concat(X.t0)),X.t0;case 13:return X.abrupt("return",we);case 14:case"end":return X.stop()}},ge,this,[[4,9]])}));function ae(ge,we){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistration",value:function(){var $e=Oe.default(_e.default.mark(function ge(){return _e.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return K.prev=0,K.next=3,this.twilsock.removeNotificationsContext(this.contextId);case 3:K.next=9;break;case 5:throw K.prev=5,K.t0=K.catch(0),ot.error("Failed to remove twilsock notification context: ".concat(K.t0)),K.t0;case 9:case"end":return K.stop()}},ge,this,[[0,5]])}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"sendDeviceRemoveRequest",value:function(){var $e=Oe.default(_e.default.mark(function ge(we){return _e.default.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:case"end":return he.stop()}},ge)}));function ae(ge){return $e.apply(this,arguments)}return ae}()}]),pe}(lr);function lt(Ee){var Ne=yt();return function(){var $e=Ie.default(Ee),ae;if(Ne){var ge=Ie.default(this).constructor;ae=Reflect.construct($e,arguments,ge)}else ae=$e.apply(this,arguments);return Z.default(this,ae)}}function yt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Bt,er=z.literal("apn","fcm","twilsock");t.Notifications=Bt=function(Ee){Ze.default(pe,Ee);var Ne=lt(pe);function pe($e){var ae,ge,we,K,he,G,de,X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Be.default(this,pe),de=Ne.call(this),X.logLevel=(ae=X.logLevel)!==null&&ae!==void 0?ae:"error",ot.setLevel(X.logLevel);var Ye=(ge=X.productId)!==null&&ge!==void 0?ge:"notifications",ze=!X.twilsockClient,ct=X.twilsockClient=(we=X.twilsockClient)!==null&&we!==void 0?we:new l.TwilsockClient($e,Ye,X),ut=(K=X.notifications)!==null&&K!==void 0?K:{},ft=(he=(G=ut.region)!==null&&G!==void 0?G:X.region)!==null&&he!==void 0?he:"us1",Et="https://ers.".concat(ft,".twilio.com/v1/registrations"),It=ut.ersUrl||Et;de.connectors=new Map;var _t=Bt._detectPlatform();return de.connectors.set("apn",new M("apn",{protocolVersion:4,productId:Ye,platform:_t},ct,It)),de.connectors.set("fcm",new M("fcm",{protocolVersion:3,productId:Ye,platform:_t},ct,It)),de.connectors.set("twilsock",new Fe(Ye,_t,ct)),ct.on("stateChanged",function(St){return de.emit("transportState",St)}),de._connector("twilsock").on("stateChanged",function(St,xt,Dt){return de.emit("stateChanged",St,xt,Dt)}),de._connector("apn").on("stateChanged",function(St,xt,Dt){return de.emit("stateChanged",St,xt,Dt)}),de._connector("fcm").on("stateChanged",function(St,xt,Dt){return de.emit("stateChanged",St,xt,Dt)}),ct.on("message",function(St,xt){return de._routeMessage(St,xt)}),de.updateToken($e),ze&&(ct.connect(),de.twilsock=ct),de}return Pe.default(pe,[{key:"shutdown",value:function(){var $e=Oe.default(_e.default.mark(function ge(){return _e.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.connectors.clear(),!this.twilsock){K.next=4;break}return K.next=4,this.twilsock.disconnect();case 4:case"end":return K.stop()}},ge,this)}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"setPushRegistrationId",value:function(ae,ge){ot.debug("Set ".concat(ae," push registration id '").concat(ge,"'")),this._connector(ae).setNotificationId(ge)}},{key:"subscribe",value:function(ae,ge){ot.debug("Add ".concat(ae," subscriptions for message type ").concat(ge)),this._connector(ae).subscribe(ge)}},{key:"unsubscribe",value:function(ae,ge){ot.debug("Remove ".concat(ae," subscriptions for message type ").concat(ge)),this._connector(ae).unsubscribe(ge)}},{key:"updateToken",value:function(ae){this.connectors.forEach(function(ge){return ge.updateToken(ae)})}},{key:"commitChanges",value:function(){var $e=Oe.default(_e.default.mark(function ge(){var we;return _e.default.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:return we=[],this.connectors.forEach(function(G){G.isActive()&&we.push(G.commitChanges())}),he.next=4,Promise.all(we);case 4:case"end":return he.stop()}},ge,this)}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistrations",value:function(){var $e=Oe.default(_e.default.mark(function ge(we,K){return _e.default.wrap(function(G){for(;;)switch(G.prev=G.next){case 0:return G.next=2,this._connector(we).sendDeviceRemoveRequest(K);case 2:case"end":return G.stop()}},ge,this)}));function ae(ge,we){return $e.apply(this,arguments)}return ae}()},{key:"handlePushNotification",value:function(ae){return{messageType:ae.twi_message_type,payload:ae.payload}}},{key:"_routeMessage",value:function(ae,ge){ot.debug("Notification message arrived: ",ae,ge),this.emit("message",ae,ge)}},{key:"_connector",value:function(ae){var ge=this.connectors.get(ae);if(!ge)throw new Error("Unknown channel type: ".concat(ae));return ge}}],[{key:"_detectPlatform",value:function(){var ae="";return typeof navigator<"u"?(ae="unknown",typeof navigator.product<"u"&&(ae=navigator.product),typeof navigator.userAgent<"u"&&(ae=navigator.userAgent)):ae="web",ae.substring(0,128)}}]),pe}(Qe),H([z.validateTypes(er,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"setPushRegistrationId",null),H([z.validateTypes(er,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"subscribe",null),H([z.validateTypes(er,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"unsubscribe",null),H([z.validateTypes(z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String]),ye("design:returntype",void 0)],t.Notifications.prototype,"updateToken",null),H([z.validateTypesAsync(er,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",Promise)],t.Notifications.prototype,"removeRegistrations",null),t.Notifications=Bt=H([z.validateConstructorTypes(z.nonEmptyString,[z.pureObject,"undefined",z.literal(null)]),ye("design:paramtypes",[String,Object])],t.Notifications)})(QI);var jn={},mn={};/*
948
+ */(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=ku,r=Qi,n=$a,i=Yi,a=Ji,s=ii,o=Au,u=ni,l=hy,c=cs,d=ds,f=Xi,m=Wc,k=Zc,L=Ou,N=Qc,z=en;function re(Ee){return Ee&&typeof Ee=="object"&&"default"in Ee?Ee:{default:Ee}}function Me(Ee){if(Ee&&Ee.__esModule)return Ee;var Ne=Object.create(null);return Ee&&Object.keys(Ee).forEach(function(pe){if(pe!=="default"){var $e=Object.getOwnPropertyDescriptor(Ee,pe);Object.defineProperty(Ne,pe,$e.get?$e:{enumerable:!0,get:function(){return Ee[pe]}})}}),Ne.default=Ee,Object.freeze(Ne)}var Oe=re(e),Fe=re(r),Pe=re(n),Ze=re(i),Z=re(a),Ie=re(s),_e=re(o),se=re(u),Te=re(c),te=re(d),oe=re(m),q=re(k),ne=Me(L),Se=Me(N);function H(Ee,Ne,pe,$e){var ae=arguments.length,ge=ae<3?Ne:$e===null?$e=Object.getOwnPropertyDescriptor(Ne,pe):$e,we;if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.decorate=="function")ge=Reflect.decorate(Ee,Ne,pe,$e);else for(var K=Ee.length-1;K>=0;K--)(we=Ee[K])&&(ge=(ae<3?we(ge):ae>3?we(Ne,pe,ge):we(Ne,pe))||ge);return ae>3&&ge&&Object.defineProperty(Ne,pe,ge),ge}function ye(Ee,Ne){if((typeof Reflect>"u"?"undefined":se.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(Ee,Ne)}var ke;function P(){}P.prototype=Object.create(null);function Qe(){Qe.init.call(this)}Qe.EventEmitter=Qe,Qe.usingDomains=!1,Qe.prototype.domain=void 0,Qe.prototype._events=void 0,Qe.prototype._maxListeners=void 0,Qe.defaultMaxListeners=10,Qe.init=function(){this.domain=null,Qe.usingDomains&&ke.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new P,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},Qe.prototype.setMaxListeners=function(Ne){if(typeof Ne!="number"||Ne<0||isNaN(Ne))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=Ne,this};function Ct(Ee){return Ee._maxListeners===void 0?Qe.defaultMaxListeners:Ee._maxListeners}Qe.prototype.getMaxListeners=function(){return Ct(this)};function tt(Ee,Ne,pe){if(Ne)Ee.call(pe);else for(var $e=Ee.length,ae=Q(Ee,$e),ge=0;ge<$e;++ge)ae[ge].call(pe)}function De(Ee,Ne,pe,$e){if(Ne)Ee.call(pe,$e);else for(var ae=Ee.length,ge=Q(Ee,ae),we=0;we<ae;++we)ge[we].call(pe,$e)}function ce(Ee,Ne,pe,$e,ae){if(Ne)Ee.call(pe,$e,ae);else for(var ge=Ee.length,we=Q(Ee,ge),K=0;K<ge;++K)we[K].call(pe,$e,ae)}function Ge(Ee,Ne,pe,$e,ae,ge){if(Ne)Ee.call(pe,$e,ae,ge);else for(var we=Ee.length,K=Q(Ee,we),he=0;he<we;++he)K[he].call(pe,$e,ae,ge)}function Ue(Ee,Ne,pe,$e){if(Ne)Ee.apply(pe,$e);else for(var ae=Ee.length,ge=Q(Ee,ae),we=0;we<ae;++we)ge[we].apply(pe,$e)}Qe.prototype.emit=function(Ne){var pe,$e,ae,ge,we,K,he,G=Ne==="error";if(K=this._events,K)G=G&&K.error==null;else if(!G)return!1;if(he=this.domain,G){if(pe=arguments[1],he)pe||(pe=new Error('Uncaught, unspecified "error" event')),pe.domainEmitter=this,pe.domain=he,pe.domainThrown=!1,he.emit("error",pe);else{if(pe instanceof Error)throw pe;var de=new Error('Uncaught, unspecified "error" event. ('+pe+")");throw de.context=pe,de}return!1}if($e=K[Ne],!$e)return!1;var X=typeof $e=="function";switch(ae=arguments.length,ae){case 1:tt($e,X,this);break;case 2:De($e,X,this,arguments[1]);break;case 3:ce($e,X,this,arguments[1],arguments[2]);break;case 4:Ge($e,X,this,arguments[1],arguments[2],arguments[3]);break;default:for(ge=new Array(ae-1),we=1;we<ae;we++)ge[we-1]=arguments[we];Ue($e,X,this,ge)}return!0};function be(Ee,Ne,pe,$e){var ae,ge,we;if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');if(ge=Ee._events,ge?(ge.newListener&&(Ee.emit("newListener",Ne,pe.listener?pe.listener:pe),ge=Ee._events),we=ge[Ne]):(ge=Ee._events=new P,Ee._eventsCount=0),!we)we=ge[Ne]=pe,++Ee._eventsCount;else if(typeof we=="function"?we=ge[Ne]=$e?[pe,we]:[we,pe]:$e?we.unshift(pe):we.push(pe),!we.warned&&(ae=Ct(Ee),ae&&ae>0&&we.length>ae)){we.warned=!0;var K=new Error("Possible EventEmitter memory leak detected. "+we.length+" "+Ne+" listeners added. Use emitter.setMaxListeners() to increase limit");K.name="MaxListenersExceededWarning",K.emitter=Ee,K.type=Ne,K.count=we.length,ht(K)}return Ee}function ht(Ee){typeof console.warn=="function"?console.warn(Ee):console.log(Ee)}Qe.prototype.addListener=function(Ne,pe){return be(this,Ne,pe,!1)},Qe.prototype.on=Qe.prototype.addListener,Qe.prototype.prependListener=function(Ne,pe){return be(this,Ne,pe,!0)};function Ve(Ee,Ne,pe){var $e=!1;function ae(){Ee.removeListener(Ne,ae),$e||($e=!0,pe.apply(Ee,arguments))}return ae.listener=pe,ae}Qe.prototype.once=function(Ne,pe){if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');return this.on(Ne,Ve(this,Ne,pe)),this},Qe.prototype.prependOnceListener=function(Ne,pe){if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(Ne,Ve(this,Ne,pe)),this},Qe.prototype.removeListener=function(Ne,pe){var $e,ae,ge,we,K;if(typeof pe!="function")throw new TypeError('"listener" argument must be a function');if(ae=this._events,!ae)return this;if($e=ae[Ne],!$e)return this;if($e===pe||$e.listener&&$e.listener===pe)--this._eventsCount===0?this._events=new P:(delete ae[Ne],ae.removeListener&&this.emit("removeListener",Ne,$e.listener||pe));else if(typeof $e!="function"){for(ge=-1,we=$e.length;we-- >0;)if($e[we]===pe||$e[we].listener&&$e[we].listener===pe){K=$e[we].listener,ge=we;break}if(ge<0)return this;if($e.length===1){if($e[0]=void 0,--this._eventsCount===0)return this._events=new P,this;delete ae[Ne]}else Rt($e,ge);ae.removeListener&&this.emit("removeListener",Ne,K||pe)}return this},Qe.prototype.off=function(Ee,Ne){return this.removeListener(Ee,Ne)},Qe.prototype.removeAllListeners=function(Ne){var pe,$e;if($e=this._events,!$e)return this;if(!$e.removeListener)return arguments.length===0?(this._events=new P,this._eventsCount=0):$e[Ne]&&(--this._eventsCount===0?this._events=new P:delete $e[Ne]),this;if(arguments.length===0){for(var ae=Object.keys($e),ge=0,we;ge<ae.length;++ge)we=ae[ge],we!=="removeListener"&&this.removeAllListeners(we);return this.removeAllListeners("removeListener"),this._events=new P,this._eventsCount=0,this}if(pe=$e[Ne],typeof pe=="function")this.removeListener(Ne,pe);else if(pe)do this.removeListener(Ne,pe[pe.length-1]);while(pe[0]);return this},Qe.prototype.listeners=function(Ne){var pe,$e,ae=this._events;return ae?(pe=ae[Ne],pe?typeof pe=="function"?$e=[pe.listener||pe]:$e=je(pe):$e=[]):$e=[],$e},Qe.listenerCount=function(Ee,Ne){return typeof Ee.listenerCount=="function"?Ee.listenerCount(Ne):Kt.call(Ee,Ne)},Qe.prototype.listenerCount=Kt;function Kt(Ee){var Ne=this._events;if(Ne){var pe=Ne[Ee];if(typeof pe=="function")return 1;if(pe)return pe.length}return 0}Qe.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function Rt(Ee,Ne){for(var pe=Ne,$e=pe+1,ae=Ee.length;$e<ae;pe+=1,$e+=1)Ee[pe]=Ee[$e];Ee.pop()}function Q(Ee,Ne){for(var pe=new Array(Ne);Ne--;)pe[Ne]=Ee[Ne];return pe}function je(Ee){for(var Ne=new Array(Ee.length),pe=0;pe<Ne.length;++pe)Ne[pe]=Ee[pe].listener||Ee[pe];return Ne}var st=ne.getLogger("twilio-notificatiions");function Re(Ee,Ne){return["".concat(new Date().toISOString()," Twilio.Notifications ").concat(Ee,":")].concat(Array.from(Ne))}var kt=function(){function Ee(){Fe.default(this,Ee)}return Pe.default(Ee,[{key:"setLevel",value:function(pe){st.setLevel(pe)}},{key:"trace",value:function(){if(st.getLevel()==st.levels.TRACE){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];st.debug.apply(null,Re("T",$e))}}},{key:"debug",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];st.debug.apply(null,Re("D",$e))}},{key:"info",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];st.info.apply(null,Re("I",$e))}},{key:"warn",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];st.warn.apply(null,Re("W",$e))}},{key:"error",value:function(){for(var pe=arguments.length,$e=new Array(pe),ae=0;ae<pe;ae++)$e[ae]=arguments[ae];st.error.apply(null,Re("E",$e))}}]),Ee}(),ot=new kt;function ar(Ee){var Ne=mr();return function(){var $e=Ie.default(Ee),ae;if(Ne){var ge=Ie.default(this).constructor;ae=Reflect.construct($e,arguments,ge)}else ae=$e.apply(this,arguments);return Z.default(this,ae)}}function mr(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Xe=Pe.default(function Ee(){var Ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",pe=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",$e=arguments.length>2&&arguments[2]!==void 0?arguments[2]:new Set;Fe.default(this,Ee),this.token=Ne,this.notificationId=pe,this.messageTypes=$e});function Or(Ee,Ne){return[].concat(q.default(q.default(Ee).filter(function(pe){return!Ne.has(pe)})),q.default(q.default(Ne).filter(function(pe){return!Ee.has(pe)})))}function jr(Ee,Ne){var pe=new Set;return Ee.notificationId!==Ne.notificationId&&pe.add("notificationId"),Ee.token!==Ne.token&&pe.add("token"),Or(Ee.messageTypes,Ne.messageTypes).length>0&&pe.add("messageType"),[pe.size>0,pe]}var lr=function(Ee){Ze.default(pe,Ee);var Ne=ar(pe);function pe($e){var ae;return Fe.default(this,pe),ae=Ne.call(this),te.default(Te.default(ae),"desiredState",new Xe),te.default(Te.default(ae),"currentState",new Xe),te.default(Te.default(ae),"_hasActiveAttempt",!1),ae.channelType=$e,ae}return Pe.default(pe,[{key:"setNotificationId",value:function(ae){this.desiredState.notificationId=ae}},{key:"isActive",value:function(){return this.desiredState.notificationId!==""}},{key:"subscribe",value:function(ae){if(this.desiredState.messageTypes.has(ae)){ot.debug("message type '".concat(ae,"' for channel ").concat(this.channelType," is already registered"));return}this.desiredState.messageTypes.add(ae)}},{key:"unsubscribe",value:function(ae){this.desiredState.messageTypes.has(ae)&&this.desiredState.messageTypes.delete(ae)}},{key:"updateToken",value:function(ae){this.desiredState.token=ae}},{key:"commitChanges",value:function(){var $e=Oe.default(_e.default.mark(function ge(){var we,K,he,G,de,X;return _e.default.wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:if(!this._hasActiveAttempt){ze.next=3;break}throw ot.error("One registration attempt is already in progress"),new Error("One registration attempt is already in progress");case 3:if(we=jr(this.desiredState,this.currentState),K=oe.default(we,2),he=K[0],G=K[1],he){ze.next=6;break}return ze.abrupt("return");case 6:if(this.currentState.notificationId||G.delete("notificationId"),ot.trace("Persisting ".concat(this.channelType," registration"),G,this.desiredState),ze.prev=8,this._hasActiveAttempt=!0,de=new Xe,de.token=this.desiredState.token,de.notificationId=this.desiredState.notificationId,de.messageTypes=new Set(this.desiredState.messageTypes),!(de.messageTypes.size>0)){ze.next=24;break}return ze.next=17,this.updateRegistration(de,G);case 17:X=ze.sent,this.currentState.token=X.token,this.currentState.notificationId=X.notificationId,this.currentState.messageTypes=new Set(X.messageTypes),this.emit("stateChanged",this.channelType,"registered",this.currentState),ze.next=30;break;case 24:return ze.next=26,this.removeRegistration();case 26:this.currentState.token=de.token,this.currentState.notificationId=de.notificationId,this.currentState.messageTypes.clear(),this.emit("stateChanged",this.channelType,"unregistered",this.currentState);case 30:ze.next=35;break;case 32:throw ze.prev=32,ze.t0=ze.catch(8),ze.t0;case 35:return ze.prev=35,this._hasActiveAttempt=!1,ze.finish(35);case 38:case"end":return ze.stop()}},ge,this,[[8,32,35,38]])}));function ae(){return $e.apply(this,arguments)}return ae}()}]),pe}(Qe);function cr(Ee){var Ne=Vt();return function(){var $e=Ie.default(Ee),ae;if(Ne){var ge=Ie.default(this).constructor;ae=Reflect.construct($e,arguments,ge)}else ae=$e.apply(this,arguments);return Z.default(this,ae)}}function Vt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var At={min:2e3,max:12e4,randomness:.2},M=function(Ee){Ze.default(pe,Ee);var Ne=cr(pe);function pe($e,ae,ge,we){var K;return Fe.default(this,pe),K=Ne.call(this,$e),te.default(Te.default(K),"registrationId",null),K.context=ae,K.twilsock=ge,K.registrarUrl=we,K}return Pe.default(pe,[{key:"updateRegistration",value:function(){var $e=Oe.default(_e.default.mark(function ge(we,K){var he=this,G,de,X,Ye,ze;return _e.default.wrap(function(ut){for(;;)switch(ut.prev=ut.next){case 0:if(!K.has("notificationId")){ut.next=3;break}return ut.next=3,this.removeRegistration();case 3:if(!(!we.notificationId||!we.notificationId.length)){ut.next=6;break}throw ot.error("No push notification ID for registration"),new Error("No push notification ID for registration");case 6:return ot.trace("Registering",this.channelType,we),G={endpoint_platform:this.context.platform,channel_type:this.channelType,version:this.context.protocolVersion.toString(),message_types:Array.from(we.messageTypes),data:{registration_id:we.notificationId}},de=this.context.productId,X="".concat(this.registrarUrl,"?productId=").concat(de),Ye={"Content-Type":"application/json"},ot.trace("Creating registration for channel ".concat(this.channelType)),ut.prev=12,ut.next=15,new f.AsyncRetrier(At).run(function(){return he.twilsock.post(X,Ye,G,de)});case 15:ze=ut.sent,this.registrationId=ze.body.id,ot.debug("Registration created: ",ze),ut.next=24;break;case 20:throw ut.prev=20,ut.t0=ut.catch(12),ot.error("Registration failed: ",ut.t0),ut.t0;case 24:return ut.abrupt("return",we);case 25:case"end":return ut.stop()}},ge,this,[[12,20]])}));function ae(ge,we){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistration",value:function(){var $e=Oe.default(_e.default.mark(function ge(){var we=this,K,he,G;return _e.default.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:if(this.registrationId){X.next=2;break}return X.abrupt("return");case 2:return K=this.context.productId,he="".concat(this.registrarUrl,"/").concat(this.registrationId,"?productId=").concat(K),G={"Content-Type":"application/json"},ot.trace("Removing registration for ".concat(this.channelType)),X.prev=6,X.next=9,new f.AsyncRetrier(Object.assign(At,{maxAttemptsCount:3})).run(function(){return we.twilsock.delete(he,G,{},K)});case 9:this.registrationId=null,this.currentState.notificationId="",ot.debug("Registration removed for ".concat(this.channelType)),X.next=18;break;case 14:throw X.prev=14,X.t0=X.catch(6),ot.error("Failed to remove registration ",this.channelType,X.t0),X.t0;case 18:case"end":return X.stop()}},ge,this,[[6,14]])}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"sendDeviceRemoveRequest",value:function(){var $e=Oe.default(_e.default.mark(function ge(we){var K=this,he,G,de,X;return _e.default.wrap(function(ze){for(;;)switch(ze.prev=ze.next){case 0:if(we!==""){ze.next=2;break}throw new Error("Empty registration ID");case 2:return he=this.context.productId,G="".concat(this.registrarUrl,"?productId=").concat(he),de={"Content-Type":"application/json"},X={binding_type:this.channelType,address:we},ze.prev=6,ot.trace("Removing old registrations for ".concat(this.channelType)),ze.next=10,new f.AsyncRetrier(Object.assign(At,{maxAttemptsCount:3})).run(function(){return K.twilsock.delete(G,de,X,he)});case 10:this.registrationId=null,this.currentState.notificationId="",ot.debug("Registration removed for ".concat(this.channelType)),ze.next=19;break;case 15:throw ze.prev=15,ze.t0=ze.catch(6),ot.error("Failed to remove registration ",this.channelType,ze.t0),ze.t0;case 19:case"end":return ze.stop()}},ge,this,[[6,15]])}));function ae(ge){return $e.apply(this,arguments)}return ae}()}]),pe}(lr);function V(Ee){var Ne=ie();return function(){var $e=Ie.default(Ee),ae;if(Ne){var ge=Ie.default(this).constructor;ae=Reflect.construct($e,arguments,ge)}else ae=$e.apply(this,arguments);return Z.default(this,ae)}}function ie(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Be=function(Ee){Ze.default(pe,Ee);var Ne=V(pe);function pe($e,ae,ge){var we;return Fe.default(this,pe),we=Ne.call(this,"twilsock"),te.default(Te.default(we),"contextId",Se.v4()),we.productId=$e,we.platform=ae,we.twilsock=ge,we}return Pe.default(pe,[{key:"updateRegistration",value:function(){var $e=Oe.default(_e.default.mark(function ge(we,K){var he,G;return _e.default.wrap(function(X){for(;;)switch(X.prev=X.next){case 0:if(K.has("messageType")){X.next=2;break}return X.abrupt("return",we);case 2:return he=Array.from(we.messageTypes),G={product_id:this.productId,notification_protocol_version:4,endpoint_platform:this.platform,message_types:he},X.prev=4,X.next=7,this.twilsock.setNotificationsContext(this.contextId,G);case 7:X.next=13;break;case 9:throw X.prev=9,X.t0=X.catch(4),ot.error("Failed to update twilsock notification context: ".concat(X.t0)),X.t0;case 13:return X.abrupt("return",we);case 14:case"end":return X.stop()}},ge,this,[[4,9]])}));function ae(ge,we){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistration",value:function(){var $e=Oe.default(_e.default.mark(function ge(){return _e.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:return K.prev=0,K.next=3,this.twilsock.removeNotificationsContext(this.contextId);case 3:K.next=9;break;case 5:throw K.prev=5,K.t0=K.catch(0),ot.error("Failed to remove twilsock notification context: ".concat(K.t0)),K.t0;case 9:case"end":return K.stop()}},ge,this,[[0,5]])}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"sendDeviceRemoveRequest",value:function(){var $e=Oe.default(_e.default.mark(function ge(we){return _e.default.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:case"end":return he.stop()}},ge)}));function ae(ge){return $e.apply(this,arguments)}return ae}()}]),pe}(lr);function lt(Ee){var Ne=yt();return function(){var $e=Ie.default(Ee),ae;if(Ne){var ge=Ie.default(this).constructor;ae=Reflect.construct($e,arguments,ge)}else ae=$e.apply(this,arguments);return Z.default(this,ae)}}function yt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Bt,er=z.literal("apn","fcm","twilsock");t.Notifications=Bt=function(Ee){Ze.default(pe,Ee);var Ne=lt(pe);function pe($e){var ae,ge,we,K,he,G,de,X=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Fe.default(this,pe),de=Ne.call(this),X.logLevel=(ae=X.logLevel)!==null&&ae!==void 0?ae:"error",ot.setLevel(X.logLevel);var Ye=(ge=X.productId)!==null&&ge!==void 0?ge:"notifications",ze=!X.twilsockClient,ct=X.twilsockClient=(we=X.twilsockClient)!==null&&we!==void 0?we:new l.TwilsockClient($e,Ye,X),ut=(K=X.notifications)!==null&&K!==void 0?K:{},ft=(he=(G=ut.region)!==null&&G!==void 0?G:X.region)!==null&&he!==void 0?he:"us1",Et="https://ers.".concat(ft,".twilio.com/v1/registrations"),It=ut.ersUrl||Et;de.connectors=new Map;var _t=Bt._detectPlatform();return de.connectors.set("apn",new M("apn",{protocolVersion:4,productId:Ye,platform:_t},ct,It)),de.connectors.set("fcm",new M("fcm",{protocolVersion:3,productId:Ye,platform:_t},ct,It)),de.connectors.set("twilsock",new Be(Ye,_t,ct)),ct.on("stateChanged",function(St){return de.emit("transportState",St)}),de._connector("twilsock").on("stateChanged",function(St,xt,Dt){return de.emit("stateChanged",St,xt,Dt)}),de._connector("apn").on("stateChanged",function(St,xt,Dt){return de.emit("stateChanged",St,xt,Dt)}),de._connector("fcm").on("stateChanged",function(St,xt,Dt){return de.emit("stateChanged",St,xt,Dt)}),ct.on("message",function(St,xt){return de._routeMessage(St,xt)}),de.updateToken($e),ze&&(ct.connect(),de.twilsock=ct),de}return Pe.default(pe,[{key:"shutdown",value:function(){var $e=Oe.default(_e.default.mark(function ge(){return _e.default.wrap(function(K){for(;;)switch(K.prev=K.next){case 0:if(this.connectors.clear(),!this.twilsock){K.next=4;break}return K.next=4,this.twilsock.disconnect();case 4:case"end":return K.stop()}},ge,this)}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"setPushRegistrationId",value:function(ae,ge){ot.debug("Set ".concat(ae," push registration id '").concat(ge,"'")),this._connector(ae).setNotificationId(ge)}},{key:"subscribe",value:function(ae,ge){ot.debug("Add ".concat(ae," subscriptions for message type ").concat(ge)),this._connector(ae).subscribe(ge)}},{key:"unsubscribe",value:function(ae,ge){ot.debug("Remove ".concat(ae," subscriptions for message type ").concat(ge)),this._connector(ae).unsubscribe(ge)}},{key:"updateToken",value:function(ae){this.connectors.forEach(function(ge){return ge.updateToken(ae)})}},{key:"commitChanges",value:function(){var $e=Oe.default(_e.default.mark(function ge(){var we;return _e.default.wrap(function(he){for(;;)switch(he.prev=he.next){case 0:return we=[],this.connectors.forEach(function(G){G.isActive()&&we.push(G.commitChanges())}),he.next=4,Promise.all(we);case 4:case"end":return he.stop()}},ge,this)}));function ae(){return $e.apply(this,arguments)}return ae}()},{key:"removeRegistrations",value:function(){var $e=Oe.default(_e.default.mark(function ge(we,K){return _e.default.wrap(function(G){for(;;)switch(G.prev=G.next){case 0:return G.next=2,this._connector(we).sendDeviceRemoveRequest(K);case 2:case"end":return G.stop()}},ge,this)}));function ae(ge,we){return $e.apply(this,arguments)}return ae}()},{key:"handlePushNotification",value:function(ae){return{messageType:ae.twi_message_type,payload:ae.payload}}},{key:"_routeMessage",value:function(ae,ge){ot.debug("Notification message arrived: ",ae,ge),this.emit("message",ae,ge)}},{key:"_connector",value:function(ae){var ge=this.connectors.get(ae);if(!ge)throw new Error("Unknown channel type: ".concat(ae));return ge}}],[{key:"_detectPlatform",value:function(){var ae="";return typeof navigator<"u"?(ae="unknown",typeof navigator.product<"u"&&(ae=navigator.product),typeof navigator.userAgent<"u"&&(ae=navigator.userAgent)):ae="web",ae.substring(0,128)}}]),pe}(Qe),H([z.validateTypes(er,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"setPushRegistrationId",null),H([z.validateTypes(er,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"subscribe",null),H([z.validateTypes(er,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",void 0)],t.Notifications.prototype,"unsubscribe",null),H([z.validateTypes(z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String]),ye("design:returntype",void 0)],t.Notifications.prototype,"updateToken",null),H([z.validateTypesAsync(er,z.nonEmptyString),ye("design:type",Function),ye("design:paramtypes",[String,String]),ye("design:returntype",Promise)],t.Notifications.prototype,"removeRegistrations",null),t.Notifications=Bt=H([z.validateConstructorTypes(z.nonEmptyString,[z.pureObject,"undefined",z.literal(null)]),ye("design:paramtypes",[String,Object])],t.Notifications)})(QI);var jn={},mn={};/*
949
949
  @license
950
950
  Copyright (c) 2021 Twilio Inc.
951
951
 
@@ -1043,7 +1043,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1043
1043
  OTHER DEALINGS IN THE SOFTWARE.
1044
1044
 
1045
1045
 
1046
- */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=ku,n=$a,i=cs,a=Rh,s=Yi,o=Ji,u=ii,l=Qi,c=ds,d=Au,f=ni,m=mn,k=Ou,L=AC,N=Qc,z=ad,re=Xi,Me=nb;function Oe(D){return D&&typeof D=="object"&&"default"in D?D:{default:D}}function Be(D){if(D&&D.__esModule)return D;var B=Object.create(null);return D&&Object.keys(D).forEach(function(C){if(C!=="default"){var T=Object.getOwnPropertyDescriptor(D,C);Object.defineProperty(B,C,T.get?T:{enumerable:!0,get:function(){return D[C]}})}}),B.default=D,Object.freeze(B)}var Pe=Oe(r),Ze=Oe(n),Z=Oe(i),Ie=Oe(a),_e=Oe(s),se=Oe(o),Te=Oe(u),te=Oe(l),oe=Oe(c),q=Oe(d),ne=Oe(f),Se=Be(k),H=Be(L),ye=Oe(z),ke=Be(Me);function P(D,B,C,T){var $=arguments.length,U=$<3?B:T===null?T=Object.getOwnPropertyDescriptor(B,C):T,O;if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(D,B,C,T);else for(var Ae=D.length-1;Ae>=0;Ae--)(O=D[Ae])&&(U=($<3?O(U):$>3?O(B,C,U):O(B,C))||U);return $>3&&U&&Object.defineProperty(B,C,U),U}function Qe(D,B){if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(D,B)}var Ct;function tt(){}tt.prototype=Object.create(null);function De(){De.init.call(this)}De.EventEmitter=De,De.usingDomains=!1,De.prototype.domain=void 0,De.prototype._events=void 0,De.prototype._maxListeners=void 0,De.defaultMaxListeners=10,De.init=function(){this.domain=null,De.usingDomains&&Ct.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new tt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},De.prototype.setMaxListeners=function(B){if(typeof B!="number"||B<0||isNaN(B))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=B,this};function ce(D){return D._maxListeners===void 0?De.defaultMaxListeners:D._maxListeners}De.prototype.getMaxListeners=function(){return ce(this)};function Ge(D,B,C){if(B)D.call(C);else for(var T=D.length,$=Re(D,T),U=0;U<T;++U)$[U].call(C)}function Ue(D,B,C,T){if(B)D.call(C,T);else for(var $=D.length,U=Re(D,$),O=0;O<$;++O)U[O].call(C,T)}function be(D,B,C,T,$){if(B)D.call(C,T,$);else for(var U=D.length,O=Re(D,U),Ae=0;Ae<U;++Ae)O[Ae].call(C,T,$)}function ht(D,B,C,T,$,U){if(B)D.call(C,T,$,U);else for(var O=D.length,Ae=Re(D,O),Ce=0;Ce<O;++Ce)Ae[Ce].call(C,T,$,U)}function Ve(D,B,C,T){if(B)D.apply(C,T);else for(var $=D.length,U=Re(D,$),O=0;O<$;++O)U[O].apply(C,T)}De.prototype.emit=function(B){var C,T,$,U,O,Ae,Ce,Je=B==="error";if(Ae=this._events,Ae)Je=Je&&Ae.error==null;else if(!Je)return!1;if(Ce=this.domain,Je){if(C=arguments[1],Ce)C||(C=new Error('Uncaught, unspecified "error" event')),C.domainEmitter=this,C.domain=Ce,C.domainThrown=!1,Ce.emit("error",C);else{if(C instanceof Error)throw C;var nt=new Error('Uncaught, unspecified "error" event. ('+C+")");throw nt.context=C,nt}return!1}if(T=Ae[B],!T)return!1;var Ot=typeof T=="function";switch($=arguments.length,$){case 1:Ge(T,Ot,this);break;case 2:Ue(T,Ot,this,arguments[1]);break;case 3:be(T,Ot,this,arguments[1],arguments[2]);break;case 4:ht(T,Ot,this,arguments[1],arguments[2],arguments[3]);break;default:for(U=new Array($-1),O=1;O<$;O++)U[O-1]=arguments[O];Ve(T,Ot,this,U)}return!0};function Kt(D,B,C,T){var $,U,O;if(typeof C!="function")throw new TypeError('"listener" argument must be a function');if(U=D._events,U?(U.newListener&&(D.emit("newListener",B,C.listener?C.listener:C),U=D._events),O=U[B]):(U=D._events=new tt,D._eventsCount=0),!O)O=U[B]=C,++D._eventsCount;else if(typeof O=="function"?O=U[B]=T?[C,O]:[O,C]:T?O.unshift(C):O.push(C),!O.warned&&($=ce(D),$&&$>0&&O.length>$)){O.warned=!0;var Ae=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+B+" listeners added. Use emitter.setMaxListeners() to increase limit");Ae.name="MaxListenersExceededWarning",Ae.emitter=D,Ae.type=B,Ae.count=O.length,Rt(Ae)}return D}function Rt(D){typeof console.warn=="function"?console.warn(D):console.log(D)}De.prototype.addListener=function(B,C){return Kt(this,B,C,!1)},De.prototype.on=De.prototype.addListener,De.prototype.prependListener=function(B,C){return Kt(this,B,C,!0)};function Q(D,B,C){var T=!1;function $(){D.removeListener(B,$),T||(T=!0,C.apply(D,arguments))}return $.listener=C,$}De.prototype.once=function(B,C){if(typeof C!="function")throw new TypeError('"listener" argument must be a function');return this.on(B,Q(this,B,C)),this},De.prototype.prependOnceListener=function(B,C){if(typeof C!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(B,Q(this,B,C)),this},De.prototype.removeListener=function(B,C){var T,$,U,O,Ae;if(typeof C!="function")throw new TypeError('"listener" argument must be a function');if($=this._events,!$)return this;if(T=$[B],!T)return this;if(T===C||T.listener&&T.listener===C)--this._eventsCount===0?this._events=new tt:(delete $[B],$.removeListener&&this.emit("removeListener",B,T.listener||C));else if(typeof T!="function"){for(U=-1,O=T.length;O-- >0;)if(T[O]===C||T[O].listener&&T[O].listener===C){Ae=T[O].listener,U=O;break}if(U<0)return this;if(T.length===1){if(T[0]=void 0,--this._eventsCount===0)return this._events=new tt,this;delete $[B]}else st(T,U);$.removeListener&&this.emit("removeListener",B,Ae||C)}return this},De.prototype.off=function(D,B){return this.removeListener(D,B)},De.prototype.removeAllListeners=function(B){var C,T;if(T=this._events,!T)return this;if(!T.removeListener)return arguments.length===0?(this._events=new tt,this._eventsCount=0):T[B]&&(--this._eventsCount===0?this._events=new tt:delete T[B]),this;if(arguments.length===0){for(var $=Object.keys(T),U=0,O;U<$.length;++U)O=$[U],O!=="removeListener"&&this.removeAllListeners(O);return this.removeAllListeners("removeListener"),this._events=new tt,this._eventsCount=0,this}if(C=T[B],typeof C=="function")this.removeListener(B,C);else if(C)do this.removeListener(B,C[C.length-1]);while(C[0]);return this},De.prototype.listeners=function(B){var C,T,$=this._events;return $?(C=$[B],C?typeof C=="function"?T=[C.listener||C]:T=kt(C):T=[]):T=[],T},De.listenerCount=function(D,B){return typeof D.listenerCount=="function"?D.listenerCount(B):je.call(D,B)},De.prototype.listenerCount=je;function je(D){var B=this._events;if(B){var C=B[D];if(typeof C=="function")return 1;if(C)return C.length}return 0}De.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function st(D,B){for(var C=B,T=C+1,$=D.length;T<$;C+=1,T+=1)D[C]=D[T];D.pop()}function Re(D,B){for(var C=new Array(B);B--;)C[B]=D[B];return C}function kt(D){for(var B=new Array(D.length),C=0;C<B.length;++C)B[C]=D[C].listener||D[C];return B}var ot=Se.getLogger("twilsock");function ar(D,B){return["".concat(new Date().toISOString()," Twilsock ").concat(D,":")].concat(Array.from(B))}var mr=function(){function D(B){te.default(this,D),oe.default(this,"prefix",""),this.prefix=B!=null&&B.length>0?" "+B+":":""}return Ze.default(D,[{key:"setLevel",value:function(C){ot.setLevel(C)}},{key:"trace",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.trace.apply(null,ar("T",T))}},{key:"debug",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.debug.apply(null,ar("D",T))}},{key:"info",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.info.apply(null,ar("I",T))}},{key:"warn",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.warn.apply(null,ar("W",T))}},{key:"error",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.error.apply(null,ar("E",T))}}],[{key:"setLevel",value:function(C){ot.setLevel(C)}},{key:"trace",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.trace.apply(null,ar("T",T))}},{key:"debug",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.debug.apply(null,ar("D",T))}},{key:"info",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.info.apply(null,ar("I",T))}},{key:"warn",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.warn.apply(null,ar("W",T))}},{key:"error",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.error.apply(null,ar("E",T))}}]),D}(),Xe=new mr(""),Or="0.12.2",jr=function(){function D(B,C,T){te.default(this,D),oe.default(this,"confirmedCapabilities",new Set),this.activeGrant=C,this._token=B;var $=T.region||"us1",U="wss://tsock.".concat($,".twilio.com/v3/wsconnect"),O=T.twilsock||T.Twilsock||{};this.url=O.uri||U,this._continuationToken=T.continuationToken?T.continuationToken:null,this.logLevel=T.logLevel?T.logLevel:"error",this.retryPolicy=T.retryPolicy?T.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=T.clientMetadata?T.clientMetadata:{},this.clientMetadata.ver=Or,this.initRegistrations=T.initRegistrations?T.initRegistrations:null,this.tweaks=T.tweaks?T.tweaks:null}return Ze.default(D,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(C){this._token=C}},{key:"updateContinuationToken",value:function(C){this._continuationToken=C}}]),D}(),lr=function D(B){te.default(this,D),this.id=B||"TM".concat(N.v4())};function cr(D){var B=Vt();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Vt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var At=function(D){_e.default(C,D);var B=cr(C);function C(T,$,U,O,Ae){var Ce;return te.default(this,C),Ce=B.call(this),oe.default(Z.default(Ce),"method","init"),Ce.token=T,Ce.continuation_token=$,Ce.metadata=U,Ce.registrations=O,Ce.tweaks=Ae,Ce.capabilities=["client_update","offline_storage","telemetry.v1"],Ce}return C}(lr);function M(D){var B=V();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function V(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ie=function(D){_e.default(C,D);var B=M(C);function C(T,$,U,O,Ae,Ce,Je){var nt;return te.default(this,C),nt=B.call(this,T),nt.continuationToken=$,nt.continuationTokenStatus=O,nt.offlineStorage=Ae,nt.initRegistrations=Ce,nt.debugInfo=Je,nt.confirmedCapabilities=U,nt}return C}(lr);function Fe(D){var B=lt();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function lt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var yt=function(D){_e.default(C,D);var B=Fe(C);function C(T){var $;return te.default(this,C),$=B.call(this),oe.default(Z.default($),"method","update"),$.token=T,$}return C}(lr);function Bt(D){var B=er();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function er(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ee=function(D){_e.default(C,D);var B=Bt(C);function C(T,$,U){var O;return te.default(this,C),O=B.call(this),oe.default(Z.default(O),"method","message"),O.active_grant=T,O.payload_type=$,O.http_request=U,O}return C}(lr);function Ne(D){var B=pe();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function pe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var $e=function(D){_e.default(C,D);var B=Ne(C);function C(T){var $;return te.default(this,C),$=B.call(this,T),oe.default(Z.default($),"method","reply"),oe.default(Z.default($),"payload_type","application/json"),oe.default(Z.default($),"status",{code:200,status:"OK"}),$}return C}(lr);function ae(D){var B=ge();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function ge(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var we=function(D){_e.default(C,D);var B=ae(C);function C(){var T;return te.default(this,C),T=B.call(this),oe.default(Z.default(T),"method","close"),T}return C}(lr);function K(D){var B=he();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function he(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var G=function D(B,C,T,$,U,O){te.default(this,D),this.start=B,this.end=C,this.title=T,this.details=$,this.id=U,this.type=O},de=function(D){_e.default(C,D);var B=K(C);function C(T){var $;return te.default(this,C),$=B.call(this),oe.default(Z.default($),"method","telemetry.v1"),$.events=T,$}return C}(lr);function X(D){var B=encodeURIComponent(D),C=B.replace(/%([0-9A-F]{2})/g,function(T,$){return String.fromCharCode(+("0x"+$))});return C.length}function Ye(D){var B=encodeURIComponent(D),C=B.replace(/%([0-9A-F]{2})/g,function($,U){return String.fromCharCode(+("0x"+U))}),T=new Uint8Array(C.length);return Array.prototype.forEach.call(C,function($,U){T[U]=$.charCodeAt(0)}),T}function ze(D){var B=Array.prototype.map.call(D,function(T){return String.fromCharCode(T)}).join(""),C=B.replace(/(.)/g,function(T,$){var U=$.charCodeAt(0).toString(16).toUpperCase();return U.length<2&&(U="0"+U),"%"+U});return decodeURIComponent(C)}function ct(D){return JSON.parse(ze(D))}function ut(D){for(var B="",C=0;C<D.length;++C){var T=String.fromCharCode(D[C]);if(B+=T,T==="\r"){C+=2;break}}var $=B.split(" ");return{size:C,protocol:$[0],version:$[1],headerSize:Number($[2])}}var ft=function(){function D(){te.default(this,D)}return Ze.default(D,null,[{key:"parse",value:function(C){var T=2,$=new Uint8Array(C),U=ut($);if(U.protocol!=="TWILSOCK"||U.version!=="V3.0")return Xe.error("unsupported protocol: ".concat(U.protocol," ver ").concat(U.version)),null;var O;try{O=ct($.subarray(U.size,U.size+U.headerSize))}catch(nt){return Xe.error("failed to parse message header",nt,C),null}Xe.debug("message received: ",O.method),Xe.trace("message received: ",O);var Ae;if(O.payload_size>0){var Ce=T+U.size+U.headerSize,Je=O.payload_size;if(!O.hasOwnProperty("payload_type")||O.payload_type.indexOf("application/json")===0)try{Ae=ct($.subarray(Ce,Ce+Je))}catch(nt){return Xe.error("failed to parse message body",nt,C),null}else O.payload_type.indexOf("text/plain")===0&&(Ae=ze($.subarray(Ce,Ce+Je)))}return{method:O.method,header:O,payload:Ae}}},{key:"createPacket",value:function(C){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";C.payload_size=X(T);var $=JSON.stringify(C),U="TWILSOCK V3.0 "+X($);Xe.debug("send request:",U+$+T);var O=Ye(U+`\r
1046
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=ku,n=$a,i=cs,a=Rh,s=Yi,o=Ji,u=ii,l=Qi,c=ds,d=Au,f=ni,m=mn,k=Ou,L=AC,N=Qc,z=ad,re=Xi,Me=nb;function Oe(D){return D&&typeof D=="object"&&"default"in D?D:{default:D}}function Fe(D){if(D&&D.__esModule)return D;var B=Object.create(null);return D&&Object.keys(D).forEach(function(C){if(C!=="default"){var T=Object.getOwnPropertyDescriptor(D,C);Object.defineProperty(B,C,T.get?T:{enumerable:!0,get:function(){return D[C]}})}}),B.default=D,Object.freeze(B)}var Pe=Oe(r),Ze=Oe(n),Z=Oe(i),Ie=Oe(a),_e=Oe(s),se=Oe(o),Te=Oe(u),te=Oe(l),oe=Oe(c),q=Oe(d),ne=Oe(f),Se=Fe(k),H=Fe(L),ye=Oe(z),ke=Fe(Me);function P(D,B,C,T){var $=arguments.length,U=$<3?B:T===null?T=Object.getOwnPropertyDescriptor(B,C):T,O;if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(D,B,C,T);else for(var Ae=D.length-1;Ae>=0;Ae--)(O=D[Ae])&&(U=($<3?O(U):$>3?O(B,C,U):O(B,C))||U);return $>3&&U&&Object.defineProperty(B,C,U),U}function Qe(D,B){if((typeof Reflect>"u"?"undefined":ne.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(D,B)}var Ct;function tt(){}tt.prototype=Object.create(null);function De(){De.init.call(this)}De.EventEmitter=De,De.usingDomains=!1,De.prototype.domain=void 0,De.prototype._events=void 0,De.prototype._maxListeners=void 0,De.defaultMaxListeners=10,De.init=function(){this.domain=null,De.usingDomains&&Ct.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new tt,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},De.prototype.setMaxListeners=function(B){if(typeof B!="number"||B<0||isNaN(B))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=B,this};function ce(D){return D._maxListeners===void 0?De.defaultMaxListeners:D._maxListeners}De.prototype.getMaxListeners=function(){return ce(this)};function Ge(D,B,C){if(B)D.call(C);else for(var T=D.length,$=Re(D,T),U=0;U<T;++U)$[U].call(C)}function Ue(D,B,C,T){if(B)D.call(C,T);else for(var $=D.length,U=Re(D,$),O=0;O<$;++O)U[O].call(C,T)}function be(D,B,C,T,$){if(B)D.call(C,T,$);else for(var U=D.length,O=Re(D,U),Ae=0;Ae<U;++Ae)O[Ae].call(C,T,$)}function ht(D,B,C,T,$,U){if(B)D.call(C,T,$,U);else for(var O=D.length,Ae=Re(D,O),Ce=0;Ce<O;++Ce)Ae[Ce].call(C,T,$,U)}function Ve(D,B,C,T){if(B)D.apply(C,T);else for(var $=D.length,U=Re(D,$),O=0;O<$;++O)U[O].apply(C,T)}De.prototype.emit=function(B){var C,T,$,U,O,Ae,Ce,Je=B==="error";if(Ae=this._events,Ae)Je=Je&&Ae.error==null;else if(!Je)return!1;if(Ce=this.domain,Je){if(C=arguments[1],Ce)C||(C=new Error('Uncaught, unspecified "error" event')),C.domainEmitter=this,C.domain=Ce,C.domainThrown=!1,Ce.emit("error",C);else{if(C instanceof Error)throw C;var nt=new Error('Uncaught, unspecified "error" event. ('+C+")");throw nt.context=C,nt}return!1}if(T=Ae[B],!T)return!1;var Ot=typeof T=="function";switch($=arguments.length,$){case 1:Ge(T,Ot,this);break;case 2:Ue(T,Ot,this,arguments[1]);break;case 3:be(T,Ot,this,arguments[1],arguments[2]);break;case 4:ht(T,Ot,this,arguments[1],arguments[2],arguments[3]);break;default:for(U=new Array($-1),O=1;O<$;O++)U[O-1]=arguments[O];Ve(T,Ot,this,U)}return!0};function Kt(D,B,C,T){var $,U,O;if(typeof C!="function")throw new TypeError('"listener" argument must be a function');if(U=D._events,U?(U.newListener&&(D.emit("newListener",B,C.listener?C.listener:C),U=D._events),O=U[B]):(U=D._events=new tt,D._eventsCount=0),!O)O=U[B]=C,++D._eventsCount;else if(typeof O=="function"?O=U[B]=T?[C,O]:[O,C]:T?O.unshift(C):O.push(C),!O.warned&&($=ce(D),$&&$>0&&O.length>$)){O.warned=!0;var Ae=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+B+" listeners added. Use emitter.setMaxListeners() to increase limit");Ae.name="MaxListenersExceededWarning",Ae.emitter=D,Ae.type=B,Ae.count=O.length,Rt(Ae)}return D}function Rt(D){typeof console.warn=="function"?console.warn(D):console.log(D)}De.prototype.addListener=function(B,C){return Kt(this,B,C,!1)},De.prototype.on=De.prototype.addListener,De.prototype.prependListener=function(B,C){return Kt(this,B,C,!0)};function Q(D,B,C){var T=!1;function $(){D.removeListener(B,$),T||(T=!0,C.apply(D,arguments))}return $.listener=C,$}De.prototype.once=function(B,C){if(typeof C!="function")throw new TypeError('"listener" argument must be a function');return this.on(B,Q(this,B,C)),this},De.prototype.prependOnceListener=function(B,C){if(typeof C!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(B,Q(this,B,C)),this},De.prototype.removeListener=function(B,C){var T,$,U,O,Ae;if(typeof C!="function")throw new TypeError('"listener" argument must be a function');if($=this._events,!$)return this;if(T=$[B],!T)return this;if(T===C||T.listener&&T.listener===C)--this._eventsCount===0?this._events=new tt:(delete $[B],$.removeListener&&this.emit("removeListener",B,T.listener||C));else if(typeof T!="function"){for(U=-1,O=T.length;O-- >0;)if(T[O]===C||T[O].listener&&T[O].listener===C){Ae=T[O].listener,U=O;break}if(U<0)return this;if(T.length===1){if(T[0]=void 0,--this._eventsCount===0)return this._events=new tt,this;delete $[B]}else st(T,U);$.removeListener&&this.emit("removeListener",B,Ae||C)}return this},De.prototype.off=function(D,B){return this.removeListener(D,B)},De.prototype.removeAllListeners=function(B){var C,T;if(T=this._events,!T)return this;if(!T.removeListener)return arguments.length===0?(this._events=new tt,this._eventsCount=0):T[B]&&(--this._eventsCount===0?this._events=new tt:delete T[B]),this;if(arguments.length===0){for(var $=Object.keys(T),U=0,O;U<$.length;++U)O=$[U],O!=="removeListener"&&this.removeAllListeners(O);return this.removeAllListeners("removeListener"),this._events=new tt,this._eventsCount=0,this}if(C=T[B],typeof C=="function")this.removeListener(B,C);else if(C)do this.removeListener(B,C[C.length-1]);while(C[0]);return this},De.prototype.listeners=function(B){var C,T,$=this._events;return $?(C=$[B],C?typeof C=="function"?T=[C.listener||C]:T=kt(C):T=[]):T=[],T},De.listenerCount=function(D,B){return typeof D.listenerCount=="function"?D.listenerCount(B):je.call(D,B)},De.prototype.listenerCount=je;function je(D){var B=this._events;if(B){var C=B[D];if(typeof C=="function")return 1;if(C)return C.length}return 0}De.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function st(D,B){for(var C=B,T=C+1,$=D.length;T<$;C+=1,T+=1)D[C]=D[T];D.pop()}function Re(D,B){for(var C=new Array(B);B--;)C[B]=D[B];return C}function kt(D){for(var B=new Array(D.length),C=0;C<B.length;++C)B[C]=D[C].listener||D[C];return B}var ot=Se.getLogger("twilsock");function ar(D,B){return["".concat(new Date().toISOString()," Twilsock ").concat(D,":")].concat(Array.from(B))}var mr=function(){function D(B){te.default(this,D),oe.default(this,"prefix",""),this.prefix=B!=null&&B.length>0?" "+B+":":""}return Ze.default(D,[{key:"setLevel",value:function(C){ot.setLevel(C)}},{key:"trace",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.trace.apply(null,ar("T",T))}},{key:"debug",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.debug.apply(null,ar("D",T))}},{key:"info",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.info.apply(null,ar("I",T))}},{key:"warn",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.warn.apply(null,ar("W",T))}},{key:"error",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.error.apply(null,ar("E",T))}}],[{key:"setLevel",value:function(C){ot.setLevel(C)}},{key:"trace",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.trace.apply(null,ar("T",T))}},{key:"debug",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.debug.apply(null,ar("D",T))}},{key:"info",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.info.apply(null,ar("I",T))}},{key:"warn",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.warn.apply(null,ar("W",T))}},{key:"error",value:function(){for(var C=arguments.length,T=new Array(C),$=0;$<C;$++)T[$]=arguments[$];ot.error.apply(null,ar("E",T))}}]),D}(),Xe=new mr(""),Or="0.12.2",jr=function(){function D(B,C,T){te.default(this,D),oe.default(this,"confirmedCapabilities",new Set),this.activeGrant=C,this._token=B;var $=T.region||"us1",U="wss://tsock.".concat($,".twilio.com/v3/wsconnect"),O=T.twilsock||T.Twilsock||{};this.url=O.uri||U,this._continuationToken=T.continuationToken?T.continuationToken:null,this.logLevel=T.logLevel?T.logLevel:"error",this.retryPolicy=T.retryPolicy?T.retryPolicy:{min:1*1e3,max:2*60*1e3,randomness:.2},this.clientMetadata=T.clientMetadata?T.clientMetadata:{},this.clientMetadata.ver=Or,this.initRegistrations=T.initRegistrations?T.initRegistrations:null,this.tweaks=T.tweaks?T.tweaks:null}return Ze.default(D,[{key:"token",get:function(){return this._token}},{key:"continuationToken",get:function(){return this._continuationToken}},{key:"updateToken",value:function(C){this._token=C}},{key:"updateContinuationToken",value:function(C){this._continuationToken=C}}]),D}(),lr=function D(B){te.default(this,D),this.id=B||"TM".concat(N.v4())};function cr(D){var B=Vt();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Vt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var At=function(D){_e.default(C,D);var B=cr(C);function C(T,$,U,O,Ae){var Ce;return te.default(this,C),Ce=B.call(this),oe.default(Z.default(Ce),"method","init"),Ce.token=T,Ce.continuation_token=$,Ce.metadata=U,Ce.registrations=O,Ce.tweaks=Ae,Ce.capabilities=["client_update","offline_storage","telemetry.v1"],Ce}return C}(lr);function M(D){var B=V();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function V(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ie=function(D){_e.default(C,D);var B=M(C);function C(T,$,U,O,Ae,Ce,Je){var nt;return te.default(this,C),nt=B.call(this,T),nt.continuationToken=$,nt.continuationTokenStatus=O,nt.offlineStorage=Ae,nt.initRegistrations=Ce,nt.debugInfo=Je,nt.confirmedCapabilities=U,nt}return C}(lr);function Be(D){var B=lt();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function lt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var yt=function(D){_e.default(C,D);var B=Be(C);function C(T){var $;return te.default(this,C),$=B.call(this),oe.default(Z.default($),"method","update"),$.token=T,$}return C}(lr);function Bt(D){var B=er();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function er(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ee=function(D){_e.default(C,D);var B=Bt(C);function C(T,$,U){var O;return te.default(this,C),O=B.call(this),oe.default(Z.default(O),"method","message"),O.active_grant=T,O.payload_type=$,O.http_request=U,O}return C}(lr);function Ne(D){var B=pe();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function pe(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var $e=function(D){_e.default(C,D);var B=Ne(C);function C(T){var $;return te.default(this,C),$=B.call(this,T),oe.default(Z.default($),"method","reply"),oe.default(Z.default($),"payload_type","application/json"),oe.default(Z.default($),"status",{code:200,status:"OK"}),$}return C}(lr);function ae(D){var B=ge();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function ge(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var we=function(D){_e.default(C,D);var B=ae(C);function C(){var T;return te.default(this,C),T=B.call(this),oe.default(Z.default(T),"method","close"),T}return C}(lr);function K(D){var B=he();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function he(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var G=function D(B,C,T,$,U,O){te.default(this,D),this.start=B,this.end=C,this.title=T,this.details=$,this.id=U,this.type=O},de=function(D){_e.default(C,D);var B=K(C);function C(T){var $;return te.default(this,C),$=B.call(this),oe.default(Z.default($),"method","telemetry.v1"),$.events=T,$}return C}(lr);function X(D){var B=encodeURIComponent(D),C=B.replace(/%([0-9A-F]{2})/g,function(T,$){return String.fromCharCode(+("0x"+$))});return C.length}function Ye(D){var B=encodeURIComponent(D),C=B.replace(/%([0-9A-F]{2})/g,function($,U){return String.fromCharCode(+("0x"+U))}),T=new Uint8Array(C.length);return Array.prototype.forEach.call(C,function($,U){T[U]=$.charCodeAt(0)}),T}function ze(D){var B=Array.prototype.map.call(D,function(T){return String.fromCharCode(T)}).join(""),C=B.replace(/(.)/g,function(T,$){var U=$.charCodeAt(0).toString(16).toUpperCase();return U.length<2&&(U="0"+U),"%"+U});return decodeURIComponent(C)}function ct(D){return JSON.parse(ze(D))}function ut(D){for(var B="",C=0;C<D.length;++C){var T=String.fromCharCode(D[C]);if(B+=T,T==="\r"){C+=2;break}}var $=B.split(" ");return{size:C,protocol:$[0],version:$[1],headerSize:Number($[2])}}var ft=function(){function D(){te.default(this,D)}return Ze.default(D,null,[{key:"parse",value:function(C){var T=2,$=new Uint8Array(C),U=ut($);if(U.protocol!=="TWILSOCK"||U.version!=="V3.0")return Xe.error("unsupported protocol: ".concat(U.protocol," ver ").concat(U.version)),null;var O;try{O=ct($.subarray(U.size,U.size+U.headerSize))}catch(nt){return Xe.error("failed to parse message header",nt,C),null}Xe.debug("message received: ",O.method),Xe.trace("message received: ",O);var Ae;if(O.payload_size>0){var Ce=T+U.size+U.headerSize,Je=O.payload_size;if(!O.hasOwnProperty("payload_type")||O.payload_type.indexOf("application/json")===0)try{Ae=ct($.subarray(Ce,Ce+Je))}catch(nt){return Xe.error("failed to parse message body",nt,C),null}else O.payload_type.indexOf("text/plain")===0&&(Ae=ze($.subarray(Ce,Ce+Je)))}return{method:O.method,header:O,payload:Ae}}},{key:"createPacket",value:function(C){var T=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";C.payload_size=X(T);var $=JSON.stringify(C),U="TWILSOCK V3.0 "+X($);Xe.debug("send request:",U+$+T);var O=Ye(U+`\r
1047
1047
  `+$+`\r
1048
1048
  `+T);return O.buffer}}]),D}();function Et(D){var B=It();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function It(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var _t=function(D){_e.default(C,D);var B=Et(C);function C(T){return te.default(this,C),B.call(this,T)}return C}(ye.default(Error));function St(D){var B=xt();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function xt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Dt=function(D){_e.default(C,D);var B=St(C);function C(T,$){var U;return te.default(this,C),U=B.call(this,T),U.reply=$,U}return C}(_t);function rn(D,B){var C=Object.keys(D);if(Object.getOwnPropertySymbols){var T=Object.getOwnPropertySymbols(D);B&&(T=T.filter(function($){return Object.getOwnPropertyDescriptor(D,$).enumerable})),C.push.apply(C,T)}return C}function yn(D){for(var B=1;B<arguments.length;B++){var C=arguments[B]!=null?arguments[B]:{};B%2?rn(Object(C),!0).forEach(function(T){oe.default(D,T,C[T])}):Object.getOwnPropertyDescriptors?Object.defineProperties(D,Object.getOwnPropertyDescriptors(C)):rn(Object(C)).forEach(function(T){Object.defineProperty(D,T,Object.getOwnPropertyDescriptor(C,T))})}return D}function jt(D){var B=Fn();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Fn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var sa=function(D){_e.default(C,D);var B=jt(C);function C(T){var $;return te.default(this,C),$=B.call(this),oe.default(Z.default($),"newBackoff",null),oe.default(Z.default($),"usedBackoff",null),oe.default(Z.default($),"retrier",null),$.options=T?yn({},T):{},$}return Ze.default(C,[{key:"inProgress",get:function(){return!!this.retrier}},{key:"start",value:function(){if(this.inProgress)throw new Error("Already waiting for next attempt, call finishAttempt(success : boolean) to finish it");this.createRetrier()}},{key:"stop",value:function(){this.cleanRetrier(),this.newBackoff=null,this.usedBackoff=null}},{key:"modifyBackoff",value:function($){this.newBackoff=$}},{key:"attemptFailed",value:function(){if(!this.inProgress)throw new Error("No attempt is in progress");if(this.newBackoff){var $=!this.usedBackoff||this.usedBackoff<this.newBackoff;if($)this.createRetrier();else{var U;(U=this.retrier)===null||U===void 0||U.failed(new Error)}}else{var O;(O=this.retrier)===null||O===void 0||O.failed(new Error)}}},{key:"cancel",value:function(){var $;($=this.retrier)===null||$===void 0||$.cancel()}},{key:"cleanRetrier",value:function(){var $,U;($=this.retrier)===null||$===void 0||$.removeAllListeners(),(U=this.retrier)===null||U===void 0||U.cancel(),this.retrier=null}},{key:"getRetryPolicy",value:function(){var $=yn({},this.options);return this.newBackoff&&($.min=this.newBackoff,$.max=this.options.max&&this.options.max>this.newBackoff?this.options.max:this.newBackoff),$.maxAttemptsCount=this.options.maxAttemptsCount?this.options.maxAttemptsCount+1:void 0,$}},{key:"createRetrier",value:function(){var $=this;this.cleanRetrier();var U=this.getRetryPolicy();this.retrier=new re.Retrier(U),this.retrier.once("attempt",function(){var O,Ae;(O=$.retrier)===null||O===void 0||O.on("attempt",function(){return $.emit("attempt")}),(Ae=$.retrier)===null||Ae===void 0||Ae.failed(new Error("Skipping first attempt"))}),this.retrier.on("failed",function(O){return $.emit("failed",O)}),this.usedBackoff=this.newBackoff,this.newBackoff=null,this.retrier.start()}}]),C}(De);function Ua(D){var B=Jn();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Jn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var oa=3e3;function Qn(D){setTimeout(D,0)}var fi=function(D){_e.default(C,D);var B=Ua(C);function C(T,$,U){var O;te.default(this,C),O=B.call(this),oe.default(Z.default(O),"disconnectingTimer",null),oe.default(Z.default(O),"disconnectedPromiseResolve",null),oe.default(Z.default(O),"terminalStates",["disconnected","rejected"]),oe.default(Z.default(O),"tokenExpiredSasCode",20104),oe.default(Z.default(O),"terminationReason","Connection is not initialized"),O.websocket=T,O.websocket.on("connected",function(){return O.fsm.socketConnected()}),O.websocket.on("disconnected",function(){return O.fsm.socketClosed()}),O.websocket.on("message",function(Ce){return O.onIncomingMessage(Ce)}),O.websocket.on("socketError",function(Ce){return O.emit("connectionError",{terminal:!1,message:"Socket error: ".concat(Ce.message),httpStatusCode:null,errorCode:null})}),O.transport=$,O.config=U,O.retrier=new sa(U.retryPolicy),O.retrier.on("attempt",function(){return O.retry()}),O.retrier.on("failed",function(Ce){Xe.warn("Retrying failed: ".concat(Ce.message)),O.disconnect()}),typeof window<"u"&&typeof window.addEventListener<"u"&&(window.addEventListener("online",function(){Xe.debug("Browser reported connectivity state: online"),O.resetBackoff(),O.fsm.systemOnline()}),window.addEventListener("offline",function(){Xe.debug("Browser reported connectivity state: offline"),O.websocket.close(),O.fsm.socketClosed()}));var Ae=H.factory({init:"disconnected",transitions:[{name:"userConnect",from:["disconnected","rejected"],to:"connecting"},{name:"userConnect",from:["connecting","connected"]},{name:"userDisconnect",from:["connecting","initialising","connected","updating","retrying","rejected","waitSocketClosed","waitOffloadSocketClosed"],to:"disconnecting"},{name:"userRetry",from:["retrying"],to:"connecting"},{name:"socketConnected",from:["connecting"],to:"initialising"},{name:"socketClosed",from:["connecting","initialising","connected","updating","error","waitOffloadSocketClosed"],to:"retrying"},{name:"socketClosed",from:["disconnecting"],to:"disconnected"},{name:"socketClosed",from:["waitSocketClosed"],to:"disconnected"},{name:"socketClosed",from:["rejected"],to:"rejected"},{name:"initSuccess",from:["initialising"],to:"connected"},{name:"initError",from:["initialising"],to:"error"},{name:"tokenRejected",from:["initialising","updating"],to:"rejected"},{name:"protocolError",from:["initialising","connected","updating"],to:"error"},{name:"receiveClose",from:["initialising","connected","updating"],to:"waitSocketClosed"},{name:"receiveOffload",from:["initialising","connected","updating"],to:"waitOffloadSocketClosed"},{name:"unsupportedProtocol",from:["initialising","connected","updating"],to:"unsupported"},{name:"receiveFatalClose",from:["initialising","connected","updating"],to:"unsupported"},{name:"userUpdateToken",from:["disconnected","rejected","connecting","retrying"],to:"connecting"},{name:"userUpdateToken",from:["connected"],to:"updating"},{name:"updateSuccess",from:["updating"],to:"connected"},{name:"updateError",from:["updating"],to:"error"},{name:"userSend",from:["connected"],to:"connected"},{name:"systemOnline",from:["retrying"],to:"connecting"}],methods:{onConnecting:function(){O.setupSocket(),O.emit("connecting")},onEnterInitialising:function(){O.sendInit()},onLeaveInitialising:function(){O.cancelInit()},onEnterUpdating:function(){O.sendUpdate()},onLeaveUpdating:function(){O.cancelUpdate()},onEnterRetrying:function(){O.initRetry(),O.emit("connecting")},onEnterConnected:function(){O.resetBackoff(),O.onConnected()},onUserUpdateToken:function(){O.resetBackoff()},onTokenRejected:function(){O.resetBackoff(),O.closeSocket(!0),O.finalizeSocket()},onUserDisconnect:function(){O.closeSocket(!0)},onEnterDisconnecting:function(){O.startDisconnectTimer()},onLeaveDisconnecting:function(){O.cancelDisconnectTimer()},onEnterWaitSocketClosed:function(){O.startDisconnectTimer()},onLeaveWaitSocketClosed:function(){O.cancelDisconnectTimer()},onEnterWaitOffloadSocketClosed:function(){O.startDisconnectTimer()},onLeaveWaitOffloadSocketClosed:function(){O.cancelDisconnectTimer()},onDisconnected:function(){O.resetBackoff(),O.finalizeSocket()},onReceiveClose:function(){O.onCloseReceived()},onReceiveOffload:function(Je,nt){Xe.debug("onreceiveoffload: ",nt),O.modifyBackoff(nt.body),O.onCloseReceived()},onUnsupported:function(){O.closeSocket(!0),O.finalizeSocket()},onError:function(Je,nt){O.closeSocket(nt),O.finalizeSocket()},onEnterState:function(Je){Je.from!=="none"&&O.changeState(Je)},onInvalidTransition:function(Je,nt,Ot){Xe.warn("FSM: unexpected transition",nt,Ot)}}});return O.fsm=new Ae,O}return Ze.default(C,[{key:"changeState",value:function($){Xe.debug("FSM: ".concat($.transition,": ").concat($.from," --> ").concat($.to)),this.lastEmittedState!==this.state&&(this.lastEmittedState=this.state,this.emit("stateChanged",this.state))}},{key:"resetBackoff",value:function(){Xe.trace("resetBackoff"),this.retrier.stop()}},{key:"modifyBackoff",value:function($){Xe.trace("modifyBackoff",$);var U=$?$.backoff_policy:null;U&&typeof U.reconnect_min_ms=="number"&&this.retrier.modifyBackoff(U.reconnect_min_ms)}},{key:"startDisconnectTimer",value:function(){var $=this;Xe.trace("startDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null),this.disconnectingTimer=setTimeout(function(){Xe.debug("disconnecting is timed out"),$.closeSocket(!0)},oa)}},{key:"cancelDisconnectTimer",value:function(){Xe.trace("cancelDisconnectTimer"),this.disconnectingTimer&&(clearTimeout(this.disconnectingTimer),this.disconnectingTimer=null)}},{key:"isConnected",get:function(){return this.state==="connected"&&this.websocket.isConnected}},{key:"state",get:function(){switch(this.fsm.state){case"connecting":case"initialising":case"retrying":case"error":return"connecting";case"updating":case"connected":return"connected";case"rejected":return"denied";case"disconnecting":case"waitSocketClosed":case"waitOffloadSocketClosed":return"disconnecting";case"disconnected":default:return"disconnected"}}},{key:"initRetry",value:function(){Xe.debug("initRetry"),this.retrier.inProgress?this.retrier.attemptFailed():this.retrier.start()}},{key:"retry",value:function(){this.fsm.state!="connecting"?(Xe.trace("retry"),this.websocket.close(),this.fsm.userRetry()):Xe.trace("can retry as already connecting")}},{key:"onConnected",value:function(){this.emit("connected")}},{key:"finalizeSocket",value:function(){Xe.trace("finalizeSocket"),this.websocket.close(),this.emit("disconnected"),this.disconnectedPromiseResolve&&(this.disconnectedPromiseResolve(),this.disconnectedPromiseResolve=null)}},{key:"setupSocket",value:function(){Xe.trace("setupSocket:",this.config.token),this.emit("beforeConnect"),this.websocket.connect()}},{key:"onIncomingMessage",value:function($){var U=ft.parse($);if(U){var O=U.method,Ae=U.header,Ce=U.payload;if(O!=="reply"&&this.confirmReceiving(Ae),O==="notification")this.emit("message",Ae.message_type,Ce);else if(Ae.method==="reply")this.transport.processReply({id:Ae.id,status:Ae.status,header:Ae,body:Ce});else if(Ae.method==="client_update")Ae.client_update_type==="token_about_to_expire"&&this.emit("tokenAboutToExpire");else if(Ae.method==="close")if(Ae.status.code===308)Xe.debug("Connection has been offloaded"),this.fsm.receiveOffload({status:Ae.status.status,body:Ce});else if(Ae.status.code===406){var Je="Server closed connection because can't parse protocol: ".concat(JSON.stringify(Ae.status));this.emitReplyConnectionError(Je,Ae,!0),Xe.error(Je),this.fsm.receiveFatalClose()}else Ae.status.code===417?(Xe.error("Server closed connection because can't parse client reply: ".concat(JSON.stringify(Ae.status))),this.fsm.receiveFatalClose(Ae.status.status)):Ae.status.code===410?(Xe.warn("Server closed connection: ".concat(JSON.stringify(Ae.status))),this.fsm.receiveClose(Ae.status.status),this.emit("tokenExpired")):Ae.status.code===401?(Xe.error("Server closed connection: ".concat(JSON.stringify(Ae.status))),this.fsm.receiveClose(Ae.status.status)):(Xe.warn("unexpected message: ",Ae.status),this.fsm.receiveOffload({status:Ae.status.status,body:null}))}}},{key:"sendInit",value:function(){var T=Pe.default(q.default.mark(function U(){var O,Ae;return q.default.wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:return Xe.trace("sendInit"),Je.prev=1,this.emit("beforeSendInit"),Je.next=5,this.transport.sendInit();case 5:O=Je.sent,this.config.updateContinuationToken(O.continuationToken),this.config.confirmedCapabilities=O.confirmedCapabilities,this.fsm.initSuccess(O),this.emit("initialized",O),this.emit("tokenUpdated"),Je.next=17;break;case 13:Je.prev=13,Je.t0=Je.catch(1),Je.t0 instanceof Dt?(Ae=!1,Xe.warn("Init rejected by server: ".concat(JSON.stringify(Je.t0.reply.status))),this.emit("sendInitFailed"),Je.t0.reply.status.code===401||Je.t0.reply.status.code===403?(Ae=!0,this.fsm.tokenRejected(Je.t0.reply.status),Je.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):Je.t0.reply.status.code===429?(this.modifyBackoff(Je.t0.reply.body),this.fsm.initError(!0)):Je.t0.reply.status.code===500?this.fsm.initError(!1):this.fsm.initError(!0),this.emitReplyConnectionError(Je.t0.message,Je.t0.reply,Ae)):(this.terminationReason=Je.t0.message,this.emit("connectionError",{terminal:!0,message:"Unknown error during connection initialisation: ".concat(Je.t0.message,`
1049
1049
  `).concat(JSON.stringify(Je.t0,null,2)),httpStatusCode:null,errorCode:null}),this.fsm.initError(!0)),this.emit("tokenUpdated",Je.t0);case 17:case"end":return Je.stop()}},U,this,[[1,13]])}));function $(){return T.apply(this,arguments)}return $}()},{key:"sendUpdate",value:function(){var T=Pe.default(q.default.mark(function U(){var O,Ae,Ce;return q.default.wrap(function(nt){for(;;)switch(nt.prev=nt.next){case 0:return Xe.trace("sendUpdate"),O=new yt(this.config.token),nt.prev=2,nt.next=5,this.transport.sendWithReply(O);case 5:Ae=nt.sent,this.fsm.updateSuccess(Ae.body),this.emit("tokenUpdated"),nt.next=14;break;case 10:nt.prev=10,nt.t0=nt.catch(2),nt.t0 instanceof Dt?(Ce=!1,Xe.warn("Token update rejected by server: ".concat(JSON.stringify(nt.t0.reply.status))),nt.t0.reply.status.code===401||nt.t0.reply.status.code===403?(Ce=!0,this.fsm.tokenRejected(nt.t0.reply.status),nt.t0.reply.status.errorCode===this.tokenExpiredSasCode&&this.emit("tokenExpired")):nt.t0.reply.status.code===429?(this.modifyBackoff(nt.t0.reply.body),this.fsm.updateError(nt.t0.reply.status)):this.fsm.updateError(nt.t0.reply.status),this.emitReplyConnectionError(nt.t0.message,nt.t0.reply,Ce)):(this.emit("error",!1,nt.t0.message,null,null),this.fsm.updateError(nt.t0)),this.emit("tokenUpdated",nt.t0);case 14:case"end":return nt.stop()}},U,this,[[2,10]])}));function $(){return T.apply(this,arguments)}return $}()},{key:"emitReplyConnectionError",value:function($,U,O){var Ae=U.status&&U.status.description?U.status.description:$,Ce=U.status.code,Je=U.status&&U.status.errorCode?U.status.errorCode:null;O&&(this.terminationReason=Ae),this.emit("connectionError",{terminal:O,message:"Connection error: ".concat(Ae),httpStatusCode:Ce,errorCode:Je})}},{key:"cancelInit",value:function(){Xe.trace("cancelInit")}},{key:"cancelUpdate",value:function(){Xe.trace("cancelUpdate")}},{key:"confirmReceiving",value:function($){Xe.trace("confirmReceiving");try{this.transport.send(new $e($.id))}catch(U){Xe.debug("failed to confirm packet receiving",U)}}},{key:"closeSocket",value:function($){var U=this;Xe.trace("closeSocket (graceful: ".concat($,")")),$&&this.transport.isConnected&&this.transport.sendClose(),this.websocket.close(),Qn(function(){return U.fsm.socketClosed()})}},{key:"connect",value:function(){Xe.trace("connect"),this.fsm.userConnect()}},{key:"disconnect",value:function(){var $=this;return Xe.trace("disconnect"),this.fsm.is("disconnected")?Promise.resolve():new Promise(function(U){$.disconnectedPromiseResolve=U,$.fsm.userDisconnect()})}},{key:"updateToken",value:function($){var U=this;return Xe.trace("updateToken:",$),new Promise(function(O,Ae){U.once("tokenUpdated",function(Ce){Ce?Ae(Ce):O()}),U.fsm.userUpdateToken()})}},{key:"isTerminalState",get:function(){return this.terminalStates.indexOf(this.fsm.state)!==-1}},{key:"getTerminationReason",get:function(){return this.terminationReason}},{key:"onCloseReceived",value:function(){this.websocket.close()}}]),C}(De),Fa=function(){function D(){te.default(this,D)}return Ze.default(D,null,[{key:"getMetadata",value:function(C){var T,$,U,O,Ae,Ce,Je,nt,Ot=C&&C.clientMetadata?C.clientMetadata:{},fn=["ver","env","envv","os","osv","osa","type","sdk","sdkv","dev","devv","devt","app","appv"],Pi={env:(T=ke.name)!==null&&T!==void 0?T:"unknown",envv:($=ke.version)!==null&&$!==void 0?$:"unknown",os:(U=(O=ke.os)===null||O===void 0?void 0:O.family)!==null&&U!==void 0?U:"unknown",osv:(Ae=(Ce=ke.os)===null||Ce===void 0?void 0:Ce.version)!==null&&Ae!==void 0?Ae:"unknown",osa:(Je=(nt=ke.os)===null||nt===void 0?void 0:nt.architecture)!==null&&Je!==void 0?Je:"unknown",sdk:"js-default"},Qr={};return fn.filter(function(Mi){return Mi in Ot||Mi in Pi}).forEach(function(Mi){return Qr[Mi]=Mi in Ot?Ot[Mi]:Pi[Mi]}),Qr}}]),D}(),Jr=3e4;function Ai(D){return D>=200&&D<300}function Es(D){switch(ne.default(D)){case"undefined":return"";case"object":return JSON.stringify(D);default:return D}}var Oi=function(){function D(B,C){var T=this;te.default(this,D),this.config=C,this.activeRequests=new Map,this.channel=B,this.channel.on("reply",function($){return T.processReply($)}),this.channel.on("disconnected",function(){T.activeRequests.forEach(function($){clearTimeout($.timeout),$.reject(new _t("disconnected"))}),T.activeRequests.clear()})}return Ze.default(D,[{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"processReply",value:function(C){var T=this.activeRequests.get(C.id);T&&(clearTimeout(T.timeout),this.activeRequests.delete(C.id),Ai(C.status.code)?T.resolve(C):(T.reject(new Dt("Transport failure: "+C.status.status,C)),Xe.trace("message rejected")))}},{key:"storeRequest",value:function(C,T,$){var U={resolve:T,reject:$,timeout:setTimeout(function(){Xe.trace("request",C,"is timed out"),$(new _t("Twilsock: request timeout: "+C))},Jr)};this.activeRequests.set(C,U)}},{key:"shutdown",value:function(){this.activeRequests.forEach(function(C){clearTimeout(C.timeout),C.reject(new _t("Twilsock: request cancelled by user"))}),this.activeRequests.clear()}},{key:"sendInit",value:function(){var B=Pe.default(q.default.mark(function T(){var $,U,O;return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:return Xe.trace("sendInit"),$=Fa.getMetadata(this.config),U=new At(this.config.token,this.config.continuationToken,$,this.config.initRegistrations,this.config.tweaks),Ce.next=5,this.sendWithReply(U);case 5:return O=Ce.sent,Ce.abrupt("return",new ie(O.id,O.header.continuation_token,new Set(O.header.capabilities),O.header.continuation_token_status,O.header.offline_storage,O.header.init_registrations,O.header.debug_info));case 7:case"end":return Ce.stop()}},T,this)}));function C(){return B.apply(this,arguments)}return C}()},{key:"sendClose",value:function(){var C=new we;this.send(C)}},{key:"sendWithReply",value:function(C,T){var $=this;return new Promise(function(U,O){var Ae=$.send(C,T);$.storeRequest(Ae,U,O)})}},{key:"send",value:function(C,T){C.id=C.id||"TM".concat(N.v4());var $=ft.createPacket(C,Es(T));try{return this.channel.send($),C.id}catch(U){throw Xe.debug("failed to send ",C,U),Xe.trace(U.stack),U}}}]),D}();function Is(D){var B=Oo();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Oo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Bn=function(D){_e.default(C,D);var B=Is(C);function C(T){var $;return te.default(this,C),$=B.call(this),oe.default(Z.default($),"socket",null),$.url=T,$.url=T,$.WebSocket=e.WebSocket||e.MozWebSocket||{},$}return Ze.default(C,[{key:"isConnected",get:function(){return!!this.socket&&this.socket.readyState===1}},{key:"connect",value:function(){var $=this;Xe.trace("connecting to socket");var U;try{U=new this.WebSocket(this.url)}catch(O){Xe.debug("Socket error: ".concat(this.url)),this.emit("socketError",O);return}U.binaryType="arraybuffer",U.onopen=function(){Xe.debug("socket opened ".concat($.url)),$.emit("connected")},U.onclose=function(O){Xe.debug("socket closed",O),$.emit("disconnected",O)},U.onerror=function(O){Xe.debug("Socket error:",O),$.emit("socketError",O)},U.onmessage=function(O){$.emit("message",O.data)},this.socket=U}},{key:"send",value:function($){return this.socket&&this.socket.send($)}},{key:"close",value:function(){if(Xe.trace("closing socket"),this.socket){this.socket.onopen=null,this.socket.onclose=null,this.socket.onerror=null,this.socket.onmessage=null;try{this.socket.close()}finally{}}}}]),C}(De);function xs(D){var B=Po();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Po(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Mo=function(D){_e.default(C,D);var B=xs(C);function C(T){var $;return te.default(this,C),$=B.call(this),$.transport=T,$.registrations=new Map,$.registrationsInProgress=new Map,$}return Ze.default(C,[{key:"putNotificationContext",value:function(){var T=Pe.default(q.default.mark(function U(O,Ae){var Ce;return q.default.wrap(function(nt){for(;;)switch(nt.prev=nt.next){case 0:return Ce={method:"put_notification_ctx",notification_ctx_id:O},nt.next=3,this.transport.sendWithReply(Ce,Ae);case 3:case"end":return nt.stop()}},U,this)}));function $(U,O){return T.apply(this,arguments)}return $}()},{key:"deleteNotificationContext",value:function(){var T=Pe.default(q.default.mark(function U(O){var Ae;return q.default.wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:return Ae={method:"delete_notification_ctx",notification_ctx_id:O},Je.next=3,this.transport.sendWithReply(Ae);case 3:case"end":return Je.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()},{key:"updateRegistration",value:function(){var T=Pe.default(q.default.mark(function U(O,Ae){var Ce,Je;return q.default.wrap(function(Ot){for(;;)switch(Ot.prev=Ot.next){case 0:return Xe.debug("update registration for context",O),Ce=this.registrationsInProgress.get(O),Ce||(Ce=new Set,this.registrationsInProgress.set(O,Ce)),Je=N.v4(),Ce.add(Je),Ot.prev=5,Ot.next=8,this.putNotificationContext(O,Ae);case 8:Xe.debug("registration attempt succeeded for context",Ae),Ce.delete(Je),Ce.size===0&&(this.registrationsInProgress.delete(O),this.emit("registered",O)),Ot.next=19;break;case 13:Ot.prev=13,Ot.t0=Ot.catch(5),Xe.warn("registration attempt failed for context",Ae),Xe.debug(Ot.t0),Ce.delete(Je),Ce.size===0&&(this.registrationsInProgress.delete(O),this.emit("registrationFailed",O,Ot.t0));case 19:case"end":return Ot.stop()}},U,this,[[5,13]])}));function $(U,O){return T.apply(this,arguments)}return $}()},{key:"updateRegistrations",value:function(){var T=Pe.default(q.default.mark(function U(){var O=this,Ae;return q.default.wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:return Xe.trace("refreshing ".concat(this.registrations.size," registrations")),Ae=[],this.registrations.forEach(function(nt,Ot){Ae.push(O.updateRegistration(Ot,nt))}),Je.next=5,Promise.all(Ae);case 5:case"end":return Je.stop()}},U,this)}));function $(){return T.apply(this,arguments)}return $}()},{key:"setNotificationsContext",value:function(){var T=Pe.default(q.default.mark(function U(O,Ae){return q.default.wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:if(!(!O||!Ae)){Je.next=2;break}throw new _t("Invalid arguments provided");case 2:return this.registrations.set(O,Ae),Je.next=5,this.updateRegistration(O,Ae);case 5:return Je.abrupt("return",Je.sent);case 6:case"end":return Je.stop()}},U,this)}));function $(U,O){return T.apply(this,arguments)}return $}()},{key:"removeNotificationsContext",value:function(){var T=Pe.default(q.default.mark(function U(O){return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:if(this.registrations.has(O)){Ce.next=2;break}return Ce.abrupt("return");case 2:return Ce.next=4,this.deleteNotificationContext(O);case 4:this.transport.isConnected&&this.registrations.delete(O);case 5:case"end":return Ce.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()}]),C}(De);function cn(D){var B=Rs();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Rs(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Rn=function(D){_e.default(C,D);var B=cn(C);function C(T,$,U){var O;return te.default(this,C),O=B.call(this,$),O.status=T,O.description=$,O.body=U,O}return C}(_t);function Nr(D){var B=No();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function No(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Xn=function(D){_e.default(C,D);var B=Nr(C);function C(T){return te.default(this,C),B.call(this,T)}return C}(_t),An=2e4;function As(D){return D>=200&&D<300}function ee(D){return D&&D.header&&D.header.http_status}function ue(D){var B=D.match(/^(https?\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)(\/[^?#]*)(\?[^#]*|)(#.*|)$/);if(B){var C={protocol:B[1],host:B[2],hostname:B[3],port:B[4],pathname:B[5],search:B[6],hash:B[7],params:{}};if(C.search.length>0){var T=C.search.substring(1);C.params=T.split("&").map(function($){return $.split("=")}).reduce(function($,U){return $.hasOwnProperty(U[0])?Array.isArray($[U[0]])?$[U[0]].push(U[1]):$[U[0]]=[$[U[0]],U[1]]:$[U[0]]=U[1],$},{})}return C}throw new _t("Incorrect URI: "+D)}function R(D,B){var C=ue(B),T={method:D,host:C.host,path:C.pathname};return C.params&&(T.params=C.params),T}function A(D,B,C,T,$){return{to:R(D,B),headers:C,body:T,grant:$}}var I=function(){function D(B,C,T){te.default(this,D),this.config=T,this.transport=B,this.pendingMessages=[],this.twilsock=C}return Ze.default(D,[{key:"saveMessage",value:function(C){var T=this;return new Promise(function($,U){var O={message:C,resolve:$,reject:U,alreadyRejected:!1,timeout:setTimeout(function(){Xe.debug("request is timed out"),U(new _t("request '".concat(C.to.method,"' to '").concat(C.to.host,"' timed out"))),O.alreadyRejected=!0},An)};T.pendingMessages.push(O)})}},{key:"sendPendingMessages",value:function(){for(var C=this,T=function(){var O=C.pendingMessages[0];if(!O.alreadyRejected)try{var Ae=O.message;C.actualSend(Ae).then(function(Ce){return O.resolve(Ce)}).catch(function(Ce){return O.reject(Ce)}),clearTimeout(O.timeout)}catch(Ce){return Xe.debug("Failed to send pending message",Ce),"break"}C.pendingMessages.splice(0,1)};this.pendingMessages.length>0;){var $=T();if($==="break")break}}},{key:"rejectPendingMessages",value:function(){var C=this;this.pendingMessages.forEach(function(T){T.reject(new Xn("Unable to connect: "+C.twilsock.getTerminationReason)),T.alreadyRejected=!0,clearTimeout(T.timeout)}),this.pendingMessages.splice(0,this.pendingMessages.length)}},{key:"actualSend",value:function(){var B=Pe.default(q.default.mark(function T($){var U,O,Ae,Ce,Je,nt,Ot,fn;return q.default.wrap(function(Qr){for(;;)switch(Qr.prev=Qr.next){case 0:return O=$.to,Ae=$.headers,Ce=$.body,Je=(U=$.grant)!==null&&U!==void 0?U:this.config.activeGrant,nt={host:O.host,path:O.path,method:O.method,params:O.params,headers:Ae},Ot=new Ee(Je,Ae["Content-Type"]||"application/json",nt),Xe.trace("Sending upstream message",Ot),Qr.next=9,this.transport.sendWithReply(Ot,Ce);case 9:if(fn=Qr.sent,Xe.trace("Received upstream message response",fn),!(ee(fn)&&!As(fn.header.http_status.code))){Qr.next=13;break}throw new Rn(fn.header.http_status.code,fn.header.http_status.status,fn.body);case 13:return Qr.abrupt("return",{status:fn.header.http_status,headers:fn.header.http_headers,body:fn.body});case 14:case"end":return Qr.stop()}},T,this)}));function C(T){return B.apply(this,arguments)}return C}()},{key:"send",value:function(C,T){var $=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},U=arguments.length>3?arguments[3]:void 0,O=arguments.length>4?arguments[4]:void 0;if(this.twilsock.isTerminalState)return Promise.reject(new Xn("Unable to connect: "+this.twilsock.getTerminationReason));var Ae=A(C,T,$,U,O);return this.twilsock.isConnected?this.actualSend(Ae):this.saveMessage(Ae)}}]),D}(),W=function(){function D(){var B=this;te.default(this,D),this._promise=new Promise(function(C,T){B._resolve=C,B._reject=T})}return Ze.default(D,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(C){this._resolve(C)}},{key:"set",value:function(C){this._resolve(C)}},{key:"fail",value:function(C){this._reject(C)}}]),D}(),j=function(){function D(B){te.default(this,D),this.id=B}return Ze.default(D,null,[{key:"create",value:function(C){if(C instanceof Object&&"storage_id"in C)return new D(C.storage_id);throw new _t('Field "storage_id" is missing')}}]),D}(),Le=function(){function D(){return te.default(this,D),oe.default(this,"initializedFlag","twilio_twilsock_token_storage"),oe.default(this,"tokenStoragePrefix","twilio_continuation_token_"),D._instance||(this.initialize(),D._instance=this),D._instance}return Ze.default(D,[{key:"sessionStorage",value:function(){try{return e.sessionStorage}catch{return null}}},{key:"window",value:function(){try{return e.window}catch{return null}}},{key:"storeToken",value:function(C,T){this.canStore()&&this.sessionStorage.setItem(this.getKeyName(T),C)}},{key:"getStoredToken",value:function(C){return this.canStore()?this.sessionStorage.getItem(this.getKeyName(C)):null}},{key:"initialize",value:function(){var C=this;if(this.canStore()){var T=this.sessionStorage.getItem(this.initializedFlag);T&&this.clear(),this.sessionStorage.setItem(this.initializedFlag,"true");var $=this.sessionStorage.removeItem;this.window.addEventListener("unload",function(){$(C.initializedFlag)})}}},{key:"clear",value:function(){if(this.canStore()){for(var C=[],T=0;T<this.sessionStorage.length;T++){var $=this.sessionStorage.key(T);$&&$.indexOf(this.tokenStoragePrefix)===0&&C.push($)}var U=this.sessionStorage.removeItem;C.forEach(function(O){return U(O)}),U(this.initializedFlag)}}},{key:"getKeyName",value:function(C){return"".concat(this.tokenStoragePrefix).concat(C)}},{key:"canStore",value:function(){return!!(this.sessionStorage&&this.sessionStorage.length&&this.window)}}]),D}();oe.default(Le,"_instance",null);var xe=new Le,He=function(){function D(B,C,T,$,U,O){te.default(this,D),this.title=B,this.details=C,this.start=T,this.type=U,this.id=O,this.end=$}return Ze.default(D,[{key:"toTelemetryEvent",value:function(){var C=new Date,T=this.start,$=this.end?this.end:C;if($<T){var U=$;$=T,T=U}var O=T.getTime()-C.getTime(),Ae=$.getTime()-C.getTime(),Ce=new G(O,Ae,this.title,this.details,this.id,this.type);return Ce}}]),D}();t.TelemetryPoint=void 0,function(D){D[D.Start=0]="Start",D[D.End=1]="End"}(t.TelemetryPoint||(t.TelemetryPoint={})),t.EventSendingLimitation=void 0,function(D){D[D.MinEventsPortion=0]="MinEventsPortion",D[D.AnyEvents=1]="AnyEvents",D[D.AnyEventsIncludingUnfinished=2]="AnyEventsIncludingUnfinished"}(t.EventSendingLimitation||(t.EventSendingLimitation={}));var it=function(){function D(B,C){te.default(this,D),oe.default(this,"minEventsPortionToSend",50),oe.default(this,"maxEventsPortionToSend",100),oe.default(this,"pendingEvents",new Map),oe.default(this,"readyEvents",[]),oe.default(this,"hasInitializationFinished",!1),oe.default(this,"_canSendTelemetry",!1),this.config=B,this.packetInterface=C}return Ze.default(D,[{key:"isTelemetryEnabled",get:function(){return this.config.confirmedCapabilities.has("telemetry.v1")}},{key:"canSendTelemetry",get:function(){return this._canSendTelemetry&&this.isTelemetryEnabled},set:function(C){Xe.debug("TelemetryTracker.canSendTelemetry: ".concat(C," TelemetryTracker.isTelemetryEnabled: ").concat(this.isTelemetryEnabled)),this._canSendTelemetry&&!C&&(this.pendingEvents.clear(),this.readyEvents=[]),this._canSendTelemetry=C,C&&this.sendTelemetry(t.EventSendingLimitation.AnyEvents),C&&!this.hasInitializationFinished&&(this.hasInitializationFinished=!0)}},{key:"addTelemetryEvent",value:function(C){!this.canSendTelemetry&&this.hasInitializationFinished||this.readyEvents.push(C)}},{key:"addPartialEvent",value:function(C,T,$){Xe.debug("Adding ".concat($===t.TelemetryPoint.Start?"starting":"ending"," timepoint for '").concat(T,"' event"));var U=this.pendingEvents.has(T);if($===t.TelemetryPoint.Start)U&&Xe.debug("Overwriting starting point for '".concat(T,"' event")),this.pendingEvents.set(T,C);else{if(!U){Xe.info("Could not find started event for '".concat(T,"' event"));return}this.addTelemetryEvent(this.merge(this.pendingEvents.get(T),C)),this.pendingEvents.delete(T)}}},{key:"getTelemetryToSend",value:function(C){return!this.canSendTelemetry||this.readyEvents.length==0?[]:C==t.EventSendingLimitation.MinEventsPortion&&this.readyEvents.length<this.minEventsPortionToSend?[]:this.getTelemetryPortion(C==t.EventSendingLimitation.AnyEventsIncludingUnfinished)}},{key:"getTelemetryPortion",value:function(C){var T=this,$=Math.min(this.readyEvents.length,this.maxEventsPortionToSend),U=this.readyEvents.splice(0,$);return C&&U.length<this.maxEventsPortionToSend&&this.pendingEvents.forEach(function(O,Ae){if(!(U.length>=T.maxEventsPortionToSend)){var Ce=T.pendingEvents.get(Ae);T.pendingEvents.delete(Ae),U.push(new He("[UNFINISHED] ".concat(Ce.title),Ce.details,Ce.start,null,Ce.type,Ce.id))}}),U}},{key:"merge",value:function(C,T){return new He(T.title?T.title:C.title,T.details?T.details:C.details,C.start,T.end,T.type?T.type:C.type,T.id?T.id:C.id)}},{key:"sendTelemetryIfMinimalPortionCollected",value:function(){this.sendTelemetry(t.EventSendingLimitation.MinEventsPortion)}},{key:"sendTelemetry",value:function(C){var T=this.getTelemetryToSend(C);if(T.length!==0)try{this.packetInterface.send(new de(T.map(function($){return $.toTelemetryEvent()})))}catch($){Xe.debug("Error while sending ".concat(T.length," telemetry events due to ").concat($,"; they will be resubmitted")),this.readyEvents=this.readyEvents.concat(T)}}}]),D}();function $t(D){var B=Ur();return function(){var T=Te.default(D),$;if(B){var U=Te.default(this).constructor;$=Reflect.construct(T,arguments,U)}else $=T.apply(this,arguments);return se.default(this,$)}}function Ur(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var On=function D(){te.default(this,D)};oe.default(On,"TWILSOCK_CONNECT","twilsock.sdk.connect"),oe.default(On,"TWILSOCK_INIT","twilsock.sdk.init"),t.TwilsockClient=function(D){_e.default(C,D);var B=$t(C);function C(T,$,U){var O;te.default(this,C),O=B.call(this),oe.default(Z.default(O),"version",Or),oe.default(Z.default(O),"offlineStorageDeferred",new W),U.continuationToken=U.continuationToken?U.continuationToken:xe.getStoredToken($);var Ae=O.config=new jr(T,$,U);Xe.setLevel(Ae.logLevel);var Ce=new Bn(Ae.url),Je=new Oi(Ce,Ae);return O.channel=new fi(Ce,Je,Ae),O.registrations=new Mo(Je),O.upstream=new I(Je,O.channel,Ae),O.telemetryTracker=new it(Ae,Je),O.channel.on("initialized",function(){return O.telemetryTracker.canSendTelemetry=!0}),Ce.on("disconnected",function(){return O.telemetryTracker.canSendTelemetry=!1}),O.registrations.on("registered",function(nt){return O.emit("registered",nt)}),O.channel.on("message",function(nt,Ot){return setTimeout(function(){return O.emit("message",nt,Ot)},0)}),O.channel.on("stateChanged",function(nt){return setTimeout(function(){return O.emit("stateChanged",nt)},0)}),O.channel.on("connectionError",function(nt){return setTimeout(function(){return O.emit("connectionError",nt)},0)}),O.channel.on("tokenAboutToExpire",function(){return setTimeout(function(){return O.emit("tokenAboutToExpire")},0)}),O.channel.on("tokenExpired",function(){return setTimeout(function(){return O.emit("tokenExpired")},0)}),O.channel.on("connected",function(){return O.registrations.updateRegistrations()}),O.channel.on("connected",function(){return O.upstream.sendPendingMessages()}),O.channel.on("connected",function(){return setTimeout(function(){return O.emit("connected")},0)}),O.channel.on("beforeConnect",function(){return O.telemetryTracker.addPartialEvent(new He("Establish WebSocket connection","",new Date),On.TWILSOCK_CONNECT,t.TelemetryPoint.Start)}),O.channel.on("connected",function(){return O.telemetryTracker.addPartialEvent(new He("Establish WebSocket connection","",new Date,new Date),On.TWILSOCK_CONNECT,t.TelemetryPoint.End)}),O.channel.on("beforeSendInit",function(){return O.telemetryTracker.addPartialEvent(new He("Send Twilsock init","",new Date),On.TWILSOCK_INIT,t.TelemetryPoint.Start)}),O.channel.on("initialized",function(){return O.telemetryTracker.addPartialEvent(new He("Send Twilsock init","Succeeded",new Date,new Date),On.TWILSOCK_INIT,t.TelemetryPoint.End)}),O.channel.on("sendInitFailed",function(){return O.telemetryTracker.addPartialEvent(new He("Send Twilsock init","Failed",new Date,new Date),On.TWILSOCK_INIT,t.TelemetryPoint.End)}),O.channel.on("initialized",function(nt){O.handleStorageId($,nt),xe.storeToken(nt.continuationToken,$),setTimeout(function(){return O.emit("initialized",nt)},0)}),O.channel.on("disconnected",function(){return setTimeout(function(){return O.emit("disconnected")},0)}),O.channel.on("disconnected",function(){return O.upstream.rejectPendingMessages()}),O.channel.on("disconnected",function(){return O.offlineStorageDeferred.fail(new _t("Client disconnected"))}),O.offlineStorageDeferred.promise.catch(function(){}),O}return Ze.default(C,[{key:"emit",value:function($){for(var U,O=arguments.length,Ae=new Array(O>1?O-1:0),Ce=1;Ce<O;Ce++)Ae[Ce-1]=arguments[Ce];return Xe.debug("Emitting ".concat($.toString(),"(").concat(Ae.map(function(Je){return JSON.stringify(Je)}).join(", "),")")),(U=Ie.default(Te.default(C.prototype),"emit",this)).call.apply(U,[this,$].concat(Ae))}},{key:"handleStorageId",value:function($,U){if(!U.offlineStorage)this.offlineStorageDeferred.fail(new _t("No offline storage id"));else if(U.offlineStorage.hasOwnProperty($))try{this.offlineStorageDeferred.set(j.create(U.offlineStorage[$])),Xe.debug("Offline storage for '".concat($,"' product: ").concat(JSON.stringify(U.offlineStorage[$]),"."))}catch(O){this.offlineStorageDeferred.fail(new _t("Failed to parse offline storage for ".concat($," ").concat(JSON.stringify(U.offlineStorage[$]),". ").concat(O,".")))}else this.offlineStorageDeferred.fail(new _t("No offline storage id for '".concat($,"' product: ").concat(JSON.stringify(U.offlineStorage))))}},{key:"storageId",value:function(){return this.offlineStorageDeferred.promise}},{key:"isConnected",get:function(){return this.channel.isConnected}},{key:"state",get:function(){return this.channel.state}},{key:"updateToken",value:function(){var T=Pe.default(q.default.mark(function U(O){return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:if(Xe.trace("updating token '".concat(O,"'")),this.config.token!==O){Ce.next=3;break}return Ce.abrupt("return");case 3:return this.config.updateToken(O),Ce.next=6,this.channel.updateToken(O);case 6:return Ce.abrupt("return",Ce.sent);case 7:case"end":return Ce.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()},{key:"setNotificationsContext",value:function(){var T=Pe.default(q.default.mark(function U(O,Ae){return q.default.wrap(function(Je){for(;;)switch(Je.prev=Je.next){case 0:return Je.next=2,this.registrations.setNotificationsContext(O,Ae);case 2:case"end":return Je.stop()}},U,this)}));function $(U,O){return T.apply(this,arguments)}return $}()},{key:"removeNotificationsContext",value:function(){var T=Pe.default(q.default.mark(function U(O){return q.default.wrap(function(Ce){for(;;)switch(Ce.prev=Ce.next){case 0:return Ce.next=2,this.registrations.removeNotificationsContext(O);case 2:case"end":return Ce.stop()}},U,this)}));function $(U){return T.apply(this,arguments)}return $}()},{key:"connect",value:function(){return this.channel.connect()}},{key:"disconnect",value:function(){var T=Pe.default(q.default.mark(function U(){return q.default.wrap(function(Ae){for(;;)switch(Ae.prev=Ae.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEventsIncludingUnfinished),Ae.next=3,this.channel.disconnect();case 3:return Ae.abrupt("return",Ae.sent);case 4:case"end":return Ae.stop()}},U,this)}));function $(){return T.apply(this,arguments)}return $}()},{key:"get",value:function(){var T=Pe.default(q.default.mark(function U(O,Ae,Ce){return q.default.wrap(function(nt){for(;;)switch(nt.prev=nt.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),nt.next=3,this.upstream.send("GET",O,Ae,void 0,Ce);case 3:return nt.abrupt("return",nt.sent);case 4:case"end":return nt.stop()}},U,this)}));function $(U,O,Ae){return T.apply(this,arguments)}return $}()},{key:"post",value:function(){var T=Pe.default(q.default.mark(function U(O,Ae,Ce,Je){return q.default.wrap(function(Ot){for(;;)switch(Ot.prev=Ot.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Ot.next=3,this.upstream.send("POST",O,Ae,Ce,Je);case 3:return Ot.abrupt("return",Ot.sent);case 4:case"end":return Ot.stop()}},U,this)}));function $(U,O,Ae,Ce){return T.apply(this,arguments)}return $}()},{key:"put",value:function(){var T=Pe.default(q.default.mark(function U(O,Ae,Ce,Je){return q.default.wrap(function(Ot){for(;;)switch(Ot.prev=Ot.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Ot.next=3,this.upstream.send("PUT",O,Ae,Ce,Je);case 3:return Ot.abrupt("return",Ot.sent);case 4:case"end":return Ot.stop()}},U,this)}));function $(U,O,Ae,Ce){return T.apply(this,arguments)}return $}()},{key:"delete",value:function(){var T=Pe.default(q.default.mark(function U(O,Ae,Ce,Je){return q.default.wrap(function(Ot){for(;;)switch(Ot.prev=Ot.next){case 0:return this.telemetryTracker.sendTelemetry(t.EventSendingLimitation.AnyEvents),Ot.next=3,this.upstream.send("DELETE",O,Ae,Ce,Je);case 3:return Ot.abrupt("return",Ot.sent);case 4:case"end":return Ot.stop()}},U,this)}));function $(U,O,Ae,Ce){return T.apply(this,arguments)}return $}()},{key:"addTelemetryEvent",value:function($){this.telemetryTracker.addTelemetryEvent($),this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}},{key:"addPartialTelemetryEvent",value:function($,U,O){this.telemetryTracker.addPartialEvent($,U,O),O===t.TelemetryPoint.End&&this.telemetryTracker.sendTelemetryIfMinimalPortionCollected()}}]),C}(De),t.TwilsockClient=P([m.validateConstructorTypes(m.nonEmptyString,m.nonEmptyString,[m.pureObject,"undefined",m.literal(null)]),Qe("design:paramtypes",[String,String,Object])],t.TwilsockClient);var bn=function(){function D(B){te.default(this,D),this.product=B,this.type="ers",this.notification_protocol_version=0,this.message_types=[]}return Ze.default(D,[{key:"populateInitRegistrations",value:function(C){var T=new Set(this.message_types);for(var $ in C)T.add(C[$]);this.message_types=Array.from(T)}}]),D}();t.InitRegistration=bn,t.TelemetryEventDescription=He,t.TelemetryTracker=it,t.TransportUnavailableError=Xn,t.Twilsock=t.TwilsockClient,t.TwilsockError=_t})(cx);/*
@@ -1146,7 +1146,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1146
1146
  THIS SOFTWARE.
1147
1147
 
1148
1148
  */Object.defineProperty(jn,"__esModule",{value:!0});var uQ=ku,lQ=Qi,cQ=$a,dQ=cs,fQ=Yi,hQ=Ji,pQ=ii,vQ=ds,gQ=Au,mQ=ni,We=mn,op=cx,yQ=ad,bQ=Ou,wQ=Wc,dx=Xi,fx=Qc,_Q=Rh,kQ=nb;function Kn(t){return t&&typeof t=="object"&&"default"in t?t:{default:t}}function db(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach(function(r){if(r!=="default"){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}}),e.default=t,Object.freeze(e)}var et=Kn(uQ),dr=Kn(lQ),yr=Kn(cQ),ra=Kn(dQ),En=Kn(fQ),ks=Kn(hQ),Zr=Kn(pQ),_r=Kn(vQ),fe=Kn(gQ),hx=Kn(mQ),SQ=Kn(yQ),$Q=db(bQ),px=Kn(wQ),TQ=db(fx),od=Kn(_Q),up=db(kQ);function hr(t,e,r,n){var i=arguments.length,a=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,s;if((typeof Reflect>"u"?"undefined":hx.default(Reflect))==="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,n);else for(var o=t.length-1;o>=0;o--)(s=t[o])&&(a=(i<3?s(a):i>3?s(e,r,a):s(e,r))||a);return i>3&&a&&Object.defineProperty(e,r,a),a}function Ke(t,e){if((typeof Reflect>"u"?"undefined":hx.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}var CQ;function Ss(){}Ss.prototype=Object.create(null);function kr(){kr.init.call(this)}kr.EventEmitter=kr,kr.usingDomains=!1,kr.prototype.domain=void 0,kr.prototype._events=void 0,kr.prototype._maxListeners=void 0,kr.defaultMaxListeners=10,kr.init=function(){this.domain=null,kr.usingDomains&&CQ.active,(!this._events||this._events===Object.getPrototypeOf(this)._events)&&(this._events=new Ss,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},kr.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||isNaN(e))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=e,this};function vx(t){return t._maxListeners===void 0?kr.defaultMaxListeners:t._maxListeners}kr.prototype.getMaxListeners=function(){return vx(this)};function EQ(t,e,r){if(e)t.call(r);else for(var n=t.length,i=ud(t,n),a=0;a<n;++a)i[a].call(r)}function IQ(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,a=ud(t,i),s=0;s<i;++s)a[s].call(r,n)}function xQ(t,e,r,n,i){if(e)t.call(r,n,i);else for(var a=t.length,s=ud(t,a),o=0;o<a;++o)s[o].call(r,n,i)}function RQ(t,e,r,n,i,a){if(e)t.call(r,n,i,a);else for(var s=t.length,o=ud(t,s),u=0;u<s;++u)o[u].call(r,n,i,a)}function AQ(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,a=ud(t,i),s=0;s<i;++s)a[s].apply(r,n)}kr.prototype.emit=function(e){var r,n,i,a,s,o,u,l=e==="error";if(o=this._events,o)l=l&&o.error==null;else if(!l)return!1;if(u=this.domain,l){if(r=arguments[1],u)r||(r=new Error('Uncaught, unspecified "error" event')),r.domainEmitter=this,r.domain=u,r.domainThrown=!1,u.emit("error",r);else{if(r instanceof Error)throw r;var c=new Error('Uncaught, unspecified "error" event. ('+r+")");throw c.context=r,c}return!1}if(n=o[e],!n)return!1;var d=typeof n=="function";switch(i=arguments.length,i){case 1:EQ(n,d,this);break;case 2:IQ(n,d,this,arguments[1]);break;case 3:xQ(n,d,this,arguments[1],arguments[2]);break;case 4:RQ(n,d,this,arguments[1],arguments[2],arguments[3]);break;default:for(a=new Array(i-1),s=1;s<i;s++)a[s-1]=arguments[s];AQ(n,d,this,a)}return!0};function gx(t,e,r,n){var i,a,s;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(a=t._events,a?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),s=a[e]):(a=t._events=new Ss,t._eventsCount=0),!s)s=a[e]=r,++t._eventsCount;else if(typeof s=="function"?s=a[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),!s.warned&&(i=vx(t),i&&i>0&&s.length>i)){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=t,o.type=e,o.count=s.length,OQ(o)}return t}function OQ(t){typeof console.warn=="function"?console.warn(t):console.log(t)}kr.prototype.addListener=function(e,r){return gx(this,e,r,!1)},kr.prototype.on=kr.prototype.addListener,kr.prototype.prependListener=function(e,r){return gx(this,e,r,!0)};function mx(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}kr.prototype.once=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.on(e,mx(this,e,r)),this},kr.prototype.prependOnceListener=function(e,r){if(typeof r!="function")throw new TypeError('"listener" argument must be a function');return this.prependListener(e,mx(this,e,r)),this},kr.prototype.removeListener=function(e,r){var n,i,a,s,o;if(typeof r!="function")throw new TypeError('"listener" argument must be a function');if(i=this._events,!i)return this;if(n=i[e],!n)return this;if(n===r||n.listener&&n.listener===r)--this._eventsCount===0?this._events=new Ss:(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(a=-1,s=n.length;s-- >0;)if(n[s]===r||n[s].listener&&n[s].listener===r){o=n[s].listener,a=s;break}if(a<0)return this;if(n.length===1){if(n[0]=void 0,--this._eventsCount===0)return this._events=new Ss,this;delete i[e]}else PQ(n,a);i.removeListener&&this.emit("removeListener",e,o||r)}return this},kr.prototype.off=function(t,e){return this.removeListener(t,e)},kr.prototype.removeAllListeners=function(e){var r,n;if(n=this._events,!n)return this;if(!n.removeListener)return arguments.length===0?(this._events=new Ss,this._eventsCount=0):n[e]&&(--this._eventsCount===0?this._events=new Ss:delete n[e]),this;if(arguments.length===0){for(var i=Object.keys(n),a=0,s;a<i.length;++a)s=i[a],s!=="removeListener"&&this.removeAllListeners(s);return this.removeAllListeners("removeListener"),this._events=new Ss,this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r)do this.removeListener(e,r[r.length-1]);while(r[0]);return this},kr.prototype.listeners=function(e){var r,n,i=this._events;return i?(r=i[e],r?typeof r=="function"?n=[r.listener||r]:n=MQ(r):n=[]):n=[],n},kr.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):yx.call(t,e)},kr.prototype.listenerCount=yx;function yx(t){var e=this._events;if(e){var r=e[t];if(typeof r=="function")return 1;if(r)return r.length}return 0}kr.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};function PQ(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}function ud(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}function MQ(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}var Zu=function(){function t(e){dr.default(this,t),this.base=e,this.args=new Array,this.paths=new Array}return yr.default(t,[{key:"pathSegment",value:function(r){return this.paths.push(encodeURIComponent(r)),this}},{key:"queryParam",value:function(r,n){return typeof n<"u"&&this.args.push(encodeURIComponent(r)+"="+encodeURIComponent(n)),this}},{key:"build",value:function(){var r=this.base;return this.paths.length&&(r+="/"+this.paths.join("/")),this.args.length&&(r+="?"+this.args.join("&")),r}}]),t}();function bx(t){var e=NQ();return function(){var n=Zr.default(t),i;if(e){var a=Zr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ks.default(this,i)}}function NQ(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Un=function(t){En.default(r,t);var e=bx(r);function r(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return dr.default(this,r),i=e.call(this),i.name=i.constructor.name,i.message="".concat(n," (status: ").concat(a,", code: ").concat(s,")"),i.status=a,i.code=s,i}return r}(SQ.default(Error)),LQ=function(t){En.default(r,t);var e=bx(r);function r(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,o=arguments.length>3?arguments[3]:void 0;return dr.default(this,r),i=e.call(this,n,a,s),i.body=o,i}return r}(Un);function Ii(t){return JSON.parse(JSON.stringify(t))}function wx(t){var e=t===void 0||fb(t);if(!e)throw new Un("Invalid pageSize parameter. Expected a positive integer, was '".concat(t,"'."),400,20007)}function DQ(t){return!isNaN(parseInt(t))&&isFinite(t)}function fb(t){return DQ(t)&&t>0}var Gu=$Q.getLogger("twilio-sync");function ld(t,e){return["".concat(new Date().toISOString()," Sync ").concat(t,":")].concat(Array.from(e))}var vr={setLevel:function(e){Gu.setLevel(e)},trace:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];Gu.trace.apply(null,ld("T",r))},debug:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];Gu.debug.apply(null,ld("D",r))},info:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];Gu.info.apply(null,ld("I",r))},warn:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];Gu.warn.apply(null,ld("W",r))},error:function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];Gu.error.apply(null,ld("E",r))}},jQ="/v4/Subscriptions",UQ="/v3/Maps",FQ="/v3/Lists",BQ="/v3/Documents",zQ="/v3/Streams",HQ="/v3/Insights";function qQ(t,e,r){return t&&typeof t[e]<"u"?t[e]:r}var VQ=function(){function t(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};dr.default(this,t);var r=e.region||"us1",n="https://cds.".concat(r,".twilio.com"),i=e.cdsUri||n;this.settings={subscriptionsUri:i+jQ,documentsUri:i+BQ,listsUri:i+FQ,mapsUri:i+UQ,streamsUri:i+zQ,insightsUri:i+HQ,sessionStorageEnabled:qQ(e.Sync,"enableSessionStorage",!0),productId:e.productId}}return yr.default(t,[{key:"subscriptionsUri",get:function(){return this.settings.subscriptionsUri}},{key:"documentsUri",get:function(){return this.settings.documentsUri}},{key:"listsUri",get:function(){return this.settings.listsUri}},{key:"mapsUri",get:function(){return this.settings.mapsUri}},{key:"streamsUri",get:function(){return this.settings.streamsUri}},{key:"insightsUri",get:function(){return this.settings.insightsUri}},{key:"backoffConfig",get:function(){return this.settings.backoffConfig||{}}},{key:"sessionStorageEnabled",get:function(){return this.settings.sessionStorageEnabled}},{key:"productId",get:function(){return this.settings.productId}}]),t}();function cd(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=WQ(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1149
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function WQ(t,e){if(t){if(typeof t=="string")return _x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _x(t,e)}}function _x(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var ZQ=function(){function t(e){dr.default(this,t),this.localObject=e,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return yr.default(t,[{key:"sid",get:function(){return this.localObject.sid}},{key:"type",get:function(){return this.localObject.type}},{key:"lastEventId",get:function(){return this.localObject.lastEventId}},{key:"indexName",get:function(){return this.localObject.indexName}},{key:"queryString",get:function(){return this.localObject.queryString}},{key:"isEstablished",get:function(){return this.established}},{key:"update",value:function(r,n){this.localObject._update(r,n)}},{key:"updatePending",value:function(r,n){this.pendingAction=r,this.pendingCorrelationId=n}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(r){this.rejectedWithError=r.error,this.updatePending(null,null),this.localObject.reportFailure(new Un("Failed to subscribe on service events: ".concat(r.error.message),r.error.status,r.error.code))}},{key:"complete",value:function(r){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(r)}},{key:"setSubscriptionState",value:function(r){this.localObject._setSubscriptionState(r)}}]),t}(),GQ=function(){function t(e){var r=this;dr.default(this,t),_r.default(this,"isConnected",!1),_r.default(this,"maxBatchSize",100),_r.default(this,"subscriptionTtlTimer",null),_r.default(this,"pendingPokeReason",null),this.services=e,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;var n={randomisationFactor:.2,initialDelay:100,maxDelay:2*60*1e3};this.backoff=dx.Backoff.exponential(Object.assign(n,this.services.config.backoffConfig)),this.backoff.on("ready",function(){var i=r.getSubscriptionUpdateBatch(),a=i.action,s=i.subscriptions;a?r.applyNewSubscriptionUpdateBatch(a,s):(r.backoff.reset(),vr.debug("All subscriptions resolved."))})}return yr.default(t,[{key:"getSubscriptionUpdateBatch",value:function(){function r(a,s,o,u){var l=[],c=cd(a),d;try{for(c.s();!(d=c.n()).done;){var f=px.default(d.value,2),m=f[0],k=f[1],L=s.get(m);if(!L&&o!==k.pendingAction&&!k.rejectedWithError&&(l.push(k),u&&l.length>=u))break}}catch(N){c.e(N)}finally{c.f()}return l}var n=r(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(n.length>0)return{action:"establish",subscriptions:n};var i=r(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return i.length>0?{action:"cancel",subscriptions:i}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:function(){var e=et.default(fe.default.mark(function n(i,a){var s=this,o,u,l,c,d,f,m,k,L,N,z,re,Me,Oe,Be,Pe;return fe.default.wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:if(this.isConnected){Z.next=4;break}return vr.debug("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),Z.abrupt("return");case 4:a=this.processLocalActions(i,a),o=new Date().getTime(),u=cd(a);try{for(u.s();!(l=u.n()).done;)c=l.value,this.recordActionAttemptOn(c,i,o)}catch(Ie){u.e(Ie)}finally{u.f()}return d=this.pendingPokeReason,this.pendingPokeReason=null,Z.prev=10,Z.next=13,this.request(i,o,d,a);case 13:f=Z.sent,m=f.body.max_batch_size,!isNaN(parseInt(m))&&isFinite(m)&&m>0&&(this.maxBatchSize=m),this.subscriptionTtlTimer||(k=f.body.ttl_in_s,L=!isNaN(parseFloat(k))&&isFinite(k),N=L&&k>0,N&&(this.subscriptionTtlTimer=setTimeout(function(){return s.onSubscriptionTtlElapsed()},k*1e3))),i==="establish"&&(z=f.body.estimated_delivery_in_ms,re=!isNaN(parseFloat(z))&&isFinite(z),Me=re&&z>0,Me?setTimeout(function(){return s.verifyPokeDelivery(o,z,a)},z):vr.error("Invalid timeout: ".concat(z)),a.filter(function(Ie){return Ie.pendingCorrelationId===o}).forEach(function(Ie){return Ie.setSubscriptionState("response_in_flight")})),this.backoff.reset(),Z.next=26;break;case 21:Z.prev=21,Z.t0=Z.catch(10),Oe=cd(a);try{for(Oe.s();!(Be=Oe.n()).done;)Pe=Be.value,this.recordActionFailureOn(Pe,i)}catch(Ie){Oe.e(Ie)}finally{Oe.f()}Z.t0 instanceof op.TransportUnavailableError?(vr.debug("Twilsock connection (required for subscription) not ready (c:".concat(o,"); waiting…")),this.backoff.reset()):(vr.debug("Failed an attempt to ".concat(i," subscriptions (c:").concat(o,"); retrying"),Z.t0),this.persist());case 26:case"end":return Z.stop()}},n,this,[[10,21]])}));function r(n,i){return e.apply(this,arguments)}return r}()},{key:"verifyPokeDelivery",value:function(r,n,i){var a=this,s=this.latestPokeResponseArrivalTimestampByCorrelationId.get(r),o=s?new Date().getTime()-s:n;if(o>=n)i.filter(function(l){return l.pendingCorrelationId===r}).forEach(function(l){l.updatePending(null,null),l.retryCount++,a.persisted.delete(l.sid)}),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(r);else{var u=n-o;setTimeout(function(){return a.verifyPokeDelivery(r,n,i)},u)}}},{key:"processLocalActions",value:function(r,n){return r==="cancel"?n.filter(function(i){return!i.rejectedWithError}):n}},{key:"recordActionAttemptOn",value:function(r,n,i){if(r.setSubscriptionState("request_in_flight"),n==="establish")this.persisted.set(r.sid,r),r.updatePending(n,i);else{var a=this.persisted.get(r.sid);a&&a.updatePending(n,i)}}},{key:"recordActionFailureOn",value:function(r,n){r.setSubscriptionState("none"),r.updatePending(null,null),n==="establish"&&this.persisted.delete(r.sid)}},{key:"request",value:function(r,n,i,a){var s=a.map(function(l){return{object_sid:l.sid,object_type:l.type,last_event_id:r==="establish"?l.lastEventId:void 0,index_name:r==="establish"?l.indexName:void 0,query_string:r==="establish"?l.queryString:void 0}}),o=a.filter(function(l){return l.retryCount>0}).length;vr.debug("Attempting '".concat(r,"' request (c:").concat(n,"):"),s);var u={event_protocol_version:4,action:r,correlation_id:n,retried_requests:o,ttl_in_s:-1,requests:s};return i==="ttl"&&(u.reason=i),this.services.network.post(this.services.config.subscriptionsUri,u)}},{key:"add",value:function(r,n){vr.debug("Establishing intent to subscribe to ".concat(r));var i=this.subscriptions.get(r);i&&n&&i.lastEventId===n.lastEventId||(this.persisted.delete(r),this.subscriptions.set(r,new ZQ(n)),this.persist())}},{key:"remove",value:function(r){vr.debug("Establishing intent to unsubscribe from ".concat(r));var n=this.subscriptions.delete(r);n&&this.persist()}},{key:"acceptMessage",value:function(r,n){vr.trace("Subscriptions received",r);var i=r.event_type,a=typeof r.events<"u"?r.events:[r.event],s=r.correlation_id;s&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(s,new Date().getTime());var o=cd(a),u;try{for(o.s();!(u=o.n()).done;){var l=u.value,c=void 0;switch(r.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(l,s);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(l,s);break;case"subscription_failed":this.applySubscriptionFailedMessage(l,s);break;case(c=i.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:{var d=void 0;switch(c[0]){case"map_":d=l.map_sid;break;case"list_":d=l.list_sid;break;case"document_":d=l.document_sid;break;case"stream_":d=l.stream_sid;break;case"live_query_":d=l.query_id,n=!1,r.strictly_ordered===!0&&(n=!0);break;default:d=void 0}this.applyEventToSubscribedEntity(d,l,i,n);break}default:vr.debug("Dropping unknown message type ".concat(i));break}}}catch(f){o.e(f)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(r,n){var i=r.object_sid,a=this.persisted.get(r.object_sid);a&&a.pendingCorrelationId===n?r.replay_status==="interrupted"?(vr.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") interrupted; continuing eagerly.")),a.updatePending(null,null),this.persisted.delete(a.sid),this.backoff.reset()):r.replay_status==="completed"&&(vr.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") completed. Subscription is ready.")),a.complete(r.last_event_id),this.persisted.set(r.object_sid,a),a.setSubscriptionState("established"),this.backoff.reset()):vr.debug("Late message for ".concat(r.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(r,n){var i=this.persisted.get(r.object_sid);i&&i.pendingCorrelationId===n?(i.updatePending(null,null),i.setSubscriptionState("none"),this.persisted.delete(r.object_sid)):vr.debug("Late message for ".concat(r.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(r,n){var i=r.object_sid,a=this.subscriptions.get(i),s=this.persisted.get(i);a&&s?s.pendingCorrelationId===n&&(vr.error("Failed to subscribe on ".concat(s.sid),r.error),s.markAsFailed(r),s.setSubscriptionState("none")):!a&&s&&(this.persisted.delete(i),s.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(r,n,i,a){var s=this;if(r){a=a||function(){var u=s.persisted.get(r);return u&&u.isEstablished}();var o=this.subscriptions.get(r);o?(n.type=i,o.update(n,a)):vr.debug("Message dropped for SID '".concat(r,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(r){this.isConnected=r,r&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(r){vr.debug("Triggering event replay for all subscriptions, reason=".concat(r)),this.pendingPokeReason=r,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var n=[],i=cd(this.persisted.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.reset(),s.rejectedWithError&&n.push(s)}}catch(c){i.e(c)}finally{i.f()}this.persisted.clear();for(var o=0,u=n;o<u.length;o++){var l=u[o];this.persisted.set(l.sid,l)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),t}(),KQ=4e3,YQ=6e4,JQ=9e4,QQ=.2;function kx(t){if(t.body&&t.body.message)return t.body.message;switch(t.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function Sx(t){return t.body?t.body.code:0}function dd(t){return t.status===409?new LQ(kx(t),t.status,Sx(t),t.body):t.status?new Un(kx(t),t.status,Sx(t)):t instanceof op.TransportUnavailableError?t:new Un(t.message,0,0)}var XQ=function(){function t(e,r,n){dr.default(this,t),this.clientInfo=e,this.config=r,this.transport=n}return yr.default(t,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+TQ.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:KQ,max:YQ,maxAttemptsTime:JQ,randomness:QQ},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(r){var n=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return new Promise(function(a,s){var o=[502,503,504];i&&o.push(429);var u=new dx.Retrier(n.backoffConfig());u.on("attempt",function(){r().then(function(l){return u.succeeded(l)}).catch(function(l){if(o.includes(l.status)){var c=parseInt(l.headers?l.headers["Retry-After"]:null);u.failed(dd(l),isNaN(c)?null:c*1e3)}else l.message==="Twilsock disconnected"?u.failed(dd(l)):(u.removeAllListeners(),u.cancel(),s(dd(l)))})}),u.on("succeeded",function(l){a(l)}),u.on("cancelled",function(l){return s(dd(l))}),u.on("failed",function(l){return s(dd(l))}),u.start()})}},{key:"get",value:function(r){var n=this,i=this.createHeaders();return vr.debug("GET",r,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.get(r,i,n.config.productId)},!0)}},{key:"post",value:function(r,n,i){var a=this,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,o=this.createHeaders();return typeof i<"u"&&i!==null&&(o["If-Match"]=i),vr.debug("POST",r,"ID:",o["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.post(r,o,n,a.config.productId)},s)}},{key:"put",value:function(r,n,i){var a=this,s=this.createHeaders();return typeof i<"u"&&i!==null&&(s["If-Match"]=i),vr.debug("PUT",r,"ID:",s["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.put(r,s,n,a.config.productId)},!1)}},{key:"delete",value:function(r){var n=this,i=this.createHeaders();return vr.debug("DELETE",r,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.delete(r,i,n.config.productId)},!1)}}]),t}(),eX=function(){function t(e,r){dr.default(this,t),this.config=e,this.storageId=null;try{this.storage=r||sessionStorage}catch{}}return yr.default(t,[{key:"storageKey",value:function(r,n){return"".concat(this.storageId,"::").concat(r,"::").concat(n)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(r){this.storageId=r}},{key:"store",value:function(r,n,i){return this.isReady?this._store(this.storageKey(r,n),i):null}},{key:"read",value:function(r,n){return this.isReady?this._read(this.storageKey(r,n)):null}},{key:"remove",value:function(r,n,i){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(r,n)),i&&this.storage.removeItem(this.storageKey(r,i))}catch{}}},{key:"update",value:function(r,n,i,a){if(!this.isReady)return null;this._apply(this.storageKey(r,n),a),i&&this._apply(this.storageKey(r,i),a)}},{key:"_store",value:function(r,n){try{this.storage.setItem(r,JSON.stringify(n))}catch{}}},{key:"_read",value:function(r){try{var n=this.storage.getItem(r);if(n)return JSON.parse(n)}catch{}return null}},{key:"_apply",value:function(r,n){var i=this._read(r);if(!i)return!1;this._store(r,Object.assign(i,n))}}]),t}();function tX(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=rX(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1149
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function WQ(t,e){if(t){if(typeof t=="string")return _x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _x(t,e)}}function _x(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var ZQ=function(){function t(e){dr.default(this,t),this.localObject=e,this.pendingCorrelationId=null,this.pendingAction=null,this.established=!1,this.retryCount=0}return yr.default(t,[{key:"sid",get:function(){return this.localObject.sid}},{key:"type",get:function(){return this.localObject.type}},{key:"lastEventId",get:function(){return this.localObject.lastEventId}},{key:"indexName",get:function(){return this.localObject.indexName}},{key:"queryString",get:function(){return this.localObject.queryString}},{key:"isEstablished",get:function(){return this.established}},{key:"update",value:function(r,n){this.localObject._update(r,n)}},{key:"updatePending",value:function(r,n){this.pendingAction=r,this.pendingCorrelationId=n}},{key:"reset",value:function(){this.updatePending(null,null),this.retryCount=0,this.established=!1,this.setSubscriptionState("none")}},{key:"markAsFailed",value:function(r){this.rejectedWithError=r.error,this.updatePending(null,null),this.localObject.reportFailure(new Un("Failed to subscribe on service events: ".concat(r.error.message),r.error.status,r.error.code))}},{key:"complete",value:function(r){this.updatePending(null,null),this.established=!0,this.localObject._advanceLastEventId(r)}},{key:"setSubscriptionState",value:function(r){this.localObject._setSubscriptionState(r)}}]),t}(),GQ=function(){function t(e){var r=this;dr.default(this,t),_r.default(this,"isConnected",!1),_r.default(this,"maxBatchSize",100),_r.default(this,"subscriptionTtlTimer",null),_r.default(this,"pendingPokeReason",null),this.services=e,this.subscriptions=new Map,this.persisted=new Map,this.latestPokeResponseArrivalTimestampByCorrelationId=new Map;var n={randomisationFactor:.2,initialDelay:100,maxDelay:2*60*1e3};this.backoff=dx.Backoff.exponential(Object.assign(n,this.services.config.backoffConfig)),this.backoff.on("ready",function(){var i=r.getSubscriptionUpdateBatch(),a=i.action,s=i.subscriptions;a?r.applyNewSubscriptionUpdateBatch(a,s):(r.backoff.reset(),vr.debug("All subscriptions resolved."))})}return yr.default(t,[{key:"getSubscriptionUpdateBatch",value:function(){function r(a,s,o,u){var l=[],c=cd(a),d;try{for(c.s();!(d=c.n()).done;){var f=px.default(d.value,2),m=f[0],k=f[1],L=s.get(m);if(!L&&o!==k.pendingAction&&!k.rejectedWithError&&(l.push(k),u&&l.length>=u))break}}catch(N){c.e(N)}finally{c.f()}return l}var n=r(this.subscriptions,this.persisted,"establish",this.maxBatchSize);if(n.length>0)return{action:"establish",subscriptions:n};var i=r(this.persisted,this.subscriptions,"cancel",this.maxBatchSize);return i.length>0?{action:"cancel",subscriptions:i}:{action:null,subscriptions:null}}},{key:"persist",value:function(){this.backoff.backoff()}},{key:"applyNewSubscriptionUpdateBatch",value:function(){var e=et.default(fe.default.mark(function n(i,a){var s=this,o,u,l,c,d,f,m,k,L,N,z,re,Me,Oe,Fe,Pe;return fe.default.wrap(function(Z){for(;;)switch(Z.prev=Z.next){case 0:if(this.isConnected){Z.next=4;break}return vr.debug("Twilsock connection (required for subscription) not ready; waiting…"),this.backoff.reset(),Z.abrupt("return");case 4:a=this.processLocalActions(i,a),o=new Date().getTime(),u=cd(a);try{for(u.s();!(l=u.n()).done;)c=l.value,this.recordActionAttemptOn(c,i,o)}catch(Ie){u.e(Ie)}finally{u.f()}return d=this.pendingPokeReason,this.pendingPokeReason=null,Z.prev=10,Z.next=13,this.request(i,o,d,a);case 13:f=Z.sent,m=f.body.max_batch_size,!isNaN(parseInt(m))&&isFinite(m)&&m>0&&(this.maxBatchSize=m),this.subscriptionTtlTimer||(k=f.body.ttl_in_s,L=!isNaN(parseFloat(k))&&isFinite(k),N=L&&k>0,N&&(this.subscriptionTtlTimer=setTimeout(function(){return s.onSubscriptionTtlElapsed()},k*1e3))),i==="establish"&&(z=f.body.estimated_delivery_in_ms,re=!isNaN(parseFloat(z))&&isFinite(z),Me=re&&z>0,Me?setTimeout(function(){return s.verifyPokeDelivery(o,z,a)},z):vr.error("Invalid timeout: ".concat(z)),a.filter(function(Ie){return Ie.pendingCorrelationId===o}).forEach(function(Ie){return Ie.setSubscriptionState("response_in_flight")})),this.backoff.reset(),Z.next=26;break;case 21:Z.prev=21,Z.t0=Z.catch(10),Oe=cd(a);try{for(Oe.s();!(Fe=Oe.n()).done;)Pe=Fe.value,this.recordActionFailureOn(Pe,i)}catch(Ie){Oe.e(Ie)}finally{Oe.f()}Z.t0 instanceof op.TransportUnavailableError?(vr.debug("Twilsock connection (required for subscription) not ready (c:".concat(o,"); waiting…")),this.backoff.reset()):(vr.debug("Failed an attempt to ".concat(i," subscriptions (c:").concat(o,"); retrying"),Z.t0),this.persist());case 26:case"end":return Z.stop()}},n,this,[[10,21]])}));function r(n,i){return e.apply(this,arguments)}return r}()},{key:"verifyPokeDelivery",value:function(r,n,i){var a=this,s=this.latestPokeResponseArrivalTimestampByCorrelationId.get(r),o=s?new Date().getTime()-s:n;if(o>=n)i.filter(function(l){return l.pendingCorrelationId===r}).forEach(function(l){l.updatePending(null,null),l.retryCount++,a.persisted.delete(l.sid)}),this.persist(),this.latestPokeResponseArrivalTimestampByCorrelationId.delete(r);else{var u=n-o;setTimeout(function(){return a.verifyPokeDelivery(r,n,i)},u)}}},{key:"processLocalActions",value:function(r,n){return r==="cancel"?n.filter(function(i){return!i.rejectedWithError}):n}},{key:"recordActionAttemptOn",value:function(r,n,i){if(r.setSubscriptionState("request_in_flight"),n==="establish")this.persisted.set(r.sid,r),r.updatePending(n,i);else{var a=this.persisted.get(r.sid);a&&a.updatePending(n,i)}}},{key:"recordActionFailureOn",value:function(r,n){r.setSubscriptionState("none"),r.updatePending(null,null),n==="establish"&&this.persisted.delete(r.sid)}},{key:"request",value:function(r,n,i,a){var s=a.map(function(l){return{object_sid:l.sid,object_type:l.type,last_event_id:r==="establish"?l.lastEventId:void 0,index_name:r==="establish"?l.indexName:void 0,query_string:r==="establish"?l.queryString:void 0}}),o=a.filter(function(l){return l.retryCount>0}).length;vr.debug("Attempting '".concat(r,"' request (c:").concat(n,"):"),s);var u={event_protocol_version:4,action:r,correlation_id:n,retried_requests:o,ttl_in_s:-1,requests:s};return i==="ttl"&&(u.reason=i),this.services.network.post(this.services.config.subscriptionsUri,u)}},{key:"add",value:function(r,n){vr.debug("Establishing intent to subscribe to ".concat(r));var i=this.subscriptions.get(r);i&&n&&i.lastEventId===n.lastEventId||(this.persisted.delete(r),this.subscriptions.set(r,new ZQ(n)),this.persist())}},{key:"remove",value:function(r){vr.debug("Establishing intent to unsubscribe from ".concat(r));var n=this.subscriptions.delete(r);n&&this.persist()}},{key:"acceptMessage",value:function(r,n){vr.trace("Subscriptions received",r);var i=r.event_type,a=typeof r.events<"u"?r.events:[r.event],s=r.correlation_id;s&&this.latestPokeResponseArrivalTimestampByCorrelationId.set(s,new Date().getTime());var o=cd(a),u;try{for(o.s();!(u=o.n()).done;){var l=u.value,c=void 0;switch(r.event_type){case"subscription_established":this.applySubscriptionEstablishedMessage(l,s);break;case"subscription_canceled":this.applySubscriptionCancelledMessage(l,s);break;case"subscription_failed":this.applySubscriptionFailedMessage(l,s);break;case(c=i.match(/^(?:map|list|document|stream|live_query)_/)||{}).input:{var d=void 0;switch(c[0]){case"map_":d=l.map_sid;break;case"list_":d=l.list_sid;break;case"document_":d=l.document_sid;break;case"stream_":d=l.stream_sid;break;case"live_query_":d=l.query_id,n=!1,r.strictly_ordered===!0&&(n=!0);break;default:d=void 0}this.applyEventToSubscribedEntity(d,l,i,n);break}default:vr.debug("Dropping unknown message type ".concat(i));break}}}catch(f){o.e(f)}finally{o.f()}}},{key:"applySubscriptionEstablishedMessage",value:function(r,n){var i=r.object_sid,a=this.persisted.get(r.object_sid);a&&a.pendingCorrelationId===n?r.replay_status==="interrupted"?(vr.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") interrupted; continuing eagerly.")),a.updatePending(null,null),this.persisted.delete(a.sid),this.backoff.reset()):r.replay_status==="completed"&&(vr.debug("Event Replay for subscription to ".concat(i," (c:").concat(n,") completed. Subscription is ready.")),a.complete(r.last_event_id),this.persisted.set(r.object_sid,a),a.setSubscriptionState("established"),this.backoff.reset()):vr.debug("Late message for ".concat(r.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionCancelledMessage",value:function(r,n){var i=this.persisted.get(r.object_sid);i&&i.pendingCorrelationId===n?(i.updatePending(null,null),i.setSubscriptionState("none"),this.persisted.delete(r.object_sid)):vr.debug("Late message for ".concat(r.object_sid," (c:").concat(n,") dropped.")),this.persist()}},{key:"applySubscriptionFailedMessage",value:function(r,n){var i=r.object_sid,a=this.subscriptions.get(i),s=this.persisted.get(i);a&&s?s.pendingCorrelationId===n&&(vr.error("Failed to subscribe on ".concat(s.sid),r.error),s.markAsFailed(r),s.setSubscriptionState("none")):!a&&s&&(this.persisted.delete(i),s.setSubscriptionState("none")),this.persist()}},{key:"applyEventToSubscribedEntity",value:function(r,n,i,a){var s=this;if(r){a=a||function(){var u=s.persisted.get(r);return u&&u.isEstablished}();var o=this.subscriptions.get(r);o?(n.type=i,o.update(n,a)):vr.debug("Message dropped for SID '".concat(r,"', for which there is no subscription."))}}},{key:"onConnectionStateChanged",value:function(r){this.isConnected=r,r&&this.poke("reconnect")}},{key:"onSubscriptionTtlElapsed",value:function(){this.isConnected&&this.poke("ttl")}},{key:"poke",value:function(r){vr.debug("Triggering event replay for all subscriptions, reason=".concat(r)),this.pendingPokeReason=r,this.subscriptionTtlTimer&&(clearTimeout(this.subscriptionTtlTimer),this.subscriptionTtlTimer=null);var n=[],i=cd(this.persisted.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.reset(),s.rejectedWithError&&n.push(s)}}catch(c){i.e(c)}finally{i.f()}this.persisted.clear();for(var o=0,u=n;o<u.length;o++){var l=u[o];this.persisted.set(l.sid,l)}this.persist()}},{key:"shutdown",value:function(){this.backoff.reset(),this.subscriptions.clear()}}]),t}(),KQ=4e3,YQ=6e4,JQ=9e4,QQ=.2;function kx(t){if(t.body&&t.body.message)return t.body.message;switch(t.status){case 429:return"Throttled by server";case 404:return"Not found from server";default:return"Error from server"}}function Sx(t){return t.body?t.body.code:0}function dd(t){return t.status===409?new LQ(kx(t),t.status,Sx(t),t.body):t.status?new Un(kx(t),t.status,Sx(t)):t instanceof op.TransportUnavailableError?t:new Un(t.message,0,0)}var XQ=function(){function t(e,r,n){dr.default(this,t),this.clientInfo=e,this.config=r,this.transport=n}return yr.default(t,[{key:"createHeaders",value:function(){return{"Content-Type":"application/json","Twilio-Sync-Client-Info":JSON.stringify(this.clientInfo),"Twilio-Request-Id":"RQ"+TQ.v4().replace(/-/g,"")}}},{key:"backoffConfig",value:function(){return Object.assign({min:KQ,max:YQ,maxAttemptsTime:JQ,randomness:QQ},this.config.backoffConfig)}},{key:"executeWithRetry",value:function(r){var n=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return new Promise(function(a,s){var o=[502,503,504];i&&o.push(429);var u=new dx.Retrier(n.backoffConfig());u.on("attempt",function(){r().then(function(l){return u.succeeded(l)}).catch(function(l){if(o.includes(l.status)){var c=parseInt(l.headers?l.headers["Retry-After"]:null);u.failed(dd(l),isNaN(c)?null:c*1e3)}else l.message==="Twilsock disconnected"?u.failed(dd(l)):(u.removeAllListeners(),u.cancel(),s(dd(l)))})}),u.on("succeeded",function(l){a(l)}),u.on("cancelled",function(l){return s(dd(l))}),u.on("failed",function(l){return s(dd(l))}),u.start()})}},{key:"get",value:function(r){var n=this,i=this.createHeaders();return vr.debug("GET",r,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.get(r,i,n.config.productId)},!0)}},{key:"post",value:function(r,n,i){var a=this,s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,o=this.createHeaders();return typeof i<"u"&&i!==null&&(o["If-Match"]=i),vr.debug("POST",r,"ID:",o["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.post(r,o,n,a.config.productId)},s)}},{key:"put",value:function(r,n,i){var a=this,s=this.createHeaders();return typeof i<"u"&&i!==null&&(s["If-Match"]=i),vr.debug("PUT",r,"ID:",s["Twilio-Request-Id"]),this.executeWithRetry(function(){return a.transport.put(r,s,n,a.config.productId)},!1)}},{key:"delete",value:function(r){var n=this,i=this.createHeaders();return vr.debug("DELETE",r,"ID:",i["Twilio-Request-Id"]),this.executeWithRetry(function(){return n.transport.delete(r,i,n.config.productId)},!1)}}]),t}(),eX=function(){function t(e,r){dr.default(this,t),this.config=e,this.storageId=null;try{this.storage=r||sessionStorage}catch{}}return yr.default(t,[{key:"storageKey",value:function(r,n){return"".concat(this.storageId,"::").concat(r,"::").concat(n)}},{key:"isReady",get:function(){return this.config.sessionStorageEnabled&&!!this.storageId}},{key:"updateStorageId",value:function(r){this.storageId=r}},{key:"store",value:function(r,n,i){return this.isReady?this._store(this.storageKey(r,n),i):null}},{key:"read",value:function(r,n){return this.isReady?this._read(this.storageKey(r,n)):null}},{key:"remove",value:function(r,n,i){if(!this.isReady)return null;try{this.storage.removeItem(this.storageKey(r,n)),i&&this.storage.removeItem(this.storageKey(r,i))}catch{}}},{key:"update",value:function(r,n,i,a){if(!this.isReady)return null;this._apply(this.storageKey(r,n),a),i&&this._apply(this.storageKey(r,i),a)}},{key:"_store",value:function(r,n){try{this.storage.setItem(r,JSON.stringify(n))}catch{}}},{key:"_read",value:function(r){try{var n=this.storage.getItem(r);if(n)return JSON.parse(n)}catch{}return null}},{key:"_apply",value:function(r,n){var i=this._read(r);if(!i)return!1;this._store(r,Object.assign(i,n))}}]),t}();function tX(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=rX(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1150
1150
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function rX(t,e){if(t){if(typeof t=="string")return $x(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return $x(t,e)}}function $x(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var fd=function(){function t(e,r){dr.default(this,t),this.services=e,this.removalHandler=r,this.subscriptionState="none",this._attachedListeners=new Map}return yr.default(t,[{key:"_advanceLastEventId",value:function(r,n){}},{key:"reportFailure",value:function(r){r.status===404?this.onRemoved(!1):this.broadcastEventToListeners("failure",r)}},{key:"_subscribe",value:function(){this.services.router._subscribe(this.sid,this)}},{key:"_unsubscribe",value:function(){this.services.router._unsubscribe(this.sid)}},{key:"_setSubscriptionState",value:function(r){this.subscriptionState=r,this.broadcastEventToListeners("_subscriptionStateChanged",r)}},{key:"close",value:function(){this._unsubscribe(),this.removalHandler!=null&&this.removalHandler(this.type,this.sid,this.uniqueName)}},{key:"attach",value:function(r){var n=r.listenerUuid,i=this._attachedListeners.get(n);i||(this._attachedListeners.size||this._subscribe(),this._attachedListeners.set(n,r))}},{key:"detach",value:function(r){this._attachedListeners.delete(r),this._attachedListeners.size||this.close()}},{key:"broadcastEventToListeners",value:function(r,n){var i=tX(this._attachedListeners.values()),a;try{for(i.s();!(a=i.n()).done;){var s=a.value;s.emit(r,n)}}catch(o){i.e(o)}finally{i.f()}}}]),t}(),Tx=function(){function t(e){dr.default(this,t),_r.default(this,"queuedRequests",[]),_r.default(this,"isRequestInFlight",!1),this.inputMergingFunction=e}return yr.default(t,[{key:"add",value:function(r,n){var i=this,a=new Promise(function(s,o){return i.queuedRequests.push({input:r,requestFunction:n,resolve:s,reject:o})});return this.wakeupQueue(),a}},{key:"squashAndAdd",value:function(r,n){var i=this.queuedRequests;this.queuedRequests=[];var a;i.length>0?(a=i.map(function(o){return o.input}).reduce(this.inputMergingFunction),a=this.inputMergingFunction(a,r)):a=r;var s=this.add(a,n);return i.forEach(function(o){return s.then(o.resolve,o.reject)}),s}},{key:"isEmpty",value:function(){return this.queuedRequests.length===0&&!this.isRequestInFlight}},{key:"wakeupQueue",value:function(){var r=this;if(!(this.queuedRequests.length===0||this.isRequestInFlight)){var n=this.queuedRequests.shift();this.isRequestInFlight=!0,n.requestFunction(n.input).then(n.resolve,n.reject).then(function(i){r.isRequestInFlight=!1,r.wakeupQueue()})}}}]),t}(),Cx=function(){function t(e){dr.default(this,t),_r.default(this,"queueByNamespaceKey",new Map),this.inputReducer=e}return yr.default(t,[{key:"add",value:function(){var e=et.default(fe.default.mark(function n(i,a,s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.invokeQueueMethod(i,function(l){return l.add(a,s)}));case 1:case"end":return u.stop()}},n,this)}));function r(n,i,a){return e.apply(this,arguments)}return r}()},{key:"squashAndAdd",value:function(){var e=et.default(fe.default.mark(function n(i,a,s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.invokeQueueMethod(i,function(l){return l.squashAndAdd(a,s)}));case 1:case"end":return u.stop()}},n,this)}));function r(n,i,a){return e.apply(this,arguments)}return r}()},{key:"invokeQueueMethod",value:function(){var e=et.default(fe.default.mark(function n(i,a){var s,o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.queueByNamespaceKey.has(i)||this.queueByNamespaceKey.set(i,new Tx(this.inputReducer)),s=this.queueByNamespaceKey.get(i),o=a(s),this.queueByNamespaceKey.get(i).isEmpty()&&this.queueByNamespaceKey.delete(i),l.abrupt("return",o);case 5:case"end":return l.stop()}},n,this)}));function r(n,i){return e.apply(this,arguments)}return r}()}]),t}();function nX(t){var e=iX();return function(){var n=Zr.default(t),i;if(e){var a=Zr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ks.default(this,i)}}function iX(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var hd=function(t){En.default(r,t);var e=nX(r);function r(){var n;return dr.default(this,r),n=e.call(this),n.closed=!1,n.uuid=fx.v4(),n}return yr.default(r,[{key:"listenerUuid",get:function(){return this.uuid}},{key:"close",value:function(){this.removeAllListeners(),this.closed=!0}},{key:"ensureNotClosed",value:function(){if(this.closed)throw new Error("Invalid operation on closed object")}}]),r}(kr);function Ex(t){var e=aX();return function(){var n=Zr.default(t),i;if(e){var a=Zr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ks.default(this,i)}}function aX(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var hb=function(t){En.default(r,t);var e=Ex(r);function r(n,i,a){var s;dr.default(this,r),s=e.call(this,n,a),_r.default(ra.default(s),"isDeleted",!1);var o=function(l,c){return typeof c.ttl=="number"?{ttl:c.ttl}:l};return s.updateMergingQueue=new Tx(o),s.descriptor=i,s.descriptor.data=s.descriptor.data||{},s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return yr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"document"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"_update",value:function(i){switch(i.date_created=new Date(i.date_created),i.type){case"document_updated":if(i.id<=this.lastEventId){vr.trace("Document update skipped, current:",this.lastEventId,", remote:",i.id);break}var a=this.descriptor.data!==void 0?Ii(this.descriptor.data):null;this.descriptor.last_event_id=i.id,this.descriptor.revision=i.document_revision,this.descriptor.date_updated=i.date_created,this.descriptor.data=i.document_data,this.broadcastEventToListeners("updated",{data:i.document_data,isLocal:!1,previousData:a}),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:i.id,revision:i.document_revision,date_updated:i.date_created,data:i.document_data});break;case"document_removed":this.onRemoved(!1);break}}},{key:"set",value:function(){var n=et.default(fe.default.mark(function a(s,o){var u=this,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return l=o||{},d.abrupt("return",this.updateMergingQueue.squashAndAdd(l,function(f){return u._setUnconditionally(s,f.ttl)}));case 2:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=et.default(fe.default.mark(function a(s,o){var u=this,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return l=o||{},d.abrupt("return",this.updateMergingQueue.add(l,function(f){return u._setWithIfMatch(s,f.ttl)}));case 2:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=et.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.abrupt("return",this.mutate(function(c){return Object.assign(c,s)},o));case 1:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=et.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this._postUpdateToServer({ttl:s});case 2:o=l.sent,this.descriptor.date_expires=o.date_expires;case 4:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_setUnconditionally",value:function(){var n=et.default(fe.default.mark(function a(s,o){var u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this._postUpdateToServer({data:s,revision:void 0,ttl:o});case 2:return u=c.sent,this._handleSuccessfulUpdateResult(u),c.abrupt("return",this.descriptor.data);case 5:case"end":return c.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_setWithIfMatch",value:function(){var n=et.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:if(u=s(Ii(this.descriptor.data)),!u){f.next=22;break}return l=this.revision,f.prev=3,f.next=6,this._postUpdateToServer({data:u,revision:l,ttl:o});case 6:return c=f.sent,this._handleSuccessfulUpdateResult(c),f.abrupt("return",this.descriptor.data);case 11:if(f.prev=11,f.t0=f.catch(3),f.t0.status!==412){f.next=19;break}return f.next=16,this._softSync();case 16:return f.abrupt("return",this._setWithIfMatch(s));case 19:throw f.t0;case 20:f.next=23;break;case 22:return f.abrupt("return",this.descriptor.data);case 23:case"end":return f.stop()}},a,this,[[3,11]])}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_handleSuccessfulUpdateResult",value:function(i){if(!(i.last_event_id<=this.descriptor.last_event_id)){var a=this.descriptor.data!==void 0?Ii(this.descriptor.data):null;this.descriptor.revision=i.revision,this.descriptor.data=i.data,this.descriptor.last_event_id=i.last_event_id,this.descriptor.date_expires=i.date_expires,this.descriptor.date_updated=new Date(i.date_updated),this.services.storage.update(this.type,this.sid,this.uniqueName,{last_event_id:i.last_event_id,revision:i.revision,date_updated:i.date_updated,data:i.data}),this.broadcastEventToListeners("updated",{data:this.descriptor.data,isLocal:!0,previousData:a})}}},{key:"_postUpdateToServer",value:function(){var n=et.default(fe.default.mark(function a(s){var o,u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:if(this.isDeleted){d.next=17;break}return o={data:s.data},s.ttl!==void 0&&(o.ttl=s.ttl),u=s.revision,d.prev=4,d.next=7,this.services.network.post(this.uri,o,u);case 7:return l=d.sent,d.abrupt("return",{revision:l.body.revision,data:s.data,last_event_id:l.body.last_event_id,date_updated:l.body.date_updated,date_expires:l.body.date_expires});case 11:throw d.prev=11,d.t0=d.catch(4),d.t0.status===404&&this.onRemoved(!1),d.t0;case 15:d.next=18;break;case 17:return d.abrupt("return",Promise.reject(new Un("The Document has been removed",404,54100)));case 18:case"end":return d.stop()}},a,this,[[4,11]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_softSync",value:function(){var n=et.default(fe.default.mark(function a(){var s=this;return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.services.network.get(this.uri).then(function(l){var c={type:"document_updated",id:l.body.last_event_id,document_revision:l.body.revision,document_data:l.body.data,date_created:l.body.date_updated};return s._update(c),s}).catch(function(l){l.status===404?s.onRemoved(!1):vr.error("Can't get updates for ".concat(s.sid,":"),l)}));case 1:case"end":return u.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"onRemoved",value:function(i){if(!this.isDeleted){var a=this.descriptor.data!==void 0?Ii(this.descriptor.data):null;this.isDeleted=!0,this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i,previousData:a})}}},{key:"removeDocument",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.isDeleted){o.next=6;break}return o.next=3,this.services.network.delete(this.uri);case 3:this.onRemoved(!0),o.next=7;break;case 6:return o.abrupt("return",Promise.reject(new Un("The Document has been removed",404,54100)));case 7:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()}],[{key:"type",get:function(){return"document"}}]),r}(fd),ai=function(t){En.default(r,t);var e=Ex(r);function r(n){var i;return dr.default(this,r),i=e.call(this),i.syncDocumentImpl=n,i.syncDocumentImpl.attach(ra.default(i)),i}return yr.default(r,[{key:"uri",get:function(){return this.syncDocumentImpl.uri}},{key:"revision",get:function(){return this.syncDocumentImpl.revision}},{key:"lastEventId",get:function(){return this.syncDocumentImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncDocumentImpl.dateExpires}},{key:"type",get:function(){return hb.type}},{key:"sid",get:function(){return this.syncDocumentImpl.sid}},{key:"data",get:function(){return this.syncDocumentImpl.data}},{key:"dateUpdated",get:function(){return this.syncDocumentImpl.dateUpdated}},{key:"uniqueName",get:function(){return this.syncDocumentImpl.uniqueName}},{key:"set",value:function(){var n=et.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncDocumentImpl.set(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=et.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncDocumentImpl.mutate(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=et.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncDocumentImpl.update(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncDocumentImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeDocument",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncDocumentImpl.removeDocument());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){od.default(Zr.default(r.prototype),"close",this).call(this),this.syncDocumentImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return hb.type}}]),r}(hd);_r.default(ai,"removed","removed"),_r.default(ai,"updated","updated"),hr([We.validateTypesAsync(We.pureObject,["undefined",We.objectSchema("document metadata",{ttl:[We.nonNegativeInteger,"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Object,Object]),Ke("design:returntype",Promise)],ai.prototype,"set",null),hr([We.validateTypesAsync("function",["undefined",We.objectSchema("document metadata",{ttl:[We.nonNegativeInteger,"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Function,Object]),Ke("design:returntype",Promise)],ai.prototype,"mutate",null),hr([We.validateTypesAsync(We.pureObject,["undefined",We.objectSchema("document metadata",{ttl:[We.nonNegativeInteger,"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Object,Object]),Ke("design:returntype",Promise)],ai.prototype,"update",null),hr([We.validateTypesAsync(We.nonNegativeInteger),Ke("design:type",Function),Ke("design:paramtypes",[Number]),Ke("design:returntype",Promise)],ai.prototype,"setTtl",null);var pb=function(){function t(e){dr.default(this,t),this.descriptor=e}return yr.default(t,[{key:"uri",get:function(){return this.descriptor.uri}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.lastEventId}},{key:"dateUpdated",get:function(){return this.descriptor.dateUpdated}},{key:"dateExpires",get:function(){return this.descriptor.dateExpires}},{key:"index",get:function(){return this.descriptor.index}},{key:"data",get:function(){return this.descriptor.data}},{key:"update",value:function(r,n,i,a){return this.descriptor.lastEventId=r,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.dateUpdated=a,this}},{key:"updateDateExpires",value:function(r){this.descriptor.dateExpires=r}}]),t}(),vb=function(){function t(e,r,n,i){dr.default(this,t),this.prevToken=n,this.nextToken=i,this.items=e,this.source=r}return yr.default(t,[{key:"hasNextPage",get:function(){return!!this.nextToken}},{key:"hasPrevPage",get:function(){return!!this.prevToken}},{key:"nextPage",value:function(){var e=et.default(fe.default.mark(function n(){return fe.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.hasNextPage){a.next=2;break}throw new Error("No next page");case 2:return a.abrupt("return",this.source(this.nextToken));case 3:case"end":return a.stop()}},n,this)}));function r(){return e.apply(this,arguments)}return r}()},{key:"prevPage",value:function(){var e=et.default(fe.default.mark(function n(){return fe.default.wrap(function(a){for(;;)switch(a.prev=a.next){case 0:if(this.hasPrevPage){a.next=2;break}throw new Error("No previous page");case 2:return a.abrupt("return",this.source(this.prevToken));case 3:case"end":return a.stop()}},n,this)}));function r(){return e.apply(this,arguments)}return r}()}]),t}();function sX(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=oX(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1151
1151
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function oX(t,e){if(t){if(typeof t=="string")return Ix(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ix(t,e)}}function Ix(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var uX=function(){function t(e,r){dr.default(this,t),this.balanceFactor=0,this.key=e,this.value=r,this.parent=null,this.left=null,this.right=null}return yr.default(t,[{key:"isRoot",get:function(){return this.parent===null}},{key:"isLeaf",get:function(){return this.left===null&&this.right===null}},{key:"isLeftChild",get:function(){return this.parent.left===this}},{key:"update",value:function(r){this.value=r}},{key:"replace",value:function(r,n){r&&(this.left===n?this.left=n:this.right===n&&(this.right=n))}}]),t}(),lX=function(){function t(e,r){dr.default(this,t),this.isLessThan=e||function(n,i){return n<i},this.isEqual=r||function(n,i){return n===i},this.root=null,this.count=null}return yr.default(t,[{key:"size",get:function(){return this.count}},{key:"clear",value:function(){this.root=null,this.count=0}},{key:"set",value:function(r,n){var i=this.getNode(r);i?i.update(n):this.insert(r,n)}},{key:"insert",value:function(r,n){var i=new uX(r,n);if(this.count++,!this.root){this.root=i;return}for(var a=this.root;;)if(this.isLessThan(r,a.key))if(a.left)a=a.left;else{a.left=i;break}else if(a.right)a=a.right;else{a.right=i;break}for(i.parent=a,a=i;a.parent;){var s=a.parent,o=s.balanceFactor;if(a.isLeftChild?s.balanceFactor++:s.balanceFactor--,Math.abs(s.balanceFactor)<Math.abs(o))break;if(s.balanceFactor<-1||s.balanceFactor>1){this.rebalance(s);break}a=s}}},{key:"get",value:function(r){for(var n=this.root;n;){if(this.isEqual(r,n.key))return n.value;this.isLessThan(r,n.key)?n=n.left:n=n.right}return null}},{key:"delete",value:function(r){var n=this.getNode(r);if(!n||n.key!==r)return null;var i=n.parent,a=n.left,s=n.right;if(!!a!=!!s){var o=a||s;!i&&!o?this.root=null:i&&!o?this.root=o:(i.replace(n,null),this.rebalance(i))}else{for(var u=n.left;u.right;)u=u.right;if(n.left===u)n.isRoot?(this.root=u,u.parent=null):(n.isLeftChild?n.parent.left=u:n.parent.right=u,u.parent=n.parent),u.right=n.right,u.right.parent=u,u.balanceFactor=n.balanceFactor,n={parent:u,isLeftChild:!0};else{var l=u.parent,c=u.left;l.right=c,c&&(c.parent=l),n.isRoot?(this.root=u,u.parent=null):(n.isLeftChild?n.parent.left=u:n.parent.right=u,u.parent=n.parent),u.right=n.right,u.right.parent=u,u.left=n.left,u.left.parent=u,u.balanceFactor=n.balanceFactor,n={parent:l,isLeftChild:!1}}}for(this.count--;n.parent;){var d=n.parent,f=d.balanceFactor;if(n.isLeftChild?d.balanceFactor-=1:d.balanceFactor+=1,Math.abs(d.balanceFactor)>Math.abs(f))if(d.balanceFactor<-1||d.balanceFactor>1)if(this.rebalance(d),d.parent.balanceFactor===0)n=d.parent;else break;else break;else n=d}return null}},{key:"getNode",value:function(r){for(var n=this.root;n;){if(this.isEqual(r,n.key))return n;this.isLessThan(r,n.key)?n=n.left:n=n.right}return null}},{key:"rebalance",value:function(r){r.balanceFactor<0?r.right.balanceFactor>0?(this.rotateRight(r.right),this.rotateLeft(r)):this.rotateLeft(r):r.balanceFactor>0&&(r.left.balanceFactor<0?(this.rotateLeft(r.left),this.rotateRight(r)):this.rotateRight(r))}},{key:"rotateLeft",value:function(r){var n=r.right;r.right=n.left,n.left!==null&&(n.left.parent=r),n.parent=r.parent,n.parent===null?this.root=n:r.isLeftChild?n.parent.left=n:n.parent.right=n,n.left=r,r.parent=n,r.balanceFactor=r.balanceFactor+1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor+1-Math.max(r.balanceFactor,0)}},{key:"rotateRight",value:function(r){var n=r.left;r.left=n.right,n.right!==null&&(n.right.parent=r),n.parent=r.parent,n.parent===null?this.root=n:r.isLeftChild?n.parent.left=n:n.parent.right=n,n.right=r,r.parent=n,r.balanceFactor=r.balanceFactor-1-Math.min(n.balanceFactor,0),n.balanceFactor=n.balanceFactor-1-Math.max(r.balanceFactor,0)}},{key:Symbol.iterator,value:fe.default.mark(function e(){var r,n,i;return fe.default.wrap(function(s){for(;;)switch(s.prev=s.next){case 0:r=sX(this.getIterator()),s.prev=1,r.s();case 3:if((n=r.n()).done){s.next=9;break}return i=n.value,s.next=7,i;case 7:s.next=3;break;case 9:s.next=14;break;case 11:s.prev=11,s.t0=s.catch(1),r.e(s.t0);case 14:return s.prev=14,r.f(),s.finish(14);case 17:case"end":return s.stop()}},e,this,[[1,11,14,17]])})},{key:"getIterator",value:fe.default.mark(function e(){var r,n,i,a=arguments;return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:r=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){o.next=8;break}if(!(this.isEqual(r,n.key)||r===null&&!n.left)){o.next=5;break}return o.abrupt("break",8);case 5:this.isLessThan(r,n.key)||r===null?n=n.left:n=n.right,o.next=2;break;case 8:if(n){o.next=10;break}return o.abrupt("return",null);case 10:i=!0;case 11:if(!i){o.next=29;break}return o.next=14,[n.key,n.value];case 14:if(i=!1,!n.right){o.next=21;break}for(n=n.right;n.left;)n=n.left;i=!0,o.next=27;break;case 21:if(!n.parent){o.next=26;break}i=n.parent.left===n,n=n.parent,o.next=27;break;case 26:return o.abrupt("break",37);case 27:o.next=35;break;case 29:if(!n.parent){o.next=34;break}i=n.parent.left===n,n=n.parent,o.next=35;break;case 34:return o.abrupt("break",37);case 35:o.next=11;break;case 37:return o.abrupt("return",null);case 38:case"end":return o.stop()}},e,this)})},{key:"getReverseIterator",value:fe.default.mark(function e(){var r,n,i,a=arguments;return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:r=a.length>0&&a[0]!==void 0?a[0]:null,n=this.root;case 2:if(!n){o.next=8;break}if(!(this.isEqual(r,n.key)||r===null&&!n.right)){o.next=5;break}return o.abrupt("break",8);case 5:!this.isLessThan(r,n.key)||r===null?n=n.right:n=n.left,o.next=2;break;case 8:if(n){o.next=10;break}return o.abrupt("return",null);case 10:i=!0;case 11:if(!i){o.next=29;break}return o.next=14,[n.key,n.value];case 14:if(i=!1,!n.left){o.next=21;break}for(n=n.left;n.right;)n=n.right;i=!0,o.next=27;break;case 21:if(!n.parent){o.next=26;break}i=n.parent.right===n,n=n.parent,o.next=27;break;case 26:return o.abrupt("break",37);case 27:o.next=35;break;case 29:if(!n.parent){o.next=34;break}i=n.parent.right===n,n=n.parent,o.next=35;break;case 34:return o.abrupt("break",37);case 35:o.next=11;break;case 37:return o.abrupt("return",null);case 38:case"end":return o.stop()}},e,this)})}]),t}();function cX(t,e){var r=typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=dX(t))||e){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1152
1152
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var a=!0,s=!1,o;return{s:function(){r=r.call(t)},n:function(){var l=r.next();return a=l.done,l},e:function(l){s=!0,o=l},f:function(){try{!a&&r.return!=null&&r.return()}finally{if(s)throw o}}}}function dX(t,e){if(t){if(typeof t=="string")return xx(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return xx(t,e)}}function xx(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var fX=function(){function t(e,r){dr.default(this,t),this.value=e,this.revision=r||0}return yr.default(t,[{key:"isValid",get:function(){return!0}}]),t}(),hX=function(){function t(e){dr.default(this,t),this.revision=e}return yr.default(t,[{key:"isValid",get:function(){return!1}}]),t}(),gb=function(){function t(){dr.default(this,t),this.items=new lX}return yr.default(t,[{key:"store",value:function(r,n,i){var a=this.items.get(r);return a&&a.revision>i?a.isValid?a.value:null:(this.items.set(r,new fX(n,i)),n)}},{key:"delete",value:function(r,n){var i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,a=this.items.get(r);(!a||a.revision<n||a&&i===!0)&&this.items.set(r,new hX(n))}},{key:"isKnown",value:function(r,n){var i=this.items.get(r);return i&&i.revision>=n}},{key:"get",value:function(r){var n=this.items.get(r);return n&&n.isValid?n.value:null}},{key:"has",value:function(r){var n=this.items.get(r);return n&&n.isValid}},{key:"forEach",value:function(r){if(this.items){var n=cX(this.items),i;try{for(n.s();!(i=n.n()).done;){var a=px.default(i.value,2),s=a[0],o=a[1];o.isValid&&r(s,o.value)}}catch(u){n.e(u)}finally{n.f()}}}}]),t}();function Rx(t){var e=pX();return function(){var n=Zr.default(t),i;if(e){var a=Zr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ks.default(this,i)}}function pX(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var mb=function(t){En.default(r,t);var e=Rx(r);function r(n,i,a){var s;dr.default(this,r),s=e.call(this,n,a);var o=function(l,c){return typeof c.ttl=="number"?{ttl:c.ttl}:l};return s.updateMergingQueue=new Cx(o),s.cache=new gb,s.descriptor=i,s.descriptor.date_updated=new Date(s.descriptor.date_updated),s}return yr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"list"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"_addOrUpdateItemOnServer",value:function(){var n=et.default(fe.default.mark(function a(s,o,u,l){var c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return c={data:o},l!==void 0&&(c.ttl=l),m.next=4,this.services.network.post(s,c,u);case 4:return d=m.sent,d.body.data=o,d.body.date_updated=new Date(d.body.date_updated),m.abrupt("return",d.body);case 8:case"end":return m.stop()}},a,this)}));function i(a,s,o,u){return n.apply(this,arguments)}return i}()},{key:"push",value:function(){var n=et.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return u=(o||{}).ttl,f.next=3,this._addOrUpdateItemOnServer(this.links.items,s,void 0,u);case 3:return l=f.sent,c=Number(l.index),this._handleItemMutated(c,l.url,l.last_event_id,l.revision,s,l.date_updated,l.date_expires,!0,!1),f.abrupt("return",this.cache.get(c));case 7:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.squashAndAdd(s,c,function(m){return l._updateItemUnconditionally(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_updateItemUnconditionally",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){var l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return l=f.sent,f.next=5,this._addOrUpdateItemOnServer(l.uri,o,void 0,u);case 5:return c=f.sent,this._handleItemMutated(s,c.url,c.last_event_id,c.revision,c.data,c.date_updated,c.date_expires,!1,!1),f.abrupt("return",this.cache.get(s));case 8:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_updateItemWithIfMatch",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){var l,c,d,f;return fe.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this.get(s);case 2:if(l=k.sent,c=o(Ii(l.data)),!c){k.next=25;break}return d=l.revision,k.prev=6,k.next=9,this._addOrUpdateItemOnServer(l.uri,c,d,u);case 9:return f=k.sent,this._handleItemMutated(s,f.url,f.last_event_id,f.revision,f.data,f.date_updated,f.date_expires,!1,!1),k.abrupt("return",this.cache.get(s));case 14:if(k.prev=14,k.t0=k.catch(6),k.t0.status!==412){k.next=22;break}return k.next=19,this._getItemFromServer(s);case 19:return k.abrupt("return",this._updateItemWithIfMatch(s,o,u));case 22:throw k.t0;case 23:k.next=26;break;case 25:return k.abrupt("return",l);case 26:case"end":return k.stop()}},a,this,[[6,14]])}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.add(s,c,function(m){return l._updateItemWithIfMatch(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",this.mutate(s,function(d){return Object.assign(d,o)},u));case 1:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=et.default(fe.default.mark(function a(s){var o,u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,this.get(s);case 2:return o=d.sent,u=Ii(o.data),d.next=6,this.services.network.delete(o.uri);case 6:l=d.sent,this._handleItemRemoved(s,l.body.last_event_id,u,new Date(l.body.date_updated),!1);case 8:case"end":return d.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=et.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(o=this.cache.get(s),!o){l.next=5;break}return l.abrupt("return",o);case 5:return l.abrupt("return",this._getItemFromServer(s));case 6:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getItemFromServer",value:function(){var n=et.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this.queryItems({index:s});case 2:if(o=l.sent,!(o.items.length<1)){l.next=7;break}throw new Un("No item with index ".concat(s," found"),404,54151);case 7:return l.abrupt("return",o.items[0]);case 8:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=et.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=s||{},u=new Zu(this.links.items).queryParam("From",s.from).queryParam("PageSize",s.limit).queryParam("Index",s.index).queryParam("PageToken",s.pageToken).queryParam("Order",s.order).build(),m.next=4,this.services.network.get(u);case 4:return l=m.sent,c=l.body.items.map(function(k){k.date_updated=new Date(k.date_updated);var L=o.cache.get(k.index);return L?o._handleItemMutated(k.index,k.url,k.last_event_id,k.revision,k.data,k.date_updated,k.date_expires,!1,!0):o.cache.store(Number(k.index),new pb({index:Number(k.index),uri:k.url,revision:k.revision,lastEventId:k.last_event_id,dateUpdated:k.date_updated,dateExpires:k.date_expires,data:k.data}),k.last_event_id),o.cache.get(k.index)}),d=l.body.meta,m.abrupt("return",new vb(c,function(k){return o.queryItems({pageToken:k})},d.previous_token,d.next_token));case 8:case"end":return m.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=s||{},wx(s.pageSize),s.limit=s.pageSize||s.limit||50,s.order=s.order||"asc",u.abrupt("return",this.queryItems(s));case 5:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getContext",value:function(){var n=et.default(fe.default.mark(function a(){var s;return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.context){u.next=5;break}return u.next=3,this.services.network.get(this.links.context);case 3:s=u.sent,this._updateContextIfRequired(s.body.data,s.body.last_event_id);case 5:return u.abrupt("return",this.context);case 6:case"end":return u.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=et.default(fe.default.mark(function a(s){var o,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o={ttl:s},c.next=4,this.services.network.post(this.uri,o);case 4:u=c.sent,this.descriptor.date_expires=u.body.date_expires,c.next=12;break;case 8:throw c.prev=8,c.t0=c.catch(0),c.t0.status===404&&this.onRemoved(!1),c.t0;case 12:case"end":return c.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=et.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return u=f.sent,l={ttl:o},f.next=6,this.services.network.post(u.uri,l);case 6:c=f.sent,u.updateDateExpires(c.body.date_expires);case 8:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}},{key:"shouldIgnoreEvent",value:function(i,a){return this.cache.isKnown(i,a)}},{key:"_update",value:function(i,a){var s=Number(i.item_index);switch(i.date_created=new Date(i.date_created),i.type){case"list_item_added":case"list_item_updated":this._handleItemMutated(s,i.item_url,i.id,i.item_revision,i.item_data,i.date_created,void 0,i.type==="list_item_added",!0);break;case"list_item_removed":this._handleItemRemoved(s,i.id,i.item_data,i.date_created,!0);break;case"list_context_updated":this._handleContextUpdate(i.context_data,i.id,i.date_created);break;case"list_removed":this.onRemoved(!1);break}a&&this._advanceLastEventId(i.id,i.list_revision)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i,a&&(this.descriptor.revision=a))}},{key:"_updateRootDateUpdated",value:function(i){(!this.descriptor.date_updated||i.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=i,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:i}))}},{key:"_handleItemMutated",value:function(i,a,s,o,u,l,c,d,f){if(this.shouldIgnoreEvent(i,s)){vr.trace("Item ".concat(i," update skipped, current: ").concat(this.lastEventId,", remote: ").concat(s));return}this._updateRootDateUpdated(l);var m=this.cache.get(i);if(!m){var k=new pb({index:i,uri:a,lastEventId:s,revision:o,data:u,dateUpdated:l,dateExpires:c});this.cache.store(i,k,s),this.emitItemMutationEvent(k,f,d);return}var L=Ii(m.data);m.update(s,o,u,l),this.cache.store(i,m,s),c!==void 0&&m.updateDateExpires(c),this.emitItemMutationEvent(m,f,!1,L)}},{key:"emitItemMutationEvent",value:function(i,a,s){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,u=s?"itemAdded":"itemUpdated",l={item:i,isLocal:!a};s||(l.previousItemData=o),this.broadcastEventToListeners(u,l)}},{key:"_handleItemRemoved",value:function(i,a,s,o,u){this._updateRootDateUpdated(o),this.cache.delete(i,a),this.broadcastEventToListeners("itemRemoved",{index:i,isLocal:!u,previousItemData:s})}},{key:"_handleContextUpdate",value:function(i,a,s){this._updateRootDateUpdated(s),this._updateContextIfRequired(i,a)&&this.broadcastEventToListeners("contextUpdated",{context:i,isLocal:!1})}},{key:"_updateContextIfRequired",value:function(i,a){return!this.contextEventId||a>this.contextEventId?(this.context=i,this.contextEventId=a,!0):(vr.trace("Context update skipped, current:",this.lastEventId,", remote:",a),!1)}}],[{key:"type",get:function(){return"list"}}]),r}(fd),Yr=function(t){En.default(r,t);var e=Rx(r);function r(n){var i;return dr.default(this,r),i=e.call(this),i.syncListImpl=n,i.syncListImpl.attach(ra.default(i)),i}return yr.default(r,[{key:"uri",get:function(){return this.syncListImpl.uri}},{key:"revision",get:function(){return this.syncListImpl.revision}},{key:"lastEventId",get:function(){return this.syncListImpl.lastEventId}},{key:"links",get:function(){return this.syncListImpl.links}},{key:"dateExpires",get:function(){return this.syncListImpl.dateExpires}},{key:"type",get:function(){return mb.type}},{key:"sid",get:function(){return this.syncListImpl.sid}},{key:"uniqueName",get:function(){return this.syncListImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncListImpl.dateUpdated}},{key:"push",value:function(){var n=et.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.push(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"set",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.set(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.mutate(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncListImpl.update(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.remove(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.get(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getContext",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncListImpl.getContext());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.getItems(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncListImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=et.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncListImpl.setItemTtl(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeList",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncListImpl.removeList());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){od.default(Zr.default(r.prototype),"close",this).call(this),this.syncListImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return mb.type}}]),r}(hd);_r.default(Yr,"itemAdded","itemAdded"),_r.default(Yr,"itemUpdated","itemUpdated"),_r.default(Yr,"itemRemoved","itemRemoved"),_r.default(Yr,"removed","removed"),hr([We.validateTypesAsync(We.pureObject,["undefined",We.objectSchema("item metadata",{ttl:[We.nonNegativeInteger,"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Object,Object]),Ke("design:returntype",Promise)],Yr.prototype,"push",null),hr([We.validateTypesAsync(We.nonNegativeInteger,We.pureObject,["undefined",We.objectSchema("item metadata",{ttl:[We.nonNegativeInteger,"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Number,Object,Object]),Ke("design:returntype",Promise)],Yr.prototype,"set",null),hr([We.validateTypesAsync(We.nonNegativeInteger,"function",["undefined",We.objectSchema("item metadata",{ttl:[We.nonNegativeInteger,"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Number,Function,Object]),Ke("design:returntype",Promise)],Yr.prototype,"mutate",null),hr([We.validateTypesAsync(We.nonNegativeInteger,We.pureObject,["undefined",We.objectSchema("item metadata",{ttl:[We.nonNegativeInteger,"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Number,Object,Object]),Ke("design:returntype",Promise)],Yr.prototype,"update",null),hr([We.validateTypesAsync(We.nonNegativeInteger),Ke("design:type",Function),Ke("design:paramtypes",[Number]),Ke("design:returntype",Promise)],Yr.prototype,"remove",null),hr([We.validateTypesAsync(We.nonNegativeInteger),Ke("design:type",Function),Ke("design:paramtypes",[Number]),Ke("design:returntype",Promise)],Yr.prototype,"get",null),hr([We.validateTypesAsync(["undefined",We.objectSchema("query options",{from:[We.nonNegativeInteger,"undefined"],pageSize:[We.custom(function(t){return[fb(t),"a positive integer"]}),"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Object]),Ke("design:returntype",Promise)],Yr.prototype,"getItems",null),hr([We.validateTypesAsync(We.nonNegativeInteger),Ke("design:type",Function),Ke("design:paramtypes",[Number]),Ke("design:returntype",Promise)],Yr.prototype,"setTtl",null),hr([We.validateTypesAsync(We.nonNegativeInteger,We.nonNegativeInteger),Ke("design:type",Function),Ke("design:paramtypes",[Number,Number]),Ke("design:returntype",Promise)],Yr.prototype,"setItemTtl",null);var pd=function(){function t(e){dr.default(this,t),this.descriptor=e}return yr.default(t,[{key:"uri",get:function(){return this.descriptor.url}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"key",get:function(){return this.descriptor.key}},{key:"data",get:function(){return this.descriptor.data}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"update",value:function(r,n,i,a){return this.descriptor.last_event_id=r,this.descriptor.revision=n,this.descriptor.data=i,this.descriptor.date_updated=a,this}},{key:"updateDateExpires",value:function(r){this.descriptor.date_expires=r}}]),t}();function Ax(t){var e=vX();return function(){var n=Zr.default(t),i;if(e){var a=Zr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ks.default(this,i)}}function vX(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var yb=function(t){En.default(r,t);var e=Ax(r);function r(n,i,a){var s;dr.default(this,r),s=e.call(this,n,a);var o=function(l,c){return typeof c.ttl=="number"?{ttl:c.ttl}:l};return s.updateMergingQueue=new Cx(o),s.cache=new gb,s.descriptor=i,s.descriptor.date_updated=new Date(s.descriptor.date_updated),i.items&&i.items.forEach(function(u){u.date_updated=new Date(u.date_updated),s.cache.store(u.key,new pd(u),u.last_event_id)}),s}return yr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"revision",get:function(){return this.descriptor.revision}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"map"}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"dateUpdated",get:function(){return this.descriptor.date_updated}},{key:"set",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.squashAndAdd(s,c,function(m){return l._putItemUnconditionally(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(s!=null){u.next=2;break}throw new Un("SyncMapItem key may not be empty",400,54209);case 2:if(!this.cache.has(s)){u.next=6;break}return u.abrupt("return",this.cache.get(s));case 6:return u.abrupt("return",this._getItemFromServer(s));case 7:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getItemFromServer",value:function(){var n=et.default(fe.default.mark(function a(s){var o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return l.next=2,this.queryItems({key:s});case 2:if(o=l.sent,!(o.items.length<1)){l.next=7;break}throw new Un("The specified Map Item does not exist",404,54201);case 7:return l.abrupt("return",o.items[0]);case 8:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){var l=this,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return c=u||{},f.abrupt("return",this.updateMergingQueue.add(s,c,function(m){return l._putItemWithIfMatch(s,o,m.ttl)}));case 2:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.abrupt("return",this.mutate(s,function(d){return Object.assign(d,o)},u));case 1:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemUnconditionally",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){var l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this._putItemToServer(s,o,void 0,u);case 2:return l=f.sent,c=l.item,this._handleItemMutated(c.key,c.url,c.last_event_id,c.revision,c.data,c.date_updated,c.date_expires,l.added,!1),f.abrupt("return",this.cache.get(c.key));case 6:case"end":return f.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemWithIfMatch",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){var l,c,d,f,m;return fe.default.wrap(function(L){for(;;)switch(L.prev=L.next){case 0:return L.next=2,this.get(s).catch(function(N){if(N.status===404)return new pd({key:s,data:{},last_event_id:-1,revision:"-1",url:null,date_updated:null,date_expires:null});throw N});case 2:if(l=L.sent,c=o(Ii(l.data)),!c){L.next=26;break}return d=l.revision,L.prev=6,L.next=9,this._putItemToServer(s,c,d,u);case 9:return f=L.sent,m=f.item,this._handleItemMutated(m.key,m.url,m.last_event_id,m.revision,m.data,m.date_updated,m.date_expires,f.added,!1),L.abrupt("return",this.cache.get(m.key));case 15:if(L.prev=15,L.t0=L.catch(6),L.t0.status!==412){L.next=23;break}return L.next=20,this._getItemFromServer(s);case 20:return L.abrupt("return",this._putItemWithIfMatch(s,o,u));case 23:throw L.t0;case 24:L.next=27;break;case 26:return L.abrupt("return",l);case 27:case"end":return L.stop()}},a,this,[[6,15]])}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"_putItemToServer",value:function(){var n=et.default(fe.default.mark(function a(s,o,u,l){var c,d,f,m,k;return fe.default.wrap(function(N){for(;;)switch(N.prev=N.next){case 0:return c=new Zu(this.links.items).pathSegment(s).build(),d={data:o},l!==void 0&&(d.ttl=l),N.prev=3,N.next=6,this.services.network.put(c,d,u);case 6:return f=N.sent,m=f.body,m.data=o,m.date_updated=new Date(m.date_updated),k=f.status.code===201,N.abrupt("return",{added:k,item:m});case 14:throw N.prev=14,N.t0=N.catch(3),N.t0.status===404&&this.onRemoved(!1),N.t0;case 18:case"end":return N.stop()}},a,this,[[3,14]])}));function i(a,s,o,u){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=et.default(fe.default.mark(function a(s){var o,u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,this.get(s);case 2:return o=d.sent,u=Ii(o.data),d.next=6,this.services.network.delete(o.uri);case 6:l=d.sent,this._handleItemRemoved(s,l.body.last_event_id,u,new Date(l.body.date_updated),!1);case 8:case"end":return d.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"queryItems",value:function(){var n=et.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return s=s||{},u=new Zu(this.links.items).queryParam("From",s.from).queryParam("PageSize",s.limit).queryParam("Key",s.key).queryParam("PageToken",s.pageToken).queryParam("Order",s.order).build(),m.next=4,this.services.network.get(u);case 4:return l=m.sent,c=l.body.items.map(function(k){k.date_updated=new Date(k.date_updated);var L=o.cache.get(k.key);return L?o._handleItemMutated(k.key,k.url,k.last_event_id,k.revision,k.data,k.date_updated,k.date_expires,!1,!0):o.cache.store(k.key,new pd(k),k.last_event_id),o.cache.get(k.key)}),d=l.body.meta,m.abrupt("return",new vb(c,function(k){return o.queryItems({pageToken:k})},d.previous_token,d.next_token));case 8:case"end":return m.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return s=s||{},wx(s.pageSize),s.limit=s.pageSize||s.limit||50,s.order=s.order||"asc",u.abrupt("return",this.queryItems(s));case 5:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"shouldIgnoreEvent",value:function(i,a){return this.cache.isKnown(i,a)}},{key:"_update",value:function(i,a){switch(i.date_created=new Date(i.date_created),i.type){case"map_item_added":case"map_item_updated":this._handleItemMutated(i.item_key,i.item_url,i.id,i.item_revision,i.item_data,i.date_created,void 0,i.type==="map_item_added",!0);break;case"map_item_removed":this._handleItemRemoved(i.item_key,i.id,i.item_data,i.date_created,!0);break;case"map_removed":this.onRemoved(!1);break}a&&this._advanceLastEventId(i.id,i.map_revision)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i,a&&(this.descriptor.revision=a))}},{key:"_updateRootDateUpdated",value:function(i){(!this.descriptor.date_updated||i.getTime()>this.descriptor.date_updated.getTime())&&(this.descriptor.date_updated=i,this.services.storage.update(this.type,this.sid,this.uniqueName,{date_updated:i}))}},{key:"_handleItemMutated",value:function(i,a,s,o,u,l,c,d,f){if(this.shouldIgnoreEvent(i,s)){vr.trace("SyncMapItem ",i," update skipped, current:",this.lastEventId,", remote:",s);return}this._updateRootDateUpdated(l);var m=this.cache.get(i);if(!m){var k=new pd({key:i,url:a,last_event_id:s,revision:o,data:u,date_updated:l,date_expires:c});this.cache.store(i,k,s),this.emitItemMutationEvent(k,f,d);return}var L=Ii(m.data);m.update(s,o,u,l),this.cache.store(i,m,s),c!==void 0&&m.updateDateExpires(c),this.emitItemMutationEvent(m,f,!1,L)}},{key:"emitItemMutationEvent",value:function(i,a,s){var o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,u=s?"itemAdded":"itemUpdated",l={item:i,isLocal:!a};s||(l.previousItemData=o),this.broadcastEventToListeners(u,l)}},{key:"_handleItemRemoved",value:function(i,a,s,o,u){this._updateRootDateUpdated(o),this.cache.delete(i,a),this.broadcastEventToListeners("itemRemoved",{key:i,isLocal:!u,previousItemData:s})}},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}},{key:"setTtl",value:function(){var n=et.default(fe.default.mark(function a(s){var o,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o={ttl:s},c.next=4,this.services.network.post(this.uri,o);case 4:u=c.sent,this.descriptor.date_expires=u.body.date_expires,c.next=12;break;case 8:throw c.prev=8,c.t0=c.catch(0),c.t0.status===404&&this.onRemoved(!1),c.t0;case 12:case"end":return c.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=et.default(fe.default.mark(function a(s,o){var u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return f.next=2,this.get(s);case 2:return u=f.sent,l={ttl:o},f.next=6,this.services.network.post(u.uri,l);case 6:c=f.sent,u.updateDateExpires(c.body.date_expires);case 8:case"end":return f.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()}],[{key:"type",get:function(){return"map"}}]),r}(fd),tn=function(t){En.default(r,t);var e=Ax(r);function r(n){var i;return dr.default(this,r),i=e.call(this),i.syncMapImpl=n,i.syncMapImpl.attach(ra.default(i)),i}return yr.default(r,[{key:"uri",get:function(){return this.syncMapImpl.uri}},{key:"links",get:function(){return this.syncMapImpl.links}},{key:"revision",get:function(){return this.syncMapImpl.revision}},{key:"lastEventId",get:function(){return this.syncMapImpl.lastEventId}},{key:"dateExpires",get:function(){return this.syncMapImpl.dateExpires}},{key:"type",get:function(){return yb.type}},{key:"sid",get:function(){return this.syncMapImpl.sid}},{key:"uniqueName",get:function(){return this.syncMapImpl.uniqueName}},{key:"dateUpdated",get:function(){return this.syncMapImpl.dateUpdated}},{key:"set",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.set(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"get",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.get(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"mutate",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.mutate(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"update",value:function(){var n=et.default(fe.default.mark(function a(s,o,u){return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return this.ensureNotClosed(),c.abrupt("return",this.syncMapImpl.update(s,o,u));case 2:case"end":return c.stop()}},a,this)}));function i(a,s,o){return n.apply(this,arguments)}return i}()},{key:"remove",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.remove(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.getItems(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncMapImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setItemTtl",value:function(){var n=et.default(fe.default.mark(function a(s,o){return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.ensureNotClosed(),l.abrupt("return",this.syncMapImpl.setItemTtl(s,o));case 2:case"end":return l.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"removeMap",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.next=3,this.syncMapImpl.removeMap();case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){od.default(Zr.default(r.prototype),"close",this).call(this),this.syncMapImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return yb.type}}]),r}(hd);_r.default(tn,"itemAdded","itemAdded"),_r.default(tn,"itemUpdated","itemUpdated"),_r.default(tn,"itemRemoved","itemRemoved"),_r.default(tn,"removed","removed"),hr([We.validateTypesAsync("string",We.pureObject,["undefined",We.objectSchema("item metadata",{ttl:[We.nonNegativeInteger,"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[String,Object,Object]),Ke("design:returntype",Promise)],tn.prototype,"set",null),hr([We.validateTypesAsync("string"),Ke("design:type",Function),Ke("design:paramtypes",[String]),Ke("design:returntype",Promise)],tn.prototype,"get",null),hr([We.validateTypesAsync("string","function",["undefined",We.objectSchema("item metadata",{ttl:[We.nonNegativeInteger,"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[String,Function,Object]),Ke("design:returntype",Promise)],tn.prototype,"mutate",null),hr([We.validateTypesAsync("string",We.pureObject,["undefined",We.objectSchema("item metadata",{ttl:[We.nonNegativeInteger,"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[String,Object,Object]),Ke("design:returntype",Promise)],tn.prototype,"update",null),hr([We.validateTypesAsync("string"),Ke("design:type",Function),Ke("design:paramtypes",[String]),Ke("design:returntype",Promise)],tn.prototype,"remove",null),hr([We.validateTypesAsync(["undefined",We.objectSchema("query options",{from:["string","undefined"],pageSize:[We.custom(function(t){return[fb(t),"a positive integer"]}),"undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Object]),Ke("design:returntype",Promise)],tn.prototype,"getItems",null),hr([We.validateTypesAsync(We.nonNegativeInteger),Ke("design:type",Function),Ke("design:paramtypes",[Number]),Ke("design:returntype",Promise)],tn.prototype,"setTtl",null),hr([We.validateTypesAsync("string",We.nonNegativeInteger),Ke("design:type",Function),Ke("design:paramtypes",[String,Number]),Ke("design:returntype",Promise)],tn.prototype,"setItemTtl",null);function Ox(t){var e=gX();return function(){var n=Zr.default(t),i;if(e){var a=Zr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ks.default(this,i)}}function gX(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var vd=function(t){En.default(r,t);var e=Ox(r);function r(n,i,a){var s;return dr.default(this,r),s=e.call(this,n,a),s.descriptor=i,s}return yr.default(r,[{key:"uri",get:function(){return this.descriptor.url}},{key:"links",get:function(){return this.descriptor.links}},{key:"dateExpires",get:function(){return this.descriptor.date_expires}},{key:"type",get:function(){return"stream"}},{key:"lastEventId",get:function(){return null}},{key:"indexName",get:function(){}},{key:"queryString",get:function(){}},{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return this.descriptor.unique_name||null}},{key:"publishMessage",value:function(){var n=et.default(fe.default.mark(function a(s){var o,u,l,c;return fe.default.wrap(function(f){for(;;)switch(f.prev=f.next){case 0:return o={data:s},f.next=3,this.services.network.post(this.links.messages,o);case 3:return u=f.sent,l=u.body,c=this._handleMessagePublished(l.sid,s,!1),f.abrupt("return",c);case 7:case"end":return f.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=et.default(fe.default.mark(function a(s){var o,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.prev=0,o={ttl:s},c.next=4,this.services.network.post(this.uri,o);case 4:u=c.sent,this.descriptor.date_expires=u.body.date_expires,c.next=12;break;case 8:throw c.prev=8,c.t0=c.catch(0),c.t0.status===404&&this.onRemoved(!1),c.t0;case 12:case"end":return c.stop()}},a,this,[[0,8]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeStream",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.network.delete(this.uri);case 2:this.onRemoved(!0);case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"_update",value:function(i){switch(i.type){case"stream_message_published":{this._handleMessagePublished(i.message_sid,i.message_data,!0);break}case"stream_removed":{this.onRemoved(!1);break}}}},{key:"_handleMessagePublished",value:function(i,a,s){var o={sid:i,data:a};return this.broadcastEventToListeners("messagePublished",{message:o,isLocal:!s}),o}},{key:"onRemoved",value:function(i){this._unsubscribe(),this.removalHandler(this.type,this.sid,this.uniqueName),this.broadcastEventToListeners("removed",{isLocal:i})}}],[{key:"type",get:function(){return"stream"}}]),r}(fd);hr([We.validateTypesAsync(We.pureObject),Ke("design:type",Function),Ke("design:paramtypes",[Object]),Ke("design:returntype",Promise)],vd.prototype,"publishMessage",null),hr([We.validateTypesAsync(We.nonNegativeInteger),Ke("design:type",Function),Ke("design:paramtypes",[Number]),Ke("design:returntype",Promise)],vd.prototype,"setTtl",null);var na=function(t){En.default(r,t);var e=Ox(r);function r(n){var i;return dr.default(this,r),i=e.call(this),i.syncStreamImpl=n,i.syncStreamImpl.attach(ra.default(i)),i}return yr.default(r,[{key:"uri",get:function(){return this.syncStreamImpl.uri}},{key:"links",get:function(){return this.syncStreamImpl.links}},{key:"dateExpires",get:function(){return this.syncStreamImpl.dateExpires}},{key:"type",get:function(){return vd.type}},{key:"lastEventId",get:function(){return null}},{key:"sid",get:function(){return this.syncStreamImpl.sid}},{key:"uniqueName",get:function(){return this.syncStreamImpl.uniqueName}},{key:"publishMessage",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncStreamImpl.publishMessage(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"setTtl",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return this.ensureNotClosed(),u.abrupt("return",this.syncStreamImpl.setTtl(s));case 2:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"removeStream",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return this.ensureNotClosed(),o.abrupt("return",this.syncStreamImpl.removeStream());case 2:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"close",value:function(){od.default(Zr.default(r.prototype),"close",this).call(this),this.syncStreamImpl.detach(this.listenerUuid)}}],[{key:"type",get:function(){return vd.type}}]),r}(hd);_r.default(na,"messagePublished","messagePublished"),_r.default(na,"removed","removed"),hr([We.validateTypesAsync(We.pureObject),Ke("design:type",Function),Ke("design:paramtypes",[Object]),Ke("design:returntype",Promise)],na.prototype,"publishMessage",null),hr([We.validateTypesAsync(We.nonNegativeInteger),Ke("design:type",Function),Ke("design:paramtypes",[Number]),Ke("design:returntype",Promise)],na.prototype,"setTtl",null);var mX=function t(e){dr.default(this,t),this.sdk="js",this.sdkVer=e,this.os=up.os.family,this.osVer=up.os.version,this.pl=up.name,this.plVer=up.version},yX=function(){function t(){dr.default(this,t),this.names=new Map,this.entities=new Map}return yr.default(t,[{key:"store",value:function(r){var n=this.entities.get(r.sid);return n||(this.entities.set(r.sid,r),r.uniqueName&&this.names.set(r.type+"::"+r.uniqueName,r.sid),r)}},{key:"getResolved",value:function(r,n){var i=this.names.get(n+"::"+r);return i?this.entities.get(i):null}},{key:"get",value:function(r,n){return this.entities.get(r)||this.getResolved(r,n)||null}},{key:"remove",value:function(r){var n=this.entities.get(r);n&&(this.entities.delete(r),n.uniqueName&&this.names.delete(n.type+"::"+n.uniqueName))}}]),t}();function bb(t){var e=bX();return function(){var n=Zr.default(t),i;if(e){var a=Zr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ks.default(this,i)}}function bX(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var wX=function t(){dr.default(this,t)},wb=function(t){En.default(r,t);var e=bb(r);function r(n,i,a,s){var o;return dr.default(this,r),o=e.call(this,i,a),o.descriptor=n,o.cache=new gb,s&&s.forEach(function(u){o.cache.store(u.key,{key:u.key,value:u.data},u.revision)}),o}return yr.default(r,[{key:"sid",get:function(){return this.descriptor.sid}},{key:"uniqueName",get:function(){return null}},{key:"type",get:function(){return r.type}},{key:"lastEventId",get:function(){return this.descriptor.last_event_id}},{key:"indexName",get:function(){return this.descriptor.indexName}},{key:"queryString",get:function(){return this.descriptor.queryExpression}},{key:"queryUri",get:function(){return this.descriptor.queryUri}},{key:"liveQueryDescriptor",get:function(){return this.descriptor}},{key:"onRemoved",value:function(){}},{key:"getItems",value:function(){var i={};return this.cache.forEach(function(a,s){i[a]=s.value}),i}},{key:"_update",value:function(i,a){switch(i.type){case"live_query_item_updated":this.handleItemMutated(i.item_key,i.item_data,i.item_revision);break;case"live_query_item_removed":this.handleItemRemoved(i.item_key,i.item_revision);break;case"live_query_updated":this.handleBatchUpdate(i.items);break}a&&this._advanceLastEventId(i.last_event_id)}},{key:"handleItemMutated",value:function(i,a,s){if(this.shouldIgnoreEvent(i,s))vr.trace("Item ".concat(i," update skipped, revision: ").concat(s));else{var o={key:i,value:a};this.cache.store(i,o,s),this.broadcastEventToListeners("itemUpdated",o)}}},{key:"handleItemRemoved",value:function(i,a){var s=a===null;this.shouldIgnoreEvent(i,a)?vr.trace("Item ".concat(i," delete skipped, revision: ").concat(a)):(this.cache.delete(i,a,s),this.broadcastEventToListeners("itemRemoved",{key:i}))}},{key:"handleBatchUpdate",value:function(i){var a=this,s={};i!=null&&i.forEach(function(u){s[u.key]={data:u.data,revision:u.revision}}),this.cache.forEach(function(u,l){var c=s[u];c!=null?a.handleItemMutated(u,c.data,c.revision):a.handleItemRemoved(u,null),delete s[u]});for(var o in s)this.handleItemMutated(o,s[o].data,s[o].revision)}},{key:"shouldIgnoreEvent",value:function(i,a){return i!=null&&a!=null&&this.cache.isKnown(i,a)}},{key:"_advanceLastEventId",value:function(i,a){this.lastEventId<i&&(this.descriptor.last_event_id=i)}}],[{key:"type",get:function(){return"live_query"}}]),r}(fd);function Px(t){return _b.apply(this,arguments)}function _b(){return _b=et.default(fe.default.mark(function t(e){var r,n,i,a,s,o;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:if(r=e.network,n=e.queryString,i=e.uri,a=e.type,n!=null){l.next=3;break}throw new Un("Invalid query",400,54507);case 3:return s={query_string:n},a===La.type&&(s.type=a),l.next=7,r.post(i,s,void 0,!0);case 7:return o=l.sent,l.abrupt("return",o.body);case 9:case"end":return l.stop()}},t)})),_b.apply(this,arguments)}var La=function(t){En.default(r,t);var e=bb(r);function r(n){var i;return dr.default(this,r),i=e.call(this),i.liveQueryImpl=n,i.liveQueryImpl.attach(ra.default(i)),i}return yr.default(r,[{key:"type",get:function(){return wb.type}},{key:"lastEventId",get:function(){return this.liveQueryImpl.lastEventId}},{key:"sid",get:function(){return this.liveQueryImpl.sid}},{key:"close",value:function(){od.default(Zr.default(r.prototype),"close",this).call(this),this.liveQueryImpl.detach(this.listenerUuid)}},{key:"getItems",value:function(){return this.ensureNotClosed(),this.liveQueryImpl.getItems()}}],[{key:"type",get:function(){return wb.type}}]),r}(hd);_r.default(La,"itemUpdated","itemUpdated"),_r.default(La,"itemRemoved","itemRemoved");var gd=function(t){En.default(r,t);var e=bb(r);function r(n){var i;return dr.default(this,r),i=e.call(this),_r.default(ra.default(i),"queryExpression",null),_r.default(ra.default(i),"items",{}),Object.assign(ra.default(i),n),i.updateIndexName(n.indexName),i}return yr.default(r,[{key:"type",get:function(){return r.type}},{key:"search",value:function(){var n=et.default(fe.default.mark(function a(s){var o=this;return fe.default.wrap(function(l){for(;;)switch(l.prev=l.next){case 0:return this.items={},l.abrupt("return",Px({network:this.network,uri:this.queryUri,queryString:s}).then(function(c){o.queryExpression=s,c.items&&c.items.forEach(function(d){o.items[d.key]=d.data}),o.emit("searchResult",o.getItems())}).catch(function(c){throw vr.error("Error '".concat(c.message,"' while executing query '").concat(s,"'")),o.queryExpression=null,c}));case 2:case"end":return l.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"subscribe",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:if(this.queryExpression!=null){o.next=2;break}return o.abrupt("return",Promise.reject(new Un("Invalid query",400,54507)));case 2:return o.abrupt("return",this.liveQueryCreator(this.indexName,this.queryExpression));case 3:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"getItems",value:function(){return this.items}},{key:"updateIndexName",value:function(i){this.indexName=i,this.queryUri=this.generateQueryUri(this.indexName)}},{key:"generateQueryUri",value:function(i){return new Zu(this.insightsUri).pathSegment(i).pathSegment("Items").build()}}],[{key:"type",get:function(){return"instant_query"}}]),r}(kr);_r.default(gd,"searchResult","searchResult"),hr([We.validateTypesAsync("string"),Ke("design:type",Function),Ke("design:paramtypes",[String]),Ke("design:returntype",Promise)],gd.prototype,"search",null),hr([We.validateTypes(We.nonEmptyString),Ke("design:type",Function),Ke("design:paramtypes",[String]),Ke("design:returntype",void 0)],gd.prototype,"updateIndexName",null);var _X="3.1.0";function kX(t){var e=SX();return function(){var n=Zr.default(t),i;if(e){var a=Zr.default(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return ks.default(this,i)}}function SX(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Mx(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),r.push.apply(r,n)}return r}function Nx(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Mx(Object(r),!0).forEach(function(n){_r.default(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Mx(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}var $X="data_sync",kb=_X;function lp(t){if(t){if(typeof t=="string")return{id:t,mode:"open_or_create"};var e=t.mode||(t.id?"open_or_create":"create_new");return Nx(Nx({},t),{},{mode:e})}else return{mode:"create_new"}}var Lx="com.twilio.rtd.cds.document",Dx="com.twilio.rtd.cds.list",jx="com.twilio.rtd.cds.map",Ux="twilio.sync.event",Yn=function(t){En.default(r,t);var e=kX(r);function r(n){var i,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(dr.default(this,r),i=e.call(this),!n)throw new Error("Sync library needs a valid Twilio token to be passed");a.hasOwnProperty("logLevel")?vr.setLevel(a.logLevel):vr.setLevel("silent");var s=a.productId=a.productId||$X;a.clientMetadata=a.clientMetadata||{},a.clientMetadata.hasOwnProperty("type")||(a.clientMetadata.type="sync"),a.clientMetadata.hasOwnProperty("sdk")||(a.clientMetadata.sdk="JS",a.clientMetadata.sdkv=kb);var o=!a.twilsockClient;if(!a.initRegistrations){var u=new op.InitRegistration(s);r.populateInitRegistrations(u),a.initRegistrations=[u]}var l=a.twilsockClient=a.twilsockClient||new op.Twilsock(n,s,a);l.on("tokenAboutToExpire",function(m){return i.emit("tokenAboutToExpire",m)}),l.on("tokenExpired",function(){return i.emit("tokenExpired")}),l.on("connectionError",function(m){return i.emit("connectionError",m)}),l.on("stateChanged",function(m){i.emit("connectionStateChanged",m),i.services.subscriptions.onConnectionStateChanged(m==="connected")}),l.on("message",function(m,k){return i._routeMessage(m,k)});var c=new VQ(a),d=new XQ(new mX(kb),c,l),f=new eX(c);return i.services={config:c,twilsock:l,network:d,storage:f,router:ra.default(i),subscriptions:null},i.services.subscriptions=new GQ(i.services),i.entities=new yX,o&&l.connect(),i}return yr.default(r,[{key:"_routeMessage",value:function(i,a){switch(vr.trace("Notification type:",i,"content:",a),i){case Lx:case Dx:case jx:this.services.subscriptions.acceptMessage(a,!1);break;case Ux:this.services.subscriptions.acceptMessage(a,!0);break}}},{key:"_subscribe",value:function(i,a){this.services.subscriptions.add(i,a)}},{key:"_unsubscribe",value:function(i){this.services.subscriptions.remove(i)}},{key:"connectionState",get:function(){return this.services.twilsock.state}},{key:"ensureReady",value:function(){var n=et.default(fe.default.mark(function a(){var s;return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:if(this.services.config.sessionStorageEnabled){u.next=2;break}return u.abrupt("return");case 2:return u.prev=2,u.next=5,this.services.twilsock.storageId();case 5:s=u.sent,this.services.storage.updateStorageId(s.id),u.next=12;break;case 9:u.prev=9,u.t0=u.catch(2),vr.warn("Failed to initialize storage",u.t0);case 12:case"end":return u.stop()}},a,this,[[2,9]])}));function i(){return n.apply(this,arguments)}return i}()},{key:"storeRootInSessionCache",value:function(i,a,s){if(!(!this.services.config.sessionStorageEnabled||!a)){var o=Ii(s);(i===Yr.type||i===tn.type)&&(o.last_event_id=null,delete o.items),this.services.storage.store(i,a,o)}}},{key:"readRootFromSessionCache",value:function(i,a){return!this.services.config.sessionStorageEnabled||!a?null:this.services.storage.read(i,a)}},{key:"_get",value:function(){var n=et.default(fe.default.mark(function a(s,o){var u,l,c,d=arguments;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:if(u=d.length>2&&d[2]!==void 0?d[2]:!1,o){m.next=3;break}throw new Un("Cannot get entity without id",404);case 3:return l=new Zu(s).pathSegment(o).queryParam("Include",u?"items":void 0).build(),m.next=6,this.services.network.get(l);case 6:return c=m.sent,m.abrupt("return",c.body);case 8:case"end":return m.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_createDocument",value:function(i,a,s){var o={unique_name:i,data:a||{}};return s!==void 0&&(o.ttl=s),this.services.network.post(this.services.config.documentsUri,o).then(function(u){return u.body.data=o.data,u.body})}},{key:"_getDocument",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(ai.type,s)||this._get(this.services.config.documentsUri,s));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createList",value:function(i,a,s,o){var u={unique_name:i,purpose:a,context:s};return o!==void 0&&(u.ttl=o),this.services.network.post(this.services.config.listsUri,u).then(function(l){return l.body})}},{key:"_getList",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(Yr.type,s)||this._get(this.services.config.listsUri,s));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createMap",value:function(i,a){var s={unique_name:i};return a!==void 0&&(s.ttl=a),this.services.network.post(this.services.config.mapsUri,s).then(function(o){return o.body})}},{key:"_getMap",value:function(){var n=et.default(fe.default.mark(function a(s){var o,u=arguments;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return o=u.length>1&&u[1]!==void 0?u[1]:!1,c.abrupt("return",this.readRootFromSessionCache(tn.type,s)||this._get(this.services.config.mapsUri,s,o));case 2:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_getStream",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.readRootFromSessionCache(na.type,s)||this._get(this.services.config.streamsUri,s,!1));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"_createStream",value:function(){var n=et.default(fe.default.mark(function a(s,o){var u,l;return fe.default.wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return u={unique_name:s},o!==void 0&&(u.ttl=o),d.next=4,this.services.network.post(this.services.config.streamsUri,u);case 4:return l=d.sent,d.abrupt("return",l.body);case 6:case"end":return d.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"_getLiveQuery",value:function(i){return this.readRootFromSessionCache(La.type,i)}},{key:"getCached",value:function(i,a){return i&&this.entities.get(i,a)||null}},{key:"removeFromCacheAndSession",value:function(i,a,s){this.entities.remove(a),this.services.config.sessionStorageEnabled&&this.services.storage.remove(i,a,s)}},{key:"document",value:function(){var n=et.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=lp(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createDocument(u.id,u.data,u.ttl);case 6:l=m.sent,m.next=39;break;case 9:if(c=this.getCached(u.id,ai.type),!c){m.next=14;break}return m.abrupt("return",new ai(c));case 14:return m.prev=14,m.next=17,this._getDocument(u.id);case 17:l=m.sent,m.next=39;break;case 20:if(m.prev=20,m.t0=m.catch(14),!(m.t0.status!==404||u.mode==="open_existing")){m.next=26;break}throw m.t0;case 26:return m.prev=26,m.next=29,this._createDocument(u.id,u.data,u.ttl);case 29:l=m.sent,m.next=39;break;case 32:if(m.prev=32,m.t1=m.catch(26),m.t1.status!==409){m.next=38;break}return m.abrupt("return",this.document(s));case 38:throw m.t1;case 39:return this.storeRootInSessionCache(ai.type,u.id,l),d=new hb(this.services,l,function(k,L,N){return o.removeFromCacheAndSession(k,L,N)}),d=this.entities.store(d),m.abrupt("return",new ai(d));case 43:case"end":return m.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"map",value:function(){var n=et.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=lp(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createMap(u.id,u.ttl);case 6:l=m.sent,m.next=39;break;case 9:if(c=this.getCached(u.id,tn.type),!c){m.next=14;break}return m.abrupt("return",new tn(c));case 14:return m.prev=14,m.next=17,this._getMap(u.id,u.includeItems);case 17:l=m.sent,m.next=39;break;case 20:if(m.prev=20,m.t0=m.catch(14),!(m.t0.status!==404||u.mode==="open_existing")){m.next=26;break}throw m.t0;case 26:return m.prev=26,m.next=29,this._createMap(u.id,u.ttl);case 29:l=m.sent,m.next=39;break;case 32:if(m.prev=32,m.t1=m.catch(26),m.t1.status!==409){m.next=38;break}return m.abrupt("return",this.map(s));case 38:throw m.t1;case 39:return this.storeRootInSessionCache(tn.type,u.id,l),d=new yb(this.services,l,function(k,L,N){return o.removeFromCacheAndSession(k,L,N)}),d=this.entities.store(d),m.abrupt("return",new tn(d));case 43:case"end":return m.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"list",value:function(){var n=et.default(fe.default.mark(function a(s){var o=this,u,l,c,d;return fe.default.wrap(function(m){for(;;)switch(m.prev=m.next){case 0:return m.next=2,this.ensureReady();case 2:if(u=lp(s),u.mode!=="create_new"){m.next=9;break}return m.next=6,this._createList(u.id,u.purpose,u.context,u.ttl);case 6:l=m.sent,m.next=39;break;case 9:if(c=this.getCached(u.id,Yr.type),!c){m.next=14;break}return m.abrupt("return",new Yr(c));case 14:return m.prev=14,m.next=17,this._getList(u.id);case 17:l=m.sent,m.next=39;break;case 20:if(m.prev=20,m.t0=m.catch(14),!(m.t0.status!==404||u.mode==="open_existing")){m.next=26;break}throw m.t0;case 26:return m.prev=26,m.next=29,this._createList(u.id,u.purpose,u.context,u.ttl);case 29:l=m.sent,m.next=39;break;case 32:if(m.prev=32,m.t1=m.catch(26),m.t1.status!==409){m.next=38;break}return m.abrupt("return",this.list(s));case 38:throw m.t1;case 39:return this.storeRootInSessionCache(Yr.type,u.id,l),d=new mb(this.services,l,function(k,L,N){return o.removeFromCacheAndSession(k,L,N)}),d=this.entities.store(d),m.abrupt("return",new Yr(d));case 43:case"end":return m.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"stream",value:function(){var n=et.default(fe.default.mark(function a(s){var o=this,u,l,c,d,f;return fe.default.wrap(function(k){for(;;)switch(k.prev=k.next){case 0:return k.next=2,this.ensureReady();case 2:if(u=lp(s),u.mode!=="create_new"){k.next=9;break}return k.next=6,this._createStream(u.id,u.ttl);case 6:l=k.sent,k.next=39;break;case 9:if(c=this.getCached(u.id,na.type),!c){k.next=14;break}return k.abrupt("return",new na(c));case 14:return k.prev=14,k.next=17,this._getStream(u.id);case 17:l=k.sent,k.next=39;break;case 20:if(k.prev=20,k.t0=k.catch(14),!(k.t0.status!==404||u.mode==="open_existing")){k.next=26;break}throw k.t0;case 26:return k.prev=26,k.next=29,this._createStream(u.id,u.ttl);case 29:l=k.sent,k.next=39;break;case 32:if(k.prev=32,k.t1=k.catch(26),k.t1.status!==409){k.next=38;break}return k.abrupt("return",this.stream(s));case 38:throw k.t1;case 39:return this.storeRootInSessionCache(na.type,u.id,l),d=function(N,z,re){return o.removeFromCacheAndSession(N,z,re)},f=new vd(this.services,l,d),f=this.entities.store(f),k.abrupt("return",new na(f));case 44:case"end":return k.stop()}},a,this,[[14,20],[26,32]])}));function i(a){return n.apply(this,arguments)}return i}()},{key:"shutdown",value:function(){var n=et.default(fe.default.mark(function a(){return fe.default.wrap(function(o){for(;;)switch(o.prev=o.next){case 0:return o.next=2,this.services.subscriptions.shutdown();case 2:return o.next=4,this.services.twilsock.disconnect();case 4:case"end":return o.stop()}},a,this)}));function i(){return n.apply(this,arguments)}return i}()},{key:"updateToken",value:function(){var n=et.default(fe.default.mark(function a(s){return fe.default.wrap(function(u){for(;;)switch(u.prev=u.next){case 0:return u.abrupt("return",this.services.twilsock.updateToken(s).catch(function(l){var c,d=l==null||(c=l.reply)===null||c===void 0?void 0:c.status;throw(d==null?void 0:d.code)===401&&(d==null?void 0:d.status)==="UNAUTHORIZED"?new Un("Updated token was rejected by server",400,51130):l}));case 1:case"end":return u.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()},{key:"liveQuery",value:function(){var n=et.default(fe.default.mark(function a(s,o){var u=this,l,c,d,f,m;return fe.default.wrap(function(L){for(;;)switch(L.prev=L.next){case 0:return L.next=2,this.ensureReady();case 2:return l=new Zu(this.services.config.insightsUri).pathSegment(s).pathSegment("Items").build(),L.next=5,Px({network:this.services.network,uri:l,queryString:o,type:La.type});case 5:return c=L.sent,d=this.getCached(c.query_id,La.type),d||(f=this._getLiveQuery(c.query_id),f||(f={indexName:s,queryExpression:o,sid:c.query_id,queryUri:l,last_event_id:c.last_event_id}),m=function(z,re,Me){return u.removeFromCacheAndSession(z,re,Me)},d=new wb(f,this.services,m,c.items)),this.storeRootInSessionCache(La.type,c.query_id,d.liveQueryDescriptor),d=this.entities.store(d),L.abrupt("return",new La(d));case 11:case"end":return L.stop()}},a,this)}));function i(a,s){return n.apply(this,arguments)}return i}()},{key:"instantQuery",value:function(){var n=et.default(fe.default.mark(function a(s){var o=this,u;return fe.default.wrap(function(c){for(;;)switch(c.prev=c.next){case 0:return c.next=2,this.ensureReady();case 2:return u=function(f,m){return o.liveQuery(f,m)},c.abrupt("return",new gd({indexName:s,network:this.services.network,insightsUri:this.services.config.insightsUri,liveQueryCreator:u}));case 4:case"end":return c.stop()}},a,this)}));function i(a){return n.apply(this,arguments)}return i}()}],[{key:"populateInitRegistrations",value:function(i){i.populateInitRegistrations([Ux,Lx,Dx,jx])}},{key:"version",get:function(){return kb}}]),r}(kr);_r.default(Yn,"connectionStateChanged","connectionStateChanged"),_r.default(Yn,"connectionError","connectionError"),_r.default(Yn,"tokenAboutToExpire","tokenAboutToExpire"),_r.default(Yn,"tokenExpired","tokenExpired"),hr([We.validateTypesAsync(["undefined","string",We.objectSchema("open document options",{id:["string","undefined"],mode:[We.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[We.nonNegativeInteger,"undefined"],data:[We.pureObject,"undefined",We.literal(null)]})]),Ke("design:type",Function),Ke("design:paramtypes",[Object]),Ke("design:returntype",Promise)],Yn.prototype,"document",null),hr([We.validateTypesAsync(["undefined","string",We.objectSchema("open map options",{id:["string","undefined"],mode:[We.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[We.nonNegativeInteger,"undefined"],data:[We.pureObject,"undefined",We.literal(null)],includeItems:["boolean","undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Object]),Ke("design:returntype",Promise)],Yn.prototype,"map",null),hr([We.validateTypesAsync(["undefined","string",We.objectSchema("open list options",{id:["string","undefined"],mode:[We.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[We.nonNegativeInteger,"undefined"],data:[We.pureObject,"undefined",We.literal(null)],purpose:["string","undefined"],context:[We.pureObject,"undefined"],includeItems:["boolean","undefined"]})]),Ke("design:type",Function),Ke("design:paramtypes",[Object]),Ke("design:returntype",Promise)],Yn.prototype,"list",null),hr([We.validateTypesAsync(["undefined","string",We.objectSchema("open stream options",{id:["string","undefined"],mode:[We.literal("open_or_create","open_existing","create_new"),"undefined"],ttl:[We.nonNegativeInteger,"undefined"],data:[We.pureObject,"undefined",We.literal(null)]})]),Ke("design:type",Function),Ke("design:paramtypes",[Object]),Ke("design:returntype",Promise)],Yn.prototype,"stream",null),hr([We.validateTypesAsync(We.nonEmptyString),Ke("design:type",Function),Ke("design:paramtypes",[String]),Ke("design:returntype",Promise)],Yn.prototype,"updateToken",null),hr([We.validateTypesAsync(We.nonEmptyString,"string"),Ke("design:type",Function),Ke("design:paramtypes",[String,String]),Ke("design:returntype",Promise)],Yn.prototype,"liveQuery",null),hr([We.validateTypesAsync(We.nonEmptyString),Ke("design:type",Function),Ke("design:paramtypes",[String]),Ke("design:returntype",Promise)],Yn.prototype,"instantQuery",null),jn.Client=Yn,jn.InsightsItem=wX,jn.InstantQuery=gd,jn.LiveQuery=La,jn.Paginator=vb,jn.SyncClient=Yn,jn.SyncDocument=ai,jn.SyncList=Yr,jn.SyncListItem=pb,jn.SyncMap=tn,jn.SyncMapItem=pd,jn.SyncStream=na;var Fx={},TX=Mr,CX=qi,EX=Cr,IX=EX("match"),xX=function(t){var e;return TX(t)&&((e=t[IX])!==void 0?!!e:CX(t)==="RegExp")},RX=xX,AX=TypeError,Bx=function(t){if(RX(t))throw new AX("The method doesn't accept regular expressions");return t},OX=Cr,PX=OX("match"),zx=function(t){var e=/./;try{"/./"[t](e)}catch{try{return e[PX]=!1,"/./"[t](e)}catch{}}return!1},MX=Xt,NX=Tg,LX=ma.f,DX=wa,Hx=Xr,jX=Bx,UX=Si,FX=zx,BX=NX("".slice),zX=Math.min,qx=FX("startsWith"),HX=!qx&&!!function(){var t=LX(String.prototype,"startsWith");return t&&!t.writable}();MX({target:"String",proto:!0,forced:!HX&&!qx},{startsWith:function(e){var r=Hx(UX(this));jX(e);var n=DX(zX(arguments.length>1?arguments[1]:void 0,r.length)),i=Hx(e);return BX(r,n,n+i.length)===i}});var qX=qt,VX=Cr,WX=xr,Vx=Y_,ZX=VX("iterator"),Wx=!qX(function(){var t=new URL("b?a=1&b=2&c=3","http://a"),e=t.searchParams,r=new URLSearchParams("a=1&a=2&b=3"),n="";return t.pathname="c%20d",e.forEach(function(i,a){e.delete("b"),n+=a+i}),r.delete("a",2),r.delete("b",void 0),Vx&&(!t.toJSON||!r.has("a",1)||r.has("a",2)||!r.has("a",void 0)||r.has("b"))||!e.size&&(Vx||!WX)||!e.sort||t.href!=="http://a/c%20d?a=1&c=3"||e.get("c")!=="3"||String(new URLSearchParams("?a=1"))!=="a=1"||!e[ZX]||new URL("https://a@b").username!=="a"||new URLSearchParams(new URLSearchParams("a=b")).get("a")!=="b"||new URL("http://тест").host!=="xn--e1aybc"||new URL("http://a#б").hash!=="#%D0%B1"||n!=="a1c3"||new URL("http://x",void 0).host!=="x"}),Io=Gt,Sb=2147483647,md=36,Zx=1,$b=26,GX=38,KX=700,YX=72,JX=128,QX="-",XX=/[^\0-\u007E]/,Gx=/[.\u3002\uFF0E\uFF61]/g,Kx="Overflow: input needs wider integers to process",Tb=md-Zx,Yx=RangeError,eee=Io(Gx.exec),Ku=Math.floor,Cb=String.fromCharCode,Jx=Io("".charCodeAt),Qx=Io([].join),$s=Io([].push),tee=Io("".replace),ree=Io("".split),nee=Io("".toLowerCase),iee=function(t){for(var e=[],r=0,n=t.length;r<n;){var i=Jx(t,r++);if(i>=55296&&i<=56319&&r<n){var a=Jx(t,r++);(a&64512)===56320?$s(e,((i&1023)<<10)+(a&1023)+65536):($s(e,i),r--)}else $s(e,i)}return e},Xx=function(t){return t+22+75*(t<26)},aee=function(t,e,r){var n=0;for(t=r?Ku(t/KX):t>>1,t+=Ku(t/e);t>Tb*$b>>1;)t=Ku(t/Tb),n+=md;return Ku(n+(Tb+1)*t/(t+GX))},see=function(t){var e=[];t=iee(t);var r=t.length,n=JX,i=0,a=YX,s,o;for(s=0;s<t.length;s++)o=t[s],o<128&&$s(e,Cb(o));var u=e.length,l=u;for(u&&$s(e,QX);l<r;){var c=Sb;for(s=0;s<t.length;s++)o=t[s],o>=n&&o<c&&(c=o);var d=l+1;if(c-n>Ku((Sb-i)/d))throw new Yx(Kx);for(i+=(c-n)*d,n=c,s=0;s<t.length;s++){if(o=t[s],o<n&&++i>Sb)throw new Yx(Kx);if(o===n){for(var f=i,m=md;;){var k=m<=a?Zx:m>=a+$b?$b:m-a;if(f<k)break;var L=f-k,N=md-k;$s(e,Cb(Xx(k+L%N))),f=Ku(L/N),m+=md}$s(e,Cb(Xx(f))),a=aee(i,d,l===u),i=0,l++}}i++,n++}return Qx(e,"")},oee=function(t){var e=[],r=ree(tee(nee(t),Gx,"."),"."),n,i;for(n=0;n<r.length;n++)i=r[n],$s(e,eee(XX,i)?"xn--"+see(i):i);return Qx(e,".")},Eb=Xt,cp=ur,Ib=bS,dp=$r,ia=Gt,yd=xr,eR=Wx,tR=Tn,uee=Ki,lee=Mh,cee=Zi,dee=P$,xb=Wn,rR=fs,Rb=Tr,fee=Hr,hee=ka,pee=_a,vee=Wr,nR=Mr,In=Xr,gee=os,iR=uo,aR=uh,mee=Fc,fp=hh,Yu=Vg,yee=Cr,bee=Jy,wee=yee("iterator"),Ju="URLSearchParams",sR=Ju+"Iterator",oR=xb.set,si=xb.getterFor(Ju),_ee=xb.getterFor(sR),uR=Ib("fetch"),hp=Ib("Request"),bd=Ib("Headers"),Ab=hp&&hp.prototype,lR=bd&&bd.prototype,kee=cp.RegExp,See=cp.TypeError,cR=cp.decodeURIComponent,$ee=cp.encodeURIComponent,Tee=ia("".charAt),dR=ia([].join),xo=ia([].push),Ob=ia("".replace),Cee=ia([].shift),fR=ia([].splice),hR=ia("".split),Eee=ia("".slice),Iee=/\+/g,pR=Array(4),xee=function(t){return pR[t-1]||(pR[t-1]=kee("((?:%[\\da-f]{2}){"+t+"})","gi"))},Ree=function(t){try{return cR(t)}catch{return t}},vR=function(t){var e=Ob(t,Iee," "),r=4;try{return cR(e)}catch{for(;r;)e=Ob(e,xee(r--),Ree);return e}},Aee=/[!'()~]|%20/g,Oee={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"},Pee=function(t){return Oee[t]},gR=function(t){return Ob($ee(t),Aee,Pee)},Pb=dee(function(e,r){oR(this,{type:sR,target:si(e).entries,index:0,kind:r})},Ju,function(){var e=_ee(this),r=e.target,n=e.index++;if(!r||n>=r.length)return e.target=void 0,fp(void 0,!0);var i=r[n];switch(e.kind){case"keys":return fp(i.key,!1);case"values":return fp(i.value,!1)}return fp([i.key,i.value],!1)},!0),mR=function(t){this.entries=[],this.url=null,t!==void 0&&(nR(t)?this.parseObject(t):this.parseQuery(typeof t=="string"?Tee(t,0)==="?"?Eee(t,1):t:In(t)))};mR.prototype={type:Ju,bindURL:function(t){this.url=t,this.update()},parseObject:function(t){var e=this.entries,r=mee(t),n,i,a,s,o,u,l;if(r)for(n=aR(t,r),i=n.next;!(a=dp(i,n)).done;){if(s=aR(vee(a.value)),o=s.next,(u=dp(o,s)).done||(l=dp(o,s)).done||!dp(o,s).done)throw new See("Expected sequence with length 2");xo(e,{key:In(u.value),value:In(l.value)})}else for(var c in t)fee(t,c)&&xo(e,{key:c,value:In(t[c])})},parseQuery:function(t){if(t)for(var e=this.entries,r=hR(t,"&"),n=0,i,a;n<r.length;)i=r[n++],i.length&&(a=hR(i,"="),xo(e,{key:vR(Cee(a)),value:vR(dR(a,"="))}))},serialize:function(){for(var t=this.entries,e=[],r=0,n;r<t.length;)n=t[r++],xo(e,gR(n.key)+"="+gR(n.value));return dR(e,"&")},update:function(){this.entries.length=0,this.parseQuery(this.url.query)},updateURL:function(){this.url&&this.url.update()}};var pp=function(){rR(this,Qu);var e=arguments.length>0?arguments[0]:void 0,r=oR(this,new mR(e));yd||(this.size=r.entries.length)},Qu=pp.prototype;if(lee(Qu,{append:function(e,r){var n=si(this);Yu(arguments.length,2),xo(n.entries,{key:In(e),value:In(r)}),yd||this.length++,n.updateURL()},delete:function(t){for(var e=si(this),r=Yu(arguments.length,1),n=e.entries,i=In(t),a=r<2?void 0:arguments[1],s=a===void 0?a:In(a),o=0;o<n.length;){var u=n[o];if(u.key===i&&(s===void 0||u.value===s)){if(fR(n,o,1),s!==void 0)break}else o++}yd||(this.size=n.length),e.updateURL()},get:function(e){var r=si(this).entries;Yu(arguments.length,1);for(var n=In(e),i=0;i<r.length;i++)if(r[i].key===n)return r[i].value;return null},getAll:function(e){var r=si(this).entries;Yu(arguments.length,1);for(var n=In(e),i=[],a=0;a<r.length;a++)r[a].key===n&&xo(i,r[a].value);return i},has:function(e){for(var r=si(this).entries,n=Yu(arguments.length,1),i=In(e),a=n<2?void 0:arguments[1],s=a===void 0?a:In(a),o=0;o<r.length;){var u=r[o++];if(u.key===i&&(s===void 0||u.value===s))return!0}return!1},set:function(e,r){var n=si(this);Yu(arguments.length,1);for(var i=n.entries,a=!1,s=In(e),o=In(r),u=0,l;u<i.length;u++)l=i[u],l.key===s&&(a?fR(i,u--,1):(a=!0,l.value=o));a||xo(i,{key:s,value:o}),yd||(this.size=i.length),n.updateURL()},sort:function(){var e=si(this);bee(e.entries,function(r,n){return r.key>n.key?1:-1}),e.updateURL()},forEach:function(e){for(var r=si(this).entries,n=hee(e,arguments.length>1?arguments[1]:void 0),i=0,a;i<r.length;)a=r[i++],n(a.value,a.key,this)},keys:function(){return new Pb(this,"keys")},values:function(){return new Pb(this,"values")},entries:function(){return new Pb(this,"entries")}},{enumerable:!0}),tR(Qu,wee,Qu.entries,{name:"entries"}),tR(Qu,"toString",function(){return si(this).serialize()},{enumerable:!0}),yd&&uee(Qu,"size",{get:function(){return si(this).entries.length},configurable:!0,enumerable:!0}),cee(pp,Ju),Eb({global:!0,constructor:!0,forced:!eR},{URLSearchParams:pp}),!eR&&Rb(bd)){var Mee=ia(lR.has),Nee=ia(lR.set),yR=function(t){if(nR(t)){var e=t.body,r;if(pee(e)===Ju)return r=t.headers?new bd(t.headers):new bd,Mee(r,"content-type")||Nee(r,"content-type","application/x-www-form-urlencoded;charset=UTF-8"),gee(t,{body:iR(0,In(e)),headers:iR(0,r)})}return t};if(Rb(uR)&&Eb({global:!0,enumerable:!0,dontCallGetSet:!0,forced:!0},{fetch:function(e){return uR(e,arguments.length>1?yR(arguments[1]):{})}}),Rb(hp)){var Mb=function(e){return rR(this,Ab),new hp(e,arguments.length>1?yR(arguments[1]):{})};Ab.constructor=Mb,Mb.prototype=Ab,Eb({global:!0,constructor:!0,dontCallGetSet:!0,forced:!0},{Request:Mb})}}var Lee={URLSearchParams:pp,getState:si},Dee=Xt,Nb=xr,jee=Wx,Lb=ur,bR=ka,oi=Gt,vp=Tn,ui=Ki,Uee=fs,Db=Hr,jb=tx,Xu=C$,xi=Gi,Fee=bm.codeAt,Bee=oee,Da=Xr,zee=Zi,Hee=Vg,wR=Lee,_R=Wn,qee=_R.set,gp=_R.getterFor("URL"),Vee=wR.URLSearchParams,Wee=wR.getState,wd=Lb.URL,Ub=Lb.TypeError,mp=Lb.parseInt,Zee=Math.floor,kR=Math.pow,li=oi("".charAt),Ri=oi(/./.exec),_d=oi([].join),Gee=oi(1 .toString),Kee=oi([].pop),el=oi([].push),Fb=oi("".replace),Yee=oi([].shift),Jee=oi("".split),kd=oi("".slice),yp=oi("".toLowerCase),Qee=oi([].unshift),Xee="Invalid authority",Bb="Invalid scheme",Ro="Invalid host",SR="Invalid port",$R=/[a-z]/i,ete=/[\d+-.a-z]/i,zb=/\d/,tte=/^0x/i,rte=/^[0-7]+$/,nte=/^\d+$/,TR=/^[\da-f]+$/i,ite=/[\0\t\n\r #%/:<>?@[\\\]^|]/,ate=/[\0\t\n\r #/:<>?@[\\\]^|]/,ste=/^[\u0000-\u0020]+/,ote=/(^|[^\u0000-\u0020])[\u0000-\u0020]+$/,ute=/[\t\n\r]/g,ci,lte=function(t){var e=Jee(t,"."),r,n,i,a,s,o,u;if(e.length&&e[e.length-1]===""&&e.length--,r=e.length,r>4)return t;for(n=[],i=0;i<r;i++){if(a=e[i],a==="")return t;if(s=10,a.length>1&&li(a,0)==="0"&&(s=Ri(tte,a)?16:8,a=kd(a,s===8?1:2)),a==="")o=0;else{if(!Ri(s===10?nte:s===8?rte:TR,a))return t;o=mp(a,s)}el(n,o)}for(i=0;i<r;i++)if(o=n[i],i===r-1){if(o>=kR(256,5-r))return null}else if(o>255)return null;for(u=Kee(n),i=0;i<n.length;i++)u+=n[i]*kR(256,3-i);return u},cte=function(t){var e=[0,0,0,0,0,0,0,0],r=0,n=null,i=0,a,s,o,u,l,c,d,f=function(){return li(t,i)};if(f()===":"){if(li(t,1)!==":")return;i+=2,r++,n=r}for(;f();){if(r===8)return;if(f()===":"){if(n!==null)return;i++,r++,n=r;continue}for(a=s=0;s<4&&Ri(TR,f());)a=a*16+mp(f(),16),i++,s++;if(f()==="."){if(s===0||(i-=s,r>6))return;for(o=0;f();){if(u=null,o>0)if(f()==="."&&o<4)i++;else return;if(!Ri(zb,f()))return;for(;Ri(zb,f());){if(l=mp(f(),10),u===null)u=l;else{if(u===0)return;u=u*10+l}if(u>255)return;i++}e[r]=e[r]*256+u,o++,(o===2||o===4)&&r++}if(o!==4)return;break}else if(f()===":"){if(i++,!f())return}else if(f())return;e[r++]=a}if(n!==null)for(c=r-n,r=7;r!==0&&c>0;)d=e[r],e[r--]=e[n+c-1],e[n+--c]=d;else if(r!==8)return;return e},dte=function(t){for(var e=null,r=1,n=null,i=0,a=0;a<8;a++)t[a]!==0?(i>r&&(e=n,r=i),n=null,i=0):(n===null&&(n=a),++i);return i>r&&(e=n,r=i),e},Sd=function(t){var e,r,n,i;if(typeof t=="number"){for(e=[],r=0;r<4;r++)Qee(e,t%256),t=Zee(t/256);return _d(e,".")}else if(typeof t=="object"){for(e="",n=dte(t),r=0;r<8;r++)i&&t[r]===0||(i&&(i=!1),n===r?(e+=r?":":"::",i=!0):(e+=Gee(t[r],16),r<7&&(e+=":")));return"["+e+"]"}return t},bp={},CR=jb({},bp,{" ":1,'"':1,"<":1,">":1,"`":1}),ER=jb({},CR,{"#":1,"?":1,"{":1,"}":1}),Hb=jb({},ER,{"/":1,":":1,";":1,"=":1,"@":1,"[":1,"\\":1,"]":1,"^":1,"|":1}),Ts=function(t,e){var r=Fee(t,0);return r>32&&r<127&&!Db(e,t)?t:encodeURIComponent(t)},wp={ftp:21,file:null,http:80,https:443,ws:80,wss:443},$d=function(t,e){var r;return t.length===2&&Ri($R,li(t,0))&&((r=li(t,1))===":"||!e&&r==="|")},IR=function(t){var e;return t.length>1&&$d(kd(t,0,2))&&(t.length===2||(e=li(t,2))==="/"||e==="\\"||e==="?"||e==="#")},fte=function(t){return t==="."||yp(t)==="%2e"},hte=function(t){return t=yp(t),t===".."||t==="%2e."||t===".%2e"||t==="%2e%2e"},qb={},xR={},Vb={},RR={},AR={},Wb={},OR={},PR={},_p={},kp={},Zb={},Gb={},Kb={},Yb={},MR={},Jb={},tl={},aa={},NR={},Ao={},ja={},Qb=function(t,e,r){var n=Da(t),i,a,s;if(e){if(a=this.parse(n),a)throw new Ub(a);this.searchParams=null}else{if(r!==void 0&&(i=new Qb(r,!0)),a=this.parse(n,null,i),a)throw new Ub(a);s=Wee(new Vee),s.bindURL(this),this.searchParams=s}};Qb.prototype={type:"URL",parse:function(t,e,r){var n=this,i=e||qb,a=0,s="",o=!1,u=!1,l=!1,c,d,f,m;for(t=Da(t),e||(n.scheme="",n.username="",n.password="",n.host=null,n.port=null,n.path=[],n.query=null,n.fragment=null,n.cannotBeABaseURL=!1,t=Fb(t,ste,""),t=Fb(t,ote,"$1")),t=Fb(t,ute,""),c=Xu(t);a<=c.length;){switch(d=c[a],i){case qb:if(d&&Ri($R,d))s+=yp(d),i=xR;else{if(e)return Bb;i=Vb;continue}break;case xR:if(d&&(Ri(ete,d)||d==="+"||d==="-"||d==="."))s+=yp(d);else if(d===":"){if(e&&(n.isSpecial()!==Db(wp,s)||s==="file"&&(n.includesCredentials()||n.port!==null)||n.scheme==="file"&&!n.host))return;if(n.scheme=s,e){n.isSpecial()&&wp[n.scheme]===n.port&&(n.port=null);return}s="",n.scheme==="file"?i=Yb:n.isSpecial()&&r&&r.scheme===n.scheme?i=RR:n.isSpecial()?i=PR:c[a+1]==="/"?(i=AR,a++):(n.cannotBeABaseURL=!0,el(n.path,""),i=NR)}else{if(e)return Bb;s="",i=Vb,a=0;continue}break;case Vb:if(!r||r.cannotBeABaseURL&&d!=="#")return Bb;if(r.cannotBeABaseURL&&d==="#"){n.scheme=r.scheme,n.path=xi(r.path),n.query=r.query,n.fragment="",n.cannotBeABaseURL=!0,i=ja;break}i=r.scheme==="file"?Yb:Wb;continue;case RR:if(d==="/"&&c[a+1]==="/")i=_p,a++;else{i=Wb;continue}break;case AR:if(d==="/"){i=kp;break}else{i=aa;continue}case Wb:if(n.scheme=r.scheme,d===ci)n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=xi(r.path),n.query=r.query;else if(d==="/"||d==="\\"&&n.isSpecial())i=OR;else if(d==="?")n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=xi(r.path),n.query="",i=Ao;else if(d==="#")n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=xi(r.path),n.query=r.query,n.fragment="",i=ja;else{n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,n.path=xi(r.path),n.path.length--,i=aa;continue}break;case OR:if(n.isSpecial()&&(d==="/"||d==="\\"))i=_p;else if(d==="/")i=kp;else{n.username=r.username,n.password=r.password,n.host=r.host,n.port=r.port,i=aa;continue}break;case PR:if(i=_p,d!=="/"||li(s,a+1)!=="/")continue;a++;break;case _p:if(d!=="/"&&d!=="\\"){i=kp;continue}break;case kp:if(d==="@"){o&&(s="%40"+s),o=!0,f=Xu(s);for(var k=0;k<f.length;k++){var L=f[k];if(L===":"&&!l){l=!0;continue}var N=Ts(L,Hb);l?n.password+=N:n.username+=N}s=""}else if(d===ci||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()){if(o&&s==="")return Xee;a-=Xu(s).length+1,s="",i=Zb}else s+=d;break;case Zb:case Gb:if(e&&n.scheme==="file"){i=Jb;continue}else if(d===":"&&!u){if(s==="")return Ro;if(m=n.parseHost(s),m)return m;if(s="",i=Kb,e===Gb)return}else if(d===ci||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()){if(n.isSpecial()&&s==="")return Ro;if(e&&s===""&&(n.includesCredentials()||n.port!==null))return;if(m=n.parseHost(s),m)return m;if(s="",i=tl,e)return;continue}else d==="["?u=!0:d==="]"&&(u=!1),s+=d;break;case Kb:if(Ri(zb,d))s+=d;else if(d===ci||d==="/"||d==="?"||d==="#"||d==="\\"&&n.isSpecial()||e){if(s!==""){var z=mp(s,10);if(z>65535)return SR;n.port=n.isSpecial()&&z===wp[n.scheme]?null:z,s=""}if(e)return;i=tl;continue}else return SR;break;case Yb:if(n.scheme="file",d==="/"||d==="\\")i=MR;else if(r&&r.scheme==="file")switch(d){case ci:n.host=r.host,n.path=xi(r.path),n.query=r.query;break;case"?":n.host=r.host,n.path=xi(r.path),n.query="",i=Ao;break;case"#":n.host=r.host,n.path=xi(r.path),n.query=r.query,n.fragment="",i=ja;break;default:IR(_d(xi(c,a),""))||(n.host=r.host,n.path=xi(r.path),n.shortenPath()),i=aa;continue}else{i=aa;continue}break;case MR:if(d==="/"||d==="\\"){i=Jb;break}r&&r.scheme==="file"&&!IR(_d(xi(c,a),""))&&($d(r.path[0],!0)?el(n.path,r.path[0]):n.host=r.host),i=aa;continue;case Jb:if(d===ci||d==="/"||d==="\\"||d==="?"||d==="#"){if(!e&&$d(s))i=aa;else if(s===""){if(n.host="",e)return;i=tl}else{if(m=n.parseHost(s),m)return m;if(n.host==="localhost"&&(n.host=""),e)return;s="",i=tl}continue}else s+=d;break;case tl:if(n.isSpecial()){if(i=aa,d!=="/"&&d!=="\\")continue}else if(!e&&d==="?")n.query="",i=Ao;else if(!e&&d==="#")n.fragment="",i=ja;else if(d!==ci&&(i=aa,d!=="/"))continue;break;case aa:if(d===ci||d==="/"||d==="\\"&&n.isSpecial()||!e&&(d==="?"||d==="#")){if(hte(s)?(n.shortenPath(),d!=="/"&&!(d==="\\"&&n.isSpecial())&&el(n.path,"")):fte(s)?d!=="/"&&!(d==="\\"&&n.isSpecial())&&el(n.path,""):(n.scheme==="file"&&!n.path.length&&$d(s)&&(n.host&&(n.host=""),s=li(s,0)+":"),el(n.path,s)),s="",n.scheme==="file"&&(d===ci||d==="?"||d==="#"))for(;n.path.length>1&&n.path[0]==="";)Yee(n.path);d==="?"?(n.query="",i=Ao):d==="#"&&(n.fragment="",i=ja)}else s+=Ts(d,ER);break;case NR:d==="?"?(n.query="",i=Ao):d==="#"?(n.fragment="",i=ja):d!==ci&&(n.path[0]+=Ts(d,bp));break;case Ao:!e&&d==="#"?(n.fragment="",i=ja):d!==ci&&(d==="'"&&n.isSpecial()?n.query+="%27":d==="#"?n.query+="%23":n.query+=Ts(d,bp));break;case ja:d!==ci&&(n.fragment+=Ts(d,CR));break}a++}},parseHost:function(t){var e,r,n;if(li(t,0)==="["){if(li(t,t.length-1)!=="]"||(e=cte(kd(t,1,-1)),!e))return Ro;this.host=e}else if(this.isSpecial()){if(t=Bee(t),Ri(ite,t)||(e=lte(t),e===null))return Ro;this.host=e}else{if(Ri(ate,t))return Ro;for(e="",r=Xu(t),n=0;n<r.length;n++)e+=Ts(r[n],bp);this.host=e}},cannotHaveUsernamePasswordPort:function(){return!this.host||this.cannotBeABaseURL||this.scheme==="file"},includesCredentials:function(){return this.username!==""||this.password!==""},isSpecial:function(){return Db(wp,this.scheme)},shortenPath:function(){var t=this.path,e=t.length;e&&(this.scheme!=="file"||e!==1||!$d(t[0],!0))&&t.length--},serialize:function(){var t=this,e=t.scheme,r=t.username,n=t.password,i=t.host,a=t.port,s=t.path,o=t.query,u=t.fragment,l=e+":";return i!==null?(l+="//",t.includesCredentials()&&(l+=r+(n?":"+n:"")+"@"),l+=Sd(i),a!==null&&(l+=":"+a)):e==="file"&&(l+="//"),l+=t.cannotBeABaseURL?s[0]:s.length?"/"+_d(s,"/"):"",o!==null&&(l+="?"+o),u!==null&&(l+="#"+u),l},setHref:function(t){var e=this.parse(t);if(e)throw new Ub(e);this.searchParams.update()},getOrigin:function(){var t=this.scheme,e=this.port;if(t==="blob")try{return new rl(t.path[0]).origin}catch{return"null"}return t==="file"||!this.isSpecial()?"null":t+"://"+Sd(this.host)+(e!==null?":"+e:"")},getProtocol:function(){return this.scheme+":"},setProtocol:function(t){this.parse(Da(t)+":",qb)},getUsername:function(){return this.username},setUsername:function(t){var e=Xu(Da(t));if(!this.cannotHaveUsernamePasswordPort()){this.username="";for(var r=0;r<e.length;r++)this.username+=Ts(e[r],Hb)}},getPassword:function(){return this.password},setPassword:function(t){var e=Xu(Da(t));if(!this.cannotHaveUsernamePasswordPort()){this.password="";for(var r=0;r<e.length;r++)this.password+=Ts(e[r],Hb)}},getHost:function(){var t=this.host,e=this.port;return t===null?"":e===null?Sd(t):Sd(t)+":"+e},setHost:function(t){this.cannotBeABaseURL||this.parse(t,Zb)},getHostname:function(){var t=this.host;return t===null?"":Sd(t)},setHostname:function(t){this.cannotBeABaseURL||this.parse(t,Gb)},getPort:function(){var t=this.port;return t===null?"":Da(t)},setPort:function(t){this.cannotHaveUsernamePasswordPort()||(t=Da(t),t===""?this.port=null:this.parse(t,Kb))},getPathname:function(){var t=this.path;return this.cannotBeABaseURL?t[0]:t.length?"/"+_d(t,"/"):""},setPathname:function(t){this.cannotBeABaseURL||(this.path=[],this.parse(t,tl))},getSearch:function(){var t=this.query;return t?"?"+t:""},setSearch:function(t){t=Da(t),t===""?this.query=null:(li(t,0)==="?"&&(t=kd(t,1)),this.query="",this.parse(t,Ao)),this.searchParams.update()},getSearchParams:function(){return this.searchParams.facade},getHash:function(){var t=this.fragment;return t?"#"+t:""},setHash:function(t){if(t=Da(t),t===""){this.fragment=null;return}li(t,0)==="#"&&(t=kd(t,1)),this.fragment="",this.parse(t,ja)},update:function(){this.query=this.searchParams.serialize()||null}};var rl=function(e){var r=Uee(this,xn),n=Hee(arguments.length,1)>1?arguments[1]:void 0,i=qee(r,new Qb(e,!1,n));Nb||(r.href=i.serialize(),r.origin=i.getOrigin(),r.protocol=i.getProtocol(),r.username=i.getUsername(),r.password=i.getPassword(),r.host=i.getHost(),r.hostname=i.getHostname(),r.port=i.getPort(),r.pathname=i.getPathname(),r.search=i.getSearch(),r.searchParams=i.getSearchParams(),r.hash=i.getHash())},xn=rl.prototype,di=function(t,e){return{get:function(){return gp(this)[t]()},set:e&&function(r){return gp(this)[e](r)},configurable:!0,enumerable:!0}};if(Nb&&(ui(xn,"href",di("serialize","setHref")),ui(xn,"origin",di("getOrigin")),ui(xn,"protocol",di("getProtocol","setProtocol")),ui(xn,"username",di("getUsername","setUsername")),ui(xn,"password",di("getPassword","setPassword")),ui(xn,"host",di("getHost","setHost")),ui(xn,"hostname",di("getHostname","setHostname")),ui(xn,"port",di("getPort","setPort")),ui(xn,"pathname",di("getPathname","setPathname")),ui(xn,"search",di("getSearch","setSearch")),ui(xn,"searchParams",di("getSearchParams")),ui(xn,"hash",di("getHash","setHash"))),vp(xn,"toJSON",function(){return gp(this).serialize()},{enumerable:!0}),vp(xn,"toString",function(){return gp(this).serialize()},{enumerable:!0}),wd){var LR=wd.createObjectURL,DR=wd.revokeObjectURL;LR&&vp(rl,"createObjectURL",bR(LR,wd)),DR&&vp(rl,"revokeObjectURL",bR(DR,wd))}zee(rl,"URL"),Dee({global:!0,constructor:!0,forced:!jee,sham:!Nb},{URL:rl});/*
@@ -1165,9 +1165,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1165
1165
  OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
1166
1166
  CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1167
1167
 
1168
- */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Qi,n=$a,i=Yi,a=Ji,s=ii,o=ad,u=ds,l=ku,c=Au,d=ni,f=Ou,m=Xi,k=en;function L(K){return K&&typeof K=="object"&&"default"in K?K:{default:K}}function N(K){if(K&&K.__esModule)return K;var he=Object.create(null);return K&&Object.keys(K).forEach(function(G){if(G!=="default"){var de=Object.getOwnPropertyDescriptor(K,G);Object.defineProperty(he,G,de.get?de:{enumerable:!0,get:function(){return K[G]}})}}),he.default=K,Object.freeze(he)}var z=L(r),re=L(n),Me=L(i),Oe=L(a),Be=L(s),Pe=L(o),Ze=L(u),Z=L(l),Ie=L(c),_e=L(d),se=N(f),Te={exports:{}},te=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(te){var oe=new Uint8Array(16);Te.exports=function(){return te(oe),oe}}else{var q=new Array(16);Te.exports=function(){for(var he=0,G;he<16;he++)he&3||(G=Math.random()*4294967296),q[he]=G>>>((he&3)<<3)&255;return q}}for(var ne=[],Se=0;Se<256;++Se)ne[Se]=(Se+256).toString(16).substr(1);function H(K,he){var G=he||0,de=ne;return[de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]]].join("")}var ye=H,ke=Te.exports,P=ye,Qe,Ct,tt=0,De=0;function ce(K,he,G){var de=he&&G||0,X=he||[];K=K||{};var Ye=K.node||Qe,ze=K.clockseq!==void 0?K.clockseq:Ct;if(Ye==null||ze==null){var ct=ke();Ye==null&&(Ye=Qe=[ct[0]|1,ct[1],ct[2],ct[3],ct[4],ct[5]]),ze==null&&(ze=Ct=(ct[6]<<8|ct[7])&16383)}var ut=K.msecs!==void 0?K.msecs:new Date().getTime(),ft=K.nsecs!==void 0?K.nsecs:De+1,Et=ut-tt+(ft-De)/1e4;if(Et<0&&K.clockseq===void 0&&(ze=ze+1&16383),(Et<0||ut>tt)&&K.nsecs===void 0&&(ft=0),ft>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");tt=ut,De=ft,Ct=ze,ut+=122192928e5;var It=((ut&268435455)*1e4+ft)%4294967296;X[de++]=It>>>24&255,X[de++]=It>>>16&255,X[de++]=It>>>8&255,X[de++]=It&255;var _t=ut/4294967296*1e4&268435455;X[de++]=_t>>>8&255,X[de++]=_t&255,X[de++]=_t>>>24&15|16,X[de++]=_t>>>16&255,X[de++]=ze>>>8|128,X[de++]=ze&255;for(var St=0;St<6;++St)X[de+St]=Ye[St];return he||P(X)}var Ge=ce,Ue=Te.exports,be=ye;function ht(K,he,G){var de=he&&G||0;typeof K=="string"&&(he=K==="binary"?new Array(16):null,K=null),K=K||{};var X=K.random||(K.rng||Ue)();if(X[6]=X[6]&15|64,X[8]=X[8]&63|128,he)for(var Ye=0;Ye<16;++Ye)he[de+Ye]=X[Ye];return he||be(X)}var Ve=ht,Kt=Ge,Rt=Ve,Q=Rt;Q.v1=Kt,Q.v4=Rt;var je=Q;function st(K){var he=Re();return function(){var de=Be.default(K),X;if(he){var Ye=Be.default(this).constructor;X=Reflect.construct(de,arguments,Ye)}else X=de.apply(this,arguments);return Oe.default(this,X)}}function Re(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var kt=function(K){Me.default(G,K);var he=st(G);function G(de){var X;z.default(this,G);var Ye=je.v4(),ze;return X=he.call(this,function(ct,ut){return ze=ut,de(function(ft){G.cancellationMap.delete(Ye),ct(ft)},function(ft){G.cancellationMap.delete(Ye),ut(ft)},function(ft){G.cancellationMap.set(Ye,ft)})}),X.id=Ye,X.rejectPromise=ze,X}return re.default(G,[{key:"cancel",value:function(){var X=G.cancellationMap.get(this.id);return X==null||X(),this.rejectPromise&&(this.catch(function(){}),this.rejectPromise(new Error("Promise was cancelled"))),this}}]),G}(Pe.default(Promise));Ze.default(kt,"cancellationMap",new Map);function ot(K,he,G,de){var X=arguments.length,Ye=X<3?he:de===null?de=Object.getOwnPropertyDescriptor(he,G):de,ze;if((typeof Reflect>"u"?"undefined":_e.default(Reflect))==="object"&&typeof Reflect.decorate=="function")Ye=Reflect.decorate(K,he,G,de);else for(var ct=K.length-1;ct>=0;ct--)(ze=K[ct])&&(Ye=(X<3?ze(Ye):X>3?ze(he,G,Ye):ze(he,G))||Ye);return X>3&&Ye&&Object.defineProperty(he,G,Ye),Ye}function ar(K,he){if((typeof Reflect>"u"?"undefined":_e.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(K,he)}function mr(K,he){return["".concat(new Date().toISOString()," MCS Client ").concat(K,":")].concat(Array.from(he))}var Xe=function(){function K(he){z.default(this,K),Ze.default(this,"prefix",""),this.prefix=he!=null&&he.length>0?he+" ":""}return re.default(K,[{key:"setLevel",value:function(G){se.setLevel(G)}},{key:"trace",value:function(){if(se.getLevel()==se.levels.TRACE){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.debug.apply(null,mr(this.prefix+"T",de))}}},{key:"debug",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.debug.apply(null,mr(this.prefix+"D",de))}},{key:"info",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.info.apply(null,mr(this.prefix+"I",de))}},{key:"warn",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.warn.apply(null,mr(this.prefix+"W",de))}},{key:"error",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.error.apply(null,mr(this.prefix+"E",de))}}],[{key:"scope",value:function(G){return new K(G)}},{key:"setLevel",value:function(G){se.setLevel(G)}},{key:"trace",value:function(){if(se.getLevel()==se.levels.TRACE){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.debug.apply(null,mr("T",de))}}},{key:"debug",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.debug.apply(null,mr("D",de))}},{key:"info",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.info.apply(null,mr("I",de))}},{key:"warn",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.warn.apply(null,mr("W",de))}},{key:"error",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.error.apply(null,mr("E",de))}}]),K}(),Or=1e3,jr=4e3,lr=3,cr=!0,Vt=function(he){return"https://mcs.".concat(he??"us1",".twilio.com")},At=function(he){return he.startsWith("http")},M=function(he,G){return"".concat(At(he)?"":Vt(G)).concat(he)},V=function(){function K(he,G,de,X){var Ye,ze,ct,ut,ft,Et;z.default(this,K);var It=(Ye=(ze=X.MCS)!==null&&ze!==void 0?ze:X)!==null&&Ye!==void 0?Ye:{};this.region=(ct=(ut=It.region)!==null&&ut!==void 0?ut:X.region)!==null&&ct!==void 0?ct:"us1",this.mediaUrl=M(G,this.region),this.mediaSetUrl=de?M(de):"".concat(this.mediaUrl,"Set"),this.token=he,this.retryWhenThrottledOverride=(ft=It.retryWhenThrottledOverride)!==null&&ft!==void 0?ft:cr,this.backoffConfigOverride=(Et=It.backoffConfigOverride)!==null&&Et!==void 0?Et:K.backoffConfigDefault}return re.default(K,[{key:"updateToken",value:function(G){this.token=G}}],[{key:"backoffConfigDefault",get:function(){return{min:Or,max:jr,maxAttemptsCount:lr}}},{key:"retryWhenThrottledDefault",get:function(){return cr}}]),K}(),ie=function(){function K(he,G,de){z.default(this,K),this.config=he,this.network=G,this._update(de)}return re.default(K,[{key:"sid",get:function(){return this.state.sid}},{key:"serviceSid",get:function(){return this.state.serviceSid}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"fileName",get:function(){return this.state.filename}},{key:"filename",get:function(){return this.state.filename}},{key:"category",get:function(){return this.state.category}},{key:"getContentUrl",value:function(){var G=this;return new kt(function(){var de=Z.default(Ie.default.mark(function X(Ye,ze,ct){var ut,ft;return Ie.default.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return ut=G.network.get("".concat(G.config.mediaUrl,"/").concat(G.sid)),ct(function(){return ut.cancel()}),It.prev=2,It.next=5,ut;case 5:ft=It.sent,G._update(ft.body),Ye(G.state.contentDirectUrl),It.next=13;break;case 10:It.prev=10,It.t0=It.catch(2),ze(It.t0);case 13:case"end":return It.stop()}},X,null,[[2,10]])}));return function(X,Ye,ze){return de.apply(this,arguments)}}())}},{key:"_update",value:function(G){var de,X,Ye,ze;this.state={sid:G.sid,serviceSid:G.service_sid,channelSid:G.channel_sid,messageSid:G.message_sid,dateCreated:G.date_created?new Date(G.date_created):null,dateUploadUpdated:G.date_upload_updated?new Date(G.date_upload_updated):null,dateUpdated:G.date_updated?new Date(G.date_updated):null,size:G.size,contentType:G.content_type,author:G.author,url:G.url,contentUrl:G.links.content,contentDirectUrl:(de=G.links.content_direct_temporary)!==null&&de!==void 0?de:null,filename:(X=G.filename)!==null&&X!==void 0?X:null,category:(Ye=G.category)!==null&&Ye!==void 0?Ye:"media",isMultipartUpstream:(ze=G.is_multipart_upstream)!==null&&ze!==void 0?ze:!1}}},{key:"_state",value:function(){var G;return{sid:this.state.sid,category:this.state.category,filename:(G=this.state.filename)!==null&&G!==void 0?G:null,contentType:this.state.contentType,size:this.state.size}}}]),K}();function Fe(K){var he=lt();return function(){var de=Be.default(K),X;if(he){var Ye=Be.default(this).constructor;X=Reflect.construct(de,arguments,Ye)}else X=de.apply(this,arguments);return Oe.default(this,X)}}function lt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var yt=function(K){Me.default(G,K);var he=Fe(G);function G(de,X,Ye,ze,ct){var ut;return z.default(this,G),ut=he.call(this,de),ut.code=X,ut.body=Ye,ut.status=ze,ut.headers=ct,ut}return re.default(G)}(Pe.default(Error)),Bt=e.XMLHttpRequest||{};function er(K){return K?K.split(`\r
1168
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=Qi,n=$a,i=Yi,a=Ji,s=ii,o=ad,u=ds,l=ku,c=Au,d=ni,f=Ou,m=Xi,k=en;function L(K){return K&&typeof K=="object"&&"default"in K?K:{default:K}}function N(K){if(K&&K.__esModule)return K;var he=Object.create(null);return K&&Object.keys(K).forEach(function(G){if(G!=="default"){var de=Object.getOwnPropertyDescriptor(K,G);Object.defineProperty(he,G,de.get?de:{enumerable:!0,get:function(){return K[G]}})}}),he.default=K,Object.freeze(he)}var z=L(r),re=L(n),Me=L(i),Oe=L(a),Fe=L(s),Pe=L(o),Ze=L(u),Z=L(l),Ie=L(c),_e=L(d),se=N(f),Te={exports:{}},te=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||typeof msCrypto<"u"&&typeof window.msCrypto.getRandomValues=="function"&&msCrypto.getRandomValues.bind(msCrypto);if(te){var oe=new Uint8Array(16);Te.exports=function(){return te(oe),oe}}else{var q=new Array(16);Te.exports=function(){for(var he=0,G;he<16;he++)he&3||(G=Math.random()*4294967296),q[he]=G>>>((he&3)<<3)&255;return q}}for(var ne=[],Se=0;Se<256;++Se)ne[Se]=(Se+256).toString(16).substr(1);function H(K,he){var G=he||0,de=ne;return[de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],"-",de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]],de[K[G++]]].join("")}var ye=H,ke=Te.exports,P=ye,Qe,Ct,tt=0,De=0;function ce(K,he,G){var de=he&&G||0,X=he||[];K=K||{};var Ye=K.node||Qe,ze=K.clockseq!==void 0?K.clockseq:Ct;if(Ye==null||ze==null){var ct=ke();Ye==null&&(Ye=Qe=[ct[0]|1,ct[1],ct[2],ct[3],ct[4],ct[5]]),ze==null&&(ze=Ct=(ct[6]<<8|ct[7])&16383)}var ut=K.msecs!==void 0?K.msecs:new Date().getTime(),ft=K.nsecs!==void 0?K.nsecs:De+1,Et=ut-tt+(ft-De)/1e4;if(Et<0&&K.clockseq===void 0&&(ze=ze+1&16383),(Et<0||ut>tt)&&K.nsecs===void 0&&(ft=0),ft>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");tt=ut,De=ft,Ct=ze,ut+=122192928e5;var It=((ut&268435455)*1e4+ft)%4294967296;X[de++]=It>>>24&255,X[de++]=It>>>16&255,X[de++]=It>>>8&255,X[de++]=It&255;var _t=ut/4294967296*1e4&268435455;X[de++]=_t>>>8&255,X[de++]=_t&255,X[de++]=_t>>>24&15|16,X[de++]=_t>>>16&255,X[de++]=ze>>>8|128,X[de++]=ze&255;for(var St=0;St<6;++St)X[de+St]=Ye[St];return he||P(X)}var Ge=ce,Ue=Te.exports,be=ye;function ht(K,he,G){var de=he&&G||0;typeof K=="string"&&(he=K==="binary"?new Array(16):null,K=null),K=K||{};var X=K.random||(K.rng||Ue)();if(X[6]=X[6]&15|64,X[8]=X[8]&63|128,he)for(var Ye=0;Ye<16;++Ye)he[de+Ye]=X[Ye];return he||be(X)}var Ve=ht,Kt=Ge,Rt=Ve,Q=Rt;Q.v1=Kt,Q.v4=Rt;var je=Q;function st(K){var he=Re();return function(){var de=Fe.default(K),X;if(he){var Ye=Fe.default(this).constructor;X=Reflect.construct(de,arguments,Ye)}else X=de.apply(this,arguments);return Oe.default(this,X)}}function Re(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var kt=function(K){Me.default(G,K);var he=st(G);function G(de){var X;z.default(this,G);var Ye=je.v4(),ze;return X=he.call(this,function(ct,ut){return ze=ut,de(function(ft){G.cancellationMap.delete(Ye),ct(ft)},function(ft){G.cancellationMap.delete(Ye),ut(ft)},function(ft){G.cancellationMap.set(Ye,ft)})}),X.id=Ye,X.rejectPromise=ze,X}return re.default(G,[{key:"cancel",value:function(){var X=G.cancellationMap.get(this.id);return X==null||X(),this.rejectPromise&&(this.catch(function(){}),this.rejectPromise(new Error("Promise was cancelled"))),this}}]),G}(Pe.default(Promise));Ze.default(kt,"cancellationMap",new Map);function ot(K,he,G,de){var X=arguments.length,Ye=X<3?he:de===null?de=Object.getOwnPropertyDescriptor(he,G):de,ze;if((typeof Reflect>"u"?"undefined":_e.default(Reflect))==="object"&&typeof Reflect.decorate=="function")Ye=Reflect.decorate(K,he,G,de);else for(var ct=K.length-1;ct>=0;ct--)(ze=K[ct])&&(Ye=(X<3?ze(Ye):X>3?ze(he,G,Ye):ze(he,G))||Ye);return X>3&&Ye&&Object.defineProperty(he,G,Ye),Ye}function ar(K,he){if((typeof Reflect>"u"?"undefined":_e.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(K,he)}function mr(K,he){return["".concat(new Date().toISOString()," MCS Client ").concat(K,":")].concat(Array.from(he))}var Xe=function(){function K(he){z.default(this,K),Ze.default(this,"prefix",""),this.prefix=he!=null&&he.length>0?he+" ":""}return re.default(K,[{key:"setLevel",value:function(G){se.setLevel(G)}},{key:"trace",value:function(){if(se.getLevel()==se.levels.TRACE){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.debug.apply(null,mr(this.prefix+"T",de))}}},{key:"debug",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.debug.apply(null,mr(this.prefix+"D",de))}},{key:"info",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.info.apply(null,mr(this.prefix+"I",de))}},{key:"warn",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.warn.apply(null,mr(this.prefix+"W",de))}},{key:"error",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.error.apply(null,mr(this.prefix+"E",de))}}],[{key:"scope",value:function(G){return new K(G)}},{key:"setLevel",value:function(G){se.setLevel(G)}},{key:"trace",value:function(){if(se.getLevel()==se.levels.TRACE){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.debug.apply(null,mr("T",de))}}},{key:"debug",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.debug.apply(null,mr("D",de))}},{key:"info",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.info.apply(null,mr("I",de))}},{key:"warn",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.warn.apply(null,mr("W",de))}},{key:"error",value:function(){for(var G=arguments.length,de=new Array(G),X=0;X<G;X++)de[X]=arguments[X];se.error.apply(null,mr("E",de))}}]),K}(),Or=1e3,jr=4e3,lr=3,cr=!0,Vt=function(he){return"https://mcs.".concat(he??"us1",".twilio.com")},At=function(he){return he.startsWith("http")},M=function(he,G){return"".concat(At(he)?"":Vt(G)).concat(he)},V=function(){function K(he,G,de,X){var Ye,ze,ct,ut,ft,Et;z.default(this,K);var It=(Ye=(ze=X.MCS)!==null&&ze!==void 0?ze:X)!==null&&Ye!==void 0?Ye:{};this.region=(ct=(ut=It.region)!==null&&ut!==void 0?ut:X.region)!==null&&ct!==void 0?ct:"us1",this.mediaUrl=M(G,this.region),this.mediaSetUrl=de?M(de):"".concat(this.mediaUrl,"Set"),this.token=he,this.retryWhenThrottledOverride=(ft=It.retryWhenThrottledOverride)!==null&&ft!==void 0?ft:cr,this.backoffConfigOverride=(Et=It.backoffConfigOverride)!==null&&Et!==void 0?Et:K.backoffConfigDefault}return re.default(K,[{key:"updateToken",value:function(G){this.token=G}}],[{key:"backoffConfigDefault",get:function(){return{min:Or,max:jr,maxAttemptsCount:lr}}},{key:"retryWhenThrottledDefault",get:function(){return cr}}]),K}(),ie=function(){function K(he,G,de){z.default(this,K),this.config=he,this.network=G,this._update(de)}return re.default(K,[{key:"sid",get:function(){return this.state.sid}},{key:"serviceSid",get:function(){return this.state.serviceSid}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"fileName",get:function(){return this.state.filename}},{key:"filename",get:function(){return this.state.filename}},{key:"category",get:function(){return this.state.category}},{key:"getContentUrl",value:function(){var G=this;return new kt(function(){var de=Z.default(Ie.default.mark(function X(Ye,ze,ct){var ut,ft;return Ie.default.wrap(function(It){for(;;)switch(It.prev=It.next){case 0:return ut=G.network.get("".concat(G.config.mediaUrl,"/").concat(G.sid)),ct(function(){return ut.cancel()}),It.prev=2,It.next=5,ut;case 5:ft=It.sent,G._update(ft.body),Ye(G.state.contentDirectUrl),It.next=13;break;case 10:It.prev=10,It.t0=It.catch(2),ze(It.t0);case 13:case"end":return It.stop()}},X,null,[[2,10]])}));return function(X,Ye,ze){return de.apply(this,arguments)}}())}},{key:"_update",value:function(G){var de,X,Ye,ze;this.state={sid:G.sid,serviceSid:G.service_sid,channelSid:G.channel_sid,messageSid:G.message_sid,dateCreated:G.date_created?new Date(G.date_created):null,dateUploadUpdated:G.date_upload_updated?new Date(G.date_upload_updated):null,dateUpdated:G.date_updated?new Date(G.date_updated):null,size:G.size,contentType:G.content_type,author:G.author,url:G.url,contentUrl:G.links.content,contentDirectUrl:(de=G.links.content_direct_temporary)!==null&&de!==void 0?de:null,filename:(X=G.filename)!==null&&X!==void 0?X:null,category:(Ye=G.category)!==null&&Ye!==void 0?Ye:"media",isMultipartUpstream:(ze=G.is_multipart_upstream)!==null&&ze!==void 0?ze:!1}}},{key:"_state",value:function(){var G;return{sid:this.state.sid,category:this.state.category,filename:(G=this.state.filename)!==null&&G!==void 0?G:null,contentType:this.state.contentType,size:this.state.size}}}]),K}();function Be(K){var he=lt();return function(){var de=Fe.default(K),X;if(he){var Ye=Fe.default(this).constructor;X=Reflect.construct(de,arguments,Ye)}else X=de.apply(this,arguments);return Oe.default(this,X)}}function lt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var yt=function(K){Me.default(G,K);var he=Be(G);function G(de,X,Ye,ze,ct){var ut;return z.default(this,G),ut=he.call(this,de),ut.code=X,ut.body=Ye,ut.status=ze,ut.headers=ct,ut}return re.default(G)}(Pe.default(Error)),Bt=e.XMLHttpRequest||{};function er(K){return K?K.split(`\r
1169
1169
  `).map(function(he){return he.split(": ")}).filter(function(he){return he.length===2&&he[1].length>0}).reduce(function(he,G){return he[G[0]]=G[1],he},{}):{}}function Ee(K){var he=K.getResponseHeader("Content-Type");if(!he||he.indexOf("application/json")!==0||K.responseText.length===0)return K.responseText;try{return JSON.parse(K.responseText)}catch{return K.responseText}}var Ne=function(){function K(){z.default(this,K)}return re.default(K,[{key:"get",value:function(G,de){return K.request("GET",G,de)}},{key:"post",value:function(G,de,X){return K.request("POST",G,de,X)}}],[{key:"request",value:function(G,de,X,Ye){return new kt(function(ze,ct,ut){var ft=new Bt,Et=!1;ut(function(){ft.abort(),Et=!0}),ft.open(G,de,!0),ft.onreadystatechange=function(){if(!(ft.readyState!==4||Et)){var St=er(ft.getAllResponseHeaders()),xt=Ee(ft);if(200<=ft.status&&ft.status<300)ze({status:ft.status,headers:St,body:xt});else{var Dt,rn=(Dt=ft.statusText)!==null&&Dt!==void 0?Dt:"NONE",yn;if(typeof xt=="string")if(xt&&xt.split(`
1170
- `,2).length===1)yn=xt;else{var jt,Fn=(jt=xt.replace(/<.*?>/g,"").split(/\r\n/g).filter(function(Ua){return Ua.length})[0])===null||jt===void 0?void 0:jt.split(" ");yn=(Fn==null?void 0:Fn.length)>2?Fn==null?void 0:Fn.slice(1).join(" "):""}else yn=JSON.stringify(xt);var sa="".concat(ft.status,": [").concat(rn,"] ").concat(yn);ct(new yt(sa,ft.status,xt,rn,St))}}};for(var It in X)ft.setRequestHeader(It,X[It]),It==="Content-Type"&&X[It]==="application/json"&&(Ye=JSON.stringify(Ye));ft.send(Ye)})}}]),K}(),pe=Xe.scope("Network"),$e=function(){function K(he,G){z.default(this,K),this.config=he,this.transport=G}return re.default(K,[{key:"backoffConfig",value:function(){return Object.assign(V.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var G,de;return(G=(de=this.config.retryWhenThrottledOverride)!==null&&de!==void 0?de:V.retryWhenThrottledDefault)!==null&&G!==void 0?G:!1}},{key:"executeWithRetry",value:function(G,de){var X=this;return new kt(function(){var Ye=Z.default(Ie.default.mark(function ze(ct,ut,ft){var Et,It;return Ie.default.wrap(function(St){for(;;)switch(St.prev=St.next){case 0:Et=new m.Retrier(X.backoffConfig()),It=[502,503,504],de&&It.push(429),ft(function(){Et.cancel(),Et.removeAllListeners()}),Et.on("attempt",Z.default(Ie.default.mark(function xt(){var Dt,rn;return Ie.default.wrap(function(jt){for(;;)switch(jt.prev=jt.next){case 0:return jt.prev=0,Dt=G(),ft(function(){Dt.cancel(),Et.cancel(),Et.removeAllListeners()}),jt.next=5,Dt;case 5:rn=jt.sent,Et.succeeded(rn),jt.next=12;break;case 9:jt.prev=9,jt.t0=jt.catch(0),It.indexOf(jt.t0.status)>-1||jt.t0.message==="Twilsock disconnected"?Et.failed(jt.t0):(Et.removeAllListeners(),Et.cancel(),ut(jt.t0));case 12:case"end":return jt.stop()}},xt,null,[[0,9]])}))),Et.on("succeeded",function(xt){ct(xt)}),Et.on("cancelled",function(xt){return ut(xt)}),Et.on("failed",function(xt){return ut(xt)}),Et.start();case 9:case"end":return St.stop()}},ze)}));return function(ze,ct,ut){return Ye.apply(this,arguments)}}())}},{key:"get",value:function(G){var de=this;return new kt(function(){var X=Z.default(Ie.default.mark(function Ye(ze,ct,ut){var ft,Et,It;return Ie.default.wrap(function(St){for(;;)switch(St.prev=St.next){case 0:return ft={"X-Twilio-Token":de.config.token},Et=de.executeWithRetry(function(){return de.transport.get(G,ft)},de.retryWhenThrottled()),pe.trace("sending GET request to ",G," headers ",ft),ut(function(){return Et.cancel()}),St.prev=4,St.next=7,Et;case 7:It=St.sent,pe.trace("response",It),ze(It),St.next=16;break;case 12:St.prev=12,St.t0=St.catch(4),pe.debug("get() error ".concat(St.t0)),ct(St.t0);case 16:case"end":return St.stop()}},Ye,null,[[4,12]])}));return function(Ye,ze,ct){return X.apply(this,arguments)}}())}},{key:"post",value:function(G,de,X,Ye,ze){var ct=this,ut={"X-Twilio-Token":this.config.token};(typeof FormData>"u"||!(X instanceof FormData))&&Ye&&Object.assign(ut,{"Content-Type":Ye});var ft=new URL(G);return de&&ft.searchParams.append("Category",de),ze&&ft.searchParams.append("Filename",ze),new kt(function(){var Et=Z.default(Ie.default.mark(function It(_t,St,xt){var Dt,rn;return Ie.default.wrap(function(jt){for(;;)switch(jt.prev=jt.next){case 0:return Dt=ct.transport.post(ft.href,ut,X),xt(function(){return Dt.cancel()}),pe.trace("sending POST request to ".concat(G," with headers ").concat(ut)),jt.prev=3,jt.next=6,Dt;case 6:rn=jt.sent,jt.next=17;break;case 9:if(jt.prev=9,jt.t0=jt.catch(3),!(e.XMLHttpRequest===void 0&&X instanceof FormData)){jt.next=14;break}return St(new TypeError("Posting FormData supported only with browser engine's FormData")),jt.abrupt("return");case 14:return pe.debug("post() error ".concat(jt.t0)),St(jt.t0),jt.abrupt("return");case 17:pe.trace("response",rn),_t(rn);case 19:case"end":return jt.stop()}},It,null,[[3,9]])}));return function(It,_t,St){return Et.apply(this,arguments)}}())}}]),K}(),ae="0.6.13",ge,we=Xe.scope("");t.default=(ge=function(){function K(he,G,de){var X,Ye,ze=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};z.default(this,K),this.options=ze,this.options.logLevel=(X=this.options.logLevel)!==null&&X!==void 0?X:"silent",this.config=new V(he,G,de,this.options),we.setLevel(this.options.logLevel),this.options.transport=(Ye=this.options.transport)!==null&&Ye!==void 0?Ye:new Ne,this.transport=this.options.transport,this.network=new $e(this.config,this.transport)}return re.default(K,[{key:"updateToken",value:function(G){we.info("updateToken"),this.config.updateToken(G)}},{key:"get",value:function(G){var de=this;return new kt(function(){var X=Z.default(Ie.default.mark(function Ye(ze,ct,ut){var ft,Et;return Ie.default.wrap(function(_t){for(;;)switch(_t.prev=_t.next){case 0:return ft=de.network.get("".concat(de.config.mediaUrl,"/").concat(G)),ut(function(){return ft.cancel()}),_t.prev=2,_t.next=5,ft;case 5:Et=_t.sent,ze(new ie(de.config,de.network,Et.body)),_t.next=12;break;case 9:_t.prev=9,_t.t0=_t.catch(2),ct(_t.t0);case 12:case"end":return _t.stop()}},Ye,null,[[2,9]])}));return function(Ye,ze,ct){return X.apply(this,arguments)}}())}},{key:"post",value:function(G,de,X,Ye){var ze=this;return new kt(function(){var ct=Z.default(Ie.default.mark(function ut(ft,Et,It){var _t,St;return Ie.default.wrap(function(Dt){for(;;)switch(Dt.prev=Dt.next){case 0:return _t=ze.network.post(ze.config.mediaUrl,X??"media",de,G,Ye),It(function(){return _t.cancel()}),Dt.prev=2,Dt.next=5,_t;case 5:St=Dt.sent,ft(new ie(ze.config,ze.network,St.body)),Dt.next=12;break;case 9:Dt.prev=9,Dt.t0=Dt.catch(2),Et(Dt.t0);case 12:case"end":return Dt.stop()}},ut,null,[[2,9]])}));return function(ut,ft,Et){return ct.apply(this,arguments)}}())}},{key:"postFormData",value:function(G,de){var X=this;return new kt(function(){var Ye=Z.default(Ie.default.mark(function ze(ct,ut,ft){var Et,It;return Ie.default.wrap(function(St){for(;;)switch(St.prev=St.next){case 0:return Et=X.network.post(X.config.mediaUrl,de??"media",G),ft(function(){return Et.cancel()}),St.prev=2,St.next=5,Et;case 5:It=St.sent,ct(new ie(X.config,X.network,It.body)),St.next=12;break;case 9:St.prev=9,St.t0=St.catch(2),ut(St.t0);case 12:case"end":return St.stop()}},ze,null,[[2,9]])}));return function(ze,ct,ut){return Ye.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(G){var de=this;return new kt(function(){var X=Z.default(Ie.default.mark(function Ye(ze,ct,ut){var ft,Et,It,_t;return Ie.default.wrap(function(xt){for(;;)switch(xt.prev=xt.next){case 0:return ft={command:"get",list:G.map(function(Dt){return{media_sid:Dt}})},Et=de.network.post("".concat(de.config.mediaSetUrl),null,ft,"application/json"),ut(function(){return Et.cancel()}),xt.prev=3,xt.next=6,Et;case 6:It=xt.sent,_t=It.body.map(function(Dt){if(Dt.code!==200){ct("Failed to obtain detailed information about Media items (failed SID ".concat(Dt.media_record.sid,")"));return}return new ie(de.config,de.network,Dt.media_record)}),ze(_t),xt.next=14;break;case 11:xt.prev=11,xt.t0=xt.catch(3),ct(xt.t0);case 14:case"end":return xt.stop()}},Ye,null,[[3,11]])}));return function(Ye,ze,ct){return X.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(G){var de=this;return new kt(function(){var X=Z.default(Ie.default.mark(function Ye(ze,ct,ut){var ft,Et,It,_t;return Ie.default.wrap(function(xt){for(;;)switch(xt.prev=xt.next){case 0:return ft={command:"get",list:G.map(function(Dt){return{media_sid:Dt}})},Et=de.network.post("".concat(de.config.mediaSetUrl),null,ft,"application/json"),ut(function(){return Et.cancel()}),xt.prev=3,xt.next=6,Et;case 6:It=xt.sent,_t=new Map,It.body.forEach(function(Dt){if(Dt.code!==200){ct("Failed to obtain detailed information about Media items (failed SID ".concat(Dt.media_record.sid,")"));return}_t.set(Dt.media_record.sid,Dt.media_record.links.content_direct_temporary)}),ze(_t),xt.next=15;break;case 12:xt.prev=12,xt.t0=xt.catch(3),ct(xt.t0);case 15:case"end":return xt.stop()}},Ye,null,[[3,12]])}));return function(Ye,ze,ct){return X.apply(this,arguments)}}())}}]),K}(),Ze.default(ge,"version",ae),ge),ot([k.validateTypes(k.nonEmptyString),ar("design:type",Function),ar("design:paramtypes",[String]),ar("design:returntype",void 0)],t.default.prototype,"updateToken",null),ot([k.validateTypesAsync(k.nonEmptyString),ar("design:type",Function),ar("design:paramtypes",[String]),ar("design:returntype",kt)],t.default.prototype,"get",null),t.default=ot([k.validateConstructorTypes(k.nonEmptyString,k.nonEmptyString,[k.nonEmptyString,k.literal(null)],[k.pureObject,"undefined"]),ar("design:paramtypes",[String,String,Object,Object])],t.default),t.CancellablePromise=kt,t.Client=t.default,t.McsClient=t.default,t.McsMedia=ie,t.Media=ie})(Fx);var pte=Xt,vte=ur,gte=wE,mte=Yf,Xb="ArrayBuffer",jR=gte[Xb],yte=vte[Xb];pte({global:!0,constructor:!0,forced:yte!==jR},{ArrayBuffer:jR}),mte(Xb);var bte=Xt,UR=Gt,wte=ti,_te=vn,FR=gn,kte=Fy,BR=Xr,ew=qt,Ste=Jy,$te=Gf,zR=TI,Tte=CI,HR=fu,qR=II,Cs=[],VR=UR(Cs.sort),Cte=UR(Cs.push),Ete=ew(function(){Cs.sort(void 0)}),Ite=ew(function(){Cs.sort(null)}),xte=$te("sort"),WR=!ew(function(){if(HR)return HR<70;if(!(zR&&zR>3)){if(Tte)return!0;if(qR)return qR<603;var t="",e,r,n,i;for(e=65;e<76;e++){switch(r=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(i=0;i<47;i++)Cs.push({k:r+i,v:n})}for(Cs.sort(function(a,s){return s.v-a.v}),i=0;i<Cs.length;i++)r=Cs[i].k.charAt(0),t.charAt(t.length-1)!==r&&(t+=r);return t!=="DGBEFHACIJK"}}),Rte=Ete||!Ite||!xte||!WR,Ate=function(t){return function(e,r){return r===void 0?-1:e===void 0?1:t!==void 0?+t(e,r)||0:BR(e)>BR(r)?1:-1}};bte({target:"Array",proto:!0,forced:Rte},{sort:function(e){e!==void 0&&wte(e);var r=_te(this);if(WR)return e===void 0?VR(r):VR(r,e);var n=[],i=FR(r),a,s;for(s=0;s<i;s++)s in r&&Cte(n,r[s]);for(Ste(n,Ate(e)),a=FR(n),s=0;s<a;)r[s]=n[s++];for(;s<i;)kte(r,s++);return r}});var Ote=Xt,Pte=Gt,Mte=Bx,Nte=Si,ZR=Xr,Lte=zx,Dte=Pte("".indexOf);Ote({target:"String",proto:!0,forced:!Lte("includes")},{includes:function(e){return!!~Dte(ZR(Nte(this)),ZR(Mte(e)),arguments.length>1?arguments[1]:void 0)}});var jte=Gt,GR=Mh,Sp=Ph.getWeakData,Ute=fs,Fte=Wr,Bte=ki,tw=Mr,zte=Bc,KR=Nn,YR=Hr,JR=Wn,Hte=JR.set,qte=JR.getterFor,Vte=KR.find,Wte=KR.findIndex,Zte=jte([].splice),Gte=0,$p=function(t){return t.frozen||(t.frozen=new QR)},QR=function(){this.entries=[]},rw=function(t,e){return Vte(t.entries,function(r){return r[0]===e})};QR.prototype={get:function(t){var e=rw(this,t);if(e)return e[1]},has:function(t){return!!rw(this,t)},set:function(t,e){var r=rw(this,t);r?r[1]=e:this.entries.push([t,e])},delete:function(t){var e=Wte(this.entries,function(r){return r[0]===t});return~e&&Zte(this.entries,e,1),!!~e}};var Kte={getConstructor:function(t,e,r,n){var i=t(function(u,l){Ute(u,a),Hte(u,{type:e,id:Gte++,frozen:void 0}),Bte(l)||zte(l,u[n],{that:u,AS_ENTRIES:r})}),a=i.prototype,s=qte(e),o=function(u,l,c){var d=s(u),f=Sp(Fte(l),!0);return f===!0?$p(d).set(l,c):f[d.id]=c,u};return GR(a,{delete:function(u){var l=s(this);if(!tw(u))return!1;var c=Sp(u);return c===!0?$p(l).delete(u):c&&YR(c,l.id)&&delete c[l.id]},has:function(l){var c=s(this);if(!tw(l))return!1;var d=Sp(l);return d===!0?$p(c).has(l):d&&YR(d,c.id)}}),GR(a,r?{get:function(l){var c=s(this);if(tw(l)){var d=Sp(l);return d===!0?$p(c).get(l):d?d[c.id]:void 0}},set:function(l,c){return o(this,l,c)}}:{add:function(l){return o(this,l,!0)}}),i}},Yte=uy,Jte=Kte;Yte("WeakSet",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Jte);var Tp={},XR={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(sn,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function a(L,N){var z=L[N];if(typeof z.bind=="function")return z.bind(L);try{return Function.prototype.bind.call(z,L)}catch{return function(){return Function.prototype.apply.apply(z,[L,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(L){return L==="debug"&&(L="log"),typeof console===r?!1:L==="trace"&&n?s:console[L]!==void 0?a(console,L):console.log!==void 0?a(console,"log"):e}function u(L,N){for(var z=0;z<i.length;z++){var re=i[z];this[re]=z<L?e:this.methodFactory(re,L,N)}this.log=this.debug}function l(L,N,z){return function(){typeof console!==r&&(u.call(this,N,z),this[L].apply(this,arguments))}}function c(L,N,z){return o(L)||l.apply(this,arguments)}function d(L,N,z){var re=this,Me;N=N??"WARN";var Oe="loglevel";typeof L=="string"?Oe+=":"+L:typeof L=="symbol"&&(Oe=void 0);function Be(Ie){var _e=(i[Ie]||"silent").toUpperCase();if(!(typeof window===r||!Oe)){try{window.localStorage[Oe]=_e;return}catch{}try{window.document.cookie=encodeURIComponent(Oe)+"="+_e+";"}catch{}}}function Pe(){var Ie;if(!(typeof window===r||!Oe)){try{Ie=window.localStorage[Oe]}catch{}if(typeof Ie===r)try{var _e=window.document.cookie,se=_e.indexOf(encodeURIComponent(Oe)+"=");se!==-1&&(Ie=/^([^;]+)/.exec(_e.slice(se))[1])}catch{}return re.levels[Ie]===void 0&&(Ie=void 0),Ie}}function Ze(){if(!(typeof window===r||!Oe)){try{window.localStorage.removeItem(Oe);return}catch{}try{window.document.cookie=encodeURIComponent(Oe)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}re.name=L,re.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},re.methodFactory=z||c,re.getLevel=function(){return Me},re.setLevel=function(Ie,_e){if(typeof Ie=="string"&&re.levels[Ie.toUpperCase()]!==void 0&&(Ie=re.levels[Ie.toUpperCase()]),typeof Ie=="number"&&Ie>=0&&Ie<=re.levels.SILENT){if(Me=Ie,_e!==!1&&Be(Ie),u.call(re,Ie,L),typeof console===r&&Ie<re.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+Ie},re.setDefaultLevel=function(Ie){N=Ie,Pe()||re.setLevel(Ie,!1)},re.resetLevel=function(){re.setLevel(N,!1),Ze()},re.enableAll=function(Ie){re.setLevel(re.levels.TRACE,Ie)},re.disableAll=function(Ie){re.setLevel(re.levels.SILENT,Ie)};var Z=Pe();Z==null&&(Z=N),re.setLevel(Z,!1)}var f=new d,m={};f.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var z=m[N];return z||(z=m[N]=new d(N,f.getLevel(),f.methodFactory)),z};var k=typeof window!==r?window.log:void 0;return f.noConflict=function(){return typeof window!==r&&window.log===f&&(window.log=k),f},f.getLoggers=function(){return m},f.default=f,f})})(XR);var Qte=XR.exports;/*
1170
+ `,2).length===1)yn=xt;else{var jt,Fn=(jt=xt.replace(/<.*?>/g,"").split(/\r\n/g).filter(function(Ua){return Ua.length})[0])===null||jt===void 0?void 0:jt.split(" ");yn=(Fn==null?void 0:Fn.length)>2?Fn==null?void 0:Fn.slice(1).join(" "):""}else yn=JSON.stringify(xt);var sa="".concat(ft.status,": [").concat(rn,"] ").concat(yn);ct(new yt(sa,ft.status,xt,rn,St))}}};for(var It in X)ft.setRequestHeader(It,X[It]),It==="Content-Type"&&X[It]==="application/json"&&(Ye=JSON.stringify(Ye));ft.send(Ye)})}}]),K}(),pe=Xe.scope("Network"),$e=function(){function K(he,G){z.default(this,K),this.config=he,this.transport=G}return re.default(K,[{key:"backoffConfig",value:function(){return Object.assign(V.backoffConfigDefault,this.config.backoffConfigOverride)}},{key:"retryWhenThrottled",value:function(){var G,de;return(G=(de=this.config.retryWhenThrottledOverride)!==null&&de!==void 0?de:V.retryWhenThrottledDefault)!==null&&G!==void 0?G:!1}},{key:"executeWithRetry",value:function(G,de){var X=this;return new kt(function(){var Ye=Z.default(Ie.default.mark(function ze(ct,ut,ft){var Et,It;return Ie.default.wrap(function(St){for(;;)switch(St.prev=St.next){case 0:Et=new m.Retrier(X.backoffConfig()),It=[502,503,504],de&&It.push(429),ft(function(){Et.cancel(),Et.removeAllListeners()}),Et.on("attempt",Z.default(Ie.default.mark(function xt(){var Dt,rn;return Ie.default.wrap(function(jt){for(;;)switch(jt.prev=jt.next){case 0:return jt.prev=0,Dt=G(),ft(function(){Dt.cancel(),Et.cancel(),Et.removeAllListeners()}),jt.next=5,Dt;case 5:rn=jt.sent,Et.succeeded(rn),jt.next=12;break;case 9:jt.prev=9,jt.t0=jt.catch(0),It.indexOf(jt.t0.status)>-1||jt.t0.message==="Twilsock disconnected"?Et.failed(jt.t0):(Et.removeAllListeners(),Et.cancel(),ut(jt.t0));case 12:case"end":return jt.stop()}},xt,null,[[0,9]])}))),Et.on("succeeded",function(xt){ct(xt)}),Et.on("cancelled",function(xt){return ut(xt)}),Et.on("failed",function(xt){return ut(xt)}),Et.start();case 9:case"end":return St.stop()}},ze)}));return function(ze,ct,ut){return Ye.apply(this,arguments)}}())}},{key:"get",value:function(G){var de=this;return new kt(function(){var X=Z.default(Ie.default.mark(function Ye(ze,ct,ut){var ft,Et,It;return Ie.default.wrap(function(St){for(;;)switch(St.prev=St.next){case 0:return ft={"X-Twilio-Token":de.config.token},Et=de.executeWithRetry(function(){return de.transport.get(G,ft)},de.retryWhenThrottled()),pe.trace("sending GET request to ",G," headers ",ft),ut(function(){return Et.cancel()}),St.prev=4,St.next=7,Et;case 7:It=St.sent,pe.trace("response",It),ze(It),St.next=16;break;case 12:St.prev=12,St.t0=St.catch(4),pe.debug("get() error ".concat(St.t0)),ct(St.t0);case 16:case"end":return St.stop()}},Ye,null,[[4,12]])}));return function(Ye,ze,ct){return X.apply(this,arguments)}}())}},{key:"post",value:function(G,de,X,Ye,ze){var ct=this,ut={"X-Twilio-Token":this.config.token};(typeof FormData>"u"||!(X instanceof FormData))&&Ye&&Object.assign(ut,{"Content-Type":Ye});var ft=new URL(G);return de&&ft.searchParams.append("Category",de),ze&&ft.searchParams.append("Filename",ze),new kt(function(){var Et=Z.default(Ie.default.mark(function It(_t,St,xt){var Dt,rn;return Ie.default.wrap(function(jt){for(;;)switch(jt.prev=jt.next){case 0:return Dt=ct.transport.post(ft.href,ut,X),xt(function(){return Dt.cancel()}),pe.trace("sending POST request to ".concat(G," with headers ").concat(ut)),jt.prev=3,jt.next=6,Dt;case 6:rn=jt.sent,jt.next=17;break;case 9:if(jt.prev=9,jt.t0=jt.catch(3),!(e.XMLHttpRequest===void 0&&X instanceof FormData)){jt.next=14;break}return St(new TypeError("Posting FormData supported only with browser engine's FormData")),jt.abrupt("return");case 14:return pe.debug("post() error ".concat(jt.t0)),St(jt.t0),jt.abrupt("return");case 17:pe.trace("response",rn),_t(rn);case 19:case"end":return jt.stop()}},It,null,[[3,9]])}));return function(It,_t,St){return Et.apply(this,arguments)}}())}}]),K}(),ae="0.6.13",ge,we=Xe.scope("");t.default=(ge=function(){function K(he,G,de){var X,Ye,ze=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};z.default(this,K),this.options=ze,this.options.logLevel=(X=this.options.logLevel)!==null&&X!==void 0?X:"silent",this.config=new V(he,G,de,this.options),we.setLevel(this.options.logLevel),this.options.transport=(Ye=this.options.transport)!==null&&Ye!==void 0?Ye:new Ne,this.transport=this.options.transport,this.network=new $e(this.config,this.transport)}return re.default(K,[{key:"updateToken",value:function(G){we.info("updateToken"),this.config.updateToken(G)}},{key:"get",value:function(G){var de=this;return new kt(function(){var X=Z.default(Ie.default.mark(function Ye(ze,ct,ut){var ft,Et;return Ie.default.wrap(function(_t){for(;;)switch(_t.prev=_t.next){case 0:return ft=de.network.get("".concat(de.config.mediaUrl,"/").concat(G)),ut(function(){return ft.cancel()}),_t.prev=2,_t.next=5,ft;case 5:Et=_t.sent,ze(new ie(de.config,de.network,Et.body)),_t.next=12;break;case 9:_t.prev=9,_t.t0=_t.catch(2),ct(_t.t0);case 12:case"end":return _t.stop()}},Ye,null,[[2,9]])}));return function(Ye,ze,ct){return X.apply(this,arguments)}}())}},{key:"post",value:function(G,de,X,Ye){var ze=this;return new kt(function(){var ct=Z.default(Ie.default.mark(function ut(ft,Et,It){var _t,St;return Ie.default.wrap(function(Dt){for(;;)switch(Dt.prev=Dt.next){case 0:return _t=ze.network.post(ze.config.mediaUrl,X??"media",de,G,Ye),It(function(){return _t.cancel()}),Dt.prev=2,Dt.next=5,_t;case 5:St=Dt.sent,ft(new ie(ze.config,ze.network,St.body)),Dt.next=12;break;case 9:Dt.prev=9,Dt.t0=Dt.catch(2),Et(Dt.t0);case 12:case"end":return Dt.stop()}},ut,null,[[2,9]])}));return function(ut,ft,Et){return ct.apply(this,arguments)}}())}},{key:"postFormData",value:function(G,de){var X=this;return new kt(function(){var Ye=Z.default(Ie.default.mark(function ze(ct,ut,ft){var Et,It;return Ie.default.wrap(function(St){for(;;)switch(St.prev=St.next){case 0:return Et=X.network.post(X.config.mediaUrl,de??"media",G),ft(function(){return Et.cancel()}),St.prev=2,St.next=5,Et;case 5:It=St.sent,ct(new ie(X.config,X.network,It.body)),St.next=12;break;case 9:St.prev=9,St.t0=St.catch(2),ut(St.t0);case 12:case"end":return St.stop()}},ze,null,[[2,9]])}));return function(ze,ct,ut){return Ye.apply(this,arguments)}}())}},{key:"mediaSetGet",value:function(G){var de=this;return new kt(function(){var X=Z.default(Ie.default.mark(function Ye(ze,ct,ut){var ft,Et,It,_t;return Ie.default.wrap(function(xt){for(;;)switch(xt.prev=xt.next){case 0:return ft={command:"get",list:G.map(function(Dt){return{media_sid:Dt}})},Et=de.network.post("".concat(de.config.mediaSetUrl),null,ft,"application/json"),ut(function(){return Et.cancel()}),xt.prev=3,xt.next=6,Et;case 6:It=xt.sent,_t=It.body.map(function(Dt){if(Dt.code!==200){ct("Failed to obtain detailed information about Media items (failed SID ".concat(Dt.media_record.sid,")"));return}return new ie(de.config,de.network,Dt.media_record)}),ze(_t),xt.next=14;break;case 11:xt.prev=11,xt.t0=xt.catch(3),ct(xt.t0);case 14:case"end":return xt.stop()}},Ye,null,[[3,11]])}));return function(Ye,ze,ct){return X.apply(this,arguments)}}())}},{key:"mediaSetGetContentUrls",value:function(G){var de=this;return new kt(function(){var X=Z.default(Ie.default.mark(function Ye(ze,ct,ut){var ft,Et,It,_t;return Ie.default.wrap(function(xt){for(;;)switch(xt.prev=xt.next){case 0:return ft={command:"get",list:G.map(function(Dt){return{media_sid:Dt}})},Et=de.network.post("".concat(de.config.mediaSetUrl),null,ft,"application/json"),ut(function(){return Et.cancel()}),xt.prev=3,xt.next=6,Et;case 6:It=xt.sent,_t=new Map,It.body.forEach(function(Dt){if(Dt.code!==200){ct("Failed to obtain detailed information about Media items (failed SID ".concat(Dt.media_record.sid,")"));return}_t.set(Dt.media_record.sid,Dt.media_record.links.content_direct_temporary)}),ze(_t),xt.next=15;break;case 12:xt.prev=12,xt.t0=xt.catch(3),ct(xt.t0);case 15:case"end":return xt.stop()}},Ye,null,[[3,12]])}));return function(Ye,ze,ct){return X.apply(this,arguments)}}())}}]),K}(),Ze.default(ge,"version",ae),ge),ot([k.validateTypes(k.nonEmptyString),ar("design:type",Function),ar("design:paramtypes",[String]),ar("design:returntype",void 0)],t.default.prototype,"updateToken",null),ot([k.validateTypesAsync(k.nonEmptyString),ar("design:type",Function),ar("design:paramtypes",[String]),ar("design:returntype",kt)],t.default.prototype,"get",null),t.default=ot([k.validateConstructorTypes(k.nonEmptyString,k.nonEmptyString,[k.nonEmptyString,k.literal(null)],[k.pureObject,"undefined"]),ar("design:paramtypes",[String,String,Object,Object])],t.default),t.CancellablePromise=kt,t.Client=t.default,t.McsClient=t.default,t.McsMedia=ie,t.Media=ie})(Fx);var pte=Xt,vte=ur,gte=wE,mte=Yf,Xb="ArrayBuffer",jR=gte[Xb],yte=vte[Xb];pte({global:!0,constructor:!0,forced:yte!==jR},{ArrayBuffer:jR}),mte(Xb);var bte=Xt,UR=Gt,wte=ti,_te=vn,FR=gn,kte=Fy,BR=Xr,ew=qt,Ste=Jy,$te=Gf,zR=TI,Tte=CI,HR=fu,qR=II,Cs=[],VR=UR(Cs.sort),Cte=UR(Cs.push),Ete=ew(function(){Cs.sort(void 0)}),Ite=ew(function(){Cs.sort(null)}),xte=$te("sort"),WR=!ew(function(){if(HR)return HR<70;if(!(zR&&zR>3)){if(Tte)return!0;if(qR)return qR<603;var t="",e,r,n,i;for(e=65;e<76;e++){switch(r=String.fromCharCode(e),e){case 66:case 69:case 70:case 72:n=3;break;case 68:case 71:n=4;break;default:n=2}for(i=0;i<47;i++)Cs.push({k:r+i,v:n})}for(Cs.sort(function(a,s){return s.v-a.v}),i=0;i<Cs.length;i++)r=Cs[i].k.charAt(0),t.charAt(t.length-1)!==r&&(t+=r);return t!=="DGBEFHACIJK"}}),Rte=Ete||!Ite||!xte||!WR,Ate=function(t){return function(e,r){return r===void 0?-1:e===void 0?1:t!==void 0?+t(e,r)||0:BR(e)>BR(r)?1:-1}};bte({target:"Array",proto:!0,forced:Rte},{sort:function(e){e!==void 0&&wte(e);var r=_te(this);if(WR)return e===void 0?VR(r):VR(r,e);var n=[],i=FR(r),a,s;for(s=0;s<i;s++)s in r&&Cte(n,r[s]);for(Ste(n,Ate(e)),a=FR(n),s=0;s<a;)r[s]=n[s++];for(;s<i;)kte(r,s++);return r}});var Ote=Xt,Pte=Gt,Mte=Bx,Nte=Si,ZR=Xr,Lte=zx,Dte=Pte("".indexOf);Ote({target:"String",proto:!0,forced:!Lte("includes")},{includes:function(e){return!!~Dte(ZR(Nte(this)),ZR(Mte(e)),arguments.length>1?arguments[1]:void 0)}});var jte=Gt,GR=Mh,Sp=Ph.getWeakData,Ute=fs,Fte=Wr,Bte=ki,tw=Mr,zte=Bc,KR=Nn,YR=Hr,JR=Wn,Hte=JR.set,qte=JR.getterFor,Vte=KR.find,Wte=KR.findIndex,Zte=jte([].splice),Gte=0,$p=function(t){return t.frozen||(t.frozen=new QR)},QR=function(){this.entries=[]},rw=function(t,e){return Vte(t.entries,function(r){return r[0]===e})};QR.prototype={get:function(t){var e=rw(this,t);if(e)return e[1]},has:function(t){return!!rw(this,t)},set:function(t,e){var r=rw(this,t);r?r[1]=e:this.entries.push([t,e])},delete:function(t){var e=Wte(this.entries,function(r){return r[0]===t});return~e&&Zte(this.entries,e,1),!!~e}};var Kte={getConstructor:function(t,e,r,n){var i=t(function(u,l){Ute(u,a),Hte(u,{type:e,id:Gte++,frozen:void 0}),Bte(l)||zte(l,u[n],{that:u,AS_ENTRIES:r})}),a=i.prototype,s=qte(e),o=function(u,l,c){var d=s(u),f=Sp(Fte(l),!0);return f===!0?$p(d).set(l,c):f[d.id]=c,u};return GR(a,{delete:function(u){var l=s(this);if(!tw(u))return!1;var c=Sp(u);return c===!0?$p(l).delete(u):c&&YR(c,l.id)&&delete c[l.id]},has:function(l){var c=s(this);if(!tw(l))return!1;var d=Sp(l);return d===!0?$p(c).has(l):d&&YR(d,c.id)}}),GR(a,r?{get:function(l){var c=s(this);if(tw(l)){var d=Sp(l);return d===!0?$p(c).get(l):d?d[c.id]:void 0}},set:function(l,c){return o(this,l,c)}}:{add:function(l){return o(this,l,!0)}}),i}},Yte=uy,Jte=Kte;Yte("WeakSet",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Jte);var Tp={},XR={exports:{}};(function(t){(function(e,r){t.exports?t.exports=r():e.log=r()})(sn,function(){var e=function(){},r="undefined",n=typeof window!==r&&typeof window.navigator!==r&&/Trident\/|MSIE /.test(window.navigator.userAgent),i=["trace","debug","info","warn","error"];function a(L,N){var z=L[N];if(typeof z.bind=="function")return z.bind(L);try{return Function.prototype.bind.call(z,L)}catch{return function(){return Function.prototype.apply.apply(z,[L,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function o(L){return L==="debug"&&(L="log"),typeof console===r?!1:L==="trace"&&n?s:console[L]!==void 0?a(console,L):console.log!==void 0?a(console,"log"):e}function u(L,N){for(var z=0;z<i.length;z++){var re=i[z];this[re]=z<L?e:this.methodFactory(re,L,N)}this.log=this.debug}function l(L,N,z){return function(){typeof console!==r&&(u.call(this,N,z),this[L].apply(this,arguments))}}function c(L,N,z){return o(L)||l.apply(this,arguments)}function d(L,N,z){var re=this,Me;N=N??"WARN";var Oe="loglevel";typeof L=="string"?Oe+=":"+L:typeof L=="symbol"&&(Oe=void 0);function Fe(Ie){var _e=(i[Ie]||"silent").toUpperCase();if(!(typeof window===r||!Oe)){try{window.localStorage[Oe]=_e;return}catch{}try{window.document.cookie=encodeURIComponent(Oe)+"="+_e+";"}catch{}}}function Pe(){var Ie;if(!(typeof window===r||!Oe)){try{Ie=window.localStorage[Oe]}catch{}if(typeof Ie===r)try{var _e=window.document.cookie,se=_e.indexOf(encodeURIComponent(Oe)+"=");se!==-1&&(Ie=/^([^;]+)/.exec(_e.slice(se))[1])}catch{}return re.levels[Ie]===void 0&&(Ie=void 0),Ie}}function Ze(){if(!(typeof window===r||!Oe)){try{window.localStorage.removeItem(Oe);return}catch{}try{window.document.cookie=encodeURIComponent(Oe)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}re.name=L,re.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},re.methodFactory=z||c,re.getLevel=function(){return Me},re.setLevel=function(Ie,_e){if(typeof Ie=="string"&&re.levels[Ie.toUpperCase()]!==void 0&&(Ie=re.levels[Ie.toUpperCase()]),typeof Ie=="number"&&Ie>=0&&Ie<=re.levels.SILENT){if(Me=Ie,_e!==!1&&Fe(Ie),u.call(re,Ie,L),typeof console===r&&Ie<re.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+Ie},re.setDefaultLevel=function(Ie){N=Ie,Pe()||re.setLevel(Ie,!1)},re.resetLevel=function(){re.setLevel(N,!1),Ze()},re.enableAll=function(Ie){re.setLevel(re.levels.TRACE,Ie)},re.disableAll=function(Ie){re.setLevel(re.levels.SILENT,Ie)};var Z=Pe();Z==null&&(Z=N),re.setLevel(Z,!1)}var f=new d,m={};f.getLogger=function(N){if(typeof N!="symbol"&&typeof N!="string"||N==="")throw new TypeError("You must supply a name when creating a logger.");var z=m[N];return z||(z=m[N]=new d(N,f.getLevel(),f.methodFactory)),z};var k=typeof window!==r?window.log:void 0;return f.noConflict=function(){return typeof window!==r&&window.log===f&&(window.log=k),f},f.getLoggers=function(){return m},f.default=f,f})})(XR);var Qte=XR.exports;/*
1171
1171
  @license
1172
1172
  Copyright (c) 2022 Twilio Inc.
1173
1173
 
@@ -1305,10 +1305,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
1305
1305
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
1306
1306
  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1307
1307
 
1308
- */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=ku,n=cs,i=Yi,a=Ji,s=ii,o=ds,u=$a,l=Qi,c=Au,d=ni,f=Ou,m=n9,k=en,L=Zc,N=xh,z=bq,re=Wc,Me=Xi,Oe=hy,Be=QI,Pe=jn,Ze=Fx,Z=Tp,Ie=ad,_e=Qc;function se(E){return E&&typeof E=="object"&&"default"in E?E:{default:E}}function Te(E){if(E&&E.__esModule)return E;var x=Object.create(null);return E&&Object.keys(E).forEach(function(b){if(b!=="default"){var p=Object.getOwnPropertyDescriptor(E,b);Object.defineProperty(x,b,p.get?p:{enumerable:!0,get:function(){return E[b]}})}}),x.default=E,Object.freeze(x)}var te=se(r),oe=se(n),q=se(i),ne=se(a),Se=se(s),H=se(o),ye=se(u),ke=se(l),P=se(c),Qe=se(d),Ct=Te(f),tt=se(L),De=se(z),ce=se(re),Ge=se(Ie);function Ue(E,x,b,p){var h=arguments.length,w=h<3?x:p===null?p=Object.getOwnPropertyDescriptor(x,b):p,v;if((typeof Reflect>"u"?"undefined":Qe.default(Reflect))==="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(E,x,b,p);else for(var g=E.length-1;g>=0;g--)(v=E[g])&&(w=(h<3?v(w):h>3?v(x,b,w):v(x,b))||w);return h>3&&w&&Object.defineProperty(x,b,w),w}function be(E,x){if((typeof Reflect>"u"?"undefined":Qe.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(E,x)}function ht(E,x){return["".concat(new Date().toISOString()," Conversations ").concat(E,":")].concat(Array.from(x))}var Ve=Ct.getLogger("twilio-conversations"),Kt=function(){function E(x){ke.default(this,E),H.default(this,"prefix",""),this.prefix=x!=null&&x.length>0?x+" ":""}return ye.default(E,[{key:"setLevel",value:function(b){Ve.setLevel(b)}},{key:"trace",value:function(){if(Ve.getLevel()==Ve.levels.TRACE){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.debug.apply(null,ht(this.prefix+"T",p))}}},{key:"debug",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.debug.apply(null,ht(this.prefix+"D",p))}},{key:"info",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.info.apply(null,ht(this.prefix+"I",p))}},{key:"warn",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.warn.apply(null,ht(this.prefix+"W",p))}},{key:"error",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.error.apply(null,ht(this.prefix+"E",p))}}],[{key:"scope",value:function(b){return new E(b)}},{key:"setLevel",value:function(b){Ve.setLevel(b)}},{key:"trace",value:function(){if(Ve.getLevel()==Ve.levels.TRACE){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.debug.apply(null,ht("T",p))}}},{key:"debug",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.debug.apply(null,ht("D",p))}},{key:"info",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.info.apply(null,ht("I",p))}},{key:"warn",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.warn.apply(null,ht("W",p))}},{key:"error",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.error.apply(null,ht("E",p))}}]),E}();function Rt(E,x){var b=Object.keys(E);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(E);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(E,h).enumerable})),b.push.apply(b,p)}return b}function Q(E){for(var x=1;x<arguments.length;x++){var b=arguments[x]!=null?arguments[x]:{};x%2?Rt(Object(b),!0).forEach(function(p){H.default(E,p,b[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(E,Object.getOwnPropertyDescriptors(b)):Rt(Object(b)).forEach(function(p){Object.defineProperty(E,p,Object.getOwnPropertyDescriptor(b,p))})}return E}var je=5,st="PT5S",Re="PT5S",kt=100,ot=1e3,ar=4e3,mr=3,Xe=!0,Or=100,jr=1e3,lr=ye.default(function E(){var x,b,p,h,w,v,g,y,_=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},S=arguments.length>1?arguments[1]:void 0,J=arguments.length>2?arguments[2]:void 0;ke.default(this,E),H.default(this,"typingIndicatorTimeoutDefault",je*1e3);var Y=_.Chat||_.IPMessaging||_||{};this.productId=Y.productId,this.links={myConversations:S.links.my_conversations,conversations:S.links.conversations,users:S.links.users,currentUser:S.links.current_user,typing:S.links.typing,mediaService:S.links.media_service,mediaSetService:S.links.media_set_service,messagesReceipts:S.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:S.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:S.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:S.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:S.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:S.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=Y.typingIndicatorTimeoutOverride,this.backoffConfiguration=Q({min:ot,max:ar,maxAttemptsCount:mr},Y.backoffConfigOverride),this.retryWhenThrottled=Y.retryWhenThrottledOverride!==void 0?Y.retryWhenThrottledOverride:Xe,this.userInfosToSubscribe=(x=(b=Y.userInfosToSubscribeOverride)!==null&&b!==void 0?b:S.options.user_infos_to_subscribe)!==null&&x!==void 0?x:kt,this.reachabilityEnabled=S.options.reachability_enabled,this.userIdentity=S.identity,this.userInfo=S.sync_objects.my_user_info,this.myConversations=S.sync_objects.my_conversations;var le=(p=(h=Y.httpCacheIntervalOverride)!==null&&h!==void 0?h:S.options.http_cache_interval)!==null&&p!==void 0?p:st;try{this.httpCacheInterval=m.toSeconds(m.parse(le))}catch{J.error("Failed to parse http cache interval ".concat(le,", using default value ").concat(st)),this.httpCacheInterval=m.toSeconds(m.parse(st))}var me=(w=(v=Y.consumptionReportIntervalOverride)!==null&&v!==void 0?v:S.options.consumption_report_interval)!==null&&w!==void 0?w:Re;try{this.consumptionReportInterval=m.toSeconds(m.parse(me))}catch{J.error("Failed to parse consumption report interval ".concat(me,", using default value ").concat(Re)),this.consumptionReportInterval=m.toSeconds(m.parse(Re))}this.channelMetadataCacheCapacity=(g=_.channelMetadataCacheCapacity)!==null&&g!==void 0?g:Or,this.messageRecipientsCacheCapacity=(y=_.messageRecipientsCacheCapacity)!==null&&y!==void 0?y:jr});function cr(E){return JSON.parse(JSON.stringify(E))}function Vt(E){return typeof E<"u"&&!isNaN(Number(E))?Number(E):null}function At(E){try{return new Date(E)}catch{return null}}function M(E,x,b){var p={};if(E)try{p=JSON.parse(E)}catch(h){b.warn(x,h)}return p}var V=function(){function E(x){ke.default(this,E),this.base=x.replace(/\/$/,""),this.args=[],this.paths=[]}return ye.default(E,[{key:"arg",value:function(b,p){return typeof p<"u"&&this.args.push(encodeURIComponent(b)+"="+encodeURIComponent(p)),this}},{key:"path",value:function(b){return this.paths.push(encodeURIComponent(b)),this}},{key:"build",value:function(){var b=this.base;return this.paths.length&&(b+="/"+this.paths.join("/")),this.args.length&&(b+="?"+this.args.join("&")),b}}]),E}(),ie=k.custom(function(E){return[["string","number","boolean","object"].includes(Qe.default(E)),"a JSON type"]}),Fe=k.custom(function(E){return[["undefined","string","number","boolean","object"].includes(Qe.default(E)),"an optional JSON type"]}),lt=k.objectSchema("send media options",{contentType:[k.literal(null),"string"],filename:["string","undefined"],media:[k.literal("null"),"string"].concat(tt.default(typeof Buffer=="function"?[Buffer]:[]),tt.default(typeof Blob=="function"?[Blob]:[]))});function yt(E){var x=Bt();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Bt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var er=Kt.scope("User"),Ee=function(E){q.default(b,E);var x=yt(b);function b(p,h,w,v){var g;return ke.default(this,b),g=x.call(this),H.default(oe.default(g),"promiseToFetch",null),H.default(oe.default(g),"updated","updated"),H.default(oe.default(g),"userSubscribed","userSubscribed"),H.default(oe.default(g),"userUnsubscribed","userUnsubscribed"),g.services=v,g.subscribed="initializing",g.setMaxListeners(0),g.state={identity:p,entityName:h,friendlyName:null,attributes:{},online:null,notifiable:null},g._initializationPromise=new Promise(function(y){g._resolveInitializationPromise=y}),w!==null&&g._resolveInitialization(w,p,h,!1),g}return ye.default(b,[{key:"identity",get:function(){return this.state.identity},set:function(h){this.state.identity=h}},{key:"entityName",set:function(h){this.state.entityName=h}},{key:"attributes",get:function(){return this.state.attributes}},{key:"friendlyName",get:function(){return this.state.friendlyName}},{key:"isOnline",get:function(){return this.state.online}},{key:"isNotifiable",get:function(){return this.state.notifiable}},{key:"isSubscribed",get:function(){return this.subscribed=="subscribed"}},{key:"_update",value:function(){var p=te.default(P.default.mark(function w(v,g){var y,_;return P.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return J.next=2,this._initializationPromise;case 2:y=[],er.debug("User for",this.state.identity,"updated:",v,g),J.t0=v,J.next=J.t0==="friendlyName"?7:J.t0==="attributes"?9:J.t0==="reachability"?12:15;break;case 7:return this.state.friendlyName!==g.value&&(y.push("friendlyName"),this.state.friendlyName=g.value),J.abrupt("break",16);case 9:return _=M(g.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),er),De.default(this.state.attributes,_)||(this.state.attributes=_,y.push("attributes")),J.abrupt("break",16);case 12:return this.state.online!==g.online&&(this.state.online=g.online,y.push("reachabilityOnline")),this.state.notifiable!==g.notifiable&&(this.state.notifiable=g.notifiable,y.push("reachabilityNotifiable")),J.abrupt("break",16);case 15:return J.abrupt("return");case 16:y.length>0&&this.emit("updated",{user:this,updateReasons:y});case 17:case"end":return J.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"_updateReachabilityInfo",value:function(){var p=te.default(P.default.mark(function w(v,g){var y=this;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){S.next=4;break}return S.abrupt("return",Promise.resolve());case 4:return S.abrupt("return",v.get("reachability").then(g).catch(function(J){er.warn("Failed to get reachability info for ",y.state.identity,J)}));case 5:case"end":return S.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"_fetch",value:function(){var p=te.default(P.default.mark(function w(){var v=this;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.state.entityName){y.next=4;break}return y.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then(function(_){return v.entity=_,_.on("itemUpdated",function(S){return er.debug(v.state.entityName+" ("+v.state.identity+") itemUpdated: "+S.item.key),v._update(S.item.key,S.item.data)}),_.on("itemAdded",function(S){return er.debug(v.state.entityName+" ("+v.state.identity+") itemAdded: "+S.item.key),v._update(S.item.key,S.item.data)}),Promise.all([_.get("friendlyName").then(function(S){return v._update(S.key,S.data)}),_.get("attributes").then(function(S){return v._update(S.key,S.data)}),v._updateReachabilityInfo(_,function(S){return v._update(S.key,S.data)})])}).then(function(){return er.debug("Fetched for",v.identity),v.subscribed="subscribed",v.emit("userSubscribed",v),v}).catch(function(_){throw v.promiseToFetch=null,_}),y.abrupt("return",this.promiseToFetch);case 6:case"end":return y.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_ensureFetched",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._initializationPromise;case 2:return g.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){y.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return y.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(v)});case 6:return y.abrupt("return",this);case 7:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"updateFriendlyName",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){y.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return y.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:v});case 6:return y.abrupt("return",this);case 7:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"unsubscribe",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){g.next=9;break}return g.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_resolveInitialization",value:function(h,w,v,g){this.configuration=h,this.identity=w,this.entityName=v,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),g&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),b}(N.ReplayEventEmitter);Ue([k.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],Ee.prototype,"updateAttributes",null),Ue([k.validateTypesAsync(["string"]),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],Ee.prototype,"updateFriendlyName",null);function Ne(E,x){var b=typeof Symbol<"u"&&E[Symbol.iterator]||E["@@iterator"];if(!b){if(Array.isArray(E)||(b=pe(E))||x){b&&(E=b);var p=0,h=function(){};return{s:h,n:function(){return p>=E.length?{done:!0}:{done:!1,value:E[p++]}},e:function(_){throw _},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1308
+ */(function(t){var e=typeof e<"u"?e:typeof self<"u"?self:typeof window<"u"?window:{};Object.defineProperty(t,"__esModule",{value:!0});var r=ku,n=cs,i=Yi,a=Ji,s=ii,o=ds,u=$a,l=Qi,c=Au,d=ni,f=Ou,m=n9,k=en,L=Zc,N=xh,z=bq,re=Wc,Me=Xi,Oe=hy,Fe=QI,Pe=jn,Ze=Fx,Z=Tp,Ie=ad,_e=Qc;function se(E){return E&&typeof E=="object"&&"default"in E?E:{default:E}}function Te(E){if(E&&E.__esModule)return E;var x=Object.create(null);return E&&Object.keys(E).forEach(function(b){if(b!=="default"){var p=Object.getOwnPropertyDescriptor(E,b);Object.defineProperty(x,b,p.get?p:{enumerable:!0,get:function(){return E[b]}})}}),x.default=E,Object.freeze(x)}var te=se(r),oe=se(n),q=se(i),ne=se(a),Se=se(s),H=se(o),ye=se(u),ke=se(l),P=se(c),Qe=se(d),Ct=Te(f),tt=se(L),De=se(z),ce=se(re),Ge=se(Ie);function Ue(E,x,b,p){var h=arguments.length,w=h<3?x:p===null?p=Object.getOwnPropertyDescriptor(x,b):p,v;if((typeof Reflect>"u"?"undefined":Qe.default(Reflect))==="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(E,x,b,p);else for(var g=E.length-1;g>=0;g--)(v=E[g])&&(w=(h<3?v(w):h>3?v(x,b,w):v(x,b))||w);return h>3&&w&&Object.defineProperty(x,b,w),w}function be(E,x){if((typeof Reflect>"u"?"undefined":Qe.default(Reflect))==="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(E,x)}function ht(E,x){return["".concat(new Date().toISOString()," Conversations ").concat(E,":")].concat(Array.from(x))}var Ve=Ct.getLogger("twilio-conversations"),Kt=function(){function E(x){ke.default(this,E),H.default(this,"prefix",""),this.prefix=x!=null&&x.length>0?x+" ":""}return ye.default(E,[{key:"setLevel",value:function(b){Ve.setLevel(b)}},{key:"trace",value:function(){if(Ve.getLevel()==Ve.levels.TRACE){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.debug.apply(null,ht(this.prefix+"T",p))}}},{key:"debug",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.debug.apply(null,ht(this.prefix+"D",p))}},{key:"info",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.info.apply(null,ht(this.prefix+"I",p))}},{key:"warn",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.warn.apply(null,ht(this.prefix+"W",p))}},{key:"error",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.error.apply(null,ht(this.prefix+"E",p))}}],[{key:"scope",value:function(b){return new E(b)}},{key:"setLevel",value:function(b){Ve.setLevel(b)}},{key:"trace",value:function(){if(Ve.getLevel()==Ve.levels.TRACE){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.debug.apply(null,ht("T",p))}}},{key:"debug",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.debug.apply(null,ht("D",p))}},{key:"info",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.info.apply(null,ht("I",p))}},{key:"warn",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.warn.apply(null,ht("W",p))}},{key:"error",value:function(){for(var b=arguments.length,p=new Array(b),h=0;h<b;h++)p[h]=arguments[h];Ve.error.apply(null,ht("E",p))}}]),E}();function Rt(E,x){var b=Object.keys(E);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(E);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(E,h).enumerable})),b.push.apply(b,p)}return b}function Q(E){for(var x=1;x<arguments.length;x++){var b=arguments[x]!=null?arguments[x]:{};x%2?Rt(Object(b),!0).forEach(function(p){H.default(E,p,b[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(E,Object.getOwnPropertyDescriptors(b)):Rt(Object(b)).forEach(function(p){Object.defineProperty(E,p,Object.getOwnPropertyDescriptor(b,p))})}return E}var je=5,st="PT5S",Re="PT5S",kt=100,ot=1e3,ar=4e3,mr=3,Xe=!0,Or=100,jr=1e3,lr=ye.default(function E(){var x,b,p,h,w,v,g,y,_=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},S=arguments.length>1?arguments[1]:void 0,J=arguments.length>2?arguments[2]:void 0;ke.default(this,E),H.default(this,"typingIndicatorTimeoutDefault",je*1e3);var Y=_.Chat||_.IPMessaging||_||{};this.productId=Y.productId,this.links={myConversations:S.links.my_conversations,conversations:S.links.conversations,users:S.links.users,currentUser:S.links.current_user,typing:S.links.typing,mediaService:S.links.media_service,mediaSetService:S.links.media_set_service,messagesReceipts:S.links.messages_receipts},this.limits={mediaAttachmentsCountLimit:S.options.media_attachments_count_limit,mediaAttachmentSizeLimitInMb:S.options.media_attachment_size_limit_in_mb,mediaAttachmentsTotalSizeLimitInMb:S.options.media_attachments_total_size_limit_in_mb,emailHistoriesAllowedContentTypes:S.options.email_histories_allowed_mime_types,emailBodiesAllowedContentTypes:S.options.email_bodies_allowed_mime_types},this.typingIndicatorTimeoutOverride=Y.typingIndicatorTimeoutOverride,this.backoffConfiguration=Q({min:ot,max:ar,maxAttemptsCount:mr},Y.backoffConfigOverride),this.retryWhenThrottled=Y.retryWhenThrottledOverride!==void 0?Y.retryWhenThrottledOverride:Xe,this.userInfosToSubscribe=(x=(b=Y.userInfosToSubscribeOverride)!==null&&b!==void 0?b:S.options.user_infos_to_subscribe)!==null&&x!==void 0?x:kt,this.reachabilityEnabled=S.options.reachability_enabled,this.userIdentity=S.identity,this.userInfo=S.sync_objects.my_user_info,this.myConversations=S.sync_objects.my_conversations;var le=(p=(h=Y.httpCacheIntervalOverride)!==null&&h!==void 0?h:S.options.http_cache_interval)!==null&&p!==void 0?p:st;try{this.httpCacheInterval=m.toSeconds(m.parse(le))}catch{J.error("Failed to parse http cache interval ".concat(le,", using default value ").concat(st)),this.httpCacheInterval=m.toSeconds(m.parse(st))}var me=(w=(v=Y.consumptionReportIntervalOverride)!==null&&v!==void 0?v:S.options.consumption_report_interval)!==null&&w!==void 0?w:Re;try{this.consumptionReportInterval=m.toSeconds(m.parse(me))}catch{J.error("Failed to parse consumption report interval ".concat(me,", using default value ").concat(Re)),this.consumptionReportInterval=m.toSeconds(m.parse(Re))}this.channelMetadataCacheCapacity=(g=_.channelMetadataCacheCapacity)!==null&&g!==void 0?g:Or,this.messageRecipientsCacheCapacity=(y=_.messageRecipientsCacheCapacity)!==null&&y!==void 0?y:jr});function cr(E){return JSON.parse(JSON.stringify(E))}function Vt(E){return typeof E<"u"&&!isNaN(Number(E))?Number(E):null}function At(E){try{return new Date(E)}catch{return null}}function M(E,x,b){var p={};if(E)try{p=JSON.parse(E)}catch(h){b.warn(x,h)}return p}var V=function(){function E(x){ke.default(this,E),this.base=x.replace(/\/$/,""),this.args=[],this.paths=[]}return ye.default(E,[{key:"arg",value:function(b,p){return typeof p<"u"&&this.args.push(encodeURIComponent(b)+"="+encodeURIComponent(p)),this}},{key:"path",value:function(b){return this.paths.push(encodeURIComponent(b)),this}},{key:"build",value:function(){var b=this.base;return this.paths.length&&(b+="/"+this.paths.join("/")),this.args.length&&(b+="?"+this.args.join("&")),b}}]),E}(),ie=k.custom(function(E){return[["string","number","boolean","object"].includes(Qe.default(E)),"a JSON type"]}),Be=k.custom(function(E){return[["undefined","string","number","boolean","object"].includes(Qe.default(E)),"an optional JSON type"]}),lt=k.objectSchema("send media options",{contentType:[k.literal(null),"string"],filename:["string","undefined"],media:[k.literal("null"),"string"].concat(tt.default(typeof Buffer=="function"?[Buffer]:[]),tt.default(typeof Blob=="function"?[Blob]:[]))});function yt(E){var x=Bt();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Bt(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var er=Kt.scope("User"),Ee=function(E){q.default(b,E);var x=yt(b);function b(p,h,w,v){var g;return ke.default(this,b),g=x.call(this),H.default(oe.default(g),"promiseToFetch",null),H.default(oe.default(g),"updated","updated"),H.default(oe.default(g),"userSubscribed","userSubscribed"),H.default(oe.default(g),"userUnsubscribed","userUnsubscribed"),g.services=v,g.subscribed="initializing",g.setMaxListeners(0),g.state={identity:p,entityName:h,friendlyName:null,attributes:{},online:null,notifiable:null},g._initializationPromise=new Promise(function(y){g._resolveInitializationPromise=y}),w!==null&&g._resolveInitialization(w,p,h,!1),g}return ye.default(b,[{key:"identity",get:function(){return this.state.identity},set:function(h){this.state.identity=h}},{key:"entityName",set:function(h){this.state.entityName=h}},{key:"attributes",get:function(){return this.state.attributes}},{key:"friendlyName",get:function(){return this.state.friendlyName}},{key:"isOnline",get:function(){return this.state.online}},{key:"isNotifiable",get:function(){return this.state.notifiable}},{key:"isSubscribed",get:function(){return this.subscribed=="subscribed"}},{key:"_update",value:function(){var p=te.default(P.default.mark(function w(v,g){var y,_;return P.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return J.next=2,this._initializationPromise;case 2:y=[],er.debug("User for",this.state.identity,"updated:",v,g),J.t0=v,J.next=J.t0==="friendlyName"?7:J.t0==="attributes"?9:J.t0==="reachability"?12:15;break;case 7:return this.state.friendlyName!==g.value&&(y.push("friendlyName"),this.state.friendlyName=g.value),J.abrupt("break",16);case 9:return _=M(g.value,"Retrieved malformed attributes from the server for user: ".concat(this.state.identity),er),De.default(this.state.attributes,_)||(this.state.attributes=_,y.push("attributes")),J.abrupt("break",16);case 12:return this.state.online!==g.online&&(this.state.online=g.online,y.push("reachabilityOnline")),this.state.notifiable!==g.notifiable&&(this.state.notifiable=g.notifiable,y.push("reachabilityNotifiable")),J.abrupt("break",16);case 15:return J.abrupt("return");case 16:y.length>0&&this.emit("updated",{user:this,updateReasons:y});case 17:case"end":return J.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"_updateReachabilityInfo",value:function(){var p=te.default(P.default.mark(function w(v,g){var y=this;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._initializationPromise;case 2:if(this.configuration.reachabilityEnabled){S.next=4;break}return S.abrupt("return",Promise.resolve());case 4:return S.abrupt("return",v.get("reachability").then(g).catch(function(J){er.warn("Failed to get reachability info for ",y.state.identity,J)}));case 5:case"end":return S.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"_fetch",value:function(){var p=te.default(P.default.mark(function w(){var v=this;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.state.entityName){y.next=4;break}return y.abrupt("return",this);case 4:return this.promiseToFetch=this.services.syncClient.map({id:this.state.entityName,mode:"open_existing",includeItems:!0}).then(function(_){return v.entity=_,_.on("itemUpdated",function(S){return er.debug(v.state.entityName+" ("+v.state.identity+") itemUpdated: "+S.item.key),v._update(S.item.key,S.item.data)}),_.on("itemAdded",function(S){return er.debug(v.state.entityName+" ("+v.state.identity+") itemAdded: "+S.item.key),v._update(S.item.key,S.item.data)}),Promise.all([_.get("friendlyName").then(function(S){return v._update(S.key,S.data)}),_.get("attributes").then(function(S){return v._update(S.key,S.data)}),v._updateReachabilityInfo(_,function(S){return v._update(S.key,S.data)})])}).then(function(){return er.debug("Fetched for",v.identity),v.subscribed="subscribed",v.emit("userSubscribed",v),v}).catch(function(_){throw v.promiseToFetch=null,_}),y.abrupt("return",this.promiseToFetch);case 6:case"end":return y.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_ensureFetched",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._initializationPromise;case 2:return g.abrupt("return",this.promiseToFetch||this._fetch());case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){y.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return y.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(v)});case 6:return y.abrupt("return",this);case 7:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"updateFriendlyName",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._initializationPromise;case 2:if(this.subscribed!="unsubscribed"){y.next=4;break}throw new Error("Can't modify unsubscribed object");case 4:return y.next=6,this.services.commandExecutor.mutateResource("post",this.links.self,{friendly_name:v});case 6:return y.abrupt("return",this);case 7:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"unsubscribe",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._initializationPromise;case 2:if(!this.promiseToFetch){g.next=9;break}return g.next=5,this.promiseToFetch;case 5:this.entity.close(),this.promiseToFetch=null,this.subscribed="unsubscribed",this.emit("userUnsubscribed",this);case 9:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_resolveInitialization",value:function(h,w,v,g){this.configuration=h,this.identity=w,this.entityName=v,this.links={self:"".concat(this.configuration.links.users,"/").concat(encodeURIComponent(this.identity))},this._resolveInitializationPromise(),g&&this.emit("updated",{user:this,updateReasons:["friendlyName","attributes","reachabilityOnline","reachabilityNotifiable"]})}}]),b}(N.ReplayEventEmitter);Ue([k.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],Ee.prototype,"updateAttributes",null),Ue([k.validateTypesAsync(["string"]),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],Ee.prototype,"updateFriendlyName",null);function Ne(E,x){var b=typeof Symbol<"u"&&E[Symbol.iterator]||E["@@iterator"];if(!b){if(Array.isArray(E)||(b=pe(E))||x){b&&(E=b);var p=0,h=function(){};return{s:h,n:function(){return p>=E.length?{done:!0}:{done:!1,value:E[p++]}},e:function(_){throw _},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1309
1309
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var w=!0,v=!1,g;return{s:function(){b=b.call(E)},n:function(){var _=b.next();return w=_.done,_},e:function(_){v=!0,g=_},f:function(){try{!w&&b.return!=null&&b.return()}finally{if(v)throw g}}}}function pe(E,x){if(E){if(typeof E=="string")return $e(E,x);var b=Object.prototype.toString.call(E).slice(8,-1);if(b==="Object"&&E.constructor&&(b=E.constructor.name),b==="Map"||b==="Set")return Array.from(E);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return $e(E,x)}}function $e(E,x){(x==null||x>E.length)&&(x=E.length);for(var b=0,p=new Array(x);b<x;b++)p[b]=E[b];return p}var ae=function(){function E(x,b){ke.default(this,E),this.configuration=x,this.services=b,this.cache=new Map,this.cacheLifetime=this.configuration.httpCacheInterval*100,this.cleanupCache()}return ye.default(E,[{key:"isExpired",value:function(b){return!this.cacheLifetime||Date.now()-b>this.cacheLifetime}},{key:"cleanupCache",value:function(){var b=Ne(this.cache),p;try{for(b.s();!(p=b.n()).done;){var h=ce.default(p.value,2),w=h[0],v=h[1];this.isExpired(v.timestamp)&&this.cache.delete(w)}}catch(g){b.e(g)}finally{b.f()}this.cache.size===0&&clearInterval(this.timer)}},{key:"pokeTimer",value:function(){var b=this;this.timer=this.timer||setInterval(function(){return b.cleanupCache()},this.cacheLifetime*2)}},{key:"executeWithRetry",value:function(b){var p=this,h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return new Promise(function(w,v){var g=[502,503,504];h&&g.push(429);var y=new Me.Retrier(p.configuration.backoffConfiguration);y.on("attempt",function(){b().then(function(_){return y.succeeded(_)}).catch(function(_){g.indexOf(_.status)>-1||_.message==="Twilsock disconnected"?y.failed(_):(y.removeAllListeners(),y.cancel(),v(_))})}),y.on("succeeded",function(_){w(_)}),y.on("cancelled",function(_){return v(_)}),y.on("failed",function(_){return v(_)}),y.start()})}},{key:"get",value:function(){var x=te.default(P.default.mark(function p(h){var w=this,v,g,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(v=this.cache.get(h),!(v&&!this.isExpired(v.timestamp))){S.next=3;break}return S.abrupt("return",v.response);case 3:return g={},S.next=6,this.executeWithRetry(function(){return w.services.transport.get(h,g,w.configuration.productId)},this.configuration.retryWhenThrottled);case 6:return y=S.sent,this.cache.set(h,{response:y,timestamp:Date.now()}),this.pokeTimer(),S.abrupt("return",y);case 10:case"end":return S.stop()}},p,this)}));function b(p){return x.apply(this,arguments)}return b}()}]),E}(),ge=ye.default(function E(){ke.default(this,E)});H.default(ge,"TYPING_INDICATOR","twilio.ipmsg.typing_indicator"),H.default(ge,"NEW_MESSAGE","twilio.conversations.new_message"),H.default(ge,"ADDED_TO_CONVERSATION","twilio.conversations.added_to_conversation"),H.default(ge,"REMOVED_FROM_CONVERSATION","twilio.conversations.removed_from_conversation"),H.default(ge,"CONSUMPTION_UPDATE","twilio.channel.consumption_update");function we(E){var x=K();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function K(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var he=Kt.scope("Participant"),G=function(E){q.default(b,E);var x=we(b);function b(p,h,w,v,g){var y,_,S;if(ke.default(this,b),S=x.call(this),S.conversation=w,S.links=v,S.services=g,S.state={attributes:M(p.attributes,"Retrieved malformed attributes from the server for participant: "+h,he),dateCreated:p.dateCreated?At(p.dateCreated):null,dateUpdated:p.dateCreated?At(p.dateUpdated):null,sid:h,typingTimeout:null,isTyping:!1,identity:p.identity,roleSid:(y=p.roleSid)!==null&&y!==void 0?y:"",lastReadMessageIndex:Number.isInteger(p.lastConsumedMessageIndex)?p.lastConsumedMessageIndex:null,lastReadTimestamp:p.lastConsumptionTimestamp?At(p.lastConsumptionTimestamp):null,type:p.type||"chat",userInfo:p.userInfo,bindings:(_=p.bindings)!==null&&_!==void 0?_:{}},!p.identity&&!p.type)throw new Error("Received invalid Participant object from server: Missing identity or type of Participant.");return S}return ye.default(b,[{key:"sid",get:function(){return this.state.sid}},{key:"attributes",get:function(){return this.state.attributes}},{key:"dateCreated",get:function(){return this.state.dateCreated}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"identity",get:function(){return this.state.identity}},{key:"isTyping",get:function(){return this.state.isTyping}},{key:"lastReadMessageIndex",get:function(){return this.state.lastReadMessageIndex}},{key:"lastReadTimestamp",get:function(){return this.state.lastReadTimestamp}},{key:"roleSid",get:function(){return this.state.roleSid}},{key:"type",get:function(){return this.state.type}},{key:"bindings",get:function(){var h;return(h=this.state.bindings)!==null&&h!==void 0?h:{}}},{key:"_startTyping",value:function(h){var w=this;return this.state.typingTimeout&&clearTimeout(this.state.typingTimeout),this.state.isTyping=!0,this.emit(b.typingStarted,this),this.conversation.emit(R.typingStarted,this),this.state.typingTimeout=Number(setTimeout(function(){return w._endTyping()},h)),this}},{key:"_endTyping",value:function(){this.state.typingTimeout&&(this.state.isTyping=!1,this.emit(b.typingEnded,this),this.conversation.emit(R.typingEnded,this),clearInterval(this.state.typingTimeout),this.state.typingTimeout=null)}},{key:"_update",value:function(h){var w=[],v=M(h.attributes,"Retrieved malformed attributes from the server for participant: "+this.state.sid,he);h.attributes&&!De.default(this.state.attributes,v)&&(this.state.attributes=v,w.push("attributes"));var g=At(h.dateUpdated);h.dateUpdated&&(g==null?void 0:g.getTime())!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=g,w.push("dateUpdated"));var y=At(h.dateCreated);if(h.dateCreated&&(y==null?void 0:y.getTime())!==(this.state.dateCreated&&this.state.dateCreated.getTime())&&(this.state.dateCreated=y,w.push("dateCreated")),h.roleSid&&this.state.roleSid!==h.roleSid&&(this.state.roleSid=h.roleSid,w.push("roleSid")),(Number.isInteger(h.lastConsumedMessageIndex)||h.lastConsumedMessageIndex===null)&&this.state.lastReadMessageIndex!==h.lastConsumedMessageIndex&&(this.state.lastReadMessageIndex=h.lastConsumedMessageIndex,w.push("lastReadMessageIndex")),h.lastConsumptionTimestamp){var _=new Date(h.lastConsumptionTimestamp);(!this.state.lastReadTimestamp||this.state.lastReadTimestamp.getTime()!==_.getTime())&&(this.state.lastReadTimestamp=_,w.push("lastReadTimestamp"))}return h.bindings&&!De.default(this.state.bindings,h.bindings)&&(this.state.bindings=h.bindings,w.push("bindings")),w.length>0&&this.emit(b.updated,{participant:this,updateReasons:w}),this}},{key:"getUser",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.type=="chat"){g.next=2;break}throw new Error("Getting User is not supported for this Participant type: "+this.type);case 2:return g.abrupt("return",this.services.users.getUser(this.state.identity,this.state.userInfo));case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.abrupt("return",this.conversation.removeParticipant(this));case 1:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:JSON.stringify(v)});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()}]),b}(N.ReplayEventEmitter);H.default(G,"typingStarted","typingStarted"),H.default(G,"typingEnded","typingEnded"),H.default(G,"updated","updated"),Ue([k.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],G.prototype,"updateAttributes",null);function de(E){var x=X();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function X(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Ye=Kt.scope("Participants"),ze=function(E){q.default(b,E);var x=de(b);function b(p,h,w,v){var g;return ke.default(this,b),g=x.call(this),H.default(oe.default(g),"rosterEntityPromise",null),g.conversation=p,g.participants=h,g.links=w,g.services=v,g}return ye.default(b,[{key:"unsubscribe",value:function(){var p=te.default(P.default.mark(function w(){var v;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this.rosterEntityPromise){y.next=6;break}return y.next=3,this.rosterEntityPromise;case 3:v=y.sent,v.close(),this.rosterEntityPromise=null;case 6:case"end":return y.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"subscribe",value:function(h){var w=this,v=typeof h=="string"?this.services.syncClient.map({id:h,mode:"open_existing"}):Promise.resolve(h);return this.rosterEntityPromise=this.rosterEntityPromise||v.then(function(g){g.on(Pe.SyncMap.itemAdded,function(S){Ye.debug(w.conversation.sid+" itemAdded: "+S.item.key),w.upsertParticipant(S.item.key,S.item.data).then(function(J){w.emit(R.participantJoined,J)})}),g.on(Pe.SyncMap.itemRemoved,function(S){Ye.debug(w.conversation.sid+" itemRemoved: "+S.key);var J=S.key;if(w.participants.has(J)){var Y=w.participants.get(J);w.participants.delete(J),Y&&w.emit(R.participantLeft,Y)}}),g.on(Pe.SyncMap.itemUpdated,function(S){Ye.debug(w.conversation.sid+" itemUpdated: "+S.item.key),w.upsertParticipant(S.item.key,S.item.data).catch(function(J){return Ye.error(J)})});var y=[],_=function S(J){return J.items.forEach(function(Y){y.push(w.upsertParticipant(Y.key,Y.data))}),J.hasNextPage?J.nextPage().then(S):null};return g.getItems().then(_).then(function(){return Promise.all(y)}).then(function(){return g})}).catch(function(g){throw w.rosterEntityPromise=null,w.services.syncClient.connectionState!="disconnected"&&Ye.error("Failed to get roster object for conversation",w.conversation.sid,g),Ye.debug("ERROR: Failed to get roster object for conversation",w.conversation.sid,g),g})}},{key:"upsertParticipantFromResponse",value:function(){var p=te.default(P.default.mark(function w(v){var g,y,_,S,J,Y,le,me;return P.default.wrap(function(Tt){for(;;)switch(Tt.prev=Tt.next){case 0:return y=v.sid,_=v.attributes,S=v.date_created,J=v.date_updated,Y=v.identity,le=v.role_sid,me=v.messaging_binding,Tt.next=3,this.upsertParticipant(y,{attributes:_,dateCreated:new Date(S),dateUpdated:new Date(J),identity:Y,roleSid:le,lastConsumedMessageIndex:null,lastConsumptionTimestamp:null,type:(g=me==null?void 0:me.type)!==null&&g!==void 0?g:"chat"});case 3:return Tt.abrupt("return",Tt.sent);case 4:case"end":return Tt.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"upsertParticipant",value:function(){var p=te.default(P.default.mark(function w(v,g){var y=this,_,S;return P.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:if(_=this.participants.get(v),!_){Y.next=3;break}return Y.abrupt("return",_._update(g));case 3:return S={self:"".concat(this.links.participants,"/").concat(v)},_=new G(g,v,this.conversation,S,this.services),this.participants.set(v,_),_.on(G.updated,function(le){return y.emit(R.participantUpdated,le)}),Y.abrupt("return",_);case 8:case"end":return Y.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"getParticipants",value:function(){var p=te.default(P.default.mark(function w(){var v=this;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var _=[];return v.participants.forEach(function(S){return _.push(S)}),_}):[]);case 1:case"end":return y.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantBySid",value:function(){var p=te.default(P.default.mark(function w(v){var g=this;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){var S=g.participants.get(v);if(!S)throw new Error("Participant with SID "+v+" was not found");return S}):null);case 1:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getParticipantByIdentity",value:function(){var p=te.default(P.default.mark(function w(v){var g=this,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return y=null,S.abrupt("return",this.rosterEntityPromise?this.rosterEntityPromise.then(function(){if(g.participants.forEach(function(J){J.identity===v&&(y=J)}),!y)throw new Error("Participant with identity "+v+" was not found");return y}):null);case 2:case"end":return S.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"add",value:function(){var p=te.default(P.default.mark(function w(v,g){return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this.services.commandExecutor.mutateResource("post",this.links.participants,{identity:v,attributes:typeof g<"u"?JSON.stringify(g):void 0});case 2:return _.abrupt("return",_.sent);case 3:case"end":return _.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"addNonChatParticipant",value:function(){var p=te.default(P.default.mark(function w(v,g){var y,_,S,J,Y=arguments;return P.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:return S=Y.length>2&&Y[2]!==void 0?Y[2]:{},J=Y.length>3&&Y[3]!==void 0?Y[3]:{},me.next=4,this.services.commandExecutor.mutateResource("post",this.links.participants,{attributes:typeof S<"u"?JSON.stringify(S):void 0,messaging_binding:{address:g,proxy_address:v,name:J==null||(y=J.email)===null||y===void 0?void 0:y.name,level:J==null||(_=J.email)===null||_===void 0?void 0:_.level}});case 4:return me.abrupt("return",me.sent);case 5:case"end":return me.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(h){return this.services.commandExecutor.mutateResource("delete","".concat(this.links.participants,"/").concat(encodeURIComponent(h)))}}]),b}(N.ReplayEventEmitter),ct=function(){function E(x,b){var p;ke.default(this,E),H.default(this,"mcsMedia",null),this.services=b,x instanceof Ze.McsMedia&&(this.mcsMedia=x),this.state={sid:x.sid,category:x.category,filename:(p=x.filename)!==null&&p!==void 0?p:null,contentType:x.contentType,size:x.size}}return ye.default(E,[{key:"sid",get:function(){return this.state.sid}},{key:"filename",get:function(){return this.state.filename}},{key:"contentType",get:function(){return this.state.contentType}},{key:"size",get:function(){return this.state.size}},{key:"category",get:function(){return this.state.category}},{key:"getContentTemporaryUrl",value:function(){var b=this;return new Ze.CancellablePromise(function(){var p=te.default(P.default.mark(function h(w,v,g){var y,_,S,J;return P.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(_=b.mcsMedia?void 0:b._fetchMcsMedia(),S=(y=b.mcsMedia)===null||y===void 0?void 0:y.getContentUrl(),g(function(){_&&_.cancel(),S&&S.cancel()}),le.prev=3,S){le.next=9;break}return le.next=7,_;case 7:J=le.sent,S=J==null?void 0:J.getContentUrl();case 9:if(le.t0=w,!S){le.next=16;break}return le.next=13,S;case 13:le.t1=le.sent,le.next=17;break;case 16:le.t1=null;case 17:le.t2=le.t1,(0,le.t0)(le.t2),le.next=24;break;case 21:le.prev=21,le.t3=le.catch(3),v(le.t3);case 24:case"end":return le.stop()}},h,null,[[3,21]])}));return function(h,w,v){return p.apply(this,arguments)}}())}},{key:"_fetchMcsMedia",value:function(){var b=this;return new Ze.CancellablePromise(function(){var p=te.default(P.default.mark(function h(w,v,g){var y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return b.services.mcsClient===null&&v(new Error("Media Content Service is unavailable")),y=b.services.mcsClient.get(b.state.sid),g(function(){return y.cancel()}),S.prev=3,S.next=6,y;case 6:b.mcsMedia=S.sent,b.state=b.mcsMedia._state(),w(b.mcsMedia),S.next=14;break;case 11:S.prev=11,S.t0=S.catch(3),v(S.t0);case 14:case"end":return S.stop()}},h,null,[[3,11]])}));return function(h,w,v){return p.apply(this,arguments)}}())}},{key:"_state",value:function(){return this.state}}]),E}(),ut=function(){function E(x){ke.default(this,E),this.state=x}return ye.default(E,[{key:"total",get:function(){return this.state.total}},{key:"sent",get:function(){return this.state.sent}},{key:"delivered",get:function(){return this.state.delivered}},{key:"read",get:function(){return this.state.read}},{key:"undelivered",get:function(){return this.state.undelivered}},{key:"failed",get:function(){return this.state.failed}},{key:"_update",value:function(b){this.state=b}},{key:"_isEquals",value:function(b){var p=this.total===b.total,h=this.sent===b.sent,w=this.delivered===b.delivered,v=this.read===b.read,g=this.undelivered===b.undelivered,y=this.failed===b.failed;return p&&h&&w&&v&&g&&y}}]),E}(),ft=function(){function E(x,b,p,h){ke.default(this,E),this.state={prevToken:p,nextToken:h,source:b,items:x}}return ye.default(E,[{key:"hasNextPage",get:function(){return!!this.state.nextToken}},{key:"hasPrevPage",get:function(){return!!this.state.prevToken}},{key:"items",get:function(){return this.state.items}},{key:"nextPage",value:function(){return this.hasNextPage?this.state.source(this.state.nextToken):Promise.reject(new Error("No next page"))}},{key:"prevPage",value:function(){return this.hasPrevPage?this.state.source(this.state.prevToken):Promise.reject(new Error("No previous page"))}}]),E}(),Et=ye.default(function E(x){ke.default(this,E),this.sid=x.sid,this.messageSid=x.message_sid,this.conversationSid=x.conversation_sid,this.channelMessageSid=x.channel_message_sid,this.participantSid=x.participant_sid,this.status=x.status||"queued",this.errorCode=x.error_code||0,this.dateCreated=x.date_created,this.dateUpdated=x.date_updated}),It=function(x){return x.map(function(b){var p,h,w,v,g=JSON.stringify(b);switch(b.type){case"QUICK_REPLY":return{type:"reply",title:b.title,id:(p=b.id)!==null&&p!==void 0?p:"",index:(h=b.index)!==null&&h!==void 0?h:0,rawData:g};case"PHONE_NUMBER":return{type:"phone",title:b.title,phone:(w=b.phone)!==null&&w!==void 0?w:"",rawData:g};case"URL":return{type:"url",title:b.title,url:(v=b.url)!==null&&v!==void 0?v:"",rawData:g};default:return{type:"other",rawData:g}}})},_t=function(x,b){var p=JSON.stringify(b);switch(x){case"twilio/text":{var h=b;return{type:"text",body:h.body,rawData:p}}case"twilio/media":{var w=b;return{type:"media",body:w.body,media:w.media,rawData:p}}case"twilio/location":{var v=b;return{type:"location",longitude:v.longitude,latitude:v.latitude,label:v.label,rawData:p}}case"twilio/quick-reply":{var g=b;return{type:"quickReply",body:g.body,replies:g.actions,rawData:p}}case"twilio/call-to-action":{var y=b;return{type:"callToAction",body:y.body,actions:It(y.actions),rawData:p}}case"twilio/list-picker":{var _=b;return{type:"listPicker",body:_.body,button:_.button,items:_.items,rawData:p}}case"twilio/card":{var S,J,Y=b;return{type:"card",title:Y.title,subtitle:Y.subtitle,media:(S=Y.media)!==null&&S!==void 0?S:[],actions:It((J=Y.actions)!==null&&J!==void 0?J:[]),rawData:p}}default:return{type:"other",rawData:p}}},St=function(x){for(var b=new Map,p=0,h=Object.entries(x);p<h.length;p++){var w=ce.default(h[p],2),v=w[0],g=w[1];b.set(v,_t(v,g))}return b},xt=function(){function E(x,b){ke.default(this,E),this.name=x,this.value=b}return ye.default(E,[{key:"copyWithValue",value:function(b){return new E(this.name,b)}}]),E}(),Dt=ye.default(function E(x){ke.default(this,E),this.sid=x.sid,this.friendlyName=x.friendly_name,this.variables=Object.entries(JSON.parse(x.variables)).map(function(b){var p=ce.default(b,2),h=p[0],w=p[1];return new xt(h,w)}),this.variants=St(x.variants),this.dateCreated=new Date(x.date_created),this.dateUpdated=new Date(x.date_updated)});function rn(E,x){var b=Object.keys(E);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(E);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(E,h).enumerable})),b.push.apply(b,p)}return b}function yn(E){for(var x=1;x<arguments.length;x++){var b=arguments[x]!=null?arguments[x]:{};x%2?rn(Object(b),!0).forEach(function(p){H.default(E,p,b[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(E,Object.getOwnPropertyDescriptors(b)):rn(Object(b)).forEach(function(p){Object.defineProperty(E,p,Object.getOwnPropertyDescriptor(b,p))})}return E}function jt(E){var x=Fn();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Fn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function sa(E,x){Ua(E,x),x.add(E)}function Ua(E,x){if(x.has(E))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Jn(E,x,b){if(!x.has(E))throw new TypeError("attempted to get private field on non-instance");return b}var oa=Kt.scope("Message"),Qn=e.XMLHttpRequest||{},fi=new WeakSet,Fa=new WeakSet,Jr=function(E){q.default(b,E);var x=jt(b);function b(p,h,w,v,g,y){var _,S,J,Y,le,me,pt,Tt;return ke.default(this,b),Tt=x.call(this),sa(oe.default(Tt),Fa),sa(oe.default(Tt),fi),Tt.conversation=w,Tt.links=v,Tt.configuration=g,Tt.services=y,Tt.state={sid:h.sid,index:p,author:h.author,subject:h.subject,contentSid:h.contentSid,body:(_=h.text)!==null&&_!==void 0?_:null,timestamp:h.timestamp?new Date(h.timestamp):null,dateUpdated:h.dateUpdated?new Date(h.dateUpdated):null,lastUpdatedBy:(S=h.lastUpdatedBy)!==null&&S!==void 0?S:null,attributes:M(h.attributes,"Got malformed attributes for the message ".concat(h.sid),oa),type:(J=h.type)!==null&&J!==void 0?J:"text",media:null,medias:null,participantSid:(Y=h.memberSid)!==null&&Y!==void 0?Y:null,aggregatedDeliveryReceipt:h.delivery?new ut(h.delivery):null,hasChannelMetadata:(le=h.channelMetadata)!==null&&le!==void 0?le:!1},Jn(oe.default(Tt),Fa,Es).call(oe.default(Tt),(me=h.medias)!==null&&me!==void 0?me:null,(pt=h.media)!==null&&pt!==void 0?pt:null),Tt}return ye.default(b,[{key:"sid",get:function(){return this.state.sid}},{key:"author",get:function(){return this.state.author}},{key:"subject",get:function(){return this.state.subject}},{key:"contentSid",get:function(){return this.state.contentSid}},{key:"body",get:function(){return this.state.body}},{key:"dateUpdated",get:function(){return this.state.dateUpdated}},{key:"index",get:function(){return this.state.index}},{key:"lastUpdatedBy",get:function(){return this.state.lastUpdatedBy}},{key:"dateCreated",get:function(){return this.state.timestamp}},{key:"attributes",get:function(){return this.state.attributes}},{key:"type",get:function(){return this.state.type}},{key:"media",get:function(){return this.state.media}},{key:"attachedMedia",get:function(){return this.getMediaByCategories(["media"])}},{key:"participantSid",get:function(){return this.state.participantSid}},{key:"aggregatedDeliveryReceipt",get:function(){return this.state.aggregatedDeliveryReceipt}},{key:"getMediaByCategory",value:function(h){return this.getMediaByCategories(h)}},{key:"getMediaByCategories",value:function(h){var w;return((w=this.state.medias)!==null&&w!==void 0?w:[]).filter(function(v){return h.includes(v.category)})}},{key:"getEmailBody",value:function(){var h,w,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(h=(w=this.getMediaByCategories(["body"]))===null||w===void 0?void 0:w.filter(function(g){return g.contentType==v}).shift())!==null&&h!==void 0?h:null}},{key:"getEmailHistory",value:function(){var h,w,v=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"text/plain";return(h=(w=this.getMediaByCategories(["history"]))===null||w===void 0?void 0:w.filter(function(g){return g.contentType==v}).shift())!==null&&h!==void 0?h:null}},{key:"_update",value:function(h){var w,v=this,g,y,_,S=[];(h.text||typeof h.text=="string")&&h.text!==this.state.body&&(this.state.body=h.text,S.push("body")),h.subject&&h.subject!==this.state.subject&&(this.state.subject=h.subject,S.push("subject")),h.lastUpdatedBy&&h.lastUpdatedBy!==this.state.lastUpdatedBy&&(this.state.lastUpdatedBy=h.lastUpdatedBy,S.push("lastUpdatedBy")),h.author&&h.author!==this.state.author&&(this.state.author=h.author,S.push("author")),h.dateUpdated&&new Date(h.dateUpdated).getTime()!==(this.state.dateUpdated&&this.state.dateUpdated.getTime())&&(this.state.dateUpdated=new Date(h.dateUpdated),S.push("dateUpdated")),h.timestamp&&new Date(h.timestamp).getTime()!==(this.state.timestamp&&this.state.timestamp.getTime())&&(this.state.timestamp=new Date(h.timestamp),S.push("dateCreated"));var J=M(h.attributes,"Got malformed attributes for the message ".concat(this.sid),oa);De.default(this.state.attributes,J)||(this.state.attributes=J,S.push("attributes"));var Y=h.delivery,le=this.state.aggregatedDeliveryReceipt,me=!!Y&&!!Y.total&&!!Y.delivered&&!!Y.failed&&!!Y.read&&!!Y.sent&&!!Y.undelivered;me&&(le?le._isEquals(Y)||(le._update(Y),S.push("deliveryReceipt")):(this.state.aggregatedDeliveryReceipt=new ut(Y),S.push("deliveryReceipt")));var pt=((w=h.medias)!==null&&w!==void 0?w:[]).map(function(br){var pr;return(pr=Jn(v,fi,Ai).call(v,br))===null||pr===void 0?void 0:pr._state()}).filter(function(br){return br!==null}),Tt=((g=this.state.medias)!==null&&g!==void 0?g:[]).map(function(br){return br._state()}).filter(function(br){return br!==null});if(!De.default(pt,Tt)||!De.default((y=Jn(this,fi,Ai).call(this,h.media))===null||y===void 0?void 0:y._state(),(_=this.state.media)===null||_===void 0?void 0:_._state())){var zt,Jt;Jn(this,Fa,Es).call(this,(zt=h.medias)!==null&&zt!==void 0?zt:null,(Jt=h.media)!==null&&Jt!==void 0?Jt:null),S.push("media")}S.length>0&&this.emit("updated",{message:this,updateReasons:S})}},{key:"getParticipant",value:function(){var p=te.default(P.default.mark(function w(){var v=this,g,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(g=null,!this.state.participantSid){S.next=5;break}return S.next=4,this.conversation.getParticipantBySid(this.state.participantSid).catch(function(){return oa.debug('Participant with sid "'.concat(v.participantSid,'" not found for message ').concat(v.sid)),null});case 4:g=S.sent;case 5:if(!(!g&&this.state.author)){S.next=9;break}return S.next=8,this.conversation.getParticipantByIdentity(this.state.author).catch(function(){return oa.debug('Participant with identity "'.concat(v.author,'" not found for message ').concat(v.sid)),null});case 8:g=S.sent;case 9:if(!g){S.next=11;break}return S.abrupt("return",g);case 11:throw y="Participant with ",this.state.participantSid&&(y+="SID '"+this.state.participantSid+"' "),this.state.author&&(this.state.participantSid&&(y+="or "),y+="identity '"+this.state.author+"' "),y==="Participant with "&&(y="Participant "),y+="was not found",new Error(y);case 17:case"end":return S.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getDetailedDeliveryReceipts",value:function(){var p=te.default(P.default.mark(function w(){var v,g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._getDetailedDeliveryReceiptsPaginator();case 2:v=_.sent,g=v.items;case 4:if(!v.hasNextPage){_.next=11;break}return _.next=7,v.nextPage();case 7:v=_.sent,g=[].concat(tt.default(g),tt.default(v.items)),_.next=4;break;case 11:return _.abrupt("return",g);case 12:case"end":return _.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"remove",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.commandExecutor.mutateResource("delete",this.links.self);case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateBody",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{body:v});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"updateAttributes",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.services.commandExecutor.mutateResource("post",this.links.self,{attributes:typeof v<"u"?JSON.stringify(v):void 0});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"attachTemporaryUrlsFor",value:function(){var p=te.default(P.default.mark(function w(v){var g=this,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(y=v==null?void 0:v.map(function(J){return J.sid}),!(this.services.mcsClient&&y)){S.next=7;break}return S.next=4,this.services.mcsClient.mediaSetGet(y);case 4:return S.abrupt("return",S.sent.map(function(J){return new ct(J,g.services)}));case 7:throw new Error("Media Content Service is unavailable");case 8:case"end":return S.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getTemporaryContentUrlsForMedia",value:function(h){var w=h.map(function(v){return v.sid});return this.getTemporaryContentUrlsForMediaSids(w)}},{key:"getTemporaryContentUrlsForMediaSids",value:function(h){var w=this;return new Ze.CancellablePromise(function(){var v=te.default(P.default.mark(function g(y,_,S){var J,Y;return P.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:if(J=w.services.mcsClient.mediaSetGetContentUrls(h??[]),!(!w.services.mcsClient||!h)){me.next=4;break}return _(new Error("Media Content Service is unavailable")),me.abrupt("return");case 4:return S(function(){J.cancel()}),me.prev=5,me.next=8,J;case 8:Y=me.sent,y(Y),me.next=15;break;case 12:me.prev=12,me.t0=me.catch(5),_(me.t0);case 15:case"end":return me.stop()}},g,null,[[5,12]])}));return function(g,y,_){return v.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForAttachedMedia",value:function(){var h,w=this.attachedMedia,v=(h=w==null?void 0:w.map(function(g){return g.sid}))!==null&&h!==void 0?h:[];return this.getTemporaryContentUrlsForMediaSids(v)}},{key:"_getDetailedDeliveryReceiptsPaginator",value:function(){var p=te.default(P.default.mark(function w(v){var g=this,y,_,S;return P.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return y=this.configuration.links.messagesReceipts.replace("%s",this.conversation.sid).replace("%s",this.sid),_=new V(y).arg("PageToken",v==null?void 0:v.pageToken).arg("PageSize",v==null?void 0:v.pageSize).build(),Y.next=4,this.services.network.get(_);case 4:return S=Y.sent,Y.abrupt("return",new ft(S.body.delivery_receipts.map(function(le){return new Et(le)}),function(le,me){return g._getDetailedDeliveryReceiptsPaginator({pageToken:le,pageSize:me})},S.body.meta.previous_token,S.body.meta.next_token));case 6:case"end":return Y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getContentData",value:function(){var h=this;return new Ze.CancellablePromise(function(){var w=te.default(P.default.mark(function v(g,y,_){var S,J,Y,le,me,pt,Tt,zt,Jt,br;return P.default.wrap(function(Zt){for(;;)switch(Zt.prev=Zt.next){case 0:if(h.state.contentSid!==null){Zt.next=3;break}return g(null),Zt.abrupt("return");case 3:if(S=h.getMediaByCategories(["body"]),S!==null){Zt.next=7;break}return g(null),Zt.abrupt("return");case 7:if(J="application/x-vnd.com.twilio.rich.",Y=S.filter(function(hi){return hi.contentType.startsWith(J)}),Y.length!==0){Zt.next=12;break}return g(null),Zt.abrupt("return");case 12:return le=Y[0],me=le.getContentTemporaryUrl(),_(function(){me.cancel()}),Zt.prev=15,Zt.next=18,me;case 18:pt=Zt.sent,Zt.next=25;break;case 21:return Zt.prev=21,Zt.t0=Zt.catch(15),y(Zt.t0),Zt.abrupt("return");case 25:if(pt!==null){Zt.next=28;break}return g(null),Zt.abrupt("return");case 28:return Tt=new Promise(function(hi,Ip){var Nt,Os=!1,pi=new Qn;pi.open("GET",(Nt=pt)!==null&&Nt!==void 0?Nt:"",!0),pi.responseType="text",pi.onreadystatechange=function(){pi.readyState!==4||Os||hi(pi.responseText)},pi.onerror=function(){Ip(pi.statusText)},_(function(){Os=!0,pi.abort(),Ip(new Error("XHR has been aborted"))}),pi.send()}),Zt.prev=29,Zt.next=32,Tt;case 32:Jt=Zt.sent,zt=JSON.parse(Jt),Zt.next=40;break;case 36:return Zt.prev=36,Zt.t1=Zt.catch(29),y(Zt.t1),Zt.abrupt("return");case 40:br=le.contentType.replace(J,"").replace(".","/"),g(_t(br,zt.data));case 42:case"end":return Zt.stop()}},v,null,[[15,21],[29,36]])}));return function(v,g,y){return w.apply(this,arguments)}}())}},{key:"getChannelMetadata",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this.state.hasChannelMetadata){g.next=2;break}return g.abrupt("return",null);case 2:return g.next=4,this.services.channelMetadataClient.getChannelMetadata(this.conversation.sid,this.sid);case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessageRecipients",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.messageRecipientsClient.getRecipientsFromMessage(this.conversation.sid,this.sid);case 2:return g.abrupt("return",g.sent);case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()}]),b}(N.ReplayEventEmitter);function Ai(E){var x=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return E?x?new ct(yn(yn({},E),{},{category:x}),this.services):new ct(E,this.services):null}function Es(E,x){var b=this;this.state.media=Jn(this,fi,Ai).call(this,x),this.state.medias=E?E.map(function(p){return Jn(b,fi,Ai).call(b,p)}).filter(function(p){return p!==null}):x&&!E?[Jn(this,fi,Ai).call(this,x,"media")].filter(function(p){return p!==null}):null}H.default(Jr,"updated","updated"),Ue([Z.deprecated("getMediaByCategory","getMediaByCategories"),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Array)],Jr.prototype,"getMediaByCategory",null),Ue([k.validateTypes([k.nonEmptyString,"undefined"]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",ct)],Jr.prototype,"getEmailBody",null),Ue([k.validateTypes([k.nonEmptyString,"undefined"]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",ct)],Jr.prototype,"getEmailHistory",null),Ue([k.validateTypesAsync("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],Jr.prototype,"updateBody",null),Ue([k.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],Jr.prototype,"updateAttributes",null),Ue([Z.deprecated("attachTemporaryUrlsFor","getTemporaryContentUrlsForMedia"),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Promise)],Jr.prototype,"attachTemporaryUrlsFor",null),Ue([k.validateTypesAsync(k.nonEmptyArray("media",ct)),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Ze.CancellablePromise)],Jr.prototype,"getTemporaryContentUrlsForMedia",null),Ue([k.validateTypesAsync(k.nonEmptyArray("strings","string")),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Ze.CancellablePromise)],Jr.prototype,"getTemporaryContentUrlsForMediaSids",null);function Oi(E,x){var b=Object.keys(E);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(E);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(E,h).enumerable})),b.push.apply(b,p)}return b}function Is(E){for(var x=1;x<arguments.length;x++){var b=arguments[x]!=null?arguments[x]:{};x%2?Oi(Object(b),!0).forEach(function(p){H.default(E,p,b[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(E,Object.getOwnPropertyDescriptors(b)):Oi(Object(b)).forEach(function(p){Object.defineProperty(E,p,Object.getOwnPropertyDescriptor(b,p))})}return E}function Oo(E,x){var b=typeof Symbol<"u"&&E[Symbol.iterator]||E["@@iterator"];if(!b){if(Array.isArray(E)||(b=Bn(E))||x){b&&(E=b);var p=0,h=function(){};return{s:h,n:function(){return p>=E.length?{done:!0}:{done:!1,value:E[p++]}},e:function(_){throw _},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1310
1310
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var w=!0,v=!1,g;return{s:function(){b=b.call(E)},n:function(){var _=b.next();return w=_.done,_},e:function(_){v=!0,g=_},f:function(){try{!w&&b.return!=null&&b.return()}finally{if(v)throw g}}}}function Bn(E,x){if(E){if(typeof E=="string")return xs(E,x);var b=Object.prototype.toString.call(E).slice(8,-1);if(b==="Object"&&E.constructor&&(b=E.constructor.name),b==="Map"||b==="Set")return Array.from(E);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return xs(E,x)}}function xs(E,x){(x==null||x>E.length)&&(x=E.length);for(var b=0,p=new Array(x);b<x;b++)p[b]=E[b];return p}function Po(E){var x=Mo();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Mo(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var cn=Kt.scope("Messages"),Rs=function(E){q.default(b,E);var x=Po(b);function b(p,h,w){var v;return ke.default(this,b),v=x.call(this),v.conversation=p,v.configuration=h,v.services=w,v.messagesByIndex=new Map,v.messagesListPromise=null,v}return ye.default(b,[{key:"subscribe",value:function(){var p=te.default(P.default.mark(function w(v){var g=this,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!this.messagesListPromise){S.next=2;break}return S.abrupt("return",this.messagesListPromise);case 2:return this.messagesListPromise=typeof v=="string"?this.services.syncClient.list({id:v,mode:"open_existing"}):Promise.resolve(v),S.prev=3,S.next=6,this.messagesListPromise;case 6:return y=S.sent,y.on("itemAdded",function(J){cn.debug("".concat(g.conversation.sid," itemAdded: ").concat(J.item.index));var Y={self:"".concat(g.conversation._links.messages,"/").concat(J.item.data.sid),conversation:g.conversation._links.self,messages_receipts:"".concat(g.conversation._links.messages,"/").concat(J.item.data.sid,"/Receipts")},le=new Jr(J.item.index,J.item.data,g.conversation,Y,g.configuration,g.services);if(g.messagesByIndex.has(le.index)){cn.debug("Message arrived, but is already known and ignored",g.conversation.sid,le.index);return}g.messagesByIndex.set(le.index,le),le.on("updated",function(me){return g.emit("messageUpdated",me)}),g.emit("messageAdded",le)}),y.on("itemRemoved",function(J){cn.debug("#{this.conversation.sid} itemRemoved: ".concat(J.index));var Y=J.index;if(g.messagesByIndex.has(Y)){var le=g.messagesByIndex.get(Y);if(!le)return;g.messagesByIndex.delete(le.index),le.removeAllListeners("updated"),g.emit("messageRemoved",le)}}),y.on("itemUpdated",function(J){cn.debug("".concat(g.conversation.sid," itemUpdated: ").concat(J.item.index));var Y=g.messagesByIndex.get(J.item.index);Y&&Y._update(J.item.data)}),S.abrupt("return",y);case 13:throw S.prev=13,S.t0=S.catch(3),this.messagesListPromise=null,this.services.syncClient.connectionState!=="disconnected"&&cn.error("Failed to get messages object for conversation",this.conversation.sid,S.t0),cn.debug("ERROR: Failed to get messages object for conversation",this.conversation.sid,S.t0),S.t0;case 19:case"end":return S.stop()}},w,this,[[3,13]])}));function h(w){return p.apply(this,arguments)}return h}()},{key:"unsubscribe",value:function(){var p=te.default(P.default.mark(function w(){var v;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this.messagesListPromise){y.next=2;break}return y.abrupt("return");case 2:return y.next=4,this.messagesListPromise;case 4:v=y.sent,v.close(),this.messagesListPromise=null;case 7:case"end":return y.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"sendV2",value:function(h){var w=this;return cn.debug("Sending message V2",h.mediaContent,h.attributes,h.emailOptions),new Ze.CancellablePromise(function(){var v=te.default(P.default.mark(function g(y,_,S){var J,Y,le,me,pt,Tt,zt,Jt,br,pr,Zt,hi;return P.default.wrap(function(Nt){for(;;)switch(Nt.prev=Nt.next){case 0:Y=[],le=[],S(function(){le.forEach(function(Os){return Os.cancel()})}),me=Oo(h.mediaContent),Nt.prev=4,me.s();case 6:if((pt=me.n()).done){Nt.next=25;break}return Tt=ce.default(pt.value,2),zt=Tt[0],Jt=Tt[1],Nt.prev=8,cn.debug("Adding media to a message as ".concat(Jt instanceof FormData?"FormData":"SendMediaOptions"),Jt),Zt=Jt instanceof FormData?w.services.mcsClient.postFormData(Jt,zt):w.services.mcsClient.post((br=Jt.contentType)!==null&&br!==void 0?br:"",(pr=Jt.media)!==null&&pr!==void 0?pr:"",zt,Jt.filename),le.push(Zt),Nt.t0=Y,Nt.next=15,Zt;case 15:Nt.t1=Nt.sent,Nt.t0.push.call(Nt.t0,Nt.t1),Nt.next=23;break;case 19:return Nt.prev=19,Nt.t2=Nt.catch(8),_(Nt.t2),Nt.abrupt("return");case 23:Nt.next=6;break;case 25:Nt.next=30;break;case 27:Nt.prev=27,Nt.t3=Nt.catch(4),me.e(Nt.t3);case 30:return Nt.prev=30,me.f(),Nt.finish(30);case 33:return hi=w.services.commandExecutor.mutateResource("post",w.conversation._links.messages,{body:h.text,subject:(J=h.emailOptions)===null||J===void 0?void 0:J.subject,media_sids:Y.map(function(Os){return Os.sid}),attributes:typeof h.attributes<"u"?JSON.stringify(h.attributes):void 0,content_sid:h.contentSid,content_variables:typeof h.contentVariables<"u"?JSON.stringify(h.contentVariables.reduce(function(Os,pi){return Is(Is({},Os),{},H.default({},pi.name,pi.value))},{})):void 0}),Nt.prev=34,Nt.t4=y,Nt.next=38,hi;case 38:Nt.t5=Nt.sent,(0,Nt.t4)(Nt.t5),Nt.next=45;break;case 42:Nt.prev=42,Nt.t6=Nt.catch(34),_(Nt.t6);case 45:case"end":return Nt.stop()}},g,null,[[4,27,30,33],[8,19],[34,42]])}));return function(g,y,_){return v.apply(this,arguments)}}())}},{key:"send",value:function(){var p=te.default(P.default.mark(function w(v){var g,y,_=arguments;return P.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return g=_.length>1&&_[1]!==void 0?_[1]:{},y=_.length>2?_[2]:void 0,cn.debug("Sending text message",v,g,y),J.abrupt("return",this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{body:v??"",attributes:typeof g<"u"?JSON.stringify(g):void 0,subject:y==null?void 0:y.subject}));case 4:case"end":return J.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"sendMedia",value:function(){var p=te.default(P.default.mark(function w(v){var g,y,_,S,J,Y=arguments;return P.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:if(_=Y.length>1&&Y[1]!==void 0?Y[1]:{},S=Y.length>2?Y[2]:void 0,cn.debug("Sending media message",v,_,S),cn.debug("Sending media message as ".concat(v instanceof FormData?"FormData":"SendMediaOptions"),v,_),!(v instanceof FormData)){me.next=10;break}return me.next=7,this.services.mcsClient.postFormData(v);case 7:me.t0=me.sent,me.next=13;break;case 10:return me.next=12,this.services.mcsClient.post((g=v.contentType)!==null&&g!==void 0?g:"",(y=v.media)!==null&&y!==void 0?y:"","media",v.filename);case 12:me.t0=me.sent;case 13:return J=me.t0,me.next=16,this.services.commandExecutor.mutateResource("post",this.conversation._links.messages,{media_sids:[J.sid],attributes:typeof _<"u"?JSON.stringify(_):void 0});case 16:return me.abrupt("return",me.sent);case 17:case"end":return me.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getMessages",value:function(){var p=te.default(P.default.mark(function w(v,g){var y,_=arguments;return P.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=_.length>2&&_[2]!==void 0?_[2]:"backwards",J.abrupt("return",this._getMessages(v,g,y));case 2:case"end":return J.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"_wrapPaginator",value:function(h,w,v){var g=this,y=h==="desc",_=function(){return w.nextPage().then(function(Y){return g._wrapPaginator(h,Y,v)})},S=function(){return w.prevPage().then(function(Y){return g._wrapPaginator(h,Y,v)})};return v(w.items).then(function(J){return{items:J.sort(function(Y,le){return Y.index-le.index}),hasPrevPage:y?w.hasNextPage:w.hasPrevPage,hasNextPage:y?w.hasPrevPage:w.hasNextPage,prevPage:y?_:S,nextPage:y?S:_}})}},{key:"_upsertMessage",value:function(h,w){var v=this,g=this.messagesByIndex.get(h);if(g)return g;var y={self:"".concat(this.conversation._links.messages,"/").concat(w.sid),conversation:this.conversation._links.self,messages_receipts:"".concat(this.conversation._links.messages,"/").concat(w.sid,"/Receipts")},_=new Jr(h,w,this.conversation,y,this.configuration,this.services);return this.messagesByIndex.set(_.index,_),_.on("updated",function(S){return v.emit("messageUpdated",S)}),_}},{key:"_getMessages",value:function(){var p=te.default(P.default.mark(function w(){var v=this,g,y,_,S,J,Y,le=arguments;return P.default.wrap(function(pt){for(;;)switch(pt.prev=pt.next){case 0:return g=le.length>0&&le[0]!==void 0?le[0]:30,y=le.length>1&&le[1]!==void 0?le[1]:"end",_=le.length>2&&le[2]!==void 0?le[2]:"forward",S=_==="backwards"?"desc":"asc",pt.next=6,this.messagesListPromise;case 6:return J=pt.sent,pt.next=9,J==null?void 0:J.getItems({from:y!=="end"?y:void 0,pageSize:g,order:S,limit:g});case 9:return Y=pt.sent,pt.next=12,this._wrapPaginator(S,Y,function(Tt){return Promise.all(Tt.map(function(zt){return v._upsertMessage(zt.index,zt.data)}))});case 12:return pt.abrupt("return",pt.sent);case 13:case"end":return pt.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()}]),b}(N.ReplayEventEmitter),Rn=function(){function E(x){ke.default(this,E),H.default(this,"attributes",{}),H.default(this,"mediaContent",[]),H.default(this,"emailOptions",{}),this.messagesEntity=x}return ye.default(E,[{key:"send",value:function(){var b=this;return new Ze.CancellablePromise(function(){var p=te.default(P.default.mark(function h(w,v,g){var y,_;return P.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return y=b.messagesEntity.sendV2(b),g(function(){return y.cancel()}),J.prev=2,J.next=5,y;case 5:_=J.sent,w(Vt(_.index)),J.next=12;break;case 9:J.prev=9,J.t0=J.catch(2),v(J.t0);case 12:case"end":return J.stop()}},h,null,[[2,9]])}));return function(h,w,v){return p.apply(this,arguments)}}())}}]),E}(),Nr=function(){function E(x,b){ke.default(this,E),this.limits=x,this.message=new Rn(b),this.emailBodies=new Map,this.emailHistories=new Map}return ye.default(E,[{key:"setBody",value:function(b){return this.message.text=b,this}},{key:"setSubject",value:function(b){return this.message.emailOptions.subject=b,this}},{key:"setAttributes",value:function(b){return this.message.attributes=b,this}},{key:"setEmailBody",value:function(b,p){return this.emailBodies.set(b,p),this}},{key:"setEmailHistory",value:function(b,p){return this.emailHistories.set(b,p),this}},{key:"setContentTemplate",value:function(b){var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return this.message.contentSid=b,this.message.contentVariables=p,this}},{key:"addMedia",value:function(b){if(typeof FormData>"u"&&b instanceof FormData)throw new Error("Could not add FormData content whilst not in a browser");if(!(b instanceof FormData)){var p=b;if(!p.contentType||!p.media)throw new Error("Media content in SendMediaOptions must contain non-empty contentType and media")}return this.message.mediaContent.push(["media",b]),this}},{key:"build",value:function(){var b=this;if(this.emailBodies.forEach(function(p,h){if(!b.limits.emailBodiesAllowedContentTypes.includes(h))throw new Error("Unsupported email body content type ".concat(h))}),this.emailHistories.forEach(function(p,h){if(!b.limits.emailHistoriesAllowedContentTypes.includes(h))throw new Error("Unsupported email history content type ".concat(h))}),this.emailBodies.size>this.limits.emailBodiesAllowedContentTypes.length)throw new Error("Too many email bodies attached to the message (".concat(this.emailBodies.size," > ").concat(this.limits.emailBodiesAllowedContentTypes.length,")"));if(this.emailHistories.size>this.limits.emailHistoriesAllowedContentTypes.length)throw new Error("Too many email histories attached to the message (".concat(this.emailHistories.size," > ").concat(this.limits.emailHistoriesAllowedContentTypes.length,")"));if(this.message.mediaContent.length>this.limits.mediaAttachmentsCountLimit)throw new Error("Too many media attachments in the message (".concat(this.message.mediaContent.length," > ").concat(this.limits.mediaAttachmentsCountLimit,")"));return this.emailBodies.forEach(function(p){b.message.mediaContent.push(["body",p])}),this.emailHistories.forEach(function(p){b.message.mediaContent.push(["history",p])}),this.message}},{key:"buildAndSend",value:function(){return this.build().send()}}]),E}();Ue([k.validateTypes("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Nr)],Nr.prototype,"setBody",null),Ue([k.validateTypes("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Nr)],Nr.prototype,"setSubject",null),Ue([k.validateTypes(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Nr)],Nr.prototype,"setAttributes",null),Ue([k.validateTypes("string",[FormData,lt]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Nr)],Nr.prototype,"setEmailBody",null),Ue([k.validateTypes("string",[FormData,lt]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Nr)],Nr.prototype,"setEmailHistory",null),Ue([k.validateTypes("string",[k.array("content variables",xt),"undefined"]),be("design:type",Function),be("design:paramtypes",[String,Array]),be("design:returntype",Nr)],Nr.prototype,"setContentTemplate",null),Ue([k.validateTypes([FormData,lt]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Nr)],Nr.prototype,"addMedia",null);function No(E,x){var b=typeof Symbol<"u"&&E[Symbol.iterator]||E["@@iterator"];if(!b){if(Array.isArray(E)||(b=Xn(E))||x){b&&(E=b);var p=0,h=function(){};return{s:h,n:function(){return p>=E.length?{done:!0}:{done:!1,value:E[p++]}},e:function(_){throw _},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1311
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var w=!0,v=!1,g;return{s:function(){b=b.call(E)},n:function(){var _=b.next();return w=_.done,_},e:function(_){v=!0,g=_},f:function(){try{!w&&b.return!=null&&b.return()}finally{if(v)throw g}}}}function Xn(E,x){if(E){if(typeof E=="string")return An(E,x);var b=Object.prototype.toString.call(E).slice(8,-1);if(b==="Object"&&E.constructor&&(b=E.constructor.name),b==="Map"||b==="Set")return Array.from(E);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return An(E,x)}}function An(E,x){(x==null||x>E.length)&&(x=E.length);for(var b=0,p=new Array(x);b<x;b++)p[b]=E[b];return p}function As(E){var x=ee();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function ee(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ue={lastMessage:"lastMessage",attributes:"attributes",createdBy:"createdBy",dateCreated:"dateCreated",dateUpdated:"dateUpdated",friendlyName:"friendlyName",lastConsumedMessageIndex:"lastConsumedMessageIndex",notificationLevel:"notificationLevel",sid:"sid",status:"status",uniqueName:"uniqueName",state:"state",bindings:"bindings"},R=function(E){q.default(b,E);var x=As(b);function b(p,h,w,v,g){var y,_,S;ke.default(this,b),S=x.call(this),S.sid=h,S._links=w,S._configuration=v,S._services=g,S._entityName=p.channel,S._internalState={uniqueName:p.uniqueName||null,status:"notParticipating",attributes:(y=p.attributes)!==null&&y!==void 0?y:{},createdBy:p.createdBy,dateCreated:At(p.dateCreated),dateUpdated:At(p.dateUpdated),friendlyName:p.friendlyName||null,lastReadMessageIndex:Number.isInteger(p.lastConsumedMessageIndex)?p.lastConsumedMessageIndex:null,bindings:(_=p.bindings)!==null&&_!==void 0?_:{}},p.notificationLevel&&(S._internalState.notificationLevel=p.notificationLevel);var J={participants:S._links.participants};return S._participants=new Map,S._participantsEntity=new ze(oe.default(S),S._participants,J,S._services),S._participantsEntity.on(b.participantJoined,function(Y){return S.emit(b.participantJoined,Y)}),S._participantsEntity.on(b.participantLeft,function(Y){return S.emit(b.participantLeft,Y)}),S._participantsEntity.on(b.participantUpdated,function(Y){return S.emit(b.participantUpdated,Y)}),S._messagesEntity=new Rs(oe.default(S),v,g),S._messagesEntity.on(b.messageAdded,function(Y){return S._onMessageAdded(Y)}),S._messagesEntity.on(b.messageUpdated,function(Y){return S.emit(b.messageUpdated,Y)}),S._messagesEntity.on(b.messageRemoved,function(Y){return S.emit(b.messageRemoved,Y)}),S}return ye.default(b,[{key:"uniqueName",get:function(){return this._internalState.uniqueName}},{key:"status",get:function(){return this._internalState.status}},{key:"friendlyName",get:function(){return this._internalState.friendlyName}},{key:"dateUpdated",get:function(){return this._internalState.dateUpdated}},{key:"dateCreated",get:function(){return this._internalState.dateCreated}},{key:"createdBy",get:function(){var h;return(h=this._internalState.createdBy)!==null&&h!==void 0?h:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var h;return(h=this._internalState.lastMessage)!==null&&h!==void 0?h:void 0}},{key:"notificationLevel",get:function(){var h;return(h=this._internalState.notificationLevel)!==null&&h!==void 0?h:"default"}},{key:"bindings",get:function(){return this._internalState.bindings}},{key:"limits",get:function(){return this._configuration.limits}},{key:"state",get:function(){return this._internalState.state}},{key:"_statusSource",get:function(){return this._dataSource}},{key:"add",value:function(){var p=te.default(P.default.mark(function w(v,g){return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.abrupt("return",this._participantsEntity.add(v,g??{}));case 1:case"end":return _.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"addNonChatParticipant",value:function(){var p=te.default(P.default.mark(function w(v,g){var y,_,S=arguments;return P.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return y=S.length>2&&S[2]!==void 0?S[2]:{},_=S.length>3&&S[3]!==void 0?S[3]:{},Y.abrupt("return",this._participantsEntity.addNonChatParticipant(v,g,y??{},_??{}));case 3:case"end":return Y.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"advanceLastReadMessageIndex",value:function(){var p=te.default(P.default.mark(function w(v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._subscribeStreams();case 2:if(!(v<((g=this.lastReadMessageIndex)!==null&&g!==void 0?g:0))){_.next=6;break}return _.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:return _.abrupt("return",_.sent);case 6:return _.next=8,this._setLastReadMessageIndex(v);case 8:return _.abrupt("return",_.sent);case 9:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"delete",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getAttributes",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribe();case 2:return g.abrupt("return",this.attributes);case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessages",value:function(){var p=te.default(P.default.mark(function w(v,g,y){return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._subscribeStreams();case 2:return S.abrupt("return",this._messagesEntity.getMessages(v,g,y));case 3:case"end":return S.stop()}},w,this)}));function h(w,v,g){return p.apply(this,arguments)}return h}()},{key:"getParticipants",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribeStreams();case 2:return g.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantsCount",value:function(){var p=te.default(P.default.mark(function w(){var v,g,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=new V(this._configuration.links.conversations).path(this.sid).build(),S.next=3,this._services.network.get(g);case 3:return y=S.sent,S.abrupt("return",(v=y.body.participants_count)!==null&&v!==void 0?v:0);case 5:case"end":return S.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantBySid",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.abrupt("return",this._participantsEntity.getParticipantBySid(v));case 1:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getParticipantByIdentity",value:function(){var p=te.default(P.default.mark(function w(){var v,g=arguments;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return v=g.length>0&&g[0]!==void 0?g[0]:"",_.abrupt("return",this._participantsEntity.getParticipantByIdentity(v??""));case 2:case"end":return _.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessagesCount",value:function(){var p=te.default(P.default.mark(function w(){var v,g,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=new V(this._configuration.links.conversations).path(this.sid).build(),S.next=3,this._services.network.get(g);case 3:return y=S.sent,S.abrupt("return",(v=y.body.messages_count)!==null&&v!==void 0?v:0);case 5:case"end":return S.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getUnreadMessagesCount",value:function(){var p=te.default(P.default.mark(function w(){var v,g,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return v=new V(this._configuration.links.myConversations).path(this.sid).build(),S.next=3,this._services.network.get(v);case 3:if(g=S.sent,g.body.conversation_sid===this.sid){S.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if(y=g.body.unread_messages_count,typeof y!="number"){S.next=9;break}return S.abrupt("return",y);case 9:return S.abrupt("return",null);case 10:case"end":return S.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"join",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"leave",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this._internalState.status!=="joined"){g.next=3;break}return g.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(encodeURIComponent(this._configuration.userIdentity)));case 3:return g.abrupt("return",this);case 4:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"removeParticipant",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._participantsEntity.remove(typeof v=="string"?v:v.sid);case 2:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"sendMessage",value:function(){var p=te.default(P.default.mark(function w(v,g,y){var _,S,J,Y;return P.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:if(!(typeof v=="string"||v===null)){me.next=5;break}return me.next=3,this._messagesEntity.send(v,g,y);case 3:return J=me.sent,me.abrupt("return",(S=Vt(J.index))!==null&&S!==void 0?S:0);case 5:return me.next=7,this._messagesEntity.sendMedia(v,g,y);case 7:return Y=me.sent,me.abrupt("return",(_=Vt(Y.index))!==null&&_!==void 0?_:0);case 9:case"end":return me.stop()}},w,this)}));function h(w,v,g){return p.apply(this,arguments)}return h}()},{key:"prepareMessage",value:function(){return new Nr(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:function(){var p=te.default(P.default.mark(function w(){var v;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.next=4,this.getMessages(1);case 4:if(v=y.sent,!(v.items.length>0)){y.next=7;break}return y.abrupt("return",this.advanceLastReadMessageIndex(v.items[0].index));case 7:return y.abrupt("return",0);case 8:case"end":return y.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"setAllMessagesUnread",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribeStreams();case 2:return g.next=4,this._setLastReadMessageIndex(null);case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"setUserNotificationLevel",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:v});case 2:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:v!==void 0?JSON.stringify(v):void 0});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"updateFriendlyName",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.friendlyName===v){y.next=3;break}return y.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:v});case 3:return y.abrupt("return",this);case 4:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"updateLastReadMessageIndex",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.abrupt("return",this._setLastReadMessageIndex(v));case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"updateUniqueName",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.uniqueName===v){y.next=4;break}return v||(v=""),y.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:v});case 4:return y.abrupt("return",this);case 5:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getMessageRecipients",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid,v);case 2:return y.abrupt("return",y.sent);case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"_subscribe",value:function(){var p=te.default(P.default.mark(function w(){var v=this;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._entityPromise){y.next=2;break}return y.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),y.prev=3,y.next=6,this._entityPromise;case 6:return this._entity=y.sent,this._entity.on(Pe.SyncDocument.updated,function(_){return v._update(_.data)}),this._entity.on(Pe.SyncDocument.removed,function(){return v.emit(b.removed,v)}),this._update(this._entity.data),y.abrupt("return",this._entity);case 13:throw y.prev=13,y.t0=y.catch(3),this._entity=null,this._entityPromise=null,this._services.syncClient.connectionState!="disconnected"&&b._logger.error("Failed to get conversation object",y.t0),b._logger.debug("ERROR: Failed to get conversation object",y.t0),y.t0;case 20:case"end":return y.stop()}},w,this,[[3,13]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"_fetchStreams",value:function(){var p=te.default(P.default.mark(function w(){var v=this;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._streamsPromise){y.next=2;break}return y.abrupt("return",this._streamsPromise);case 2:return this._streamsPromise=new Promise(function(){var _=te.default(P.default.mark(function S(J,Y){var le,me,pt,Tt,zt;return P.default.wrap(function(br){for(;;)switch(br.prev=br.next){case 0:return br.prev=0,br.next=3,v._subscribe();case 3:br.next=9;break;case 5:return br.prev=5,br.t0=br.catch(0),b._logger.trace("Failed to subscribe to conversation",br.t0),br.abrupt("return",Y(br.t0));case 9:b._logger.trace("_streamsAvailable, this.entity.data=",(le=v._entity)===null||le===void 0?void 0:le.data),pt=(me=v._entity)===null||me===void 0?void 0:me.data,Tt=v._services.syncClient.list({id:pt.messages,mode:"open_existing"}).then(function(pr){return v._messagesList=pr,pr}),zt=v._services.syncClient.map({id:pt.roster,mode:"open_existing"}).then(function(pr){return v._participantsMap=pr,pr}),Promise.all([Tt,zt]).then(function(){return J(!0)}).catch(function(pr){b._logger.trace("Failed to fetch conversation streams for conversation",v.sid,pr),Y(pr)});case 14:case"end":return br.stop()}},S,null,[[0,5]])}));return function(S,J){return _.apply(this,arguments)}}()),y.abrupt("return",this._streamsPromise.catch(function(_){throw v._streamsPromise=null,_}));case 4:case"end":return y.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_subscribeStreams",value:function(){var p=te.default(P.default.mark(function w(){var v,g,y,_,S,J,Y;return P.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:return me.prev=0,me.next=3,this._fetchStreams();case 3:return b._logger.trace("_subscribeStreams, this.entity.data=",(v=this._entity)===null||v===void 0?void 0:v.data),S=(g=this._entity)===null||g===void 0?void 0:g.data,J=S.messages,Y=S.roster,me.next=9,Promise.all([this._messagesEntity.subscribe((y=this._messagesList)!==null&&y!==void 0?y:J),this._participantsEntity.subscribe((_=this._participantsMap)!==null&&_!==void 0?_:Y)]);case 9:me.next=16;break;case 11:throw me.prev=11,me.t0=me.catch(0),this._services.syncClient.connectionState!=="disconnected"&&b._logger.error("Failed to subscribe on conversation objects",this.sid,me.t0),b._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,me.t0),me.t0;case 16:case"end":return me.stop()}},w,this,[[0,11]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"_unsubscribe",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return this._entity&&(this._entity.close(),this._entity=null,this._entityPromise=null),g.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 2:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_setStatus",value:function(h,w){var v=this;if(this._dataSource=w,this._internalState.status!==h){if(this._internalState.status=h,h==="joined"){this._subscribeStreams().catch(function(g){if(b._logger.debug("ERROR while setting conversation status "+h,g),v._services.syncClient.connectionState!=="disconnected")throw g});return}this._entityPromise&&this._unsubscribe().catch(function(g){if(b._logger.debug("ERROR while setting conversation status "+h,g),v._services.syncClient.connectionState!=="disconnected")throw g})}}},{key:"_update",value:function(h){var w,v,g,y,_;b._logger.trace("_update",h),b.preprocessUpdate(h,this.sid);for(var S=new Set,J=0,Y=Object.keys(h);J<Y.length;J++){var le=Y[J],me=ue[le];if(me)switch(me){case ue.status:if(!h.status||h.status==="unknown"||this._internalState.status===h.status)break;this._internalState.status=h.status,S.add(me);break;case ue.attributes:if(De.default(this._internalState.attributes,h.attributes))break;this._internalState.attributes=h.attributes,S.add(me);break;case ue.lastConsumedMessageIndex:if(h.lastConsumedMessageIndex===void 0||h.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=h.lastConsumedMessageIndex,S.add("lastReadMessageIndex");break;case ue.lastMessage:if(this._internalState.lastMessage&&!h.lastMessage){delete this._internalState.lastMessage,S.add(me);break}this._internalState.lastMessage=this._internalState.lastMessage||{},((w=h.lastMessage)===null||w===void 0?void 0:w.index)!==void 0&&h.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=h.lastMessage.index,S.add(me)),((v=h.lastMessage)===null||v===void 0?void 0:v.timestamp)!==void 0&&((g=this._internalState.lastMessage)===null||g===void 0||(y=g.dateCreated)===null||y===void 0?void 0:y.getTime())!==h.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=h.lastMessage.timestamp,S.add(me)),De.default(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case ue.state:var pt=h.state||void 0;if(pt!==void 0&&(pt.dateUpdated=new Date(pt.dateUpdated)),De.default(this._internalState.state,pt))break;this._internalState.state=pt,S.add(me);break;case ue.bindings:if(De.default(this._internalState.bindings,h.bindings))break;this._internalState.bindings=h.bindings,S.add(me);break;default:var Tt=h[le]instanceof Date,zt=Tt&&((_=this._internalState[me])===null||_===void 0?void 0:_.getTime())===h[le].getTime(),Jt=!Tt&&this[me]===h[le];if(zt||Jt)break;this._internalState[me]=h[le],S.add(me)}}S.size>0&&this.emit(b.updated,{conversation:this,updateReasons:tt.default(S)})}},{key:"_onMessageAdded",value:function(h){var w=No(this._participants.values()),v;try{for(w.s();!(v=w.n()).done;){var g=v.value;if(g.identity===h.author){g._endTyping();break}}}catch(y){w.e(y)}finally{w.f()}this.emit(b.messageAdded,h)}},{key:"_setLastReadMessageIndex",value:function(){var p=te.default(P.default.mark(function w(v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:v});case 2:return g=_.sent,_.abrupt("return",g.unread_messages_count);case 4:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()}],[{key:"preprocessUpdate",value:function(h,w){try{typeof h.attributes=="string"?h.attributes=JSON.parse(h.attributes):h.attributes&&JSON.stringify(h.attributes)}catch{b._logger.warn("Retrieved malformed attributes from the server for conversation: "+w),h.attributes={}}try{h.dateCreated&&(h.dateCreated=new Date(h.dateCreated))}catch{b._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+w),delete h.dateCreated}try{h.dateUpdated&&(h.dateUpdated=new Date(h.dateUpdated))}catch{b._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+w),delete h.dateUpdated}try{h.lastMessage&&h.lastMessage.timestamp&&(h.lastMessage.timestamp=new Date(h.lastMessage.timestamp))}catch{b._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+w),delete h.lastMessage.timestamp}}}]),b}(N.ReplayEventEmitter);H.default(R,"participantJoined","participantJoined"),H.default(R,"participantLeft","participantLeft"),H.default(R,"participantUpdated","participantUpdated"),H.default(R,"messageAdded","messageAdded"),H.default(R,"messageRemoved","messageRemoved"),H.default(R,"messageUpdated","messageUpdated"),H.default(R,"typingEnded","typingEnded"),H.default(R,"typingStarted","typingStarted"),H.default(R,"updated","updated"),H.default(R,"removed","removed"),H.default(R,"_logger",Kt.scope("Conversation")),Ue([k.validateTypesAsync(k.nonEmptyString,Fe),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Promise)],R.prototype,"add",null),Ue([k.validateTypesAsync(k.nonEmptyString,k.nonEmptyString,Fe,Fe),be("design:type",Function),be("design:paramtypes",[String,String,Object,Object]),be("design:returntype",Promise)],R.prototype,"addNonChatParticipant",null),Ue([k.validateTypesAsync(k.nonNegativeInteger),be("design:type",Function),be("design:paramtypes",[Number]),be("design:returntype",Promise)],R.prototype,"advanceLastReadMessageIndex",null),Ue([k.validateTypesAsync(["undefined",k.nonNegativeInteger],["undefined",k.nonNegativeInteger],["undefined",k.literal("backwards","forward")]),be("design:type",Function),be("design:paramtypes",[Number,Number,String]),be("design:returntype",Promise)],R.prototype,"getMessages",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],R.prototype,"getParticipantBySid",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],R.prototype,"getParticipantByIdentity",null),Ue([k.validateTypesAsync([k.nonEmptyString,G]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],R.prototype,"removeParticipant",null),Ue([k.validateTypesAsync(["string",FormData,k.literal(null),k.objectSchema("media options",{contentType:k.nonEmptyString,media:k.custom(function(E){var x=typeof E=="string"&&E.length>0||E instanceof Uint8Array||E instanceof ArrayBuffer;return typeof Blob=="function"&&(x=x||E instanceof Blob),[x,"a non-empty string, an instance of Buffer or an instance of Blob"]})})],Fe,["undefined",k.literal(null),k.objectSchema("email attributes",{subject:[k.nonEmptyString,"undefined"]})]),be("design:type",Function),be("design:paramtypes",[Object,Object,Object]),be("design:returntype",Promise)],R.prototype,"sendMessage",null),Ue([k.validateTypesAsync(k.literal("default","muted")),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],R.prototype,"setUserNotificationLevel",null),Ue([k.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],R.prototype,"updateAttributes",null),Ue([k.validateTypesAsync("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],R.prototype,"updateFriendlyName",null),Ue([k.validateTypesAsync([k.literal(null),k.nonNegativeInteger]),be("design:type",Function),be("design:paramtypes",[Number]),be("design:returntype",Promise)],R.prototype,"updateLastReadMessageIndex",null),Ue([k.validateTypesAsync(["string",k.literal(null)]),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],R.prototype,"updateUniqueName",null);var A=function(){function E(){var x=this;ke.default(this,E),this._promise=new Promise(function(b,p){x._resolve=b,x._reject=p})}return ye.default(E,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(b){this._resolve(b)}},{key:"set",value:function(b){this.current=b,this._resolve(b)}},{key:"fail",value:function(b){this._reject(b)}}]),E}();function I(E,x){var b=typeof Symbol<"u"&&E[Symbol.iterator]||E["@@iterator"];if(!b){if(Array.isArray(E)||(b=W(E))||x){b&&(E=b);var p=0,h=function(){};return{s:h,n:function(){return p>=E.length?{done:!0}:{done:!1,value:E[p++]}},e:function(_){throw _},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1311
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var w=!0,v=!1,g;return{s:function(){b=b.call(E)},n:function(){var _=b.next();return w=_.done,_},e:function(_){v=!0,g=_},f:function(){try{!w&&b.return!=null&&b.return()}finally{if(v)throw g}}}}function Xn(E,x){if(E){if(typeof E=="string")return An(E,x);var b=Object.prototype.toString.call(E).slice(8,-1);if(b==="Object"&&E.constructor&&(b=E.constructor.name),b==="Map"||b==="Set")return Array.from(E);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return An(E,x)}}function An(E,x){(x==null||x>E.length)&&(x=E.length);for(var b=0,p=new Array(x);b<x;b++)p[b]=E[b];return p}function As(E){var x=ee();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function ee(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var ue={lastMessage:"lastMessage",attributes:"attributes",createdBy:"createdBy",dateCreated:"dateCreated",dateUpdated:"dateUpdated",friendlyName:"friendlyName",lastConsumedMessageIndex:"lastConsumedMessageIndex",notificationLevel:"notificationLevel",sid:"sid",status:"status",uniqueName:"uniqueName",state:"state",bindings:"bindings"},R=function(E){q.default(b,E);var x=As(b);function b(p,h,w,v,g){var y,_,S;ke.default(this,b),S=x.call(this),S.sid=h,S._links=w,S._configuration=v,S._services=g,S._entityName=p.channel,S._internalState={uniqueName:p.uniqueName||null,status:"notParticipating",attributes:(y=p.attributes)!==null&&y!==void 0?y:{},createdBy:p.createdBy,dateCreated:At(p.dateCreated),dateUpdated:At(p.dateUpdated),friendlyName:p.friendlyName||null,lastReadMessageIndex:Number.isInteger(p.lastConsumedMessageIndex)?p.lastConsumedMessageIndex:null,bindings:(_=p.bindings)!==null&&_!==void 0?_:{}},p.notificationLevel&&(S._internalState.notificationLevel=p.notificationLevel);var J={participants:S._links.participants};return S._participants=new Map,S._participantsEntity=new ze(oe.default(S),S._participants,J,S._services),S._participantsEntity.on(b.participantJoined,function(Y){return S.emit(b.participantJoined,Y)}),S._participantsEntity.on(b.participantLeft,function(Y){return S.emit(b.participantLeft,Y)}),S._participantsEntity.on(b.participantUpdated,function(Y){return S.emit(b.participantUpdated,Y)}),S._messagesEntity=new Rs(oe.default(S),v,g),S._messagesEntity.on(b.messageAdded,function(Y){return S._onMessageAdded(Y)}),S._messagesEntity.on(b.messageUpdated,function(Y){return S.emit(b.messageUpdated,Y)}),S._messagesEntity.on(b.messageRemoved,function(Y){return S.emit(b.messageRemoved,Y)}),S}return ye.default(b,[{key:"uniqueName",get:function(){return this._internalState.uniqueName}},{key:"status",get:function(){return this._internalState.status}},{key:"friendlyName",get:function(){return this._internalState.friendlyName}},{key:"dateUpdated",get:function(){return this._internalState.dateUpdated}},{key:"dateCreated",get:function(){return this._internalState.dateCreated}},{key:"createdBy",get:function(){var h;return(h=this._internalState.createdBy)!==null&&h!==void 0?h:""}},{key:"attributes",get:function(){return this._internalState.attributes}},{key:"lastReadMessageIndex",get:function(){return this._internalState.lastReadMessageIndex}},{key:"lastMessage",get:function(){var h;return(h=this._internalState.lastMessage)!==null&&h!==void 0?h:void 0}},{key:"notificationLevel",get:function(){var h;return(h=this._internalState.notificationLevel)!==null&&h!==void 0?h:"default"}},{key:"bindings",get:function(){return this._internalState.bindings}},{key:"limits",get:function(){return this._configuration.limits}},{key:"state",get:function(){return this._internalState.state}},{key:"_statusSource",get:function(){return this._dataSource}},{key:"add",value:function(){var p=te.default(P.default.mark(function w(v,g){return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.abrupt("return",this._participantsEntity.add(v,g??{}));case 1:case"end":return _.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"addNonChatParticipant",value:function(){var p=te.default(P.default.mark(function w(v,g){var y,_,S=arguments;return P.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return y=S.length>2&&S[2]!==void 0?S[2]:{},_=S.length>3&&S[3]!==void 0?S[3]:{},Y.abrupt("return",this._participantsEntity.addNonChatParticipant(v,g,y??{},_??{}));case 3:case"end":return Y.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"advanceLastReadMessageIndex",value:function(){var p=te.default(P.default.mark(function w(v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._subscribeStreams();case 2:if(!(v<((g=this.lastReadMessageIndex)!==null&&g!==void 0?g:0))){_.next=6;break}return _.next=5,this._setLastReadMessageIndex(this.lastReadMessageIndex);case 5:return _.abrupt("return",_.sent);case 6:return _.next=8,this._setLastReadMessageIndex(v);case 8:return _.abrupt("return",_.sent);case 9:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"delete",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._services.commandExecutor.mutateResource("delete",this._links.self);case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getAttributes",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribe();case 2:return g.abrupt("return",this.attributes);case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessages",value:function(){var p=te.default(P.default.mark(function w(v,g,y){return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._subscribeStreams();case 2:return S.abrupt("return",this._messagesEntity.getMessages(v,g,y));case 3:case"end":return S.stop()}},w,this)}));function h(w,v,g){return p.apply(this,arguments)}return h}()},{key:"getParticipants",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribeStreams();case 2:return g.abrupt("return",this._participantsEntity.getParticipants());case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantsCount",value:function(){var p=te.default(P.default.mark(function w(){var v,g,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=new V(this._configuration.links.conversations).path(this.sid).build(),S.next=3,this._services.network.get(g);case 3:return y=S.sent,S.abrupt("return",(v=y.body.participants_count)!==null&&v!==void 0?v:0);case 5:case"end":return S.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getParticipantBySid",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.abrupt("return",this._participantsEntity.getParticipantBySid(v));case 1:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getParticipantByIdentity",value:function(){var p=te.default(P.default.mark(function w(){var v,g=arguments;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return v=g.length>0&&g[0]!==void 0?g[0]:"",_.abrupt("return",this._participantsEntity.getParticipantByIdentity(v??""));case 2:case"end":return _.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getMessagesCount",value:function(){var p=te.default(P.default.mark(function w(){var v,g,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return g=new V(this._configuration.links.conversations).path(this.sid).build(),S.next=3,this._services.network.get(g);case 3:return y=S.sent,S.abrupt("return",(v=y.body.messages_count)!==null&&v!==void 0?v:0);case 5:case"end":return S.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getUnreadMessagesCount",value:function(){var p=te.default(P.default.mark(function w(){var v,g,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return v=new V(this._configuration.links.myConversations).path(this.sid).build(),S.next=3,this._services.network.get(v);case 3:if(g=S.sent,g.body.conversation_sid===this.sid){S.next=6;break}throw new Error("Conversation was not found in the user conversations list");case 6:if(y=g.body.unread_messages_count,typeof y!="number"){S.next=9;break}return S.abrupt("return",y);case 9:return S.abrupt("return",null);case 10:case"end":return S.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"join",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._services.commandExecutor.mutateResource("post",this._links.participants,{identity:this._configuration.userIdentity});case 2:return g.abrupt("return",this);case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"leave",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:if(this._internalState.status!=="joined"){g.next=3;break}return g.next=3,this._services.commandExecutor.mutateResource("delete","".concat(this._links.participants,"/").concat(encodeURIComponent(this._configuration.userIdentity)));case 3:return g.abrupt("return",this);case 4:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"removeParticipant",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._participantsEntity.remove(typeof v=="string"?v:v.sid);case 2:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"sendMessage",value:function(){var p=te.default(P.default.mark(function w(v,g,y){var _,S,J,Y;return P.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:if(!(typeof v=="string"||v===null)){me.next=5;break}return me.next=3,this._messagesEntity.send(v,g,y);case 3:return J=me.sent,me.abrupt("return",(S=Vt(J.index))!==null&&S!==void 0?S:0);case 5:return me.next=7,this._messagesEntity.sendMedia(v,g,y);case 7:return Y=me.sent,me.abrupt("return",(_=Vt(Y.index))!==null&&_!==void 0?_:0);case 9:case"end":return me.stop()}},w,this)}));function h(w,v,g){return p.apply(this,arguments)}return h}()},{key:"prepareMessage",value:function(){return new Nr(this.limits,this._messagesEntity)}},{key:"setAllMessagesRead",value:function(){var p=te.default(P.default.mark(function w(){var v;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.next=4,this.getMessages(1);case 4:if(v=y.sent,!(v.items.length>0)){y.next=7;break}return y.abrupt("return",this.advanceLastReadMessageIndex(v.items[0].index));case 7:return y.abrupt("return",0);case 8:case"end":return y.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"setAllMessagesUnread",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._subscribeStreams();case 2:return g.next=4,this._setLastReadMessageIndex(null);case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"setUserNotificationLevel",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{notification_level:v});case 2:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"typing",value:function(){return this._services.typingIndicator.send(this.sid)}},{key:"updateAttributes",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.commandExecutor.mutateResource("post",this._links.self,{attributes:v!==void 0?JSON.stringify(v):void 0});case 2:return y.abrupt("return",this);case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"updateFriendlyName",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.friendlyName===v){y.next=3;break}return y.next=3,this._services.commandExecutor.mutateResource("post",this._links.self,{friendly_name:v});case 3:return y.abrupt("return",this);case 4:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"updateLastReadMessageIndex",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._subscribeStreams();case 2:return y.abrupt("return",this._setLastReadMessageIndex(v));case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"updateUniqueName",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(this._internalState.uniqueName===v){y.next=4;break}return v||(v=""),y.next=4,this._services.commandExecutor.mutateResource("post",this._links.self,{unique_name:v});case 4:return y.abrupt("return",this);case 5:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getMessageRecipients",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._services.messageRecipientsClient.getRecipientsFromConversation(this.sid,v);case 2:return y.abrupt("return",y.sent);case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"_subscribe",value:function(){var p=te.default(P.default.mark(function w(){var v=this;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._entityPromise){y.next=2;break}return y.abrupt("return",this._entityPromise);case 2:return this._entityPromise=this._services.syncClient.document({id:this._entityName,mode:"open_existing"}),y.prev=3,y.next=6,this._entityPromise;case 6:return this._entity=y.sent,this._entity.on(Pe.SyncDocument.updated,function(_){return v._update(_.data)}),this._entity.on(Pe.SyncDocument.removed,function(){return v.emit(b.removed,v)}),this._update(this._entity.data),y.abrupt("return",this._entity);case 13:throw y.prev=13,y.t0=y.catch(3),this._entity=null,this._entityPromise=null,this._services.syncClient.connectionState!="disconnected"&&b._logger.error("Failed to get conversation object",y.t0),b._logger.debug("ERROR: Failed to get conversation object",y.t0),y.t0;case 20:case"end":return y.stop()}},w,this,[[3,13]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"_fetchStreams",value:function(){var p=te.default(P.default.mark(function w(){var v=this;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(!this._streamsPromise){y.next=2;break}return y.abrupt("return",this._streamsPromise);case 2:return this._streamsPromise=new Promise(function(){var _=te.default(P.default.mark(function S(J,Y){var le,me,pt,Tt,zt;return P.default.wrap(function(br){for(;;)switch(br.prev=br.next){case 0:return br.prev=0,br.next=3,v._subscribe();case 3:br.next=9;break;case 5:return br.prev=5,br.t0=br.catch(0),b._logger.trace("Failed to subscribe to conversation",br.t0),br.abrupt("return",Y(br.t0));case 9:b._logger.trace("_streamsAvailable, this.entity.data=",(le=v._entity)===null||le===void 0?void 0:le.data),pt=(me=v._entity)===null||me===void 0?void 0:me.data,Tt=v._services.syncClient.list({id:pt.messages,mode:"open_existing"}).then(function(pr){return v._messagesList=pr,pr}),zt=v._services.syncClient.map({id:pt.roster,mode:"open_existing"}).then(function(pr){return v._participantsMap=pr,pr}),Promise.all([Tt,zt]).then(function(){return J(!0)}).catch(function(pr){b._logger.trace("Failed to fetch conversation streams for conversation",v.sid,pr),Y(pr)});case 14:case"end":return br.stop()}},S,null,[[0,5]])}));return function(S,J){return _.apply(this,arguments)}}()),y.abrupt("return",this._streamsPromise.catch(function(_){throw v._streamsPromise=null,_}));case 4:case"end":return y.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_subscribeStreams",value:function(){var p=te.default(P.default.mark(function w(){var v,g,y,_,S,J,Y;return P.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:return me.prev=0,me.next=3,this._fetchStreams();case 3:return b._logger.trace("_subscribeStreams, this.entity.data=",(v=this._entity)===null||v===void 0?void 0:v.data),S=(g=this._entity)===null||g===void 0?void 0:g.data,J=S.messages,Y=S.roster,me.next=9,Promise.all([this._messagesEntity.subscribe((y=this._messagesList)!==null&&y!==void 0?y:J),this._participantsEntity.subscribe((_=this._participantsMap)!==null&&_!==void 0?_:Y)]);case 9:me.next=16;break;case 11:throw me.prev=11,me.t0=me.catch(0),this._services.syncClient.connectionState!=="disconnected"&&b._logger.error("Failed to subscribe on conversation objects",this.sid,me.t0),b._logger.debug("ERROR: Failed to subscribe on conversation objects",this.sid,me.t0),me.t0;case 16:case"end":return me.stop()}},w,this,[[0,11]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"_unsubscribe",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return this._entity&&(this._entity.close(),this._entity=null,this._entityPromise=null),g.abrupt("return",Promise.all([this._participantsEntity.unsubscribe(),this._messagesEntity.unsubscribe()]));case 2:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_setStatus",value:function(h,w){var v=this;if(this._dataSource=w,this._internalState.status!==h){if(this._internalState.status=h,h==="joined"){this._subscribeStreams().catch(function(g){if(b._logger.debug("ERROR while setting conversation status "+h,g),v._services.syncClient.connectionState!=="disconnected")throw g});return}this._entityPromise&&this._unsubscribe().catch(function(g){if(b._logger.debug("ERROR while setting conversation status "+h,g),v._services.syncClient.connectionState!=="disconnected")throw g})}}},{key:"_update",value:function(h){var w,v,g,y,_;b._logger.trace("_update",h),b.preprocessUpdate(h,this.sid);for(var S=new Set,J=0,Y=Object.keys(h);J<Y.length;J++){var le=Y[J],me=ue[le];if(me)switch(me){case ue.status:if(!h.status||h.status==="unknown"||this._internalState.status===h.status)break;this._internalState.status=h.status,S.add(me);break;case ue.attributes:if(De.default(this._internalState.attributes,h.attributes))break;this._internalState.attributes=h.attributes,S.add(me);break;case ue.lastConsumedMessageIndex:if(h.lastConsumedMessageIndex===void 0||h.lastConsumedMessageIndex===this._internalState.lastReadMessageIndex)break;this._internalState.lastReadMessageIndex=h.lastConsumedMessageIndex,S.add("lastReadMessageIndex");break;case ue.lastMessage:if(this._internalState.lastMessage&&!h.lastMessage){delete this._internalState.lastMessage,S.add(me);break}this._internalState.lastMessage=this._internalState.lastMessage||{},((w=h.lastMessage)===null||w===void 0?void 0:w.index)!==void 0&&h.lastMessage.index!==this._internalState.lastMessage.index&&(this._internalState.lastMessage.index=h.lastMessage.index,S.add(me)),((v=h.lastMessage)===null||v===void 0?void 0:v.timestamp)!==void 0&&((g=this._internalState.lastMessage)===null||g===void 0||(y=g.dateCreated)===null||y===void 0?void 0:y.getTime())!==h.lastMessage.timestamp.getTime()&&(this._internalState.lastMessage.dateCreated=h.lastMessage.timestamp,S.add(me)),De.default(this._internalState.lastMessage,{})&&delete this._internalState.lastMessage;break;case ue.state:var pt=h.state||void 0;if(pt!==void 0&&(pt.dateUpdated=new Date(pt.dateUpdated)),De.default(this._internalState.state,pt))break;this._internalState.state=pt,S.add(me);break;case ue.bindings:if(De.default(this._internalState.bindings,h.bindings))break;this._internalState.bindings=h.bindings,S.add(me);break;default:var Tt=h[le]instanceof Date,zt=Tt&&((_=this._internalState[me])===null||_===void 0?void 0:_.getTime())===h[le].getTime(),Jt=!Tt&&this[me]===h[le];if(zt||Jt)break;this._internalState[me]=h[le],S.add(me)}}S.size>0&&this.emit(b.updated,{conversation:this,updateReasons:tt.default(S)})}},{key:"_onMessageAdded",value:function(h){var w=No(this._participants.values()),v;try{for(w.s();!(v=w.n()).done;){var g=v.value;if(g.identity===h.author){g._endTyping();break}}}catch(y){w.e(y)}finally{w.f()}this.emit(b.messageAdded,h)}},{key:"_setLastReadMessageIndex",value:function(){var p=te.default(P.default.mark(function w(v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._services.commandExecutor.mutateResource("post","".concat(this._configuration.links.myConversations,"/").concat(this.sid),{last_read_message_index:v});case 2:return g=_.sent,_.abrupt("return",g.unread_messages_count);case 4:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()}],[{key:"preprocessUpdate",value:function(h,w){try{typeof h.attributes=="string"?h.attributes=JSON.parse(h.attributes):h.attributes&&JSON.stringify(h.attributes)}catch{b._logger.warn("Retrieved malformed attributes from the server for conversation: "+w),h.attributes={}}try{h.dateCreated&&(h.dateCreated=new Date(h.dateCreated))}catch{b._logger.warn("Retrieved malformed dateCreated from the server for conversation: "+w),delete h.dateCreated}try{h.dateUpdated&&(h.dateUpdated=new Date(h.dateUpdated))}catch{b._logger.warn("Retrieved malformed dateUpdated from the server for conversation: "+w),delete h.dateUpdated}try{h.lastMessage&&h.lastMessage.timestamp&&(h.lastMessage.timestamp=new Date(h.lastMessage.timestamp))}catch{b._logger.warn("Retrieved malformed lastMessage.timestamp from the server for conversation: "+w),delete h.lastMessage.timestamp}}}]),b}(N.ReplayEventEmitter);H.default(R,"participantJoined","participantJoined"),H.default(R,"participantLeft","participantLeft"),H.default(R,"participantUpdated","participantUpdated"),H.default(R,"messageAdded","messageAdded"),H.default(R,"messageRemoved","messageRemoved"),H.default(R,"messageUpdated","messageUpdated"),H.default(R,"typingEnded","typingEnded"),H.default(R,"typingStarted","typingStarted"),H.default(R,"updated","updated"),H.default(R,"removed","removed"),H.default(R,"_logger",Kt.scope("Conversation")),Ue([k.validateTypesAsync(k.nonEmptyString,Be),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Promise)],R.prototype,"add",null),Ue([k.validateTypesAsync(k.nonEmptyString,k.nonEmptyString,Be,Be),be("design:type",Function),be("design:paramtypes",[String,String,Object,Object]),be("design:returntype",Promise)],R.prototype,"addNonChatParticipant",null),Ue([k.validateTypesAsync(k.nonNegativeInteger),be("design:type",Function),be("design:paramtypes",[Number]),be("design:returntype",Promise)],R.prototype,"advanceLastReadMessageIndex",null),Ue([k.validateTypesAsync(["undefined",k.nonNegativeInteger],["undefined",k.nonNegativeInteger],["undefined",k.literal("backwards","forward")]),be("design:type",Function),be("design:paramtypes",[Number,Number,String]),be("design:returntype",Promise)],R.prototype,"getMessages",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],R.prototype,"getParticipantBySid",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],R.prototype,"getParticipantByIdentity",null),Ue([k.validateTypesAsync([k.nonEmptyString,G]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],R.prototype,"removeParticipant",null),Ue([k.validateTypesAsync(["string",FormData,k.literal(null),k.objectSchema("media options",{contentType:k.nonEmptyString,media:k.custom(function(E){var x=typeof E=="string"&&E.length>0||E instanceof Uint8Array||E instanceof ArrayBuffer;return typeof Blob=="function"&&(x=x||E instanceof Blob),[x,"a non-empty string, an instance of Buffer or an instance of Blob"]})})],Be,["undefined",k.literal(null),k.objectSchema("email attributes",{subject:[k.nonEmptyString,"undefined"]})]),be("design:type",Function),be("design:paramtypes",[Object,Object,Object]),be("design:returntype",Promise)],R.prototype,"sendMessage",null),Ue([k.validateTypesAsync(k.literal("default","muted")),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],R.prototype,"setUserNotificationLevel",null),Ue([k.validateTypesAsync(ie),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],R.prototype,"updateAttributes",null),Ue([k.validateTypesAsync("string"),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],R.prototype,"updateFriendlyName",null),Ue([k.validateTypesAsync([k.literal(null),k.nonNegativeInteger]),be("design:type",Function),be("design:paramtypes",[Number]),be("design:returntype",Promise)],R.prototype,"updateLastReadMessageIndex",null),Ue([k.validateTypesAsync(["string",k.literal(null)]),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],R.prototype,"updateUniqueName",null);var A=function(){function E(){var x=this;ke.default(this,E),this._promise=new Promise(function(b,p){x._resolve=b,x._reject=p})}return ye.default(E,[{key:"promise",get:function(){return this._promise}},{key:"update",value:function(b){this._resolve(b)}},{key:"set",value:function(b){this.current=b,this._resolve(b)}},{key:"fail",value:function(b){this._reject(b)}}]),E}();function I(E,x){var b=typeof Symbol<"u"&&E[Symbol.iterator]||E["@@iterator"];if(!b){if(Array.isArray(E)||(b=W(E))||x){b&&(E=b);var p=0,h=function(){};return{s:h,n:function(){return p>=E.length?{done:!0}:{done:!1,value:E[p++]}},e:function(_){throw _},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1312
1312
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var w=!0,v=!1,g;return{s:function(){b=b.call(E)},n:function(){var _=b.next();return w=_.done,_},e:function(_){v=!0,g=_},f:function(){try{!w&&b.return!=null&&b.return()}finally{if(v)throw g}}}}function W(E,x){if(E){if(typeof E=="string")return j(E,x);var b=Object.prototype.toString.call(E).slice(8,-1);if(b==="Object"&&E.constructor&&(b=E.constructor.name),b==="Map"||b==="Set")return Array.from(E);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return j(E,x)}}function j(E,x){(x==null||x>E.length)&&(x=E.length);for(var b=0,p=new Array(x);b<x;b++)p[b]=E[b];return p}function Le(E,x){var b=Object.keys(E);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(E);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(E,h).enumerable})),b.push.apply(b,p)}return b}function xe(E){for(var x=1;x<arguments.length;x++){var b=arguments[x]!=null?arguments[x]:{};x%2?Le(Object(b),!0).forEach(function(p){H.default(E,p,b[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(E,Object.getOwnPropertyDescriptors(b)):Le(Object(b)).forEach(function(p){Object.defineProperty(E,p,Object.getOwnPropertyDescriptor(b,p))})}return E}function He(E){var x=it();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function it(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var $t=Kt.scope("Conversations"),Ur=function(E){q.default(b,E);var x=He(b);function b(p,h){var w;return ke.default(this,b),w=x.call(this),H.default(oe.default(w),"conversations",new Map),H.default(oe.default(w),"myConversationsRead",new A),H.default(oe.default(w),"tombstones",new Set),H.default(oe.default(w),"myConversationsFetched",!1),w.configuration=p,w.services=h,w}return ye.default(b,[{key:"addConversation",value:function(){var p=te.default(P.default.mark(function w(v){var g,y,_,S,J,Y,le,me,pt,Tt;return P.default.wrap(function(Jt){for(;;)switch(Jt.prev=Jt.next){case 0:return S=typeof(v==null?void 0:v.attributes)<"u"?v.attributes:{},Jt.next=3,this.services.commandExecutor.mutateResource("post",this.configuration.links.conversations,{friendly_name:v.friendlyName,unique_name:v.uniqueName,access:v.access,attributes:typeof S<"u"?JSON.stringify(S):void 0});case 3:if(J=Jt.sent,Y=(g=J.sid)!==null&&g!==void 0?g:null,le=(y=(_=J.sync_objects)===null||_===void 0?void 0:_.conversation)!==null&&y!==void 0?y:null,me=xe({self:J.url},J.links),pt=this.conversations.get(Y),!pt){Jt.next=12;break}return Jt.next=11,pt._subscribe();case 11:return Jt.abrupt("return",pt);case 12:return Tt=new R({channel:le,entityName:"",uniqueName:"",attributes:null,createdBy:"",friendlyName:"",lastConsumedMessageIndex:0,dateCreated:null,dateUpdated:null},Y,me,this.configuration,this.services),this.conversations.set(Tt.sid,Tt),this._registerForEvents(Tt),Jt.next=17,Tt._subscribe();case 17:return this.emit("conversationAdded",Tt),Jt.abrupt("return",Tt);case 19:case"end":return Jt.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"fetchConversations",value:function(){var p=te.default(P.default.mark(function w(){var v=this,g,y,_,S,J,Y,le;return P.default.wrap(function(pt){for(;;)switch(pt.prev=pt.next){case 0:return pt.prev=0,pt.next=3,this._getMap();case 3:return g=pt.sent,g.on(Pe.SyncMap.itemAdded,function(Tt){$t.debug("itemAdded: ".concat(Tt.item.key)),v._upsertConversation("sync",Tt.item.key,Tt.item.data)}),g.on(Pe.SyncMap.itemRemoved,function(Tt){$t.debug("itemRemoved: ".concat(Tt.key));var zt=Tt.key;v.myConversationsFetched||v.tombstones.add(zt);var Jt=v.conversations.get(zt);Jt&&(Jt.status==="joined"&&(Jt._setStatus("notParticipating","sync"),v.emit("conversationLeft",Jt)),v.conversations.delete(zt),v.emit("conversationRemoved",Jt),Jt.emit("removed",Jt))}),g.on(Pe.SyncMap.itemUpdated,function(Tt){$t.debug("itemUpdated: ".concat(Tt.item.key)),v._upsertConversation("sync",Tt.item.key,Tt.item.data)}),pt.next=9,this._fetchMyConversations();case 9:y=pt.sent,_=[],S=I(y);try{for(S.s();!(J=S.n()).done;)Y=J.value,_.push(this._upsertConversation("rest",Y.channel_sid,Y))}catch(Tt){S.e(Tt)}finally{S.f()}return this.myConversationsRead.set(!0),pt.next=16,Promise.all(_);case 16:return this.myConversationsFetched=!0,this.tombstones.clear(),$t.debug("The conversations list has been successfully fetched"),pt.abrupt("return",this);case 22:throw pt.prev=22,pt.t0=pt.catch(0),le="Failed to fetch the conversations list",this.services.syncClient.connectionState!=="disconnected"&&$t.error(le,pt.t0),$t.debug("ERROR: ".concat(le),pt.t0),pt.t0;case 28:case"end":return pt.stop()}},w,this,[[0,22]])}));function h(){return p.apply(this,arguments)}return h}()},{key:"getConversations",value:function(){var p=te.default(P.default.mark(function w(){var v=this,g,y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:return S.next=2,this._getMap();case 2:return g=S.sent,S.next=5,g.getItems();case 5:return y=S.sent,S.abrupt("return",this._wrapPaginator(y,function(J){return Promise.all(J.map(function(Y){return v._upsertConversation("sync",Y.key,Y.data)}))}));case 7:case"end":return S.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getConversation",value:function(){var p=te.default(P.default.mark(function w(v){var g=this,y,_,S;return P.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return Y.next=2,this._getMap();case 2:return y=Y.sent,Y.next=5,y.getItems({key:v});case 5:return _=Y.sent,S=_.items.map(function(le){return g._upsertConversation("sync",le.key,le.data)}),Y.abrupt("return",S.length>0?S[0]:null);case 8:case"end":return Y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getConversationByUniqueName",value:function(){var p=te.default(P.default.mark(function w(v){var g,y,_,S,J;return P.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:return g=new V(this.configuration.links.myConversations).path(v).build(),le.next=3,this.services.network.get(g);case 3:return y=le.sent,_=y.body,S=_.conversation_sid,J={entityName:null,lastConsumedMessageIndex:_.last_read_message_index,status:(_==null?void 0:_.status)||"unknown",friendlyName:_.friendly_name,dateUpdated:_.date_updated,dateCreated:_.date_created,uniqueName:_.unique_name,createdBy:_.created_by,attributes:_.attributes,channel:_.sync_objects.conversation,roster:_.sync_objects.participants,messages:_.sync_objects.messages,notificationLevel:_==null?void 0:_.notification_level,sid:S},le.abrupt("return",S?this._upsertConversation("sync",S,J):null);case 8:case"end":return le.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"peekConversation",value:function(){var p=te.default(P.default.mark(function w(v){var g,y,_,S;return P.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return g=new V(this.configuration.links.conversations).path(v).build(),Y.next=3,this.services.network.get(g);case 3:return y=Y.sent,_=y.body,S={entityName:null,status:(_==null?void 0:_.status)||"unknown",friendlyName:_.friendly_name,dateUpdated:_.date_updated,dateCreated:_.date_created,uniqueName:_.unique_name,createdBy:_.created_by,attributes:_.attributes,channel:_.sync_objects.conversation||"".concat(v,".channel"),roster:_.sync_objects.participants,messages:_.sync_objects.messages,notificationLevel:_==null?void 0:_.notification_level,sid:v},Y.abrupt("return",this._upsertConversation("sync",v,S));case 7:case"end":return Y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"_getMap",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this.services.syncClient.map({id:this.configuration.myConversations,mode:"open_existing"});case 2:return g.abrupt("return",g.sent);case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_wrapPaginator",value:function(){var p=te.default(P.default.mark(function w(v,g){var y=this,_;return P.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return J.next=2,g(v.items);case 2:return _=J.sent,J.abrupt("return",{items:_.filter(function(Y){return Y!==null}),hasNextPage:v.hasNextPage,hasPrevPage:v.hasPrevPage,nextPage:function(){return v.nextPage().then(function(le){return y._wrapPaginator(le,g)})},prevPage:function(){return v.prevPage().then(function(le){return y._wrapPaginator(le,g)})}});case 4:case"end":return J.stop()}},w)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"_updateConversation",value:function(){var p=te.default(P.default.mark(function w(v,g,y){var _,S,J;return P.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(_=g._statusSource!==void 0&&v!==g._statusSource,S=v!=="rest"||g._statusSource==="sync",!(_&&S&&v!=="sync")){le.next=5;break}return $t.trace("upsertConversation: conversation is known from sync and came from REST, ignoring",{sid:g.sid,data:y.status,conversation:g.status}),le.abrupt("return");case 5:if(!(y.status==="joined"&&g.status!=="joined")){le.next=15;break}return g._setStatus("joined",v),J={},typeof y.notificationLevel<"u"&&(J.notificationLevel=y.notificationLevel),typeof y.lastConsumedMessageIndex<"u"&&(J.lastConsumedMessageIndex=y.lastConsumedMessageIndex),De.default(J,{})||g._update(J),le.next=13,g._subscribe();case 13:return this.emit("conversationJoined",g),le.abrupt("return");case 15:if(!(y.status==="notParticipating"&&g.status==="joined")){le.next=22;break}return g._setStatus("notParticipating",v),g._update(y),le.next=20,g._subscribe();case 20:return this.emit("conversationLeft",g),le.abrupt("return");case 22:if(y.status!=="notParticipating"){le.next=26;break}return le.next=25,g._subscribe();case 25:return le.abrupt("return");case 26:g._update(y);case 27:case"end":return le.stop()}},w,this)}));function h(w,v,g){return p.apply(this,arguments)}return h}()},{key:"_upsertConversation",value:function(){var p=te.default(P.default.mark(function w(v,g,y){var _,S,J,Y;return P.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:if($t.trace("upsertConversation called for ".concat(g),y),_=this.conversations.get(g),!_){me.next=9;break}return $t.trace("upsertConversation: the conversation ".concat(_.sid," is known;")+"its status is known from the source ".concat(_._statusSource," ")+"and the update came from the source ".concat(v),_),me.next=6,this._updateConversation(v,_,y);case 6:return me.next=8,_._subscribe();case 8:return me.abrupt("return",_);case 9:if(!(v==="rest"&&this.tombstones.has(g))){me.next=12;break}return $t.trace("upsertChannel: the conversation is deleted but reappeared again from REST, ignoring",g),me.abrupt("return",null);case 12:return $t.trace("upsertConversation: creating a local conversation object with sid "+g,y),S="".concat(this.configuration.links.conversations,"/").concat(g),J={self:S,messages:"".concat(S,"/Messages"),participants:"".concat(S,"/Participants")},Y=new R(y,g,J,this.configuration,this.services),this.conversations.set(g,Y),me.prev=17,me.next=20,Y._subscribe();case 20:if(y.status!=="joined"){me.next=23;break}return me.next=23,Y._fetchStreams();case 23:me.next=32;break;case 25:if(me.prev=25,me.t0=me.catch(17),me.t0.name==="SyncError"){me.next=29;break}throw me.t0;case 29:return $t.trace("upsertChannel: the conversation is missing some Sync entity(ies), ignoring",g,me.t0),this.conversations.delete(g),me.abrupt("return",null);case 32:return this._registerForEvents(Y),this.emit("conversationAdded",Y),y.status==="joined"&&(Y._setStatus("joined",v),this.emit("conversationJoined",Y)),me.abrupt("return",Y);case 36:case"end":return me.stop()}},w,this,[[17,25]])}));function h(w,v,g){return p.apply(this,arguments)}return h}()},{key:"_fetchMyConversations",value:function(){var p=te.default(P.default.mark(function w(){var v,g,y,_,S,J;return P.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:v=[],g=null;case 2:return _=new V(this.configuration.links.myConversations),g&&_.arg("PageToken",g),le.next=6,this.services.network.get(_.build());case 6:S=le.sent,J=(y=S.body)===null||y===void 0?void 0:y.conversations.map(function(me){return{descriptor:me,channel_sid:me.conversation_sid,status:me.status,channel:me.sync_objects.conversation,messages:me.sync_objects.messages,roster:me.sync_objects.participants||"".concat(me.conversation_sid,".roster"),lastConsumedMessageIndex:me.last_read_message_index,notificationLevel:me.notification_level}}),g=S.body.meta.next_token,v=[].concat(tt.default(v),tt.default(J));case 10:if(g){le.next=2;break}case 11:return le.abrupt("return",v);case 12:case"end":return le.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_onConversationRemoved",value:function(h){var w=this.conversations.get(h);w&&(this.conversations.delete(h),this.emit("conversationRemoved",w))}},{key:"_registerForEvents",value:function(h){var w=this;h.on("removed",function(){return w._onConversationRemoved(h.sid)}),h.on("updated",function(v){return w.emit("conversationUpdated",v)}),h.on("participantJoined",function(v){return w.emit("participantJoined",v)}),h.on("participantLeft",function(v){return w.emit("participantLeft",v)}),h.on("participantUpdated",function(v){return w.emit("participantUpdated",v)}),h.on("messageAdded",function(v){return w.emit("messageAdded",v)}),h.on("messageUpdated",function(v){return w.emit("messageUpdated",v)}),h.on("messageRemoved",function(v){return w.emit("messageRemoved",v)}),h.on("typingStarted",function(v){return w.emit("typingStarted",v)}),h.on("typingEnded",function(v){return w.emit("typingEnded",v)})}}]),b}(N.ReplayEventEmitter);function On(E){var x=bn();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function bn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var D=function(E){q.default(b,E);var x=On(b);function b(p,h,w){var v;return ke.default(this,b),v=x.call(this),v.configuration=h,v.services=w,v.fifoStack=[],v.myself=p,v.myself.on("updated",function(g){return v.emit("userUpdated",g)}),v.myself.on("userSubscribed",function(){return v.emit("userSubscribed",v.myself)}),v.myself.on("userUnsubscribed",function(){v.emit("userUnsubscribed",v.myself),v.myself._ensureFetched()}),v.subscribedUsers=new Map,v}return ye.default(b,[{key:"handleUnsubscribeUser",value:function(h){this.subscribedUsers.has(h.identity)&&this.subscribedUsers.delete(h.identity);var w=0,v=this.fifoStack.find(function(g,y){return g==h.identity?(w=y,!0):!1});v&&this.fifoStack.splice(w,1),this.emit("userUnsubscribed",h)}},{key:"handleSubscribeUser",value:function(h){if(!this.subscribedUsers.has(h.identity)){if(this.fifoStack.length>=this.configuration.userInfosToSubscribe){var w,v,g=this.fifoStack.shift();(w=this.subscribedUsers)===null||w===void 0||(v=w.get(g))===null||v===void 0||v.unsubscribe()}this.fifoStack.push(h.identity),this.subscribedUsers.set(h.identity,h),this.emit("userSubscribed",h)}}},{key:"getUser",value:function(){var p=te.default(P.default.mark(function w(v,g){var y,_=this,S,J;return P.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:return le.next=2,this.myself._ensureFetched();case 2:if(v!=this.myself.identity){le.next=4;break}return le.abrupt("return",this.myself);case 4:if(S=this.subscribedUsers.get(v),!S){le.next=7;break}return le.abrupt("return",S);case 7:if(!((y=g)!==null&&y!==void 0)){le.next=11;break}le.next=14;break;case 11:return le.next=13,this.getSyncUniqueName(v);case 13:g=le.sent;case 14:return J=new Ee(v,g,this.configuration,this.services),J.on("updated",function(me){return _.emit("userUpdated",me)}),J.on("userSubscribed",function(){return _.handleSubscribeUser(J)}),J.on("userUnsubscribed",function(){return _.handleUnsubscribeUser(J)}),le.next=20,J._ensureFetched();case 20:return le.abrupt("return",J);case 21:case"end":return le.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"getSubscribedUsers",value:function(){var p=te.default(P.default.mark(function w(){var v;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this.myself._ensureFetched();case 2:return v=[this.myself],this.subscribedUsers.forEach(function(_){return v.push(_)}),y.abrupt("return",v);case 5:case"end":return y.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getSyncUniqueName",value:function(){var p=te.default(P.default.mark(function w(v){var g,y,_,S;return P.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:return _=new V(this.configuration.links.users).path(v).build(),Y.next=3,this.services.network.get(_);case 3:return S=Y.sent,Y.abrupt("return",(g=(y=S.body)===null||y===void 0?void 0:y.sync_objects.user_info_map)!==null&&g!==void 0?g:"");case 5:case"end":return Y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()}]),b}(N.ReplayEventEmitter),B=Kt.scope("TypingIndicator"),C=function(){function E(x,b,p){ke.default(this,E),this.configuration=b,this.services=p,this.getConversation=x,this.serviceTypingTimeout=null,this.sentUpdates=new Map}return ye.default(E,[{key:"typingTimeout",get:function(){return this.configuration.typingIndicatorTimeoutOverride||this.serviceTypingTimeout||this.configuration.typingIndicatorTimeoutDefault}},{key:"initialize",value:function(){var b=this;this.services.notificationClient.on("message",function(){var p=te.default(P.default.mark(function h(w,v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:if(w!==ge.TYPING_INDICATOR){y.next=3;break}return y.next=3,b._handleRemoteTyping(v);case 3:case"end":return y.stop()}},h)}));return function(h,w){return p.apply(this,arguments)}}())}},{key:"_handleRemoteTyping",value:function(){var x=te.default(P.default.mark(function p(h){var w=this;return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:B.trace("Got new typing indicator ",h),this.getConversation(h.channel_sid).then(function(y){y&&y._participants.forEach(function(_){if(!(_.identity!==h.identity&&_.type!=="apple")){var S=w.configuration.typingIndicatorTimeoutOverride?w.configuration.typingIndicatorTimeoutOverride+1e3:h.typing_timeout*1e3;_._startTyping(S)}})}).catch(function(y){throw B.error(y),y});case 2:case"end":return g.stop()}},p,this)}));function b(p){return x.apply(this,arguments)}return b}()},{key:"send",value:function(b){var p=this.sentUpdates.get(b);return p&&p>Date.now()-this.typingTimeout?Promise.resolve():(this.sentUpdates.set(b,Date.now()),this._send(b))}},{key:"_send",value:function(b){var p=this;B.trace("Sending typing indicator");var h=this.configuration.links.typing,w={"Content-Type":"application/x-www-form-urlencoded"},v="ChannelSid=".concat(b);return this.services.twilsockClient.post(h,w,v,this.configuration.productId).then(function(g){g.body.hasOwnProperty("typing_timeout")&&(p.serviceTypingTimeout=g.body.typing_timeout*1e3)}).catch(function(g){throw B.error("Failed to send typing indicator:",g),g})}}]),E}(),T=ye.default(function E(x){ke.default(this,E),this.title=x.title||null,this.body=x.body||null,this.sound=x.sound||null,this.badge=x.badge||null,this.action=x.action||null,this.type=x.type||null,this.data=x.data||{}}),$="2.6.5";function U(E,x){var b=Object.keys(E);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(E);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(E,h).enumerable})),b.push.apply(b,p)}return b}function O(E){for(var x=1;x<arguments.length;x++){var b=arguments[x]!=null?arguments[x]:{};x%2?U(Object(b),!0).forEach(function(p){H.default(E,p,b[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(E,Object.getOwnPropertyDescriptors(b)):U(Object(b)).forEach(function(p){Object.defineProperty(E,p,Object.getOwnPropertyDescriptor(b,p))})}return E}function Ae(E){var x=Ce();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function Ce(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Je=function(x){return x.replace(/(^\/+|\/+$)/g,"")},nt=function(x){return x.status.code===202},Ot=function(E){q.default(b,E);var x=Ae(b);function b(p){return ke.default(this,b),x.call(this,p)}return ye.default(b)}(Ge.default(Error)),fn=function(){function E(x,b,p){ke.default(this,E),this._serviceUrl=x,this._services=b,this._productId=p}return ye.default(E,[{key:"_preProcessUrl",value:function(b){var p=Je(b);return/^https?:\/\//.test(b)?p:"".concat(Je(this._serviceUrl),"/").concat(p)}},{key:"_makeRequest",value:function(){var x=te.default(P.default.mark(function p(h,w,v,g){var y,_,S,J;return P.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:y=this._preProcessUrl(w),_=O({"Content-Type":"application/json; charset=utf-8"},g||{}),le.t0=h,le.next=le.t0==="get"?5:le.t0==="post"?11:le.t0==="delete"?15:19;break;case 5:return J=y,v&&(J+="?"+Object.entries(v).map(function(me){return me.map(encodeURIComponent).join("=")}).join("&")),le.next=9,this._services.transport.get(J,_,this._productId);case 9:return S=le.sent,le.abrupt("break",19);case 11:return le.next=13,this._services.transport.post(y,_,JSON.stringify(v),this._productId);case 13:return S=le.sent,le.abrupt("break",19);case 15:return le.next=17,this._services.transport.delete(y,_,{},this._productId);case 17:return S=le.sent,le.abrupt("break",19);case 19:if(!(S.status.code<200||S.status.code>=300)){le.next=21;break}throw new Error("Request responded with a non-success code ".concat(S.status.code));case 21:return le.abrupt("return",S);case 22:case"end":return le.stop()}},p,this)}));function b(p,h,w,v){return x.apply(this,arguments)}return b}()},{key:"fetchResource",value:function(){var x=te.default(P.default.mark(function p(h,w){var v=this,g,y,_;return P.default.wrap(function(J){for(;;)switch(J.prev=J.next){case 0:return g=6,y=new Me.AsyncRetrier({min:50,max:1600,maxAttemptsCount:g}),J.prev=2,J.next=5,y.run(te.default(P.default.mark(function Y(){var le,me,pt;return P.default.wrap(function(zt){for(;;)switch(zt.prev=zt.next){case 0:return zt.prev=0,zt.next=3,v._makeRequest("get",h,w);case 3:return le=zt.sent,zt.abrupt("return",{type:"success",data:le.body});case 7:if(zt.prev=7,zt.t0=zt.catch(0),!((zt.t0===null||zt.t0===void 0||(me=zt.t0.body)===null||me===void 0?void 0:me.status)===404&&(zt.t0===null||zt.t0===void 0||(pt=zt.t0.body)===null||pt===void 0?void 0:pt.code)===50530)){zt.next=11;break}return zt.abrupt("return",{type:"noMetadata"});case 11:throw zt.t0;case 12:case"end":return zt.stop()}},Y,null,[[0,7]])})));case 5:_=J.sent,J.next=11;break;case 8:throw J.prev=8,J.t0=J.catch(2),new Error('Fetch resource from "'.concat(h,'" failed.'));case 11:if(_.type!=="noMetadata"){J.next=13;break}throw new Ot("No metadata found.");case 13:return J.abrupt("return",_.data);case 14:case"end":return J.stop()}},p,null,[[2,8]])}));function b(p,h){return x.apply(this,arguments)}return b}()},{key:"mutateResource",value:function(){var x=te.default(P.default.mark(function p(h,w,v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._makeRequest(h,w,v,{"X-Twilio-Mutation-Id":_e.v4()});case 2:if(g=_.sent,!nt(g)){_.next=7;break}return _.next=6,this.fetchResource(g.body.resource_url);case 6:return _.abrupt("return",_.sent);case 7:return _.abrupt("return",g.body);case 8:case"end":return _.stop()}},p,this)}));function b(p,h,w){return x.apply(this,arguments)}return b}()}]),E}(),Pi=function(){function E(x){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:100,p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:5e3;ke.default(this,E),H.default(this,"_cachedTemplates",null),this._services=x,this._pageSize=b,this._cacheTtlMs=p}return ye.default(E,[{key:"getContentTemplates",value:function(){var x=te.default(P.default.mark(function p(){var h=this,w,v,g,y,_,S,J;return P.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(this._cachedTemplates===null){le.next=2;break}return le.abrupt("return",this._cachedTemplates);case 2:return le.next=4,this._fetchContentTemplates();case 4:w=le.sent,v=ce.default(w,2),g=v[0],y=v[1],_=g;case 9:if(y===null){le.next=19;break}return le.next=12,this._fetchContentTemplates(y);case 12:S=le.sent,J=ce.default(S,2),g=J[0],y=J[1],_=[].concat(tt.default(_),tt.default(g)),le.next=9;break;case 19:return this._cachedTemplates=Object.freeze(_),setTimeout(function(){h._cachedTemplates=null},this._cacheTtlMs),le.abrupt("return",_);case 22:case"end":return le.stop()}},p,this)}));function b(){return x.apply(this,arguments)}return b}()},{key:"_fetchContentTemplates",value:function(){var x=te.default(P.default.mark(function p(h){var w,v,g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return w="Client/v2/ContentTemplates",v=new V(w),v.arg("PageSize",this._pageSize),h!==void 0&&v.arg("PageToken",h),_.next=6,this._services.commandExecutor.fetchResource(v.build());case 6:return g=_.sent,_.abrupt("return",[g.templates.map(function(S){return new Dt(S)}),g.meta.next_token]);case 8:case"end":return _.stop()}},p,this)}));function b(p){return x.apply(this,arguments)}return b}()}]),E}();function Qr(E,x){var b=typeof Symbol<"u"&&E[Symbol.iterator]||E["@@iterator"];if(!b){if(Array.isArray(E)||(b=Mi(E))||x){b&&(E=b);var p=0,h=function(){};return{s:h,n:function(){return p>=E.length?{done:!0}:{done:!1,value:E[p++]}},e:function(_){throw _},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1313
1313
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var w=!0,v=!1,g;return{s:function(){b=b.call(E)},n:function(){var _=b.next();return w=_.done,_},e:function(_){v=!0,g=_},f:function(){try{!w&&b.return!=null&&b.return()}finally{if(v)throw g}}}}function Mi(E,x){if(E){if(typeof E=="string")return Ep(E,x);var b=Object.prototype.toString.call(E).slice(8,-1);if(b==="Object"&&E.constructor&&(b=E.constructor.name),b==="Map"||b==="Set")return Array.from(E);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return Ep(E,x)}}function Ep(E,x){(x==null||x>E.length)&&(x=E.length);for(var b=0,p=new Array(x);b<x;b++)p[b]=E[b];return p}var sw=function(E){function x(){var b=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(ke.default(this,x),!(b.maxSize&&b.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=b.maxSize,this.onEviction=b.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}return ye.default(x,[{key:"_set",value:function(p,h){if(this.cache.set(p,h),this._size++,this._size>=this.maxSize){if(this._size=0,typeof this.onEviction=="function"){var w=Qr(this.oldCache.entries()),v;try{for(w.s();!(v=w.n()).done;){var g=ce.default(v.value,2),y=g[0],_=g[1];this.onEviction(y,_)}}catch(S){w.e(S)}finally{w.f()}}this.oldCache=this.cache,this.cache=new Map}}},{key:"get",value:function(p){if(this.cache.has(p))return this.cache.get(p);if(this.oldCache.has(p)){var h=this.oldCache.get(p);return this.oldCache.delete(p),this._set(p,h),h}}},{key:"set",value:function(p,h){return this.cache.has(p)?this.cache.set(p,h):this._set(p,h),this}},{key:"has",value:function(p){return this.cache.has(p)||this.oldCache.has(p)}},{key:"peek",value:function(p){if(this.cache.has(p))return this.cache.get(p);if(this.oldCache.has(p))return this.oldCache.get(p)}},{key:"delete",value:function(p){var h=this.cache.delete(p);return h&&this._size--,this.oldCache.delete(p)||h}},{key:"clear",value:function(){this.cache.clear(),this.oldCache.clear(),this._size=0}},{key:"keys",value:P.default.mark(function b(){var p,h,w,v;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:p=Qr(this),y.prev=1,p.s();case 3:if((h=p.n()).done){y.next=9;break}return w=ce.default(h.value,1),v=w[0],y.next=7,v;case 7:y.next=3;break;case 9:y.next=14;break;case 11:y.prev=11,y.t0=y.catch(1),p.e(y.t0);case 14:return y.prev=14,p.f(),y.finish(14);case 17:case"end":return y.stop()}},b,this,[[1,11,14,17]])})},{key:"values",value:P.default.mark(function b(){var p,h,w,v;return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:p=Qr(this),y.prev=1,p.s();case 3:if((h=p.n()).done){y.next=9;break}return w=ce.default(h.value,2),v=w[1],y.next=7,v;case 7:y.next=3;break;case 9:y.next=14;break;case 11:y.prev=11,y.t0=y.catch(1),p.e(y.t0);case 14:return y.prev=14,p.f(),y.finish(14);case 17:case"end":return y.stop()}},b,this,[[1,11,14,17]])})},{key:E,value:P.default.mark(function b(){var p,h,w,v,g,y,_,S;return P.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:p=Qr(this.cache),Y.prev=1,p.s();case 3:if((h=p.n()).done){Y.next=9;break}return w=h.value,Y.next=7,w;case 7:Y.next=3;break;case 9:Y.next=14;break;case 11:Y.prev=11,Y.t0=Y.catch(1),p.e(Y.t0);case 14:return Y.prev=14,p.f(),Y.finish(14);case 17:v=Qr(this.oldCache),Y.prev=18,v.s();case 20:if((g=v.n()).done){Y.next=28;break}if(y=g.value,_=ce.default(y,1),S=_[0],this.cache.has(S)){Y.next=26;break}return Y.next=26,y;case 26:Y.next=20;break;case 28:Y.next=33;break;case 30:Y.prev=30,Y.t1=Y.catch(18),v.e(Y.t1);case 33:return Y.prev=33,v.f(),Y.finish(33);case 36:case"end":return Y.stop()}},b,this,[[1,11,14,17],[18,30,33,36]])})},{key:"size",get:function(){var p=0,h=Qr(this.oldCache.keys()),w;try{for(h.s();!(w=h.n()).done;){var v=w.value;this.cache.has(v)||p++}}catch(g){h.e(g)}finally{h.f()}return Math.min(this._size+p,this.maxSize)}}]),x}(Symbol.iterator),F=sw,ve=ye.default(function E(x,b){ke.default(this,E),this.type=x,this.data=b,Object.freeze(b)}),qe=function(){function E(x,b){ke.default(this,E),this._services=x,this._configuration=b,this._cache=new F({maxSize:b.channelMetadataCacheCapacity})}return ye.default(E,[{key:"getChannelMetadata",value:function(){var x=te.default(P.default.mark(function p(h,w){var v,g,y,_,S;return P.default.wrap(function(Y){for(;;)switch(Y.prev=Y.next){case 0:if(v="".concat(h,",").concat(w),g=this._cache.get(v),!g){Y.next=4;break}return Y.abrupt("return",g.item);case 4:return y="".concat(this._configuration.links.conversations,"/").concat(h,"/Messages/").concat(w,"/ChannelMetadata"),Y.prev=5,Y.next=8,this._services.commandExecutor.fetchResource(y);case 8:_=Y.sent,Y.next=17;break;case 11:if(Y.prev=11,Y.t0=Y.catch(5),!(Y.t0 instanceof Ot)){Y.next=16;break}return this._cache.set(v,{item:null}),Y.abrupt("return",null);case 16:throw new Error(Y.t0);case 17:return S=new ve(_.type,_.data),this._cache.set(v,{item:S}),Y.abrupt("return",S);case 20:case"end":return Y.stop()}},p,this,[[5,11]])}));function b(p,h){return x.apply(this,arguments)}return b}()}]),E}();function bt(E,x){var b=typeof Symbol<"u"&&E[Symbol.iterator]||E["@@iterator"];if(!b){if(Array.isArray(E)||(b=Pr(E))||x){b&&(E=b);var p=0,h=function(){};return{s:h,n:function(){return p>=E.length?{done:!0}:{done:!1,value:E[p++]}},e:function(_){throw _},f:h}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
1314
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var w=!0,v=!1,g;return{s:function(){b=b.call(E)},n:function(){var _=b.next();return w=_.done,_},e:function(_){v=!0,g=_},f:function(){try{!w&&b.return!=null&&b.return()}finally{if(v)throw g}}}}function Pr(E,x){if(E){if(typeof E=="string")return Yt(E,x);var b=Object.prototype.toString.call(E).slice(8,-1);if(b==="Object"&&E.constructor&&(b=E.constructor.name),b==="Map"||b==="Set")return Array.from(E);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return Yt(E,x)}}function Yt(E,x){(x==null||x>E.length)&&(x=E.length);for(var b=0,p=new Array(x);b<x;b++)p[b]=E[b];return p}var Fr=ye.default(function E(x){ke.default(this,E),H.default(this,"type","email"),this.messageSid=x.message_sid,this.level=x.level,this.name=x.name,this.address=x.address}),Gr=ye.default(function E(x){ke.default(this,E),this.type=x.type,this.messageSid=x.message_sid,this.rawData=JSON.stringify(x)}),nn=function(){function E(x,b){ke.default(this,E),this._services=x,this._configuration=b,this._cache=new F({maxSize:b.messageRecipientsCacheCapacity})}return ye.default(E,[{key:"getRecipientsFromMessage",value:function(){var x=te.default(P.default.mark(function p(h,w){var v=this,g,y,_,S,J;return P.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(g="".concat(h,",").concat(w),y=this._cache.get(g),!y){le.next=4;break}return le.abrupt("return",y.item);case 4:return _=new V(this._configuration.links.conversations).path(h).path("MessageRecipients").arg("MessageSid",w).build(),le.next=7,this._services.commandExecutor.fetchResource(_);case 7:return S=le.sent,J=S.message_recipients.map(function(me){return v._wrapResponse(me)}),J.length>0&&this._cache.set(g,{item:J}),le.abrupt("return",J);case 11:case"end":return le.stop()}},p,this)}));function b(p,h){return x.apply(this,arguments)}return b}()},{key:"getRecipientsFromConversation",value:function(){var x=te.default(P.default.mark(function p(h,w){var v,g,y=this,_,S,J,Y,le,me,pt,Tt,zt,Jt;return P.default.wrap(function(pr){for(;;)switch(pr.prev=pr.next){case 0:return _=new V(this._configuration.links.conversations).path(h).path("MessageRecipients").arg("PageToken",(v=w==null?void 0:w.pageToken)!==null&&v!==void 0?v:void 0).arg("PageSize",(g=w==null?void 0:w.pageSize)!==null&&g!==void 0?g:void 0).build(),pr.next=3,this._services.commandExecutor.fetchResource(_);case 3:S=pr.sent,J=S.message_recipients.map(function(Zt){return y._wrapResponse(Zt)}),Y=bt(J);try{for(Y.s();!(le=Y.n()).done;)Tt=le.value,zt="".concat(h,",").concat(Tt.messageSid),Jt=(me=(pt=this._cache.get(zt))===null||pt===void 0?void 0:pt.item)!==null&&me!==void 0?me:[],this._cache.set(zt,{item:[].concat(tt.default(Jt),[Tt])})}catch(Zt){Y.e(Zt)}finally{Y.f()}return pr.abrupt("return",new ft(J,function(Zt,hi){return y.getRecipientsFromConversation(h,{pageToken:Zt,pageSize:hi})},S.meta.previous_token,S.meta.next_token));case 8:case"end":return pr.stop()}},p,this)}));function b(p,h){return x.apply(this,arguments)}return b}()},{key:"_wrapResponse",value:function(b){switch(b.type){case"email":return new Fr(b);default:return new Gr(b)}}}]),E}(),Mt;function wn(E,x){var b=Object.keys(E);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(E);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(E,h).enumerable})),b.push.apply(b,p)}return b}function _n(E){for(var x=1;x<arguments.length;x++){var b=arguments[x]!=null?arguments[x]:{};x%2?wn(Object(b),!0).forEach(function(p){H.default(E,p,b[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(E,Object.getOwnPropertyDescriptors(b)):wn(Object(b)).forEach(function(p){Object.defineProperty(E,p,Object.getOwnPropertyDescriptor(b,p))})}return E}function dn(E){var x=zn();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function zn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Wt,ua=ye.default(function E(){ke.default(this,E)});t.Client=Wt=(Mt=function(E){q.default(b,E);var x=dn(b);function b(p){var h,w,v,g,y,_,S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(ke.default(this,b),_=x.call(this),H.default(oe.default(_),"version",$),H.default(oe.default(_),"connectionState","unknown"),H.default(oe.default(_),"parsePushNotification",Wt.parsePushNotification),_._fpaToken=p??"",_._options=S??{},!_._options.disableDeepClone){var J=_n(_n({},_._options),{},{transport:void 0,twilsockClient:void 0});J=cr(J),J.transport=_._options.transport,J.twilsockClient=_._options.twilsockClient,_._options=J}_._options.logLevel=(h=_._options.logLevel)!==null&&h!==void 0?h:"silent",Wt._logger.setLevel(_._options.logLevel);var Y=_._options.productId="ip_messaging";if(_._options.clientMetadata=_._options.clientMetadata||{},_._options.clientMetadata.hasOwnProperty("type")||(_._options.clientMetadata.type="conversations"),_._options.clientMetadata.hasOwnProperty("sdk")||(_._options.clientMetadata.sdk="JS",_._options.clientMetadata.sdkv=$),_._options.Sync=_._options.Sync||{},typeof _._options.Sync.enableSessionStorage>"u"&&(_._options.Sync.enableSessionStorage=!0),_._options.region&&(_._options.Sync.region=_._options.region),!p)throw new Error("A valid Twilio token should be provided");_._services=new ua,_._myself=new Ee("","",null,_._services);var le=!_._options.twilsockClient;if(!_._options.initRegistrations){var me=new Oe.InitRegistration(Y);Wt.populateInitRegistrations(me),_._options.initRegistrations=[me]}_._services.twilsockClient=_._options.twilsockClient=(w=_._options.twilsockClient)!==null&&w!==void 0?w:new Oe.TwilsockClient(p,Y,_._options),_._services.twilsockClient.on(Wt.tokenAboutToExpire,function(){return _.emit(Wt.tokenAboutToExpire)}),_._services.twilsockClient.on(Wt.tokenExpired,function(){return _.emit(Wt.tokenExpired)}),_._services.twilsockClient.on(Wt.connectionError,function(pr){return _.emit(Wt.connectionError,pr)}),_._services.twilsockClient.on("stateChanged",function(pr){Wt._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(pr)),pr!==_.connectionState&&(_.connectionState=pr,_.emit(Wt.connectionStateChanged,_.connectionState))}),_._services.transport=_._options.transport=(v=_._options.transport)!==null&&v!==void 0?v:_._options.twilsockClient,_._services.notificationClient=_._options.notificationsClient=(g=_._options.notificationsClient)!==null&&g!==void 0?g:new Be.Notifications(p,_._options),_._services.syncClient=_._options.syncClient=(y=_._options.syncClient)!==null&&y!==void 0?y:new Pe.SyncClient(p,_._options);var pt=(S==null?void 0:S.Chat)||(S==null?void 0:S.IPMessaging)||S||{},Tt=pt.region||(S==null?void 0:S.region),zt=pt.apiUri||pt.typingUri||"https://aim.".concat(Tt||"us1",".twilio.com");_._services.commandExecutor=new fn(zt,{transport:_._options.transport},Y),_._services.contentClient=new Pi(_._services);var Jt=function(Zt){_._rejectEnsureReady(Zt),_.emit(Wt.stateChanged,"failed"),_.emit(Wt.initFailed,{error:Zt})},br=function(){Jt({terminal:!0,message:"Twilsock has disconnected."}),_._initializeEnsureReady((S==null?void 0:S.throwErrorsAlways)||!1)};return _._services.twilsockClient.once("connectionError",Jt),_._services.twilsockClient.once("disconnected",br),_._services.twilsockClient.once("connected",te.default(P.default.mark(function pr(){var Zt,hi;return P.default.wrap(function(Nt){for(;;)switch(Nt.prev=Nt.next){case 0:return Wt._logger.debug("ConversationsClient started INITIALIZING"),_._services.twilsockClient.off("connectionError",Jt),_._services.twilsockClient.off("disconnected",br),Nt.prev=3,Zt="conversations.client.startup",_._services.twilsockClient.addPartialTelemetryEvent(new Oe.TelemetryEventDescription(Zt,"Conversations client startup",new Date),Zt,Oe.TelemetryPoint.Start),Nt.next=8,_._initialize();case 8:_._services.twilsockClient.addPartialTelemetryEvent(new Oe.TelemetryEventDescription("","",new Date),Zt,Oe.TelemetryPoint.End),Nt.next=17;break;case 11:Nt.prev=11,Nt.t0=Nt.catch(3),hi={terminal:!0,message:Nt.t0.message},_._rejectEnsureReady(hi),_.emit(Wt.stateChanged,"failed"),_.emit(Wt.initFailed,{error:hi});case 17:case"end":return Nt.stop()}},pr,null,[[3,11]])}))),_._initializeEnsureReady((S==null?void 0:S.throwErrorsAlways)||!1),le&&_._services.twilsockClient.connect(),_}return ye.default(b,[{key:"user",get:function(){return this._myself}},{key:"reachabilityEnabled",get:function(){if(!this._configuration)throw new Error("Reachability information could not yet be accessed as the client has not yet been initialized. Subscribe to the 'stateChanged' event to properly react to the client initialization.");return this._configuration.reachabilityEnabled}},{key:"token",get:function(){return this._fpaToken}},{key:"shutdown",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateToken",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:if(Wt._logger.info("updateToken"),this._fpaToken!==v){y.next=5;break}return y.abrupt("return",this);case 5:return y.next=7,this._services.twilsockClient.updateToken(v);case 7:return y.next=9,this._services.notificationClient.updateToken(v);case 9:return y.next=11,this._services.mcsClient.updateToken(v);case 11:return this._fpaToken=v,y.abrupt("return",this);case 13:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getConversationBySid",value:function(){var p=te.default(P.default.mark(function w(v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._ensureReady;case 2:return _.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return _.next=6,this._conversationsEntity.getConversation(v);case 6:if(g=_.sent,g){_.next=12;break}return _.next=10,this.peekConversationBySid(v);case 10:g=_.sent,g&&Z.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");case 12:if(g){_.next=14;break}throw new Error("Conversation with SID ".concat(v," was not found."));case 14:return _.abrupt("return",g);case 15:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"peekConversationBySid",value:function(){var p=te.default(P.default.mark(function w(v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._ensureReady;case 2:return _.next=4,this._conversationsEntity.peekConversation(v);case 4:if(g=_.sent,g){_.next=7;break}throw new Error("Conversation with SID ".concat(v," was not found."));case 7:return _.abrupt("return",g);case 8:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getConversationByUniqueName",value:function(){var p=te.default(P.default.mark(function w(v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._ensureReady;case 2:return _.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return _.next=6,this._conversationsEntity.getConversationByUniqueName(v);case 6:if(g=_.sent,g){_.next=9;break}throw new Error("Conversation with unique name ".concat(v," was not found."));case 9:return _.abrupt("return",g);case 10:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getSubscribedConversations",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.abrupt("return",this._conversationsPromise.then(function(y){return y.getConversations()}));case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"createConversation",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return v=v||{},y.abrupt("return",this._conversationsPromise.then(function(_){return _.addConversation(v)}));case 4:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"setPushRegistrationId",value:function(){var p=te.default(P.default.mark(function w(v,g){return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(v),this._services.notificationClient.setPushRegistrationId(v,g),_.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return _.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"unsetPushRegistrationId",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(v),y.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"removePushRegistrations",value:function(){var p=te.default(P.default.mark(function w(v,g){return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._services.notificationClient.removeRegistrations(v,g);case 2:case"end":return _.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"handlePushNotification",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:Wt._logger.debug("handlePushNotification, notificationPayload=",v),this.emit("pushNotification",Wt.parsePushNotification(v));case 4:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getUser",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return y.abrupt("return",this._services.users.getUser(v));case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getSubscribedUsers",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getTemporaryContentUrlsForMediaSids",value:function(h){var w=this;return new Ze.CancellablePromise(function(){var v=te.default(P.default.mark(function g(y,_,S){var J,Y;return P.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:if(!(!w._services.mcsClient||!h)){me.next=3;break}return _(new Error("Media Content Service is unavailable")),me.abrupt("return");case 3:return J=w._services.mcsClient.mediaSetGetContentUrls(h),S(function(){J.cancel()}),me.prev=5,me.next=8,J;case 8:Y=me.sent,y(Y),me.next=15;break;case 12:me.prev=12,me.t0=me.catch(5),_(me.t0);case 15:case"end":return me.stop()}},g,null,[[5,12]])}));return function(g,y,_){return v.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(h){var w=h.map(function(v){return v.sid});return this.getTemporaryContentUrlsForMediaSids(w)}},{key:"getContentTemplates",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.next=4,this._services.contentClient.getContentTemplates();case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_initialize",value:function(){var p=te.default(P.default.mark(function w(){var v=this,g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return g=_.sent,this._configuration=new lr(this._options,g,Wt._logger),this._services.channelMetadataClient=new qe(this._services,this._configuration),this._services.messageRecipientsClient=new nn(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new C(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new ae(this._configuration,this._services),this._services.users=new D(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",function(S){v.emit("userSubscribed",S)}),this._services.users.on("userUpdated",function(S){return v.emit("userUpdated",S)}),this._services.users.on("userUnsubscribed",function(S){v.emit("userUnsubscribed",S)}),this._conversationsEntity=new Ur(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",function(S){v.emit("conversationAdded",S)}),this._conversationsEntity.on("conversationRemoved",function(S){v.emit("conversationRemoved",S)}),this._conversationsEntity.on("conversationJoined",function(S){v.emit("conversationJoined",S)}),this._conversationsEntity.on("conversationLeft",function(S){v.emit("conversationLeft",S)}),this._conversationsEntity.on("conversationUpdated",function(S){return v.emit("conversationUpdated",S)}),this._conversationsEntity.on("participantJoined",function(S){v.emit("participantJoined",S)}),this._conversationsEntity.on("participantLeft",function(S){v.emit("participantLeft",S)}),this._conversationsEntity.on("participantUpdated",function(S){return v.emit("participantUpdated",S)}),this._conversationsEntity.on("messageAdded",function(S){return v.emit("messageAdded",S)}),this._conversationsEntity.on("messageUpdated",function(S){return v.emit("messageUpdated",S)}),this._conversationsEntity.on("messageRemoved",function(S){return v.emit("messageRemoved",S)}),this._conversationsEntity.on("typingStarted",function(S){return v.emit("typingStarted",S)}),this._conversationsEntity.on("typingEnded",function(S){return v.emit("typingEnded",S)}),this._conversationsPromise=this._conversationsEntity.fetchConversations().then(function(){return v._conversationsEntity}).catch(function(S){throw console.error("Failed to fetch conversations _conversationsPromise -> client.ts",S),S}),_.next=30,this._services.users.myself._ensureFetched();case 30:Wt._supportedPushChannels.forEach(function(S){return v._subscribeToPushNotifications(S)}),this._services.typingIndicator.initialize(),this._services.mcsClient=new Ze.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,_n(_n({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(Wt.stateChanged,"initialized"),this.emit(Wt.initialized);case 36:case"end":return _.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_subscribeToPushNotifications",value:function(h){var w=this;[ge.NEW_MESSAGE,ge.ADDED_TO_CONVERSATION,ge.REMOVED_FROM_CONVERSATION,ge.TYPING_INDICATOR,ge.CONSUMPTION_UPDATE].forEach(function(v){w._services.notificationClient.subscribe(h,v)})}},{key:"_unsubscribeFromPushNotifications",value:function(h){var w=this;[ge.NEW_MESSAGE,ge.ADDED_TO_CONVERSATION,ge.REMOVED_FROM_CONVERSATION,ge.TYPING_INDICATOR,ge.CONSUMPTION_UPDATE].forEach(function(v){w._services.notificationClient.unsubscribe(h,v)})}},{key:"_initializeEnsureReady",value:function(h){var w=this;this._ensureReady=new Promise(function(v,g){w._resolveEnsureReady=v,w._rejectEnsureReady=g}).catch(function(v){if(h)throw v})}}],[{key:"create",value:function(){var p=te.default(P.default.mark(function w(v,g){var y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!(g!=null&&g.twilsockClient)){S.next=2;break}throw new Error("Obsolete usage of ConversationsClient.create() factory method: if you pass twilsock from the outside then you must use ConversationsClient constructor and be prepared to work with uninitialized client.");case 2:return y=new Wt(v,g),S.next=5,y._ensureReady;case 5:return S.abrupt("return",y);case 6:case"end":return S.stop()}},w)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"parsePushNotification",value:function(h){if(Wt._logger.debug("parsePushNotification, notificationPayload=",h),typeof h.aps<"u"){if(!h.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var w=Wt._parsePushNotificationChatData(h),v=h.aps,g,y=null;if(typeof v.alert=="string")g=v.alert||null;else{var _,S;g=((_=v.alert)===null||_===void 0?void 0:_.body)||null,y=((S=v.alert)===null||S===void 0?void 0:S.title)||null}return new T({title:y,body:g,sound:v.sound||null,badge:v.badge||null,action:v.category||null,type:h.twi_message_type,data:w})}if(typeof h.data<"u"){var J=h.data;if(!J.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var Y=Wt._parsePushNotificationChatData(h.data);return new T({title:J.twi_title||null,body:J.twi_body||null,sound:J.twi_sound||null,badge:null,action:J.twi_action||null,type:J.twi_message_type,data:Y})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(h){var w={};for(var v in Wt._supportedPushDataFields){var g=h[v];if(!(typeof g>"u"||g===null)){if(v==="message_index"||v==="media_count"){var y=Vt(g);y!==null&&(w[Wt._supportedPushDataFields[v]]=y);continue}if(v==="media"){if(typeof g=="string")try{w[Wt._supportedPushDataFields[v]]=JSON.parse(g)}catch{Wt._logger.debug("Media message notification parsing error")}continue}w[Wt._supportedPushDataFields[v]]=g}}return w}},{key:"populateInitRegistrations",value:function(h){h.populateInitRegistrations([ge.TYPING_INDICATOR]),Pe.SyncClient.populateInitRegistrations(h)}}]),b}(N.ReplayEventEmitter),H.default(Mt,"conversationAdded","conversationAdded"),H.default(Mt,"conversationJoined","conversationJoined"),H.default(Mt,"conversationLeft","conversationLeft"),H.default(Mt,"conversationRemoved","conversationRemoved"),H.default(Mt,"conversationUpdated","conversationUpdated"),H.default(Mt,"participantJoined","participantJoined"),H.default(Mt,"participantLeft","participantLeft"),H.default(Mt,"participantUpdated","participantUpdated"),H.default(Mt,"messageAdded","messageAdded"),H.default(Mt,"messageRemoved","messageRemoved"),H.default(Mt,"messageUpdated","messageUpdated"),H.default(Mt,"tokenAboutToExpire","tokenAboutToExpire"),H.default(Mt,"tokenExpired","tokenExpired"),H.default(Mt,"typingEnded","typingEnded"),H.default(Mt,"typingStarted","typingStarted"),H.default(Mt,"pushNotification","pushNotification"),H.default(Mt,"userSubscribed","userSubscribed"),H.default(Mt,"userUnsubscribed","userUnsubscribed"),H.default(Mt,"userUpdated","userUpdated"),H.default(Mt,"stateChanged","stateChanged"),H.default(Mt,"initialized","initialized"),H.default(Mt,"initFailed","initFailed"),H.default(Mt,"connectionStateChanged","connectionStateChanged"),H.default(Mt,"connectionError","connectionError"),H.default(Mt,"version",$),H.default(Mt,"_logger",Kt.scope("Client")),H.default(Mt,"_supportedPushChannels",["fcm","apn"]),H.default(Mt,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),Mt),Ue([Z.deprecated("token"),be("design:type",String),be("design:paramtypes",[])],t.Client.prototype,"token",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"updateToken",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getConversationBySid",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"peekConversationBySid",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getConversationByUniqueName",null),Ue([k.validateTypesAsync(["undefined",k.objectSchema("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],t.Client.prototype,"createConversation",null),Ue([k.validateTypesAsync(k.literal("fcm","apn"),"string"),be("design:type",Function),be("design:paramtypes",[String,String]),be("design:returntype",Promise)],t.Client.prototype,"setPushRegistrationId",null),Ue([k.validateTypesAsync(k.literal("fcm","apn")),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"unsetPushRegistrationId",null),Ue([k.validateTypesAsync(k.literal("fcm","apn"),k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String,String]),be("design:returntype",Promise)],t.Client.prototype,"removePushRegistrations",null),Ue([k.validateTypesAsync(k.pureObject),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],t.Client.prototype,"handlePushNotification",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getUser",null),Ue([k.validateTypesAsync(k.nonEmptyArray("strings","string")),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Ze.CancellablePromise)],t.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),Ue([k.validateTypesAsync(k.nonEmptyArray("media",ct)),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Ze.CancellablePromise)],t.Client.prototype,"getTemporaryContentUrlsForMedia",null),Ue([Z.deprecated("Client.create()","new Client()"),k.validateTypesAsync("string",["undefined",k.pureObject]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Promise)],t.Client,"create",null),Ue([k.validateTypes(k.pureObject),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",T)],t.Client,"parsePushNotification",null),t.Client=Wt=Ue([k.validateConstructorTypes(k.nonEmptyString,[k.pureObject,"undefined"]),be("design:paramtypes",[String,Object])],t.Client),Object.defineProperty(t,"CancellablePromise",{enumerable:!0,get:function(){return Ze.CancellablePromise}}),t.AggregatedDeliveryReceipt=ut,t.ChannelMetadata=ve,t.ContentTemplate=Dt,t.ContentTemplateVariable=xt,t.Conversation=R,t.DetailedDeliveryReceipt=Et,t.EmailRecipientDescriptor=Fr,t.Media=ct,t.Message=Jr,t.MessageBuilder=Nr,t.NotificationTypes=ge,t.Participant=G,t.PushNotification=T,t.RestPaginator=ft,t.UnknownRecipientDescriptor=Gr,t.UnsentMessage=Rn,t.User=Ee})(L_);const dre=nl({__proto__:null},[L_]);Lo.AnyChatWidget=h4,Object.defineProperty(Lo,Symbol.toStringTag,{value:"Module"})});
1314
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var w=!0,v=!1,g;return{s:function(){b=b.call(E)},n:function(){var _=b.next();return w=_.done,_},e:function(_){v=!0,g=_},f:function(){try{!w&&b.return!=null&&b.return()}finally{if(v)throw g}}}}function Pr(E,x){if(E){if(typeof E=="string")return Yt(E,x);var b=Object.prototype.toString.call(E).slice(8,-1);if(b==="Object"&&E.constructor&&(b=E.constructor.name),b==="Map"||b==="Set")return Array.from(E);if(b==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(b))return Yt(E,x)}}function Yt(E,x){(x==null||x>E.length)&&(x=E.length);for(var b=0,p=new Array(x);b<x;b++)p[b]=E[b];return p}var Fr=ye.default(function E(x){ke.default(this,E),H.default(this,"type","email"),this.messageSid=x.message_sid,this.level=x.level,this.name=x.name,this.address=x.address}),Gr=ye.default(function E(x){ke.default(this,E),this.type=x.type,this.messageSid=x.message_sid,this.rawData=JSON.stringify(x)}),nn=function(){function E(x,b){ke.default(this,E),this._services=x,this._configuration=b,this._cache=new F({maxSize:b.messageRecipientsCacheCapacity})}return ye.default(E,[{key:"getRecipientsFromMessage",value:function(){var x=te.default(P.default.mark(function p(h,w){var v=this,g,y,_,S,J;return P.default.wrap(function(le){for(;;)switch(le.prev=le.next){case 0:if(g="".concat(h,",").concat(w),y=this._cache.get(g),!y){le.next=4;break}return le.abrupt("return",y.item);case 4:return _=new V(this._configuration.links.conversations).path(h).path("MessageRecipients").arg("MessageSid",w).build(),le.next=7,this._services.commandExecutor.fetchResource(_);case 7:return S=le.sent,J=S.message_recipients.map(function(me){return v._wrapResponse(me)}),J.length>0&&this._cache.set(g,{item:J}),le.abrupt("return",J);case 11:case"end":return le.stop()}},p,this)}));function b(p,h){return x.apply(this,arguments)}return b}()},{key:"getRecipientsFromConversation",value:function(){var x=te.default(P.default.mark(function p(h,w){var v,g,y=this,_,S,J,Y,le,me,pt,Tt,zt,Jt;return P.default.wrap(function(pr){for(;;)switch(pr.prev=pr.next){case 0:return _=new V(this._configuration.links.conversations).path(h).path("MessageRecipients").arg("PageToken",(v=w==null?void 0:w.pageToken)!==null&&v!==void 0?v:void 0).arg("PageSize",(g=w==null?void 0:w.pageSize)!==null&&g!==void 0?g:void 0).build(),pr.next=3,this._services.commandExecutor.fetchResource(_);case 3:S=pr.sent,J=S.message_recipients.map(function(Zt){return y._wrapResponse(Zt)}),Y=bt(J);try{for(Y.s();!(le=Y.n()).done;)Tt=le.value,zt="".concat(h,",").concat(Tt.messageSid),Jt=(me=(pt=this._cache.get(zt))===null||pt===void 0?void 0:pt.item)!==null&&me!==void 0?me:[],this._cache.set(zt,{item:[].concat(tt.default(Jt),[Tt])})}catch(Zt){Y.e(Zt)}finally{Y.f()}return pr.abrupt("return",new ft(J,function(Zt,hi){return y.getRecipientsFromConversation(h,{pageToken:Zt,pageSize:hi})},S.meta.previous_token,S.meta.next_token));case 8:case"end":return pr.stop()}},p,this)}));function b(p,h){return x.apply(this,arguments)}return b}()},{key:"_wrapResponse",value:function(b){switch(b.type){case"email":return new Fr(b);default:return new Gr(b)}}}]),E}(),Mt;function wn(E,x){var b=Object.keys(E);if(Object.getOwnPropertySymbols){var p=Object.getOwnPropertySymbols(E);x&&(p=p.filter(function(h){return Object.getOwnPropertyDescriptor(E,h).enumerable})),b.push.apply(b,p)}return b}function _n(E){for(var x=1;x<arguments.length;x++){var b=arguments[x]!=null?arguments[x]:{};x%2?wn(Object(b),!0).forEach(function(p){H.default(E,p,b[p])}):Object.getOwnPropertyDescriptors?Object.defineProperties(E,Object.getOwnPropertyDescriptors(b)):wn(Object(b)).forEach(function(p){Object.defineProperty(E,p,Object.getOwnPropertyDescriptor(b,p))})}return E}function dn(E){var x=zn();return function(){var p=Se.default(E),h;if(x){var w=Se.default(this).constructor;h=Reflect.construct(p,arguments,w)}else h=p.apply(this,arguments);return ne.default(this,h)}}function zn(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}var Wt,ua=ye.default(function E(){ke.default(this,E)});t.Client=Wt=(Mt=function(E){q.default(b,E);var x=dn(b);function b(p){var h,w,v,g,y,_,S=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(ke.default(this,b),_=x.call(this),H.default(oe.default(_),"version",$),H.default(oe.default(_),"connectionState","unknown"),H.default(oe.default(_),"parsePushNotification",Wt.parsePushNotification),_._fpaToken=p??"",_._options=S??{},!_._options.disableDeepClone){var J=_n(_n({},_._options),{},{transport:void 0,twilsockClient:void 0});J=cr(J),J.transport=_._options.transport,J.twilsockClient=_._options.twilsockClient,_._options=J}_._options.logLevel=(h=_._options.logLevel)!==null&&h!==void 0?h:"silent",Wt._logger.setLevel(_._options.logLevel);var Y=_._options.productId="ip_messaging";if(_._options.clientMetadata=_._options.clientMetadata||{},_._options.clientMetadata.hasOwnProperty("type")||(_._options.clientMetadata.type="conversations"),_._options.clientMetadata.hasOwnProperty("sdk")||(_._options.clientMetadata.sdk="JS",_._options.clientMetadata.sdkv=$),_._options.Sync=_._options.Sync||{},typeof _._options.Sync.enableSessionStorage>"u"&&(_._options.Sync.enableSessionStorage=!0),_._options.region&&(_._options.Sync.region=_._options.region),!p)throw new Error("A valid Twilio token should be provided");_._services=new ua,_._myself=new Ee("","",null,_._services);var le=!_._options.twilsockClient;if(!_._options.initRegistrations){var me=new Oe.InitRegistration(Y);Wt.populateInitRegistrations(me),_._options.initRegistrations=[me]}_._services.twilsockClient=_._options.twilsockClient=(w=_._options.twilsockClient)!==null&&w!==void 0?w:new Oe.TwilsockClient(p,Y,_._options),_._services.twilsockClient.on(Wt.tokenAboutToExpire,function(){return _.emit(Wt.tokenAboutToExpire)}),_._services.twilsockClient.on(Wt.tokenExpired,function(){return _.emit(Wt.tokenExpired)}),_._services.twilsockClient.on(Wt.connectionError,function(pr){return _.emit(Wt.connectionError,pr)}),_._services.twilsockClient.on("stateChanged",function(pr){Wt._logger.debug("Handling stateChanged for ConversationsClient: new state ".concat(pr)),pr!==_.connectionState&&(_.connectionState=pr,_.emit(Wt.connectionStateChanged,_.connectionState))}),_._services.transport=_._options.transport=(v=_._options.transport)!==null&&v!==void 0?v:_._options.twilsockClient,_._services.notificationClient=_._options.notificationsClient=(g=_._options.notificationsClient)!==null&&g!==void 0?g:new Fe.Notifications(p,_._options),_._services.syncClient=_._options.syncClient=(y=_._options.syncClient)!==null&&y!==void 0?y:new Pe.SyncClient(p,_._options);var pt=(S==null?void 0:S.Chat)||(S==null?void 0:S.IPMessaging)||S||{},Tt=pt.region||(S==null?void 0:S.region),zt=pt.apiUri||pt.typingUri||"https://aim.".concat(Tt||"us1",".twilio.com");_._services.commandExecutor=new fn(zt,{transport:_._options.transport},Y),_._services.contentClient=new Pi(_._services);var Jt=function(Zt){_._rejectEnsureReady(Zt),_.emit(Wt.stateChanged,"failed"),_.emit(Wt.initFailed,{error:Zt})},br=function(){Jt({terminal:!0,message:"Twilsock has disconnected."}),_._initializeEnsureReady((S==null?void 0:S.throwErrorsAlways)||!1)};return _._services.twilsockClient.once("connectionError",Jt),_._services.twilsockClient.once("disconnected",br),_._services.twilsockClient.once("connected",te.default(P.default.mark(function pr(){var Zt,hi;return P.default.wrap(function(Nt){for(;;)switch(Nt.prev=Nt.next){case 0:return Wt._logger.debug("ConversationsClient started INITIALIZING"),_._services.twilsockClient.off("connectionError",Jt),_._services.twilsockClient.off("disconnected",br),Nt.prev=3,Zt="conversations.client.startup",_._services.twilsockClient.addPartialTelemetryEvent(new Oe.TelemetryEventDescription(Zt,"Conversations client startup",new Date),Zt,Oe.TelemetryPoint.Start),Nt.next=8,_._initialize();case 8:_._services.twilsockClient.addPartialTelemetryEvent(new Oe.TelemetryEventDescription("","",new Date),Zt,Oe.TelemetryPoint.End),Nt.next=17;break;case 11:Nt.prev=11,Nt.t0=Nt.catch(3),hi={terminal:!0,message:Nt.t0.message},_._rejectEnsureReady(hi),_.emit(Wt.stateChanged,"failed"),_.emit(Wt.initFailed,{error:hi});case 17:case"end":return Nt.stop()}},pr,null,[[3,11]])}))),_._initializeEnsureReady((S==null?void 0:S.throwErrorsAlways)||!1),le&&_._services.twilsockClient.connect(),_}return ye.default(b,[{key:"user",get:function(){return this._myself}},{key:"reachabilityEnabled",get:function(){if(!this._configuration)throw new Error("Reachability information could not yet be accessed as the client has not yet been initialized. Subscribe to the 'stateChanged' event to properly react to the client initialization.");return this._configuration.reachabilityEnabled}},{key:"token",get:function(){return this._fpaToken}},{key:"shutdown",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.next=4,this._services.twilsockClient.disconnect();case 4:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"updateToken",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:if(Wt._logger.info("updateToken"),this._fpaToken!==v){y.next=5;break}return y.abrupt("return",this);case 5:return y.next=7,this._services.twilsockClient.updateToken(v);case 7:return y.next=9,this._services.notificationClient.updateToken(v);case 9:return y.next=11,this._services.mcsClient.updateToken(v);case 11:return this._fpaToken=v,y.abrupt("return",this);case 13:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getConversationBySid",value:function(){var p=te.default(P.default.mark(function w(v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._ensureReady;case 2:return _.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return _.next=6,this._conversationsEntity.getConversation(v);case 6:if(g=_.sent,g){_.next=12;break}return _.next=10,this.peekConversationBySid(v);case 10:g=_.sent,g&&Z.deprecationWarning("The method getConversationBySid is deprecated to retrieve conversations you're not part of. Use peekConversationBySid instead.");case 12:if(g){_.next=14;break}throw new Error("Conversation with SID ".concat(v," was not found."));case 14:return _.abrupt("return",g);case 15:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"peekConversationBySid",value:function(){var p=te.default(P.default.mark(function w(v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._ensureReady;case 2:return _.next=4,this._conversationsEntity.peekConversation(v);case 4:if(g=_.sent,g){_.next=7;break}throw new Error("Conversation with SID ".concat(v," was not found."));case 7:return _.abrupt("return",g);case 8:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getConversationByUniqueName",value:function(){var p=te.default(P.default.mark(function w(v){var g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._ensureReady;case 2:return _.next=4,this._conversationsEntity.myConversationsRead.promise;case 4:return _.next=6,this._conversationsEntity.getConversationByUniqueName(v);case 6:if(g=_.sent,g){_.next=9;break}throw new Error("Conversation with unique name ".concat(v," was not found."));case 9:return _.abrupt("return",g);case 10:case"end":return _.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getSubscribedConversations",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.abrupt("return",this._conversationsPromise.then(function(y){return y.getConversations()}));case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"createConversation",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return v=v||{},y.abrupt("return",this._conversationsPromise.then(function(_){return _.addConversation(v)}));case 4:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"setPushRegistrationId",value:function(){var p=te.default(P.default.mark(function w(v,g){return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._ensureReady;case 2:return this._subscribeToPushNotifications(v),this._services.notificationClient.setPushRegistrationId(v,g),_.next=6,this._services.notificationClient.commitChanges();case 6:case"end":return _.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"unsetPushRegistrationId",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return this._unsubscribeFromPushNotifications(v),y.next=5,this._services.notificationClient.commitChanges();case 5:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"removePushRegistrations",value:function(){var p=te.default(P.default.mark(function w(v,g){return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._services.notificationClient.removeRegistrations(v,g);case 2:case"end":return _.stop()}},w,this)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"handlePushNotification",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:Wt._logger.debug("handlePushNotification, notificationPayload=",v),this.emit("pushNotification",Wt.parsePushNotification(v));case 4:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getUser",value:function(){var p=te.default(P.default.mark(function w(v){return P.default.wrap(function(y){for(;;)switch(y.prev=y.next){case 0:return y.next=2,this._ensureReady;case 2:return y.abrupt("return",this._services.users.getUser(v));case 3:case"end":return y.stop()}},w,this)}));function h(w){return p.apply(this,arguments)}return h}()},{key:"getSubscribedUsers",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.abrupt("return",this._services.users.getSubscribedUsers());case 3:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"getTemporaryContentUrlsForMediaSids",value:function(h){var w=this;return new Ze.CancellablePromise(function(){var v=te.default(P.default.mark(function g(y,_,S){var J,Y;return P.default.wrap(function(me){for(;;)switch(me.prev=me.next){case 0:if(!(!w._services.mcsClient||!h)){me.next=3;break}return _(new Error("Media Content Service is unavailable")),me.abrupt("return");case 3:return J=w._services.mcsClient.mediaSetGetContentUrls(h),S(function(){J.cancel()}),me.prev=5,me.next=8,J;case 8:Y=me.sent,y(Y),me.next=15;break;case 12:me.prev=12,me.t0=me.catch(5),_(me.t0);case 15:case"end":return me.stop()}},g,null,[[5,12]])}));return function(g,y,_){return v.apply(this,arguments)}}())}},{key:"getTemporaryContentUrlsForMedia",value:function(h){var w=h.map(function(v){return v.sid});return this.getTemporaryContentUrlsForMediaSids(w)}},{key:"getContentTemplates",value:function(){var p=te.default(P.default.mark(function w(){return P.default.wrap(function(g){for(;;)switch(g.prev=g.next){case 0:return g.next=2,this._ensureReady;case 2:return g.next=4,this._services.contentClient.getContentTemplates();case 4:return g.abrupt("return",g.sent);case 5:case"end":return g.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_initialize",value:function(){var p=te.default(P.default.mark(function w(){var v=this,g;return P.default.wrap(function(_){for(;;)switch(_.prev=_.next){case 0:return _.next=2,this._services.commandExecutor.fetchResource("Client/v2/Configuration");case 2:return g=_.sent,this._configuration=new lr(this._options,g,Wt._logger),this._services.channelMetadataClient=new qe(this._services,this._configuration),this._services.messageRecipientsClient=new nn(this._services,this._configuration),this._myself._resolveInitialization(this._configuration,this._configuration.userIdentity,this._configuration.userInfo,!0),this._services.typingIndicator=new C(this.getConversationBySid.bind(this),this._configuration,this._services),this._services.network=new ae(this._configuration,this._services),this._services.users=new D(this._myself,this._configuration,this._services),this._services.users.on("userSubscribed",function(S){v.emit("userSubscribed",S)}),this._services.users.on("userUpdated",function(S){return v.emit("userUpdated",S)}),this._services.users.on("userUnsubscribed",function(S){v.emit("userUnsubscribed",S)}),this._conversationsEntity=new Ur(this._configuration,this._services),this._conversationsEntity.on("conversationAdded",function(S){v.emit("conversationAdded",S)}),this._conversationsEntity.on("conversationRemoved",function(S){v.emit("conversationRemoved",S)}),this._conversationsEntity.on("conversationJoined",function(S){v.emit("conversationJoined",S)}),this._conversationsEntity.on("conversationLeft",function(S){v.emit("conversationLeft",S)}),this._conversationsEntity.on("conversationUpdated",function(S){return v.emit("conversationUpdated",S)}),this._conversationsEntity.on("participantJoined",function(S){v.emit("participantJoined",S)}),this._conversationsEntity.on("participantLeft",function(S){v.emit("participantLeft",S)}),this._conversationsEntity.on("participantUpdated",function(S){return v.emit("participantUpdated",S)}),this._conversationsEntity.on("messageAdded",function(S){return v.emit("messageAdded",S)}),this._conversationsEntity.on("messageUpdated",function(S){return v.emit("messageUpdated",S)}),this._conversationsEntity.on("messageRemoved",function(S){return v.emit("messageRemoved",S)}),this._conversationsEntity.on("typingStarted",function(S){return v.emit("typingStarted",S)}),this._conversationsEntity.on("typingEnded",function(S){return v.emit("typingEnded",S)}),this._conversationsPromise=this._conversationsEntity.fetchConversations().then(function(){return v._conversationsEntity}).catch(function(S){throw console.error("Failed to fetch conversations _conversationsPromise -> client.ts",S),S}),_.next=30,this._services.users.myself._ensureFetched();case 30:Wt._supportedPushChannels.forEach(function(S){return v._subscribeToPushNotifications(S)}),this._services.typingIndicator.initialize(),this._services.mcsClient=new Ze.McsClient(this._fpaToken,this._configuration.links.mediaService,this._configuration.links.mediaSetService,_n(_n({},this._options),{},{transport:void 0})),this._resolveEnsureReady(),this.emit(Wt.stateChanged,"initialized"),this.emit(Wt.initialized);case 36:case"end":return _.stop()}},w,this)}));function h(){return p.apply(this,arguments)}return h}()},{key:"_subscribeToPushNotifications",value:function(h){var w=this;[ge.NEW_MESSAGE,ge.ADDED_TO_CONVERSATION,ge.REMOVED_FROM_CONVERSATION,ge.TYPING_INDICATOR,ge.CONSUMPTION_UPDATE].forEach(function(v){w._services.notificationClient.subscribe(h,v)})}},{key:"_unsubscribeFromPushNotifications",value:function(h){var w=this;[ge.NEW_MESSAGE,ge.ADDED_TO_CONVERSATION,ge.REMOVED_FROM_CONVERSATION,ge.TYPING_INDICATOR,ge.CONSUMPTION_UPDATE].forEach(function(v){w._services.notificationClient.unsubscribe(h,v)})}},{key:"_initializeEnsureReady",value:function(h){var w=this;this._ensureReady=new Promise(function(v,g){w._resolveEnsureReady=v,w._rejectEnsureReady=g}).catch(function(v){if(h)throw v})}}],[{key:"create",value:function(){var p=te.default(P.default.mark(function w(v,g){var y;return P.default.wrap(function(S){for(;;)switch(S.prev=S.next){case 0:if(!(g!=null&&g.twilsockClient)){S.next=2;break}throw new Error("Obsolete usage of ConversationsClient.create() factory method: if you pass twilsock from the outside then you must use ConversationsClient constructor and be prepared to work with uninitialized client.");case 2:return y=new Wt(v,g),S.next=5,y._ensureReady;case 5:return S.abrupt("return",y);case 6:case"end":return S.stop()}},w)}));function h(w,v){return p.apply(this,arguments)}return h}()},{key:"parsePushNotification",value:function(h){if(Wt._logger.debug("parsePushNotification, notificationPayload=",h),typeof h.aps<"u"){if(!h.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var w=Wt._parsePushNotificationChatData(h),v=h.aps,g,y=null;if(typeof v.alert=="string")g=v.alert||null;else{var _,S;g=((_=v.alert)===null||_===void 0?void 0:_.body)||null,y=((S=v.alert)===null||S===void 0?void 0:S.title)||null}return new T({title:y,body:g,sound:v.sound||null,badge:v.badge||null,action:v.category||null,type:h.twi_message_type,data:w})}if(typeof h.data<"u"){var J=h.data;if(!J.twi_message_type)throw new Error("Provided push notification payload does not contain Programmable Chat push notification type");var Y=Wt._parsePushNotificationChatData(h.data);return new T({title:J.twi_title||null,body:J.twi_body||null,sound:J.twi_sound||null,badge:null,action:J.twi_action||null,type:J.twi_message_type,data:Y})}throw new Error("Provided push notification payload is not Programmable Chat notification")}},{key:"_parsePushNotificationChatData",value:function(h){var w={};for(var v in Wt._supportedPushDataFields){var g=h[v];if(!(typeof g>"u"||g===null)){if(v==="message_index"||v==="media_count"){var y=Vt(g);y!==null&&(w[Wt._supportedPushDataFields[v]]=y);continue}if(v==="media"){if(typeof g=="string")try{w[Wt._supportedPushDataFields[v]]=JSON.parse(g)}catch{Wt._logger.debug("Media message notification parsing error")}continue}w[Wt._supportedPushDataFields[v]]=g}}return w}},{key:"populateInitRegistrations",value:function(h){h.populateInitRegistrations([ge.TYPING_INDICATOR]),Pe.SyncClient.populateInitRegistrations(h)}}]),b}(N.ReplayEventEmitter),H.default(Mt,"conversationAdded","conversationAdded"),H.default(Mt,"conversationJoined","conversationJoined"),H.default(Mt,"conversationLeft","conversationLeft"),H.default(Mt,"conversationRemoved","conversationRemoved"),H.default(Mt,"conversationUpdated","conversationUpdated"),H.default(Mt,"participantJoined","participantJoined"),H.default(Mt,"participantLeft","participantLeft"),H.default(Mt,"participantUpdated","participantUpdated"),H.default(Mt,"messageAdded","messageAdded"),H.default(Mt,"messageRemoved","messageRemoved"),H.default(Mt,"messageUpdated","messageUpdated"),H.default(Mt,"tokenAboutToExpire","tokenAboutToExpire"),H.default(Mt,"tokenExpired","tokenExpired"),H.default(Mt,"typingEnded","typingEnded"),H.default(Mt,"typingStarted","typingStarted"),H.default(Mt,"pushNotification","pushNotification"),H.default(Mt,"userSubscribed","userSubscribed"),H.default(Mt,"userUnsubscribed","userUnsubscribed"),H.default(Mt,"userUpdated","userUpdated"),H.default(Mt,"stateChanged","stateChanged"),H.default(Mt,"initialized","initialized"),H.default(Mt,"initFailed","initFailed"),H.default(Mt,"connectionStateChanged","connectionStateChanged"),H.default(Mt,"connectionError","connectionError"),H.default(Mt,"version",$),H.default(Mt,"_logger",Kt.scope("Client")),H.default(Mt,"_supportedPushChannels",["fcm","apn"]),H.default(Mt,"_supportedPushDataFields",{conversation_sid:"conversationSid",conversation_title:"conversationTitle",message_sid:"messageSid",message_index:"messageIndex",media_count:"mediaCount",media:"media"}),Mt),Ue([Z.deprecated("token"),be("design:type",String),be("design:paramtypes",[])],t.Client.prototype,"token",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"updateToken",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getConversationBySid",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"peekConversationBySid",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getConversationByUniqueName",null),Ue([k.validateTypesAsync(["undefined",k.objectSchema("conversation options",{friendlyName:["string","undefined"],isPrivate:["boolean","undefined"],uniqueName:["string","undefined"]})]),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],t.Client.prototype,"createConversation",null),Ue([k.validateTypesAsync(k.literal("fcm","apn"),"string"),be("design:type",Function),be("design:paramtypes",[String,String]),be("design:returntype",Promise)],t.Client.prototype,"setPushRegistrationId",null),Ue([k.validateTypesAsync(k.literal("fcm","apn")),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"unsetPushRegistrationId",null),Ue([k.validateTypesAsync(k.literal("fcm","apn"),k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String,String]),be("design:returntype",Promise)],t.Client.prototype,"removePushRegistrations",null),Ue([k.validateTypesAsync(k.pureObject),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",Promise)],t.Client.prototype,"handlePushNotification",null),Ue([k.validateTypesAsync(k.nonEmptyString),be("design:type",Function),be("design:paramtypes",[String]),be("design:returntype",Promise)],t.Client.prototype,"getUser",null),Ue([k.validateTypesAsync(k.nonEmptyArray("strings","string")),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Ze.CancellablePromise)],t.Client.prototype,"getTemporaryContentUrlsForMediaSids",null),Ue([k.validateTypesAsync(k.nonEmptyArray("media",ct)),be("design:type",Function),be("design:paramtypes",[Array]),be("design:returntype",Ze.CancellablePromise)],t.Client.prototype,"getTemporaryContentUrlsForMedia",null),Ue([Z.deprecated("Client.create()","new Client()"),k.validateTypesAsync("string",["undefined",k.pureObject]),be("design:type",Function),be("design:paramtypes",[String,Object]),be("design:returntype",Promise)],t.Client,"create",null),Ue([k.validateTypes(k.pureObject),be("design:type",Function),be("design:paramtypes",[Object]),be("design:returntype",T)],t.Client,"parsePushNotification",null),t.Client=Wt=Ue([k.validateConstructorTypes(k.nonEmptyString,[k.pureObject,"undefined"]),be("design:paramtypes",[String,Object])],t.Client),Object.defineProperty(t,"CancellablePromise",{enumerable:!0,get:function(){return Ze.CancellablePromise}}),t.AggregatedDeliveryReceipt=ut,t.ChannelMetadata=ve,t.ContentTemplate=Dt,t.ContentTemplateVariable=xt,t.Conversation=R,t.DetailedDeliveryReceipt=Et,t.EmailRecipientDescriptor=Fr,t.Media=ct,t.Message=Jr,t.MessageBuilder=Nr,t.NotificationTypes=ge,t.Participant=G,t.PushNotification=T,t.RestPaginator=ft,t.UnknownRecipientDescriptor=Gr,t.UnsentMessage=Rn,t.User=Ee})(L_);const dre=nl({__proto__:null},[L_]);Lo.AnyChatWidget=h4,Object.defineProperty(Lo,Symbol.toStringTag,{value:"Module"})});